Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ export async function ensureUserCliCompatShims(baseDir: string = USER_OPENCLI_DI
const writes: Promise<void>[] = [];

// Root-level shims (both with and without .js extension)
// Also generate src/ shims: adapters import ../../src/registry.js etc., which
// resolve to ~/.opencli/src/registry.js when running from ~/.opencli/clis/<site>/
const srcDir = path.join(baseDir, 'src');
await fs.promises.mkdir(srcDir, { recursive: true });
for (const [shimName, moduleName] of rootShims) {
const url = pathToFileURL(resolveHostRuntimeModulePath(moduleName)).href;
const content = `export * from '${url}';\n`;
writes.push(writeCompatShimIfNeeded(path.join(baseDir, shimName), content));
writes.push(writeCompatShimIfNeeded(path.join(baseDir, `${shimName}.js`), content));
writes.push(writeCompatShimIfNeeded(path.join(srcDir, `${shimName}.js`), content));
}

// Subdirectory shims
Expand Down
9 changes: 8 additions & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import * as path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const pkgJsonPath = path.resolve(__dirname, '..', 'package.json');

// Dev: __dirname is src/ (one level to root).
// Prod: __dirname is dist/src/ (two levels to root).
let _pkgDir = path.resolve(__dirname, '..');
if (!fs.existsSync(path.join(_pkgDir, 'package.json'))) {
_pkgDir = path.resolve(_pkgDir, '..');
}
const pkgJsonPath = path.join(_pkgDir, 'package.json');

export const PKG_VERSION: string = (() => {
try {
Expand Down