gridsum-vue3-pc 1.0.6 → 1.0.8

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.
@@ -134,6 +134,17 @@ function getInstallCommand(pkgManager) {
134
134
  return args;
135
135
  }
136
136
 
137
+ function getRunCommand(pkgManager, script) {
138
+ switch (pkgManager) {
139
+ case 'yarn':
140
+ case 'pnpm':
141
+ case 'bun':
142
+ return [pkgManager, script];
143
+ default:
144
+ return [pkgManager, 'run', script];
145
+ }
146
+ }
147
+
137
148
  function runCommand(command, options = {}) {
138
149
  const [cmd, ...args] = command;
139
150
  const result = spawn.sync(cmd, args, {
@@ -189,21 +200,6 @@ function runCommandAsync(command, options = {}) {
189
200
  });
190
201
  }
191
202
 
192
- function tryGitInit(root) {
193
- try {
194
- const hasGit = spawn.sync('git', ['--version'], { stdio: 'ignore' });
195
- if (hasGit.status !== 0) return;
196
- spawn.sync('git', ['init'], { cwd: root, stdio: 'ignore' });
197
- spawn.sync('git', ['add', '.'], { cwd: root, stdio: 'ignore' });
198
- 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'], {
199
- cwd: root,
200
- stdio: 'ignore',
201
- });
202
- } catch {
203
- // git init is best-effort
204
- }
205
- }
206
-
207
203
  function checkNodeVersion() {
208
204
  const version = parseInt(process.version.slice(1).split('.')[0]);
209
205
  if (version < MIN_NODE_VERSION) {
@@ -472,14 +468,26 @@ async function main() {
472
468
  autoInstall = result;
473
469
  }
474
470
 
471
+ let autoStart = argv['auto-start'];
472
+ if (autoStart === undefined && isInteractive && autoInstall) {
473
+ const result = await prompts.confirm({
474
+ message: 'Start dev server now?',
475
+ initialValue: false,
476
+ });
477
+ if (prompts.isCancel(result)) return cancel();
478
+ autoStart = result;
479
+ }
480
+
475
481
  if (autoInstall && !process.env._CREATE_VUE3_PC_TEST) {
476
482
  process.stdout.write(`\r\x1b[K${pc.dim('Installing dependencies...')}\n`);
477
483
  runCommand(getInstallCommand(pkgManager), { cwd: root });
478
484
  process.stdout.write(`${pc.green('✓')} Dependencies installed!\n`);
479
485
  }
480
486
 
481
- if (!argv['no-git'] && !process.env._CREATE_VUE3_PC_TEST) {
482
- tryGitInit(root);
487
+ if (autoStart) {
488
+ prompts.log.step(`Starting dev server... (press ${pc.bold('Ctrl+C')} to stop)`);
489
+ runCommand(getRunCommand(pkgManager, 'dev'), { cwd: root });
490
+ return;
483
491
  }
484
492
 
485
493
  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.6",
3
+ "version": "1.0.8",
4
4
  "description": "Gridsum Vue3 Vite PC Template Generator - 快速生成基于 Vue3 + Vite + TypeScript 的企业级 PC 端项目",
5
5
  "type": "module",
6
6
  "sideEffects": false,