From 939200c9f21be240485ea602a73b983ba2f47aaf Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Mon, 29 Jan 2024 02:49:36 +0200 Subject: [PATCH] fix: remove gh flag --- docs/docs/usage/cli.md | 17 +++++++++++------ src/cmd.ts | 22 ++++++---------------- src/config.ts | 22 ++++++++++++---------- src/types.ts | 1 - 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/docs/docs/usage/cli.md b/docs/docs/usage/cli.md index d1e08f9..3b23cb8 100644 --- a/docs/docs/usage/cli.md +++ b/docs/docs/usage/cli.md @@ -16,7 +16,6 @@ To see this and more information anytime, add the `-h` or `--help` flag to your | `--name` \| `-n` | 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. | | `--config`\|`-c` | Filename to load config from instead of passing arguments to CLI or using a Node.js script. See examples for syntax. This can also work in conjunction with `--git` or `--github` to point to remote files, and with `--key` to denote which key to select from the file., | | `--git`\|`-g` | Git URL to load config from instead of passing arguments to CLI or using a Node.js script. See examples for syntax. | -| `--github`\|`-gh` | GitHub path to load config from instead of passing arguments to CLI or using a Node.js script. | | `--key` \| `-k` | 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`) | | `--output` \| `-o` | Path to output to. If `--create-sub-folder` is enabled, the subfolder will be created inside this path. Default is current working directory. | | `--templates` \| `-t` | 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. | @@ -39,20 +38,23 @@ To see this and more information anytime, add the `-h` or `--help` flag to your Usage with config file ```shell -$ simple-scaffold -c scaffold.cmd.js -k component +$ simple-scaffold -c scaffold.cmd.js -k component MyComponent ``` Usage with GitHub config file ```shell -$ simple-scaffold -gh chenasraf/simple-scaffold -k component +$ simple-scaffold -g chenasraf/simple-scaffold -k component MyComponent ``` Usage with https git URL (for non-GitHub) ```shell -$ simple-scaffold -g \ - https://example.com/user/template.git -c scaffold.cmd.js -k component +$ simple-scaffold \ + -g https://example.com/user/template.git \ + -c scaffold.cmd.js \ + -k component \ + MyComponent ``` Full syntax with config path and template key (applicable to all above methods) @@ -70,7 +72,7 @@ $ simple-scaffold -c scaffold.cmd.js MyComponent Shortest syntax for GitHub, assumes file 'scaffold.cmd.js' and template key 'default' ```shell -$ simple-scaffold -gh chenasraf/simple-scaffold MyComponent +$ simple-scaffold -g chenasraf/simple-scaffold MyComponent ``` You can also add this as a script in your `package.json`: @@ -78,7 +80,10 @@ You can also add this as a script in your `package.json`: ```json { "scripts": { + "scaffold-cfg": "npx simple-scaffold -c scaffold.cmd.js -k component", + "scaffold-gh": "npx simple-scaffold -g chenasraf/simple-scaffold -k component", "scaffold": "npx simple-scaffold@latest -t scaffolds/component/**/* -o src/components -d '{\"myProp\": \"propName\", \"myVal\": 123}'" + "scaffold-component": "npx simple-scaffold -c scaffold.cmd.js -k" } } ``` diff --git a/src/cmd.ts b/src/cmd.ts index 6df2ae9..f9765e8 100644 --- a/src/cmd.ts +++ b/src/cmd.ts @@ -11,7 +11,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) { const pkgFile = await fs.readFile(path.join(__dirname, "package.json")) const pkg = JSON.parse(pkgFile.toString()) const isConfigProvided = - args.includes("--config") || args.includes("-c") || args.includes("--github") || args.includes("-gh") + args.includes("--config") || args.includes("-c") || args.includes("--git") || args.includes("-g") return ( massarg({ @@ -46,13 +46,6 @@ export async function parseCliArgs(args = process.argv.slice(2)) { "Git URL to load config from instead of passing arguments to CLI or using a Node.js script. See " + "examples for syntax.", }) - .option({ - name: "github", - aliases: ["gh"], - description: - "GitHub path to load config from instead of passing arguments to CLI or using a Node.js script. See " + - "examples for syntax.", - }) .option({ name: "key", aliases: ["k"], @@ -144,23 +137,20 @@ export async function parseCliArgs(args = process.argv.slice(2)) { }) .example({ description: "Usage with GitHub config file", - input: "simple-scaffold -gh chenasraf/simple-scaffold --key component", + input: "simple-scaffold -g chenasraf/simple-scaffold --key component", }) .example({ description: "Usage with https git URL (for non-GitHub)", - input: "simple-scaffold -c https://example.com/user/template.git#scaffold.cmd.js --key component", - }) - .example({ - description: "Full syntax with config path and template key (applicable to all above methods)", - input: "simple-scaffold -c scaffold.cmd.js:component MyComponent", + input: "simple-scaffold -g https://example.com/user/template.git -c scaffold.cmd.js --key component", }) .example({ description: "Excluded template key, assumes 'default' key", input: "simple-scaffold -c scaffold.cmd.js MyComponent", }) .example({ - description: "Shortest syntax for GitHub, assumes file 'scaffold.cmd.js' and template key 'default'", - input: "simple-scaffold -gh chenasraf/simple-scaffold MyComponent", + description: + "Shortest syntax for GitHub, searches for config file automaticlly, assumes and template key 'default'", + input: "simple-scaffold -g chenasraf/simple-scaffold MyComponent", }) .help({ bindOption: true, diff --git a/src/config.ts b/src/config.ts index 4009034..a061c8e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -55,21 +55,23 @@ export async function parseConfigFile(config: ScaffoldCmdConfig): Promise