Skip to content

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

TypeScript

fix(cli): detect pnpm-symlinked theme packages in astryx doctor (#3530) (#3545)

arman-luthraa30efd1ed9cc
diff --git a/.changeset/doctor-pnpm-symlinked-themes.md b/.changeset/doctor-pnpm-symlinked-themes.md
new file mode 100644
index 0000000000..8dc9b04d05
--- /dev/null
+++ b/.changeset/doctor-pnpm-symlinked-themes.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[fix] cli: `astryx doctor` now detects `@astryxdesign/theme-*` packages in pnpm projects. pnpm installs packages as symlinks into `node_modules/.pnpm`, and the theme scan only accepted real directories, so every symlinked theme package was skipped and doctor warned that none were installed (#3530).
+@arman-luthra
diff --git a/packages/cli/src/api/doctor.mjs b/packages/cli/src/api/doctor.mjs
index 3057da38b6..10df4eb1ae 100644
--- a/packages/cli/src/api/doctor.mjs
+++ b/packages/cli/src/api/doctor.mjs
@@ -115,10 +115,21 @@ function findThemePackages(cwd) {
return found;
}
for (const entry of entries) {
- if (!entry.isDirectory()) continue;
if (!entry.name.startsWith('theme-')) continue;
+ const dir = path.join(scopeDir, entry.name);
+ // pnpm installs packages as symlinks into node_modules/.pnpm, and a
+ // symlink dirent reports isDirectory() as false — stat the target instead.
+ let isDir = entry.isDirectory();
+ if (!isDir && entry.isSymbolicLink()) {
+ try {
+ isDir = fs.statSync(dir).isDirectory();
+ } catch {
+ isDir = false;
+ }
+ }
+ if (!isDir) continue;
const name = `@astryxdesign/${entry.name}`;
- found.push({name, version: pkgVersion(path.join(scopeDir, entry.name))});
+ found.push({name, version: pkgVersion(dir)});
}
return found;
}
diff --git a/packages/cli/src/commands/doctor.test.mjs b/packages/cli/src/commands/doctor.test.mjs
index 585d26b75f..7a516daaaf 100644
--- a/packages/cli/src/commands/doctor.test.mjs
+++ b/packages/cli/src/commands/doctor.test.mjs
@@ -63,6 +63,33 @@ function installPkg(name, version = '1.0.0') {
return dir;
}
+/**
+ * Mirror pnpm's layout: the real package lives under node_modules/.pnpm and
+ * the entry in the scope directory is a symlink to it.
+ */
+function installPkgPnpmStyle(name, version = '1.0.0') {
+ const realDir = path.join(
+ tmpDir,
+ 'node_modules',
+ '.pnpm',
+ `${name.replace('/', '+')}@${version}`,
+ 'node_modules',
+ ...name.split('/'),
+ );
+ fs.mkdirSync(realDir, {recursive: true});
+ fs.writeFileSync(
+ path.join(realDir, 'package.json'),
+ JSON.stringify({name, version, main: 'index.js'}),
+ );
+ fs.writeFileSync(path.join(realDir, 'index.js'), 'module.exports = {};');
+ const linkPath = path.join(tmpDir, 'node_modules', ...name.split('/'));
+ fs.mkdirSync(path.dirname(linkPath), {recursive: true});
+ // 'junction' keeps this working on Windows without elevated permissions;
+ // it is ignored on posix.
+ fs.symlinkSync(realDir, linkPath, 'junction');
+ return linkPath;
+}
+
function find(checks, id) {
return checks.find(c => c.id === id);
}
@@ -119,6 +146,13 @@ describe('doctor — individual checks', () => {
expect(res.status).toBe('pass');
});
+ it('themes: detects pnpm-style symlinked theme packages (#3530)', () => {
+ installPkgPnpmStyle('@astryxdesign/theme-neutral', '0.1.2');
+ const res = checkThemes({cwd: tmpDir, configTheme: 'default'});
+ expect(res.status).toBe('pass');
+ expect(res.message).toContain('@astryxdesign/theme-neutral');
+ });
+
it('config: INFO when no astryx.config.mjs', async () => {
const res = await checkConfig({cwd: tmpDir, configPath: null});
expect(res.status).toBe('info');