1
0
Fork 0

tada: First commit

This commit is contained in:
Joost De Cock 2018-08-10 16:03:39 +02:00
parent 91b768a329
commit 4081cb91d6
9 changed files with 4989 additions and 2 deletions

View file

@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

62
packages/plugin-validate/.gitignore vendored Normal file
View file

@ -0,0 +1,62 @@
dist
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next

View file

@ -0,0 +1,2 @@
src
.editorconfig

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018 freesewing Copyright (c) 2018 Joost De Cock
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,2 +1,59 @@
<p align="center">
<a title="Go to freesewing.org" href="https://freesewing.org/"><img src="https://freesewing.org/img/logo/black.svg" align="center" width="150px" alt="Freesewing logo"/></a>
</p>
<h4 align="center"><em>&nbsp;<a title="Go to freesewing.org" href="https://freesewing.org/">freesewing</a></em>
<br><sup>a library for made-to-measure sewing patterns</sup>
</h4>
# plugin-validate # plugin-validate
A freesewing plugin that checks whether all required measurements are set prior to drafting your pattern
A freesewing plugin that checks whether all required measurements are set prior to drafting your pattern.
If a measurement is missing, this will throw an exception, and tell you which measurement is missing.
## Usage
To load this plugin, add it to your instantiated pattern.
On node.js:
```js
import pattern from '@freesewing/pattern-brian'
import validate from '@freesewing/plugin-validate'
pattern.with(validate);
```
In the browser, this plugin will register as `freesewing.plugins.validate`:
```html
<script type="text/javascript" src="https://unpkg.com/freesewing"></script>
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-validate"></script>
<script type="text/javascript" src="https://unpkg.com/@freesewing/pattern-brian"></script>
<script>
var pattern = freesewing.patterns.brian
.with(freesewing.plugins.validate);
</script>
```
## Install
To install, run:
```sh
npm install @freesewing/plugin-validate
```
## Build
To build this plugin, run:
```sh
npm run build
```
## License: MIT
See [the license file](https://github.com/freesewing/plugin-validate/blob/master/LICENSE)
for details.

4738
packages/plugin-validate/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,69 @@
{
"name": "@freesewing/plugin-validate",
"version": "0.0.1",
"description": "A freesewing plugin that checks whether all required measurements are set prior to drafting your pattern ",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"homepage": "https://github.com/freesewing/plugin-validate#readme",
"repository": "github:freesewing/plugin-validate",
"bugs": {
"url": "https://github.com/freesewing/plugin-validate/issues"
},
"keywords": [
"freesewing",
"plugin",
"sewing",
"patterns",
"input-validation"
],
"main": "dist/index.js",
"unpkg": "dist/browser.js",
"module": "dist/index.mjs",
"scripts": {
"patch": "npm version patch -m ':bookmark: v%s; && npm run build",
"minor": "npm version minor -m ':bookmark: v%s; && npm run build",
"major": "npm version major -m ':bookmark: v%s; && npm run build",
"precommit": "npm run pretty && lint-staged",
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist",
"pretty": "npx prettier --write \"src/*.js\"",
"lint": "eslint --fix \"src/*.js\"",
"browserbuild": "rollup -c rollup.js --file dist/browser.js --format iife --name freesewing.plugins.validate",
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs",
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es",
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,json}": [
"prettier --write",
"git add"
]
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"eslint": "^5.2.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.2",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"prettier": "^1.13.7",
"rimraf": "^2.6.2",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-terser": "^1.0.1"
},
"files": [
"dist/*",
"README.md",
"package-lock.json",
"package.json"
]
}

View file

@ -0,0 +1,27 @@
import { terser } from "rollup-plugin-terser";
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import json from "rollup-plugin-json";
import { version, name, description, author, license } from "./package.json";
export default {
input: "src/index.js",
plugins: [
resolve({
browser: true
}),
json(),
babel({
exclude: "node_modules/**"
}),
terser({
output: {
preamble: `/**\n * ${name} | v${version}\n * ${
description
}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${
license
}\n */`
}
})
]
};

View file

@ -0,0 +1,19 @@
import { version, name } from "../package.json";
export default {
name: name,
version: version,
hooks: {
preDraft: function(next) {
for(let m in this.config.measurements) {
let measurement = this.config.measurements[m];
if(!this.context.settings.measurements[measurement]) {
this.debug('Missing measurement:', measurement);
this.debug('All measurements:', this.settings.measurements);
throw `Missing measurement: ${measurement}`;
}
}
next();
}
}
};