@dreamy-ui/cli 2.0.1 → 2.0.3

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
@@ -19554,9 +19554,7 @@ async function writeRecipesIndexFile(recipesDir, jsx, debug4) {
19554
19554
  exportName: recipeExport
19555
19555
  });
19556
19556
  } else {
19557
- debug4(
19558
- `No recipe export found for ${expectedExportName} in ${file}`
19559
- );
19557
+ debug4(`No recipe export found for ${expectedExportName} in ${file}`);
19560
19558
  }
19561
19559
  } catch (error) {
19562
19560
  debug4(`Failed to read recipe file ${file}:`, error);
@@ -19607,9 +19605,7 @@ async function writePatternsIndexFile(patternsDir, jsx, debug4) {
19607
19605
  exportName: patternExport
19608
19606
  });
19609
19607
  } else {
19610
- debug4(
19611
- `No pattern export found for ${expectedExportName} in ${file}`
19612
- );
19608
+ debug4(`No pattern export found for ${expectedExportName} in ${file}`);
19613
19609
  }
19614
19610
  } catch (error) {
19615
19611
  debug4(`Failed to read pattern file ${file}:`, error);
@@ -19630,6 +19626,46 @@ export const patterns = {
19630
19626
  const indexPath = join$1(patternsDir, indexFilename);
19631
19627
  await writeFile(indexPath, indexContent, "utf-8");
19632
19628
  }
19629
+ function toPascalCase(str) {
19630
+ return str.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
19631
+ }
19632
+ async function writeComponentsIndexFile(componentsDir, jsx, debug4) {
19633
+ let componentFiles = [];
19634
+ try {
19635
+ const allFiles = await readdir(componentsDir);
19636
+ componentFiles = allFiles.filter((file) => {
19637
+ if (file === "index.ts" || file === "index.tsx" || file === "index.js" || file === "index.jsx") {
19638
+ return false;
19639
+ }
19640
+ return jsx && (file.endsWith(".jsx") || file.endsWith(".js")) || !jsx && (file.endsWith(".tsx") || file.endsWith(".ts"));
19641
+ });
19642
+ } catch (error) {
19643
+ return;
19644
+ }
19645
+ if (componentFiles.length === 0) return;
19646
+ const exports$1 = [];
19647
+ for (const file of componentFiles) {
19648
+ try {
19649
+ const filePath = join$1(componentsDir, file);
19650
+ const fileContent = await readFile$1(filePath, "utf-8");
19651
+ const fileName = file.replace(/\.(tsx|ts|jsx|js)$/, "");
19652
+ const componentName = toPascalCase(fileName);
19653
+ const hasRootExport = fileContent.match(/export\s+const\s+Root\s*/) !== null;
19654
+ if (hasRootExport) {
19655
+ exports$1.push(`export * as ${componentName} from "./${fileName}";`);
19656
+ } else {
19657
+ exports$1.push(`export * from "./${fileName}";`);
19658
+ }
19659
+ } catch (error) {
19660
+ debug4(`Failed to read component file ${file}:`, error);
19661
+ }
19662
+ }
19663
+ if (exports$1.length === 0) return;
19664
+ const indexContent = exports$1.join("\n") + "\n";
19665
+ const indexFilename = jsx ? "index.js" : "index.ts";
19666
+ const indexPath = join$1(componentsDir, indexFilename);
19667
+ await writeFile(indexPath, indexContent, "utf-8");
19668
+ }
19633
19669
  var execAsync = promisify(exec);
19634
19670
  var commandMap = {
19635
19671
  npm: {
@@ -19701,14 +19737,7 @@ function getFramework(files, cwd) {
19701
19737
  }
19702
19738
  function getComponentsDir(scope, cwd) {
19703
19739
  const basePath = join$2("components", "ui");
19704
- if (scope.framework === "remix" || scope.framework === "react-router") {
19705
- return join$2("app", basePath);
19706
- }
19707
- if (scope.framework === "next") {
19708
- const isSrcDir = existsSync(join$2(cwd, "src"));
19709
- return join$2(isSrcDir ? "src" : "", basePath);
19710
- }
19711
- return join$2("src", basePath);
19740
+ return basePath;
19712
19741
  }
19713
19742
  async function getProjectContext(opts) {
19714
19743
  const { cwd = process.cwd(), tsx } = opts;
@@ -19721,7 +19750,7 @@ async function getProjectContext(opts) {
19721
19750
  if (files.length > 0) {
19722
19751
  scope.framework = getFramework(files, cwd);
19723
19752
  if (scope.framework) {
19724
- scope.componentsDir = getComponentsDir(scope, cwd);
19753
+ scope.componentsDir = getComponentsDir();
19725
19754
  }
19726
19755
  }
19727
19756
  return {
@@ -19738,7 +19767,7 @@ var compositionFileSchema = z.object({
19738
19767
  content: z.string()
19739
19768
  }),
19740
19769
  component: z.string(),
19741
- // npmDependencies: z.array(z.string()),
19770
+ npmDependencies: z.array(z.string()),
19742
19771
  fileDependencies: z.array(z.string()),
19743
19772
  hasRecipe: z.boolean(),
19744
19773
  hasPattern: z.boolean(),
@@ -19751,7 +19780,7 @@ var compositionIndexSchema = z.array(
19751
19780
  id: z.string(),
19752
19781
  file: z.string(),
19753
19782
  component: z.string(),
19754
- // npmDependencies: z.array(z.string()),
19783
+ npmDependencies: z.array(z.string()),
19755
19784
  fileDependencies: z.array(z.string()),
19756
19785
  hasRecipe: z.boolean(),
19757
19786
  hasPattern: z.boolean(),
@@ -19783,6 +19812,8 @@ var processEnvSchema = z.object({
19783
19812
  var addCommandFlagsSchema = z.object({
19784
19813
  force: z.boolean().optional(),
19785
19814
  dryRun: z.boolean().optional(),
19815
+ skipInstall: z.boolean().optional(),
19816
+ skipCodegen: z.boolean().optional(),
19786
19817
  outdir: z.string().optional(),
19787
19818
  all: z.boolean().optional(),
19788
19819
  tsx: z.boolean().optional()
@@ -19883,7 +19914,9 @@ var findCompositionById = (compositions, id) => {
19883
19914
  return normalizedCompId === normalizedId;
19884
19915
  });
19885
19916
  if (found) {
19886
- debug(`Found composition: "${found.id}" with ${found.fileDependencies.length} dependencies`);
19917
+ debug(
19918
+ `Found composition: "${found.id}" with ${found.fileDependencies.length} dependencies`
19919
+ );
19887
19920
  } else {
19888
19921
  debug(`No composition found for: "${id}" (normalized: "${normalizedId}")`);
19889
19922
  debug(`Available composition IDs: ${compositions.map((c2) => c2.id).join(", ")}`);
@@ -19908,6 +19941,7 @@ var getFileDependencies = (compositions, id) => {
19908
19941
  debug(` Adding initial dependency: "${dep}" -> "${normalized}"`);
19909
19942
  fileDependencies.add(normalized);
19910
19943
  });
19944
+ const npmDependencies = new Set(composition.npmDependencies || []);
19911
19945
  const collect = (depId, depth = 0) => {
19912
19946
  const indent3 = " ".repeat(depth + 1);
19913
19947
  debug(`${indent3}Collecting dependencies for: "${depId}"`);
@@ -19916,6 +19950,11 @@ var getFileDependencies = (compositions, id) => {
19916
19950
  debug(`${indent3}\u274C Could not find composition for: "${depId}"`);
19917
19951
  return;
19918
19952
  }
19953
+ if (comp.npmDependencies) {
19954
+ comp.npmDependencies.forEach((dep) => {
19955
+ npmDependencies.add(dep);
19956
+ });
19957
+ }
19919
19958
  comp.fileDependencies.forEach((dep) => {
19920
19959
  const normalizedDep = normalizePath(dep);
19921
19960
  if (fileDependencies.has(normalizedDep)) {
@@ -19929,12 +19968,16 @@ var getFileDependencies = (compositions, id) => {
19929
19968
  };
19930
19969
  collect(id);
19931
19970
  const result = Array.from(fileDependencies);
19971
+ const npmResult = Array.from(npmDependencies);
19932
19972
  debug(`
19933
19973
  === Total file dependencies collected: ${result.length} ===`);
19934
19974
  debug(result);
19975
+ debug(`
19976
+ === Total npm dependencies collected: ${npmResult.length} ===`);
19977
+ debug(npmResult);
19935
19978
  return {
19936
- fileDependencies: result
19937
- // npmDependencies: Array.from(npmDependencies)
19979
+ fileDependencies: result,
19980
+ npmDependencies: npmResult
19938
19981
  };
19939
19982
  };
19940
19983
  function ensureDir(dirPath) {
@@ -19963,9 +20006,9 @@ async function tasks(tasks2) {
19963
20006
 
19964
20007
  // src/commands/add.ts
19965
20008
  var debug2 = createDebug("dreamy-ui:add");
19966
- var AddCommand = new Command("add").description("Add components to your project").argument("[components...]", "components to add").option("-d, --dry-run", "Dry run").option("--outdir <dir>", "Output directory to write the components").option("--all", "Add all components").option("-f, --force", "Overwrite existing files").option("--tsx", "Convert to TSX").action(async (selectedComponents, flags) => {
20009
+ var AddCommand = new Command("add").description("Add components to your project").argument("[components...]", "components to add").option("-d, --dry-run", "Dry run").option("--skip-install", "Skip dependency installation").option("--skip-codegen", "Skip running panda codegen").option("--outdir <dir>", "Output directory to write the components").option("--all", "Add all components").option("-f, --force", "Overwrite existing files").option("--tsx", "Convert to TSX").action(async (selectedComponents, flags) => {
19967
20010
  const parsedFlags = addCommandFlagsSchema.parse(flags);
19968
- const { dryRun, force, all, tsx } = parsedFlags;
20011
+ const { dryRun, force, all, tsx, skipInstall, skipCodegen } = parsedFlags;
19969
20012
  const ctx = await getProjectContext({
19970
20013
  cwd: parsedFlags.outdir || process.cwd(),
19971
20014
  tsx
@@ -20028,8 +20071,12 @@ var AddCommand = new Command("add").description("Add components to your project"
20028
20071
  return;
20029
20072
  }
20030
20073
  debug2(`Found dependencies for ${id}:`, result.fileDependencies);
20031
- const key2 = JSON.stringify(result);
20032
- allDeps.set(key2, result);
20074
+ const depData = {
20075
+ fileDependencies: result.fileDependencies,
20076
+ npmDependencies: result.npmDependencies || []
20077
+ };
20078
+ const key2 = JSON.stringify(depData);
20079
+ allDeps.set(key2, depData);
20033
20080
  result.fileDependencies.forEach((fileDep) => {
20034
20081
  const depId = fileDep.replace(/\.(tsx|ts|jsx|js)$/, "");
20035
20082
  debug2(`Recursively processing: ${depId} (from ${fileDep})`);
@@ -20042,7 +20089,9 @@ var AddCommand = new Command("add").description("Add components to your project"
20042
20089
  }
20043
20090
  const deps = getAllDependenciesRecursive(components);
20044
20091
  const fileDependencies = uniq(deps.flatMap((dep) => dep.fileDependencies));
20092
+ const npmDependencies = uniq(deps.flatMap((dep) => dep.npmDependencies));
20045
20093
  debug2("fileDependencies", fileDependencies);
20094
+ debug2("npmDependencies", npmDependencies);
20046
20095
  const dependencyComponentIds = fileDependencies.map(
20047
20096
  (dep) => dep.replace(/\.(tsx|ts|jsx|js)$/, "")
20048
20097
  );
@@ -20051,6 +20100,7 @@ var AddCommand = new Command("add").description("Add components to your project"
20051
20100
  const skippedFiles = [];
20052
20101
  const skippedRecipes = [];
20053
20102
  const skippedPatterns = [];
20103
+ const writtenComponentFiles = [];
20054
20104
  const componentRecipes = await Promise.all(
20055
20105
  allComponentIds.map(async (id) => {
20056
20106
  const recipes = await getRecipeForComponent(id);
@@ -20066,11 +20116,11 @@ var AddCommand = new Command("add").description("Add components to your project"
20066
20116
  );
20067
20117
  const validPatterns = componentPatterns.filter(Boolean);
20068
20118
  await tasks([
20069
- // {
20070
- // title: "Installing required dependencies...",
20071
- // enabled: !!npmDependencies.length && !dryRun,
20072
- // task: () => installCommand([...npmDependencies, "--silent"], outdir)
20073
- // },
20119
+ {
20120
+ title: "Installing required dependencies...",
20121
+ enabled: !!npmDependencies.length && !dryRun && !skipInstall,
20122
+ task: () => installCommand([...npmDependencies, "--silent"], outdir)
20123
+ },
20074
20124
  {
20075
20125
  title: "Writing file dependencies",
20076
20126
  enabled: !!fileDependencies.length && !dryRun,
@@ -20092,6 +20142,7 @@ var AddCommand = new Command("add").description("Add components to your project"
20092
20142
  item.file.content.replace("compositions/ui", "."),
20093
20143
  "utf-8"
20094
20144
  );
20145
+ writtenComponentFiles.push(item.file.name);
20095
20146
  })
20096
20147
  );
20097
20148
  return "File dependencies written";
@@ -20207,6 +20258,7 @@ var AddCommand = new Command("add").description("Add components to your project"
20207
20258
  item.file.content.replace("compositions/ui", "."),
20208
20259
  "utf-8"
20209
20260
  );
20261
+ writtenComponentFiles.push(item.file.name);
20210
20262
  }
20211
20263
  } catch (error) {
20212
20264
  if (error instanceof Error) {
@@ -20220,8 +20272,16 @@ var AddCommand = new Command("add").description("Add components to your project"
20220
20272
  }
20221
20273
  },
20222
20274
  {
20223
- title: "Running panda codegen",
20275
+ title: "Generating components index file",
20224
20276
  enabled: !dryRun,
20277
+ task: async () => {
20278
+ await writeComponentsIndexFile(outdir, jsx, debug2);
20279
+ return "Components index file generated";
20280
+ }
20281
+ },
20282
+ {
20283
+ title: "Running panda codegen",
20284
+ enabled: !dryRun && !skipCodegen,
20225
20285
  task: async () => {
20226
20286
  await pandaCodegenCommand(process.cwd());
20227
20287
  return "panda codegen finished";
@@ -20596,7 +20656,7 @@ async function detectFramework(cwd) {
20596
20656
  type: "react-router",
20597
20657
  cssPath: "app/app.css",
20598
20658
  cssImportPath: "app/root.tsx",
20599
- providerPath: "app/components/dreamy-provider.tsx",
20659
+ providerPath: "components/dreamy-provider.tsx",
20600
20660
  includePattern: "./app/**/*.{js,jsx,ts,tsx}"
20601
20661
  };
20602
20662
  }
@@ -20606,7 +20666,7 @@ async function detectFramework(cwd) {
20606
20666
  type: "nextjs",
20607
20667
  cssPath: hasSrcDir ? "src/app/globals.css" : "app/globals.css",
20608
20668
  cssImportPath: hasSrcDir ? "src/app/layout.tsx" : "app/layout.tsx",
20609
- providerPath: hasSrcDir ? "src/components/dreamy-provider.tsx" : "components/dreamy-provider.tsx",
20669
+ providerPath: "components/dreamy-provider.tsx",
20610
20670
  includePattern: hasSrcDir ? "./src/**/*.{js,jsx,ts,tsx}" : "./app/**/*.{js,jsx,ts,tsx}"
20611
20671
  };
20612
20672
  }
@@ -20616,7 +20676,7 @@ async function detectFramework(cwd) {
20616
20676
  type: "vite",
20617
20677
  cssPath: hasSrcDir ? "src/index.css" : "src/index.css",
20618
20678
  cssImportPath: hasSrcDir ? "src/main.tsx" : "src/main.tsx",
20619
- providerPath: hasSrcDir ? "src/components/dreamy-provider.tsx" : "src/components/dreamy-provider.tsx",
20679
+ providerPath: "components/dreamy-provider.tsx",
20620
20680
  includePattern: "./src/**/*.{js,jsx,ts,tsx}"
20621
20681
  };
20622
20682
  }
@@ -20667,7 +20727,7 @@ async function createPandaConfig(cwd, framework, isTypeScript) {
20667
20727
  return false;
20668
20728
  }
20669
20729
  }
20670
- const componentsImportPath = framework.type === "react-router" ? "./app/components" : framework.type === "nextjs" && existsSync(join$2(cwd, "src")) ? "./src/components" : framework.type === "nextjs" ? "./components" : "./src/components";
20730
+ const componentsImportPath = "./components";
20671
20731
  const configContent = isTypeScript ? `import createDreamyPreset, { dreamyPlugin } from "@dreamy-ui/panda-preset";
20672
20732
  import { defineConfig } from "@pandacss/dev";
20673
20733
  import { patterns } from "${componentsImportPath}/patterns";
@@ -20675,7 +20735,6 @@ import { recipes } from "${componentsImportPath}/recipes";
20675
20735
 
20676
20736
  export default defineConfig({
20677
20737
  preflight: true,
20678
- watch: true,
20679
20738
  jsxFramework: "react",
20680
20739
  jsxStyleProps: "all",
20681
20740
  outExtension: "js",
@@ -20705,7 +20764,6 @@ import { recipes } from "${componentsImportPath}/recipes";
20705
20764
 
20706
20765
  export default defineConfig({
20707
20766
  preflight: true,
20708
- watch: true,
20709
20767
  jsxFramework: "react",
20710
20768
  jsxStyleProps: "all",
20711
20769
  outExtension: "js",
@@ -20798,7 +20856,8 @@ async function updateViteConfig(cwd, framework) {
20798
20856
  }
20799
20857
  const viteConfigPath = join$2(cwd, viteConfigFiles[0]);
20800
20858
  let content = readFileSync(viteConfigPath, "utf-8");
20801
- if (content.includes("@pandacss/dev/postcss") && content.includes("css:")) {
20859
+ const hasPandaPlugin = /plugins:\s*\[[^\]]*pandacss[^\]]*\]/.test(content) || /plugins:\s*\[[^\]]*@pandacss\/dev\/postcss[^\]]*\]/.test(content);
20860
+ if (hasPandaPlugin) {
20802
20861
  p4.log.info("\u2298 Vite config already configured for Panda CSS");
20803
20862
  return true;
20804
20863
  }
@@ -20827,10 +20886,62 @@ async function updateViteConfig(cwd, framework) {
20827
20886
  content = 'import pandacss from "@pandacss/dev/postcss";\n' + content;
20828
20887
  }
20829
20888
  }
20830
- if (!content.includes("css:")) {
20831
- const defineConfigMatch = content.match(/defineConfig\s*\(\s*\{/);
20832
- if (defineConfigMatch) {
20833
- const insertPosition = content.indexOf(defineConfigMatch[0]) + defineConfigMatch[0].length;
20889
+ const hasCssProperty = /css\s*:\s*\{/.test(content);
20890
+ if (hasCssProperty) {
20891
+ const postcssIndex = content.search(/postcss\s*:\s*\{/);
20892
+ const hasPostcssPlugins = postcssIndex !== -1 && content.slice(postcssIndex).search(/plugins\s*:\s*\[/) !== -1;
20893
+ if (hasPostcssPlugins) {
20894
+ const pluginsArrayMatch = content.match(/plugins\s*:\s*\[([^\]]*)\]/);
20895
+ if (pluginsArrayMatch) {
20896
+ const pluginsContent = pluginsArrayMatch[1];
20897
+ if (!pluginsContent.includes("pandacss")) {
20898
+ const arrayStart = content.indexOf(pluginsArrayMatch[0]);
20899
+ const pluginsStart = arrayStart + content.slice(arrayStart).indexOf("[") + 1;
20900
+ const insertPosition = pluginsStart + pluginsContent.trim().length;
20901
+ const separator = pluginsContent.trim() ? ", " : "";
20902
+ content = content.slice(0, insertPosition) + separator + "pandacss" + content.slice(insertPosition);
20903
+ }
20904
+ } else {
20905
+ const postcssMatch = content.match(/postcss\s*:\s*\{/);
20906
+ if (postcssMatch) {
20907
+ const postcssStart = content.indexOf(postcssMatch[0]);
20908
+ const postcssBraceStart = postcssStart + postcssMatch[0].length - 1;
20909
+ const afterBrace = content.slice(postcssBraceStart + 1);
20910
+ const nextBrace = afterBrace.indexOf("}");
20911
+ const postcssContent = afterBrace.slice(0, nextBrace);
20912
+ const needsComma = postcssContent.trim().length > 0 && !postcssContent.trim().endsWith(",");
20913
+ const insertPosition = postcssBraceStart + 1;
20914
+ const pluginsConfig = `${needsComma ? ", " : ""}plugins: [pandacss]`;
20915
+ content = content.slice(0, insertPosition) + pluginsConfig + content.slice(insertPosition);
20916
+ }
20917
+ }
20918
+ } else {
20919
+ const cssMatch = content.match(/css\s*:\s*\{/);
20920
+ if (cssMatch) {
20921
+ const cssStart = content.indexOf(cssMatch[0]);
20922
+ const cssBraceStart = cssStart + cssMatch[0].length - 1;
20923
+ const afterBrace = content.slice(cssBraceStart + 1);
20924
+ let braceCount = 1;
20925
+ let nextBracePos = -1;
20926
+ for (let i = 0; i < afterBrace.length; i++) {
20927
+ if (afterBrace[i] === "{") braceCount++;
20928
+ if (afterBrace[i] === "}") braceCount--;
20929
+ if (braceCount === 0) {
20930
+ nextBracePos = i;
20931
+ break;
20932
+ }
20933
+ }
20934
+ const cssContent = nextBracePos > 0 ? afterBrace.slice(0, nextBracePos) : "";
20935
+ const needsComma = cssContent.trim().length > 0 && !cssContent.trim().endsWith(",");
20936
+ const insertPosition = cssBraceStart + 1;
20937
+ const postcssConfig = `${needsComma ? ", " : ""}postcss: { plugins: [pandacss] }`;
20938
+ content = content.slice(0, insertPosition) + postcssConfig + content.slice(insertPosition);
20939
+ }
20940
+ }
20941
+ } else {
20942
+ const defineConfigObjectMatch = content.match(/defineConfig\s*\(\s*\{/);
20943
+ if (defineConfigObjectMatch) {
20944
+ const insertPosition = content.indexOf(defineConfigObjectMatch[0]) + defineConfigObjectMatch[0].length;
20834
20945
  const cssConfig = `
20835
20946
  css: {
20836
20947
  postcss: {
@@ -20838,6 +20949,67 @@ async function updateViteConfig(cwd, framework) {
20838
20949
  }
20839
20950
  },`;
20840
20951
  content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
20952
+ } else {
20953
+ const defineConfigCallbackMatch = content.match(
20954
+ /defineConfig\s*\(\s*(?:async\s+)?(?:\([^)]*\)|[a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>\s*(\{|\()/
20955
+ );
20956
+ if (defineConfigCallbackMatch) {
20957
+ const callbackStart = content.indexOf(defineConfigCallbackMatch[0]);
20958
+ const arrowIndex = content.indexOf("=>", callbackStart);
20959
+ const isImplicitReturn = defineConfigCallbackMatch[1] === "(";
20960
+ if (isImplicitReturn) {
20961
+ const matchEnd = callbackStart + defineConfigCallbackMatch[0].length;
20962
+ const braceInParen = content.indexOf("{", matchEnd);
20963
+ if (braceInParen !== -1) {
20964
+ const insertPosition = braceInParen + 1;
20965
+ const cssConfig = `
20966
+ css: {
20967
+ postcss: {
20968
+ plugins: [pandacss]
20969
+ }
20970
+ },`;
20971
+ content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
20972
+ } else {
20973
+ p4.log.warn("\u26A0 Could not find config object in implicit return");
20974
+ return false;
20975
+ }
20976
+ } else {
20977
+ const callbackBodyStart = arrowIndex + 2;
20978
+ const firstBrace = content.indexOf("{", callbackBodyStart);
20979
+ if (firstBrace === -1) {
20980
+ p4.log.warn("\u26A0 Could not find callback body");
20981
+ return false;
20982
+ }
20983
+ const callbackBody = content.slice(firstBrace);
20984
+ const returnMatch = callbackBody.match(/return\s*\{/);
20985
+ if (returnMatch) {
20986
+ const returnStart = firstBrace + callbackBody.indexOf(returnMatch[0]);
20987
+ const insertPosition = returnStart + returnMatch[0].length;
20988
+ const cssConfig = `
20989
+ css: {
20990
+ postcss: {
20991
+ plugins: [pandacss]
20992
+ }
20993
+ },`;
20994
+ content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
20995
+ } else {
20996
+ const insertPosition = firstBrace + 1;
20997
+ const cssConfig = `
20998
+ css: {
20999
+ postcss: {
21000
+ plugins: [pandacss]
21001
+ }
21002
+ },`;
21003
+ content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
21004
+ }
21005
+ }
21006
+ } else {
21007
+ p4.log.warn("\u26A0 Could not detect defineConfig pattern in vite.config");
21008
+ p4.log.info(
21009
+ '\u{1F4A1} Manually add Panda CSS PostCSS plugin to your vite.config:\n import pandacss from "@pandacss/dev/postcss";\n css: { postcss: { plugins: [pandacss] } }'
21010
+ );
21011
+ return false;
21012
+ }
20841
21013
  }
20842
21014
  }
20843
21015
  await writeFile(viteConfigPath, content, "utf-8");
@@ -21147,16 +21319,60 @@ async function updateTsConfig(cwd, framework) {
21147
21319
  tsconfig.include.push("styled-system/**/*");
21148
21320
  needsUpdate = true;
21149
21321
  }
21150
- const componentsPath = framework.type === "react-router" ? "./app/components/ui/*" : framework.type === "nextjs" && existsSync(join$2(cwd, "src")) ? "./src/components/ui/*" : framework.type === "nextjs" ? "./components/ui/*" : "./src/components/ui/*";
21322
+ const componentsPath = "./components/ui/*";
21151
21323
  if (!tsconfig.compilerOptions) {
21152
21324
  tsconfig.compilerOptions = {};
21153
21325
  }
21154
21326
  if (!tsconfig.compilerOptions.paths) {
21155
21327
  tsconfig.compilerOptions.paths = {};
21156
21328
  }
21157
- if (!tsconfig.compilerOptions.paths["@/ui/*"]) {
21158
- tsconfig.compilerOptions.paths["@/ui/*"] = [componentsPath];
21159
- needsUpdate = true;
21329
+ const existingPaths = tsconfig.compilerOptions.paths;
21330
+ const hasUiPath = "@/ui/*" in existingPaths;
21331
+ if (!hasUiPath) {
21332
+ const shouldAddUiPath = await p4.confirm({
21333
+ message: "Add @/ui/* path alias to tsconfig.json?",
21334
+ initialValue: true
21335
+ });
21336
+ if (p4.isCancel(shouldAddUiPath) || !shouldAddUiPath) {
21337
+ p4.log.warn("\u2298 Skipped @/ui/* path alias");
21338
+ p4.log.info(
21339
+ '\u{1F4A1} Manually add "@/ui/*": ["./components/ui/*"] to the "paths" object in tsconfig.json compilerOptions'
21340
+ );
21341
+ } else {
21342
+ const pathsWithoutUi = Object.keys(existingPaths).reduce(
21343
+ (acc, key2) => {
21344
+ if (key2 !== "@/ui/*") {
21345
+ acc[key2] = existingPaths[key2];
21346
+ }
21347
+ return acc;
21348
+ },
21349
+ {}
21350
+ );
21351
+ tsconfig.compilerOptions.paths = {
21352
+ "@/ui/*": [componentsPath],
21353
+ ...pathsWithoutUi
21354
+ };
21355
+ needsUpdate = true;
21356
+ }
21357
+ } else {
21358
+ const firstKey = Object.keys(existingPaths)[0];
21359
+ const needsReorder = firstKey !== "@/ui/*";
21360
+ if (needsReorder) {
21361
+ const pathsWithoutUi = Object.keys(existingPaths).reduce(
21362
+ (acc, key2) => {
21363
+ if (key2 !== "@/ui/*") {
21364
+ acc[key2] = existingPaths[key2];
21365
+ }
21366
+ return acc;
21367
+ },
21368
+ {}
21369
+ );
21370
+ tsconfig.compilerOptions.paths = {
21371
+ "@/ui/*": existingPaths["@/ui/*"],
21372
+ ...pathsWithoutUi
21373
+ };
21374
+ needsUpdate = true;
21375
+ }
21160
21376
  }
21161
21377
  if (framework.type === "nextjs" && !tsconfig.compilerOptions.paths["styled-system/*"]) {
21162
21378
  tsconfig.compilerOptions.paths["styled-system/*"] = ["./styled-system/*"];
@@ -21181,6 +21397,54 @@ async function updateTsConfig(cwd, framework) {
21181
21397
  return false;
21182
21398
  }
21183
21399
  }
21400
+ async function updatePackageJson(cwd) {
21401
+ try {
21402
+ const packageJsonPath = join$2(cwd, "package.json");
21403
+ if (!existsSync(packageJsonPath)) {
21404
+ p4.log.warn("\u26A0 Could not find package.json to add prepare script");
21405
+ p4.log.info(
21406
+ '\u{1F4A1} Manually add this script to your package.json:\n "prepare": "panda codegen"'
21407
+ );
21408
+ return false;
21409
+ }
21410
+ const content = readFileSync(packageJsonPath, "utf-8");
21411
+ const packageJson = JSON.parse(content);
21412
+ if (packageJson.scripts?.prepare) {
21413
+ if (packageJson.scripts.prepare.includes("panda codegen")) {
21414
+ p4.log.info("\u2298 prepare script already configured with panda codegen");
21415
+ return true;
21416
+ }
21417
+ const shouldUpdate = await p4.confirm({
21418
+ message: "prepare script exists but doesn't include 'panda codegen'. Update it?",
21419
+ initialValue: true
21420
+ });
21421
+ if (p4.isCancel(shouldUpdate) || !shouldUpdate) {
21422
+ p4.log.warn("\u2298 Skipped package.json prepare script update");
21423
+ p4.log.info(
21424
+ "\u{1F4A1} Manually add 'panda codegen' to your prepare script in package.json"
21425
+ );
21426
+ return false;
21427
+ }
21428
+ packageJson.scripts.prepare = `${packageJson.scripts.prepare} && panda codegen`;
21429
+ } else {
21430
+ if (!packageJson.scripts) {
21431
+ packageJson.scripts = {};
21432
+ }
21433
+ packageJson.scripts.prepare = "panda codegen";
21434
+ }
21435
+ await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
21436
+ p4.log.success("\u2713 Added prepare script to package.json");
21437
+ return true;
21438
+ } catch (error) {
21439
+ p4.log.error(
21440
+ `\u2717 Failed to update package.json: ${error instanceof Error ? error.message : String(error)}`
21441
+ );
21442
+ p4.log.warn(
21443
+ '\u{1F4A1} Manually add this script to your package.json:\n "prepare": "panda codegen"'
21444
+ );
21445
+ return false;
21446
+ }
21447
+ }
21184
21448
  async function runPandaCodegen(cwd) {
21185
21449
  const s = p4.spinner();
21186
21450
  try {
@@ -21229,7 +21493,7 @@ function printNextSteps(framework) {
21229
21493
  p4.log.info(
21230
21494
  `1. Update your app/root.tsx to use DreamyProvider:
21231
21495
 
21232
- import { DreamyProvider, getColorModeHTMLProps, getSSRColorMode } from "./${framework.providerPath.replace("app/", "")}";
21496
+ import { DreamyProvider, getColorModeHTMLProps, getSSRColorMode } from "../${framework.providerPath.replace("app/", "")}";
21233
21497
  import type { Route } from "./+types/root";
21234
21498
  import { useRouteLoaderData } from "react-router";
21235
21499
 
@@ -21261,7 +21525,7 @@ function printNextSteps(framework) {
21261
21525
  p4.log.info(
21262
21526
  `1. Update your app/layout.tsx to use DreamyProvider:
21263
21527
 
21264
- import { DreamyProvider } from "@/ui/${framework.providerPath.replace(/^(src\/)?/, "")}";
21528
+ import { DreamyProvider } from "../${framework.providerPath.replace(/^(src\/)?/, "")}";
21265
21529
  import { getSSRColorMode, getColorModeHTMLProps } from "@dreamy-ui/react/rsc";
21266
21530
  import { cookies } from "next/headers";
21267
21531
 
@@ -21286,7 +21550,7 @@ function printNextSteps(framework) {
21286
21550
  p4.log.info(
21287
21551
  `1. Update your src/main.tsx or src/App.tsx to use DreamyProvider:
21288
21552
 
21289
- import { DreamyProvider } from "./${framework.providerPath.replace("src/", "")}";
21553
+ import { DreamyProvider } from "../${framework.providerPath.replace("src/", "")}";
21290
21554
 
21291
21555
  function App() {
21292
21556
  return (
@@ -21326,6 +21590,7 @@ var InitCommand = new Command("init").description("Initialize Dreamy UI in your
21326
21590
  p4.log.info("\u2298 Skipped dependency installation");
21327
21591
  }
21328
21592
  await createPandaConfig(cwd, framework, isTypeScript);
21593
+ await updatePackageJson(cwd);
21329
21594
  await setupPostCSS(cwd, framework);
21330
21595
  await updateViteConfig(cwd, framework);
21331
21596
  if (framework.type === "react-router") {
@@ -21373,7 +21638,7 @@ var ListCommand = new Command("list").description("List all available components
21373
21638
  process.setMaxListeners(Number.POSITIVE_INFINITY);
21374
21639
  async function run() {
21375
21640
  p4.intro("Dreamy UI CLI \u{1F4AB}");
21376
- const packageJson = await import('./package-ER5PXQNF.js');
21641
+ const packageJson = await import('./package-QAS4MTCY.js');
21377
21642
  const program = new Command().name("dreamy-ui").description("The official CLI for Dreamy UI projects").version(packageJson.version);
21378
21643
  program.addCommand(InitCommand);
21379
21644
  program.addCommand(AddCommand);
@@ -0,0 +1,94 @@
1
+ import { createRequire } from 'module';
2
+ import './chunk-XML6CAC2.js';
3
+
4
+ createRequire(import.meta.url);
5
+
6
+ // package.json
7
+ var name = "@dreamy-ui/cli";
8
+ var version = "2.0.1";
9
+ var description = "CLI for Dreamy UI";
10
+ var author = "imexoodeex";
11
+ var license = "MIT";
12
+ var type = "module";
13
+ var sideEffects = false;
14
+ var main = "dist/index.js";
15
+ var module$1 = "dist/index.js";
16
+ var types = "dist/index.d.ts";
17
+ var files = [
18
+ "dist",
19
+ "bin"
20
+ ];
21
+ var bin = {
22
+ dreamy: "./bin/index.js"
23
+ };
24
+ var exports$1 = {
25
+ ".": {
26
+ source: "./src/index.ts",
27
+ import: {
28
+ types: "./dist/index.d.ts",
29
+ default: "./dist/index.js"
30
+ }
31
+ },
32
+ "./package.json": "./package.json"
33
+ };
34
+ var scripts = {
35
+ dev: "tsup --watch",
36
+ start: "bun run ./src/index.ts",
37
+ lint: "biome lint ./src",
38
+ build: "tsup",
39
+ "build:dev": "tsup",
40
+ "build:production": "tsup"
41
+ };
42
+ var dependencies = {
43
+ "@clack/prompts": "^0.11.0",
44
+ "@effect/platform": "0.69.28",
45
+ "@visulima/boxen": "^1.0.30",
46
+ "cli-table": "^0.3.11",
47
+ commander: "^13.1.0",
48
+ debug: "^4.4.0",
49
+ "fs-extra": "11.2.0",
50
+ globby: "14.0.2",
51
+ "https-proxy-agent": "^7.0.6",
52
+ "look-it-up": "^2.1.0",
53
+ "node-fetch": "^3.3.2",
54
+ "package-manager-detector": "^1.2.0",
55
+ picocolors: "^1.1.1",
56
+ "pkg-dir": "8.0.0",
57
+ sucrase: "^3.35.0",
58
+ yargs: "17.7.2",
59
+ zod: "^3.23.8"
60
+ };
61
+ var devDependencies = {
62
+ "@types/cli-table": "^0.3.4",
63
+ "@types/debug": "^4.1.12",
64
+ "@types/fs-extra": "11.0.4",
65
+ "@types/node": "22.10.1",
66
+ "@types/yargs": "17.0.33",
67
+ dotenv: "^17.2.3",
68
+ tsup: "^8.4.0",
69
+ typescript: "5.7.2"
70
+ };
71
+ var peerDependencies = {
72
+ typescript: "^5.0.0"
73
+ };
74
+ var package_default = {
75
+ name,
76
+ version,
77
+ description,
78
+ author,
79
+ license,
80
+ type,
81
+ sideEffects,
82
+ main,
83
+ module: module$1,
84
+ types,
85
+ files,
86
+ bin,
87
+ exports: exports$1,
88
+ scripts,
89
+ dependencies,
90
+ devDependencies,
91
+ peerDependencies
92
+ };
93
+
94
+ export { author, bin, package_default as default, dependencies, description, devDependencies, exports$1 as exports, files, license, main, module$1 as module, name, peerDependencies, scripts, sideEffects, type, types, version };
@@ -0,0 +1,94 @@
1
+ import { createRequire } from 'module';
2
+ import './chunk-XML6CAC2.js';
3
+
4
+ createRequire(import.meta.url);
5
+
6
+ // package.json
7
+ var name = "@dreamy-ui/cli";
8
+ var version = "2.0.2";
9
+ var description = "CLI for Dreamy UI";
10
+ var author = "imexoodeex";
11
+ var license = "MIT";
12
+ var type = "module";
13
+ var sideEffects = false;
14
+ var main = "dist/index.js";
15
+ var module$1 = "dist/index.js";
16
+ var types = "dist/index.d.ts";
17
+ var files = [
18
+ "dist",
19
+ "bin"
20
+ ];
21
+ var bin = {
22
+ dreamy: "./bin/index.js"
23
+ };
24
+ var exports$1 = {
25
+ ".": {
26
+ source: "./src/index.ts",
27
+ import: {
28
+ types: "./dist/index.d.ts",
29
+ default: "./dist/index.js"
30
+ }
31
+ },
32
+ "./package.json": "./package.json"
33
+ };
34
+ var scripts = {
35
+ dev: "tsup --watch",
36
+ start: "bun run ./src/index.ts",
37
+ lint: "biome lint ./src",
38
+ build: "tsup",
39
+ "build:dev": "tsup",
40
+ "build:production": "tsup"
41
+ };
42
+ var dependencies = {
43
+ "@clack/prompts": "^0.11.0",
44
+ "@effect/platform": "0.69.28",
45
+ "@visulima/boxen": "^1.0.30",
46
+ "cli-table": "^0.3.11",
47
+ commander: "^13.1.0",
48
+ debug: "^4.4.0",
49
+ "fs-extra": "11.2.0",
50
+ globby: "14.0.2",
51
+ "https-proxy-agent": "^7.0.6",
52
+ "look-it-up": "^2.1.0",
53
+ "node-fetch": "^3.3.2",
54
+ "package-manager-detector": "^1.2.0",
55
+ picocolors: "^1.1.1",
56
+ "pkg-dir": "8.0.0",
57
+ sucrase: "^3.35.0",
58
+ yargs: "17.7.2",
59
+ zod: "^3.23.8"
60
+ };
61
+ var devDependencies = {
62
+ "@types/cli-table": "^0.3.4",
63
+ "@types/debug": "^4.1.12",
64
+ "@types/fs-extra": "11.0.4",
65
+ "@types/node": "22.10.1",
66
+ "@types/yargs": "17.0.33",
67
+ dotenv: "^17.2.3",
68
+ tsup: "^8.4.0",
69
+ typescript: "5.7.2"
70
+ };
71
+ var peerDependencies = {
72
+ typescript: "^5.0.0"
73
+ };
74
+ var package_default = {
75
+ name,
76
+ version,
77
+ description,
78
+ author,
79
+ license,
80
+ type,
81
+ sideEffects,
82
+ main,
83
+ module: module$1,
84
+ types,
85
+ files,
86
+ bin,
87
+ exports: exports$1,
88
+ scripts,
89
+ dependencies,
90
+ devDependencies,
91
+ peerDependencies
92
+ };
93
+
94
+ export { author, bin, package_default as default, dependencies, description, devDependencies, exports$1 as exports, files, license, main, module$1 as module, name, peerDependencies, scripts, sideEffects, type, types, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamy-ui/cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "CLI for Dreamy UI",
5
5
  "author": "imexoodeex",
6
6
  "license": "MIT",