bejamas 0.5.0 → 0.6.1

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as PRESET_MENU_COLORS, A as SEMANTIC_ICON_NAMES, B as getFontValue, C as BEJAMAS_COMPONENTS_SCHEMA_URL, D as ICON_LIBRARIES, E as resolveRegistryUrl, F as RTL_LANGUAGE_VALUES, G as normalizeDesignSystemConfig, H as getRadiusValue, I as designSystemConfigSchema, J as PRESET_CHART_COLORS, K as DEFAULT_PRESET_CONFIG, L as getDocumentDirection, M as getSemanticIconNameFromLucidePath, N as renderSemanticIconSvgWithAttributeString, O as buildRegistryTheme, P as DEFAULT_DESIGN_SYSTEM_CONFIG, Q as PRESET_MENU_ACCENTS, R as getDocumentLanguage, S as highlighter, T as buildUiUrl, U as getStyleDefaultRadius, V as getHeadingFontValue, W as getStyleId, X as PRESET_FONT_HEADINGS, Y as PRESET_FONTS, Z as PRESET_ICON_LIBRARIES, _ as findCommonRoot, at as encodePreset, b as getProjectInfo, d as parseJsDocMetadata, et as PRESET_RADII, g as spinner, it as decodePreset, j as getSemanticIconNameFromLucideExport, k as ICON_LIBRARY_COLLECTIONS, nt as PRESET_THEMES, o as extractFrontmatter, ot as isPresetCode, p as resolveUiRoot, q as PRESET_BASE_COLORS, rt as V1_CHART_COLOR_MAP, st as fonts, tt as PRESET_STYLES, v as getConfig, w as BASE_COLORS, x as logger, y as getWorkspaceConfig, z as getFontPackageName } from "./utils-BEqgES6q.js";
2
+ import { $ as PRESET_MENU_COLORS, A as SEMANTIC_ICON_NAMES, B as getFontValue, C as BEJAMAS_COMPONENTS_SCHEMA_URL, D as ICON_LIBRARIES, E as resolveRegistryUrl, F as RTL_LANGUAGE_VALUES, G as normalizeDesignSystemConfig, H as getRadiusValue, I as designSystemConfigSchema, J as PRESET_CHART_COLORS, K as DEFAULT_PRESET_CONFIG, L as getDocumentDirection, M as getSemanticIconNameFromLucidePath, N as renderSemanticIconSvgWithAttributeString, O as buildRegistryTheme, P as DEFAULT_DESIGN_SYSTEM_CONFIG, Q as PRESET_MENU_ACCENTS, R as getDocumentLanguage, S as highlighter, T as buildUiUrl, U as getStyleDefaultRadius, V as getHeadingFontValue, W as getStyleId, X as PRESET_FONT_HEADINGS, Y as PRESET_FONTS, Z as PRESET_ICON_LIBRARIES, _ as findCommonRoot, at as encodePreset, b as getProjectInfo, d as parseJsDocMetadata, et as PRESET_RADII, g as spinner, it as decodePreset, j as getSemanticIconNameFromLucideExport, k as ICON_LIBRARY_COLLECTIONS, nt as PRESET_THEMES, o as extractFrontmatter, ot as isPresetCode, p as resolveUiRoot, q as PRESET_BASE_COLORS, rt as V1_CHART_COLOR_MAP, st as fonts, tt as PRESET_STYLES, v as getConfig, w as BASE_COLORS, x as logger, y as getWorkspaceConfig, z as getFontPackageName } from "./utils-BpBN6-Y9.js";
3
3
  import { Command } from "commander";
4
4
  import { createRequire } from "module";
5
5
  import path, { extname, isAbsolute, join, relative, resolve } from "node:path";
@@ -61,6 +61,15 @@ const STARLIGHT_HEAD_RELATIVE_PATH = "apps/docs/src/components/Head.astro";
61
61
  const ASTRO_FONT_PROVIDERS = ["fontsource", "google"];
62
62
  const ASTRO_FONTSOURCE_FONT_NAMES = /* @__PURE__ */ new Set(["geist", "geist-mono"]);
63
63
  const MANAGED_BODY_FONT_CLASSES = /* @__PURE__ */ new Set(["font-mono", "font-serif"]);
