@dreamy-ui/cli 2.0.1 → 2.0.2
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 +260 -46
- package/dist/package-5IJ5ICCX.js +94 -0
- package/package.json +1 -1
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
19783
|
+
npmDependencies: z.array(z.string()),
|
|
19755
19784
|
fileDependencies: z.array(z.string()),
|
|
19756
19785
|
hasRecipe: z.boolean(),
|
|
19757
19786
|
hasPattern: z.boolean(),
|
|
@@ -19883,7 +19912,9 @@ var findCompositionById = (compositions, id) => {
|
|
|
19883
19912
|
return normalizedCompId === normalizedId;
|
|
19884
19913
|
});
|
|
19885
19914
|
if (found) {
|
|
19886
|
-
debug(
|
|
19915
|
+
debug(
|
|
19916
|
+
`Found composition: "${found.id}" with ${found.fileDependencies.length} dependencies`
|
|
19917
|
+
);
|
|
19887
19918
|
} else {
|
|
19888
19919
|
debug(`No composition found for: "${id}" (normalized: "${normalizedId}")`);
|
|
19889
19920
|
debug(`Available composition IDs: ${compositions.map((c2) => c2.id).join(", ")}`);
|
|
@@ -19908,6 +19939,7 @@ var getFileDependencies = (compositions, id) => {
|
|
|
19908
19939
|
debug(` Adding initial dependency: "${dep}" -> "${normalized}"`);
|
|
19909
19940
|
fileDependencies.add(normalized);
|
|
19910
19941
|
});
|
|
19942
|
+
const npmDependencies = new Set(composition.npmDependencies || []);
|
|
19911
19943
|
const collect = (depId, depth = 0) => {
|
|
19912
19944
|
const indent3 = " ".repeat(depth + 1);
|
|
19913
19945
|
debug(`${indent3}Collecting dependencies for: "${depId}"`);
|
|
@@ -19916,6 +19948,11 @@ var getFileDependencies = (compositions, id) => {
|
|
|
19916
19948
|
debug(`${indent3}\u274C Could not find composition for: "${depId}"`);
|
|
19917
19949
|
return;
|
|
19918
19950
|
}
|
|
19951
|
+
if (comp.npmDependencies) {
|
|
19952
|
+
comp.npmDependencies.forEach((dep) => {
|
|
19953
|
+
npmDependencies.add(dep);
|
|
19954
|
+
});
|
|
19955
|
+
}
|
|
19919
19956
|
comp.fileDependencies.forEach((dep) => {
|
|
19920
19957
|
const normalizedDep = normalizePath(dep);
|
|
19921
19958
|
if (fileDependencies.has(normalizedDep)) {
|
|
@@ -19929,12 +19966,16 @@ var getFileDependencies = (compositions, id) => {
|
|
|
19929
19966
|
};
|
|
19930
19967
|
collect(id);
|
|
19931
19968
|
const result = Array.from(fileDependencies);
|
|
19969
|
+
const npmResult = Array.from(npmDependencies);
|
|
19932
19970
|
debug(`
|
|
19933
19971
|
=== Total file dependencies collected: ${result.length} ===`);
|
|
19934
19972
|
debug(result);
|
|
19973
|
+
debug(`
|
|
19974
|
+
=== Total npm dependencies collected: ${npmResult.length} ===`);
|
|
19975
|
+
debug(npmResult);
|
|
19935
19976
|
return {
|
|
19936
|
-
fileDependencies: result
|
|
19937
|
-
|
|
19977
|
+
fileDependencies: result,
|
|
19978
|
+
npmDependencies: npmResult
|
|
19938
19979
|
};
|
|
19939
19980
|
};
|
|
19940
19981
|
function ensureDir(dirPath) {
|
|
@@ -20028,8 +20069,12 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20028
20069
|
return;
|
|
20029
20070
|
}
|
|
20030
20071
|
debug2(`Found dependencies for ${id}:`, result.fileDependencies);
|
|
20031
|
-
const
|
|
20032
|
-
|
|
20072
|
+
const depData = {
|
|
20073
|
+
fileDependencies: result.fileDependencies,
|
|
20074
|
+
npmDependencies: result.npmDependencies || []
|
|
20075
|
+
};
|
|
20076
|
+
const key2 = JSON.stringify(depData);
|
|
20077
|
+
allDeps.set(key2, depData);
|
|
20033
20078
|
result.fileDependencies.forEach((fileDep) => {
|
|
20034
20079
|
const depId = fileDep.replace(/\.(tsx|ts|jsx|js)$/, "");
|
|
20035
20080
|
debug2(`Recursively processing: ${depId} (from ${fileDep})`);
|
|
@@ -20042,7 +20087,9 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20042
20087
|
}
|
|
20043
20088
|
const deps = getAllDependenciesRecursive(components);
|
|
20044
20089
|
const fileDependencies = uniq(deps.flatMap((dep) => dep.fileDependencies));
|
|
20090
|
+
const npmDependencies = uniq(deps.flatMap((dep) => dep.npmDependencies));
|
|
20045
20091
|
debug2("fileDependencies", fileDependencies);
|
|
20092
|
+
debug2("npmDependencies", npmDependencies);
|
|
20046
20093
|
const dependencyComponentIds = fileDependencies.map(
|
|
20047
20094
|
(dep) => dep.replace(/\.(tsx|ts|jsx|js)$/, "")
|
|
20048
20095
|
);
|
|
@@ -20051,6 +20098,7 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20051
20098
|
const skippedFiles = [];
|
|
20052
20099
|
const skippedRecipes = [];
|
|
20053
20100
|
const skippedPatterns = [];
|
|
20101
|
+
const writtenComponentFiles = [];
|
|
20054
20102
|
const componentRecipes = await Promise.all(
|
|
20055
20103
|
allComponentIds.map(async (id) => {
|
|
20056
20104
|
const recipes = await getRecipeForComponent(id);
|
|
@@ -20066,11 +20114,11 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20066
20114
|
);
|
|
20067
20115
|
const validPatterns = componentPatterns.filter(Boolean);
|
|
20068
20116
|
await tasks([
|
|
20069
|
-
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
|
|
20073
|
-
|
|
20117
|
+
{
|
|
20118
|
+
title: "Installing required dependencies...",
|
|
20119
|
+
enabled: !!npmDependencies.length && !dryRun,
|
|
20120
|
+
task: () => installCommand([...npmDependencies, "--silent"], outdir)
|
|
20121
|
+
},
|
|
20074
20122
|
{
|
|
20075
20123
|
title: "Writing file dependencies",
|
|
20076
20124
|
enabled: !!fileDependencies.length && !dryRun,
|
|
@@ -20092,6 +20140,7 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20092
20140
|
item.file.content.replace("compositions/ui", "."),
|
|
20093
20141
|
"utf-8"
|
|
20094
20142
|
);
|
|
20143
|
+
writtenComponentFiles.push(item.file.name);
|
|
20095
20144
|
})
|
|
20096
20145
|
);
|
|
20097
20146
|
return "File dependencies written";
|
|
@@ -20207,6 +20256,7 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20207
20256
|
item.file.content.replace("compositions/ui", "."),
|
|
20208
20257
|
"utf-8"
|
|
20209
20258
|
);
|
|
20259
|
+
writtenComponentFiles.push(item.file.name);
|
|
20210
20260
|
}
|
|
20211
20261
|
} catch (error) {
|
|
20212
20262
|
if (error instanceof Error) {
|
|
@@ -20219,6 +20269,14 @@ var AddCommand = new Command("add").description("Add components to your project"
|
|
|
20219
20269
|
return "Selected components written";
|
|
20220
20270
|
}
|
|
20221
20271
|
},
|
|
20272
|
+
{
|
|
20273
|
+
title: "Generating components index file",
|
|
20274
|
+
enabled: !dryRun,
|
|
20275
|
+
task: async () => {
|
|
20276
|
+
await writeComponentsIndexFile(outdir, jsx, debug2);
|
|
20277
|
+
return "Components index file generated";
|
|
20278
|
+
}
|
|
20279
|
+
},
|
|
20222
20280
|
{
|
|
20223
20281
|
title: "Running panda codegen",
|
|
20224
20282
|
enabled: !dryRun,
|
|
@@ -20596,7 +20654,7 @@ async function detectFramework(cwd) {
|
|
|
20596
20654
|
type: "react-router",
|
|
20597
20655
|
cssPath: "app/app.css",
|
|
20598
20656
|
cssImportPath: "app/root.tsx",
|
|
20599
|
-
providerPath: "
|
|
20657
|
+
providerPath: "components/dreamy-provider.tsx",
|
|
20600
20658
|
includePattern: "./app/**/*.{js,jsx,ts,tsx}"
|
|
20601
20659
|
};
|
|
20602
20660
|
}
|
|
@@ -20606,7 +20664,7 @@ async function detectFramework(cwd) {
|
|
|
20606
20664
|
type: "nextjs",
|
|
20607
20665
|
cssPath: hasSrcDir ? "src/app/globals.css" : "app/globals.css",
|
|
20608
20666
|
cssImportPath: hasSrcDir ? "src/app/layout.tsx" : "app/layout.tsx",
|
|
20609
|
-
providerPath:
|
|
20667
|
+
providerPath: "components/dreamy-provider.tsx",
|
|
20610
20668
|
includePattern: hasSrcDir ? "./src/**/*.{js,jsx,ts,tsx}" : "./app/**/*.{js,jsx,ts,tsx}"
|
|
20611
20669
|
};
|
|
20612
20670
|
}
|
|
@@ -20616,7 +20674,7 @@ async function detectFramework(cwd) {
|
|
|
20616
20674
|
type: "vite",
|
|
20617
20675
|
cssPath: hasSrcDir ? "src/index.css" : "src/index.css",
|
|
20618
20676
|
cssImportPath: hasSrcDir ? "src/main.tsx" : "src/main.tsx",
|
|
20619
|
-
providerPath:
|
|
20677
|
+
providerPath: "components/dreamy-provider.tsx",
|
|
20620
20678
|
includePattern: "./src/**/*.{js,jsx,ts,tsx}"
|
|
20621
20679
|
};
|
|
20622
20680
|
}
|
|
@@ -20667,7 +20725,7 @@ async function createPandaConfig(cwd, framework, isTypeScript) {
|
|
|
20667
20725
|
return false;
|
|
20668
20726
|
}
|
|
20669
20727
|
}
|
|
20670
|
-
const componentsImportPath =
|
|
20728
|
+
const componentsImportPath = "./components";
|
|
20671
20729
|
const configContent = isTypeScript ? `import createDreamyPreset, { dreamyPlugin } from "@dreamy-ui/panda-preset";
|
|
20672
20730
|
import { defineConfig } from "@pandacss/dev";
|
|
20673
20731
|
import { patterns } from "${componentsImportPath}/patterns";
|
|
@@ -20675,7 +20733,6 @@ import { recipes } from "${componentsImportPath}/recipes";
|
|
|
20675
20733
|
|
|
20676
20734
|
export default defineConfig({
|
|
20677
20735
|
preflight: true,
|
|
20678
|
-
watch: true,
|
|
20679
20736
|
jsxFramework: "react",
|
|
20680
20737
|
jsxStyleProps: "all",
|
|
20681
20738
|
outExtension: "js",
|
|
@@ -20705,7 +20762,6 @@ import { recipes } from "${componentsImportPath}/recipes";
|
|
|
20705
20762
|
|
|
20706
20763
|
export default defineConfig({
|
|
20707
20764
|
preflight: true,
|
|
20708
|
-
watch: true,
|
|
20709
20765
|
jsxFramework: "react",
|
|
20710
20766
|
jsxStyleProps: "all",
|
|
20711
20767
|
outExtension: "js",
|
|
@@ -20798,7 +20854,8 @@ async function updateViteConfig(cwd, framework) {
|
|
|
20798
20854
|
}
|
|
20799
20855
|
const viteConfigPath = join$2(cwd, viteConfigFiles[0]);
|
|
20800
20856
|
let content = readFileSync(viteConfigPath, "utf-8");
|
|
20801
|
-
|
|
20857
|
+
const hasPandaPlugin = /plugins:\s*\[[^\]]*pandacss[^\]]*\]/.test(content) || /plugins:\s*\[[^\]]*@pandacss\/dev\/postcss[^\]]*\]/.test(content);
|
|
20858
|
+
if (hasPandaPlugin) {
|
|
20802
20859
|
p4.log.info("\u2298 Vite config already configured for Panda CSS");
|
|
20803
20860
|
return true;
|
|
20804
20861
|
}
|
|
@@ -20827,10 +20884,62 @@ async function updateViteConfig(cwd, framework) {
|
|
|
20827
20884
|
content = 'import pandacss from "@pandacss/dev/postcss";\n' + content;
|
|
20828
20885
|
}
|
|
20829
20886
|
}
|
|
20830
|
-
|
|
20831
|
-
|
|
20832
|
-
|
|
20833
|
-
|
|
20887
|
+
const hasCssProperty = /css\s*:\s*\{/.test(content);
|
|
20888
|
+
if (hasCssProperty) {
|
|
20889
|
+
const postcssIndex = content.search(/postcss\s*:\s*\{/);
|
|
20890
|
+
const hasPostcssPlugins = postcssIndex !== -1 && content.slice(postcssIndex).search(/plugins\s*:\s*\[/) !== -1;
|
|
20891
|
+
if (hasPostcssPlugins) {
|
|
20892
|
+
const pluginsArrayMatch = content.match(/plugins\s*:\s*\[([^\]]*)\]/);
|
|
20893
|
+
if (pluginsArrayMatch) {
|
|
20894
|
+
const pluginsContent = pluginsArrayMatch[1];
|
|
20895
|
+
if (!pluginsContent.includes("pandacss")) {
|
|
20896
|
+
const arrayStart = content.indexOf(pluginsArrayMatch[0]);
|
|
20897
|
+
const pluginsStart = arrayStart + content.slice(arrayStart).indexOf("[") + 1;
|
|
20898
|
+
const insertPosition = pluginsStart + pluginsContent.trim().length;
|
|
20899
|
+
const separator = pluginsContent.trim() ? ", " : "";
|
|
20900
|
+
content = content.slice(0, insertPosition) + separator + "pandacss" + content.slice(insertPosition);
|
|
20901
|
+
}
|
|
20902
|
+
} else {
|
|
20903
|
+
const postcssMatch = content.match(/postcss\s*:\s*\{/);
|
|
20904
|
+
if (postcssMatch) {
|
|
20905
|
+
const postcssStart = content.indexOf(postcssMatch[0]);
|
|
20906
|
+
const postcssBraceStart = postcssStart + postcssMatch[0].length - 1;
|
|
20907
|
+
const afterBrace = content.slice(postcssBraceStart + 1);
|
|
20908
|
+
const nextBrace = afterBrace.indexOf("}");
|
|
20909
|
+
const postcssContent = afterBrace.slice(0, nextBrace);
|
|
20910
|
+
const needsComma = postcssContent.trim().length > 0 && !postcssContent.trim().endsWith(",");
|
|
20911
|
+
const insertPosition = postcssBraceStart + 1;
|
|
20912
|
+
const pluginsConfig = `${needsComma ? ", " : ""}plugins: [pandacss]`;
|
|
20913
|
+
content = content.slice(0, insertPosition) + pluginsConfig + content.slice(insertPosition);
|
|
20914
|
+
}
|
|
20915
|
+
}
|
|
20916
|
+
} else {
|
|
20917
|
+
const cssMatch = content.match(/css\s*:\s*\{/);
|
|
20918
|
+
if (cssMatch) {
|
|
20919
|
+
const cssStart = content.indexOf(cssMatch[0]);
|
|
20920
|
+
const cssBraceStart = cssStart + cssMatch[0].length - 1;
|
|
20921
|
+
const afterBrace = content.slice(cssBraceStart + 1);
|
|
20922
|
+
let braceCount = 1;
|
|
20923
|
+
let nextBracePos = -1;
|
|
20924
|
+
for (let i = 0; i < afterBrace.length; i++) {
|
|
20925
|
+
if (afterBrace[i] === "{") braceCount++;
|
|
20926
|
+
if (afterBrace[i] === "}") braceCount--;
|
|
20927
|
+
if (braceCount === 0) {
|
|
20928
|
+
nextBracePos = i;
|
|
20929
|
+
break;
|
|
20930
|
+
}
|
|
20931
|
+
}
|
|
20932
|
+
const cssContent = nextBracePos > 0 ? afterBrace.slice(0, nextBracePos) : "";
|
|
20933
|
+
const needsComma = cssContent.trim().length > 0 && !cssContent.trim().endsWith(",");
|
|
20934
|
+
const insertPosition = cssBraceStart + 1;
|
|
20935
|
+
const postcssConfig = `${needsComma ? ", " : ""}postcss: { plugins: [pandacss] }`;
|
|
20936
|
+
content = content.slice(0, insertPosition) + postcssConfig + content.slice(insertPosition);
|
|
20937
|
+
}
|
|
20938
|
+
}
|
|
20939
|
+
} else {
|
|
20940
|
+
const defineConfigObjectMatch = content.match(/defineConfig\s*\(\s*\{/);
|
|
20941
|
+
if (defineConfigObjectMatch) {
|
|
20942
|
+
const insertPosition = content.indexOf(defineConfigObjectMatch[0]) + defineConfigObjectMatch[0].length;
|
|
20834
20943
|
const cssConfig = `
|
|
20835
20944
|
css: {
|
|
20836
20945
|
postcss: {
|
|
@@ -20838,6 +20947,67 @@ async function updateViteConfig(cwd, framework) {
|
|
|
20838
20947
|
}
|
|
20839
20948
|
},`;
|
|
20840
20949
|
content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
|
|
20950
|
+
} else {
|
|
20951
|
+
const defineConfigCallbackMatch = content.match(
|
|
20952
|
+
/defineConfig\s*\(\s*(?:async\s+)?(?:\([^)]*\)|[a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>\s*(\{|\()/
|
|
20953
|
+
);
|
|
20954
|
+
if (defineConfigCallbackMatch) {
|
|
20955
|
+
const callbackStart = content.indexOf(defineConfigCallbackMatch[0]);
|
|
20956
|
+
const arrowIndex = content.indexOf("=>", callbackStart);
|
|
20957
|
+
const isImplicitReturn = defineConfigCallbackMatch[1] === "(";
|
|
20958
|
+
if (isImplicitReturn) {
|
|
20959
|
+
const matchEnd = callbackStart + defineConfigCallbackMatch[0].length;
|
|
20960
|
+
const braceInParen = content.indexOf("{", matchEnd);
|
|
20961
|
+
if (braceInParen !== -1) {
|
|
20962
|
+
const insertPosition = braceInParen + 1;
|
|
20963
|
+
const cssConfig = `
|
|
20964
|
+
css: {
|
|
20965
|
+
postcss: {
|
|
20966
|
+
plugins: [pandacss]
|
|
20967
|
+
}
|
|
20968
|
+
},`;
|
|
20969
|
+
content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
|
|
20970
|
+
} else {
|
|
20971
|
+
p4.log.warn("\u26A0 Could not find config object in implicit return");
|
|
20972
|
+
return false;
|
|
20973
|
+
}
|
|
20974
|
+
} else {
|
|
20975
|
+
const callbackBodyStart = arrowIndex + 2;
|
|
20976
|
+
const firstBrace = content.indexOf("{", callbackBodyStart);
|
|
20977
|
+
if (firstBrace === -1) {
|
|
20978
|
+
p4.log.warn("\u26A0 Could not find callback body");
|
|
20979
|
+
return false;
|
|
20980
|
+
}
|
|
20981
|
+
const callbackBody = content.slice(firstBrace);
|
|
20982
|
+
const returnMatch = callbackBody.match(/return\s*\{/);
|
|
20983
|
+
if (returnMatch) {
|
|
20984
|
+
const returnStart = firstBrace + callbackBody.indexOf(returnMatch[0]);
|
|
20985
|
+
const insertPosition = returnStart + returnMatch[0].length;
|
|
20986
|
+
const cssConfig = `
|
|
20987
|
+
css: {
|
|
20988
|
+
postcss: {
|
|
20989
|
+
plugins: [pandacss]
|
|
20990
|
+
}
|
|
20991
|
+
},`;
|
|
20992
|
+
content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
|
|
20993
|
+
} else {
|
|
20994
|
+
const insertPosition = firstBrace + 1;
|
|
20995
|
+
const cssConfig = `
|
|
20996
|
+
css: {
|
|
20997
|
+
postcss: {
|
|
20998
|
+
plugins: [pandacss]
|
|
20999
|
+
}
|
|
21000
|
+
},`;
|
|
21001
|
+
content = content.slice(0, insertPosition) + cssConfig + content.slice(insertPosition);
|
|
21002
|
+
}
|
|
21003
|
+
}
|
|
21004
|
+
} else {
|
|
21005
|
+
p4.log.warn("\u26A0 Could not detect defineConfig pattern in vite.config");
|
|
21006
|
+
p4.log.info(
|
|
21007
|
+
'\u{1F4A1} Manually add Panda CSS PostCSS plugin to your vite.config:\n import pandacss from "@pandacss/dev/postcss";\n css: { postcss: { plugins: [pandacss] } }'
|
|
21008
|
+
);
|
|
21009
|
+
return false;
|
|
21010
|
+
}
|
|
20841
21011
|
}
|
|
20842
21012
|
}
|
|
20843
21013
|
await writeFile(viteConfigPath, content, "utf-8");
|
|
@@ -21147,16 +21317,60 @@ async function updateTsConfig(cwd, framework) {
|
|
|
21147
21317
|
tsconfig.include.push("styled-system/**/*");
|
|
21148
21318
|
needsUpdate = true;
|
|
21149
21319
|
}
|
|
21150
|
-
const componentsPath =
|
|
21320
|
+
const componentsPath = "./components/ui/*";
|
|
21151
21321
|
if (!tsconfig.compilerOptions) {
|
|
21152
21322
|
tsconfig.compilerOptions = {};
|
|
21153
21323
|
}
|
|
21154
21324
|
if (!tsconfig.compilerOptions.paths) {
|
|
21155
21325
|
tsconfig.compilerOptions.paths = {};
|
|
21156
21326
|
}
|
|
21157
|
-
|
|
21158
|
-
|
|
21159
|
-
|
|
21327
|
+
const existingPaths = tsconfig.compilerOptions.paths;
|
|
21328
|
+
const hasUiPath = "@/ui/*" in existingPaths;
|
|
21329
|
+
if (!hasUiPath) {
|
|
21330
|
+
const shouldAddUiPath = await p4.confirm({
|
|
21331
|
+
message: "Add @/ui/* path alias to tsconfig.json?",
|
|
21332
|
+
initialValue: true
|
|
21333
|
+
});
|
|
21334
|
+
if (p4.isCancel(shouldAddUiPath) || !shouldAddUiPath) {
|
|
21335
|
+
p4.log.warn("\u2298 Skipped @/ui/* path alias");
|
|
21336
|
+
p4.log.info(
|
|
21337
|
+
'\u{1F4A1} Manually add "@/ui/*": ["./components/ui/*"] to the "paths" object in tsconfig.json compilerOptions'
|
|
21338
|
+
);
|
|
21339
|
+
} else {
|
|
21340
|
+
const pathsWithoutUi = Object.keys(existingPaths).reduce(
|
|
21341
|
+
(acc, key2) => {
|
|
21342
|
+
if (key2 !== "@/ui/*") {
|
|
21343
|
+
acc[key2] = existingPaths[key2];
|
|
21344
|
+
}
|
|
21345
|
+
return acc;
|
|
21346
|
+
},
|
|
21347
|
+
{}
|
|
21348
|
+
);
|
|
21349
|
+
tsconfig.compilerOptions.paths = {
|
|
21350
|
+
"@/ui/*": [componentsPath],
|
|
21351
|
+
...pathsWithoutUi
|
|
21352
|
+
};
|
|
21353
|
+
needsUpdate = true;
|
|
21354
|
+
}
|
|
21355
|
+
} else {
|
|
21356
|
+
const firstKey = Object.keys(existingPaths)[0];
|
|
21357
|
+
const needsReorder = firstKey !== "@/ui/*";
|
|
21358
|
+
if (needsReorder) {
|
|
21359
|
+
const pathsWithoutUi = Object.keys(existingPaths).reduce(
|
|
21360
|
+
(acc, key2) => {
|
|
21361
|
+
if (key2 !== "@/ui/*") {
|
|
21362
|
+
acc[key2] = existingPaths[key2];
|
|
21363
|
+
}
|
|
21364
|
+
return acc;
|
|
21365
|
+
},
|
|
21366
|
+
{}
|
|
21367
|
+
);
|
|
21368
|
+
tsconfig.compilerOptions.paths = {
|
|
21369
|
+
"@/ui/*": existingPaths["@/ui/*"],
|
|
21370
|
+
...pathsWithoutUi
|
|
21371
|
+
};
|
|
21372
|
+
needsUpdate = true;
|
|
21373
|
+
}
|
|
21160
21374
|
}
|
|
21161
21375
|
if (framework.type === "nextjs" && !tsconfig.compilerOptions.paths["styled-system/*"]) {
|
|
21162
21376
|
tsconfig.compilerOptions.paths["styled-system/*"] = ["./styled-system/*"];
|
|
@@ -21229,7 +21443,7 @@ function printNextSteps(framework) {
|
|
|
21229
21443
|
p4.log.info(
|
|
21230
21444
|
`1. Update your app/root.tsx to use DreamyProvider:
|
|
21231
21445
|
|
|
21232
|
-
import { DreamyProvider, getColorModeHTMLProps, getSSRColorMode } from "
|
|
21446
|
+
import { DreamyProvider, getColorModeHTMLProps, getSSRColorMode } from "../${framework.providerPath.replace("app/", "")}";
|
|
21233
21447
|
import type { Route } from "./+types/root";
|
|
21234
21448
|
import { useRouteLoaderData } from "react-router";
|
|
21235
21449
|
|
|
@@ -21261,7 +21475,7 @@ function printNextSteps(framework) {
|
|
|
21261
21475
|
p4.log.info(
|
|
21262
21476
|
`1. Update your app/layout.tsx to use DreamyProvider:
|
|
21263
21477
|
|
|
21264
|
-
import { DreamyProvider } from "
|
|
21478
|
+
import { DreamyProvider } from "../${framework.providerPath.replace(/^(src\/)?/, "")}";
|
|
21265
21479
|
import { getSSRColorMode, getColorModeHTMLProps } from "@dreamy-ui/react/rsc";
|
|
21266
21480
|
import { cookies } from "next/headers";
|
|
21267
21481
|
|
|
@@ -21286,7 +21500,7 @@ function printNextSteps(framework) {
|
|
|
21286
21500
|
p4.log.info(
|
|
21287
21501
|
`1. Update your src/main.tsx or src/App.tsx to use DreamyProvider:
|
|
21288
21502
|
|
|
21289
|
-
import { DreamyProvider } from "
|
|
21503
|
+
import { DreamyProvider } from "../${framework.providerPath.replace("src/", "")}";
|
|
21290
21504
|
|
|
21291
21505
|
function App() {
|
|
21292
21506
|
return (
|
|
@@ -21373,7 +21587,7 @@ var ListCommand = new Command("list").description("List all available components
|
|
|
21373
21587
|
process.setMaxListeners(Number.POSITIVE_INFINITY);
|
|
21374
21588
|
async function run() {
|
|
21375
21589
|
p4.intro("Dreamy UI CLI \u{1F4AB}");
|
|
21376
|
-
const packageJson = await import('./package-
|
|
21590
|
+
const packageJson = await import('./package-5IJ5ICCX.js');
|
|
21377
21591
|
const program = new Command().name("dreamy-ui").description("The official CLI for Dreamy UI projects").version(packageJson.version);
|
|
21378
21592
|
program.addCommand(InitCommand);
|
|
21379
21593
|
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 };
|