gridsum-vue3-pc 1.0.2 → 1.0.4

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.
@@ -202,6 +202,8 @@ function runCommandAsync(command, options = {}) {
202
202
 
203
203
  function tryGitInit(root) {
204
204
  try {
205
+ const hasGit = spawn.sync('git', ['--version'], { stdio: 'ignore' });
206
+ if (hasGit.status !== 0) return;
205
207
  spawn.sync('git', ['init'], { cwd: root, stdio: 'ignore' });
206
208
  spawn.sync('git', ['add', '.'], { cwd: root, stdio: 'ignore' });
207
209
  spawn.sync('git', ['-c', 'user.name=gridsum-vue3-pc', '-c', 'user.email=gridsum-vue3-pc@local', 'commit', '-m', 'Initial project scaffolded by gridsum-vue3-pc'], {
@@ -481,23 +483,8 @@ async function main() {
481
483
  autoInstall = result;
482
484
  }
483
485
 
484
- if (autoInstall && !process.env._CREATE_VUE3_PC_TEST) {
485
- try {
486
- await runCommandAsync(getInstallCommand(pkgManager), { cwd: root });
487
- process.stdout.write(`\r\x1b[K${pc.green('✓')} Dependencies installed!\n`);
488
- } catch (e) {
489
- process.stdout.write(`\r\x1b[K${pc.red('✗')} Installation failed\n`);
490
- console.error(` ${pc.dim('You can retry manually:')}`);
491
- console.error(` ${pc.cyan(`cd ${targetDir} && ${pkgManager} install${pkgManager === 'npm' ? ' --legacy-peer-deps' : ''}`)}\n`);
492
- }
493
- }
494
-
495
- if (!argv['no-git'] && !process.env._CREATE_VUE3_PC_TEST) {
496
- tryGitInit(root);
497
- }
498
-
499
486
  let autoStart = argv['auto-start'];
500
- if (autoStart === undefined && isInteractive) {
487
+ if (autoStart === undefined && isInteractive && autoInstall) {
501
488
  const result = await prompts.confirm({
502
489
  message: 'Start dev server now?',
503
490
  initialValue: false,
@@ -506,14 +493,20 @@ async function main() {
506
493
  autoStart = result;
507
494
  }
508
495
 
496
+ if (autoInstall && !process.env._CREATE_VUE3_PC_TEST) {
497
+ process.stdout.write(`\r\x1b[K${pc.dim('Installing dependencies...')}\n`);
498
+ runCommand(getInstallCommand(pkgManager), { cwd: root });
499
+ process.stdout.write(`${pc.green('✓')} Dependencies installed!\n`);
500
+ }
501
+
502
+ if (!argv['no-git'] && !process.env._CREATE_VUE3_PC_TEST) {
503
+ tryGitInit(root);
504
+ }
505
+
509
506
  if (autoStart) {
510
507
  prompts.log.step(`Starting dev server... (press ${pc.bold('Ctrl+C')} to stop)`);
511
- if (process.env._CREATE_VUE3_PC_TEST) {
512
- prompts.log.info('Dev server started (skipped in test)');
513
- } else {
514
- runCommand(getRunCommand(pkgManager, 'dev'), { cwd: root });
515
- return;
516
- }
508
+ runCommand(getRunCommand(pkgManager, 'dev'), { cwd: root });
509
+ return;
517
510
  }
518
511
 
519
512
  const cdProjectName = path.relative(process.cwd(), root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridsum-vue3-pc",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Gridsum Vue3 Vite PC Template Generator - 快速生成基于 Vue3 + Vite + TypeScript 的企业级 PC 端项目",
5
5
  "type": "module",
6
6
  "sideEffects": false,