@yamada-ui/cli 1.1.2-dev-20240920162115 → 1.2.0-dev-20240920165318

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
@@ -3282,7 +3282,7 @@ var require_util = __commonJS({
3282
3282
  const typeList = [].concat(types[key]);
3283
3283
  const isPath = typeList.indexOf(path14) !== -1;
3284
3284
  const isBool = typeList.indexOf(Boolean) !== -1;
3285
- const isString3 = typeList.indexOf(String) !== -1;
3285
+ const isString2 = typeList.indexOf(String) !== -1;
3286
3286
  const isNumber = typeList.indexOf(Number) !== -1;
3287
3287
  field = `${field}`.trim();
3288
3288
  if (/^".*"$/.test(field)) {
@@ -3292,7 +3292,7 @@ var require_util = __commonJS({
3292
3292
  throw new Error(`Failed parsing JSON config key ${key}: ${field}`);
3293
3293
  }
3294
3294
  }
3295
- if (isBool && !isString3 && field === "") {
3295
+ if (isBool && !isString2 && field === "") {
3296
3296
  return true;
3297
3297
  }
3298
3298
  switch (field) {
@@ -4318,8 +4318,8 @@ var require_coerce = __commonJS({
4318
4318
  const minor = match[3] || "0";
4319
4319
  const patch = match[4] || "0";
4320
4320
  const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
4321
- const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
4322
- return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
4321
+ const build2 = options.includePrerelease && match[6] ? `+${match[6]}` : "";
4322
+ return parse(`${major}.${minor}.${patch}${prerelease}${build2}`, options);
4323
4323
  };
4324
4324
  module2.exports = coerce;
4325
4325
  }
@@ -6465,20 +6465,21 @@ var package_default = {
6465
6465
  },
6466
6466
  dependencies: {
6467
6467
  "@clack/prompts": "^0.7.0",
6468
- "bundle-n-require": "^1.1.1",
6469
6468
  chokidar: "^3.6.0",
6470
6469
  "cli-check-node": "^1.3.4",
6471
6470
  "cli-handle-unhandled": "^1.1.1",
6472
6471
  commander: "^12.1.0",
6472
+ esbuild: "^0.23.1",
6473
6473
  glob: "^11.0.0",
6474
+ "node-eval": "^2.0.0",
6474
6475
  prettier: "^3.3.3",
6475
6476
  tar: "^7.4.3",
6476
6477
  typescript: "^5.5.4"
6477
6478
  },
6478
6479
  devDependencies: {
6479
- "update-notifier": "^7.2.0",
6480
+ "@types/update-notifier": "6.0.8",
6480
6481
  chalk: "^5.3.0",
6481
- "@types/update-notifier": "6.0.8"
6482
+ "update-notifier": "^7.2.0"
6482
6483
  }
6483
6484
  };
6484
6485
 
@@ -6490,15 +6491,10 @@ init_cjs_shims();
6490
6491
  var import_promises = require("fs/promises");
6491
6492
  var import_path4 = __toESM(require("path"));
6492
6493
  var p = __toESM(require("@clack/prompts"));
6493
- var import_bundle_n_require = require("bundle-n-require");
6494
6494
  var import_chokidar = __toESM(require("chokidar"));
6495
6495
 
6496
- // src/command/tokens/create-theme-typings.ts
6497
- init_cjs_shims();
6498
-
6499
6496
  // src/utils/assertion.ts
6500
6497
  init_cjs_shims();
6501
- var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
6502
6498
  var isObject = (obj) => obj !== null && (typeof obj === "object" || typeof obj === "function") && !isArray(obj);
6503
6499
  var isArray = (value) => Array.isArray(value);
6504
6500
 
@@ -6778,7 +6774,7 @@ init_cjs_shims();
6778
6774
  var isException = (value) => {
6779
6775
  return value instanceof Error && "code" in value;
6780
6776
  };
6781
- var isString2 = (value) => {
6777
+ var isString = (value) => {
6782
6778
  return typeof value === "string";
6783
6779
  };
6784
6780
  var isUndefined = (value) => {
@@ -6915,7 +6911,7 @@ var temp_default = Temp;
6915
6911
 
6916
6912
  // ../../node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/index.js
6917
6913
  function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
6918
- if (isString2(options))
6914
+ if (isString(options))
6919
6915
  return writeFileSync(filePath, data, { encoding: options });
6920
6916
  const timeout2 = Date.now() + ((options.timeout ?? DEFAULT_TIMEOUT_SYNC) || -1);
6921
6917
  let tempDisposer = null;
@@ -6951,7 +6947,7 @@ function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
6951
6947
  if (options.tmpCreated) {
6952
6948
  options.tmpCreated(tempPath);
6953
6949
  }
6954
- if (isString2(data)) {
6950
+ if (isString(data)) {
6955
6951
  dist_default.retry.writeSync(timeout2)(fd, data, 0, options.encoding || DEFAULT_ENCODING);
6956
6952
  } else if (!isUndefined(data)) {
6957
6953
  dist_default.retry.writeSync(timeout2)(fd, data, 0, data.length, 0);
@@ -9090,21 +9086,54 @@ var prettier = async (content, options) => {
9090
9086
 
9091
9087
  // src/utils/object.ts
9092
9088
  init_cjs_shims();
9093
- var omitObject = (obj, keys) => {
9094
- const result = {};
9095
- Object.keys(obj).forEach((key) => {
9096
- if (keys.includes(key)) return;
9097
- result[key] = obj[key];
9089
+ var getObject2 = (obj, path14) => {
9090
+ const keys = path14.split(".");
9091
+ return keys.reduce((obj2, key) => obj2[key] ?? {}, obj);
9092
+ };
9093
+
9094
+ // src/utils/module.ts
9095
+ init_cjs_shims();
9096
+ var import_fs = require("fs");
9097
+ var import_vm = require("vm");
9098
+ var import_esbuild = require("esbuild");
9099
+ var import_node_eval = __toESM(require("node-eval"));
9100
+ var getModule = async (file, cwd) => {
9101
+ const result = await (0, import_esbuild.build)({
9102
+ platform: "node",
9103
+ format: "cjs",
9104
+ mainFields: ["module", "main"],
9105
+ absWorkingDir: cwd,
9106
+ entryPoints: [file],
9107
+ outfile: "out.js",
9108
+ write: false,
9109
+ bundle: true,
9110
+ sourcemap: false,
9111
+ metafile: true
9098
9112
  });
9099
- return result;
9113
+ const { text: code } = result.outputFiles[0];
9114
+ const dependencies = result.metafile ? Object.keys(result.metafile.inputs) : [];
9115
+ try {
9116
+ const realFileName = import_fs.realpathSync.native(file);
9117
+ const script = new import_vm.Script(code, { filename: realFileName });
9118
+ const mod = { exports: {} };
9119
+ const require2 = (id) => id === realFileName ? mod.exports : require2(id);
9120
+ script.runInThisContext()(mod.exports, require2, mod);
9121
+ return { mod, code, dependencies };
9122
+ } catch {
9123
+ const mod = (0, import_node_eval.default)(code);
9124
+ return { mod, code, dependencies };
9125
+ }
9100
9126
  };
9101
9127
 
9128
+ // src/command/tokens/create-theme-typings.ts
9129
+ init_cjs_shims();
9130
+
9102
9131
  // src/command/tokens/config.ts
9103
9132
  init_cjs_shims();
9104
9133
  var config = [
9105
9134
  { key: "borders" },
9106
- { key: "breakpoints", filter: (value) => Number.isNaN(Number(value)) },
9107
- { key: "colors", maxScanDepth: 3 },
9135
+ { key: "breakpoints" },
9136
+ { key: "colors" },
9108
9137
  { key: "fonts" },
9109
9138
  { key: "fontSizes" },
9110
9139
  { key: "fontWeights" },
@@ -9113,11 +9142,14 @@ var config = [
9113
9142
  { key: "radii" },
9114
9143
  { key: "shadows" },
9115
9144
  { key: "blurs" },
9116
- { key: "sizes", maxScanDepth: 2 },
9145
+ { key: "sizes" },
9117
9146
  { key: "spaces", flatMap: (value) => [value, `-${value}`] },
9118
9147
  { key: "zIndices" },
9119
9148
  { key: "animations", omitScanKeys: ["keyframes"] },
9120
- { key: "gradients" }
9149
+ { key: "gradients" },
9150
+ { key: "transitions.property", replaceKey: "transitionProperty" },
9151
+ { key: "transitions.duration", replaceKey: "transitionDuration" },
9152
+ { key: "transitions.easing", replaceKey: "transitionEasing" }
9121
9153
  ];
9122
9154
 
9123
9155
  // src/command/tokens/create-theme-typings.ts
@@ -9143,31 +9175,6 @@ var extractComponents = ({ components = {} }) => Object.entries(components).redu
9143
9175
  },
9144
9176
  {}
9145
9177
  );
9146
- var extractTransitions = (theme) => {
9147
- let transitionProperty = [];
9148
- let transitionDuration = [];
9149
- let transitionEasing = [];
9150
- const { transitions, semantics } = theme;
9151
- if (!isObject(transitions))
9152
- return { transitionProperty, transitionDuration, transitionEasing };
9153
- const { property, duration, easing } = semantics.transitions ?? {};
9154
- Object.entries(transitions).forEach(([key, value]) => {
9155
- switch (key) {
9156
- case "property":
9157
- transitionProperty = [...extractPaths(value), ...extractPaths(property)];
9158
- break;
9159
- case "duration":
9160
- transitionDuration = [...extractPaths(value), ...extractPaths(duration)];
9161
- break;
9162
- case "easing":
9163
- transitionEasing = [...extractPaths(value), ...extractPaths(easing)];
9164
- break;
9165
- default:
9166
- return;
9167
- }
9168
- });
9169
- return { transitionProperty, transitionDuration, transitionEasing };
9170
- };
9171
9178
  var isTone = (value) => {
9172
9179
  if (!isObject(value)) return false;
9173
9180
  const keys = Object.keys(value);
@@ -9175,75 +9182,90 @@ var isTone = (value) => {
9175
9182
  };
9176
9183
  var extractColorSchemes = (theme) => {
9177
9184
  const { colors, semantics } = theme;
9178
- const results = {
9179
- colorSchemes: [],
9180
- colorSchemeColors: []
9181
- };
9182
- if (!isObject(colors)) return results;
9185
+ let colorSchemes = [];
9186
+ let colorSchemeColors = [];
9187
+ if (!isObject(colors)) return { colorSchemes, colorSchemeColors };
9183
9188
  Object.entries(colors).forEach(([key, value]) => {
9184
9189
  if (!isTone(value)) return;
9185
- results.colorSchemes.push(key);
9190
+ colorSchemes.push(key);
9186
9191
  });
9187
- if (!isObject(semantics?.colorSchemes)) return results;
9192
+ if (!isObject(semantics?.colorSchemes))
9193
+ return { colorSchemes, colorSchemeColors };
9188
9194
  Object.entries(semantics.colorSchemes).forEach(([key, value]) => {
9189
9195
  if (isTone(value)) {
9190
- results.colorSchemes.push(key);
9191
- results.colorSchemeColors.push(...TONES.map((tone) => `${key}.${tone}`));
9196
+ colorSchemes.push(key);
9197
+ colorSchemeColors.push(...TONES.map((tone) => `${key}.${tone}`));
9192
9198
  } else {
9193
- const hasColorScheme = isArray(value) ? value.every(
9194
- (key2) => isString(key2) && Object.keys(colors).includes(key2)
9195
- ) : Object.keys(colors).some((key2) => key2 === value);
9199
+ const hasColorScheme = isArray(value) ? value.every((key2) => Object.keys(colors).includes(String(key2))) : Object.keys(colors).includes(String(value));
9196
9200
  if (!hasColorScheme) return;
9197
- results.colorSchemes.push(key);
9198
- results.colorSchemeColors.push(...TONES.map((tone) => `${key}.${tone}`));
9201
+ colorSchemes.push(key);
9202
+ colorSchemeColors.push(...TONES.map((tone) => `${key}.${tone}`));
9199
9203
  }
9200
9204
  });
9201
- return results;
9205
+ return { colorSchemes, colorSchemeColors };
9202
9206
  };
9203
9207
  var extractThemeSchemes = (theme) => {
9204
9208
  const { themeSchemes } = theme;
9205
9209
  if (!isObject(themeSchemes)) return ["base"];
9206
9210
  return ["base", ...Object.keys(themeSchemes)];
9207
9211
  };
9208
- var extractPaths = (target, maxDepth = 3, omitKeys = []) => {
9212
+ var extractPaths = (target, maxDepth = 3, omitKeys = [], shouldProcess) => {
9209
9213
  if (!isObject(target) && !isArray(target) || !maxDepth) return [];
9210
- return Object.entries(target).reduce((array, [key, value]) => {
9211
- if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2))) {
9212
- extractPaths(value, maxDepth - 1, omitKeys).forEach(
9213
- (nestedKey) => array.push(`${key}.${nestedKey}`)
9214
+ return Object.entries(target).reduce((prev, [key, value]) => {
9215
+ if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2)) && (!shouldProcess || shouldProcess(value))) {
9216
+ extractPaths(value, maxDepth - 1, omitKeys, shouldProcess).forEach(
9217
+ (nestedKey) => prev.push(`${key}.${nestedKey}`)
9214
9218
  );
9215
9219
  } else {
9216
- array.push(key);
9220
+ prev.push(key);
9217
9221
  }
9218
- return array;
9222
+ return prev;
9219
9223
  }, []);
9220
9224
  };
9221
- var extractKeys = (theme, key) => {
9222
- const keys = key.split(".");
9223
- const property = keys.reduce((obj, key2) => obj[key2] ?? {}, theme);
9225
+ var extractKeys = (obj, key) => {
9226
+ const property = getObject2(obj, key);
9224
9227
  if (!isObject(property)) return [];
9225
9228
  return Object.keys(property);
9226
9229
  };
9227
- var createThemeTypings = async (theme) => {
9230
+ var createThemeTypings = async (theme, { responsive = false }) => {
9231
+ let shouldProcess = void 0;
9232
+ if (responsive && isObject(theme.breakpoints)) {
9233
+ const keys = ["base", ...Object.keys(theme.breakpoints)];
9234
+ const isResponsive = (obj) => {
9235
+ const providedKeys = Object.keys(obj);
9236
+ if (!providedKeys.length) return false;
9237
+ if (!providedKeys.includes("base")) return false;
9238
+ return providedKeys.every((key) => keys.includes(key));
9239
+ };
9240
+ shouldProcess = (obj) => !isResponsive(obj);
9241
+ }
9228
9242
  const tokens = config.reduce(
9229
9243
  (prev, {
9230
9244
  key,
9245
+ replaceKey,
9231
9246
  maxScanDepth,
9232
9247
  omitScanKeys,
9233
- filter = () => true,
9234
9248
  flatMap = (value) => value
9235
9249
  }) => {
9236
- const target = theme[key];
9237
- prev[key] = [];
9250
+ const target = getObject2(theme, key);
9251
+ prev[replaceKey ?? key] = [];
9238
9252
  if (isObject(target) || isArray(target)) {
9239
- prev[key] = extractPaths(target, maxScanDepth, omitScanKeys).filter(filter).flatMap(flatMap);
9253
+ prev[replaceKey ?? key] = extractPaths(
9254
+ target,
9255
+ maxScanDepth,
9256
+ omitScanKeys,
9257
+ shouldProcess
9258
+ ).flatMap(flatMap);
9240
9259
  }
9241
9260
  if (isObject(theme.semantics)) {
9242
- const semanticKeys = extractKeys(
9243
- omitObject(theme.semantics, ["colorSchemes"]),
9244
- key
9245
- ).filter(filter).flatMap(flatMap);
9246
- prev[key].push(...semanticKeys);
9261
+ const target2 = getObject2(theme.semantics, key);
9262
+ const semanticKeys = extractPaths(
9263
+ target2,
9264
+ maxScanDepth,
9265
+ omitScanKeys,
9266
+ shouldProcess
9267
+ ).flatMap(flatMap);
9268
+ prev[replaceKey ?? key].push(...semanticKeys);
9247
9269
  }
9248
9270
  return prev;
9249
9271
  },
@@ -9253,24 +9275,23 @@ var createThemeTypings = async (theme) => {
9253
9275
  const layerStyles = extractKeys(theme, "styles.layerStyles");
9254
9276
  const { colorSchemes, colorSchemeColors } = extractColorSchemes(theme);
9255
9277
  const themeSchemes = extractThemeSchemes(theme);
9256
- const { transitionProperty, transitionDuration, transitionEasing } = extractTransitions(theme);
9257
- const componentTypes = extractComponents(theme);
9278
+ const components = extractComponents(theme);
9258
9279
  tokens.colors = [...tokens.colors, ...colorSchemeColors];
9259
9280
  return prettier(
9260
- `import type { UITheme } from './ui-theme.types'
9261
-
9262
- export interface GeneratedTheme extends UITheme { ${print(
9263
- {
9281
+ [
9282
+ `import type { UITheme } from './ui-theme.types'`,
9283
+ ``,
9284
+ `export interface GeneratedTheme extends UITheme {`,
9285
+ print({
9264
9286
  ...tokens,
9265
9287
  textStyles,
9266
9288
  layerStyles,
9267
9289
  colorSchemes,
9268
- themeSchemes,
9269
- transitionProperty,
9270
- transitionDuration,
9271
- transitionEasing
9272
- }
9273
- )} ${printComponent(componentTypes)} }`
9290
+ themeSchemes
9291
+ }),
9292
+ printComponent(components),
9293
+ `}`
9294
+ ].join("\n")
9274
9295
  );
9275
9296
  };
9276
9297
 
@@ -9316,6 +9337,7 @@ var resolveOutputPath = async (outPath) => {
9316
9337
  // src/command/tokens/index.ts
9317
9338
  var generateThemeTypings = async ({
9318
9339
  theme,
9340
+ config: config2,
9319
9341
  outFile
9320
9342
  }) => {
9321
9343
  p.intro(source_default.magenta(`Generating Yamada UI theme typings`));
@@ -9323,7 +9345,7 @@ var generateThemeTypings = async ({
9323
9345
  try {
9324
9346
  const start = process.hrtime.bigint();
9325
9347
  s.start(`Parsing the theme`);
9326
- const generatedTheme = await createThemeTypings(theme);
9348
+ const generatedTheme = await createThemeTypings(theme, config2.theme ?? {});
9327
9349
  s.stop(`Parsed the theme`);
9328
9350
  s.start(`Resolving the output path`);
9329
9351
  const outPath = await resolveOutputPath(outFile);
@@ -9341,19 +9363,22 @@ var generateThemeTypings = async ({
9341
9363
  p.cancel(source_default.red(e instanceof Error ? e.message : "Message is missing"));
9342
9364
  }
9343
9365
  };
9344
- var actionTokens = async (themePath2, { out: outFile, watch: watchFile }) => {
9366
+ var actionTokens = async (themePath2, { cwd = import_path4.default.resolve(), out: outFile, watch: watchFile }) => {
9345
9367
  const readFile2 = async () => {
9346
9368
  const filePath = import_path4.default.resolve(themePath2);
9347
- const { mod: theme, dependencies } = await (0, import_bundle_n_require.bundleNRequire)(filePath);
9348
- return { theme, dependencies };
9369
+ const { mod, dependencies: dependencies2 } = await getModule(filePath, cwd);
9370
+ const theme2 = mod?.default ?? mod?.theme ?? mod?.customTheme ?? mod?.defaultTheme ?? {};
9371
+ const config3 = mod?.config ?? mod?.customConfig ?? mod?.defaultConfig ?? {};
9372
+ return { theme: theme2, config: config3, dependencies: dependencies2 };
9349
9373
  };
9350
9374
  let file = await readFile2();
9375
+ const { theme, config: config2, dependencies } = file;
9351
9376
  const buildFile = async () => {
9352
- await generateThemeTypings({ theme: file.theme, outFile });
9377
+ await generateThemeTypings({ theme, config: config2, outFile });
9353
9378
  if (watchFile) console.log("\n", "\u231B\uFE0F Watching for changes...");
9354
9379
  };
9355
9380
  if (watchFile) {
9356
- const watchPath = typeof watchFile === "string" ? watchFile : file.dependencies;
9381
+ const watchPath = typeof watchFile === "string" ? watchFile : dependencies;
9357
9382
  import_chokidar.default.watch(watchPath).on("ready", buildFile).on("change", async (filePath) => {
9358
9383
  console.log("\u{1F4E6} File changed", filePath);
9359
9384
  file = await readFile2();
@@ -9367,7 +9392,7 @@ var actionTokens = async (themePath2, { out: outFile, watch: watchFile }) => {
9367
9392
  // src/command/theme/index.ts
9368
9393
  init_cjs_shims();
9369
9394
  var import_dns = __toESM(require("dns"));
9370
- var import_fs2 = require("fs");
9395
+ var import_fs3 = require("fs");
9371
9396
  var import_promises2 = require("fs/promises");
9372
9397
  var import_node_stream = require("stream");
9373
9398
  var import_promises3 = require("stream/promises");
@@ -9378,10 +9403,10 @@ var import_typescript = require("typescript");
9378
9403
 
9379
9404
  // src/utils/fs.ts
9380
9405
  init_cjs_shims();
9381
- var import_fs = __toESM(require("fs"));
9406
+ var import_fs2 = __toESM(require("fs"));
9382
9407
  var isWriteable = async (directory) => {
9383
9408
  try {
9384
- await import_fs.default.promises.access(directory, (import_fs.default.constants || import_fs.default).W_OK);
9409
+ await import_fs2.default.promises.access(directory, (import_fs2.default.constants || import_fs2.default).W_OK);
9385
9410
  return true;
9386
9411
  } catch {
9387
9412
  return false;
@@ -9554,13 +9579,13 @@ var generateTheme = async (outPath, fileMap, isReactReplace, isForceReplace) =>
9554
9579
  }
9555
9580
  const formattedContent = await prettier(content);
9556
9581
  try {
9557
- if (!isForceReplace && (0, import_fs2.existsSync)(targetPath)) return;
9582
+ if (!isForceReplace && (0, import_fs3.existsSync)(targetPath)) return;
9558
9583
  await (0, import_promises2.writeFile)(targetPath, formattedContent, "utf-8");
9559
9584
  } catch (e) {
9560
9585
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
9561
9586
  const dirPath = import_path5.default.dirname(targetPath);
9562
9587
  await (0, import_promises2.mkdir)(dirPath, { recursive: true });
9563
- if (!isForceReplace && (0, import_fs2.existsSync)(targetPath)) return;
9588
+ if (!isForceReplace && (0, import_fs3.existsSync)(targetPath)) return;
9564
9589
  await (0, import_promises2.writeFile)(targetPath, formattedContent, "utf-8");
9565
9590
  }
9566
9591
  }
@@ -9597,7 +9622,7 @@ var actionTheme = async (_outPath, { branch = DEFAULT_BRANCH_NAME, cwd, replace
9597
9622
  var run = async () => {
9598
9623
  await initCLI();
9599
9624
  const program = new import_commander.Command(package_default.name).name("yamada-cli").description(package_default.description).version(package_default.version).usage(`${source_default.green("<command>")} [options]`);
9600
- program.command("tokens <path>").option("-o, --out <path>", `Output file to ${import_path6.default.join(...themePath)}`).option("-w, --watch [path]", "Watch directory for changes and rebuild").action(actionTokens);
9625
+ program.command("tokens <path>").option("--cwd <path>", "Current working directory").option("-o, --out <path>", `Output file to ${import_path6.default.join(...themePath)}`).option("-w, --watch [path]", "Watch directory for changes and rebuild").action(actionTokens);
9601
9626
  program.command("theme <path>").option("-b, --branch <branch>", "Branch to download").option("--cwd <path>", "Current working directory").option("-r, --replace", "Force replace the theme").action(actionTheme);
9602
9627
  program.parse();
9603
9628
  };
package/dist/utils/cli.js CHANGED
@@ -9010,20 +9010,21 @@ var package_default = {
9010
9010
  },
9011
9011
  dependencies: {
9012
9012
  "@clack/prompts": "^0.7.0",
9013
- "bundle-n-require": "^1.1.1",
9014
9013
  chokidar: "^3.6.0",
9015
9014
  "cli-check-node": "^1.3.4",
9016
9015
  "cli-handle-unhandled": "^1.1.1",
9017
9016
  commander: "^12.1.0",
9017
+ esbuild: "^0.23.1",
9018
9018
  glob: "^11.0.0",
9019
+ "node-eval": "^2.0.0",
9019
9020
  prettier: "^3.3.3",
9020
9021
  tar: "^7.4.3",
9021
9022
  typescript: "^5.5.4"
9022
9023
  },
9023
9024
  devDependencies: {
9024
- "update-notifier": "^7.2.0",
9025
+ "@types/update-notifier": "6.0.8",
9025
9026
  chalk: "^5.3.0",
9026
- "@types/update-notifier": "6.0.8"
9027
+ "update-notifier": "^7.2.0"
9027
9028
  }
9028
9029
  };
9029
9030
 
@@ -4318,8 +4318,8 @@ var require_coerce = __commonJS({
4318
4318
  const minor = match[3] || "0";
4319
4319
  const patch = match[4] || "0";
4320
4320
  const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
4321
- const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
4322
- return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
4321
+ const build2 = options.includePrerelease && match[6] ? `+${match[6]}` : "";
4322
+ return parse(`${major}.${minor}.${patch}${prerelease}${build2}`, options);
4323
4323
  };
4324
4324
  module2.exports = coerce;
4325
4325
  }
@@ -5915,6 +5915,8 @@ var require_ansi_align = __commonJS({
5915
5915
  // src/utils/index.ts
5916
5916
  var utils_exports = {};
5917
5917
  __export(utils_exports, {
5918
+ getModule: () => getModule,
5919
+ getObject: () => getObject2,
5918
5920
  initCLI: () => initCLI,
5919
5921
  isArray: () => isArray,
5920
5922
  isFunction: () => isFunction,
@@ -9036,20 +9038,21 @@ var package_default = {
9036
9038
  },
9037
9039
  dependencies: {
9038
9040
  "@clack/prompts": "^0.7.0",
9039
- "bundle-n-require": "^1.1.1",
9040
9041
  chokidar: "^3.6.0",
9041
9042
  "cli-check-node": "^1.3.4",
9042
9043
  "cli-handle-unhandled": "^1.1.1",
9043
9044
  commander: "^12.1.0",
9045
+ esbuild: "^0.23.1",
9044
9046
  glob: "^11.0.0",
9047
+ "node-eval": "^2.0.0",
9045
9048
  prettier: "^3.3.3",
9046
9049
  tar: "^7.4.3",
9047
9050
  typescript: "^5.5.4"
9048
9051
  },
9049
9052
  devDependencies: {
9050
- "update-notifier": "^7.2.0",
9053
+ "@types/update-notifier": "6.0.8",
9051
9054
  chalk: "^5.3.0",
9052
- "@types/update-notifier": "6.0.8"
9055
+ "update-notifier": "^7.2.0"
9053
9056
  }
9054
9057
  };
9055
9058
 
@@ -9099,8 +9102,48 @@ var omitObject = (obj, keys) => {
9099
9102
  });
9100
9103
  return result;
9101
9104
  };
9105
+ var getObject2 = (obj, path10) => {
9106
+ const keys = path10.split(".");
9107
+ return keys.reduce((obj2, key) => obj2[key] ?? {}, obj);
9108
+ };
9109
+
9110
+ // src/utils/module.ts
9111
+ init_cjs_shims();
9112
+ var import_fs = require("fs");
9113
+ var import_vm = require("vm");
9114
+ var import_esbuild = require("esbuild");
9115
+ var import_node_eval = __toESM(require("node-eval"));
9116
+ var getModule = async (file, cwd) => {
9117
+ const result = await (0, import_esbuild.build)({
9118
+ platform: "node",
9119
+ format: "cjs",
9120
+ mainFields: ["module", "main"],
9121
+ absWorkingDir: cwd,
9122
+ entryPoints: [file],
9123
+ outfile: "out.js",
9124
+ write: false,
9125
+ bundle: true,
9126
+ sourcemap: false,
9127
+ metafile: true
9128
+ });
9129
+ const { text: code } = result.outputFiles[0];
9130
+ const dependencies = result.metafile ? Object.keys(result.metafile.inputs) : [];
9131
+ try {
9132
+ const realFileName = import_fs.realpathSync.native(file);
9133
+ const script = new import_vm.Script(code, { filename: realFileName });
9134
+ const mod = { exports: {} };
9135
+ const require2 = (id) => id === realFileName ? mod.exports : require2(id);
9136
+ script.runInThisContext()(mod.exports, require2, mod);
9137
+ return { mod, code, dependencies };
9138
+ } catch {
9139
+ const mod = (0, import_node_eval.default)(code);
9140
+ return { mod, code, dependencies };
9141
+ }
9142
+ };
9102
9143
  // Annotate the CommonJS export names for ESM import in node:
9103
9144
  0 && (module.exports = {
9145
+ getModule,
9146
+ getObject,
9104
9147
  initCLI,
9105
9148
  isArray,
9106
9149
  isFunction,
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/utils/module.ts
31
+ var module_exports = {};
32
+ __export(module_exports, {
33
+ getModule: () => getModule
34
+ });
35
+ module.exports = __toCommonJS(module_exports);
36
+ var import_fs = require("fs");
37
+ var import_vm = require("vm");
38
+ var import_esbuild = require("esbuild");
39
+ var import_node_eval = __toESM(require("node-eval"));
40
+ var getModule = async (file, cwd) => {
41
+ const result = await (0, import_esbuild.build)({
42
+ platform: "node",
43
+ format: "cjs",
44
+ mainFields: ["module", "main"],
45
+ absWorkingDir: cwd,
46
+ entryPoints: [file],
47
+ outfile: "out.js",
48
+ write: false,
49
+ bundle: true,
50
+ sourcemap: false,
51
+ metafile: true
52
+ });
53
+ const { text: code } = result.outputFiles[0];
54
+ const dependencies = result.metafile ? Object.keys(result.metafile.inputs) : [];
55
+ try {
56
+ const realFileName = import_fs.realpathSync.native(file);
57
+ const script = new import_vm.Script(code, { filename: realFileName });
58
+ const mod = { exports: {} };
59
+ const require2 = (id) => id === realFileName ? mod.exports : require2(id);
60
+ script.runInThisContext()(mod.exports, require2, mod);
61
+ return { mod, code, dependencies };
62
+ } catch {
63
+ const mod = (0, import_node_eval.default)(code);
64
+ return { mod, code, dependencies };
65
+ }
66
+ };
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ getModule
70
+ });
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/utils/object.ts
21
21
  var object_exports = {};
22
22
  __export(object_exports, {
23
+ getObject: () => getObject,
23
24
  omitObject: () => omitObject
24
25
  });
25
26
  module.exports = __toCommonJS(object_exports);
@@ -31,7 +32,12 @@ var omitObject = (obj, keys) => {
31
32
  });
32
33
  return result;
33
34
  };
35
+ var getObject = (obj, path) => {
36
+ const keys = path.split(".");
37
+ return keys.reduce((obj2, key) => obj2[key] ?? {}, obj);
38
+ };
34
39
  // Annotate the CommonJS export names for ESM import in node:
35
40
  0 && (module.exports = {
41
+ getObject,
36
42
  omitObject
37
43
  });