speccrew 0.1.5 → 0.1.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/lib/commands/update.js +22 -0
- package/package.json +1 -1
package/lib/commands/update.js
CHANGED
|
@@ -376,6 +376,28 @@ function updatePackageDocs(packageRoot, workspaceDir, stats) {
|
|
|
376
376
|
function run() {
|
|
377
377
|
try {
|
|
378
378
|
const args = parseArgs();
|
|
379
|
+
|
|
380
|
+
// Self-update: check if a newer version exists on npm registry
|
|
381
|
+
const localVersion = getPackageVersion();
|
|
382
|
+
let latestVersion = null;
|
|
383
|
+
try {
|
|
384
|
+
const { execSync } = require('child_process');
|
|
385
|
+
latestVersion = execSync('npm view speccrew version', { encoding: 'utf8', timeout: 15000 }).trim();
|
|
386
|
+
} catch (e) {
|
|
387
|
+
// Network error or npm not available, skip self-update
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (latestVersion && latestVersion !== localVersion) {
|
|
391
|
+
console.log(`Updating CLI: v${localVersion} → v${latestVersion} ...`);
|
|
392
|
+
try {
|
|
393
|
+
const { execSync } = require('child_process');
|
|
394
|
+
execSync('npm install -g speccrew@latest', { stdio: 'inherit', timeout: 60000 });
|
|
395
|
+
console.log(`CLI updated to v${latestVersion}\n`);
|
|
396
|
+
} catch (e) {
|
|
397
|
+
console.warn(`Warning: CLI self-update failed (${e.message}). Continuing with current version.\n`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
379
401
|
const projectRoot = process.cwd();
|
|
380
402
|
|
|
381
403
|
// 读取 .speccrewrc (with migration support)
|