simple-scaffold 2.3.3 → 3.0.0
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 +40 -13
- package/before-write.d.ts +7 -0
- package/cmd.js +214 -260
- package/cmd.js.map +1 -1
- package/colors.d.ts +32 -0
- package/config.d.ts +12 -10
- package/file.d.ts +30 -11
- package/fs-utils.d.ts +9 -0
- package/index.js +12 -23
- package/index.js.map +1 -1
- package/logger.d.ts +6 -0
- package/package.json +21 -19
- package/parser.d.ts +1 -1
- package/path-utils.d.ts +6 -0
- package/prompts.d.ts +27 -0
- package/scaffold-Ce-rIwy9.js +2636 -0
- package/scaffold-Ce-rIwy9.js.map +1 -0
- package/types.d.ts +36 -0
- package/utils.d.ts +4 -24
- package/config.js +0 -254
- package/config.js.map +0 -1
- package/file.js +0 -166
- package/file.js.map +0 -1
- package/git.js +0 -81
- package/git.js.map +0 -1
- package/logger.js +0 -58
- package/logger.js.map +0 -1
- package/parser.js +0 -100
- package/parser.js.map +0 -1
- package/scaffold.js +0 -139
- package/scaffold.js.map +0 -1
- package/types.js +0 -31
- package/types.js.map +0 -1
- package/utils.js +0 -61
- package/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,17 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
</h2>
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
copying your commonly-created files.
|
|
16
|
+
Simple Scaffold is a file scaffolding tool. You define templates once, then generate files from them
|
|
17
|
+
whenever you need — whether it's a single component or an entire app boilerplate.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
you can also use it to loop through data, use conditions, and write custom functions using helpers.
|
|
24
|
-
|
|
25
|
-
Don't waste any more time manually copying and pasting files - let Simple Scaffold do the heavy
|
|
26
|
-
lifting for you and start building your projects faster and more efficiently today!
|
|
19
|
+
Templates use **Handlebars.js** syntax, so you can inject data, loop over lists, use conditionals,
|
|
20
|
+
and write custom helpers. It works as a CLI or as a Node.js library, and it doesn't care what kind
|
|
21
|
+
of files you're generating.
|
|
27
22
|
|
|
28
23
|
<div align="center">
|
|
29
24
|
|
|
@@ -100,9 +95,40 @@ See information about each option and flag using the `--help` flag, or read the
|
|
|
100
95
|
[CLI documentation](https://chenasraf.github.io/simple-scaffold/docs/usage/cli). For information
|
|
101
96
|
about how configuration files work, [see below](#configuration-files).
|
|
102
97
|
|
|
98
|
+
### Interactive Mode
|
|
99
|
+
|
|
100
|
+
When running in a terminal, Simple Scaffold will interactively prompt for any missing required
|
|
101
|
+
values — name, output directory, template paths, and template key (if multiple are available).
|
|
102
|
+
|
|
103
|
+
Config files can also define **inputs** — custom fields that are prompted interactively and become
|
|
104
|
+
template data:
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
module.exports = {
|
|
108
|
+
component: {
|
|
109
|
+
templates: ["templates/component"],
|
|
110
|
+
output: "src/components",
|
|
111
|
+
inputs: {
|
|
112
|
+
author: { message: "Author name", required: true },
|
|
113
|
+
license: { message: "License", default: "MIT" },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Inputs can be pre-provided via `--data` or `-D` to skip the prompt:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
npx simple-scaffold -c scaffold.config.js -k component -D author=John MyComponent
|
|
123
|
+
```
|
|
124
|
+
|
|
103
125
|
### Configuration Files
|
|
104
126
|
|
|
105
|
-
You can use a config file to more easily maintain all your scaffold definitions.
|
|
127
|
+
You can use a config file to more easily maintain all your scaffold definitions. Simple Scaffold
|
|
128
|
+
**auto-detects** config files in the current directory — no `--config` flag needed.
|
|
129
|
+
|
|
130
|
+
It searches for these files in order: `scaffold.config.{mjs,cjs,js,json}`,
|
|
131
|
+
`scaffold.{mjs,cjs,js,json}`, `.scaffold.{mjs,cjs,js,json}`.
|
|
106
132
|
|
|
107
133
|
`scaffold.config.js`
|
|
108
134
|
|
|
@@ -120,10 +146,11 @@ module.exports = {
|
|
|
120
146
|
}
|
|
121
147
|
```
|
|
122
148
|
|
|
123
|
-
Then
|
|
149
|
+
Then just run from the same directory:
|
|
124
150
|
|
|
125
151
|
```sh
|
|
126
|
-
$ npx simple-scaffold
|
|
152
|
+
$ npx simple-scaffold PageWrapper
|
|
153
|
+
# or explicitly: npx simple-scaffold -c scaffold.config.js PageWrapper
|
|
127
154
|
```
|
|
128
155
|
|
|
129
156
|
This will allow you to avoid needing to remember which configs are needed or to store them in a
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LogConfig, ScaffoldConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a CLI beforeWrite command string into a beforeWrite callback function.
|
|
4
|
+
* The command receives the processed content via a temp file and can return modified content via stdout.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function wrapBeforeWrite(config: LogConfig & Pick<ScaffoldConfig, "dryRun">, beforeWrite: string): ScaffoldConfig["beforeWrite"];
|
package/cmd.js
CHANGED
|
@@ -1,265 +1,219 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const types_1 = require("./types");
|
|
12
|
-
const scaffold_1 = require("./scaffold");
|
|
13
|
-
const config_1 = require("./config");
|
|
14
|
-
const logger_1 = require("./logger");
|
|
15
|
-
const command_1 = require("massarg/command");
|
|
16
|
-
const file_1 = require("./file");
|
|
17
|
-
const utils_1 = require("./utils");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_scaffold = require("./scaffold-Ce-rIwy9.js");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
node_path = require_scaffold.__toESM(node_path);
|
|
6
|
+
let node_fs_promises = require("node:fs/promises");
|
|
7
|
+
node_fs_promises = require_scaffold.__toESM(node_fs_promises);
|
|
8
|
+
let massarg = require("massarg");
|
|
9
|
+
let massarg_command = require("massarg/command");
|
|
10
|
+
//#region src/cmd.ts
|
|
18
11
|
async function parseCliArgs(args = process.argv.slice(2)) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
})
|
|
222
|
-
.help({
|
|
223
|
-
bindOption: true,
|
|
224
|
-
}))
|
|
225
|
-
.example({
|
|
226
|
-
description: "Usage with config file",
|
|
227
|
-
input: "simple-scaffold -c scaffold.cmd.js --key component",
|
|
228
|
-
})
|
|
229
|
-
.example({
|
|
230
|
-
description: "Usage with GitHub config file",
|
|
231
|
-
input: "simple-scaffold -g chenasraf/simple-scaffold --key component",
|
|
232
|
-
})
|
|
233
|
-
.example({
|
|
234
|
-
description: "Usage with https git URL (for non-GitHub)",
|
|
235
|
-
input: "simple-scaffold -g https://example.com/user/template.git -c scaffold.cmd.js --key component",
|
|
236
|
-
})
|
|
237
|
-
.example({
|
|
238
|
-
description: "Excluded template key, assumes 'default' key",
|
|
239
|
-
input: "simple-scaffold -c scaffold.cmd.js MyComponent",
|
|
240
|
-
})
|
|
241
|
-
.example({
|
|
242
|
-
description: "Shortest syntax for GitHub, searches for config file automaticlly, assumes and template key 'default'",
|
|
243
|
-
input: "simple-scaffold -g chenasraf/simple-scaffold MyComponent",
|
|
244
|
-
})
|
|
245
|
-
.help({
|
|
246
|
-
bindOption: true,
|
|
247
|
-
lineLength: 100,
|
|
248
|
-
useGlobalTableColumns: true,
|
|
249
|
-
usageText: [utils_1.colorize.yellow `simple-scaffold`, utils_1.colorize.gray `[options]`, utils_1.colorize.cyan `<name>`].join(" "),
|
|
250
|
-
optionOptions: {
|
|
251
|
-
displayNegations: true,
|
|
252
|
-
},
|
|
253
|
-
footerText: [
|
|
254
|
-
`Version: ${pkg.version}`,
|
|
255
|
-
`Copyright © Chen Asraf 2017-${new Date().getFullYear()}`,
|
|
256
|
-
``,
|
|
257
|
-
`Documentation: ${utils_1.colorize.underline `https://chenasraf.github.io/simple-scaffold`}`,
|
|
258
|
-
`NPM: ${utils_1.colorize.underline `https://npmjs.com/package/simple-scaffold`}`,
|
|
259
|
-
`GitHub: ${utils_1.colorize.underline `https://github.com/chenasraf/simple-scaffold`}`,
|
|
260
|
-
].join("\n"),
|
|
261
|
-
})
|
|
262
|
-
.parse(args);
|
|
12
|
+
const isProjectRoot = Boolean(await node_fs_promises.default.stat(node_path.default.join(__dirname, "package.json")).catch(() => false));
|
|
13
|
+
const pkgFile = await node_fs_promises.default.readFile(node_path.default.resolve(__dirname, isProjectRoot ? "." : "..", "package.json"));
|
|
14
|
+
const pkg = JSON.parse(pkgFile.toString());
|
|
15
|
+
args.includes("--version") || args.includes("-v");
|
|
16
|
+
args.includes("--config") || args.includes("-c");
|
|
17
|
+
args.includes("--git") || args.includes("-g");
|
|
18
|
+
return (0, massarg.massarg)({
|
|
19
|
+
name: pkg.name,
|
|
20
|
+
description: pkg.description
|
|
21
|
+
}).main(async (config) => {
|
|
22
|
+
if (config.version) {
|
|
23
|
+
console.log(pkg.version);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
require_scaffold.log(config, require_scaffold.LogLevel.info, `Simple Scaffold v${pkg.version}`);
|
|
27
|
+
config.tmpDir = require_scaffold.getUniqueTmpPath();
|
|
28
|
+
try {
|
|
29
|
+
if (!config.config && !config.git) try {
|
|
30
|
+
config.config = await require_scaffold.findConfigFile(process.cwd());
|
|
31
|
+
require_scaffold.log(config, require_scaffold.LogLevel.debug, `Auto-detected config file: ${config.config}`);
|
|
32
|
+
} catch {}
|
|
33
|
+
const hasConfigSource = Boolean(config.config || config.git);
|
|
34
|
+
let configMap;
|
|
35
|
+
if (hasConfigSource) configMap = await require_scaffold.getConfigFile(config);
|
|
36
|
+
config = await require_scaffold.promptForMissingConfig(config, configMap);
|
|
37
|
+
require_scaffold.log(config, require_scaffold.LogLevel.debug, "Parsing config file...", config);
|
|
38
|
+
await require_scaffold.Scaffold(await require_scaffold.resolveInputs(await require_scaffold.parseConfigFile(config)));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
const message = "message" in e ? e.message : e?.toString();
|
|
41
|
+
require_scaffold.log(config, require_scaffold.LogLevel.error, message);
|
|
42
|
+
} finally {
|
|
43
|
+
require_scaffold.log(config, require_scaffold.LogLevel.debug, "Cleaning up temporary files...", config.tmpDir);
|
|
44
|
+
if (config.tmpDir) await node_fs_promises.default.rm(config.tmpDir, {
|
|
45
|
+
recursive: true,
|
|
46
|
+
force: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}).option({
|
|
50
|
+
name: "name",
|
|
51
|
+
aliases: ["n"],
|
|
52
|
+
description: "Name to be passed to the generated files. `{{name}}` and other data parameters inside contents and file names will be replaced accordingly. You may omit the `--name` or `-n` for this specific option. If omitted in an interactive terminal, you will be prompted.",
|
|
53
|
+
isDefault: true
|
|
54
|
+
}).option({
|
|
55
|
+
name: "config",
|
|
56
|
+
aliases: ["c"],
|
|
57
|
+
description: "Filename or directory to load config from"
|
|
58
|
+
}).option({
|
|
59
|
+
name: "git",
|
|
60
|
+
aliases: ["g"],
|
|
61
|
+
description: "Git URL or GitHub path to load a template from."
|
|
62
|
+
}).option({
|
|
63
|
+
name: "key",
|
|
64
|
+
aliases: ["k"],
|
|
65
|
+
description: "Key to load inside the config file. This overwrites the config key provided after the colon in `--config` (e.g. `--config scaffold.cmd.js:component)`. If omitted and multiple templates are available, you will be prompted to select one."
|
|
66
|
+
}).option({
|
|
67
|
+
name: "output",
|
|
68
|
+
aliases: ["o"],
|
|
69
|
+
description: "Path to output to. If `--subdir` is enabled, the subdir will be created inside this path. If omitted in an interactive terminal, you will be prompted."
|
|
70
|
+
}).option({
|
|
71
|
+
name: "templates",
|
|
72
|
+
aliases: ["t"],
|
|
73
|
+
array: true,
|
|
74
|
+
description: "Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, or a glob pattern for multiple file matching easily. If omitted in an interactive terminal, you will be prompted for a comma-separated list."
|
|
75
|
+
}).flag({
|
|
76
|
+
name: "overwrite",
|
|
77
|
+
aliases: ["w"],
|
|
78
|
+
defaultValue: false,
|
|
79
|
+
description: "Enable to override output files, even if they already exist.",
|
|
80
|
+
negatable: true
|
|
81
|
+
}).option({
|
|
82
|
+
name: "data",
|
|
83
|
+
aliases: ["d"],
|
|
84
|
+
description: "Add custom data to the templates. By default, only your app name is included.",
|
|
85
|
+
parse: (v) => JSON.parse(v)
|
|
86
|
+
}).option({
|
|
87
|
+
name: "append-data",
|
|
88
|
+
aliases: ["D"],
|
|
89
|
+
description: "Append additional custom data to the templates, which will overwrite `--data`, using an alternate syntax, which is easier to use with CLI: `-D key1=string -D key2:=raw`",
|
|
90
|
+
parse: require_scaffold.parseAppendData
|
|
91
|
+
}).flag({
|
|
92
|
+
name: "subdir",
|
|
93
|
+
aliases: ["s"],
|
|
94
|
+
defaultValue: false,
|
|
95
|
+
description: "Create a parent directory with the input name (and possibly `--subdir-helper`",
|
|
96
|
+
negatable: true,
|
|
97
|
+
negationName: "no-subdir"
|
|
98
|
+
}).option({
|
|
99
|
+
name: "subdir-helper",
|
|
100
|
+
aliases: ["H"],
|
|
101
|
+
description: "Default helper to apply to subdir name when using `--subdir`."
|
|
102
|
+
}).flag({
|
|
103
|
+
name: "quiet",
|
|
104
|
+
aliases: ["q"],
|
|
105
|
+
defaultValue: false,
|
|
106
|
+
description: "Suppress output logs (Same as `--log-level none`)"
|
|
107
|
+
}).option({
|
|
108
|
+
name: "log-level",
|
|
109
|
+
aliases: ["l"],
|
|
110
|
+
defaultValue: require_scaffold.LogLevel.info,
|
|
111
|
+
description: `Determine amount of logs to display. The values are: ${require_scaffold.colorize.bold`\`none | debug | info | warn | error\``}. The provided level will display messages of the same level or higher.`,
|
|
112
|
+
parse: (v) => {
|
|
113
|
+
const val = v.toLowerCase();
|
|
114
|
+
if (!(val in require_scaffold.LogLevel)) throw new Error(`Invalid log level: ${val}, must be one of: ${Object.keys(require_scaffold.LogLevel).join(", ")}`);
|
|
115
|
+
return val;
|
|
116
|
+
}
|
|
117
|
+
}).option({
|
|
118
|
+
name: "before-write",
|
|
119
|
+
aliases: ["B"],
|
|
120
|
+
description: "Run a script before writing the files. This can be a command or a path to a file. A temporary file path will be passed to the given command and the command should return a string for the final output."
|
|
121
|
+
}).flag({
|
|
122
|
+
name: "dry-run",
|
|
123
|
+
aliases: ["dr"],
|
|
124
|
+
defaultValue: false,
|
|
125
|
+
description: "Don't emit files. This is good for testing your scaffolds and making sure they don't fail, without having to write actual file contents or create directories."
|
|
126
|
+
}).flag({
|
|
127
|
+
name: "version",
|
|
128
|
+
aliases: ["v"],
|
|
129
|
+
description: "Display version."
|
|
130
|
+
}).command(new massarg_command.MassargCommand({
|
|
131
|
+
name: "list",
|
|
132
|
+
aliases: ["ls"],
|
|
133
|
+
description: "List all available templates for a given config. See `list -h` for more information.",
|
|
134
|
+
run: async (_config) => {
|
|
135
|
+
const config = {
|
|
136
|
+
templates: [],
|
|
137
|
+
name: "",
|
|
138
|
+
version: false,
|
|
139
|
+
output: "",
|
|
140
|
+
subdir: false,
|
|
141
|
+
overwrite: false,
|
|
142
|
+
dryRun: false,
|
|
143
|
+
tmpDir: require_scaffold.getUniqueTmpPath(),
|
|
144
|
+
..._config,
|
|
145
|
+
config: _config.config ?? (!_config.git ? process.cwd() : void 0)
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
const file = await require_scaffold.getConfigFile(config);
|
|
149
|
+
console.log(require_scaffold.colorize.underline`Available templates:\n`);
|
|
150
|
+
console.log(Object.keys(file).join("\n"));
|
|
151
|
+
} catch (e) {
|
|
152
|
+
const message = "message" in e ? e.message : e?.toString();
|
|
153
|
+
require_scaffold.log(config, require_scaffold.LogLevel.error, message);
|
|
154
|
+
} finally {
|
|
155
|
+
require_scaffold.log(config, require_scaffold.LogLevel.debug, "Cleaning up temporary files...", config.tmpDir);
|
|
156
|
+
if (config.tmpDir) await node_fs_promises.default.rm(config.tmpDir, {
|
|
157
|
+
recursive: true,
|
|
158
|
+
force: true
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}).option({
|
|
163
|
+
name: "config",
|
|
164
|
+
aliases: ["c"],
|
|
165
|
+
description: "Filename or directory to load config from. Defaults to current working directory."
|
|
166
|
+
}).option({
|
|
167
|
+
name: "git",
|
|
168
|
+
aliases: ["g"],
|
|
169
|
+
description: "Git URL or GitHub path to load a template from."
|
|
170
|
+
}).option({
|
|
171
|
+
name: "log-level",
|
|
172
|
+
aliases: ["l"],
|
|
173
|
+
defaultValue: require_scaffold.LogLevel.none,
|
|
174
|
+
description: `Determine amount of logs to display. The values are: ${require_scaffold.colorize.bold`\`none | debug | info | warn | error\``}. The provided level will display messages of the same level or higher.`,
|
|
175
|
+
parse: (v) => {
|
|
176
|
+
const val = v.toLowerCase();
|
|
177
|
+
if (!(val in require_scaffold.LogLevel)) throw new Error(`Invalid log level: ${val}, must be one of: ${Object.keys(require_scaffold.LogLevel).join(", ")}`);
|
|
178
|
+
return val;
|
|
179
|
+
}
|
|
180
|
+
}).help({ bindOption: true })).example({
|
|
181
|
+
description: "Usage with config file",
|
|
182
|
+
input: "simple-scaffold -c scaffold.cmd.js --key component"
|
|
183
|
+
}).example({
|
|
184
|
+
description: "Usage with GitHub config file",
|
|
185
|
+
input: "simple-scaffold -g chenasraf/simple-scaffold --key component"
|
|
186
|
+
}).example({
|
|
187
|
+
description: "Usage with https git URL (for non-GitHub)",
|
|
188
|
+
input: "simple-scaffold -g https://example.com/user/template.git -c scaffold.cmd.js --key component"
|
|
189
|
+
}).example({
|
|
190
|
+
description: "Excluded template key, assumes 'default' key",
|
|
191
|
+
input: "simple-scaffold -c scaffold.cmd.js MyComponent"
|
|
192
|
+
}).example({
|
|
193
|
+
description: "Shortest syntax for GitHub, searches for config file automaticlly, assumes and template key 'default'",
|
|
194
|
+
input: "simple-scaffold -g chenasraf/simple-scaffold MyComponent"
|
|
195
|
+
}).help({
|
|
196
|
+
bindOption: true,
|
|
197
|
+
lineLength: 100,
|
|
198
|
+
useGlobalTableColumns: true,
|
|
199
|
+
usageText: [
|
|
200
|
+
require_scaffold.colorize.yellow`simple-scaffold`,
|
|
201
|
+
require_scaffold.colorize.gray`[options]`,
|
|
202
|
+
require_scaffold.colorize.cyan`<name>`
|
|
203
|
+
].join(" "),
|
|
204
|
+
optionOptions: { displayNegations: true },
|
|
205
|
+
footerText: [
|
|
206
|
+
`Version: ${pkg.version}`,
|
|
207
|
+
`Copyright © Chen Asraf 2017-${(/* @__PURE__ */ new Date()).getFullYear()}`,
|
|
208
|
+
``,
|
|
209
|
+
`Documentation: ${require_scaffold.colorize.underline`https://chenasraf.github.io/simple-scaffold`}`,
|
|
210
|
+
`NPM: ${require_scaffold.colorize.underline`https://npmjs.com/package/simple-scaffold`}`,
|
|
211
|
+
`GitHub: ${require_scaffold.colorize.underline`https://github.com/chenasraf/simple-scaffold`}`
|
|
212
|
+
].join("\n")
|
|
213
|
+
}).parse(args);
|
|
263
214
|
}
|
|
264
215
|
parseCliArgs();
|
|
216
|
+
//#endregion
|
|
217
|
+
exports.parseCliArgs = parseCliArgs;
|
|
218
|
+
|
|
265
219
|
//# sourceMappingURL=cmd.js.map
|