@gadmin2n/cli 0.0.123 → 0.0.125
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/actions/new.action.js +15 -5
- package/package.json +1 -1
package/actions/new.action.js
CHANGED
|
@@ -36,14 +36,20 @@ class NewAction extends abstract_action_1.AbstractAction {
|
|
|
36
36
|
const isDryRunEnabled = dryRunOption && dryRunOption.value;
|
|
37
37
|
yield askForMissingInformation(inputs, options);
|
|
38
38
|
console.info();
|
|
39
|
-
|
|
40
|
-
const shouldSkipInstall = options.some((option) => option.name === 'skip-install' && option.value === true);
|
|
41
|
-
const shouldSkipGit = options.some((option) => option.name === 'skip-git' && option.value === true);
|
|
39
|
+
// 在调用 schematics 之前先解析项目目录
|
|
42
40
|
const projectDirectory = getProjectDirectory(getApplicationNameInput(inputs), directoryOption);
|
|
43
41
|
// 统一解析为绝对路径,确保 --directory /absolute/path 可以正常工作
|
|
44
42
|
const projectAbsDir = (0, path_1.isAbsolute)(projectDirectory)
|
|
45
43
|
? projectDirectory
|
|
46
44
|
: (0, path_1.join)(process.cwd(), projectDirectory);
|
|
45
|
+
// Angular DevKit schematics 引擎始终把 --directory 当作相对于 cwd 的路径处理。
|
|
46
|
+
// projectDirectory 已包含 appName(父目录 + appName),将其转为相对路径传给引擎。
|
|
47
|
+
if (directoryOption === null || directoryOption === void 0 ? void 0 : directoryOption.value) {
|
|
48
|
+
directoryOption.value = (0, path_1.relative)(process.cwd(), projectAbsDir);
|
|
49
|
+
}
|
|
50
|
+
yield generateApplicationFiles(inputs, options).catch(exports.exit);
|
|
51
|
+
const shouldSkipInstall = options.some((option) => option.name === 'skip-install' && option.value === true);
|
|
52
|
+
const shouldSkipGit = options.some((option) => option.name === 'skip-git' && option.value === true);
|
|
47
53
|
// 落盘用户提供的环境配置(dry-run 模式跳过,因为目录可能未实际生成)
|
|
48
54
|
if (!isDryRunEnabled) {
|
|
49
55
|
yield applyEnvConfig(projectAbsDir, options).catch((err) => {
|
|
@@ -192,8 +198,12 @@ exports.NewAction = NewAction;
|
|
|
192
198
|
const getApplicationNameInput = (inputs) => inputs.find((input) => input.name === 'name');
|
|
193
199
|
const getOptionByName = (inputs, option) => { var _a; return (_a = inputs.find((input) => input.name === option)) === null || _a === void 0 ? void 0 : _a.value; };
|
|
194
200
|
const getProjectDirectory = (applicationName, directoryOption) => {
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
const appName = (0, formatting_1.normalizeToKebabOrSnakeCase)(applicationName.value);
|
|
202
|
+
if (directoryOption === null || directoryOption === void 0 ? void 0 : directoryOption.value) {
|
|
203
|
+
// --directory 是父目录,项目实际创建在 <directory>/<appName> 下
|
|
204
|
+
return (0, path_1.join)(directoryOption.value, appName);
|
|
205
|
+
}
|
|
206
|
+
return appName;
|
|
197
207
|
};
|
|
198
208
|
const askForMissingInformation = (inputs, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
199
209
|
console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
|