@kirinnee/weave v0.0.3
Weave
Weave a specific scaffolding package that ease my project starts by scaffolding templates to start working with Visual Studio 2017
Getting Started
Install npm or node on your machine
Install binary using npm
$ npm i @kirinnee/weave -g
- Execute command at target folder
$ mkdir my-infra
$ cd my-infra
$ weave
Follow through the instruction and it will generate the project for you
Templating Rules
Variable Replacement
A json weave object will replace all occurence (including file and folder name) that matches the variable:
weave = {
name: "kirinnee",
email: "kirinnee@gmail.com",
description:{
short: "short des",
long: "Very very long and informative description. Please something...",
readme: "# Get Started!!~ "
}
}
This will replace any expression, whether in name of folder, of
w~~weave.name~~
tokirinnee
w~~weave.email~~
tokirinnee@gmail.com
w~~weave.description.short~~
toshort des
w~~weave.description.long~~
toVery very long and informative description. Please something...
w~~weave.description.readme~~
to# Get Started!!~
Flag lines injection
Within the json object, flags are true or false value.
With Weave, you can inject small code into lines, either as end of line comments or make it part of the code.
Lines with these injection:
- line will be removed if injected flag is false
- line will stay, but injected code will be removed, if flag is true
Consider the Wflag object:
wflags = {
unitTest:false,
e2eTest: true
}
and the following piece of code:
public static RunTest(string test){
unitTest.execute(test); // flag~~wflags.unitTest~~
e2eTest.execute(test); //flag~~wflags.e2eTest~~
}
will be transpiled to
public static RunTest(string test){
e2eTest.execute(test); //
}
Flag Blocks
Flags can also be used to choose what choose which block of code is in or not.
The Flags will erase the line it is in regardless, but the block encapsulated within will depend on the state of the flag.
Consider the Wflag Object
wflags = {
useShould: true,
useExpect: false,
}
and the following code:
// hey lollol if~~wflag.useExpect~~ random stuff here
import {expect} from 'chai';
//end~~wflag.useExpect~~
//if~~wflag.useShould~~
import {should} from 'chai';
should();
//end~~wflag.useShould~~
describe('test',()=>{
it('should return true if 1 is equal to 1',()=>{
//if~~wflag.useShould~~
(1).should.be.equal(1);
//end~~wflag.useShould~~
// if~~wflag.useExpect~~
expect(1).to.equal(1);
// end~~wflag.useExpect~~
});
});
will be converted to
import {should} from 'chai';
should();
describe('test',()=>{
it('should return true if 1 is equal to 1',()=>{
(1).should.be.equal(1);
});
});
Package.json dependency filter
By default, you should have all packages installed, regardless. Within the wflag object, have a package object, and any key that has a flag of false will be removed from the package.json.
Consider the wflag object:
wflag = {
package:{
"@types/chai": false,
"chai": false,
"@types/mocha": true,
"mocha": true
}
}
and the following package.json:
{
"name": "some-package-name",
"version": "0.0.1",
"description": "description",
"devDependencies": {
"@babel/core": "^7.1.0",
"@types/chai": "^4.1.5",
"@types/mocha": "^5.2.5"
},
"dependencies": {
"chai": "^4.1.2",
"mocha": "^5.2.0"
}
}
will be converted to
{
"name": "some-package-name",
"version": "0.0.1",
"description": "description",
"devDependencies": {
"@babel/core": "^7.1.0",
"@types/mocha": "^5.2.5"
},
"dependencies": {
"mocha": "^5.2.0"
}
}
Do note that this does not affect peer dependency, and will only apply to package.json file name.
Order of replacement
- Block Flags
- Line Injection Flags
- Variable Replacement
- package.json
Community
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- kirinnee
License
This project is licensed under the MIT - see the LICENSE.md file for details