axhub-make 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/bin/index.js +79 -21
  2. package/package.json +3 -4
package/bin/index.js CHANGED
@@ -3,8 +3,9 @@
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
- const { execFileSync, execSync } = require('child_process');
6
+ const { execFile, execFileSync } = require('child_process');
7
7
  const chalk = require('chalk');
8
+ const packageJson = require('../package.json');
8
9
  const {
9
10
  isAxhubMakeProject,
10
11
  ensureAxhubMakeMarker
@@ -277,13 +278,7 @@ async function applyUpdateFromTemplate(tmpDir, targetDir, rules, conflictMode) {
277
278
  async function testGitHubAccess(url, timeout = 5000) {
278
279
  return new Promise((resolve) => {
279
280
  try {
280
- const { exec } = require('child_process');
281
- const timer = setTimeout(() => {
282
- resolve(false);
283
- }, timeout);
284
-
285
- exec(`git ls-remote ${url}`, (error) => {
286
- clearTimeout(timer);
281
+ execFile('git', ['ls-remote', url], { timeout }, (error) => {
287
282
  resolve(!error);
288
283
  });
289
284
  } catch {
@@ -318,16 +313,22 @@ function parseArgs(argv) {
318
313
  pre: false,
319
314
  dir: '.',
320
315
  template: null, // 将在 run() 中动态选择
321
- install: true,
322
- start: true,
316
+ install: false,
317
+ start: false,
323
318
  force: false,
324
319
  pm: null,
320
+ version: false,
325
321
  conflict: 'overwrite' // 默认强制覆盖,用户可通过 --conflict keep 改为保留模式(不对外文档化)
326
322
  };
327
323
 
328
324
  for (let i = 0; i < args.length; i++) {
329
325
  const a = args[i];
330
326
 
327
+ if (a === '-v' || a === '--version') {
328
+ opts.version = true;
329
+ continue;
330
+ }
331
+
331
332
  if ((a === 'pre' || a === 'preinstall' || a === 'preupdate') && opts.dir === '.' && !opts.pre) {
332
333
  opts.pre = true;
333
334
  continue;
@@ -343,6 +344,10 @@ function parseArgs(argv) {
343
344
  continue;
344
345
  }
345
346
 
347
+ // Deprecated compatibility flag: remote setup handles dependency install.
348
+ // Keep parsing it so old callers do not fail, but never auto-install here.
349
+ if (a === '--install') opts.install = false;
350
+ if (a === '--start') opts.start = true;
346
351
  if (a === '--no-install') opts.install = false;
347
352
  if (a === '--no-start') opts.start = false;
348
353
  if (a === '--pre') opts.pre = true;
@@ -354,10 +359,66 @@ function parseArgs(argv) {
354
359
  return opts;
355
360
  }
356
361
 
357
- async function run() {
358
- console.log(chalk.magenta.bold('\n🚀 Axhub Make\n'));
362
+ function resolveExecutable(command) {
363
+ return process.platform === 'win32' ? `${command}.cmd` : command;
364
+ }
359
365
 
366
+ function runPackageManager(pm, args, cwd) {
367
+ execFileSync(resolveExecutable(pm), args, {
368
+ cwd,
369
+ stdio: 'inherit'
370
+ });
371
+ }
372
+
373
+ function quotePathForDisplay(value) {
374
+ if (!value) return '.';
375
+ if (!/[\s"'`$\\]/.test(value)) return value;
376
+ return JSON.stringify(value);
377
+ }
378
+
379
+ function printManualNextSteps({ targetDir, isCurrentDir, pm, install, start }) {
380
+ if (install && start) return;
381
+
382
+ console.log(chalk.cyan('\n下一步:'));
383
+
384
+ if (!isCurrentDir) {
385
+ const rel = path.relative(process.cwd(), targetDir);
386
+ console.log(chalk.cyan(` cd ${quotePathForDisplay(rel || targetDir)}`));
387
+ }
388
+
389
+ if (!install) {
390
+ console.log(chalk.cyan(` ${pm} install`));
391
+ }
392
+
393
+ if (!start) {
394
+ console.log(chalk.cyan(` ${pm} run dev`));
395
+ }
396
+ }
397
+
398
+ function printCompletionMessage({ targetDir, isCurrentDir, pm, install, start }) {
399
+ if (!install && !start) {
400
+ console.log(chalk.green('\n✅ 模板已写入。CLI 不会自动运行安装或开发服务。'));
401
+ } else if (install && !start) {
402
+ console.log(chalk.green('\n✅ 模板已写入,依赖已安装。CLI 不会自动启动开发服务。'));
403
+ } else if (!install && start) {
404
+ console.log(chalk.green('\n✅ 模板已写入,已尝试启动开发服务。CLI 不会自动运行依赖安装。'));
405
+ } else {
406
+ console.log(chalk.green('\n✅ 完成'));
407
+ return;
408
+ }
409
+
410
+ printManualNextSteps({ targetDir, isCurrentDir, pm, install, start });
411
+ }
412
+
413
+ async function run() {
360
414
  const opts = parseArgs(process.argv);
415
+
416
+ if (opts.version) {
417
+ console.log(packageJson.version);
418
+ return;
419
+ }
420
+
421
+ console.log(chalk.magenta.bold('\n🚀 Axhub Make\n'));
361
422
 
362
423
  // 如果用户没有指定模板,自动选择可用的仓库
363
424
  if (!opts.template) {
@@ -478,10 +539,7 @@ async function run() {
478
539
 
479
540
  if (opts.install) {
480
541
  console.log(chalk.blue(`\n📦 安装依赖(${pm})...\n`));
481
- execSync(`${pm} install`, {
482
- cwd: targetDir,
483
- stdio: 'inherit'
484
- });
542
+ runPackageManager(pm, ['install'], targetDir);
485
543
  }
486
544
 
487
545
  // -----------------------------
@@ -490,23 +548,23 @@ async function run() {
490
548
  if (opts.start) {
491
549
  console.log(chalk.green('\n🚀 启动项目...\n'));
492
550
  try {
493
- execSync(`${pm} run dev`, { cwd: targetDir, stdio: 'inherit' });
551
+ runPackageManager(pm, ['run', 'dev'], targetDir);
494
552
  } catch {
495
553
  try {
496
- execSync(`${pm} run start`, { cwd: targetDir, stdio: 'inherit' });
554
+ runPackageManager(pm, ['run', 'start'], targetDir);
497
555
  } catch {}
498
556
  }
499
557
  }
500
558
 
501
- console.log(chalk.green('\n✅ 完成'));
559
+ printCompletionMessage({ targetDir, isCurrentDir, pm, install: opts.install, start: opts.start });
502
560
  }
503
561
 
504
562
  // -----------------------------
505
563
  // 包管理器检测
506
564
  // -----------------------------
507
565
  function detectPackageManager() {
508
- try { execSync('pnpm -v', { stdio: 'ignore' }); return 'pnpm'; } catch {}
509
- try { execSync('yarn -v', { stdio: 'ignore' }); return 'yarn'; } catch {}
566
+ try { execFileSync(resolveExecutable('pnpm'), ['-v'], { stdio: 'ignore' }); return 'pnpm'; } catch {}
567
+ try { execFileSync(resolveExecutable('yarn'), ['-v'], { stdio: 'ignore' }); return 'yarn'; } catch {}
510
568
  return 'npm';
511
569
  }
512
570
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "axhub-make",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Axhub Make scaffolding tool",
5
5
  "files": [
6
6
  "bin"
7
7
  ],
8
8
  "bin": {
9
- "axhub-make": "./bin/index.js"
9
+ "axhub-make": "bin/index.js"
10
10
  },
11
11
  "scripts": {
12
12
  "test": "node test.js",
@@ -19,11 +19,10 @@
19
19
  "dependencies": {
20
20
  "chalk": "^4.1.2",
21
21
  "class-variance-authority": "^0.7.1",
22
- "clsx": "^2.1.1",
23
22
  "download-git-repo": "^3.0.2",
24
23
  "fs-extra": "^10.0.0",
25
24
  "inquirer": "^8.2.0",
26
- "tailwind-merge": "^3.4.0"
25
+ "three": "^0.183.2"
27
26
  },
28
27
  "author": "Lintendo",
29
28
  "license": "ISC",