Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(cli): detect package manager for jscodeshift install + read version from package.json (#915)

Cindy Zhang4cd428fbf481
diff --git a/packages/cli/src/codemods/ensure-jscodeshift.mjs b/packages/cli/src/codemods/ensure-jscodeshift.mjs
index 1816df8ce1..cacc879f59 100644
--- a/packages/cli/src/codemods/ensure-jscodeshift.mjs
+++ b/packages/cli/src/codemods/ensure-jscodeshift.mjs
@@ -11,6 +11,7 @@
import {execSync} from 'node:child_process';
import * as p from '@clack/prompts';
+import {detectPackageManager} from '../utils/package-manager.mjs';
/**
* @param {object} [options]
@@ -54,9 +55,19 @@ export async function ensureJscodeshift({installDeps = false} = {}) {
/** @returns {boolean} */
function installJscodeshift() {
+ const pm = detectPackageManager();
+ const cmds = {
+ yarn: 'yarn add --dev jscodeshift',
+ pnpm: 'pnpm add -D jscodeshift',
+ bun: 'bun add -D jscodeshift',
+ npm: 'npm install --save-dev jscodeshift',
+ npx: 'npm install --save-dev jscodeshift',
+ };
+ const cmd = cmds[pm] || cmds.npm;
+
try {
- p.log.step('Installing jscodeshift...');
- execSync('npm install --no-save jscodeshift', {stdio: 'pipe'});
+ p.log.step(`Installing jscodeshift via ${pm}...`);
+ execSync(cmd, {stdio: 'pipe'});
p.log.success('jscodeshift installed.');
return true;
} catch (err) {
diff --git a/packages/cli/src/index.mjs b/packages/cli/src/index.mjs
index 69ae2d67c5..cd90f17d6b 100644
--- a/packages/cli/src/index.mjs
+++ b/packages/cli/src/index.mjs
@@ -7,17 +7,21 @@
import {Command} from 'commander';
import {fileURLToPath} from 'node:url';
+import * as fs from 'node:fs';
import * as path from 'node:path';
import {checkForUpdate} from './utils/update-check.mjs';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
+// Read version from package.json so it stays in sync
+const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
+
export const program = new Command();
program
.name('xds')
.description('XDS design system CLI — components, themes, and tooling')
- .version('0.0.1')
+ .version(pkg.version)
.option('--zh', 'Output docs in Chinese Simplified')
.option('--dense', 'Output docs in compressed dense format (token-efficient)')
.option('--lang <locale>', 'Output docs in specified language/format (en, zh, dense)')