xinyu-pro 0.21.1 → 0.21.2

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 (3) hide show
  1. package/bin/cli.js +17 -23
  2. package/package.json +1 -1
  3. package/version.json +1 -1
package/bin/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } = require('fs');
3
+ const { existsSync, readFileSync, writeFileSync } = require('fs');
4
4
  const { join, resolve } = require('path');
5
5
  const { createInterface } = require('readline');
6
6
  const { execSync, spawn } = require('child_process');
7
- const { homedir } = require('os');
8
7
 
8
+ const isWin = process.platform === 'win32';
9
9
  const cwd = process.cwd();
10
10
  const APP_DIR = __dirname.includes('node_modules') ? resolve(__dirname, '..') : cwd;
11
11
 
@@ -75,15 +75,14 @@ function detectPackageManager() {
75
75
  return 'npm';
76
76
  }
77
77
 
78
- function getNextCliPath() {
79
- const possiblePaths = [
80
- join(APP_DIR, 'node_modules', '.bin', 'next'),
81
- join(APP_DIR, 'node_modules', 'next', 'dist', 'bin', 'next'),
82
- join(cwd, 'node_modules', '.bin', 'next'),
83
- ];
84
- for (const p of possiblePaths) {
85
- if (existsSync(p)) return p;
78
+ function getNextCommand() {
79
+ const binDir = join(APP_DIR, 'node_modules', '.bin');
80
+ if (isWin) {
81
+ const cmdPath = join(binDir, 'next.cmd');
82
+ if (existsSync(cmdPath)) return cmdPath;
86
83
  }
84
+ const unixPath = join(binDir, 'next');
85
+ if (existsSync(unixPath)) return unixPath;
87
86
  return 'next';
88
87
  }
89
88
 
@@ -93,7 +92,7 @@ function checkDependencies() {
93
92
  const pm = detectPackageManager();
94
93
  const cmd = pm === 'yarn' ? 'yarn install' : pm === 'pnpm' ? 'pnpm install' : 'npm install';
95
94
  echo(` $ ${cmd}`, 'dim');
96
- execSync(cmd, { cwd: APP_DIR, stdio: 'inherit' });
95
+ execSync(cmd, { cwd: APP_DIR, stdio: 'inherit', shell: isWin });
97
96
  return true;
98
97
  }
99
98
  return false;
@@ -163,12 +162,9 @@ function checkBuildExists() {
163
162
 
164
163
  function runBuild() {
165
164
  echo(' ■ 正在构建应用,首次构建可能需要 1-2 分钟...', 'info');
166
- const nextCli = getNextCliPath();
165
+ const nextCmd = getNextCommand();
167
166
  try {
168
- execSync(`"${process.execPath}" "${nextCli}" build`, {
169
- cwd: APP_DIR,
170
- stdio: 'inherit',
171
- });
167
+ execSync(`"${nextCmd}" build`, { cwd: APP_DIR, stdio: 'inherit', shell: isWin });
172
168
  echo(' ✓ 构建完成', 'success');
173
169
  } catch (e) {
174
170
  echo(' ✗ 构建失败,请检查代码错误', 'error');
@@ -177,7 +173,8 @@ function runBuild() {
177
173
  }
178
174
 
179
175
  function startServer(port, devMode) {
180
- const nextCli = getNextCliPath();
176
+ const nextCmd = getNextCommand();
177
+ const action = devMode ? 'dev' : 'start';
181
178
 
182
179
  echo('');
183
180
  echo(` ╔══════════════════════════════════════╗`, 'success');
@@ -187,14 +184,11 @@ function startServer(port, devMode) {
187
184
  echo(` ╚══════════════════════════════════════╝`, 'success');
188
185
  echo('');
189
186
 
190
- const cmd = devMode ? 'dev' : 'start';
191
- const child = spawn(process.execPath, [nextCli, cmd, '-p', port], {
187
+ const child = spawn(nextCmd, [action, '-p', port], {
192
188
  cwd: APP_DIR,
193
189
  stdio: 'inherit',
194
- env: {
195
- ...process.env,
196
- PORT: port,
197
- },
190
+ shell: isWin,
191
+ env: { ...process.env, PORT: port },
198
192
  });
199
193
 
200
194
  child.on('error', (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xinyu-pro",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "private": false,
5
5
  "description": "星语 Pro - AI 驱动的互动叙事平台",
6
6
  "author": "RestRegular",
package/version.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.21.1",
2
+ "version": "0.21.2",
3
3
  "name": "xinyu-pro",
4
4
  "displayName": "星语 Pro",
5
5
  "description": "AI 驱动的互动叙事平台"