@farris/cli 2.3.7 → 2.3.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/lib/commands/add-app.js +5 -5
- package/lib/commands/add-app.js.map +1 -1
- package/lib/commands/add-lib.js +5 -5
- package/lib/commands/add-lib.js.map +1 -1
- package/lib/commands/add-micro.js +12 -0
- package/lib/commands/add-micro.js.map +1 -0
- package/lib/commands/add-project.js +196 -194
- package/lib/commands/add-project.js.map +1 -1
- package/lib/commands/build-components.js +60 -60
- package/lib/commands/build-components.js.map +1 -1
- package/lib/commands/build-css.js +38 -38
- package/lib/commands/build-css.js.map +1 -1
- package/lib/commands/build-lib.js +30 -30
- package/lib/commands/build-lib.js.map +1 -1
- package/lib/commands/build.js +19 -19
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/create-app-options.js +85 -74
- package/lib/commands/create-app-options.js.map +1 -1
- package/lib/commands/create-app.js +131 -131
- package/lib/commands/create-app.js.map +1 -1
- package/lib/commands/create-options.js +58 -32
- package/lib/commands/create-options.js.map +1 -1
- package/lib/commands/create.js +341 -331
- package/lib/commands/create.js.map +1 -1
- package/lib/commands/dev-serve.js +18 -18
- package/lib/commands/extract-i18n.js +74 -74
- package/lib/commands/extract-i18n.js.map +1 -1
- package/lib/commands/generate/api.js +124 -124
- package/lib/commands/generate/api.js.map +1 -1
- package/lib/commands/generate/common.js +101 -101
- package/lib/commands/generate/common.js.map +1 -1
- package/lib/commands/generate/component.js +156 -156
- package/lib/commands/generate/component.js.map +1 -1
- package/lib/commands/generate/view.js +168 -168
- package/lib/commands/generate/view.js.map +1 -1
- package/lib/commands/preview-serve.js +16 -16
- package/lib/commands/workspace/add-app.js +15 -15
- package/lib/commands/workspace/add-app.js.map +1 -1
- package/lib/commands/workspace/create.js +62 -62
- package/lib/commands/workspace/create.js.map +1 -1
- package/lib/commands/workspace/inspect.js +30 -30
- package/lib/commands/workspace/inspect.js.map +1 -1
- package/lib/commands/workspace/verify.js +38 -38
- package/lib/commands/workspace/verify.js.map +1 -1
- package/lib/common/agents-doc.js +33 -33
- package/lib/common/agents-doc.js.map +1 -1
- package/lib/common/apply-catalog-deps.js +15 -15
- package/lib/common/apply-catalog-deps.js.map +1 -1
- package/lib/common/component-file-name.js +3 -3
- package/lib/common/constant.js +85 -84
- package/lib/common/constant.js.map +1 -1
- package/lib/common/create-app-target.js +46 -46
- package/lib/common/create-app-target.js.map +1 -1
- package/lib/common/generate-app.js +106 -109
- package/lib/common/generate-app.js.map +1 -1
- package/lib/common/get-dependencies.js +9 -9
- package/lib/common/get-farris-config.js +25 -25
- package/lib/common/get-farris-config.js.map +1 -1
- package/lib/common/get-version.js +6 -6
- package/lib/common/get-vite-config.js +192 -192
- package/lib/common/get-vite-config.js.map +1 -1
- package/lib/common/lib-package-exports.js +24 -24
- package/lib/common/lib-package-exports.js.map +1 -1
- package/lib/common/list-lib-components.js +23 -23
- package/lib/common/list-lib-components.js.map +1 -1
- package/lib/common/output.js +164 -164
- package/lib/common/output.js.map +1 -1
- package/lib/common/project-layout.js +155 -183
- package/lib/common/project-layout.js.map +1 -1
- package/lib/common/safety.js +172 -173
- package/lib/common/safety.js.map +1 -1
- package/lib/common/template-manifest.js +18 -14
- package/lib/common/template-manifest.js.map +1 -1
- package/lib/common/template-renderer.js +114 -114
- package/lib/common/template-renderer.js.map +1 -1
- package/lib/common/transaction.js +83 -83
- package/lib/common/transaction.js.map +1 -1
- package/lib/common/verifier.js +187 -201
- package/lib/common/verifier.js.map +1 -1
- package/lib/common/workspace-contract.js +191 -157
- package/lib/common/workspace-contract.js.map +1 -1
- package/lib/config/vite-app.js +13 -13
- package/lib/config/vite-common.js +20 -20
- package/lib/config/vite-common.js.map +1 -1
- package/lib/config/vite-component.js +32 -32
- package/lib/config/vite-component.js.map +1 -1
- package/lib/config/vite-lib.js +26 -26
- package/lib/config/vite-lib.js.map +1 -1
- package/lib/index.js +261 -238
- package/lib/index.js.map +1 -1
- package/lib/plugins/create-app-package-json.js +23 -23
- package/lib/plugins/create-component-style.js +44 -44
- package/lib/plugins/create-package-json.js +48 -48
- package/lib/plugins/create-package-json.js.map +1 -1
- package/lib/plugins/dts.js +8 -8
- package/lib/plugins/html-system.js +9 -9
- package/lib/plugins/mock.js +240 -292
- package/lib/plugins/mock.js.map +1 -1
- package/lib/plugins/msw-adapter.js +141 -0
- package/lib/plugins/msw-adapter.js.map +1 -0
- package/lib/plugins/replace.js +17 -17
- package/lib/plugins/systemjs-bundle.js +15 -15
- package/lib/plugins/systemjs-bundle.js.map +1 -1
- package/package.json +6 -1
- package/templates/create/.gitignore.tpl +28 -8
- package/templates/create/AGENTS.md +76 -45
- package/templates/create/README.md +44 -11
- package/templates/create/package.json +2 -1
- package/templates/lib/.gitignore.tpl +31 -1
- package/templates/lib/.gitlab-ci.yml +2 -2
- package/templates/lib/README.md +24 -1
- package/templates/lib/{test → components/__tests__}/index.spec.ts +1 -1
- package/templates/lib/{test → components/__tests__}/index.spec.tsx +2 -2
- package/templates/lib/farris.config.mjs +2 -2
- package/templates/lib/package.json +1 -1
- package/templates/lib/tsconfig.json +1 -2
- package/templates/lib/vitest.config.ts +4 -2
- package/templates/micro/.eslintrc.cjs +15 -0
- package/templates/micro/.gitignore.tpl +33 -0
- package/templates/micro/.gitlab-ci.yml +59 -0
- package/templates/micro/.prettierrc.json +8 -0
- package/templates/micro/farris.config.mjs +34 -0
- package/templates/micro/index.html +12 -0
- package/templates/micro/mock/README.md +53 -0
- package/templates/micro/mock/tsconfig.json +10 -0
- package/templates/micro/package.json +47 -0
- package/templates/micro/src/App.tsx +25 -0
- package/templates/micro/src/locales/index.ts +5 -0
- package/templates/micro/src/locales/zh-CHS.json +1 -0
- package/templates/micro/src/main.ts +47 -0
- package/templates/micro/src/router/index.ts +24 -0
- package/templates/micro/src/views/AboutView.tsx +12 -0
- package/templates/micro/src/views/HomeView.tsx +13 -0
- package/templates/micro/src/views/__tests__/AboutView.spec.tsx +11 -0
- package/templates/micro/src/views/__tests__/HomeView.spec.tsx +11 -0
- package/templates/micro/tsconfig.json +18 -0
- package/templates/micro/vitest.config.ts +12 -0
- package/templates/mobile/.gitignore.tpl +25 -24
- package/templates/mobile/farris.config.mjs +2 -2
- package/templates/mobile/mock/README.md +39 -20
- package/templates/mobile/mock/tsconfig.json +10 -0
- package/templates/mobile/package.json +5 -2
- package/templates/mobile/src/main.ts +5 -40
- package/templates/mobile/src/views/HomeView.tsx +2 -2
- package/templates/mobile/src/views/__tests__/AboutView.spec.tsx +11 -0
- package/templates/mobile/src/views/__tests__/HomeView.spec.tsx +11 -0
- package/templates/mobile/tsconfig.json +1 -2
- package/templates/mobile/vitest.config.ts +4 -2
- package/templates/web/.gitignore.tpl +25 -24
- package/templates/web/farris.config.mjs +2 -2
- package/templates/web/mock/README.md +39 -20
- package/templates/web/mock/tsconfig.json +10 -0
- package/templates/web/package.json +5 -2
- package/templates/web/src/App.tsx +0 -4
- package/templates/web/src/main.ts +5 -40
- package/templates/web/src/views/HomeView.tsx +2 -2
- package/templates/web/src/views/__tests__/AboutView.spec.tsx +11 -0
- package/templates/web/src/views/__tests__/HomeView.spec.tsx +11 -0
- package/templates/web/tsconfig.json +1 -2
- package/templates/web/vitest.config.ts +4 -2
- package/templates/mobile/src/components/TheButton.tsx +0 -9
- package/templates/mobile/test/src/components/TheButton.spec.ts +0 -15
- package/templates/mobile/test/src/components/TheButton.spec.tsx +0 -15
- package/templates/web/src/components/TheButton.tsx +0 -9
- package/templates/web/src/micro-app.d.ts +0 -20
- package/templates/web/src/styles/index.css +0 -0
- package/templates/web/test/src/components/TheButton.spec.ts +0 -15
- package/templates/web/test/src/components/TheButton.spec.tsx +0 -15
- /package/templates/{web → micro}/src/micro/context.ts +0 -0
- /package/templates/{mobile → micro}/src/micro-app.d.ts +0 -0
- /package/templates/{mobile/src/styles/index.css → micro/src/styles/index.scss} +0 -0
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import { ExitCode } from '../common/constant.js';
|
|
4
|
-
import { generateApp } from '../common/generate-app.js';
|
|
5
|
-
import { fail, logWarn, sendJson, setJsonMode } from '../common/output.js';
|
|
6
|
-
import { findWorkspaceRoot } from '../common/project-layout.js';
|
|
7
|
-
import { assertTargetDirectoryFree, CreateAppError, DEFAULT_APP_FORMAT, DEFAULT_LIB_FORMATS, parseFormatsFlag, resolveNonInteractiveOptions, resolvePackageName, validateCliInput } from './create-app-options.js';
|
|
8
|
-
const prompt = inquirer.createPromptModule();
|
|
9
|
-
const questions = [
|
|
10
|
-
{
|
|
11
|
-
type: 'input',
|
|
12
|
-
name: 'name',
|
|
13
|
-
message: 'What is your project name?',
|
|
14
|
-
default: 'my-project'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: 'list',
|
|
18
|
-
name: 'type',
|
|
19
|
-
message: 'What type of project is this?',
|
|
20
|
-
choices: ['app', 'lib']
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'list',
|
|
24
|
-
name: 'platform',
|
|
25
|
-
message: 'What platform of project is this?',
|
|
26
|
-
choices: ['web', 'mobile'],
|
|
27
|
-
when: (response) => response.type === 'app'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: 'checkbox',
|
|
31
|
-
name: 'formats',
|
|
32
|
-
message: 'What output format of project is this?',
|
|
33
|
-
choices: ['es', 'cjs', 'umd', 'systemjs'],
|
|
34
|
-
default: [...DEFAULT_LIB_FORMATS],
|
|
35
|
-
when: (response) => response.type === 'lib'
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
type: 'list',
|
|
39
|
-
name: 'format',
|
|
40
|
-
message: 'What output format of project is this? (iife: IBP 微前端单文件产物)',
|
|
41
|
-
choices: ['iife', 'es', 'umd', 'systemjs'],
|
|
42
|
-
default: DEFAULT_APP_FORMAT,
|
|
43
|
-
when: (response) => response.type === 'app'
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
function toGenerateOptions(answers) {
|
|
47
|
-
const packageName = resolvePackageName(answers.name);
|
|
48
|
-
if (answers.type === 'lib') {
|
|
49
|
-
return { name: answers.name, packageName, type: 'lib', formats: answers.formats };
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
name: answers.name,
|
|
53
|
-
packageName,
|
|
54
|
-
type: 'app',
|
|
55
|
-
platform: answers.platform,
|
|
56
|
-
format: answers.format
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function initialAnswers(input) {
|
|
60
|
-
const initial = {};
|
|
61
|
-
if (input.name) {
|
|
62
|
-
initial.name = input.name;
|
|
63
|
-
}
|
|
64
|
-
if (input.type) {
|
|
65
|
-
initial.type = input.type;
|
|
66
|
-
}
|
|
67
|
-
if (input.platform) {
|
|
68
|
-
initial.platform = input.platform;
|
|
69
|
-
}
|
|
70
|
-
if (input.format) {
|
|
71
|
-
initial.format = input.format;
|
|
72
|
-
}
|
|
73
|
-
if (input.formats !== undefined) {
|
|
74
|
-
initial.formats = parseFormatsFlag(input.formats);
|
|
75
|
-
}
|
|
76
|
-
return initial;
|
|
77
|
-
}
|
|
78
|
-
function emitCreateAppJson(options) {
|
|
79
|
-
sendJson({
|
|
80
|
-
command: 'create-app',
|
|
81
|
-
ok: true,
|
|
82
|
-
name: options.name,
|
|
83
|
-
...(options.packageName ? { packageName: options.packageName } : {}),
|
|
84
|
-
type: options.type,
|
|
85
|
-
...(options.platform ? { platform: options.platform } : {}),
|
|
86
|
-
...(options.format ? { format: options.format } : {}),
|
|
87
|
-
...(options.formats ? { formats: options.formats } : {}),
|
|
88
|
-
target: resolve(process.cwd(), options.name)
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function failCreateApp(error) {
|
|
92
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
93
|
-
const exitCode = error instanceof CreateAppError ? error.exitCode : ExitCode.GENERAL_ERROR;
|
|
94
|
-
fail({
|
|
95
|
-
command: 'create-app',
|
|
96
|
-
error: message,
|
|
97
|
-
exitCode
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
export async function createApp(nameArg, commandOptions = {}) {
|
|
101
|
-
const isJson = !!commandOptions.json;
|
|
102
|
-
setJsonMode(isJson);
|
|
103
|
-
// 检测到 workspace 时只提示,不改变 create-app 的对外语义(设计文档 §10)
|
|
104
|
-
if (findWorkspaceRoot(process.cwd())) {
|
|
105
|
-
logWarn('检测到当前目录位于 pnpm workspace 内:建议改用 `farris-cli add-app <name>` / `farris-cli add-lib <name>`,由 CLI 负责落盘位置、catalog 改写与校验。');
|
|
106
|
-
}
|
|
107
|
-
const input = { ...commandOptions, name: nameArg ?? commandOptions.name };
|
|
108
|
-
try {
|
|
109
|
-
validateCliInput(input);
|
|
110
|
-
const skipPrompt = !!(input.yes || input.json);
|
|
111
|
-
let options;
|
|
112
|
-
if (skipPrompt) {
|
|
113
|
-
options = resolveNonInteractiveOptions(input);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const answers = await prompt(questions, initialAnswers(input));
|
|
117
|
-
options = toGenerateOptions(answers);
|
|
118
|
-
}
|
|
119
|
-
assertTargetDirectoryFree(options.name);
|
|
120
|
-
generateApp(options);
|
|
121
|
-
if (isJson) {
|
|
122
|
-
emitCreateAppJson(options);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
if (isJson) {
|
|
127
|
-
failCreateApp(error);
|
|
128
|
-
}
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { ExitCode } from '../common/constant.js';
|
|
4
|
+
import { generateApp } from '../common/generate-app.js';
|
|
5
|
+
import { fail, logWarn, sendJson, setJsonMode } from '../common/output.js';
|
|
6
|
+
import { findWorkspaceRoot } from '../common/project-layout.js';
|
|
7
|
+
import { assertTargetDirectoryFree, CreateAppError, DEFAULT_APP_FORMAT, DEFAULT_LIB_FORMATS, parseFormatsFlag, resolveNonInteractiveOptions, resolvePackageName, validateCliInput } from './create-app-options.js';
|
|
8
|
+
const prompt = inquirer.createPromptModule();
|
|
9
|
+
const questions = [
|
|
10
|
+
{
|
|
11
|
+
type: 'input',
|
|
12
|
+
name: 'name',
|
|
13
|
+
message: 'What is your project name?',
|
|
14
|
+
default: 'my-project'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'list',
|
|
18
|
+
name: 'type',
|
|
19
|
+
message: 'What type of project is this?',
|
|
20
|
+
choices: ['app', 'lib']
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'list',
|
|
24
|
+
name: 'platform',
|
|
25
|
+
message: 'What platform of project is this?',
|
|
26
|
+
choices: ['web', 'mobile'],
|
|
27
|
+
when: (response) => response.type === 'app'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'checkbox',
|
|
31
|
+
name: 'formats',
|
|
32
|
+
message: 'What output format of project is this?',
|
|
33
|
+
choices: ['es', 'cjs', 'umd', 'systemjs'],
|
|
34
|
+
default: [...DEFAULT_LIB_FORMATS],
|
|
35
|
+
when: (response) => response.type === 'lib'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'list',
|
|
39
|
+
name: 'format',
|
|
40
|
+
message: 'What output format of project is this? (iife: IBP 微前端单文件产物)',
|
|
41
|
+
choices: ['iife', 'es', 'umd', 'systemjs'],
|
|
42
|
+
default: DEFAULT_APP_FORMAT,
|
|
43
|
+
when: (response) => response.type === 'app'
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
function toGenerateOptions(answers) {
|
|
47
|
+
const packageName = resolvePackageName(answers.name);
|
|
48
|
+
if (answers.type === 'lib') {
|
|
49
|
+
return { name: answers.name, packageName, type: 'lib', formats: answers.formats };
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
name: answers.name,
|
|
53
|
+
packageName,
|
|
54
|
+
type: 'app',
|
|
55
|
+
platform: answers.platform,
|
|
56
|
+
format: answers.format
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function initialAnswers(input) {
|
|
60
|
+
const initial = {};
|
|
61
|
+
if (input.name) {
|
|
62
|
+
initial.name = input.name;
|
|
63
|
+
}
|
|
64
|
+
if (input.type) {
|
|
65
|
+
initial.type = input.type;
|
|
66
|
+
}
|
|
67
|
+
if (input.platform) {
|
|
68
|
+
initial.platform = input.platform;
|
|
69
|
+
}
|
|
70
|
+
if (input.format) {
|
|
71
|
+
initial.format = input.format;
|
|
72
|
+
}
|
|
73
|
+
if (input.formats !== undefined) {
|
|
74
|
+
initial.formats = parseFormatsFlag(input.formats);
|
|
75
|
+
}
|
|
76
|
+
return initial;
|
|
77
|
+
}
|
|
78
|
+
function emitCreateAppJson(options) {
|
|
79
|
+
sendJson({
|
|
80
|
+
command: 'create-app',
|
|
81
|
+
ok: true,
|
|
82
|
+
name: options.name,
|
|
83
|
+
...(options.packageName ? { packageName: options.packageName } : {}),
|
|
84
|
+
type: options.type,
|
|
85
|
+
...(options.platform ? { platform: options.platform } : {}),
|
|
86
|
+
...(options.format ? { format: options.format } : {}),
|
|
87
|
+
...(options.formats ? { formats: options.formats } : {}),
|
|
88
|
+
target: resolve(process.cwd(), options.name)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function failCreateApp(error) {
|
|
92
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
93
|
+
const exitCode = error instanceof CreateAppError ? error.exitCode : ExitCode.GENERAL_ERROR;
|
|
94
|
+
fail({
|
|
95
|
+
command: 'create-app',
|
|
96
|
+
error: message,
|
|
97
|
+
exitCode
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export async function createApp(nameArg, commandOptions = {}) {
|
|
101
|
+
const isJson = !!commandOptions.json;
|
|
102
|
+
setJsonMode(isJson);
|
|
103
|
+
// 检测到 workspace 时只提示,不改变 create-app 的对外语义(设计文档 §10)
|
|
104
|
+
if (findWorkspaceRoot(process.cwd())) {
|
|
105
|
+
logWarn('检测到当前目录位于 pnpm workspace 内:建议改用 `farris-cli add-app <name>` / `farris-cli add-lib <name>`,由 CLI 负责落盘位置、catalog 改写与校验。');
|
|
106
|
+
}
|
|
107
|
+
const input = { ...commandOptions, name: nameArg ?? commandOptions.name };
|
|
108
|
+
try {
|
|
109
|
+
validateCliInput(input);
|
|
110
|
+
const skipPrompt = !!(input.yes || input.json);
|
|
111
|
+
let options;
|
|
112
|
+
if (skipPrompt) {
|
|
113
|
+
options = resolveNonInteractiveOptions(input);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const answers = await prompt(questions, initialAnswers(input));
|
|
117
|
+
options = toGenerateOptions(answers);
|
|
118
|
+
}
|
|
119
|
+
assertTargetDirectoryFree(options.name);
|
|
120
|
+
generateApp(options);
|
|
121
|
+
if (isJson) {
|
|
122
|
+
emitCreateAppJson(options);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (isJson) {
|
|
127
|
+
failCreateApp(error);
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
132
|
//# sourceMappingURL=create-app.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAA2B,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,yBAAyB,EACzB,c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G,iBAAiB,CAAC,OAM3B,CAAC,CAAC;QACL,CAAC;QAED,yBAAyB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,WAAW,CAAC,OAAO,CAAC,CAAC;QAErB,IAAI,MAAM,EAAE,CAAC;YACX,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,MAAM,EAAE,CAAC;YACX,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,33 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
/** 需要取值的选项:`--app` 与 `--no-app` 是隐藏兼容别名,不进帮助文本。 */
|
|
2
|
+
const VALUE_FLAGS = {
|
|
3
|
+
'--app': 'project',
|
|
4
|
+
'--project': 'project',
|
|
5
|
+
'--style': 'style',
|
|
6
|
+
'--format': 'format',
|
|
7
|
+
'--formats': 'formats',
|
|
8
|
+
'--platform': 'platform',
|
|
9
|
+
'--type': 'type'
|
|
10
|
+
};
|
|
11
|
+
export function parseCreateArgv(argv) {
|
|
12
|
+
const options = {};
|
|
13
|
+
let name;
|
|
14
|
+
for (let i = 0; i < argv.length; i++) {
|
|
15
|
+
const arg = argv[i];
|
|
16
|
+
if (arg === '--json') {
|
|
17
|
+
options.json = true;
|
|
18
|
+
}
|
|
19
|
+
else if (arg === '--install') {
|
|
20
|
+
options.install = true;
|
|
21
|
+
}
|
|
22
|
+
else if (arg === '--force') {
|
|
23
|
+
options.force = true;
|
|
24
|
+
}
|
|
25
|
+
else if (arg === '-y' || arg === '--yes') {
|
|
26
|
+
options.yes = true;
|
|
27
|
+
}
|
|
28
|
+
else if (arg === '--no-app' || arg === '--no-project') {
|
|
29
|
+
options.noProject = true;
|
|
30
|
+
}
|
|
31
|
+
else if (VALUE_FLAGS[arg]) {
|
|
32
|
+
const value = argv[i + 1];
|
|
33
|
+
if (value === undefined || value.startsWith('-')) {
|
|
34
|
+
throw new Error(`参数 ${arg} 缺少取值`);
|
|
35
|
+
}
|
|
36
|
+
options[VALUE_FLAGS[arg]] = value;
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
else if (arg.startsWith('--') && arg.includes('=')) {
|
|
40
|
+
const [flag, value] = arg.split(/=(.*)/s);
|
|
41
|
+
const key = VALUE_FLAGS[flag];
|
|
42
|
+
if (!key) {
|
|
43
|
+
throw new Error(`未知参数: ${flag}(运行 farris-cli create --help 查看用法)`);
|
|
44
|
+
}
|
|
45
|
+
options[key] = value;
|
|
46
|
+
}
|
|
47
|
+
else if (arg.startsWith('-')) {
|
|
48
|
+
throw new Error(`未知参数: ${arg}(运行 farris-cli create --help 查看用法)`);
|
|
49
|
+
}
|
|
50
|
+
else if (name === undefined) {
|
|
51
|
+
name = arg;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw new Error(`多余的参数: ${arg}(只接受一个 workspace 名)`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { name, options };
|
|
58
|
+
}
|
|
33
59
|
//# sourceMappingURL=create-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-options.js","sourceRoot":"","sources":["../../src/commands/create-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-options.js","sourceRoot":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