simple-scaffold 1.0.0-alpha.4 → 1.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -21
- package/cmd.js +2 -66
- package/cmd.js.map +1 -1
- package/cmd_util.d.ts +1 -0
- package/cmd_util.js +90 -0
- package/cmd_util.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/scaffold.js +27 -15
- package/scaffold.js.map +1 -1
- package/types.d.ts +10 -0
- package/types.js +9 -0
- package/types.js.map +1 -1
- package/utils.d.ts +3 -2
- package/utils.js +20 -4
- package/utils.js.map +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ npx simple-scaffold <...args>
|
|
|
22
22
|
```plaintext
|
|
23
23
|
Usage: simple-scaffold [options]
|
|
24
24
|
|
|
25
|
+
Create structured files based on templates.
|
|
26
|
+
|
|
25
27
|
Options:
|
|
26
28
|
|
|
27
29
|
--help|-h Display help information
|
|
@@ -35,7 +37,8 @@ Options:
|
|
|
35
37
|
|
|
36
38
|
--templates|-t Template files to use as input. You may provide multiple
|
|
37
39
|
files, each of which can be a relative or absolute path, or a glob
|
|
38
|
-
pattern for multiple file matching easily.
|
|
40
|
+
pattern for multiple file matching easily. (default:
|
|
41
|
+
)
|
|
39
42
|
|
|
40
43
|
--overwrite|-w Enable to override output files, even if they already exist.
|
|
41
44
|
(default: false)
|
|
@@ -46,19 +49,27 @@ Options:
|
|
|
46
49
|
--create-sub-folder|-s Create subfolder with the input name (default:
|
|
47
50
|
false)
|
|
48
51
|
|
|
49
|
-
--quiet|-q Suppress output logs (
|
|
50
|
-
false)
|
|
52
|
+
--quiet|-q Suppress output logs (Same as --verbose 0)
|
|
53
|
+
(default: false)
|
|
54
|
+
|
|
55
|
+
--verbose|-v Determine amount of logs to display. The values are: 0
|
|
56
|
+
(none) | 1 (debug) | 2 (info) | 3 (warn) | 4 (error). The
|
|
57
|
+
provided level will display messages of the same level or higher.
|
|
58
|
+
(default: 2)
|
|
51
59
|
|
|
52
|
-
--dry-run|-dr Don't emit
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
--dry-run|-dr Don't emit files. This is good for testing your scaffolds and
|
|
61
|
+
making sure they don't fail, without having to write actual file
|
|
62
|
+
contents or create directories. (default:
|
|
63
|
+
false)
|
|
55
64
|
```
|
|
56
65
|
|
|
57
66
|
You can also add this as a script in your `package.json`:
|
|
58
67
|
|
|
59
68
|
```json
|
|
60
69
|
{
|
|
70
|
+
...
|
|
61
71
|
"scripts": {
|
|
72
|
+
...
|
|
62
73
|
"scaffold": "yarn simple-scaffold --templates scaffolds/component/**/* --output src/components --data '{\"myProp\": \"propName\", \"myVal\": \"123\"}'"
|
|
63
74
|
}
|
|
64
75
|
}
|
|
@@ -73,7 +84,7 @@ The config takes similar arguments to the command line:
|
|
|
73
84
|
```javascript
|
|
74
85
|
const SimpleScaffold = require("simple-scaffold").default
|
|
75
86
|
|
|
76
|
-
const scaffold =
|
|
87
|
+
const scaffold = SimpleScaffold({
|
|
77
88
|
name: "component",
|
|
78
89
|
templates: [path.join(__dirname, "scaffolds", "component")],
|
|
79
90
|
output: path.join(__dirname, "src", "components"),
|
|
@@ -81,7 +92,7 @@ const scaffold = new SimpleScaffold({
|
|
|
81
92
|
locals: {
|
|
82
93
|
property: "value",
|
|
83
94
|
},
|
|
84
|
-
})
|
|
95
|
+
})
|
|
85
96
|
```
|
|
86
97
|
|
|
87
98
|
The exception in the config is that `output`, when used in Node directly, may also be passed a
|
|
@@ -90,7 +101,7 @@ function for each input file to output into a dynamic path:
|
|
|
90
101
|
```javascript
|
|
91
102
|
config.output = (fullPath, baseDir, baseName) => {
|
|
92
103
|
console.log({ fullPath, baseDir, baseName })
|
|
93
|
-
return
|
|
104
|
+
return path.resolve(baseDir, baseName)
|
|
94
105
|
}
|
|
95
106
|
```
|
|
96
107
|
|
|
@@ -118,21 +129,23 @@ Your `data` will be pre-populated with the following:
|
|
|
118
129
|
> Any `data` you add in the config will be available for use with their names wrapped in
|
|
119
130
|
> `{{` and `}}`.
|
|
120
131
|
|
|
132
|
+
#### Helpers
|
|
133
|
+
|
|
121
134
|
Simple-Scaffold provides some built-in text transformation filters usable by handleBars.
|
|
122
135
|
|
|
123
|
-
For example, you may use `{{ name
|
|
136
|
+
For example, you may use `{{ snakeCase name }}` inside a template file or filename, and it will
|
|
124
137
|
replace `My Name` with `my_name` when producing the final value.
|
|
125
138
|
|
|
126
139
|
Here are the built-in helpers available for use:
|
|
127
140
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
{{ name |
|
|
131
|
-
{{ name
|
|
132
|
-
{{ name |
|
|
133
|
-
{{ name |
|
|
134
|
-
{{ name |
|
|
135
|
-
|
|
141
|
+
| Helper name | Example code | Example output |
|
|
142
|
+
| ----------- | ----------------------- | -------------- |
|
|
143
|
+
| camelCase | `{{ camelCase name }}` | myName |
|
|
144
|
+
| snakeCase | `{{ snakeCase name }}` | my_name |
|
|
145
|
+
| startCase | `{{ startCase name }}` | My Name |
|
|
146
|
+
| kebabCase | `{{ kebabCase name }}` | my-name |
|
|
147
|
+
| hyphenCase | `{{ hyphenCase name }}` | my-name |
|
|
148
|
+
| pascalCase | `{{ pascalCase name }}` | MyName |
|
|
136
149
|
|
|
137
150
|
**Note:** These helpers are available for any data property, not exclusive to `name`.
|
|
138
151
|
|
|
@@ -144,7 +157,8 @@ Here are the built-in helpers available for use:
|
|
|
144
157
|
simple-scaffold MyComponent \
|
|
145
158
|
-t project/scaffold/**/* \
|
|
146
159
|
-o src/components \
|
|
147
|
-
-d '{"className":"myClassName"}'
|
|
160
|
+
-d '{"className": "myClassName"}'
|
|
161
|
+
MyComponent
|
|
148
162
|
```
|
|
149
163
|
|
|
150
164
|
### Example Scaffold Input
|
|
@@ -185,7 +199,7 @@ module.exports = class {{Name}} extends React.Component {
|
|
|
185
199
|
- ...
|
|
186
200
|
```
|
|
187
201
|
|
|
188
|
-
With `
|
|
202
|
+
With `createSubFolder = false`:
|
|
189
203
|
|
|
190
204
|
```plaintext
|
|
191
205
|
- project
|
|
@@ -202,7 +216,7 @@ const React = require("react")
|
|
|
202
216
|
|
|
203
217
|
module.exports = class MyComponent extends React.Component {
|
|
204
218
|
render() {
|
|
205
|
-
<div className="
|
|
219
|
+
<div className="myClassName">MyComponent Component</div>
|
|
206
220
|
}
|
|
207
221
|
}
|
|
208
222
|
```
|
package/cmd.js
CHANGED
|
@@ -1,69 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
massarg_1.default()
|
|
9
|
-
.main(scaffold_1.default)
|
|
10
|
-
.option({
|
|
11
|
-
name: "name",
|
|
12
|
-
aliases: ["n"],
|
|
13
|
-
isDefault: true,
|
|
14
|
-
description: "Name to be passed to the generated files. {{name}} and {{Name}} inside contents and file names will be replaced accordingly.",
|
|
15
|
-
})
|
|
16
|
-
.option({
|
|
17
|
-
name: "output",
|
|
18
|
-
aliases: ["o"],
|
|
19
|
-
description: "Path to output to. If --create-sub-folder is enabled, the subfolder will be created inside this path.",
|
|
20
|
-
})
|
|
21
|
-
.option({
|
|
22
|
-
name: "templates",
|
|
23
|
-
aliases: ["t"],
|
|
24
|
-
description: "Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, " +
|
|
25
|
-
"or a glob pattern for multiple file matching easily.",
|
|
26
|
-
defaultValue: [],
|
|
27
|
-
array: true,
|
|
28
|
-
})
|
|
29
|
-
.option({
|
|
30
|
-
aliases: ["w"],
|
|
31
|
-
name: "overwrite",
|
|
32
|
-
description: "Enable to override output files, even if they already exist.",
|
|
33
|
-
defaultValue: false,
|
|
34
|
-
boolean: true,
|
|
35
|
-
})
|
|
36
|
-
.option({
|
|
37
|
-
aliases: ["d"],
|
|
38
|
-
name: "data",
|
|
39
|
-
description: "Add custom data to the templates. By default, only your app name is included.",
|
|
40
|
-
parse: (v) => JSON.parse(v),
|
|
41
|
-
})
|
|
42
|
-
.option({
|
|
43
|
-
aliases: ["s"],
|
|
44
|
-
name: "create-sub-folder",
|
|
45
|
-
description: "Create subfolder with the input name",
|
|
46
|
-
defaultValue: false,
|
|
47
|
-
boolean: true,
|
|
48
|
-
})
|
|
49
|
-
.option({ aliases: ["q"], name: "quiet", description: "Suppress output logs", defaultValue: false, boolean: true })
|
|
50
|
-
.option({
|
|
51
|
-
aliases: ["dr"],
|
|
52
|
-
name: "dry-run",
|
|
53
|
-
description: "Don't emit files. This is good for testing your scaffolds and making sure they " +
|
|
54
|
-
"don't fail, without having to write actual file contents or create directories.",
|
|
55
|
-
defaultValue: false,
|
|
56
|
-
boolean: true,
|
|
57
|
-
})
|
|
58
|
-
// .example({
|
|
59
|
-
// input: `yarn cmd -t examples/test-input/Component -o examples/test-output -d '{"property":"myProp","value":"10"}'`,
|
|
60
|
-
// description: "Usage",
|
|
61
|
-
// output: "",
|
|
62
|
-
// })
|
|
63
|
-
.help({
|
|
64
|
-
binName: "simple-scaffold",
|
|
65
|
-
useGlobalColumns: true,
|
|
66
|
-
usageExample: "[options]",
|
|
67
|
-
})
|
|
68
|
-
.parse();
|
|
3
|
+
const cmd_util_1 = require("./cmd_util");
|
|
4
|
+
cmd_util_1.parseCliArgs();
|
|
69
5
|
//# sourceMappingURL=cmd.js.map
|
package/cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmd.js","sourceRoot":"","sources":["../src/cmd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cmd.js","sourceRoot":"","sources":["../src/cmd.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,uBAAY,EAAE,CAAA"}
|
package/cmd_util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseCliArgs(args?: string[]): void;
|
package/cmd_util.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseCliArgs = void 0;
|
|
7
|
+
const massarg_1 = __importDefault(require("massarg"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
const scaffold_1 = require("./scaffold");
|
|
11
|
+
function parseCliArgs(args = process.argv.slice(2)) {
|
|
12
|
+
return (massarg_1.default()
|
|
13
|
+
.main(scaffold_1.Scaffold)
|
|
14
|
+
.option({
|
|
15
|
+
name: "name",
|
|
16
|
+
aliases: ["n"],
|
|
17
|
+
isDefault: true,
|
|
18
|
+
description: "Name to be passed to the generated files. {{name}} and {{Name}} inside contents and file names will be replaced accordingly.",
|
|
19
|
+
})
|
|
20
|
+
.option({
|
|
21
|
+
name: "output",
|
|
22
|
+
aliases: ["o"],
|
|
23
|
+
description: "Path to output to. If --create-sub-folder is enabled, the subfolder will be created inside this path.",
|
|
24
|
+
})
|
|
25
|
+
.option({
|
|
26
|
+
name: "templates",
|
|
27
|
+
aliases: ["t"],
|
|
28
|
+
description: "Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, " +
|
|
29
|
+
"or a glob pattern for multiple file matching easily.",
|
|
30
|
+
defaultValue: [],
|
|
31
|
+
array: true,
|
|
32
|
+
})
|
|
33
|
+
.option({
|
|
34
|
+
aliases: ["w"],
|
|
35
|
+
name: "overwrite",
|
|
36
|
+
description: "Enable to override output files, even if they already exist.",
|
|
37
|
+
defaultValue: false,
|
|
38
|
+
boolean: true,
|
|
39
|
+
})
|
|
40
|
+
.option({
|
|
41
|
+
aliases: ["d"],
|
|
42
|
+
name: "data",
|
|
43
|
+
description: "Add custom data to the templates. By default, only your app name is included.",
|
|
44
|
+
parse: (v) => JSON.parse(v),
|
|
45
|
+
})
|
|
46
|
+
.option({
|
|
47
|
+
aliases: ["s"],
|
|
48
|
+
name: "create-sub-folder",
|
|
49
|
+
description: "Create subfolder with the input name",
|
|
50
|
+
defaultValue: false,
|
|
51
|
+
boolean: true,
|
|
52
|
+
})
|
|
53
|
+
.option({
|
|
54
|
+
aliases: ["q"],
|
|
55
|
+
name: "quiet",
|
|
56
|
+
description: "Suppress output logs (Same as --verbose 0)",
|
|
57
|
+
defaultValue: false,
|
|
58
|
+
boolean: true,
|
|
59
|
+
})
|
|
60
|
+
.option({
|
|
61
|
+
aliases: ["v"],
|
|
62
|
+
name: "verbose",
|
|
63
|
+
description: `Determine amount of logs to display. The values are: ${chalk_1.default.bold `0 (none) | 1 (debug) | 2 (info) | 3 (warn) | 4 (error)`}. The provided level will display messages of the same level or higher.`,
|
|
64
|
+
defaultValue: types_1.LogLevel.Info,
|
|
65
|
+
parse: Number,
|
|
66
|
+
})
|
|
67
|
+
.option({
|
|
68
|
+
aliases: ["dr"],
|
|
69
|
+
name: "dry-run",
|
|
70
|
+
description: "Don't emit files. This is good for testing your scaffolds and making sure they " +
|
|
71
|
+
"don't fail, without having to write actual file contents or create directories.",
|
|
72
|
+
defaultValue: false,
|
|
73
|
+
boolean: true,
|
|
74
|
+
})
|
|
75
|
+
// .example({
|
|
76
|
+
// input: `yarn cmd -t examples/test-input/Component -o examples/test-output -d '{"property":"myProp","value":"10"}'`,
|
|
77
|
+
// description: "Usage",
|
|
78
|
+
// output: "",
|
|
79
|
+
// })
|
|
80
|
+
.help({
|
|
81
|
+
binName: "simple-scaffold",
|
|
82
|
+
useGlobalColumns: true,
|
|
83
|
+
usageExample: "[options]",
|
|
84
|
+
header: "Create structured files based on templates.",
|
|
85
|
+
footer: `Copyright © Chen Asraf 2021\nNPM: ${chalk_1.default.underline `https://npmjs.com/package/massarg`}\nGitHub: ${chalk_1.default.underline `https://github.com/chenasraf/massarg`}`,
|
|
86
|
+
})
|
|
87
|
+
.parse(args));
|
|
88
|
+
}
|
|
89
|
+
exports.parseCliArgs = parseCliArgs;
|
|
90
|
+
//# sourceMappingURL=cmd_util.js.map
|
package/cmd_util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cmd_util.js","sourceRoot":"","sources":["../src/cmd_util.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,kDAAyB;AACzB,mCAAqD;AACrD,yCAAqC;AAErC,SAAgB,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,OAAO,CACL,iBAAO,EAA2D;SAC/D,IAAI,CAAC,mBAAQ,CAAC;SACd,MAAM,CAAC;QACN,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,SAAS,EAAE,IAAI;QACf,WAAW,EACT,8HAA8H;KACjI,CAAC;SACD,MAAM,CAAC;QACN,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,WAAW,EACT,uGAAuG;KAC1G,CAAC;SACD,MAAM,CAAC;QACN,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,WAAW,EACT,oHAAoH;YACpH,sDAAsD;QACxD,YAAY,EAAE,EAAE;QAChB,KAAK,EAAE,IAAI;KACZ,CAAC;SACD,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,8DAA8D;QAC3E,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,+EAA+E;QAC5F,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KAC5B,CAAC;SACD,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,4CAA4C;QACzD,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,GAAG,CAAC;QACd,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,wDAAwD,eAAK,CAAC,IAAI,CAAA,wDAAwD,yEAAyE;QAChN,YAAY,EAAE,gBAAQ,CAAC,IAAI;QAC3B,KAAK,EAAE,MAAM;KACd,CAAC;SACD,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,SAAS;QACf,WAAW,EACT,iFAAiF;YACjF,iFAAiF;QACnF,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,IAAI;KACd,CAAC;QACF,aAAa;QACb,wHAAwH;QACxH,0BAA0B;QAC1B,gBAAgB;QAChB,KAAK;SACJ,IAAI,CAAC;QACJ,OAAO,EAAE,iBAAiB;QAC1B,gBAAgB,EAAE,IAAI;QACtB,YAAY,EAAE,WAAW;QACzB,MAAM,EAAE,6CAA6C;QACrD,MAAM,EAAE,qCAAqC,eAAK,CAAC,SAAS,CAAA,mCAAmC,aAAa,eAAK,CAAC,SAAS,CAAA,sCAAsC,EAAE;KACpK,CAAC;SACD,KAAK,CAAC,IAAI,CAAC,CACf,CAAA;AACH,CAAC;AAnFD,oCAmFC"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
__exportStar(require("./scaffold"), exports);
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
17
18
|
const scaffold_1 = __importDefault(require("./scaffold"));
|
|
18
19
|
exports.default = scaffold_1.default;
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,0DAAiC;AACjC,kBAAe,kBAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,0CAAuB;AACvB,0DAAiC;AACjC,kBAAe,kBAAQ,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-scaffold",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"description": "Create files based on templates",
|
|
5
5
|
"repository": "https://github.com/chenasraf/simple-scaffold.git",
|
|
6
6
|
"author": "Chen Asraf <inbox@casraf.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"bin": "cmd.js",
|
|
10
|
-
"types": "types.d.ts",
|
|
11
10
|
"scripts": {
|
|
12
11
|
"clean": "rm -rf dist/",
|
|
13
12
|
"build": "yarn clean && tsc && chmod -R +x ./dist && cp ./package.json ./dist/ && cp ./README.md ./dist/",
|
|
@@ -20,10 +19,11 @@
|
|
|
20
19
|
},
|
|
21
20
|
"dependencies": {
|
|
22
21
|
"args": "^5.0.1",
|
|
22
|
+
"chalk": "^4.1.2",
|
|
23
23
|
"glob": "^7.1.3",
|
|
24
24
|
"handlebars": "^4.7.7",
|
|
25
25
|
"lodash": "^4.17.21",
|
|
26
|
-
"massarg": "^0.
|
|
26
|
+
"massarg": "^1.0.3",
|
|
27
27
|
"util.promisify": "^1.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/scaffold.js
CHANGED
|
@@ -10,11 +10,12 @@ const util_1 = require("util");
|
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const { readFile, writeFile } = fs_1.promises;
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
|
+
const types_1 = require("./types");
|
|
13
14
|
async function Scaffold(config) {
|
|
14
15
|
try {
|
|
15
16
|
const options = { ...config };
|
|
16
17
|
const data = { name: options.name, Name: utils_1.pascalCase(options.name), ...options.data };
|
|
17
|
-
utils_1.log(options, "
|
|
18
|
+
utils_1.log(options, types_1.LogLevel.Debug, "Full config:", {
|
|
18
19
|
name: options.name,
|
|
19
20
|
templates: options.templates,
|
|
20
21
|
output: options.output,
|
|
@@ -23,19 +24,26 @@ async function Scaffold(config) {
|
|
|
23
24
|
overwrite: options.overwrite,
|
|
24
25
|
quiet: options.quiet,
|
|
25
26
|
});
|
|
26
|
-
utils_1.log(options, "Data:", data);
|
|
27
|
+
utils_1.log(options, types_1.LogLevel.Info, "Data:", data);
|
|
27
28
|
for (let template of config.templates) {
|
|
28
29
|
try {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
30
|
+
const _isGlob = template.includes("*");
|
|
31
|
+
const _nonGlobTemplate = _isGlob ? utils_1.removeGlob(template) : template;
|
|
32
|
+
const _isDir = _isGlob ? false : await utils_1.isDir(template);
|
|
33
|
+
const _shouldAddGlob = !_isGlob && !_isDir;
|
|
34
|
+
if (_shouldAddGlob) {
|
|
34
35
|
template = template + "/**/*";
|
|
35
36
|
}
|
|
36
37
|
const files = await util_1.promisify(glob_1.glob)(template, { dot: true, debug: false });
|
|
37
38
|
for (const templatePath of files) {
|
|
38
39
|
if (!(await utils_1.isDir(templatePath))) {
|
|
40
|
+
const basePath = path_1.default
|
|
41
|
+
.resolve(process.cwd(), _isDir
|
|
42
|
+
? templatePath.replace(template, "")
|
|
43
|
+
: path_1.default.dirname(utils_1.removeGlob(templatePath).replace(_nonGlobTemplate, "")))
|
|
44
|
+
.replace(process.cwd() + "/", "")
|
|
45
|
+
.replace(process.cwd(), "");
|
|
46
|
+
utils_1.log(options, types_1.LogLevel.Debug, `\ntemplate: ${template}\ntemplatePath: ${templatePath}, \nbase path: ${basePath}\n`);
|
|
39
47
|
await handleTemplateFile(templatePath, basePath, options, data);
|
|
40
48
|
}
|
|
41
49
|
}
|
|
@@ -55,18 +63,22 @@ async function handleTemplateFile(templatePath, basePath, options, data) {
|
|
|
55
63
|
return new Promise(async (resolve, reject) => {
|
|
56
64
|
var _a;
|
|
57
65
|
try {
|
|
58
|
-
|
|
59
|
-
const inputPath = path_1.default.join(process.cwd(), templatePath);
|
|
66
|
+
const inputPath = path_1.default.resolve(process.cwd(), templatePath);
|
|
60
67
|
const outputPathOpt = utils_1.getOptionValueForFile(inputPath, data, options.output);
|
|
61
|
-
const outputDir = path_1.default.resolve(process.cwd(), ...[outputPathOpt, options.createSubFolder ? options.name : undefined].filter(Boolean));
|
|
68
|
+
const outputDir = path_1.default.resolve(process.cwd(), ...[outputPathOpt, basePath, options.createSubFolder ? options.name : undefined].filter(Boolean));
|
|
69
|
+
utils_1.log(options, types_1.LogLevel.Debug, `\nParsing ${templatePath}`, `\nBase path: ${basePath}`, `\nFull input path: ${inputPath}`, `\nFull output path: ${outputDir}\n`);
|
|
62
70
|
const outputPath = path_1.default.join(outputDir, utils_1.handlebarsParse(path_1.default.basename(inputPath), data));
|
|
63
71
|
const overwrite = utils_1.getOptionValueForFile(inputPath, data, (_a = options.overwrite) !== null && _a !== void 0 ? _a : false);
|
|
64
72
|
const exists = await utils_1.pathExists(outputPath);
|
|
73
|
+
utils_1.log(options, types_1.LogLevel.Debug, "Filename parsed:", utils_1.handlebarsParse(path_1.default.basename(inputPath), data), "Orig:", path_1.default.basename(inputPath)
|
|
74
|
+
// "Test:",
|
|
75
|
+
// handlebarsParse("{{name}} {{name pascalCase}}", data)
|
|
76
|
+
);
|
|
65
77
|
await utils_1.createDirIfNotExists(outputDir, options);
|
|
66
|
-
utils_1.log(options, `Writing to ${outputPath}`);
|
|
78
|
+
utils_1.log(options, types_1.LogLevel.Info, `Writing to ${outputPath}`);
|
|
67
79
|
if (!exists || overwrite) {
|
|
68
80
|
if (exists && overwrite) {
|
|
69
|
-
utils_1.log(options, `File ${outputPath} exists, overwriting`);
|
|
81
|
+
utils_1.log(options, types_1.LogLevel.Info, `File ${outputPath} exists, overwriting`);
|
|
70
82
|
}
|
|
71
83
|
const templateBuffer = await readFile(inputPath);
|
|
72
84
|
const outputContents = utils_1.handlebarsParse(templateBuffer, data);
|
|
@@ -74,12 +86,12 @@ async function handleTemplateFile(templatePath, basePath, options, data) {
|
|
|
74
86
|
await writeFile(outputPath, outputContents);
|
|
75
87
|
}
|
|
76
88
|
else {
|
|
77
|
-
utils_1.log(options, "Content output:");
|
|
78
|
-
utils_1.log(options, outputContents);
|
|
89
|
+
utils_1.log(options, types_1.LogLevel.Info, "Content output:");
|
|
90
|
+
utils_1.log(options, types_1.LogLevel.Info, outputContents);
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
93
|
else if (exists) {
|
|
82
|
-
utils_1.log(options, `File ${outputPath} already exists, skipping`);
|
|
94
|
+
utils_1.log(options, types_1.LogLevel.Info, `File ${outputPath} already exists, skipping`);
|
|
83
95
|
}
|
|
84
96
|
resolve();
|
|
85
97
|
}
|
package/scaffold.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA2B;AAC3B,gDAAuB;AACvB,+BAAgC;AAChC,2BAA2C;AAC3C,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,aAAU,C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
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
None = 0,
|
|
3
|
+
Debug = 1,
|
|
4
|
+
Info = 2,
|
|
5
|
+
Warning = 3,
|
|
6
|
+
Error = 4
|
|
7
|
+
}
|
|
1
8
|
export declare type FileResponseFn<T> = (fullPath: string, basedir: string, basename: string) => T;
|
|
2
9
|
export declare type FileResponse<T> = T | FileResponseFn<T>;
|
|
3
10
|
export interface ScaffoldConfig {
|
|
4
11
|
/** The name supplied for the output templates */
|
|
5
12
|
name: string;
|
|
13
|
+
/** Template input files/dirs/glob patterns to use as template input. These will be copied to the output directory. */
|
|
6
14
|
templates: string[];
|
|
15
|
+
/** Output directory to put scaffolded files in. */
|
|
7
16
|
output: FileResponse<string>;
|
|
8
17
|
createSubFolder?: boolean;
|
|
9
18
|
data?: Record<string, string>;
|
|
10
19
|
overwrite?: FileResponse<boolean>;
|
|
11
20
|
quiet?: boolean;
|
|
21
|
+
verbose?: LogLevel;
|
|
12
22
|
dryRun?: boolean;
|
|
13
23
|
}
|
|
14
24
|
export interface ScaffoldCmdConfig {
|
package/types.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel[LogLevel["None"] = 0] = "None";
|
|
7
|
+
LogLevel[LogLevel["Debug"] = 1] = "Debug";
|
|
8
|
+
LogLevel[LogLevel["Info"] = 2] = "Info";
|
|
9
|
+
LogLevel[LogLevel["Warning"] = 3] = "Warning";
|
|
10
|
+
LogLevel[LogLevel["Error"] = 4] = "Error";
|
|
11
|
+
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
3
12
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,6CAAW,CAAA;IACX,yCAAS,CAAA;AACX,CAAC,EANW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAMnB"}
|
package/utils.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { FileResponse, ScaffoldConfig } from "./types";
|
|
2
|
+
import { FileResponse, LogLevel, ScaffoldConfig } from "./types";
|
|
3
3
|
export declare function handleErr(err: NodeJS.ErrnoException | null): void;
|
|
4
|
-
export declare function log(options: ScaffoldConfig, ...obj: any[]): void;
|
|
4
|
+
export declare function log(options: ScaffoldConfig, level: LogLevel, ...obj: any[]): void;
|
|
5
5
|
export declare function createDirIfNotExists(dir: string, options: ScaffoldConfig): Promise<void>;
|
|
6
6
|
export declare function getOptionValueForFile<T>(filePath: string, data: Record<string, string>, fn: FileResponse<T>, defaultValue?: T): T;
|
|
7
7
|
export declare function handlebarsParse(templateBuffer: Buffer | string, data: Record<string, string>): string;
|
|
8
8
|
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
9
9
|
export declare function pascalCase(s: string): string;
|
|
10
10
|
export declare function isDir(path: string): Promise<boolean>;
|
|
11
|
+
export declare function removeGlob(template: string): string;
|
package/utils.js
CHANGED
|
@@ -3,15 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isDir = exports.pascalCase = exports.pathExists = exports.handlebarsParse = exports.getOptionValueForFile = exports.createDirIfNotExists = exports.log = exports.handleErr = void 0;
|
|
6
|
+
exports.removeGlob = exports.isDir = exports.pascalCase = exports.pathExists = exports.handlebarsParse = exports.getOptionValueForFile = exports.createDirIfNotExists = exports.log = exports.handleErr = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const constants_1 = require("constants");
|
|
9
|
+
const types_1 = require("./types");
|
|
9
10
|
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
10
11
|
const snakeCase_1 = __importDefault(require("lodash/snakeCase"));
|
|
11
12
|
const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
|
|
12
13
|
const startCase_1 = __importDefault(require("lodash/startCase"));
|
|
13
14
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
14
15
|
const fs_1 = require("fs");
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
17
|
const { stat, access, mkdir } = fs_1.promises;
|
|
16
18
|
const helpers = {
|
|
17
19
|
camelCase: camelCase_1.default,
|
|
@@ -29,11 +31,21 @@ function handleErr(err) {
|
|
|
29
31
|
throw err;
|
|
30
32
|
}
|
|
31
33
|
exports.handleErr = handleErr;
|
|
32
|
-
function log(options, ...obj) {
|
|
33
|
-
|
|
34
|
+
function log(options, level, ...obj) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (options.quiet || options.verbose === types_1.LogLevel.None || ((_a = options.verbose) !== null && _a !== void 0 ? _a : types_1.LogLevel.Info) > level) {
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
const levelColor = {
|
|
40
|
+
[types_1.LogLevel.None]: "reset",
|
|
41
|
+
[types_1.LogLevel.Debug]: "blue",
|
|
42
|
+
[types_1.LogLevel.Info]: "dim",
|
|
43
|
+
[types_1.LogLevel.Warning]: "yellow",
|
|
44
|
+
[types_1.LogLevel.Error]: "red",
|
|
45
|
+
};
|
|
46
|
+
const chalkFn = chalk_1.default[levelColor[level]];
|
|
47
|
+
console["log"](...obj.map((i) => (typeof i === "object" ? chalkFn(JSON.stringify(i, undefined, 1)) : chalkFn(i))));
|
|
48
|
+
// console["log"](...obj)
|
|
37
49
|
}
|
|
38
50
|
exports.log = log;
|
|
39
51
|
async function createDirIfNotExists(dir, options) {
|
|
@@ -90,4 +102,8 @@ async function isDir(path) {
|
|
|
90
102
|
return tplStat.isDirectory();
|
|
91
103
|
}
|
|
92
104
|
exports.isDir = isDir;
|
|
105
|
+
function removeGlob(template) {
|
|
106
|
+
return template.replace(/\*/g, "").replace(/\/\//g, "/");
|
|
107
|
+
}
|
|
108
|
+
exports.removeGlob = removeGlob;
|
|
93
109
|
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,yCAAgC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,yCAAgC;AAChC,mCAAgF;AAChF,iEAAwC;AACxC,iEAAwC;AACxC,iEAAwC;AACxC,iEAAwC;AACxC,4DAAmC;AACnC,2BAA2C;AAC3C,kDAAyB;AACzB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,aAAU,CAAA;AAE1C,MAAM,OAAO,GAAG;IACd,SAAS,EAAT,mBAAS;IACT,SAAS,EAAT,mBAAS;IACT,SAAS,EAAT,mBAAS;IACT,SAAS,EAAT,mBAAS;IACT,UAAU,EAAE,mBAAS;IACrB,UAAU;CACX,CAAA;AAED,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE;IAChC,oBAAU,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,UAAkC,CAAC,CAAC,CAAA;CACnF;AAED,SAAgB,SAAS,CAAC,GAAiC;IACzD,IAAI,GAAG;QAAE,MAAM,GAAG,CAAA;AACpB,CAAC;AAFD,8BAEC;AAED,SAAgB,GAAG,CAAC,OAAu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