fix: fwScript prefers npm-bundled scripts over stale deployed copies (#361)
This commit was merged in pull request #361.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mosaic/cli",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import { execFileSync, execSync, spawnSync } from 'node:child_process';
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, rmSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { homedir } from 'node:os';
|
||||
import { join, dirname } from 'node:path';
|
||||
import type { Command } from 'commander';
|
||||
@@ -491,7 +492,20 @@ function delegateToScript(scriptPath: string, args: string[], env?: Record<strin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a framework script path. Prefers the version bundled in the
|
||||
* @mosaic/mosaic npm package (always matches the installed CLI version)
|
||||
* over the deployed copy in ~/.config/mosaic/ (may be stale).
|
||||
*/
|
||||
function fwScript(name: string): string {
|
||||
try {
|
||||
const require = createRequire(import.meta.url);
|
||||
const mosaicPkg = dirname(require.resolve('@mosaic/mosaic/package.json'));
|
||||
const bundled = join(mosaicPkg, 'framework', 'tools', '_scripts', name);
|
||||
if (existsSync(bundled)) return bundled;
|
||||
} catch {
|
||||
// Fall through to deployed copy
|
||||
}
|
||||
return join(MOSAIC_HOME, 'tools', '_scripts', name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mosaic/mosaic",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"description": "Mosaic agent framework — installation wizard and meta package",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
||||
Reference in New Issue
Block a user