@codeledger/cli 0.10.49 → 0.10.51
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/package.json +1 -1
- package/scripts/postinstall.js +28 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeledger/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.51",
|
|
4
4
|
"mcpName": "io.github.codeledgerECF/codeledger",
|
|
5
5
|
"description": "Official ContextECF CodeLedger CLI wrapper. Installs the hardened binary from GitHub Releases; zero engine code ships in this package.",
|
|
6
6
|
"type": "commonjs",
|
package/scripts/postinstall.js
CHANGED
|
@@ -266,9 +266,34 @@ async function main() {
|
|
|
266
266
|
console.log(`codeledger: installed ${BINARY_LOCAL_PATH}`);
|
|
267
267
|
console.log(` sha256: ${actualSha}`);
|
|
268
268
|
console.log('');
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
|
|
270
|
+
// Auto-run `codeledger upgrade` so users get a fully wired ambient setup
|
|
271
|
+
// in a single `npm install -g @codeledger/cli` command — no manual upgrade
|
|
272
|
+
// or vendor step needed. We use the bin wrapper path directly rather than
|
|
273
|
+
// relying on the global bin symlink being on PATH during postinstall.
|
|
274
|
+
const { spawnSync } = require('node:child_process');
|
|
275
|
+
const path = require('node:path');
|
|
276
|
+
const fs = require('node:fs');
|
|
277
|
+
const codeledgerBin = path.join(__dirname, '..', 'bin', 'codeledger.js');
|
|
278
|
+
// INIT_CWD is set by npm to the directory the user invoked npm from.
|
|
279
|
+
// Prefer it when it contains a .codeledger/ directory so upgrade runs
|
|
280
|
+
// against the user's repo rather than HOME, keeping the repo-local
|
|
281
|
+
// vendored CLI current. Fall back to HOME for the global ambient case.
|
|
282
|
+
const initCwd = process.env['INIT_CWD'];
|
|
283
|
+
const homeCwd = process.env['HOME'] ?? process.env['USERPROFILE'] ?? process.cwd();
|
|
284
|
+
const upgradeCwd =
|
|
285
|
+
initCwd && fs.existsSync(path.join(initCwd, '.codeledger')) ? initCwd : homeCwd;
|
|
286
|
+
console.log('codeledger: running upgrade to complete ambient setup...');
|
|
287
|
+
const upgradeResult = spawnSync(process.execPath, [codeledgerBin, 'upgrade'], {
|
|
288
|
+
stdio: 'inherit',
|
|
289
|
+
cwd: upgradeCwd,
|
|
290
|
+
env: { ...process.env, CODELEDGER_SKIP_AMBIENT_ACTIVATION: '1' },
|
|
291
|
+
});
|
|
292
|
+
if ((upgradeResult.status ?? 0) !== 0) {
|
|
293
|
+
console.log('');
|
|
294
|
+
console.log('codeledger: upgrade step encountered an issue. Run manually:');
|
|
295
|
+
console.log(' codeledger upgrade');
|
|
296
|
+
}
|
|
272
297
|
}
|
|
273
298
|
|
|
274
299
|
// Only run main() when invoked directly (npm postinstall, node scripts/postinstall.js).
|