@yamada-ui/cli 2.0.0-dev-20251007020753 → 2.0.0-dev-20251007054727

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.
Files changed (2) hide show
  1. package/dist/index.js +253 -132
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5290,6 +5290,104 @@ var package_default = {
5290
5290
  devDependencies
5291
5291
  };
5292
5292
 
5293
+ //#endregion
5294
+ //#region src/constant.ts
5295
+ const CONFIG_FILE_NAME = "ui.json";
5296
+ const REGISTRY_FILE_NAME = "registry.json";
5297
+ const DEFAULT_PACKAGE_NAME = {
5298
+ ui: "@workspaces/ui",
5299
+ theme: "@workspaces/theme"
5300
+ };
5301
+ const REGISTRY_URL = "https://v2.yamada-ui.com/registry/v2";
5302
+ const DEFAULT_PATH = {
5303
+ components: "./components",
5304
+ hooks: "./hooks",
5305
+ providers: "./providers",
5306
+ ui: {
5307
+ monorepo: "./workspaces/ui",
5308
+ polyrepo: "./components/ui"
5309
+ },
5310
+ theme: {
5311
+ monorepo: "./workspaces/theme",
5312
+ polyrepo: "./theme"
5313
+ }
5314
+ };
5315
+ const SECTION_NAMES = [
5316
+ "components",
5317
+ "hooks",
5318
+ "providers"
5319
+ ];
5320
+ const DEFAULT_CONFIG = {
5321
+ $schema: `${REGISTRY_URL}/config.schema.json`,
5322
+ components: { overwrite: true },
5323
+ hooks: { overwrite: true },
5324
+ providers: { overwrite: true }
5325
+ };
5326
+ const REQUIRED_DEPENDENCIES = {
5327
+ ui: ["react@^19", "react-dom@^19"],
5328
+ theme: []
5329
+ };
5330
+ const REQUIRED_DEV_DEPENDENCIES = {
5331
+ ui: ["@types/react@^19", "@types/react-dom@^19"],
5332
+ theme: []
5333
+ };
5334
+ const DEFAULT_PACKAGE_JSON = {
5335
+ version: "1.0.0",
5336
+ type: "module",
5337
+ private: true,
5338
+ scripts: {}
5339
+ };
5340
+ const DEFAULT_PACKAGE_JSON_EXPORTS = {
5341
+ ui: {
5342
+ tsx: {
5343
+ ".": "./src/index.ts",
5344
+ "./components/*": "./src/components/*/index.ts",
5345
+ "./hooks/*": "./src/hooks/*/index.ts",
5346
+ "./providers/*": "./src/providers/*/index.ts"
5347
+ },
5348
+ jsx: {
5349
+ ".": "./src/index.js",
5350
+ "./components/*": "./src/components/*/index.js",
5351
+ "./hooks/*": "./src/hooks/*/index.js",
5352
+ "./providers/*": "./src/providers/*/index.js"
5353
+ }
5354
+ },
5355
+ theme: {
5356
+ tsx: { ".": "./src/index.ts" },
5357
+ jsx: { ".": "./src/index.js" }
5358
+ }
5359
+ };
5360
+ const TSCONFIG_JSON = {
5361
+ compilerOptions: {
5362
+ target: "ESNext",
5363
+ module: "ESNext",
5364
+ lib: [
5365
+ "DOM",
5366
+ "DOM.Iterable",
5367
+ "ESNext"
5368
+ ],
5369
+ moduleResolution: "Bundler",
5370
+ moduleDetection: "force",
5371
+ jsx: "preserve",
5372
+ strict: true,
5373
+ declaration: true,
5374
+ declarationMap: true,
5375
+ esModuleInterop: true,
5376
+ isolatedModules: true,
5377
+ resolveJsonModule: true,
5378
+ incremental: false,
5379
+ noEmit: true,
5380
+ skipLibCheck: true,
5381
+ allowJs: true,
5382
+ allowSyntheticDefaultImports: true,
5383
+ noUncheckedSideEffectImports: true,
5384
+ noFallthroughCasesInSwitch: true,
5385
+ noUncheckedIndexedAccess: true
5386
+ },
5387
+ include: ["src/**/*.ts", "src/**/*.tsx"],
5388
+ exclude: ["node_modules"]
5389
+ };
5390
+
5293
5391
  //#endregion
5294
5392
  //#region src/utils/lint.ts