64
+ function parseStringArray(source) {
65
+ if (!source) return void 0;
66
+ try {
67
+ const parsed = JSON.parse(source);
68
+ return Array.isArray(parsed) && parsed.length > 0 && parsed.every((value) => typeof value === "string") ? parsed : void 0;
69
+ } catch {
70
+ return;
71
+ }
72
+ }
64
73
  function compactSource$1(source) {
65
74
  return source.replace(/\n{3,}/g, "\n\n").trimEnd() + "\n";
66
75
  }
@@ -81,7 +90,7 @@ function upsertImport(source, moduleName, importedName, fallbackNames = []) {
81
90
  return `${importLine}\n${source}`;
82
91
  }
83
92
  function buildAstroConfigFontBlock(fontsToSerialize) {
84
- const body = fontsToSerialize.length === 0 ? "" : `\n${fontsToSerialize.map((font) => ` {\n provider: fontProviders.${font.provider}(),\n name: ${JSON.stringify(font.name)},\n cssVariable: ${JSON.stringify(font.cssVariable)},\n subsets: ${JSON.stringify(font.subsets)},\n },`).join("\n")}\n`;
93
+ const body = fontsToSerialize.length === 0 ? "" : `\n${fontsToSerialize.map((font) => ` {\n provider: fontProviders.${font.provider}(),\n name: ${JSON.stringify(font.name)},\n cssVariable: ${JSON.stringify(font.cssVariable)},\n${font.weights ? ` weights: ${JSON.stringify(font.weights)},\n` : ""} subsets: ${JSON.stringify(font.subsets)},\n },`).join("\n")}\n`;
85
94
  return `${ASTRO_CONFIG_BLOCK_START}\n/** @type {NonNullable<import("astro").AstroUserConfig["fonts"]>} */\nconst ${ASTRO_FONT_CONSTANT} = [${body}];\n${ASTRO_CONFIG_BLOCK_END}`;
86
95
  }
87
96
  function buildAstroLayoutFontBlock(fontsToSerialize) {
@@ -116,19 +125,14 @@ function parseManagedAstroFonts(source) {
116
125
  const cssVariable = entry.match(/cssVariable:\s*"([^"]+)"/)?.[1];
117
126
  const provider = entry.match(/provider:\s*fontProviders\.([a-z]+)\(\)/)?.[1];
118
127
  const subsetsSource = entry.match(/subsets:\s*(\[[^\]]*\])/s)?.[1];
128
+ const weights = parseStringArray(entry.match(/weights:\s*(\[[^\]]*\])/s)?.[1]);
119
129
  if (!name || !cssVariable || !provider || !ASTRO_FONT_PROVIDERS.includes(provider)) return null;
120
- let subsets = ["latin"];
121
- if (subsetsSource) try {
122
- const parsed = JSON.parse(subsetsSource);
123
- if (Array.isArray(parsed) && parsed.length > 0 && parsed.every((value) => typeof value === "string")) subsets = parsed;
124
- } catch {
125
- subsets = ["latin"];
126
- }
127
130
  return {
128
131
  name,
129
132
  cssVariable,
130
133
  provider,
131
- subsets
134
+ subsets: parseStringArray(subsetsSource) ?? ["latin"],
135
+ ...weights && { weights }
132
136
  };
133
137
  }).filter((value) => value !== null);
134
138
  }
@@ -232,7 +236,8 @@ function toManagedAstroFont(fontName) {
232
236
  name: font.title?.replace(/\s+\(Heading\)$/, "") ?? font.font.import.replace(/_/g, " "),
233
237
  cssVariable: font.font.variable,
234
238
  provider: ASTRO_FONTSOURCE_FONT_NAMES.has(normalized) ? "fontsource" : "google",
235
- subsets: normalizeManagedAstroFontSubsets(font.font.subsets)
239
+ subsets: normalizeManagedAstroFontSubsets(font.font.subsets),
240
+ ...font.font.weight?.length && { weights: [...font.font.weight] }
236
241
  };
237
242
  }
