@yamada-ui/cli 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,12 +51,13 @@ var isArray = (value) => Array.isArray(value);
51
51
  // src/utils/prettier.ts
52
52
  init_cjs_shims();
53
53
  var import_prettier = require("prettier");
54
- var prettier = async (content) => {
54
+ var prettier = async (content, options) => {
55
55
  const prettierConfig = await (0, import_prettier.resolveConfig)(process.cwd());
56
56
  try {
57
57
  return (0, import_prettier.format)(content, {
58
58
  ...prettierConfig,
59
- parser: "typescript"
59
+ parser: "typescript",
60
+ ...options
60
61
  });
61
62
  } catch {
62
63
  return content;
@@ -5346,13 +5346,15 @@ var require_bl = __commonJS({
5346
5346
  // src/command/tokens/index.ts
5347
5347
  var tokens_exports = {};
5348
5348
  __export(tokens_exports, {
5349
- generateThemeTypings: () => generateThemeTypings,
5349
+ actionTokens: () => actionTokens,
5350
5350
  themePath: () => themePath
5351
5351
  });
5352
5352
  module.exports = __toCommonJS(tokens_exports);
5353
5353
  init_cjs_shims();
5354
- var import_fs2 = require("fs");
5355
- var import_util2 = require("util");
5354
+ var import_promises = require("fs/promises");
5355
+ var import_path2 = __toESM(require("path"));
5356
+ var import_bundle_n_require = require("bundle-n-require");
5357
+ var import_chokidar = __toESM(require("chokidar"));
5356
5358
 
5357
5359
  // ../../node_modules/.pnpm/ora@7.0.1/node_modules/ora/index.js
5358
5360
  init_cjs_shims();
@@ -6379,50 +6381,6 @@ function ora(options) {
6379
6381
  return new Ora(options);
6380
6382
  }
6381
6383
 
6382
- // src/command/tokens/resolve-output-path.ts
6383
- init_cjs_shims();
6384
- var import_fs = __toESM(require("fs"));
6385
- var import_path = __toESM(require("path"));
6386
- var import_util = require("util");
6387
- var exists = (0, import_util.promisify)(import_fs.default.exists);
6388
- var themePath = [
6389
- "node_modules",
6390
- "@yamada-ui",
6391
- "core",
6392
- "dist",
6393
- "generated-theme.types.d.ts"
6394
- ];
6395
- var resolveThemePath = async () => {
6396
- const basePath = import_path.default.join("..", "..", "..");
6397
- const rootPath = process.cwd();
6398
- const paths = [
6399
- import_path.default.resolve(basePath, "..", ...themePath),
6400
- import_path.default.resolve(basePath, "..", "..", ...themePath),
6401
- import_path.default.resolve(rootPath, ...themePath),
6402
- import_path.default.resolve(rootPath, "..", ...themePath),
6403
- import_path.default.resolve(rootPath, "..", "..", ...themePath)
6404
- ];
6405
- const triedPaths = await Promise.all(
6406
- paths.map(async (possiblePath) => {
6407
- const isExist = await exists(possiblePath);
6408
- if (isExist)
6409
- return possiblePath;
6410
- return "";
6411
- })
6412
- );
6413
- return triedPaths.find(Boolean);
6414
- };
6415
- var resolveOutputPath = async (outPath) => {
6416
- if (outPath)
6417
- return import_path.default.resolve(process.cwd(), outPath);
6418
- const themePath2 = await resolveThemePath();
6419
- if (!themePath2)
6420
- throw new Error(
6421
- "Could not find @yamada-ui/core in node_modules. Please provide `--out` parameter."
6422
- );
6423
- return themePath2;
6424
- };
6425
-
6426
6384
  // src/command/tokens/create-theme-typings.ts
6427
6385
  init_cjs_shims();
6428
6386
 
@@ -6434,12 +6392,13 @@ var isArray = (value) => Array.isArray(value);
6434
6392
  // src/utils/prettier.ts
6435
6393
  init_cjs_shims();
6436
6394
  var import_prettier = require("prettier");
6437
- var prettier = async (content) => {
6395
+ var prettier = async (content, options) => {
6438
6396
  const prettierConfig = await (0, import_prettier.resolveConfig)(process.cwd());
6439
6397
  try {
6440
6398
  return (0, import_prettier.format)(content, {
6441
6399
  ...prettierConfig,
6442
- parser: "typescript"
6400
+ parser: "typescript",
6401
+ ...options
6443
6402
  });
6444
6403
  } catch {
6445
6404
  return content;
@@ -6625,8 +6584,47 @@ export interface GeneratedTheme extends UITheme { ${print(
6625
6584
  );
6626
6585
  };
6627
6586
 
6587
+ // src/command/tokens/resolve-output-path.ts
6588
+ init_cjs_shims();
6589
+ var import_path = __toESM(require("path"));
6590
+ var import_glob = require("glob");
6591
+ var themePath = [
6592
+ "node_modules",
6593
+ "@yamada-ui",
6594
+ "core",
6595
+ "dist",
6596
+ "generated-theme.types.d.ts"
6597
+ ];
6598
+ var resolveThemePath = async () => {
6599
+ const paths = [
6600
+ import_path.default.join("node_modules", ".pnpm", "@yamada-ui+core@*", ...themePath),
6601
+ import_path.default.join(...themePath)
6602
+ ];
6603
+ const triedPaths = await Promise.all(
6604
+ paths.map(async (possiblePath) => {
6605
+ const paths2 = await (0, import_glob.glob)(possiblePath);
6606
+ if (paths2.length)
6607
+ return paths2[0];
6608
+ return "";
6609
+ })
6610
+ );
6611
+ const resolvedPath = triedPaths.find(Boolean);
6612
+ if (!resolvedPath)
6613
+ return;
6614
+ return import_path.default.resolve(process.cwd(), resolvedPath);
6615
+ };
6616
+ var resolveOutputPath = async (outPath) => {
6617
+ if (outPath)
6618
+ return import_path.default.resolve(process.cwd(), outPath);
6619
+ const themePath2 = await resolveThemePath();
6620
+ if (!themePath2)
6621
+ throw new Error(
6622
+ "Could not find @yamada-ui/core in node_modules. Please provide `--out` parameter."
6623
+ );
6624
+ return themePath2;
6625
+ };
6626
+
6628
6627
  // src/command/tokens/index.ts
6629
- var writeFileAsync = (0, import_util2.promisify)(import_fs2.writeFile);
6630
6628
  var generateThemeTypings = async ({
6631
6629
  theme,
6632
6630
  outFile
@@ -6638,21 +6636,45 @@ var generateThemeTypings = async ({
6638
6636
  const outPath = await resolveOutputPath(outFile);
6639
6637
  spinner.info();
6640
6638
  spinner.text = `Write file "${outPath}"...`;
6641
- await writeFileAsync(outPath, generatedTheme, "utf8");
6639
+ await (0, import_promises.writeFile)(outPath, generatedTheme, "utf8");
6642
6640
  const end = process.hrtime.bigint();
6643
6641
  const duration = (Number(end - start) / 1e9).toFixed(2);
6644
- spinner.succeed(`Done in ${duration}s`);
6642
+ spinner.succeed(`Done in ${duration}s
6643
+ `);
6645
6644
  } catch (e) {
6646
- spinner.fail("An error occurred");
6645
+ spinner.fail("An error occurred\n");
6647
6646
  if (e instanceof Error)
6648
6647
  console.error(e.message);
6649
6648
  } finally {
6650
6649
  spinner.stop();
6651
6650
  }
6652
6651
  };
6652
+ var actionTokens = async (themeFile, { out: outFile, watch: watchFile }) => {
6653
+ const readFile = async () => {
6654
+ const filePath = import_path2.default.resolve(themeFile);
6655
+ const { mod: theme, dependencies } = await (0, import_bundle_n_require.bundleNRequire)(filePath);
6656
+ return { theme, dependencies };
6657
+ };
6658
+ let file = await readFile();
6659
+ const buildFile = async () => {
6660
+ await generateThemeTypings({ theme: file.theme, outFile });
6661
+ if (watchFile)
6662
+ console.log("\n", "\u231B\uFE0F Watching for changes...");
6663
+ };
6664
+ if (watchFile) {
6665
+ const watchPath = typeof watchFile === "string" ? watchFile : file.dependencies;
6666
+ import_chokidar.default.watch(watchPath).on("ready", buildFile).on("change", async (filePath) => {
6667
+ console.log("\u{1F4E6} File changed", filePath);
6668
+ file = await readFile();
6669
+ return buildFile();
6670
+ });
6671
+ } else {
6672
+ await buildFile();
6673
+ }
6674
+ };
6653
6675
  // Annotate the CommonJS export names for ESM import in node:
6654
6676
  0 && (module.exports = {
6655
- generateThemeTypings,
6677
+ actionTokens,
6656
6678
  themePath
6657
6679
  });
6658
6680
  /*! Bundled license information:
@@ -34,10 +34,8 @@ __export(resolve_output_path_exports, {
34
34
  themePath: () => themePath
35
35
  });
36
36
  module.exports = __toCommonJS(resolve_output_path_exports);
37
- var import_fs = __toESM(require("fs"));
38
37
  var import_path = __toESM(require("path"));
39
- var import_util = require("util");
40
- var exists = (0, import_util.promisify)(import_fs.default.exists);
38
+ var import_glob = require("glob");
41
39
  var themePath = [
42
40
  "node_modules",
43
41
  "@yamada-ui",
@@ -46,24 +44,22 @@ var themePath = [
46
44
  "generated-theme.types.d.ts"
47
45
  ];
48
46
  var resolveThemePath = async () => {
49
- const basePath = import_path.default.join("..", "..", "..");
50
- const rootPath = process.cwd();
51
47
  const paths = [
52
- import_path.default.resolve(basePath, "..", ...themePath),
53
- import_path.default.resolve(basePath, "..", "..", ...themePath),
54
- import_path.default.resolve(rootPath, ...themePath),
55
- import_path.default.resolve(rootPath, "..", ...themePath),
56
- import_path.default.resolve(rootPath, "..", "..", ...themePath)
48
+ import_path.default.join("node_modules", ".pnpm", "@yamada-ui+core@*", ...themePath),
49
+ import_path.default.join(...themePath)
57
50
  ];
58
51
  const triedPaths = await Promise.all(
59
52
  paths.map(async (possiblePath) => {
60
- const isExist = await exists(possiblePath);
61
- if (isExist)
62
- return possiblePath;
53
+ const paths2 = await (0, import_glob.glob)(possiblePath);
54
+ if (paths2.length)
55
+ return paths2[0];
63
56
  return "";
64
57
  })
65
58
  );
66
- return triedPaths.find(Boolean);
59
+ const resolvedPath = triedPaths.find(Boolean);
60
+ if (!resolvedPath)
61
+ return;
62
+ return import_path.default.resolve(process.cwd(), resolvedPath);
67
63
  };
68
64
  var resolveOutputPath = async (outPath) => {
69
65
  if (outPath)