5295
5393
  async function lintText(content, { cwd: cwd$3, enabled = true, filePath } = {}) {
@@ -5574,6 +5672,17 @@ function transformTsToJs(content) {
5574
5672
 
5575
5673
  //#endregion
5576
5674
  //#region src/utils/config.ts
5675
+ function getPaths(rootPath, jsx) {
5676
+ const srcPath = existsSync(path$1.resolve(rootPath, "src")) ? path$1.resolve(rootPath, "src") : rootPath;
5677
+ const indexPath = path$1.resolve(srcPath, transformExtension("index.ts", jsx));
5678
+ const registryPath = path$1.resolve(srcPath, REGISTRY_FILE_NAME);
5679
+ return {
5680
+ src: srcPath,
5681
+ index: indexPath,
5682
+ registry: registryPath,
5683
+ root: rootPath
5684
+ };
5685
+ }
5577
5686
  async function getConfig(cwd$3, configPath, { format: format$2, jsx, lint } = {}) {
5578
5687
  try {
5579
5688
  const data = await readFile(path$1.resolve(cwd$3, configPath), "utf-8");
@@ -5581,21 +5690,20 @@ async function getConfig(cwd$3, configPath, { format: format$2, jsx, lint } = {}
5581
5690
  if (!isUndefined(format$2)) userConfig.format = { enabled: format$2 };
5582
5691
  if (!isUndefined(lint)) userConfig.lint = { enabled: lint };
5583
5692
  if (!isUndefined(jsx)) userConfig.jsx = jsx;
5584
- const rootPath = path$1.resolve(cwd$3, userConfig.path ?? (userConfig.monorepo ? DEFAULT_PATH.monorepo : DEFAULT_PATH.polyrepo));
5585
- const src = existsSync(path$1.resolve(rootPath, "src"));
5586
- const srcPath = src ? path$1.resolve(rootPath, "src") : rootPath;
5693
+ const paths = {
5694
+ theme: getPaths(path$1.resolve(cwd$3, userConfig.theme?.path ?? (userConfig.monorepo ? DEFAULT_PATH.theme.monorepo : DEFAULT_PATH.theme.polyrepo)), userConfig.jsx),
5695
+ ui: getPaths(path$1.resolve(cwd$3, userConfig.path ?? (userConfig.monorepo ? DEFAULT_PATH.ui.monorepo : DEFAULT_PATH.ui.polyrepo)), userConfig.jsx)
5696
+ };
5587
5697
  const sectionMap = Object.fromEntries(SECTION_NAMES.map((section) => {
5588
5698
  const replacedSection = (userConfig[section]?.path ?? DEFAULT_PATH[section]).replace(/(\.\.\/|\.\/)/g, "").replace(/(^\/|\/$)/g, "");
5589
5699
  return [section, replacedSection];
5590
5700
  }));
5591
- const indexPath = path$1.resolve(srcPath, transformExtension("index.ts", userConfig.jsx));
5592
- const registryPath = path$1.resolve(srcPath, REGISTRY_FILE_NAME);
5593
5701
  if (userConfig.theme?.path) userConfig.theme.path = path$1.resolve(cwd$3, userConfig.theme.path);
5594
5702
  function isSection(section) {
5595
5703
  return SECTION_NAMES.includes(section);
5596
5704
  }
5597
5705
  function getSectionResolvedPath(section) {
5598
- return path$1.resolve(srcPath, userConfig[section]?.path ?? DEFAULT_PATH[section]);
5706
+ return path$1.resolve(paths.ui.src, userConfig[section]?.path ?? DEFAULT_PATH[section]);
5599
5707
  }
5600
5708
  function getSectionPath(section) {
5601
5709
  let path$9 = userConfig[section]?.path ?? DEFAULT_PATH[section];
@@ -5627,16 +5735,12 @@ async function getConfig(cwd$3, configPath, { format: format$2, jsx, lint } = {}
5627
5735
  }
5628
5736
  return {
5629
5737
  ...userConfig,
5630
- src,
5631
5738
  cwd: cwd$3,
5632
5739
  getSection,
5633
5740
  getSectionPath,
5634
5741
  getSectionResolvedPath,
5635
- indexPath,
5636
5742
  isSection,
5637
- registryPath,
5638
- rootPath,
5639
- srcPath
5743
+ paths
5640
5744
  };
5641
5745
  } catch {
5642
5746
  const packageManager = getPackageManager();
@@ -5855,15 +5959,14 @@ function transformIndex(generatedNames, content, { getSection }) {
5855
5959
  return content;
5856
5960
  }
5857
5961
  async function transformIndexWithFormatAndLint(content, config$1, generatedNames) {
5858
- const { cwd: cwd$3, format: format$2, indexPath, jsx, lint } = config$1;
5859
5962
  content = transformIndex(generatedNames, content, config$1);
5860
- if (jsx) content = transformTsToJs(content);
5963
+ if (config$1.jsx) content = transformTsToJs(content);
5861
5964
  content = await lintText(content, {
5862
- ...lint,
5863
- cwd: cwd$3,
5864
- filePath: indexPath
5965
+ ...config$1.lint,
5966
+ cwd: config$1.cwd,
5967
+ filePath: config$1.paths.ui.index
5865
5968
  });
5866
- content = await formatText(content, format$2);
5969
+ content = await formatText(content, config$1.format);
5867
5970
  return content;
5868
5971
  }
5869
5972
  async function generateSource(dirPath, section, { name: fileName, content, data, template }, config$1, generatedNames = []) {
@@ -5885,86 +5988,6 @@ async function generateSources(dirPath, registry, config$1, generatedNames = [])
5885
5988
  await Promise.all([...registry.sources.map((source) => generateSource(dirPath, registry.section, source, config$1, generatedNames)), writeFileSafe(path$1.resolve(dirPath, REGISTRY_FILE_NAME), JSON.stringify(registry), merge(config$1, { format: { parser: "json" } }))]);
5886
5989
  }
5887
5990
 
5888
- //#endregion
5889
- //#region src/constant.ts
5890
- const CONFIG_FILE_NAME = "ui.json";
5891
- const REGISTRY_FILE_NAME = "registry.json";
5892
- const THEME_PATH = "./theme";
5893
- const DEFAULT_PACKAGE_NAME = "@workspaces/ui";
5894
- const REGISTRY_URL = "https://v2.yamada-ui.com/registry/v2";
5895
- const DEFAULT_PATH = {
5896
- components: "./components",
5897
- hooks: "./hooks",
5898
- monorepo: "./workspaces/ui",
5899
- polyrepo: "./components/ui",
5900
- providers: "./providers"
5901
- };
5902
- const SECTION_NAMES = [
5903
- "components",
5904
- "hooks",
5905
- "providers"
5906
- ];
5907
- const DEFAULT_CONFIG = {
5908
- $schema: `${REGISTRY_URL}/config.schema.json`,
5909
- components: { overwrite: true },
5910
- hooks: { overwrite: true },
5911
- providers: { overwrite: true }
5912
- };
5913
- const REQUIRED_DEPENDENCIES = ["react@^19", "react-dom@^19"];
5914
- const REQUIRED_DEV_DEPENDENCIES = ["@types/react@^19", "@types/react-dom@^19"];
5915
- const DEFAULT_PACKAGE_JSON = {
5916
- version: "1.0.0",
5917
- type: "module",
5918
- private: true,
5919
- scripts: {},
5920
- dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.map((dependency) => splitVersion(dependency))),
5921
- devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.map((dependency) => splitVersion(dependency)))
5922
- };
5923
- const DEFAULT_PACKAGE_JSON_EXPORTS = {
5924
- TSX: {
5925
- ".": "./src/index.ts",
5926
- "./components/*": "./src/components/*/index.ts",
5927
- "./hooks/*": "./src/hooks/*/index.ts",
5928
- "./providers/*": "./src/providers/*/index.ts"
5929
- },
5930
- JSX: {
5931
- ".": "./src/index.js",
5932
- "./components/*": "./src/components/*/index.js",
5933
- "./hooks/*": "./src/hooks/*/index.js",
5934
- "./providers/*": "./src/providers/*/index.js"
5935
- }
5936
- };
5937
- const TSCONFIG_JSON = {
5938
- compilerOptions: {
5939
- target: "ESNext",
5940
- module: "ESNext",
5941
- lib: [
5942
- "DOM",
5943
- "DOM.Iterable",
5944
- "ESNext"
5945
- ],
5946
- moduleResolution: "Bundler",
5947
- moduleDetection: "force",
5948
- jsx: "preserve",
5949
- strict: true,
5950
- declaration: true,
5951
- declarationMap: true,
5952
- esModuleInterop: true,
5953
- isolatedModules: true,
5954
- resolveJsonModule: true,
5955
- incremental: false,
5956
- noEmit: true,
5957
- skipLibCheck: true,
5958
- allowJs: true,
5959
- allowSyntheticDefaultImports: true,
5960
- noUncheckedSideEffectImports: true,
5961
- noFallthroughCasesInSwitch: true,
5962
- noUncheckedIndexedAccess: true
5963
- },
5964
- include: ["src/**/*.ts", "src/**/*.tsx"],
5965
- exclude: ["node_modules"]
5966
- };
5967
-
5968
5991
  //#endregion
5969
5992
  //#region src/commands/add/index.ts
5970
5993
  const add = new Command("add").description("add a component to your project").argument("[components...]", "components to add").option("--cwd <path>", "current working directory", cwd).option("-c, --config <path>", "path to the config file", CONFIG_FILE_NAME).option("-o, --overwrite", "overwrite existing files.", false).option("-i, --install", "install dependencies", false).option("-s, --sequential", "run tasks sequentially.", false).option("-f, --format", "format the output files.").option("-l, --lint", "lint the output files.").action(async function(componentNames, { config: configPath, cwd: cwd$3, format: format$2, install, lint, overwrite, sequential }) {
@@ -5990,7 +6013,7 @@ const add = new Command("add").description("add a component to your project").ar
5990
6013
  message: c.reset(`Add all available components?`)
5991
6014
  });
5992
6015
  if (!proceed) process.exit(0);
5993
- if (!overwrite && existsSync(config$1.srcPath)) {
6016
+ if (!overwrite && existsSync(config$1.paths.ui.src)) {
5994
6017
  const { overwrite: overwrite$1 } = await prompts({
5995
6018
  type: "confirm",
5996
6019
  name: "overwrite",
@@ -6102,11 +6125,11 @@ const add = new Command("add").description("add a component to your project").ar
6102
6125
  });
6103
6126
  }
6104
6127
  const indexFileName = transformExtension("index.ts", config$1.jsx);
6105
- if (existsSync(config$1.indexPath)) tasks.add({
6128
+ if (existsSync(config$1.paths.ui.index)) tasks.add({
6106
6129
  task: async (_, task) => {
6107
- let content = await readFile(config$1.indexPath, "utf-8");
6130
+ let content = await readFile(config$1.paths.ui.index, "utf-8");
6108
6131
  content = transformIndex(targetNames, content, config$1);
6109
- await writeFileSafe(config$1.indexPath, content, config$1);
6132
+ await writeFileSafe(config$1.paths.ui.index, content, config$1);
6110
6133
  task.title = `Updated ${c.cyan(indexFileName)}`;
6111
6134
  },
6112
6135
  title: `Updating ${c.cyan(indexFileName)}`
@@ -6116,13 +6139,13 @@ const add = new Command("add").description("add a component to your project").ar
6116
6139
  const { sources: [source] } = await fetchRegistry("index");
6117
6140
  let content = transformIndex(targetNames, source.content, config$1);
6118
6141
  if (config$1.jsx) content = transformTsToJs(content);
6119
- await writeFileSafe(config$1.indexPath, content, config$1);
6142
+ await writeFileSafe(config$1.paths.ui.index, content, config$1);
6120
6143
  task.title = `Generated ${c.cyan(indexFileName)}`;
6121
6144
  },
6122
6145
  title: `Generating ${c.cyan(indexFileName)}`
6123
6146
  });
6124
6147
  if (dependencies$1.length) {
6125
- const targetPath = config$1.monorepo ? config$1.rootPath : cwd$3;
6148
+ const targetPath = config$1.monorepo ? config$1.paths.ui.root : cwd$3;
6126
6149
  spinner.start(`Checking ${c.cyan("package.json")} dependencies`);
6127
6150
  const packageJson$2 = await getPackageJson(targetPath);
6128
6151
  const notInstalledDependencies = getNotInstalledDependencies(packageJson$2, dependencies$1);
@@ -6157,7 +6180,7 @@ const add = new Command("add").description("add a component to your project").ar
6157
6180
  //#region src/commands/update/print-conflicts.ts
6158
6181
  function printConflicts(conflictMap, config$1) {
6159
6182
  Object.entries(conflictMap).forEach(([name$1, files$1]) => {
6160
- if (name$1 === "index") console.log(`- ${c.yellow(transformExtension("index.ts", config$1.jsx))}: ${config$1.indexPath.replace(`${config$1.cwd}/`, "")}`);
6183
+ if (name$1 === "index") console.log(`- ${c.yellow(transformExtension("index.ts", config$1.jsx))}: ${config$1.paths.ui.index.replace(`${config$1.cwd}/`, "")}`);
6161
6184
  else {
6162
6185
  console.log(`- ${name$1}`);
6163
6186
  Object.entries(files$1).forEach(([fileName, path$9]) => {
@@ -6170,7 +6193,7 @@ function printConflicts(conflictMap, config$1) {
6170
6193
  //#endregion
6171
6194
  //#region src/commands/diff/get-diff.ts
6172
6195
  function getDirPath(section, name$1, config$1) {
6173
- return config$1.isSection(section) ? path$1.join(config$1.getSectionResolvedPath(section), name$1) : section === "theme" ? config$1.theme.path : config$1.srcPath;
6196
+ return config$1.isSection(section) ? path$1.join(config$1.getSectionResolvedPath(section), name$1) : config$1.paths[section === "theme" ? "theme" : "ui"].src;
6174
6197
  }
6175
6198
  async function getDiff(generatedNames, { locale, remote }, config$1, concurrent = true) {
6176
6199
  const changeMap = {};
@@ -6363,17 +6386,17 @@ async function updateFiles(changeMap, { add: add$1, remove, update: update$1 },
6363
6386
  const dirPath = getDirPath(registry.section, componentName, config$1);
6364
6387
  try {
6365
6388
  if (componentName === "index") {
6366
- const name$1 = config$1.indexPath.split("/").at(-1);
6389
+ const name$1 = config$1.paths.ui.index.split("/").at(-1);
6367
6390
  const data = changes[name$1];
6368
6391
  if (!("locale" in data && "remote" in data)) return;
6369
6392
  const remotePath = path$1.join(tempDirPath, `remote-${name$1}`);
6370
6393
  const localePath = path$1.join(tempDirPath, `locale-${name$1}`);
6371
6394
  await Promise.all([writeFileSafe(remotePath, data.remote, disabledFormatAndLint), writeFileSafe(localePath, data.locale, disabledFormatAndLint)]);
6372
- const { conflict, content: mergedContent } = await mergeContent(remotePath, localePath, config$1.indexPath, data.remote);
6373
- await writeFileSafe(config$1.indexPath, mergedContent, conflict ? merge(config$1, disabledFormatAndLint) : config$1);
6395
+ const { conflict, content: mergedContent } = await mergeContent(remotePath, localePath, config$1.paths.ui.index, data.remote);
6396
+ await writeFileSafe(config$1.paths.ui.index, mergedContent, conflict ? merge(config$1, disabledFormatAndLint) : config$1);
6374
6397
  if (conflict) {
6375
6398
  conflictMap[componentName] ??= {};
6376
- conflictMap[componentName][name$1] = config$1.indexPath;
6399
+ conflictMap[componentName][name$1] = config$1.paths.ui.index;
6377
6400
  }
6378
6401
  } else await Promise.all(Object.entries(changes).map(async ([name$1, { ...data }]) => {
6379
6402
  const currentPath = path$1.join(dirPath, name$1);
@@ -6407,7 +6430,7 @@ async function updateFiles(changeMap, { add: add$1, remove, update: update$1 },
6407
6430
  });
6408
6431
  if (!install$1) return conflictMap;
6409
6432
  }
6410
- const cwd$3 = config$1.monorepo ? config$1.rootPath : config$1.cwd;
6433
+ const cwd$3 = config$1.monorepo ? config$1.paths.ui.root : config$1.cwd;
6411
6434
  remove.push(...update$1.map(({ name: name$1 }) => name$1));
6412
6435
  add$1.push(...update$1.map(getPackageNameWithVersion));
6413
6436
  if (remove.length) await uninstallDependencies(remove.map(getPackageName), { cwd: cwd$3 });
@@ -6437,8 +6460,8 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
6437
6460
  const tasks = new Listr([], { concurrent });
6438
6461
  if (index) tasks.add([{
6439
6462
  task: async (_, task) => {
6440
- fileMap.index = { [transformExtension("index.ts", config$1.jsx)]: await readFile(config$1.indexPath, "utf-8") };
6441
- registryMap.locale.index = await fetchLocaleRegistry(config$1.registryPath);
6463
+ fileMap.index = { [transformExtension("index.ts", config$1.jsx)]: await readFile(config$1.paths.ui.index, "utf-8") };
6464
+ registryMap.locale.index = await fetchLocaleRegistry(config$1.paths.ui.registry);
6442
6465
  task.title = `Got ${c.cyan("index")} file`;
6443
6466
  },
6444
6467
  title: `Getting ${c.cyan("index")} file`
@@ -6452,7 +6475,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
6452
6475
  if (theme$1) tasks.add([{
6453
6476
  task: async (_, task) => {
6454
6477
  if (!config$1.theme?.path) return;
6455
- const { dirPath, files: files$1 } = await getFiles(config$1.theme.path);
6478
+ const { dirPath, files: files$1 } = await getFiles(config$1.paths.theme.src);
6456
6479
  fileMap.theme = files$1;
6457
6480
  registryMap.locale.theme = await fetchLocaleRegistry(path$1.posix.join(dirPath, REGISTRY_FILE_NAME));
6458
6481
  task.title = `Got ${c.cyan("theme")} files`;
@@ -6467,7 +6490,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
6467
6490
  }]);
6468
6491
  tasks.add(componentNames.map((componentName) => [{
6469
6492
  task: async (_, task) => {
6470
- const { dirPath, files: files$1 } = await getFiles(path$1.posix.join(config$1.srcPath, "**", componentName));
6493
+ const { dirPath, files: files$1 } = await getFiles(path$1.posix.join(config$1.paths.ui.src, "**", componentName));
6471
6494
  fileMap[componentName] = files$1;
6472
6495
  registryMap.locale[componentName] = await fetchLocaleRegistry(path$1.posix.join(dirPath, REGISTRY_FILE_NAME));
6473
6496
  task.title = `Got ${c.cyan(componentName)} files`;
@@ -6556,7 +6579,7 @@ const diff = new Command("diff").description("check for updates against the regi
6556
6579
  const componentNames = [];
6557
6580
  const generatedNameMap = await getGeneratedNameMap(config$1);
6558
6581
  const generatedNames = Object.values(generatedNameMap).flat();
6559
- const existsTheme = !!config$1.theme?.path && existsSync(config$1.theme.path);
6582
+ const existsTheme = !!config$1.theme?.path && existsSync(config$1.paths.theme.src);
6560
6583
  let index = targetName === "index";
6561
6584
  let theme$1 = targetName === "theme";
6562
6585
  spinner.succeed("Got generated components");
@@ -6655,13 +6678,13 @@ const init = new Command("init").description("initialize your project and instal
6655
6678
  {
6656
6679
  type: "text",
6657
6680
  name: "outdir",
6658
- initial: (_, { monorepo: monorepo$1 }) => monorepo$1 ? DEFAULT_PATH.monorepo : DEFAULT_PATH.polyrepo,
6681
+ initial: (_, { monorepo: monorepo$1 }) => monorepo$1 ? DEFAULT_PATH.ui.monorepo : DEFAULT_PATH.ui.polyrepo,
6659
6682
  message: (_, { monorepo: monorepo$1 }) => monorepo$1 ? c.reset(`What is the path to the monorepo?`) : c.reset(`What is the path to the directory?`)
6660
6683
  },
6661
6684
  {
6662
6685
  type: (_, { monorepo: monorepo$1 }) => monorepo$1 ? "text" : null,
6663
6686
  name: "packageName",
6664
- initial: DEFAULT_PACKAGE_NAME,
6687
+ initial: DEFAULT_PACKAGE_NAME.ui,
6665
6688
  message: c.reset("What is the package name?")
6666
6689
  },
6667
6690
  {
@@ -6690,7 +6713,7 @@ const init = new Command("init").description("initialize your project and instal
6690
6713
  }
6691
6714
  ]);
6692
6715
  outdir = outdir.replace(/\x17/g, "").trim();
6693
- outdir ||= monorepo ? DEFAULT_PATH.monorepo : DEFAULT_PATH.polyrepo;
6716
+ outdir ||= monorepo ? DEFAULT_PATH.ui.monorepo : DEFAULT_PATH.ui.polyrepo;
6694
6717
  packageName = packageName.replace(/\x17/g, "").trim();
6695
6718
  packageName ||= DEFAULT_PACKAGE_NAME;
6696
6719
  if (monorepo) config$1.monorepo = monorepo;
@@ -6742,10 +6765,14 @@ const init = new Command("init").description("initialize your project and instal
6742
6765
  {
6743
6766
  task: async (_, task) => {
6744
6767
  const targetPath = path$1.resolve(outdirPath, "package.json");
6768
+ const defaultExports = DEFAULT_PACKAGE_JSON_EXPORTS.ui[jsx ? "jsx" : "tsx"];
6769
+ const exports$2 = src ? defaultExports : Object.fromEntries(Object.entries(defaultExports).map(([key, value]) => [key, value.replace(/src\//, "")]));
6745
6770
  const content = JSON.stringify({
6746
6771
  name: packageName,
6747
6772
  ...DEFAULT_PACKAGE_JSON,
6748
- exports: DEFAULT_PACKAGE_JSON_EXPORTS[jsx ? "JSX" : "TSX"]
6773
+ dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.ui.map((dependency) => splitVersion(dependency))),
6774
+ devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.ui.map((dependency) => splitVersion(dependency))),
6775
+ exports: exports$2
6749
6776
  });
6750
6777
  await writeFileSafe(targetPath, content, merge(config$1, { format: { parser: "json" } }));
6751
6778
  task.title = `Generated ${c.cyan("package.json")}`;
@@ -6777,7 +6804,9 @@ const init = new Command("init").description("initialize your project and instal
6777
6804
  if (!jsx) tasks.add({
6778
6805
  task: async (_, task) => {
6779
6806
  const targetPath = path$1.resolve(outdirPath, "tsconfig.json");
6780
- const content = JSON.stringify({ ...TSCONFIG_JSON });
6807
+ const tsconfig = { ...TSCONFIG_JSON };
6808
+ if (!src) tsconfig.include = tsconfig.include.map((value) => value.replace(/src\//, ""));
6809
+ const content = JSON.stringify(tsconfig);
6781
6810
  await writeFileSafe(targetPath, content, merge(config$1, { format: { parser: "json" } }));
6782
6811
  task.title = `Generated ${c.cyan("tsconfig.json")}`;
6783
6812
  },
@@ -6797,8 +6826,8 @@ const init = new Command("init").description("initialize your project and instal
6797
6826
  await new Listr([{
6798
6827
  task: async (_, task) => {
6799
6828
  const packageJson$2 = await getPackageJson(cwd$3);
6800
- notInstalledDependencies.push(...getNotInstalledDependencies(packageJson$2, [...REQUIRED_DEPENDENCIES, "@yamada-ui/react@dev"]));
6801
- notInstalledDevDependencies.push(...getNotInstalledDependencies(packageJson$2, REQUIRED_DEV_DEPENDENCIES));
6829
+ notInstalledDependencies.push(...getNotInstalledDependencies(packageJson$2, [...REQUIRED_DEPENDENCIES.ui, "@yamada-ui/react@dev"]));
6830
+ notInstalledDevDependencies.push(...getNotInstalledDependencies(packageJson$2, REQUIRED_DEV_DEPENDENCIES.ui));
6802
6831
  task.title = `Checked ${c.cyan("package.json")} dependencies`;
6803
6832
  },
6804
6833
  title: `Checking ${c.cyan("package.json")} dependencies`
@@ -6873,9 +6902,45 @@ const theme = new Command("theme").description("generate theme to your project")
6873
6902
  jsx: js,
6874
6903
  lint
6875
6904
  });
6876
- const resolvedPath = themePath ? path$1.resolve(cwd$3, themePath) : config$1.theme?.path ?? path$1.resolve(cwd$3, THEME_PATH);
6877
6905
  spinner.succeed("Fetched config");
6878
- if (!overwrite && existsSync(resolvedPath)) {
6906
+ themePath ??= config$1.theme?.path;
6907
+ const defaultThemePath = config$1.monorepo ? DEFAULT_PATH.theme.monorepo : DEFAULT_PATH.theme.polyrepo;
6908
+ if (!themePath) {
6909
+ let { outdir = "" } = await prompts({
6910
+ type: "text",
6911
+ name: "outdir",
6912
+ initial: defaultThemePath,
6913
+ message: "What is the path to the theme directory?"
6914
+ });
6915
+ outdir = outdir.replace(/\x17/g, "").trim();
6916
+ outdir ||= defaultThemePath;
6917
+ themePath = outdir;
6918
+ }
6919
+ const monorepoConfig = {
6920
+ src: false,
6921
+ packageName: ""
6922
+ };
6923
+ if (config$1.monorepo) {
6924
+ let { src = true, packageName = "" } = await prompts([{
6925
+ type: "text",
6926
+ name: "packageName",
6927
+ initial: DEFAULT_PACKAGE_NAME.theme,
6928
+ message: c.reset("What is the package name?")
6929
+ }, {
6930
+ type: "toggle",
6931
+ name: "src",
6932
+ active: "Yes",
6933
+ inactive: "No",
6934
+ initial: true,
6935
+ message: c.reset("Would you like your code inside a `src/` directory?")
6936
+ }]);
6937
+ packageName = packageName.replace(/\x17/g, "").trim();
6938
+ packageName ||= DEFAULT_PACKAGE_NAME.theme;
6939
+ monorepoConfig.src = src;
6940
+ monorepoConfig.packageName = packageName;
6941
+ }
6942
+ const outdirPath = path$1.resolve(cwd$3, themePath);
6943
+ if (!overwrite && existsSync(outdirPath)) {
6879
6944
  const { overwrite: overwrite$1 } = await prompts({
6880
6945
  type: "confirm",
6881
6946
  name: "overwrite",
@@ -6884,21 +6949,21 @@ const theme = new Command("theme").description("generate theme to your project")
6884
6949
  });
6885
6950
  if (!overwrite$1) process.exit(0);
6886
6951
  spinner.start("Clearing directory");
6887
- await rimraf(resolvedPath);
6952
+ await rimraf(outdirPath);
6888
6953
  spinner.succeed("Cleared directory");
6889
6954
  }
6890
6955
  spinner.start("Fetching registry");
6891
6956
  const registry = await fetchRegistry("theme");
6892
6957
  spinner.succeed("Fetched registry");
6893
- await new Listr([{
6958
+ const tasks = new Listr([{
6894
6959
  task: async (_, task) => {
6960
+ const targetPath = path$1.resolve(outdirPath, monorepoConfig.src ? "src" : "");
6895
6961
  await Promise.all([...registry.sources.map(async ({ name: name$1, content }) => {
6896
6962
  if (!content) return;
6897
6963
  name$1 = transformExtension(name$1, config$1.jsx);
6898
- const targetPath = path$1.resolve(resolvedPath, name$1);
6899
6964
  if (config$1.jsx) content = isTsx(name$1) ? transformTsxToJsx(content) : transformTsToJs(content);
6900
- await writeFileSafe(targetPath, content, config$1);
6901
- }), writeFileSafe(path$1.resolve(resolvedPath, REGISTRY_FILE_NAME), JSON.stringify(registry), merge(config$1, { format: { parser: "json" } }))]);
6965
+ await writeFileSafe(path$1.resolve(targetPath, name$1), content, config$1);
6966
+ }), writeFileSafe(path$1.resolve(targetPath, REGISTRY_FILE_NAME), JSON.stringify(registry), merge(config$1, { format: { parser: "json" } }))]);
6902
6967
  task.title = `Generated theme`;
6903
6968
  },
6904
6969
  title: `Generating theme`
@@ -6908,12 +6973,68 @@ const theme = new Command("theme").description("generate theme to your project")
6908
6973
  const data = await readFile(targetPath, "utf-8");
6909
6974
  const userConfig = JSON.parse(data);
6910
6975
  userConfig.theme ??= {};
6911
- userConfig.theme.path ??= themePath ?? THEME_PATH;
6976
+ userConfig.theme.path ??= themePath;
6912
6977
  await writeFileSafe(targetPath, JSON.stringify(userConfig), merge(config$1, { format: { parser: "json" } }));
6913
6978
  task.title = `Updated config`;
6914
6979
  },
6915
6980
  title: `Updating config`
6916
- }], { concurrent: true }).run();
6981
+ }], { concurrent: true });
6982
+ if (config$1.monorepo) tasks.add({
6983
+ task: async (_, task) => {
6984
+ const targetPath = path$1.resolve(outdirPath, "package.json");
6985
+ const defaultExports = DEFAULT_PACKAGE_JSON_EXPORTS.theme[config$1.jsx ? "jsx" : "tsx"];
6986
+ const exports$2 = monorepoConfig.src ? defaultExports : Object.fromEntries(Object.entries(defaultExports).map(([key, value]) => [key, value.replace(/src\//, "")]));
6987
+ const content = JSON.stringify({
6988
+ name: monorepoConfig.packageName,
6989
+ ...DEFAULT_PACKAGE_JSON,
6990
+ dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.theme.map((dependency) => splitVersion(dependency))),
6991
+ devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.theme.map((dependency) => splitVersion(dependency))),
6992
+ exports: exports$2
6993
+ });
6994
+ await writeFileSafe(targetPath, content, merge(config$1, { format: { parser: "json" } }));
6995
+ task.title = `Generated ${c.cyan("package.json")}`;
6996
+ },
6997
+ title: `Generating ${c.cyan("package.json")}`
6998
+ });
6999
+ if (!config$1.jsx) tasks.add({
7000
+ task: async (_, task) => {
7001
+ const targetPath = path$1.resolve(outdirPath, "tsconfig.json");
7002
+ const tsconfig = { ...TSCONFIG_JSON };
7003
+ if (!monorepoConfig.src) tsconfig.include = tsconfig.include.map((value) => value.replace(/src\//, ""));
7004
+ const content = JSON.stringify(tsconfig);
7005
+ await writeFileSafe(targetPath, content, merge(config$1, { format: { parser: "json" } }));
7006
+ task.title = `Generated ${c.cyan("tsconfig.json")}`;
7007
+ },
7008
+ title: `Generating ${c.cyan("tsconfig.json")}`
7009
+ });
7010
+ await tasks.run();
7011
+ if (config$1.monorepo) {
7012
+ const { install } = await prompts({
7013
+ type: "confirm",
7014
+ name: "install",
7015
+ initial: true,
7016
+ message: c.reset(`The theme is generated. Do you want to install dependencies?`)
7017
+ });
7018
+ if (install) {
7019
+ spinner.start("Installing dependencies");
7020
+ await installDependencies([], { cwd: cwd$3 });
7021
+ await installDependencies(["@yamada-ui/react@dev"], { cwd: outdirPath });
7022
+ spinner.succeed("Installed dependencies");
7023
+ }
7024
+ const packageManager = getPackageManager();
7025
+ const args = packageAddArgs(packageManager);
7026
+ console.log("");
7027
+ console.log(boxen([
7028
+ "Run",
7029
+ c.cyan(`${packageManager} ${args.join(" ")} "${monorepoConfig.packageName}@workspace:*"`),
7030
+ "in your application."
7031
+ ].join(" "), {
7032
+ borderColor: "yellow",
7033
+ borderStyle: "round",
7034
+ padding: 1,
7035
+ textAlignment: "center"
7036
+ }));
7037
+ }
6917
7038
  end();
6918
7039
  } catch (e) {
6919
7040
  if (e instanceof Error) spinner.fail(e.message);
@@ -7124,7 +7245,7 @@ const tokens = new Command("tokens").description("generate theme typings").argum
7124
7245
  format: format$2,
7125
7246
  lint
7126
7247
  });
7127
- if (config$1.theme?.path) inputPath ??= path$1.resolve(cwd$3, config$1.theme.path, "index.ts");
7248
+ if (config$1.theme?.path) inputPath ??= config$1.paths.theme.index;
7128
7249
  spinner.succeed("Fetched config");
7129
7250
  }
7130
7251
  if (!inputPath) throw new Error("No input path provided");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yamada-ui/cli",
3
3
  "type": "module",
4
- "version": "2.0.0-dev-20251007020753",
4
+ "version": "2.0.0-dev-20251007054727",
5
5
  "description": "The official CLI for Yamada UI projects",
6
6
  "keywords": [
7
7
  "theme",