@boopkit/cli 0.1.8 → 0.1.9
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/dist/capability-versions.json +1 -1
- package/dist/cli.js +1 -0
- package/dist/commands/update.d.ts +1 -0
- package/dist/commands/update.js +39 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -52,6 +52,7 @@ program
|
|
|
52
52
|
.option('--force', 'Overwrite locally modified files (creates .bak backup)')
|
|
53
53
|
.option('--restore', 'Restore locally deleted scaffold files')
|
|
54
54
|
.option('--prune', 'Remove deprecated scaffold files from disk (creates .bak backup)')
|
|
55
|
+
.option('--skip-npm', 'Skip npm update (only re-scaffold from installed versions)')
|
|
55
56
|
.option('--json', 'Output structured JSON')
|
|
56
57
|
.action(update_1.runUpdate);
|
|
57
58
|
program
|
package/dist/commands/update.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.runUpdate = runUpdate;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
+
const child_process_1 = require("child_process");
|
|
39
40
|
const project_1 = require("../lib/project");
|
|
40
41
|
const capability_1 = require("../lib/capability");
|
|
41
42
|
const update_1 = require("../lib/update");
|
|
@@ -58,6 +59,21 @@ function runUpdate(capabilityName, options) {
|
|
|
58
59
|
process.exitCode = 1;
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
62
|
+
// Step 1: npm install capability packages at latest within current major (unless --skip-npm or --dry-run)
|
|
63
|
+
if (!options.skipNpm && !options.dryRun) {
|
|
64
|
+
const packageSpecs = resolveNpmPackageSpecs(capsToUpdate, targetDir);
|
|
65
|
+
if (packageSpecs.length > 0) {
|
|
66
|
+
if (!options.json) {
|
|
67
|
+
console.log(`Updating npm packages: ${packageSpecs.join(', ')}`);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
(0, child_process_1.execSync)(`npm install ${packageSpecs.join(' ')}`, { cwd: targetDir, stdio: options.json ? 'pipe' : 'inherit' });
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
console.error(`\x1b[33mWARN\x1b[0m npm install failed — continuing with scaffold update using installed versions`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
61
77
|
// Plan all updates
|
|
62
78
|
const plans = [];
|
|
63
79
|
for (const cap of capsToUpdate) {
|
|
@@ -202,3 +218,26 @@ function diagnoseMissingPlans(capsToUpdate, requestedCap, targetDir) {
|
|
|
202
218
|
}
|
|
203
219
|
return 'No capabilities to update.';
|
|
204
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Resolve capability names to npm install specs pinned to the current major version.
|
|
223
|
+
* E.g. @boopkit/cap-background-jobs@0.2.0 → "@boopkit/cap-background-jobs@0"
|
|
224
|
+
* This allows minor+patch updates within the same major (including 0.x → 0.y)
|
|
225
|
+
* without crossing a major version boundary.
|
|
226
|
+
*/
|
|
227
|
+
function resolveNpmPackageSpecs(capabilities, targetDir) {
|
|
228
|
+
const specs = [];
|
|
229
|
+
for (const cap of capabilities) {
|
|
230
|
+
const pkgDir = (0, capability_1.getPackageDir)(cap, [targetDir]);
|
|
231
|
+
if (!pkgDir)
|
|
232
|
+
continue;
|
|
233
|
+
const pkgJsonPath = path.join(pkgDir, 'package.json');
|
|
234
|
+
if (!fs.existsSync(pkgJsonPath))
|
|
235
|
+
continue;
|
|
236
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
237
|
+
if (pkgJson.name && pkgJson.boopkit?.capability && pkgJson.version) {
|
|
238
|
+
const major = pkgJson.version.split('.')[0];
|
|
239
|
+
specs.push(`${pkgJson.name}@${major}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return specs;
|
|
243
|
+
}
|