@alauda/doom 0.6.5 → 0.6.6
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/lib/cli/index.js +8 -4
- package/lib/cli/new.d.ts +2 -0
- package/lib/cli/new.js +4 -11
- package/package.json +1 -1
package/lib/cli/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { program } from 'commander';
|
|
|
11
11
|
import { green } from 'yoctocolors';
|
|
12
12
|
import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js';
|
|
13
13
|
import { loadConfig } from './load-config.js';
|
|
14
|
+
import { newCommand } from './new.js';
|
|
14
15
|
const META_FILE = '_meta.json';
|
|
15
16
|
const CONFIG_FILES = [...DEFAULT_CONFIGS, I18N_FILE, SITES_FILE];
|
|
16
17
|
const setNodeEnv = (env) => {
|
|
@@ -28,7 +29,7 @@ program
|
|
|
28
29
|
.option('-c, --config [config]', 'Specify the path to the config file')
|
|
29
30
|
.option('-v <version>', 'Specify the version of the documentation')
|
|
30
31
|
.option('-p, --prefix <prefix>', 'Specify the prefix of the documentation base')
|
|
31
|
-
.option('-f, --force [boolean]', 'Force to fetch latest reference remotes, otherwise use local cache', (value) => !!value && value !== 'false', false)
|
|
32
|
+
.option('-f, --force [boolean]', 'Force to fetch latest reference remotes or scaffolding templates, otherwise use local cache', (value) => !!value && value !== 'false', false)
|
|
32
33
|
.command('dev', { isDefault: true })
|
|
33
34
|
.description('Start the development server')
|
|
34
35
|
.argument('[root]', 'Root directory of the documentation')
|
|
@@ -128,7 +129,10 @@ program
|
|
|
128
129
|
...server,
|
|
129
130
|
});
|
|
130
131
|
});
|
|
131
|
-
program.
|
|
132
|
-
|
|
132
|
+
program.addCommand(newCommand);
|
|
133
|
+
program.parseAsync().catch((err) => {
|
|
134
|
+
if (err instanceof Error && err.name === 'ExitPromptError') {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
logger.error(err);
|
|
133
138
|
});
|
|
134
|
-
program.parseAsync().catch(console.error);
|
package/lib/cli/new.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as prompts from '@inquirer/prompts';
|
|
2
|
+
import { Command } from 'commander';
|
|
2
3
|
export declare const DEFAULT_PATH = "templates/scaffolding.yaml";
|
|
3
4
|
export interface ScaffoldingTemplate {
|
|
4
5
|
repo: string;
|
|
@@ -42,4 +43,5 @@ export interface Scaffolding {
|
|
|
42
43
|
parameters?: ScaffoldingParameter[];
|
|
43
44
|
layout?: ScaffoldingLayout[];
|
|
44
45
|
}
|
|
46
|
+
export declare const newCommand: Command;
|
|
45
47
|
export {};
|
package/lib/cli/new.js
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import * as prompts from '@inquirer/prompts';
|
|
5
5
|
import { logger } from '@rsbuild/core';
|
|
6
|
-
import {
|
|
6
|
+
import { Command } from 'commander';
|
|
7
7
|
import { render } from 'ejs';
|
|
8
8
|
import { simpleGit } from 'simple-git';
|
|
9
9
|
import { glob } from 'tinyglobby';
|
|
@@ -110,14 +110,14 @@ const handleTemplateFile = async ({ source, target, processors, parameters, writ
|
|
|
110
110
|
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
111
111
|
await fs[`${writeMode}File`](target, content);
|
|
112
112
|
};
|
|
113
|
-
|
|
113
|
+
export const newCommand = new Command('new')
|
|
114
114
|
.argument('[template]', 'Scaffolding template name, format: `[name][:type]`')
|
|
115
|
-
.
|
|
116
|
-
.action(async (template = '', { force }) => {
|
|
115
|
+
.action(async function (template = '') {
|
|
117
116
|
let [name, type] = template.split(':');
|
|
118
117
|
if (!name) {
|
|
119
118
|
name = 'product-doc';
|
|
120
119
|
}
|
|
120
|
+
const { force } = this.optsWithGlobals();
|
|
121
121
|
const { base, scaffoldings } = (await resolveScaffoldings(name, force)) || {};
|
|
122
122
|
if (!scaffoldings) {
|
|
123
123
|
logger.error(`Unable to resolve any scaffoldings, if you are sure the template \`${magenta(name)}\` exists, try to use the \`--force\` option, or event remove the local cache at ${magenta(path.resolve(scaffoldingsFolder, name))} and try again`);
|
|
@@ -194,11 +194,4 @@ program
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
logger.success('Scaffolding generated successfully!');
|
|
197
|
-
})
|
|
198
|
-
.parseAsync(process.argv)
|
|
199
|
-
.catch((err) => {
|
|
200
|
-
if (err instanceof Error && err.name === 'ExitPromptError') {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
logger.error(err);
|
|
204
197
|
});
|