@deepstorm/cli 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/dist/cli.js +93 -42
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -6247,19 +6247,38 @@ function initContextMap(targetDir, opts) {
|
|
|
6247
6247
|
const content = CONTEXT_MD_TEMPLATE.replace("{backend.language}", backendLang).replace("{frontend.framework}", frontendFramework);
|
|
6248
6248
|
fs2.writeFileSync(contextPath, content, "utf-8");
|
|
6249
6249
|
console.log("\u2714 \u5DF2\u521B\u5EFA .deepstorm/context.md \u9879\u76EE\u4E0A\u4E0B\u6587\u5730\u56FE");
|
|
6250
|
-
appendClaudeMdRef(targetDir);
|
|
6251
6250
|
}
|
|
6252
|
-
function
|
|
6253
|
-
const
|
|
6254
|
-
const
|
|
6255
|
-
if (
|
|
6256
|
-
|
|
6257
|
-
|
|
6251
|
+
function initClaudeMd(targetDir, opts) {
|
|
6252
|
+
const claudeDir = path2.join(targetDir, ".claude");
|
|
6253
|
+
const claudeMdPath = path2.join(claudeDir, "CLAUDE.md");
|
|
6254
|
+
if (fs2.existsSync(claudeMdPath)) return;
|
|
6255
|
+
ensureDir2(claudeDir);
|
|
6256
|
+
const projectName = opts.projectName || "unknown";
|
|
6257
|
+
const lines = [
|
|
6258
|
+
`# ${projectName}`,
|
|
6259
|
+
""
|
|
6260
|
+
];
|
|
6261
|
+
const techLines = [];
|
|
6262
|
+
if (opts.frontend) {
|
|
6263
|
+
techLines.push(`- **\u524D\u7AEF**\uFF1A${opts.frontend}`);
|
|
6264
|
+
if (opts.uiLib) techLines.push(`- **UI \u5E93**\uFF1A${opts.uiLib}`);
|
|
6265
|
+
if (opts.cssFramework) techLines.push(`- **CSS \u65B9\u6848**\uFF1A${opts.cssFramework}`);
|
|
6266
|
+
}
|
|
6267
|
+
if (opts.backend) {
|
|
6268
|
+
techLines.push(`- **\u540E\u7AEF**\uFF1A${opts.backend}`);
|
|
6269
|
+
if (opts.orm) techLines.push(`- **ORM**\uFF1A${opts.orm}`);
|
|
6270
|
+
if (opts.migration) techLines.push(`- **\u6570\u636E\u5E93\u8FC1\u79FB**\uFF1A${opts.migration}`);
|
|
6271
|
+
if (opts.ai) techLines.push(`- **AI \u6846\u67B6**\uFF1A${opts.ai}`);
|
|
6258
6272
|
}
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6273
|
+
if (techLines.length > 0) {
|
|
6274
|
+
lines.push("## \u6280\u672F\u6808", "");
|
|
6275
|
+
lines.push(...techLines);
|
|
6276
|
+
lines.push("");
|
|
6277
|
+
}
|
|
6278
|
+
lines.push("> \u9879\u76EE\u4E8B\u5B9E\u89C1 .deepstorm/context.md");
|
|
6279
|
+
lines.push("");
|
|
6280
|
+
fs2.writeFileSync(claudeMdPath, lines.join("\n"), "utf-8");
|
|
6281
|
+
console.log("\u2714 \u5DF2\u521B\u5EFA .claude/claude.md \u9879\u76EE\u4FE1\u606F");
|
|
6263
6282
|
}
|
|
6264
6283
|
function writeInitTechStack(baseDir, opts) {
|
|
6265
6284
|
const config = {};
|
|
@@ -6280,6 +6299,7 @@ function writeInitTechStack(baseDir, opts) {
|
|
|
6280
6299
|
const nested = buildInitNestedConfig(config);
|
|
6281
6300
|
writeDeepStormConfig(baseDir, nested);
|
|
6282
6301
|
initContextMap(baseDir, opts);
|
|
6302
|
+
initClaudeMd(baseDir, opts);
|
|
6283
6303
|
}
|
|
6284
6304
|
function buildInitNestedConfig(flat) {
|
|
6285
6305
|
const result = { reef: {} };
|
|
@@ -6346,9 +6366,10 @@ async function promptContinueSetup(targetDir, projectName, registry2) {
|
|
|
6346
6366
|
}
|
|
6347
6367
|
}
|
|
6348
6368
|
function buildContext(opts) {
|
|
6369
|
+
const projectName = opts.projectName || "project";
|
|
6349
6370
|
return {
|
|
6350
|
-
projectName
|
|
6351
|
-
packageName:
|
|
6371
|
+
projectName,
|
|
6372
|
+
packageName: projectName.replace(/[_-]/g, "").toLowerCase(),
|
|
6352
6373
|
groupId: "com.example",
|
|
6353
6374
|
frontend: opts.frontend || false,
|
|
6354
6375
|
backend: opts.backend || false,
|
|
@@ -6362,19 +6383,34 @@ function buildContext(opts) {
|
|
|
6362
6383
|
async function runInteractiveMode(targetDir) {
|
|
6363
6384
|
const { intro: intro2, outro: outro2, text: text2, select: select2, isCancel: isCancel8, confirm: confirm6 } = await import("@clack/prompts");
|
|
6364
6385
|
intro2("\u{1F680} DeepStorm Init \u2014 \u9879\u76EE\u811A\u624B\u67B6\u521D\u59CB\u5316");
|
|
6365
|
-
const
|
|
6366
|
-
message: "\u9879\u76EE\
|
|
6367
|
-
|
|
6368
|
-
validate: (value) => {
|
|
6369
|
-
if (!value) return "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0";
|
|
6370
|
-
if (!VALID_PROJECT_NAME.test(value)) return "\u9879\u76EE\u540D\u4EC5\u652F\u6301\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u77ED\u6A2A\u7EBF";
|
|
6371
|
-
return void 0;
|
|
6372
|
-
}
|
|
6386
|
+
const isProjectDir = await confirm6({
|
|
6387
|
+
message: "\u5F53\u524D\u8DEF\u5F84\u662F\u5426\u4E3A\u9879\u76EE\u76EE\u5F55\uFF1F",
|
|
6388
|
+
initialValue: false
|
|
6373
6389
|
});
|
|
6374
|
-
if (isCancel8(
|
|
6390
|
+
if (isCancel8(isProjectDir)) {
|
|
6375
6391
|
outro2("\u5DF2\u53D6\u6D88");
|
|
6376
6392
|
return;
|
|
6377
6393
|
}
|
|
6394
|
+
let projectName;
|
|
6395
|
+
if (isProjectDir) {
|
|
6396
|
+
console.log("\u2713 \u5C06\u5728\u5F53\u524D\u76EE\u5F55\u76F4\u63A5\u751F\u6210\u811A\u624B\u67B6");
|
|
6397
|
+
projectName = void 0;
|
|
6398
|
+
} else {
|
|
6399
|
+
const name = await text2({
|
|
6400
|
+
message: "\u9879\u76EE\u540D\u79F0\uFF1A",
|
|
6401
|
+
placeholder: "my-project",
|
|
6402
|
+
validate: (value) => {
|
|
6403
|
+
if (!value) return "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0";
|
|
6404
|
+
if (!VALID_PROJECT_NAME.test(value)) return "\u9879\u76EE\u540D\u4EC5\u652F\u6301\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u77ED\u6A2A\u7EBF";
|
|
6405
|
+
return void 0;
|
|
6406
|
+
}
|
|
6407
|
+
});
|
|
6408
|
+
if (isCancel8(name) || typeof name !== "string") {
|
|
6409
|
+
outro2("\u5DF2\u53D6\u6D88");
|
|
6410
|
+
return;
|
|
6411
|
+
}
|
|
6412
|
+
projectName = name;
|
|
6413
|
+
}
|
|
6378
6414
|
const frontendChoice = await select2({
|
|
6379
6415
|
message: "\u9009\u62E9\u524D\u7AEF\u6846\u67B6\uFF1A",
|
|
6380
6416
|
options: [
|
|
@@ -6389,28 +6425,30 @@ async function runInteractiveMode(targetDir) {
|
|
|
6389
6425
|
let uiLib;
|
|
6390
6426
|
let cssFramework;
|
|
6391
6427
|
if (frontendChoice === "angular") {
|
|
6392
|
-
|
|
6428
|
+
const uiLibResult = await select2({
|
|
6393
6429
|
message: "\u9009\u62E9 UI \u5E93\uFF1A",
|
|
6394
6430
|
options: [
|
|
6395
6431
|
{ value: "primeng", label: "PrimeNG" },
|
|
6396
6432
|
{ value: "none", label: "\u65E0\uFF08\u4EC5 Angular \u6838\u5FC3\uFF09" }
|
|
6397
6433
|
]
|
|
6398
6434
|
});
|
|
6399
|
-
if (isCancel8(
|
|
6435
|
+
if (isCancel8(uiLibResult)) {
|
|
6400
6436
|
outro2("\u5DF2\u53D6\u6D88");
|
|
6401
6437
|
return;
|
|
6402
6438
|
}
|
|
6403
|
-
|
|
6439
|
+
uiLib = uiLibResult;
|
|
6440
|
+
const cssResult = await select2({
|
|
6404
6441
|
message: "\u9009\u62E9 CSS \u65B9\u6848\uFF1A",
|
|
6405
6442
|
options: [
|
|
6406
6443
|
{ value: "tailwind", label: "Tailwind CSS" },
|
|
6407
6444
|
{ value: "none", label: "\u6807\u51C6 CSS" }
|
|
6408
6445
|
]
|
|
6409
6446
|
});
|
|
6410
|
-
if (isCancel8(
|
|
6447
|
+
if (isCancel8(cssResult)) {
|
|
6411
6448
|
outro2("\u5DF2\u53D6\u6D88");
|
|
6412
6449
|
return;
|
|
6413
6450
|
}
|
|
6451
|
+
cssFramework = cssResult;
|
|
6414
6452
|
}
|
|
6415
6453
|
const backendChoice = await select2({
|
|
6416
6454
|
message: "\u9009\u62E9\u540E\u7AEF\u6846\u67B6\uFF1A",
|
|
@@ -6427,39 +6465,42 @@ async function runInteractiveMode(targetDir) {
|
|
|
6427
6465
|
let migration;
|
|
6428
6466
|
let aiChoice;
|
|
6429
6467
|
if (backendChoice === "java") {
|
|
6430
|
-
|
|
6468
|
+
const ormResult = await select2({
|
|
6431
6469
|
message: "\u9009\u62E9 ORM \u6846\u67B6\uFF1A",
|
|
6432
6470
|
options: [
|
|
6433
6471
|
{ value: "hibernate", label: "Hibernate" },
|
|
6434
6472
|
{ value: "none", label: "\u65E0" }
|
|
6435
6473
|
]
|
|
6436
6474
|
});
|
|
6437
|
-
if (isCancel8(
|
|
6475
|
+
if (isCancel8(ormResult)) {
|
|
6438
6476
|
outro2("\u5DF2\u53D6\u6D88");
|
|
6439
6477
|
return;
|
|
6440
6478
|
}
|
|
6441
|
-
|
|
6479
|
+
orm = ormResult;
|
|
6480
|
+
const migrationResult = await select2({
|
|
6442
6481
|
message: "\u9009\u62E9\u6570\u636E\u5E93\u8FC1\u79FB\u5DE5\u5177\uFF1A",
|
|
6443
6482
|
options: [
|
|
6444
6483
|
{ value: "liquibase", label: "Liquibase" },
|
|
6445
6484
|
{ value: "none", label: "\u65E0" }
|
|
6446
6485
|
]
|
|
6447
6486
|
});
|
|
6448
|
-
if (isCancel8(
|
|
6487
|
+
if (isCancel8(migrationResult)) {
|
|
6449
6488
|
outro2("\u5DF2\u53D6\u6D88");
|
|
6450
6489
|
return;
|
|
6451
6490
|
}
|
|
6452
|
-
|
|
6491
|
+
migration = migrationResult;
|
|
6492
|
+
const aiResult = await select2({
|
|
6453
6493
|
message: "\u9009\u62E9 AI \u6846\u67B6\uFF1A",
|
|
6454
6494
|
options: [
|
|
6455
6495
|
{ value: "spring-ai", label: "Spring AI" },
|
|
6456
6496
|
{ value: "none", label: "\u65E0" }
|
|
6457
6497
|
]
|
|
6458
6498
|
});
|
|
6459
|
-
if (isCancel8(
|
|
6499
|
+
if (isCancel8(aiResult)) {
|
|
6460
6500
|
outro2("\u5DF2\u53D6\u6D88");
|
|
6461
6501
|
return;
|
|
6462
6502
|
}
|
|
6503
|
+
aiChoice = aiResult;
|
|
6463
6504
|
}
|
|
6464
6505
|
if ((!frontendChoice || frontendChoice === "none") && (!backendChoice || backendChoice === "none")) {
|
|
6465
6506
|
console.error("\u274C \u81F3\u5C11\u9700\u8981\u9009\u62E9\u524D\u7AEF\u6216\u540E\u7AEF\u4E4B\u4E00");
|
|
@@ -6481,18 +6522,19 @@ async function runInteractiveMode(targetDir) {
|
|
|
6481
6522
|
return opts;
|
|
6482
6523
|
}
|
|
6483
6524
|
async function runInit(baseDir, opts) {
|
|
6484
|
-
|
|
6485
|
-
|
|
6525
|
+
const inPlace = !opts.projectName;
|
|
6526
|
+
const projectName = inPlace ? "project" : opts.projectName;
|
|
6527
|
+
if (!inPlace && !VALID_PROJECT_NAME.test(projectName)) {
|
|
6528
|
+
throw new Error(`\u9879\u76EE\u540D "${projectName}" \u5305\u542B\u975E\u6CD5\u5B57\u7B26\u3002\u4EC5\u652F\u6301\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u77ED\u6A2A\u7EBF\u3002`);
|
|
6486
6529
|
}
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
}
|
|
6490
|
-
const projectDir = path2.join(baseDir, opts.projectName);
|
|
6491
|
-
if (fs2.existsSync(projectDir)) {
|
|
6530
|
+
const projectDir = inPlace ? baseDir : path2.join(baseDir, projectName);
|
|
6531
|
+
if (!inPlace && fs2.existsSync(projectDir)) {
|
|
6492
6532
|
throw new Error(`\u76EE\u6807\u76EE\u5F55 ${projectDir} \u5DF2\u5B58\u5728\u3002\u8BF7\u5220\u9664\u540E\u91CD\u8BD5\u6216\u4F7F\u7528\u5176\u4ED6\u9879\u76EE\u540D\u3002`);
|
|
6493
6533
|
}
|
|
6534
|
+
if (!inPlace) {
|
|
6535
|
+
fs2.mkdirSync(projectDir, { recursive: true });
|
|
6536
|
+
}
|
|
6494
6537
|
const ctx = buildContext(opts);
|
|
6495
|
-
fs2.mkdirSync(projectDir, { recursive: true });
|
|
6496
6538
|
const hasFrontend = opts.frontend === "angular";
|
|
6497
6539
|
const hasBackend = opts.backend === "java";
|
|
6498
6540
|
try {
|
|
@@ -6506,13 +6548,18 @@ async function runInit(baseDir, opts) {
|
|
|
6506
6548
|
console.log(`
|
|
6507
6549
|
\u2714 \u9879\u76EE\u5DF2\u521B\u5EFA: ${projectDir}`);
|
|
6508
6550
|
console.log("\n\u4E0B\u4E00\u6B65:");
|
|
6509
|
-
|
|
6551
|
+
if (!inPlace) {
|
|
6552
|
+
console.log(` cd ${opts.projectName}`);
|
|
6553
|
+
}
|
|
6510
6554
|
if (opts.frontend) console.log(` pnpm install # \u5B89\u88C5\u524D\u7AEF\u4F9D\u8D56`);
|
|
6511
6555
|
if (opts.backend) console.log(` ./gradlew build # \u6784\u5EFA\u540E\u7AEF`);
|
|
6512
6556
|
console.log();
|
|
6513
6557
|
printProjectTree(projectDir, hasFrontend, hasBackend);
|
|
6558
|
+
if (inPlace) {
|
|
6559
|
+
initClaudeMd(baseDir, opts);
|
|
6560
|
+
}
|
|
6514
6561
|
} catch (err) {
|
|
6515
|
-
if (fs2.existsSync(projectDir)) {
|
|
6562
|
+
if (!inPlace && fs2.existsSync(projectDir)) {
|
|
6516
6563
|
fs2.rmSync(projectDir, { recursive: true, force: true });
|
|
6517
6564
|
}
|
|
6518
6565
|
throw err;
|
|
@@ -7076,6 +7123,10 @@ function ensureDir2(dir) {
|
|
|
7076
7123
|
}
|
|
7077
7124
|
function writeTemplate(baseDir, relativePath, content) {
|
|
7078
7125
|
const fullPath = path2.join(baseDir, relativePath);
|
|
7126
|
+
if (fs2.existsSync(fullPath)) {
|
|
7127
|
+
console.log(` \u2139 \u8DF3\u8FC7\u5DF2\u6709\u6587\u4EF6: ${relativePath}`);
|
|
7128
|
+
return;
|
|
7129
|
+
}
|
|
7079
7130
|
ensureDir2(path2.dirname(fullPath));
|
|
7080
7131
|
fs2.writeFileSync(fullPath, content, "utf-8");
|
|
7081
7132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstorm/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "DeepStorm CLI — 一键配置项目开发环境",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "billkang",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dotenv": "^17.4.2",
|
|
17
17
|
"handlebars": "^4.7.8",
|
|
18
18
|
"js-yaml": "^4.1.0",
|
|
19
|
-
"@deepstorm/pilot": "^0.6.
|
|
19
|
+
"@deepstorm/pilot": "^0.6.6"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^22.0.0",
|