tada: Initial commit
This commit is contained in:
parent
329633bdf6
commit
477b47f8eb
12 changed files with 10340 additions and 1 deletions
10
packages/plugin-sprinkle/.babelrc
Normal file
10
packages/plugin-sprinkle/.babelrc
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"useBuiltIns": "entry"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
13
packages/plugin-sprinkle/.editorconfig
Normal file
13
packages/plugin-sprinkle/.editorconfig
Normal 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-sprinkle/.gitignore
vendored
Normal file
62
packages/plugin-sprinkle/.gitignore
vendored
Normal 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
|
4
packages/plugin-sprinkle/.npmignore
Normal file
4
packages/plugin-sprinkle/.npmignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
src
|
||||
.editorconfig
|
||||
rollup.browser.js
|
||||
rollup.node.js
|
21
packages/plugin-sprinkle/LICENSE
Normal file
21
packages/plugin-sprinkle/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Joost De Cock
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,2 +1,63 @@
|
|||
<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> <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>
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/freesewing/plugin-sprinkle"><img src="https://badgen.net/travis/freesewing/plugin-sprinkle/master" alt="Travis build"></a>
|
||||
<a href="https://www.npmjs.com/package/@freesewing/plugin-sprinkle"><img src="https://badgen.net/npm/v/@freesewing/plugin-sprinkle" alt="Version"></a>
|
||||
<a href="https://www.npmjs.com/package/@freesewing/plugin-sprinkle"><img src="https://badgen.net/npm/license/@freesewing/plugin-sprinkle" alt="License"></a>
|
||||
<a href="https://codecov.io/gh/freesewing/plugin-sprinkle"><img src="https://badgen.net/codecov/c/github/freesewing/plugin-sprinkle/master" alt="Code coverage"></a>
|
||||
<a href="https://deepscan.io/dashboard#view=project&pid=3267&bid=27574"><img src="https://deepscan.io/api/projects/3267/branches/27574/badge/grade.svg" alt="DeepScan grade"></a>
|
||||
<a href="https://gitter.im/freesewing/freesewing"><img src="https://badgen.net/badge/chat/on%20Gitter/cyan" alt="Chat on Gitter"></a>
|
||||
<a href="https://freesewing.org/patrons/join"><img src="https://badgen.net/badge/become/a%20Patron/FF5B77" alt="Become a Patron"></a>
|
||||
</p>
|
||||
|
||||
# plugin-sprinkle
|
||||
A plugin to bulk-add snippets to your pattern
|
||||
|
||||
A freesewing plugin to bulk-add multiple snippets to your pattern.
|
||||
|
||||
Typically used to add a bunch of notches, buttons, and so on.
|
||||
|
||||
## Install
|
||||
|
||||
Install this plugin from NPM:
|
||||
|
||||
```sh
|
||||
npm install --save @freesewing/plugin-sprinkle
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To load this plugin, add it to your instantiated pattern:
|
||||
|
||||
```js
|
||||
import freesewing from 'freesewing'
|
||||
import sprinkle from '@freesewing/plugin-sprinkle'
|
||||
|
||||
const Simon = function(settings) {
|
||||
freesewing.Pattern.call(this, config);
|
||||
this
|
||||
.use(sprinkle)
|
||||
.apply(settings);
|
||||
|
||||
return this;
|
||||
}
|
||||
```
|
||||
|
||||
You now have the `sprinkle` macro available:
|
||||
|
||||
```js
|
||||
macro("sprinkle", {
|
||||
snippet: "notch",
|
||||
on: ["pointA", "pointB", "pointC"]
|
||||
});
|
||||
```
|
||||
|
||||
FIXME: Link to documentation
|
||||
|
||||
## Where to get help
|
||||
|
||||
Questions? Stuck? The [freesewing chat room on Gitter](https://gitter.im/freesewing/freesewing)
|
||||
is the best place to ask for help.
|
||||
|
|
BIN
packages/plugin-sprinkle/img/example.png
Normal file
BIN
packages/plugin-sprinkle/img/example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 79 KiB |
10030
packages/plugin-sprinkle/package-lock.json
generated
Normal file
10030
packages/plugin-sprinkle/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
79
packages/plugin-sprinkle/package.json
Normal file
79
packages/plugin-sprinkle/package.json
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"name": "@freesewing/plugin-sprinkle",
|
||||
"version": "0.0.1",
|
||||
"description": "A freesewing plugin to bulk-add snippets to your pattern",
|
||||
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/freesewing/plugin-sprinkle#readme",
|
||||
"repository": "github:freesewing/plugin-sprinkle",
|
||||
"bugs": {
|
||||
"url": "https://github.com/freesewing/plugin-sprinkle/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"freesewing",
|
||||
"plugin",
|
||||
"sewing patterns",
|
||||
"snippets"
|
||||
],
|
||||
"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": "nyc mocha --require @babel/register tests/*.test.js",
|
||||
"report": "nyc report --reporter=html mocha --require @babel/register tests/*.test.js",
|
||||
"coverage": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && ./node_modules/.bin/codecov",
|
||||
"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.sprinkle",
|
||||
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs",
|
||||
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es",
|
||||
"rebuild": "npm run nodebuild && npm run modulebuild",
|
||||
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/*.{js,json}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"chai": "^4.1.2",
|
||||
"chai-string": "1.4.0",
|
||||
"codecov": "^3.1.0",
|
||||
"eslint": "^5.2.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-plugin-prettier": "^2.6.2",
|
||||
"freesewing": "^0.26.1",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.2.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "12.0.2",
|
||||
"prettier": "^1.13.7",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup": "^0.66.2",
|
||||
"rollup-plugin-babel": "^4.0.3",
|
||||
"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"
|
||||
]
|
||||
}
|
27
packages/plugin-sprinkle/rollup.js
Normal file
27
packages/plugin-sprinkle/rollup.js
Normal 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 */`
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
18
packages/plugin-sprinkle/src/index.js
Normal file
18
packages/plugin-sprinkle/src/index.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { name, version } from "../package.json";
|
||||
|
||||
export default {
|
||||
name: name,
|
||||
version: version,
|
||||
hooks: {
|
||||
preRender: function(svg) {
|
||||
if (svg.attributes.get("freesewing:plugin-sprinkle") === false)
|
||||
svg.attributes.set("freesewing:plugin-sprinkle", version);
|
||||
}
|
||||
},
|
||||
macros: {
|
||||
sprinkle: function(so) {
|
||||
for (let pid of so.on)
|
||||
this.snippets[pid+"-"+so.snippet] = new this.Snippet(so.snippet, this.points[pid]);
|
||||
}
|
||||
}
|
||||
};
|
14
packages/plugin-sprinkle/tests/sprinkle.test.js
Normal file
14
packages/plugin-sprinkle/tests/sprinkle.test.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import freesewing from "freesewing";
|
||||
import { version } from "../package.json";
|
||||
let chai = require("chai");
|
||||
let expect = chai.expect;
|
||||
chai.use(require('chai-string'));
|
||||
let plugin = require("../dist/index.js");
|
||||
|
||||
it("Should set the plugin name:version attribute", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.use(plugin).draft().render();
|
||||
expect(pattern.svg.attributes.get("freesewing:plugin-sprinkle")).to.equal(
|
||||
version
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue