1
0
Fork 0

feat(config-helpers): Renamed snapseries to config-helpers

It would be useful to have a place where we can place methods
like the pctBasedOn method that we now import from core, even though
it has nothing to do with core.

So I've decided to rename this packet since it's essentially also
things that facilitate pattern configuration (files).

Since this is a very new package, and I am 100% certain that we
(FreeSewing itself) are the only ones using it, no need to major
bump this. The most recent snapseries package will remain available
for people who want to use it.

I'll update all patterns accordingly.
This commit is contained in:
Joost De Cock 2022-06-12 23:49:52 +02:00
parent b0aa9f3895
commit 447970c689
6 changed files with 70 additions and 32 deletions

View file

@ -1,12 +1,6 @@
# Change log for: @freesewing/snapseries # Change log for: @freesewing/config-helpers
## 2.19.0 (2021-10-17)
### Added
- Initial release of `@freesewing/snapseries` wich holds commonly used series of snap values for percentage options
This is the **initial release**, and the start of this change log. This is the **initial release**, and the start of this change log.

View file

@ -1,13 +1,13 @@
![FreeSewing](https://static.freesewing.org/banner.png) ![FreeSewing](https://static.freesewing.org/banner.png)
<p align='center'><a <p align='center'><a
href="https://www.npmjs.com/package/@freesewing/snapseries" href="https://www.npmjs.com/package/@freesewing/config-helpers"
title="@freesewing/snapseries on NPM" title="@freesewing/config-helpers on NPM"
><img src="https://img.shields.io/npm/v/@freesewing/snapseries.svg" ><img src="https://img.shields.io/npm/v/@freesewing/config-helpers.svg"
alt="@freesewing/snapseries on NPM"/> alt="@freesewing/config-helpers on NPM"/>
</a><a </a><a
href="https://opensource.org/licenses/MIT" href="https://opensource.org/licenses/MIT"
title="License: MIT" title="License: MIT"
><img src="https://img.shields.io/npm/l/@freesewing/snapseries.svg?label=License" ><img src="https://img.shields.io/npm/l/@freesewing/config-helpers.svg?label=License"
alt="License: MIT"/> alt="License: MIT"/>
</a><a </a><a
href="https://deepscan.io/dashboard#view=project&tid=2114&pid=2993&bid=23256" href="https://deepscan.io/dashboard#view=project&tid=2114&pid=2993&bid=23256"
@ -15,10 +15,10 @@
><img src="https://deepscan.io/api/teams/2114/projects/2993/branches/23256/badge/grade.svg" ><img src="https://deepscan.io/api/teams/2114/projects/2993/branches/23256/badge/grade.svg"
alt="Code quality on DeepScan"/> alt="Code quality on DeepScan"/>
</a><a </a><a
href="https://github.com/freesewing/freesewing/issues?q=is%3Aissue+is%3Aopen+label%3Apkg%3Asnapseries" href="https://github.com/freesewing/freesewing/issues?q=is%3Aissue+is%3Aopen+label%3Apkg%3Aconfig-helpers"
title="Open issues tagged pkg:snapseries" title="Open issues tagged pkg:config-helpers"
><img src="https://img.shields.io/github/issues/freesewing/freesewing/pkg:snapseries.svg?label=Issues" ><img src="https://img.shields.io/github/issues/freesewing/freesewing/pkg:config-helpers.svg?label=Issues"
alt="Open issues tagged pkg:snapseries"/> alt="Open issues tagged pkg:config-helpers"/>
</a><a </a><a
href="#contributors-" href="#contributors-"
title="All Contributors" title="All Contributors"
@ -46,9 +46,9 @@
alt="Follow @freesewing_org on Twitter"/> alt="Follow @freesewing_org on Twitter"/>
</a></p> </a></p>
# @freesewing/snapseries # @freesewing/config-helpers
A FreeSewing package for common values for snapped percentage options A FreeSewing package to facilitate pattern configurations
@ -57,7 +57,7 @@ A FreeSewing package for common values for snapped percentage options
This repository is our *monorepo* This repository is our *monorepo*
holding [all our NPM packages](https://freesewing.dev/reference/packages/). holding [all our NPM packages](https://freesewing.dev/reference/packages/).
This folder holds: @freesewing/snapseries This folder holds: @freesewing/config-helpers
## About FreeSewing 💀 ## About FreeSewing 💀

View file

@ -0,0 +1,33 @@
/* This script will build the package with esbuild */
const esbuild = require('esbuild')
const pkg = require('./package.json')
// Create banner based on package info
const banner = `/**
* ${pkg.name} | v${pkg.version}
* ${pkg.description}
* (c) ${new Date().getFullYear()} ${pkg.author}
* @license ${pkg.license}
*/`
// Shared esbuild options
const options = {
banner: { js: banner },
bundle: true,
entryPoints: ['src/index.js'],
minify: true,
sourcemap: true,
}
// Different formats
const formats = {
esm: "dist/index.mjs",
cjs: "dist/index.js"
}
// Let esbuild generate different formats
for (const [format, outfile] of Object.entries(formats)) esbuild
.build({ ...options, outfile, format })
.catch(() => process.exit(1))

View file

@ -1,7 +1,7 @@
{ {
"name": "@freesewing/snapseries", "name": "@freesewing/config-helpers",
"version": "2.20.8", "version": "2.20.8",
"description": "A FreeSewing package for common values for snapped percentage options", "description": "A FreeSewing package to facilitate pattern configurations",
"author": "Joost De Cock <joost@joost.at> (https://github.com/joostdecock)", "author": "Joost De Cock <joost@joost.at> (https://github.com/joostdecock)",
"homepage": "https://freesewing.org/", "homepage": "https://freesewing.org/",
"repository": "github:freesewing/freesewing", "repository": "github:freesewing/freesewing",
@ -26,13 +26,10 @@
"module": "dist/index.mjs", "module": "dist/index.mjs",
"scripts": { "scripts": {
"clean": "rimraf dist", "clean": "rimraf dist",
"build": "rollup -c", "build": "node build.js",
"cibuild_step1": "rollup -c", "cibuild_step1": "node build.js",
"test": "echo \"snapseries: No tests configured. Perhaps you'd like to do this?\" && exit 0", "test": "echo \"config-helpers: No tests configured. Perhaps you'd like to do this?\" && exit 0",
"pubtest": "npm publish --registry http://localhost:6662", "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -"
"pubforce": "npm publish",
"symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -",
"start": "rollup -c -w"
}, },
"peerDependencies": {}, "peerDependencies": {},
"dependencies": {}, "dependencies": {},
@ -47,10 +44,7 @@
"tag": "latest" "tag": "latest"
}, },
"engines": { "engines": {
"node": ">=12.0.0", "node": ">=14.0.0",
"npm": ">=6" "npm": ">=6"
},
"rollup": {
"exports": "named"
} }
} }

View file

@ -1,3 +1,8 @@
/*
* Snap series
* ==============================
*/
// Common width for elastics // Common width for elastics
export const elastics = { export const elastics = {
metric: [3.5, 5, 10, 12, 20, 25, 30, 40, 50, 60, 80, 100, 120], metric: [3.5, 5, 10, 12, 20, 25, 30, 40, 50, 60, 80, 100, 120],
@ -32,3 +37,15 @@ export const bigsteps = {
metric: 10, metric: 10,
imperial: 12.7, // 1/2 inch imperial: 12.7, // 1/2 inch
} }
/*
* Config helper methods
* ==============================
*/
export function pctBasedOn(measurement) {
return {
toAbs: (val, { measurements }) => measurements[measurement] * val,
fromAbs: (val, { measurements }) => Math.round((10 * val) / measurements[measurement]) / 10,
}
}