npm package: @kirinnee/weave
Description: Scaffolding CLI to generate web templates
Author: kirinnee
Latest version: 0.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

1. Install npm or node on your machine

2. Install binary using npm

```shell
$ npm i @kirinnee/weave -g
```

3. 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:
```javascript
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~~` to `kirinnee`
* `w~~weave.email~~` to `kirinnee@gmail.com`
* `w~~weave.description.short~~` to `short des`
* `w~~weave.description.long~~` to `Very 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:

```javascript
wflags = {
	unitTest:false,
	e2eTest: true
}
```

and the following piece of code:
```c#
public static RunTest(string test){
	unitTest.execute(test); // flag~~wflags.unitTest~~
	e2eTest.execute(test); //flag~~wflags.e2eTest~~
}
```

will be transpiled to 
```c#
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

```javascript

wflags = {
	useShould: true,
	useExpect: false,
}

```
 and the following code:
```typescript
// 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
```typescript
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: 
```javascript
wflag = {
	package:{
		"@types/chai": false,
		"chai": false,
		"@types/mocha": true,
		"mocha": true
	}
}
```
and the following package.json:
```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 
```json
{
  "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
1. Block Flags
2. Line Injection Flags
3. Variable Replacement
4. package.json

# Community

## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.MD) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning
We use [SemVer](https://semver.org/) 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](LICENSE.MD) file for details