@h-ai/cli 0.1.0-alpha.58 → 0.1.0-alpha.60
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.en.md +43 -20
- package/README.ja.md +43 -20
- package/README.md +43 -20
- package/dist/{chunk-WUSFJFW5.js → chunk-P6X63D3I.js} +64 -6
- package/dist/chunk-P6X63D3I.js.map +1 -0
- package/dist/{chunk-F4IBPVZ5.js → chunk-WWG3U5ZD.js} +20 -2
- package/dist/chunk-WWG3U5ZD.js.map +1 -0
- package/dist/cli-config-templates-EFABFSCY.js +5 -0
- package/dist/{cli-config-templates-6XA7V6CC.js.map → cli-config-templates-EFABFSCY.js.map} +1 -1
- package/dist/{cli-skill-templates-45CK4RQ2.js → cli-skill-templates-2KDUACT6.js} +3 -3
- package/dist/{cli-skill-templates-45CK4RQ2.js.map → cli-skill-templates-2KDUACT6.js.map} +1 -1
- package/dist/index.js +96 -73
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
- package/templates/README.md +8 -0
- package/templates/apps/api/apps/{{projectName}}-service/README.md.hbs +12 -0
- package/templates/apps/api/apps/{{projectName}}-service/src/app.ts.hbs +4 -7
- package/templates/apps/api/apps/{{projectName}}-service/src/lib/server/init.ts.hbs +11 -1
- package/templates/apps/api/apps/{{projectName}}-service/tests/service.test.ts.hbs +2 -1
- package/templates/apps/api/e2e/api-service.spec.ts.hbs +72 -6
- package/templates/apps/api/package.json.hbs +4 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/README.md.hbs +10 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/project.inlang/settings.json.hbs +1 -1
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/README.md.hbs +10 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/project.inlang/settings.json.hbs +1 -1
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/README.md.hbs +2 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/project.inlang/settings.json.hbs +1 -1
- package/templates/apps/fullstack/apps/{{projectName}}-web/README.md.hbs +10 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/project.inlang/settings.json.hbs +1 -1
- package/templates/apps/fullstack/e2e/fullstack.spec.ts.hbs +63 -1
- package/templates/apps/fullstack/packages/{{projectName}}-contract/README.md.hbs +1 -1
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/admin-contract.ts.hbs +8 -1
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/admin-schemas.ts.hbs +1 -1
- package/templates/apps/fullstack/packages/{{projectName}}-serv/README.md.hbs +10 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_iam.yml.hbs +46 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_reach.yml.hbs +21 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/package.json.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/admin-service.ts.hbs +1 -1
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/admin-procedures.ts.hbs +2 -2
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/runtime.ts.hbs +7 -3
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/app-server.test.ts.hbs +11 -4
- package/templates/apps/fullstack/packages/{{projectName}}-shared/README.md.hbs +12 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/en-US.json.hbs +2 -2
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/zh-CN.json.hbs +2 -2
- package/templates/apps/fullstack/packages/{{projectName}}-shared/package.json.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/project.inlang/settings.json.hbs +1 -1
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/api-client.ts.hbs +3 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/AdminWorkspace.svelte.hbs +32 -23
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/ProfileSettings.svelte.hbs +24 -24
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/UserManagement.svelte.hbs +1 -1
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/management-store.svelte.ts.hbs +20 -20
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tests/management-store.test.ts.hbs +7 -8
- package/templates/apps/mobile-app/src/App.svelte.hbs +43 -0
- package/templates/base/e2e/app.spec.ts.hbs +105 -0
- package/templates/base/package.json.hbs +1 -1
- package/templates/base/src/hooks.server.ts.hbs +2 -2
- package/templates/base/src/lib/server/init.ts.hbs +1 -1
- package/templates/base/src/routes/+layout.server.ts.hbs +6 -0
- package/templates/base/tests/scaffold.test.ts.hbs +3 -0
- package/templates/base/vite.config.ts.hbs +1 -0
- package/templates/features/iam/routes-admin/(auth)/+layout.svelte.hbs +2 -16
- package/templates/features/iam/routes-admin/(auth)/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-admin/(auth)/auth/login/+page.svelte.hbs +6 -95
- package/templates/features/iam/routes-admin/(auth)/auth/register/+page.svelte.hbs +6 -117
- package/templates/features/iam/routes-admin/(auth)/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-h5/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-h5/auth/login/+page.svelte.hbs +6 -97
- package/templates/features/iam/routes-h5/auth/register/+page.svelte.hbs +6 -112
- package/templates/features/iam/routes-h5/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-shared/api/auth/config/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/login/+server.ts +1 -33
- package/templates/features/iam/routes-shared/api/auth/login/ldap/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/login/otp/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/otp/send/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/password-reset/confirm/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/password-reset/request/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/register/+server.ts +1 -23
- package/templates/features/iam/routes-website/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-website/auth/login/+page.svelte.hbs +11 -0
- package/templates/features/iam/routes-website/auth/register/+page.svelte.hbs +11 -0
- package/templates/features/iam/routes-website/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/skills/hai-api-client/SKILL.md +5 -0
- package/templates/skills/hai-app-create/SKILL.md +2 -0
- package/templates/skills/hai-app-create/development.md +15 -0
- package/templates/skills/hai-deploy/SKILL.md +2 -0
- package/templates/skills/hai-framework-sync/SKILL.md +4 -0
- package/templates/skills/hai-iam/SKILL.md +9 -2
- package/templates/skills/hai-iam/reference.md +76 -11
- package/templates/skills/hai-reach/SKILL.md +2 -0
- package/templates/skills/hai-ui/reference.md +45 -0
- package/dist/chunk-F4IBPVZ5.js.map +0 -1
- package/dist/chunk-WUSFJFW5.js.map +0 -1
- package/dist/cli-config-templates-6XA7V6CC.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"cli-config-templates-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"cli-config-templates-EFABFSCY.js"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { generateModuleSkillFile, generateProjectAiSupport, generateSkillFiles, resolveCompatibleSkillNames, resolveSkillNamesForPackages } from './chunk-
|
|
2
|
+
export { generateModuleSkillFile, generateProjectAiSupport, generateSkillFiles, resolveCompatibleSkillNames, resolveSkillNamesForPackages } from './chunk-WWG3U5ZD.js';
|
|
3
3
|
import './chunk-2H7UOFLK.js';
|
|
4
|
-
//# sourceMappingURL=cli-skill-templates-
|
|
5
|
-
//# sourceMappingURL=cli-skill-templates-
|
|
4
|
+
//# sourceMappingURL=cli-skill-templates-2KDUACT6.js.map
|
|
5
|
+
//# sourceMappingURL=cli-skill-templates-2KDUACT6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"cli-skill-templates-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"cli-skill-templates-2KDUACT6.js"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { generateConfigFile } from './chunk-
|
|
3
|
-
import { cliM } from './chunk-
|
|
2
|
+
import { generateConfigFile } from './chunk-P6X63D3I.js';
|
|
3
|
+
import { cliM } from './chunk-WWG3U5ZD.js';
|
|
4
4
|
import './chunk-2H7UOFLK.js';
|
|
5
|
-
import
|
|
6
|
-
import { core } from '@h-ai/core';
|
|
5
|
+
import process4 from 'process';
|
|
7
6
|
import { cac } from 'cac';
|
|
8
7
|
import chalk from 'chalk';
|
|
9
8
|
import path2, { resolve } from 'path';
|
|
10
9
|
import { fileURLToPath } from 'url';
|
|
10
|
+
import { wrapAnsi } from 'fast-wrap-ansi';
|
|
11
11
|
import fse from 'fs-extra';
|
|
12
12
|
import Handlebars2 from 'handlebars';
|
|
13
|
+
import { core } from '@h-ai/core';
|
|
13
14
|
import ora from 'ora';
|
|
14
15
|
import prompts from 'prompts';
|
|
15
16
|
import { Buffer } from 'buffer';
|
|
@@ -20,6 +21,20 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
20
21
|
|
|
21
22
|
var CAMEL_CASE_SEPARATOR_REGEX = /[-_\s]+(.)?/g;
|
|
22
23
|
var LEADING_CHAR_REGEX = /^./;
|
|
24
|
+
function writeCliMessage(message) {
|
|
25
|
+
process4.stdout.write(`${message}
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
function writeCliError(message, error) {
|
|
29
|
+
process4.stderr.write(`${message}
|
|
30
|
+
`);
|
|
31
|
+
if (error !== void 0)
|
|
32
|
+
process4.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
function formatPromptDescription(description) {
|
|
36
|
+
return wrapAnsi(description, Math.max(1, (process4.stdout.columns || 80) - 32), { hard: true });
|
|
37
|
+
}
|
|
23
38
|
function toCamelCase(str) {
|
|
24
39
|
return str.replace(CAMEL_CASE_SEPARATOR_REGEX, (_, c) => c ? c.toUpperCase() : "").replace(LEADING_CHAR_REGEX, (c) => c.toLowerCase());
|
|
25
40
|
}
|
|
@@ -177,7 +192,7 @@ var IMPLEMENTED_FRONTENDS = ["web", "app", "desktop"];
|
|
|
177
192
|
var DEFAULT_FULLSTACK_FRONTENDS = ["web", "app", "desktop"];
|
|
178
193
|
var DEFAULT_THEMES = ["light", "dark"];
|
|
179
194
|
var DEFAULT_THEME_NAME = "light";
|
|
180
|
-
var HAI_PACKAGE_VERSION =
|
|
195
|
+
var HAI_PACKAGE_VERSION = getCliVersion();
|
|
181
196
|
var HAI_PACKAGE_SPECIFIER_CATALOG = "catalog:";
|
|
182
197
|
var HAI_CATALOG_PACKAGE_NAMES = [
|
|
183
198
|
"@h-ai/ai",
|
|
@@ -274,6 +289,7 @@ var FULLSTACK_SERV_CATALOG_PACKAGE_NAMES = [
|
|
|
274
289
|
"@h-ai/core",
|
|
275
290
|
"@h-ai/crypto",
|
|
276
291
|
"@h-ai/iam",
|
|
292
|
+
"@h-ai/reach",
|
|
277
293
|
"@h-ai/reldb",
|
|
278
294
|
"@h-ai/serv",
|
|
279
295
|
"@h-ai/storage",
|
|
@@ -281,6 +297,7 @@ var FULLSTACK_SERV_CATALOG_PACKAGE_NAMES = [
|
|
|
281
297
|
];
|
|
282
298
|
var FULLSTACK_SHARED_CATALOG_PACKAGE_NAMES = [
|
|
283
299
|
"@h-ai/api-client",
|
|
300
|
+
"@h-ai/api-contract",
|
|
284
301
|
"@h-ai/core",
|
|
285
302
|
"@h-ai/crypto",
|
|
286
303
|
"@h-ai/ui",
|
|
@@ -400,7 +417,7 @@ function buildApiWorkspaceCatalogPackages(featureMap) {
|
|
|
400
417
|
function buildAppHaiCatalogPackages(options) {
|
|
401
418
|
const packageNames = [];
|
|
402
419
|
if (options.isSvelteOnlyApp) {
|
|
403
|
-
packageNames.push("@h-ai/api-client", "@h-ai/capacitor", "@h-ai/ui");
|
|
420
|
+
packageNames.push("@h-ai/api-client", "@h-ai/api-contract", "@h-ai/capacitor", "@h-ai/ui");
|
|
404
421
|
return pickCatalogPackages(packageNames, HAI_CATALOG_PACKAGES);
|
|
405
422
|
}
|
|
406
423
|
packageNames.push("@h-ai/core", "@h-ai/kit");
|
|
@@ -469,7 +486,7 @@ var FEATURE_ROUTE_DIRS = {
|
|
|
469
486
|
audit: ["routes"]
|
|
470
487
|
};
|
|
471
488
|
var FEATURE_APP_ROUTE_DIRS = {
|
|
472
|
-
iam: ["admin", "h5"]
|
|
489
|
+
iam: ["admin", "h5", "website"]
|
|
473
490
|
};
|
|
474
491
|
var FEATURE_ID_REGEX = /^[a-z0-9-]+$/;
|
|
475
492
|
var HBS_SUFFIX_REGEX = /\.hbs$/;
|
|
@@ -1069,7 +1086,7 @@ async function createProject(options) {
|
|
|
1069
1086
|
try {
|
|
1070
1087
|
const resolvedOptions = await resolveOptions(options);
|
|
1071
1088
|
if (!PROJECT_NAME_REGEX.test(resolvedOptions.name)) {
|
|
1072
|
-
|
|
1089
|
+
writeCliError(chalk.red(`\u9879\u76EE\u540D\u79F0\u4E0D\u5408\u6CD5: "${resolvedOptions.name}"\uFF0C\u53EA\u80FD\u5305\u542B\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26`));
|
|
1073
1090
|
return;
|
|
1074
1091
|
}
|
|
1075
1092
|
const projectPath = path2.resolve(resolvedOptions.cwd ?? ".", resolvedOptions.name);
|
|
@@ -1081,7 +1098,7 @@ async function createProject(options) {
|
|
|
1081
1098
|
initial: false
|
|
1082
1099
|
});
|
|
1083
1100
|
if (!overwrite) {
|
|
1084
|
-
|
|
1101
|
+
writeCliMessage(chalk.yellow("\u5DF2\u53D6\u6D88"));
|
|
1085
1102
|
return;
|
|
1086
1103
|
}
|
|
1087
1104
|
await fse.remove(projectPath);
|
|
@@ -1100,7 +1117,7 @@ async function createProject(options) {
|
|
|
1100
1117
|
});
|
|
1101
1118
|
await generateFromTemplates(projectPath, context);
|
|
1102
1119
|
{
|
|
1103
|
-
const { generateConfigFile: generateConfigFile2, generateEnvExample } = await import('./cli-config-templates-
|
|
1120
|
+
const { generateConfigFile: generateConfigFile2, generateEnvExample } = await import('./cli-config-templates-EFABFSCY.js');
|
|
1104
1121
|
const configs = resolvedOptions.moduleConfigs;
|
|
1105
1122
|
const isApiWorkspace = resolvedOptions.appType === "api";
|
|
1106
1123
|
const isFullstack = resolvedOptions.appType === "fullstack";
|
|
@@ -1138,7 +1155,7 @@ PUBLIC_API_BASE=http://127.0.0.1:3000
|
|
|
1138
1155
|
`), { mode: 384 });
|
|
1139
1156
|
}
|
|
1140
1157
|
}
|
|
1141
|
-
const { generateSkillFiles } = await import('./cli-skill-templates-
|
|
1158
|
+
const { generateSkillFiles } = await import('./cli-skill-templates-2KDUACT6.js');
|
|
1142
1159
|
await generateSkillFiles(
|
|
1143
1160
|
projectPath,
|
|
1144
1161
|
resolvedOptions.features,
|
|
@@ -1173,19 +1190,19 @@ PUBLIC_API_BASE=http://127.0.0.1:3000
|
|
|
1173
1190
|
printCompletionMessage(resolvedOptions);
|
|
1174
1191
|
} catch (error) {
|
|
1175
1192
|
spinner.fail();
|
|
1176
|
-
|
|
1193
|
+
writeCliError(chalk.red(cliM("cli_createFailed")), error);
|
|
1177
1194
|
throw error;
|
|
1178
1195
|
}
|
|
1179
1196
|
}
|
|
1180
1197
|
async function resolveOptions(options) {
|
|
1181
1198
|
const useDefaults = options.yes ?? false;
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1199
|
+
writeCliMessage("");
|
|
1200
|
+
writeCliMessage(chalk.bold.cyan(" \u{1F680} hai Agent Framework"));
|
|
1201
|
+
writeCliMessage(chalk.gray(" AI-Native \xB7 Configuration-Driven \xB7 Security-First"));
|
|
1202
|
+
writeCliMessage("");
|
|
1186
1203
|
const onCancel = () => {
|
|
1187
|
-
|
|
1188
|
-
|
|
1204
|
+
writeCliMessage(chalk.red("\n\u5DF2\u53D6\u6D88"));
|
|
1205
|
+
process4.exit(1);
|
|
1189
1206
|
};
|
|
1190
1207
|
let projectName = options.name;
|
|
1191
1208
|
if (!projectName && useDefaults) {
|
|
@@ -1214,8 +1231,10 @@ async function resolveOptions(options) {
|
|
|
1214
1231
|
type: "select",
|
|
1215
1232
|
name: "appType",
|
|
1216
1233
|
message: "\u5E94\u7528\u7C7B\u578B:",
|
|
1234
|
+
hint: cliM("cli_selectHint"),
|
|
1217
1235
|
choices: Object.entries(APP_TYPES).map(([key, t]) => ({
|
|
1218
|
-
title:
|
|
1236
|
+
title: t.name,
|
|
1237
|
+
description: formatPromptDescription(t.description),
|
|
1219
1238
|
value: key
|
|
1220
1239
|
})),
|
|
1221
1240
|
initial: 0
|
|
@@ -1235,8 +1254,10 @@ async function resolveOptions(options) {
|
|
|
1235
1254
|
type: "select",
|
|
1236
1255
|
name: "template",
|
|
1237
1256
|
message: "\u9009\u62E9\u6A21\u677F:",
|
|
1257
|
+
hint: cliM("cli_selectHint"),
|
|
1238
1258
|
choices: Object.values(PROJECT_TEMPLATES).map((t) => ({
|
|
1239
|
-
title:
|
|
1259
|
+
title: t.name,
|
|
1260
|
+
description: formatPromptDescription(t.description),
|
|
1240
1261
|
value: t.name
|
|
1241
1262
|
})),
|
|
1242
1263
|
initial: 1
|
|
@@ -1252,16 +1273,17 @@ async function resolveOptions(options) {
|
|
|
1252
1273
|
selectedFeatures = resolveFeatureDependencies(appTypeDefaults);
|
|
1253
1274
|
} else if (selectedTemplate === "custom" && !options.features) {
|
|
1254
1275
|
const featureChoices = SELECTABLE_FEATURES.map((id) => ({
|
|
1255
|
-
title:
|
|
1276
|
+
title: FEATURES[id].name,
|
|
1277
|
+
description: formatPromptDescription(FEATURES[id].description),
|
|
1256
1278
|
value: id,
|
|
1257
1279
|
selected: appTypeDefaults.includes(id)
|
|
1258
1280
|
}));
|
|
1259
1281
|
const { features } = await prompts({
|
|
1260
1282
|
type: "multiselect",
|
|
1261
1283
|
name: "features",
|
|
1262
|
-
message: "
|
|
1284
|
+
message: cliM("cli_featuresPrompt"),
|
|
1263
1285
|
choices: featureChoices,
|
|
1264
|
-
hint: "
|
|
1286
|
+
hint: cliM("cli_multiselectHint"),
|
|
1265
1287
|
instructions: false
|
|
1266
1288
|
}, { onCancel });
|
|
1267
1289
|
selectedFeatures = features || [];
|
|
@@ -1396,13 +1418,14 @@ async function resolveFrontendTargets(frontends, useDefaults, onCancel) {
|
|
|
1396
1418
|
const { selectedFrontends } = await prompts({
|
|
1397
1419
|
type: "multiselect",
|
|
1398
1420
|
name: "selectedFrontends",
|
|
1399
|
-
message: "
|
|
1421
|
+
message: cliM("cli_frontendsPrompt"),
|
|
1400
1422
|
choices: Object.entries(FRONTEND_TARGETS).map(([id, target]) => ({
|
|
1401
|
-
title:
|
|
1423
|
+
title: target.name,
|
|
1424
|
+
description: formatPromptDescription(target.description),
|
|
1402
1425
|
value: id,
|
|
1403
1426
|
selected: DEFAULT_FULLSTACK_FRONTENDS2.includes(id)
|
|
1404
1427
|
})),
|
|
1405
|
-
hint: "
|
|
1428
|
+
hint: cliM("cli_multiselectHint"),
|
|
1406
1429
|
instructions: false
|
|
1407
1430
|
}, { onCancel });
|
|
1408
1431
|
return normalizeFrontendTargets(selectedFrontends ?? DEFAULT_FULLSTACK_FRONTENDS2);
|
|
@@ -1434,13 +1457,13 @@ function resolveFeatureDependencies(features) {
|
|
|
1434
1457
|
async function promptModuleConfigs(features, projectName) {
|
|
1435
1458
|
const configs = {};
|
|
1436
1459
|
const onCancel = () => {
|
|
1437
|
-
|
|
1438
|
-
|
|
1460
|
+
writeCliMessage(chalk.red("\n\u5DF2\u53D6\u6D88"));
|
|
1461
|
+
process4.exit(1);
|
|
1439
1462
|
};
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1463
|
+
writeCliMessage("");
|
|
1464
|
+
writeCliMessage(chalk.bold(" \u2699 \u6A21\u5757\u914D\u7F6E"));
|
|
1465
|
+
writeCliMessage(chalk.gray(" \u8BBE\u7F6E\u5173\u952E\u914D\u7F6E\u9879\uFF08\u56DE\u8F66\u4F7F\u7528\u9ED8\u8BA4\u503C\uFF09"));
|
|
1466
|
+
writeCliMessage("");
|
|
1444
1467
|
configs.core = await promptCoreConfig(projectName, onCancel);
|
|
1445
1468
|
if (features.includes("db")) {
|
|
1446
1469
|
configs.db = await promptDbConfig(projectName, onCancel);
|
|
@@ -1460,7 +1483,7 @@ async function promptModuleConfigs(features, projectName) {
|
|
|
1460
1483
|
return configs;
|
|
1461
1484
|
}
|
|
1462
1485
|
async function promptCoreConfig(projectName, onCancel) {
|
|
1463
|
-
|
|
1486
|
+
writeCliMessage(chalk.cyan(" [core] \u5E94\u7528\u57FA\u7840\u914D\u7F6E"));
|
|
1464
1487
|
const { defaultLocale } = await prompts({
|
|
1465
1488
|
type: "select",
|
|
1466
1489
|
name: "defaultLocale",
|
|
@@ -1474,7 +1497,7 @@ async function promptCoreConfig(projectName, onCancel) {
|
|
|
1474
1497
|
return { name: projectName, defaultLocale };
|
|
1475
1498
|
}
|
|
1476
1499
|
async function promptDbConfig(projectName, onCancel) {
|
|
1477
|
-
|
|
1500
|
+
writeCliMessage(chalk.cyan(" [db] \u6570\u636E\u5E93\u914D\u7F6E"));
|
|
1478
1501
|
const { type } = await prompts({
|
|
1479
1502
|
type: "select",
|
|
1480
1503
|
name: "type",
|
|
@@ -1503,7 +1526,7 @@ async function promptDbConfig(projectName, onCancel) {
|
|
|
1503
1526
|
return { type, host: answers.host, port: answers.port, database: answers.database };
|
|
1504
1527
|
}
|
|
1505
1528
|
async function promptCacheConfig(onCancel) {
|
|
1506
|
-
|
|
1529
|
+
writeCliMessage(chalk.cyan(" [cache] \u7F13\u5B58\u914D\u7F6E"));
|
|
1507
1530
|
const { type } = await prompts({
|
|
1508
1531
|
type: "select",
|
|
1509
1532
|
name: "type",
|
|
@@ -1523,7 +1546,7 @@ async function promptCacheConfig(onCancel) {
|
|
|
1523
1546
|
return { type, host: answers.host, port: answers.port };
|
|
1524
1547
|
}
|
|
1525
1548
|
async function promptIamConfig(onCancel) {
|
|
1526
|
-
|
|
1549
|
+
writeCliMessage(chalk.cyan(" [iam] \u8BA4\u8BC1\u6388\u6743\u914D\u7F6E"));
|
|
1527
1550
|
const answers = await prompts([
|
|
1528
1551
|
{ type: "confirm", name: "loginPassword", message: "\u542F\u7528\u5BC6\u7801\u767B\u5F55?", initial: true },
|
|
1529
1552
|
{ type: "confirm", name: "loginOtp", message: "\u542F\u7528 OTP \u9A8C\u8BC1\u7801\u767B\u5F55?", initial: false }
|
|
@@ -1531,7 +1554,7 @@ async function promptIamConfig(onCancel) {
|
|
|
1531
1554
|
return { loginPassword: answers.loginPassword, loginOtp: answers.loginOtp };
|
|
1532
1555
|
}
|
|
1533
1556
|
async function promptStorageConfig(onCancel) {
|
|
1534
|
-
|
|
1557
|
+
writeCliMessage(chalk.cyan(" [storage] \u6587\u4EF6\u5B58\u50A8\u914D\u7F6E"));
|
|
1535
1558
|
const { type } = await prompts({
|
|
1536
1559
|
type: "select",
|
|
1537
1560
|
name: "type",
|
|
@@ -1554,7 +1577,7 @@ async function promptStorageConfig(onCancel) {
|
|
|
1554
1577
|
return { type };
|
|
1555
1578
|
}
|
|
1556
1579
|
async function promptAiConfig(onCancel) {
|
|
1557
|
-
|
|
1580
|
+
writeCliMessage(chalk.cyan(" [ai] AI \u96C6\u6210\u914D\u7F6E"));
|
|
1558
1581
|
const { defaultProvider } = await prompts({
|
|
1559
1582
|
type: "select",
|
|
1560
1583
|
name: "defaultProvider",
|
|
@@ -1615,21 +1638,21 @@ function installDependencies(projectPath, pm) {
|
|
|
1615
1638
|
});
|
|
1616
1639
|
} catch (error) {
|
|
1617
1640
|
const details = formatCommandFailure(installCmd, error);
|
|
1618
|
-
throw new Error(
|
|
1641
|
+
throw new Error(`${cliM("cli_installFailed", { params: { pm } })}
|
|
1619
1642
|
${details}`);
|
|
1620
1643
|
}
|
|
1621
1644
|
}
|
|
1622
1645
|
function formatCommandFailure(command, error) {
|
|
1623
1646
|
if (!error || typeof error !== "object") {
|
|
1624
|
-
return
|
|
1647
|
+
return cliM("cli_commandLabel", { params: { command } });
|
|
1625
1648
|
}
|
|
1626
1649
|
const failure = error;
|
|
1627
1650
|
const stdout = normalizeChildOutput(failure.stdout);
|
|
1628
1651
|
const stderr = normalizeChildOutput(failure.stderr);
|
|
1629
|
-
const status = typeof failure.status === "number" ?
|
|
1630
|
-
const signal = typeof failure.signal === "string" ?
|
|
1652
|
+
const status = typeof failure.status === "number" ? cliM("cli_exitCode", { params: { code: failure.status } }) : "";
|
|
1653
|
+
const signal = typeof failure.signal === "string" ? cliM("cli_signal", { params: { signal: failure.signal } }) : "";
|
|
1631
1654
|
const output = [
|
|
1632
|
-
|
|
1655
|
+
cliM("cli_commandLabel", { params: { command } }),
|
|
1633
1656
|
status,
|
|
1634
1657
|
signal,
|
|
1635
1658
|
stderr ? `stderr:
|
|
@@ -1964,35 +1987,35 @@ ${generateAiDevelopmentReadme()}## \u6587\u6863
|
|
|
1964
1987
|
`;
|
|
1965
1988
|
}
|
|
1966
1989
|
function printCompletionMessage(options) {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1990
|
+
writeCliMessage("");
|
|
1991
|
+
writeCliMessage(chalk.green("\u2714 \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01"));
|
|
1992
|
+
writeCliMessage("");
|
|
1970
1993
|
if (options.features.length > 0) {
|
|
1971
|
-
|
|
1994
|
+
writeCliMessage(chalk.bold("\u5DF2\u542F\u7528\u529F\u80FD:"));
|
|
1972
1995
|
for (const featureId of options.features) {
|
|
1973
1996
|
const feature = FEATURES[featureId];
|
|
1974
1997
|
if (feature) {
|
|
1975
|
-
|
|
1998
|
+
writeCliMessage(chalk.gray(` \u2022 ${feature.name} (${featureId})`));
|
|
1976
1999
|
}
|
|
1977
2000
|
}
|
|
1978
|
-
|
|
2001
|
+
writeCliMessage("");
|
|
1979
2002
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
2003
|
+
writeCliMessage("\u4E0B\u4E00\u6B65\uFF1A");
|
|
2004
|
+
writeCliMessage(chalk.cyan(` cd ${options.name}`));
|
|
1982
2005
|
if (options.appType === "fullstack")
|
|
1983
|
-
|
|
2006
|
+
writeCliMessage(chalk.cyan(cliM("cli_adminPasswordSaved")));
|
|
1984
2007
|
if (!options.install) {
|
|
1985
|
-
|
|
2008
|
+
writeCliMessage(chalk.cyan(` ${getInstallCommand(options.packageManager)}`));
|
|
1986
2009
|
}
|
|
1987
2010
|
if (options.appType === "fullstack" || options.appType === "api") {
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2011
|
+
writeCliMessage(chalk.cyan(` ${getRunCommand(options.packageManager, "dev")}`));
|
|
2012
|
+
writeCliMessage(chalk.cyan(` ${getRunCommand(options.packageManager, "typecheck")}`));
|
|
2013
|
+
writeCliMessage(chalk.cyan(` ${getRunCommand(options.packageManager, "test")}`));
|
|
2014
|
+
writeCliMessage(chalk.cyan(` ${getRunCommand(options.packageManager, "test:e2e")}`));
|
|
1992
2015
|
} else {
|
|
1993
|
-
|
|
2016
|
+
writeCliMessage(chalk.cyan(` ${getRunCommand(options.packageManager, "dev")}`));
|
|
1994
2017
|
}
|
|
1995
|
-
|
|
2018
|
+
writeCliMessage("");
|
|
1996
2019
|
}
|
|
1997
2020
|
async function detectProject(cwd) {
|
|
1998
2021
|
const pkgPath = path2.join(cwd, "package.json");
|
|
@@ -2074,7 +2097,7 @@ async function addModule(options) {
|
|
|
2074
2097
|
core.logger.info(`\u53EF\u7528\u6A21\u5757: ${Object.keys(MODULE_MAP).join(", ")}`);
|
|
2075
2098
|
return;
|
|
2076
2099
|
}
|
|
2077
|
-
const { generateProjectAiSupport, resolveSkillNamesForPackages } = await import('./cli-skill-templates-
|
|
2100
|
+
const { generateProjectAiSupport, resolveSkillNamesForPackages } = await import('./cli-skill-templates-2KDUACT6.js');
|
|
2078
2101
|
if (moduleDef.packages.every((p) => project.haiPackages.includes(p))) {
|
|
2079
2102
|
const generatedFiles2 = await generateProjectAiSupport(
|
|
2080
2103
|
cwd,
|
|
@@ -2111,7 +2134,7 @@ async function addModule(options) {
|
|
|
2111
2134
|
if (!pkg.dependencies)
|
|
2112
2135
|
pkg.dependencies = {};
|
|
2113
2136
|
const existingHaiSpecifier = Object.entries(pkg.dependencies).find(([pkgName]) => pkgName.startsWith("@h-ai/"))?.[1];
|
|
2114
|
-
const depVersion = existingHaiSpecifier === "catalog:" ? "catalog:" :
|
|
2137
|
+
const depVersion = existingHaiSpecifier === "catalog:" ? "catalog:" : getCliVersion();
|
|
2115
2138
|
for (const pkgName of allPackages) {
|
|
2116
2139
|
if (!pkg.dependencies[pkgName]) {
|
|
2117
2140
|
pkg.dependencies[pkgName] = depVersion;
|
|
@@ -2182,7 +2205,7 @@ async function addModule(options) {
|
|
|
2182
2205
|
}
|
|
2183
2206
|
async function deployCommand(options) {
|
|
2184
2207
|
const spinner = ora();
|
|
2185
|
-
const cwd = options.cwd ??
|
|
2208
|
+
const cwd = options.cwd ?? process4.cwd();
|
|
2186
2209
|
const appDir = resolve(cwd, options.appDir ?? ".");
|
|
2187
2210
|
let closeDeploy = null;
|
|
2188
2211
|
try {
|
|
@@ -2258,14 +2281,14 @@ async function deployCommand(options) {
|
|
|
2258
2281
|
await closeDeploy();
|
|
2259
2282
|
} catch (error) {
|
|
2260
2283
|
core.logger.error("Failed to close deploy module", { error });
|
|
2261
|
-
|
|
2284
|
+
process4.exitCode = 1;
|
|
2262
2285
|
}
|
|
2263
2286
|
}
|
|
2264
2287
|
}
|
|
2265
2288
|
}
|
|
2266
2289
|
function interpolateEnvFallback(content) {
|
|
2267
2290
|
return content.replace(/\$\{([^:}]+)(?::([^}]*))?\}/g, (_match, key, defaultValue) => {
|
|
2268
|
-
return
|
|
2291
|
+
return process4.env[key] ?? defaultValue ?? "";
|
|
2269
2292
|
});
|
|
2270
2293
|
}
|
|
2271
2294
|
var GENERATORS = {
|
|
@@ -2609,7 +2632,7 @@ async function initProject(options) {
|
|
|
2609
2632
|
const { project, existing, missing } = result;
|
|
2610
2633
|
spinner.succeed(`\u68C0\u6D4B\u5230\u9879\u76EE: ${chalk.cyan(project.name)}`);
|
|
2611
2634
|
if (project.isHaiProject) {
|
|
2612
|
-
const { generateProjectAiSupport, resolveSkillNamesForPackages } = await import('./cli-skill-templates-
|
|
2635
|
+
const { generateProjectAiSupport, resolveSkillNamesForPackages } = await import('./cli-skill-templates-2KDUACT6.js');
|
|
2613
2636
|
const generatedFiles = await generateProjectAiSupport(cwd, resolveSkillNamesForPackages(project.haiPackages), {
|
|
2614
2637
|
overwriteSkills: false,
|
|
2615
2638
|
overwriteBridgeFiles: false
|
|
@@ -2713,7 +2736,7 @@ cli.command("create [name]", "\u521B\u5EFA\u65B0\u7684 hai \u9879\u76EE").option
|
|
|
2713
2736
|
cwd: options.cwd
|
|
2714
2737
|
});
|
|
2715
2738
|
} catch {
|
|
2716
|
-
|
|
2739
|
+
process4.exitCode = 1;
|
|
2717
2740
|
}
|
|
2718
2741
|
});
|
|
2719
2742
|
cli.command("add [module]", "\u5411\u73B0\u6709\u9879\u76EE\u6DFB\u52A0\u6A21\u5757").option("--no-install", "\u4E0D\u5B89\u88C5\u4F9D\u8D56").action(async (module, options) => {
|
|
@@ -2725,7 +2748,7 @@ cli.command("add [module]", "\u5411\u73B0\u6709\u9879\u76EE\u6DFB\u52A0\u6A21\u5
|
|
|
2725
2748
|
cwd: options.cwd
|
|
2726
2749
|
});
|
|
2727
2750
|
} catch {
|
|
2728
|
-
|
|
2751
|
+
process4.exit(1);
|
|
2729
2752
|
}
|
|
2730
2753
|
});
|
|
2731
2754
|
cli.command("init", "\u521D\u59CB\u5316/\u6821\u9A8C\u9879\u76EE\u914D\u7F6E").option("-f, --force", "\u5F3A\u5236\u91CD\u65B0\u751F\u6210\u914D\u7F6E").action(async (options) => {
|
|
@@ -2736,7 +2759,7 @@ cli.command("init", "\u521D\u59CB\u5316/\u6821\u9A8C\u9879\u76EE\u914D\u7F6E").o
|
|
|
2736
2759
|
cwd: options.cwd
|
|
2737
2760
|
});
|
|
2738
2761
|
} catch {
|
|
2739
|
-
|
|
2762
|
+
process4.exit(1);
|
|
2740
2763
|
}
|
|
2741
2764
|
});
|
|
2742
2765
|
cli.command("generate [type] [name]", "\u751F\u6210\u4EE3\u7801").alias("g").option("-o, --output <path>", "\u8F93\u51FA\u8DEF\u5F84").option("-f, --force", "\u8986\u76D6\u73B0\u6709\u6587\u4EF6").action(async (type, name, options) => {
|
|
@@ -2750,7 +2773,7 @@ cli.command("generate [type] [name]", "\u751F\u6210\u4EE3\u7801").alias("g").opt
|
|
|
2750
2773
|
cwd: options.cwd
|
|
2751
2774
|
});
|
|
2752
2775
|
} catch {
|
|
2753
|
-
|
|
2776
|
+
process4.exit(1);
|
|
2754
2777
|
}
|
|
2755
2778
|
});
|
|
2756
2779
|
cli.command("deploy [appDir]", "\u90E8\u7F72\u5E94\u7528\u5230\u4E91\u5E73\u53F0").option("--project-name <name>", "\u9879\u76EE\u540D\u79F0\uFF08\u9ED8\u8BA4\u4ECE package.json \u8BFB\u53D6\uFF09").option("--skip-provision", "\u8DF3\u8FC7\u57FA\u7840\u8BBE\u65BD\u5F00\u901A").option("--skip-build", "\u8DF3\u8FC7\u6784\u5EFA").action(async (appDir, options) => {
|
|
@@ -2764,7 +2787,7 @@ cli.command("deploy [appDir]", "\u90E8\u7F72\u5E94\u7528\u5230\u4E91\u5E73\u53F0
|
|
|
2764
2787
|
cwd: options.cwd
|
|
2765
2788
|
});
|
|
2766
2789
|
} catch {
|
|
2767
|
-
|
|
2790
|
+
process4.exit(1);
|
|
2768
2791
|
}
|
|
2769
2792
|
});
|
|
2770
2793
|
cli.command("g:page <name>", "\u751F\u6210\u9875\u9762").action(async (name, options) => {
|
|
@@ -2783,9 +2806,9 @@ cli.version(VERSION);
|
|
|
2783
2806
|
cli.help();
|
|
2784
2807
|
var parsed = cli.parse();
|
|
2785
2808
|
if (!cli.matchedCommand && !parsed.options.help && !parsed.options.version) {
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2809
|
+
writeCliMessage("");
|
|
2810
|
+
writeCliMessage(chalk.cyan("hai Agent Framework CLI"));
|
|
2811
|
+
writeCliMessage("");
|
|
2789
2812
|
cli.outputHelp();
|
|
2790
2813
|
}
|
|
2791
2814
|
//# sourceMappingURL=index.js.map
|