238
243
  function mergeManagedAstroFonts(currentFonts, nextFont) {
@@ -676,10 +681,17 @@ function transformStarterPageToI18n(source) {
676
681
  if (!match) return source;
677
682
  return compactSource(match.i18nSource);
678
683
  }
679
- function upsertThemeInlineFont(source, fontVariable) {
684
+ /**
685
+ * Astro's <Font> defines the font variables outside any cascade layer, so it
686
+ * beats Tailwind's theme layer. The body font therefore needs no theme line
687
+ * (without a <Font>, Tailwind's default stack applies), and the heading font
688
+ * falls back to the body font until a heading <Font> defines it.
689
+ */
690
+ function upsertThemeInlineFont(source, fontVariable = "--font-sans") {
680
691
  const pattern = /@theme inline\s*\{[\s\S]*?\n\}/m;
692
+ const declarations = ` --font-heading: var(--font-heading, var(${fontVariable}));`;
681
693
  if (!pattern.test(source)) {
682
- const block = `@theme inline {\n${[fontVariable ? ` ${fontVariable}: var(${fontVariable});` : null, " --font-heading: var(--font-heading);"].filter(Boolean).join("\n")}\n}`;
694
+ const block = `@theme inline {\n${declarations}\n}`;
683
695
  const customVariantIndex = source.indexOf("@custom-variant");
684
696
  if (customVariantIndex !== -1) {
685
697
  const nextLineIndex = source.indexOf("\n", customVariantIndex);
@@ -688,9 +700,7 @@ function upsertThemeInlineFont(source, fontVariable) {
688
700
  return `${block}\n\n${source.trimStart()}`;
689
701
  }
690
702
  return source.replace(pattern, (block) => {
691
- const withoutManagedFonts = block.replace(/\n\s*--font-(sans|serif|mono|heading):[^\n]+/g, "").replace(/\n\s*--bejamas-font-family:[^\n]+/g, "").replace(/@theme inline\s*\{\n?/, "@theme inline {\n");
692
- const declarations = [fontVariable ? ` ${fontVariable}: var(${fontVariable});` : null, " --font-heading: var(--font-heading);"].filter(Boolean).join("\n");
693
- return withoutManagedFonts.replace("@theme inline {\n", `@theme inline {\n${declarations}\n`);
703
+ return block.replace(/\n\s*--font-(sans|serif|mono|heading):[^\n]+/g, "").replace(/\n\s*--bejamas-font-family:[^\n]+/g, "").replace(/@theme inline\s*\{\n?/, "@theme inline {\n").replace("@theme inline {\n", `@theme inline {\n${declarations}\n`);
694
704
  });
695
705
  }
696
706
  function upsertBaseLayerHtmlFont(source, fontClass) {
@@ -706,7 +716,7 @@ function transformDesignSystemCss(source, config, themeVars) {
706
716
  function transformDesignSystemThemeCss(source, config, themeVars) {
707
717
  const effectiveThemeVars = themeVars ?? buildRegistryTheme(config).cssVars;
708
718
  const rootVars = {
709
- ...Object.fromEntries(Object.entries(effectiveThemeVars.theme ?? {}).filter(([key]) => key !== "bejamas-font-family")),
719
+ ...Object.fromEntries(Object.entries(effectiveThemeVars.theme ?? {}).filter(([key]) => key !== "bejamas-font-family" && key !== "font-heading")),
710
720
  ...effectiveThemeVars.light ?? {}
711
721
  };
712
722
  const darkVars = { ...effectiveThemeVars.dark ?? {} };
@@ -870,7 +880,7 @@ async function patchLayoutFile(filepath, config) {
870
880
  }
871
881
  const nextLanguage = getDocumentLanguage(config);
872
882
  const nextDirection = getDocumentDirection(config);
873
- let next = current.replace(/<html([^>]*?)lang="[^"]*"([^>]*)>/, "<html$1$2>").replace(/<html([^>]*?)dir="[^"]*"([^>]*)>/, "<html$1$2>");
883
+ let next = current.replace(/<html([^>]*?)\slang="[^"]*"([^>]*)>/, "<html$1$2>").replace(/<html([^>]*?)\sdir="[^"]*"([^>]*)>/, "<html$1$2>");
874
884
  next = next.replace(/<html([^>]*)>/, `<html$1 lang="${nextLanguage}"${config.rtl ? ` dir="${nextDirection}"` : ""}>`);
875
885
  if (next !== current) await fs.writeFile(filepath, next, "utf8");
876
886
  }
@@ -1165,6 +1175,7 @@ async function getPackageManager(targetDir, { withFallback } = { withFallback: f
1165
1175
  if (userAgent.startsWith("bun")) return "bun";
1166
1176
  return "npm";
1167
1177
  }
1178
+ const WORKSPACE_ROOT_INSTALL_ENV = { npm_config_ignore_workspace_root_check: "true" };
1168
1179
 
1169
1180
  //#endregion
1170
1181
  //#region src/registry/errors.ts
@@ -1363,20 +1374,33 @@ async function copyTemplateFromGitHub(templateDirName, projectPath) {
1363
1374
  failures.join("\n")
1364
1375
  ].join("\n"));
1365
1376
  }
1366
- async function applyLocalPackageOverrides(projectPath) {
1367
- const bejamasPackageOverride = process.env.BEJAMAS_PACKAGE_OVERRIDE;
1368
- if (!bejamasPackageOverride) return;
1377
+ /** A valid npm package name derived from the project's folder name. */
1378
+ function toPackageName(projectName) {
1379
+ return path$1.basename(projectName).toLowerCase().replace(/[^a-z0-9._~-]+/g, "-").replace(/^[._-]+|-+$/g, "") || "my-app";
1380
+ }
1381
+ /**
1382
+ * Fit the template's manifests to this project: the root package takes the
1383
+ * project's name (the template's `astro` shadows the real `astro` package in a
1384
+ * workspace), and every `bejamas` dependency points at the running CLI version,
1385
+ * or at `BEJAMAS_PACKAGE_OVERRIDE` when testing a local build.
1386
+ */
1387
+ async function applyProjectPackageMetadata(projectPath, { projectName, bejamasVersion = BEJAMAS_PACKAGE_METADATA.version, bejamasOverride = process.env.BEJAMAS_PACKAGE_OVERRIDE }) {
1388
+ const bejamasSpec = bejamasOverride ? `file:${bejamasOverride.replace(/\\/g, "/")}` : bejamasVersion && `^${bejamasVersion}`;
1389
+ const rootPackageJson = path$1.resolve(projectPath, "package.json");
1369
1390
  const packageJsonPaths = await fg("**/package.json", {
1370
1391
  cwd: projectPath,
1371
1392
  absolute: true,
1372
1393
  ignore: ["**/node_modules/**"]
1373
1394
  });
1374
- const normalizedOverride = bejamasPackageOverride.replace(/\\/g, "/");
1375
1395
  await Promise.all(packageJsonPaths.map(async (packageJsonPath) => {
1376
1396
  const packageJson = await fs.readJson(packageJsonPath);
1377
1397
  let changed = false;
1378
- for (const field of ["dependencies", "devDependencies"]) if (packageJson[field]?.bejamas) {
1379
- packageJson[field].bejamas = `file:${normalizedOverride}`;
1398
+ if (path$1.resolve(packageJsonPath) === rootPackageJson) {
1399
+ packageJson.name = toPackageName(projectName);
1400
+ changed = true;
1401
+ }
1402
+ for (const field of ["dependencies", "devDependencies"]) if (bejamasSpec && packageJson[field]?.bejamas) {
1403
+ packageJson[field].bejamas = bejamasSpec;
1380
1404
  changed = true;
1381
1405
  }
1382
1406
  if (changed) await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
@@ -1442,6 +1466,7 @@ async function createProject(options) {
1442
1466
  process.exit(1);
1443
1467
  }
1444
1468
  await createProjectFromTemplate(projectPath, {
1469
+ projectName,
1445
1470
  templateKey: template,
1446
1471
  packageManager,
1447
1472
  cwd: options.cwd
@@ -1464,7 +1489,7 @@ async function createProjectFromTemplate(projectPath, options) {
1464
1489
  await copyTemplateFromGitHub(templateDirName, projectPath);
1465
1490
  }
1466
1491
  await removeEmptyTemplateI18nDirs(projectPath);
1467
- await applyLocalPackageOverrides(projectPath);
1492
+ await applyProjectPackageMetadata(projectPath, { projectName: options.projectName });
1468
1493
  await execa(options.packageManager, ["install"], { cwd: projectPath });
1469
1494
  try {
1470
1495
  const { stdout } = await execa("git", ["rev-parse", "--is-inside-work-tree"], { cwd: projectPath });
@@ -1730,34 +1755,50 @@ async function repairUiPackageExports(uiDir, packageRoot) {
1730
1755
  }
1731
1756
 
1732
1757
  //#endregion
1733
- //#region src/utils/shadcn-cli.ts
1734
- const PINNED_SHADCN_VERSION = "4.21.0";
1735
- const PINNED_SHADCN_PACKAGE = `shadcn@${PINNED_SHADCN_VERSION}`;
1736
- const PINNED_SHADCN_EXEC_PREFIX = path.join(os$1.tmpdir(), "bejamas-shadcn", PINNED_SHADCN_VERSION);
1737
- async function ensurePinnedShadcnExecPrefix() {
1738
- await fs$1.mkdir(PINNED_SHADCN_EXEC_PREFIX, { recursive: true });
1739
- return PINNED_SHADCN_EXEC_PREFIX;
1740
- }
1741
- function getNpmExecutable() {
1742
- return process.platform === "win32" ? "npm.cmd" : "npm";
1743
- }
1744
- function buildPinnedShadcnInvocation(shadcnArgs) {
1758
+ //#region src/utils/pinned-npm-exec.ts
1759
+ /**
1760
+ * Run a package's bin at an exact version through `npm exec`, in a prefix of
1761
+ * its own so the user's project dependencies never interfere.
1762
+ */
1763
+ function definePinnedPackage({ name, version, bin, prefixDir }) {
1764
+ const execPrefix = path.join(os$1.tmpdir(), prefixDir, version);
1765
+ const spec = `${name}@${version}`;
1745
1766
  return {
1746
- cmd: getNpmExecutable(),
1747
- args: [
1748
- "exec",
1749
- "--yes",
1750
- "--prefix",
1751
- PINNED_SHADCN_EXEC_PREFIX,
1752
- `--package=${PINNED_SHADCN_PACKAGE}`,
1753
- "--",
1754
- "shadcn",
1755
- ...shadcnArgs
1756
- ],
1757
- source: "isolated"
1767
+ version,
1768
+ spec,
1769
+ execPrefix,
1770
+ async ensureExecPrefix() {
1771
+ await fs$1.mkdir(execPrefix, { recursive: true });
1772
+ return execPrefix;
1773
+ },
1774
+ invocation(args) {
1775
+ return {
1776
+ cmd: process.platform === "win32" ? "npm.cmd" : "npm",
1777
+ args: [
1778
+ "exec",
1779
+ "--yes",
1780
+ "--prefix",
1781
+ execPrefix,
1782
+ `--package=${spec}`,
1783
+ "--",
1784
+ bin,
1785
+ ...args
1786
+ ],
1787
+ source: "isolated"
1788
+ };
1789
+ }
1758
1790
  };
1759
1791
  }
1760
1792
 
1793
+ //#endregion
1794
+ //#region src/utils/shadcn-cli.ts
1795
+ const PINNED_SHADCN = definePinnedPackage({
1796
+ name: "shadcn",
1797
+ version: "4.21.0",
1798
+ bin: "shadcn",
1799
+ prefixDir: "bejamas-shadcn"
1800
+ });
1801
+
1761
1802
  //#endregion
1762
1803
  //#region src/utils/shadcn-command.ts
1763
1804
  function extractPassthroughArgs(rawArgv, commandName) {
@@ -1769,8 +1810,8 @@ function extractPassthroughArgs(rawArgv, commandName) {
1769
1810
  return rest.slice(doubleDashIndex + 1);
1770
1811
  }
1771
1812
  async function runShadcnCommand({ cwd, args, env }) {
1772
- await ensurePinnedShadcnExecPrefix();
1773
- const invocation = buildPinnedShadcnInvocation(args);
1813
+ await PINNED_SHADCN.ensureExecPrefix();
1814
+ const invocation = PINNED_SHADCN.invocation(args);
1774
1815
  await execa(invocation.cmd, invocation.args, {
1775
1816
  cwd,
1776
1817
  env: {
@@ -1795,14 +1836,13 @@ function resolveDesignSystemConfig(options) {
1795
1836
  rtlLanguage
1796
1837
  }));
1797
1838
  }
1798
- const baseColor = options.baseColor ?? DEFAULT_DESIGN_SYSTEM_CONFIG.baseColor;
1799
1839
  return normalizeDesignSystemConfig(designSystemConfigSchema.parse({
1800
1840
  ...DEFAULT_DESIGN_SYSTEM_CONFIG,
1801
1841
  template: options.template ?? DEFAULT_DESIGN_SYSTEM_CONFIG.template,
1802
1842
  rtl: options.rtl ?? false,
1803
1843
  rtlLanguage,
1804
- baseColor,
1805
- theme: baseColor === DEFAULT_DESIGN_SYSTEM_CONFIG.baseColor ? DEFAULT_DESIGN_SYSTEM_CONFIG.theme : baseColor
1844
+ baseColor: options.baseColor ?? DEFAULT_DESIGN_SYSTEM_CONFIG.baseColor,
1845
+ theme: options.baseColor ?? DEFAULT_DESIGN_SYSTEM_CONFIG.theme
1806
1846
  }));
1807
1847
  }
1808
1848
  function buildInitUrl(config, themeRef, env = process.env) {
@@ -1925,7 +1965,7 @@ function extractOptionsForShadcnInit(rawArgv, cmd) {
1925
1965
  }
1926
1966
  return forwarded;
1927
1967
  }
1928
- const init = new Command().name("init").description("initialize your project and install dependencies").argument("[components...]", "names, url or local path to component").option("-t, --template <template>", "the template to use. (astro, astro-monorepo, astro-with-component-docs-monorepo)").option("-b, --base-color <base-color>", "the base color to use. (neutral, gray, zinc, stone, slate)", void 0).option("-p, --preset <preset>", "the encoded create preset to use").option("--theme-ref <theme-ref>", "the custom theme ref to use").option("-y, --yes", "skip confirmation prompt.", false).option("-d, --defaults", "use default configuration.", false).option("-f, --force", "force overwrite of existing configuration.", false).option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-s, --silent", "mute output.", false).option("--src-dir", "use the src directory when creating a new project.", false).option("--no-src-dir", "do not use the src directory when creating a new project.").option("--css-variables", "use css variables for theming.", true).option("--no-css-variables", "do not use css variables for theming.").option("--no-base-style", "do not install the base shadcn style.").option("--rtl", "enable right-to-left output", false).option("--lang <lang>", "set the RTL language. (ar, fa, he)").option("--reinstall", "re-install existing UI components. Enabled by default for preset switching.").option("--no-reinstall", "do not re-install existing UI components during preset switching.").action(async (_components, opts, cmd) => {
1968
+ const init = new Command().name("init").description("initialize your project and install dependencies").argument("[components...]", "names, url or local path to component").option("-t, --template <template>", "the template to use. (astro, astro-monorepo, astro-with-component-docs-monorepo)").option("-b, --base-color <base-color>", `the base color to use. (${BASE_COLORS.map((color) => color.name).join(", ")})`, void 0).option("-p, --preset <preset>", "the encoded create preset to use").option("--theme-ref <theme-ref>", "the custom theme ref to use").option("-y, --yes", "skip confirmation prompt.", false).option("-d, --defaults", "use default configuration.", false).option("-f, --force", "force overwrite of existing configuration.", false).option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-s, --silent", "mute output.", false).option("--src-dir", "use the src directory when creating a new project.", false).option("--no-src-dir", "do not use the src directory when creating a new project.").option("--css-variables", "use css variables for theming.", true).option("--no-css-variables", "do not use css variables for theming.").option("--no-base-style", "do not install the base shadcn style.").option("--rtl", "enable right-to-left output", false).option("--lang <lang>", "set the RTL language. (ar, fa, he)").option("--reinstall", "re-install existing UI components. Enabled by default for preset switching.").option("--no-reinstall", "do not re-install existing UI components during preset switching.").action(async (_components, opts, cmd) => {
1929
1969
  try {
1930
1970
  await runInit({
1931
1971
  ...opts,
@@ -1976,6 +2016,7 @@ async function runInit(options) {
1976
2016
  async function runExistingProjectInit(options, designConfig = resolveDesignSystemConfig(options)) {
1977
2017
  const env = {
1978
2018
  ...process.env,
2019
+ ...WORKSPACE_ROOT_INSTALL_ENV,
1979
2020
  REGISTRY_URL: resolveRegistryUrl()
1980
2021
  };
1981
2022
  const initUrl = buildInitUrl(designConfig, options.themeRef);
@@ -2184,7 +2225,7 @@ async function generateDocs({ cwd, outDir, verbose }) {
2184
2225
  if (process.env.BEJAMAS_DOCS_CWD) logger.info(`Docs CWD: ${process.env.BEJAMAS_DOCS_CWD}`);
2185
2226
  if (process.env.BEJAMAS_DOCS_OUT_DIR) logger.info(`Docs out: ${process.env.BEJAMAS_DOCS_OUT_DIR}`);
2186
2227
  }
2187
- const mod = await import("./generate-mdx-Bd_qGcMg.js");
2228
+ const mod = await import("./generate-mdx-COXrRS-x.js");
2188
2229
  if (typeof mod.runDocsGenerator === "function") await mod.runDocsGenerator();
2189
2230
  else throw new Error("Failed to load docs generator. Export 'runDocsGenerator' not found.");
2190
2231
  } catch (err) {
@@ -2404,6 +2445,7 @@ async function ensureRegistryDependencies(cwd, items) {
2404
2445
  const manager = await getPackageManager(cwd);
2405
2446
  await execa(manager, [manager === "npm" ? "install" : "add", ...missing], {
2406
2447
  cwd,
2448
+ env: WORKSPACE_ROOT_INSTALL_ENV,
2407
2449
  stdio: "inherit"
2408
2450
  });
2409
2451
  }
@@ -2820,11 +2862,12 @@ function parseShadcnOutput(stdout, stderr) {
2820
2862
  async function addComponents(cwd, packages, forwardedOptions, isVerbose, isSilent, inspectionMode) {
2821
2863
  const env = {
2822
2864
  ...process.env,
2865
+ ...WORKSPACE_ROOT_INSTALL_ENV,
2823
2866
  REGISTRY_URL: resolveRegistryUrl()
2824
2867
  };
2825
- await ensurePinnedShadcnExecPrefix();
2868
+ await PINNED_SHADCN.ensureExecPrefix();
2826
2869
  const shadcnArgs = buildShadcnAddArgs(packages, forwardedOptions);
2827
- const invocation = buildPinnedShadcnInvocation(shadcnArgs);
2870
+ const invocation = PINNED_SHADCN.invocation(shadcnArgs);
2828
2871
  if (isVerbose) logger.info(`[bejamas-ui] ${invocation.cmd} ${invocation.args.join(" ")}`);
2829
2872
  const registrySpinner = spinner("Checking registry.", { silent: isSilent });
2830
2873
  registrySpinner.start();
@@ -3937,10 +3980,32 @@ function handlePresetError(error) {
3937
3980
  process.exit(1);
3938
3981
  }
3939
3982
 
3983
+ //#endregion
3984
+ //#region ../bench/package.json
3985
+ var version = "0.1.0";
3986
+
3987
+ //#endregion
3988
+ //#region src/commands/bench.ts
3989
+ const PINNED_BENCH = definePinnedPackage({
3990
+ name: "@bejamas/bench",
3991
+ version,
3992
+ bin: "bejamas-bench",
3993
+ prefixDir: "bejamas-bench"
3994
+ });
3995
+ const bench = new Command().name("bench").description("compare an original site with its ported version (runs @bejamas/bench)").usage("--original <url> --ported <url> [options]").argument("[args...]", "run `bejamas bench --help` for all options").helpOption(false).allowUnknownOption().passThroughOptions().allowExcessArguments().action(async (args) => {
3996
+ await PINNED_BENCH.ensureExecPrefix();
3997
+ const invocation = PINNED_BENCH.invocation(args);
3998
+ const result = await execa(invocation.cmd, invocation.args, {
3999
+ stdio: "inherit",
4000
+ reject: false
4001
+ });
4002
+ process.exit(result.exitCode ?? 2);
4003
+ });
4004
+
3940
4005
  //#endregion
3941
4006
  //#region src/index.ts
3942
4007
  const pkg = createRequire(import.meta.url)("../package.json");
3943
- const program = new Command().name("bejamas").description("bejamas/ui cli").configureHelp({ helpWidth: Math.min(100, process.stdout.columns || 100) }).version(pkg.version, "-v, --version", "output the version number");
4008
+ const program = new Command().name("bejamas").description("bejamas/ui cli").configureHelp({ helpWidth: Math.min(100, process.stdout.columns || 100) }).version(pkg.version, "-v, --version", "output the version number").enablePositionalOptions();
3944
4009
  program.addCommand(init);
3945
4010
  program.addCommand(add);
3946
4011
  program.addCommand(apply);
@@ -3949,6 +4014,7 @@ program.addCommand(info);
3949
4014
  program.addCommand(docs);
3950
4015
  program.addCommand(docsBuild);
3951
4016
  program.addCommand(docsCheck);
4017
+ program.addCommand(bench);
3952
4018
  program.parse(process.argv);
3953
4019
 
3954
4020
  //#endregion