@yamada-ui/cli 2.1.0-dev-20260308045531 → 2.1.0-dev-20260309110959
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.mjs +172 -134
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5494,7 +5494,7 @@ function updateNotifier(options) {
|
|
|
5494
5494
|
//#endregion
|
|
5495
5495
|
//#region package.json
|
|
5496
5496
|
var name = "@yamada-ui/cli";
|
|
5497
|
-
var version = "2.0
|
|
5497
|
+
var version = "2.1.0-dev-20260308051035";
|
|
5498
5498
|
var description = "The official CLI for Yamada UI projects";
|
|
5499
5499
|
var package_default = {
|
|
5500
5500
|
name,
|
|
@@ -5576,13 +5576,20 @@ var package_default = {
|
|
|
5576
5576
|
|
|
5577
5577
|
//#endregion
|
|
5578
5578
|
//#region src/constant.ts
|
|
5579
|
+
const PACKAGE_NAME = "@yamada-ui/react";
|
|
5579
5580
|
const CONFIG_FILE_NAME = "ui.json";
|
|
5580
5581
|
const REGISTRY_FILE_NAME = "registry.json";
|
|
5582
|
+
const REGISTRY_VERSION = "v2";
|
|
5583
|
+
const REGISTRY_URL = "https://yamada-ui.com/registry";
|
|
5584
|
+
const SECTION_NAMES = [
|
|
5585
|
+
"components",
|
|
5586
|
+
"hooks",
|
|
5587
|
+
"providers"
|
|
5588
|
+
];
|
|
5581
5589
|
const DEFAULT_PACKAGE_NAME = {
|
|
5582
5590
|
ui: "@workspaces/ui",
|
|
5583
5591
|
theme: "@workspaces/theme"
|
|
5584
5592
|
};
|
|
5585
|
-
const REGISTRY_URL = "https://yamada-ui.com/registry/v2";
|
|
5586
5593
|
const DEFAULT_PATH = {
|
|
5587
5594
|
components: "./components",
|
|
5588
5595
|
hooks: "./hooks",
|
|
@@ -5596,13 +5603,8 @@ const DEFAULT_PATH = {
|
|
|
5596
5603
|
polyrepo: "./theme"
|
|
5597
5604
|
}
|
|
5598
5605
|
};
|
|
5599
|
-
const SECTION_NAMES = [
|
|
5600
|
-
"components",
|
|
5601
|
-
"hooks",
|
|
5602
|
-
"providers"
|
|
5603
|
-
];
|
|
5604
5606
|
const DEFAULT_CONFIG = {
|
|
5605
|
-
$schema: `${REGISTRY_URL}/config.schema.json`,
|
|
5607
|
+
$schema: `${REGISTRY_URL}/${REGISTRY_VERSION}/config.schema.json`,
|
|
5606
5608
|
components: { overwrite: true },
|
|
5607
5609
|
hooks: { overwrite: true },
|
|
5608
5610
|
providers: { overwrite: true }
|
|
@@ -5611,9 +5613,9 @@ const REQUIRED_DEPENDENCIES = {
|
|
|
5611
5613
|
ui: [
|
|
5612
5614
|
"react@^19",
|
|
5613
5615
|
"react-dom@^19",
|
|
5614
|
-
|
|
5616
|
+
`${PACKAGE_NAME}@^2`
|
|
5615
5617
|
],
|
|
5616
|
-
theme: [
|
|
5618
|
+
theme: [`${PACKAGE_NAME}@^2`]
|
|
5617
5619
|
};
|
|
5618
5620
|
const REQUIRED_DEV_DEPENDENCIES = {
|
|
5619
5621
|
ui: ["@types/react@^19", "@types/react-dom@^19"],
|
|
@@ -5838,6 +5840,13 @@ function splitVersion(value) {
|
|
|
5838
5840
|
return [`@${name$1}`, version$1];
|
|
5839
5841
|
} else return value.split("@");
|
|
5840
5842
|
}
|
|
5843
|
+
function replaceVersion(value, target, tag) {
|
|
5844
|
+
if (!tag) return value;
|
|
5845
|
+
const [name$1, version$1] = splitVersion(value);
|
|
5846
|
+
if (!version$1) return value;
|
|
5847
|
+
if (name$1 !== target) return value;
|
|
5848
|
+
return `${name$1}@${tag}`;
|
|
5849
|
+
}
|
|
5841
5850
|
function getPackageName(value) {
|
|
5842
5851
|
return splitVersion(value)[0];
|
|
5843
5852
|
}
|
|
@@ -6064,15 +6073,15 @@ async function getModule(file, cwd$1) {
|
|
|
6064
6073
|
//#region src/utils/registry.ts
|
|
6065
6074
|
const agent = process.env.https_proxy ? new HttpsProxyAgent(process.env.https_proxy) : void 0;
|
|
6066
6075
|
const registryStore = /* @__PURE__ */ new Map();
|
|
6067
|
-
function getRegistryUrl(name$1) {
|
|
6068
|
-
if (name$1 === "index") return path$1.posix.join(REGISTRY_URL, "index.json");
|
|
6069
|
-
else if (name$1 === "theme") return path$1.posix.join(REGISTRY_URL, "theme.json");
|
|
6070
|
-
else if (name$1.startsWith("use-")) return path$1.posix.join(REGISTRY_URL, "hooks", `${name$1}.json`);
|
|
6071
|
-
else if (name$1.endsWith("-provider")) return path$1.posix.join(REGISTRY_URL, "providers", `${name$1}.json`);
|
|
6072
|
-
else return path$1.posix.join(REGISTRY_URL, "components", `${name$1}.json`);
|
|
6076
|
+
function getRegistryUrl(name$1, tag = "") {
|
|
6077
|
+
if (name$1 === "index") return path$1.posix.join(REGISTRY_URL, tag, REGISTRY_VERSION, "index.json");
|
|
6078
|
+
else if (name$1 === "theme") return path$1.posix.join(REGISTRY_URL, tag, REGISTRY_VERSION, "theme.json");
|
|
6079
|
+
else if (name$1.startsWith("use-")) return path$1.posix.join(REGISTRY_URL, tag, REGISTRY_VERSION, "hooks", `${name$1}.json`);
|
|
6080
|
+
else if (name$1.endsWith("-provider")) return path$1.posix.join(REGISTRY_URL, tag, REGISTRY_VERSION, "providers", `${name$1}.json`);
|
|
6081
|
+
else return path$1.posix.join(REGISTRY_URL, tag, REGISTRY_VERSION, "components", `${name$1}.json`);
|
|
6073
6082
|
}
|
|
6074
|
-
async function fetchRegistryNames() {
|
|
6075
|
-
const { sources } = await fetchRegistry("index");
|
|
6083
|
+
async function fetchRegistryNames(tag) {
|
|
6084
|
+
const { sources } = await fetchRegistry("index", { tag });
|
|
6076
6085
|
const content = sources[0].content;
|
|
6077
6086
|
const regex = /"@yamada-ui\/react\/([^"/]+)(?:\/([^"/]+))?"/g;
|
|
6078
6087
|
const registryNames = [];
|
|
@@ -6083,8 +6092,8 @@ async function fetchRegistryNames() {
|
|
|
6083
6092
|
}
|
|
6084
6093
|
return registryNames;
|
|
6085
6094
|
}
|
|
6086
|
-
async function fetchRegistry(name$1, { cache = true } = {}) {
|
|
6087
|
-
const url$2 = getRegistryUrl(name$1);
|
|
6095
|
+
async function fetchRegistry(name$1, { cache = true, tag } = {}) {
|
|
6096
|
+
const url$2 = getRegistryUrl(name$1, tag);
|
|
6088
6097
|
if (cache && registryStore.has(url$2)) return registryStore.get(url$2);
|
|
6089
6098
|
const res = await fetch(url$2, { agent });
|
|
6090
6099
|
if (res.ok) {
|
|
@@ -6103,12 +6112,15 @@ async function fetchRegistry(name$1, { cache = true } = {}) {
|
|
|
6103
6112
|
default: throw new Error(`An error occurred while fetching the registry at ${c.red(name$1)}. Please try again later.`);
|
|
6104
6113
|
}
|
|
6105
6114
|
}
|
|
6106
|
-
async function fetchRegistries(names, config$1, { cache = true, dependencies: withDependencies = true, dependents: withDependents = true, omit = [] } = {}) {
|
|
6115
|
+
async function fetchRegistries(names, config$1, { cache = true, dependencies: withDependencies = true, dependents: withDependents = true, omit = [], tag } = {}) {
|
|
6107
6116
|
const results = {};
|
|
6108
6117
|
async function fetch$1(names$1) {
|
|
6109
6118
|
await Promise.all(names$1.map(async (name$1) => {
|
|
6110
6119
|
if (results[name$1] || omit.includes(name$1)) return;
|
|
6111
|
-
results[name$1] = fetchRegistry(name$1, {
|
|
6120
|
+
results[name$1] = fetchRegistry(name$1, {
|
|
6121
|
+
cache,
|
|
6122
|
+
tag
|
|
6123
|
+
});
|
|
6112
6124
|
results[name$1] = await results[name$1];
|
|
6113
6125
|
const { dependencies: dependencies$1, dependents, section } = results[name$1];
|
|
6114
6126
|
const target = [];
|
|
@@ -6168,7 +6180,7 @@ function transformContent(targetSection, content, { getSection }, generatedNames
|
|
|
6168
6180
|
const depth = (value.match(/\.\.\//g) || []).length;
|
|
6169
6181
|
if (!depth) return;
|
|
6170
6182
|
if (depth === 1) if (generated) replaceValue = `from "${path$1.join("..", name$1)}"`;
|
|
6171
|
-
else replaceValue = `from "
|
|
6183
|
+
else replaceValue = `from "${PACKAGE_NAME}/${targetSection}/${name$1}"`;
|
|
6172
6184
|
else {
|
|
6173
6185
|
const { path: sectionPath, section } = getSection(value.replace(/(\.\.\/|\.\/)/g, "").split("/").slice(0, -1).join("/")) ?? {};
|
|
6174
6186
|
if (!section || !sectionPath) return;
|
|
@@ -6176,7 +6188,7 @@ function transformContent(targetSection, content, { getSection }, generatedNames
|
|
|
6176
6188
|
const neededDepth = depth + (sectionPath.match(/\.\.\//g) || []).length;
|
|
6177
6189
|
const omittedTargetPath = sectionPath.replace(/(\.\.\/|\.\/)/g, "");
|
|
6178
6190
|
replaceValue = `from "${"../".repeat(neededDepth)}${omittedTargetPath}/${name$1}"`;
|
|
6179
|
-
} else replaceValue = `from "
|
|
6191
|
+
} else replaceValue = `from "${PACKAGE_NAME}/${section}/${name$1}"`;
|
|
6180
6192
|
}
|
|
6181
6193
|
}
|
|
6182
6194
|
content = content.replace(searchValue, replaceValue);
|
|
@@ -6218,7 +6230,7 @@ function transformIndex(generatedNames, content, { getSection }) {
|
|
|
6218
6230
|
} else {
|
|
6219
6231
|
const { section } = getSection(value.replace(/(\.\.\/|\.\/)/g, "").split("/").slice(0, -1).join("/")) ?? {};
|
|
6220
6232
|
if (!section) return;
|
|
6221
|
-
replaceValue = `from "
|
|
6233
|
+
replaceValue = `from "${PACKAGE_NAME}/${section}/${name$1}"`;
|
|
6222
6234
|
}
|
|
6223
6235
|
content = content.replace(searchValue, replaceValue);
|
|
6224
6236
|
});
|
|
@@ -6256,7 +6268,7 @@ async function generateSources(dirPath, registry, config$1, generatedNames = [])
|
|
|
6256
6268
|
|
|
6257
6269
|
//#endregion
|
|
6258
6270
|
//#region src/commands/add/index.ts
|
|
6259
|
-
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("-
|
|
6271
|
+
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("-s, --sequential", "run tasks sequentially.", false).option("-y, --yes", "skip all confirmation prompts.", false).option("-i, --install", "install dependencies.").option("--no-install", "do not install dependencies.").option("-f, --format", "format the output files.").option("--no-format", "do not format the output files.").option("-l, --lint", "lint the output files.").option("--no-lint", "do not lint the output files.").option("-t, --tag <name>", "tag for the registries (e.g. dev, next).").action(async function(componentNames, { config: configPath, cwd: cwd$1, format: format$2, install, lint, overwrite, sequential, tag, yes }) {
|
|
6260
6272
|
const spinner = ora();
|
|
6261
6273
|
try {
|
|
6262
6274
|
const { end } = timer();
|
|
@@ -6272,14 +6284,17 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6272
6284
|
let generatedNameMap;
|
|
6273
6285
|
const omittedGeneratedNames = [];
|
|
6274
6286
|
if (!componentNames.length) {
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6287
|
+
if (!yes) {
|
|
6288
|
+
const { proceed } = await prompts({
|
|
6289
|
+
type: "confirm",
|
|
6290
|
+
name: "proceed",
|
|
6291
|
+
initial: true,
|
|
6292
|
+
message: c.reset(`Add all available components?`)
|
|
6293
|
+
});
|
|
6294
|
+
if (!proceed) process.exit(0);
|
|
6295
|
+
}
|
|
6282
6296
|
if (!overwrite && existsSync(config$1.paths.ui.src)) {
|
|
6297
|
+
if (yes) throw new Error(`The directory already exists. Use ${c.cyan("--overwrite")} to overwrite it.`);
|
|
6283
6298
|
const { overwrite: overwrite$1 } = await prompts({
|
|
6284
6299
|
type: "confirm",
|
|
6285
6300
|
name: "overwrite",
|
|
@@ -6289,7 +6304,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6289
6304
|
if (!overwrite$1) process.exit(0);
|
|
6290
6305
|
}
|
|
6291
6306
|
spinner.start("Fetching all available components");
|
|
6292
|
-
componentNames = await fetchRegistryNames();
|
|
6307
|
+
componentNames = await fetchRegistryNames(tag);
|
|
6293
6308
|
spinner.succeed("Fetched all available components");
|
|
6294
6309
|
} else {
|
|
6295
6310
|
spinner.start("Getting generated components");
|
|
@@ -6298,6 +6313,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6298
6313
|
const existsNames = componentNames.filter((name$1) => generatedNames.includes(name$1));
|
|
6299
6314
|
spinner.succeed("Got generated components");
|
|
6300
6315
|
if (!overwrite && existsNames.length) {
|
|
6316
|
+
if (yes) throw new Error(`The ${existsNames.map((name$1) => c.yellow(name$1)).join(", ")} components already exist. Use ${c.cyan("--overwrite")} to overwrite them.`);
|
|
6301
6317
|
const colorizedNames = existsNames.map((name$1) => c.yellow(name$1));
|
|
6302
6318
|
const { overwrite: overwrite$1 } = await prompts({
|
|
6303
6319
|
type: "confirm",
|
|
@@ -6313,7 +6329,8 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6313
6329
|
const registries = await fetchRegistries(componentNames, config$1, {
|
|
6314
6330
|
dependencies: !!componentNames.length,
|
|
6315
6331
|
dependents: !!componentNames.length,
|
|
6316
|
-
omit: omittedGeneratedNames
|
|
6332
|
+
omit: omittedGeneratedNames,
|
|
6333
|
+
tag
|
|
6317
6334
|
});
|
|
6318
6335
|
const registryNames = Object.keys(registries);
|
|
6319
6336
|
const dependencies$1 = [...new Set(Object.values(registries).map(({ dependencies: dependencies$2 }) => dependencies$2?.externals).filter((dependencies$2) => !isUndefined(dependencies$2)).flat())];
|
|
@@ -6324,14 +6341,16 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6324
6341
|
]).flat().filter((dependent) => omittedGeneratedNames.includes(dependent)))];
|
|
6325
6342
|
spinner.succeed("Fetched registries");
|
|
6326
6343
|
if (componentNames.length !== registryNames.length) {
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6344
|
+
if (!yes) {
|
|
6345
|
+
const colorizedNames = registryNames.map((name$1) => c.yellow(name$1));
|
|
6346
|
+
const { proceed } = await prompts({
|
|
6347
|
+
type: "confirm",
|
|
6348
|
+
name: "proceed",
|
|
6349
|
+
initial: true,
|
|
6350
|
+
message: c.reset(`The following components will be added: ${colorizedNames.join(", ")}. Do you want to add them?`)
|
|
6351
|
+
});
|
|
6352
|
+
if (!proceed) process.exit(0);
|
|
6353
|
+
}
|
|
6335
6354
|
}
|
|
6336
6355
|
const targetNames = [...new Set([...omittedGeneratedNames, ...registryNames])];
|
|
6337
6356
|
const tasks = new Listr(Object.entries(registries).map(([name$1, registry]) => {
|
|
@@ -6347,7 +6366,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6347
6366
|
};
|
|
6348
6367
|
}).filter((task) => !isUndefined(task)), { concurrent: !sequential });
|
|
6349
6368
|
if (affectedNames.length && generatedNameMap) {
|
|
6350
|
-
if (!overwrite) {
|
|
6369
|
+
if (!overwrite) if (!yes) {
|
|
6351
6370
|
const colorizedNames = affectedNames.map((name$1) => c.yellow(name$1));
|
|
6352
6371
|
const { update: update$1 } = await prompts({
|
|
6353
6372
|
type: "confirm",
|
|
@@ -6355,8 +6374,8 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6355
6374
|
initial: true,
|
|
6356
6375
|
message: c.reset([`The following generated files will be updated: ${colorizedNames.join(", ")}.`, "Do you want to update them?"].join(" "))
|
|
6357
6376
|
});
|
|
6358
|
-
|
|
6359
|
-
}
|
|
6377
|
+
overwrite = update$1;
|
|
6378
|
+
} else overwrite = true;
|
|
6360
6379
|
if (overwrite) Object.entries(generatedNameMap).forEach(([section, names]) => {
|
|
6361
6380
|
names.forEach((name$1) => {
|
|
6362
6381
|
if (!affectedNames.includes(name$1)) return;
|
|
@@ -6401,7 +6420,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6401
6420
|
});
|
|
6402
6421
|
else tasks.add({
|
|
6403
6422
|
task: async (_, task) => {
|
|
6404
|
-
const { sources: [source] } = await fetchRegistry("index");
|
|
6423
|
+
const { sources: [source] } = await fetchRegistry("index", { tag });
|
|
6405
6424
|
let content = transformIndex(targetNames, source.content, config$1);
|
|
6406
6425
|
if (config$1.jsx) content = transformTsToJs(content);
|
|
6407
6426
|
await writeFileSafe(config$1.paths.ui.index, content, config$1);
|
|
@@ -6414,7 +6433,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6414
6433
|
spinner.start(`Checking ${c.cyan("package.json")} dependencies`);
|
|
6415
6434
|
const notInstalledDependencies = getNotInstalledDependencies(await getPackageJson(targetPath), dependencies$1);
|
|
6416
6435
|
spinner.succeed(`Checked ${c.cyan("package.json")} dependencies`);
|
|
6417
|
-
if (!install && notInstalledDependencies.length) {
|
|
6436
|
+
if (!install && notInstalledDependencies.length) if (!yes) {
|
|
6418
6437
|
const colorizedNames = notInstalledDependencies.map((value) => c.yellow(isObject(value) ? value.current ? `${value.name}@${value.current}->${c.red(value.wanted)}` : value.name : value));
|
|
6419
6438
|
const { proceed } = await prompts({
|
|
6420
6439
|
type: "confirm",
|
|
@@ -6423,7 +6442,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6423
6442
|
message: c.reset([`The following dependencies are not installed: ${colorizedNames.join(", ")}.`, "Do you want to install them?"].join(" "))
|
|
6424
6443
|
});
|
|
6425
6444
|
install = proceed;
|
|
6426
|
-
}
|
|
6445
|
+
} else install = true;
|
|
6427
6446
|
if (install) tasks.add({
|
|
6428
6447
|
task: async (_, task) => {
|
|
6429
6448
|
await installDependencies(notInstalledDependencies.map(getPackageNameWithVersion), { cwd: targetPath });
|
|
@@ -6637,7 +6656,7 @@ async function mergeContent(remotePath, localPath, currentPath, fallback) {
|
|
|
6637
6656
|
content
|
|
6638
6657
|
};
|
|
6639
6658
|
}
|
|
6640
|
-
async function updateFiles(changeMap, { add: add$1, remove, update: update$1 }, { remote }, config$1, { concurrent = true, force = false, install = false } = {}) {
|
|
6659
|
+
async function updateFiles(changeMap, { add: add$1, remove, update: update$1 }, { remote }, config$1, { concurrent = true, force = false, install, yes = false } = {}) {
|
|
6641
6660
|
const conflictMap = {};
|
|
6642
6661
|
const disabledFormatAndLint = {
|
|
6643
6662
|
format: { enabled: false },
|
|
@@ -6691,13 +6710,14 @@ async function updateFiles(changeMap, { add: add$1, remove, update: update$1 },
|
|
|
6691
6710
|
title: `Changing ${c.cyan(componentName)}`
|
|
6692
6711
|
})), { concurrent }).run();
|
|
6693
6712
|
if (!install && (add$1.length || remove.length || update$1.length)) {
|
|
6694
|
-
const
|
|
6695
|
-
type: "confirm",
|
|
6713
|
+
const answer = await prompts({
|
|
6714
|
+
type: !yes && isUndefined(install) ? "confirm" : null,
|
|
6696
6715
|
name: "install",
|
|
6697
6716
|
initial: true,
|
|
6698
6717
|
message: c.reset("There are dependency updates. Do you want to install them?")
|
|
6699
6718
|
});
|
|
6700
|
-
|
|
6719
|
+
install ??= answer.install ?? true;
|
|
6720
|
+
if (!install) return conflictMap;
|
|
6701
6721
|
}
|
|
6702
6722
|
const cwd$1 = config$1.monorepo ? config$1.paths.ui.root : config$1.cwd;
|
|
6703
6723
|
remove.push(...update$1.map(({ name: name$1 }) => name$1));
|
|
@@ -6720,7 +6740,7 @@ async function validateDiff3() {
|
|
|
6720
6740
|
|
|
6721
6741
|
//#endregion
|
|
6722
6742
|
//#region src/commands/diff/get-registries-and-files.ts
|
|
6723
|
-
async function getRegistriesAndFiles(componentNames, config$1, { concurrent = true, index = false, theme: theme$1 = false } = {}) {
|
|
6743
|
+
async function getRegistriesAndFiles(componentNames, config$1, { concurrent = true, index = false, tag, theme: theme$1 = false } = {}) {
|
|
6724
6744
|
const fileMap = {};
|
|
6725
6745
|
const registryMap = {
|
|
6726
6746
|
local: {},
|
|
@@ -6736,7 +6756,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
|
|
|
6736
6756
|
title: `Getting ${c.cyan("index")} file`
|
|
6737
6757
|
}, {
|
|
6738
6758
|
task: async (_, task) => {
|
|
6739
|
-
registryMap.remote.index = await fetchRegistry("index");
|
|
6759
|
+
registryMap.remote.index = await fetchRegistry("index", { tag });
|
|
6740
6760
|
task.title = `Fetched ${c.cyan("index")} registry`;
|
|
6741
6761
|
},
|
|
6742
6762
|
title: `Fetching ${c.cyan("index")} registry`
|
|
@@ -6752,7 +6772,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
|
|
|
6752
6772
|
title: `Getting ${c.cyan("theme")} files`
|
|
6753
6773
|
}, {
|
|
6754
6774
|
task: async (_, task) => {
|
|
6755
|
-
registryMap.remote.theme = await fetchRegistry("theme");
|
|
6775
|
+
registryMap.remote.theme = await fetchRegistry("theme", { tag });
|
|
6756
6776
|
task.title = `Fetched ${c.cyan("theme")} registry`;
|
|
6757
6777
|
},
|
|
6758
6778
|
title: `Fetching ${c.cyan("theme")} registry`
|
|
@@ -6767,7 +6787,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
|
|
|
6767
6787
|
title: `Getting ${c.cyan(componentName)} files`
|
|
6768
6788
|
}, {
|
|
6769
6789
|
task: async (_, task) => {
|
|
6770
|
-
registryMap.remote[componentName] = await fetchRegistry(componentName);
|
|
6790
|
+
registryMap.remote[componentName] = await fetchRegistry(componentName, { tag });
|
|
6771
6791
|
task.title = `Fetched ${c.cyan(componentName)} registry`;
|
|
6772
6792
|
},
|
|
6773
6793
|
title: `Fetching ${c.cyan(componentName)} registry`
|
|
@@ -6830,7 +6850,7 @@ function printDiffDependencies({ add: add$1, remove, update: update$1 }) {
|
|
|
6830
6850
|
|
|
6831
6851
|
//#endregion
|
|
6832
6852
|
//#region src/commands/diff/index.ts
|
|
6833
|
-
const diff = new Command("diff").description("check for updates against the registry").argument("[component]", "component to check").option("--cwd <path>", "current working directory", cwd).option("-c, --config <path>", "path to the config file", CONFIG_FILE_NAME).option("-s, --sequential", "run tasks sequentially.", false).option("-d, --detail", "show detailed changes", false).action(async function(targetName, { config: configPath, cwd: cwd$1, detail, sequential }) {
|
|
6853
|
+
const diff = new Command("diff").description("check for updates against the registry.").argument("[component]", "component to check.").option("--cwd <path>", "current working directory.", cwd).option("-c, --config <path>", "path to the config file.", CONFIG_FILE_NAME).option("-s, --sequential", "run tasks sequentially.", false).option("-d, --detail", "show detailed changes.", false).option("-y, --yes", "skip all confirmation prompts.", false).option("-u, --update", "update files when there are file diff.").option("--no-update", "do not update files when there are file diff.").option("-i, --install", "install dependencies when updating files.").option("--no-install", "do not install dependencies when updating files.").option("-t, --tag <name>", "tag for the registries (e.g. dev, next).").action(async function(targetName, { config: configPath, cwd: cwd$1, detail, install, sequential, tag, update: update$1, yes }) {
|
|
6834
6854
|
const spinner = ora();
|
|
6835
6855
|
try {
|
|
6836
6856
|
const { end } = timer();
|
|
@@ -6875,6 +6895,7 @@ const diff = new Command("diff").description("check for updates against the regi
|
|
|
6875
6895
|
const { registryMap } = await getRegistriesAndFiles(componentNames, config$1, {
|
|
6876
6896
|
concurrent: !sequential,
|
|
6877
6897
|
index,
|
|
6898
|
+
tag,
|
|
6878
6899
|
theme: theme$1
|
|
6879
6900
|
});
|
|
6880
6901
|
const { changeMap, dependencyMap } = await getDiff(generatedNames, registryMap, config$1, !sequential);
|
|
@@ -6896,17 +6917,22 @@ const diff = new Command("diff").description("check for updates against the regi
|
|
|
6896
6917
|
}
|
|
6897
6918
|
if (hasDependencyChanges) printDiffDependencies(dependencyMap);
|
|
6898
6919
|
console.log("---------------------------------");
|
|
6899
|
-
const
|
|
6900
|
-
type: "confirm",
|
|
6920
|
+
const answer = await prompts({
|
|
6921
|
+
type: !yes && isUndefined(update$1) ? "confirm" : null,
|
|
6901
6922
|
name: "update",
|
|
6902
6923
|
initial: true,
|
|
6903
6924
|
message: c.reset("Do you want to update the files?")
|
|
6904
6925
|
});
|
|
6926
|
+
update$1 ??= answer.update ?? true;
|
|
6905
6927
|
if (update$1) {
|
|
6906
6928
|
spinner.start("Validating methods");
|
|
6907
6929
|
await validateDiff3();
|
|
6908
6930
|
spinner.succeed("Validated methods");
|
|
6909
|
-
const conflictMap = await updateFiles(changeMap, dependencyMap, registryMap, config$1, {
|
|
6931
|
+
const conflictMap = await updateFiles(changeMap, dependencyMap, registryMap, config$1, {
|
|
6932
|
+
concurrent: !sequential,
|
|
6933
|
+
install,
|
|
6934
|
+
yes
|
|
6935
|
+
});
|
|
6910
6936
|
if (Object.keys(conflictMap).length) {
|
|
6911
6937
|
console.log("---------------------------------");
|
|
6912
6938
|
spinner.warn("There are conflicts. Please check the following files:");
|
|
@@ -6923,7 +6949,7 @@ const diff = new Command("diff").description("check for updates against the regi
|
|
|
6923
6949
|
|
|
6924
6950
|
//#endregion
|
|
6925
6951
|
//#region src/commands/init/index.ts
|
|
6926
|
-
const init = new Command("init").description("initialize your project and install dependencies").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("-j, --jsx", "use jsx instead of tsx", false).action(async function({ config: configPath, cwd: cwd$1, jsx, overwrite }) {
|
|
6952
|
+
const init = new Command("init").description("initialize your project and install dependencies.").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("-t, --tag <name>", "tag for the registries (e.g. dev, next).").option("-j, --jsx", "use jsx instead of tsx.", false).option("-y, --yes", "skip all confirmation prompts.", false).option("-m, --monorepo", "enable monorepo mode.").option("--no-monorepo", "disable monorepo mode.").option("-p, --package-name <name>", "package name.").option("-s, --src", "use src/ directory.").option("-i, --install", "install dependencies when choice is monorepo.").option("--no-install", "do not install dependencies when choice is monorepo.").option("-f, --format", "use Prettier.").option("--no-format", "do not use Prettier.").option("-l, --lint", "use ESLint.").option("--no-lint", "do not use ESLint.").option("--outdir <path>", "output directory path.").action(async function({ src, config: configPath, cwd: cwd$1, format: format$2, install, jsx, lint, monorepo, outdir = "", overwrite, packageName = "", tag, yes }) {
|
|
6927
6953
|
const spinner = ora();
|
|
6928
6954
|
try {
|
|
6929
6955
|
const { end } = timer();
|
|
@@ -6934,9 +6960,9 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6934
6960
|
configPath = path$1.resolve(cwd$1, configPath);
|
|
6935
6961
|
let dependencies$1;
|
|
6936
6962
|
let devDependencies$1;
|
|
6937
|
-
|
|
6963
|
+
const answer = await prompts([
|
|
6938
6964
|
{
|
|
6939
|
-
type: "toggle",
|
|
6965
|
+
type: !yes && isUndefined(monorepo) ? "toggle" : null,
|
|
6940
6966
|
name: "monorepo",
|
|
6941
6967
|
active: "Yes",
|
|
6942
6968
|
inactive: "No",
|
|
@@ -6944,19 +6970,19 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6944
6970
|
message: c.reset(`Would you like to use monorepo? (recommended)`)
|
|
6945
6971
|
},
|
|
6946
6972
|
{
|
|
6947
|
-
type: "text",
|
|
6973
|
+
type: !yes && !outdir ? "text" : null,
|
|
6948
6974
|
name: "outdir",
|
|
6949
|
-
initial: (_,
|
|
6950
|
-
message: (_,
|
|
6975
|
+
initial: (_, answer$1) => answer$1.monorepo ?? monorepo ? DEFAULT_PATH.ui.monorepo : DEFAULT_PATH.ui.polyrepo,
|
|
6976
|
+
message: (_, answer$1) => answer$1.monorepo ?? monorepo ? c.reset(`What is the path to the monorepo?`) : c.reset(`What is the path to the directory?`)
|
|
6951
6977
|
},
|
|
6952
6978
|
{
|
|
6953
|
-
type: (_,
|
|
6979
|
+
type: !yes && !packageName ? (_, answer$1) => answer$1.monorepo ?? monorepo ? "text" : null : null,
|
|
6954
6980
|
name: "packageName",
|
|
6955
6981
|
initial: DEFAULT_PACKAGE_NAME.ui,
|
|
6956
6982
|
message: c.reset("What is the package name?")
|
|
6957
6983
|
},
|
|
6958
6984
|
{
|
|
6959
|
-
type: (_,
|
|
6985
|
+
type: !yes && isUndefined(src) ? (_, answer$1) => answer$1.monorepo ?? monorepo ? "toggle" : null : null,
|
|
6960
6986
|
name: "src",
|
|
6961
6987
|
active: "Yes",
|
|
6962
6988
|
inactive: "No",
|
|
@@ -6964,7 +6990,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6964
6990
|
message: c.reset("Would you like your code inside a `src/` directory?")
|
|
6965
6991
|
},
|
|
6966
6992
|
{
|
|
6967
|
-
type: "toggle",
|
|
6993
|
+
type: !yes && isUndefined(format$2) ? "toggle" : null,
|
|
6968
6994
|
name: "format",
|
|
6969
6995
|
active: "Yes",
|
|
6970
6996
|
inactive: "No",
|
|
@@ -6972,7 +6998,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6972
6998
|
message: c.reset(`Would you like to use Prettier?`)
|
|
6973
6999
|
},
|
|
6974
7000
|
{
|
|
6975
|
-
type: "toggle",
|
|
7001
|
+
type: !yes && isUndefined(lint) ? "toggle" : null,
|
|
6976
7002
|
name: "lint",
|
|
6977
7003
|
active: "Yes",
|
|
6978
7004
|
inactive: "No",
|
|
@@ -6980,23 +7006,30 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6980
7006
|
message: c.reset(`Would you like to use ESLint?`)
|
|
6981
7007
|
}
|
|
6982
7008
|
]);
|
|
6983
|
-
|
|
7009
|
+
monorepo ??= answer.monorepo ?? true;
|
|
7010
|
+
src ??= answer.src ?? true;
|
|
7011
|
+
lint ??= answer.lint ?? true;
|
|
7012
|
+
format$2 ??= answer.format ?? true;
|
|
7013
|
+
outdir = (answer.outdir ?? "").replace(/\x17/g, "").trim();
|
|
6984
7014
|
outdir ||= monorepo ? DEFAULT_PATH.ui.monorepo : DEFAULT_PATH.ui.polyrepo;
|
|
6985
|
-
packageName = packageName.replace(/\x17/g, "").trim();
|
|
6986
|
-
packageName ||= DEFAULT_PACKAGE_NAME;
|
|
7015
|
+
packageName = (answer.packageName ?? "").replace(/\x17/g, "").trim();
|
|
7016
|
+
packageName ||= DEFAULT_PACKAGE_NAME.ui;
|
|
6987
7017
|
if (monorepo) config$1.monorepo = monorepo;
|
|
6988
7018
|
if (jsx) config$1.jsx = jsx;
|
|
6989
7019
|
config$1.path = outdir;
|
|
6990
7020
|
config$1.format = { enabled: format$2 };
|
|
6991
7021
|
config$1.lint = { enabled: lint };
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
7022
|
+
if (!yes) {
|
|
7023
|
+
const { generate } = await prompts({
|
|
7024
|
+
type: "confirm",
|
|
7025
|
+
name: "generate",
|
|
7026
|
+
initial: true,
|
|
7027
|
+
message: c.reset(`Generate ${c.cyan(configFileName)}. Proceed?`)
|
|
7028
|
+
});
|
|
7029
|
+
if (!generate) process.exit(0);
|
|
7030
|
+
}
|
|
6999
7031
|
if (!overwrite && existsSync(configPath)) {
|
|
7032
|
+
if (yes) throw new Error(`The config file already exists. Use ${c.cyan("--overwrite")} to overwrite it.`);
|
|
7000
7033
|
const { overwrite: overwrite$1 } = await prompts({
|
|
7001
7034
|
type: "confirm",
|
|
7002
7035
|
name: "overwrite",
|
|
@@ -7010,6 +7043,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7010
7043
|
spinner.succeed(`Generated ${c.cyan(configFileName)}`);
|
|
7011
7044
|
const outdirPath = path$1.resolve(cwd$1, outdir);
|
|
7012
7045
|
if (!overwrite && existsSync(outdirPath)) {
|
|
7046
|
+
if (yes) throw new Error(`The ${c.yellow(outdir)} directory already exists. Use ${c.cyan("--overwrite")} to overwrite it.`);
|
|
7013
7047
|
const { overwrite: overwrite$1 } = await prompts({
|
|
7014
7048
|
type: "confirm",
|
|
7015
7049
|
name: "overwrite",
|
|
@@ -7022,13 +7056,15 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7022
7056
|
spinner.succeed("Cleared directory");
|
|
7023
7057
|
}
|
|
7024
7058
|
if (monorepo) {
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7059
|
+
if (!yes) {
|
|
7060
|
+
const { generate } = await prompts({
|
|
7061
|
+
type: "confirm",
|
|
7062
|
+
name: "generate",
|
|
7063
|
+
initial: true,
|
|
7064
|
+
message: c.reset(`Generate ${c.cyan(packageName)}. Proceed?`)
|
|
7065
|
+
});
|
|
7066
|
+
if (!generate) process.exit(0);
|
|
7067
|
+
}
|
|
7032
7068
|
const tasks = new Listr([
|
|
7033
7069
|
{
|
|
7034
7070
|
task: async (_, task) => {
|
|
@@ -7038,8 +7074,8 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7038
7074
|
await writeFileSafe(targetPath, JSON.stringify({
|
|
7039
7075
|
name: packageName,
|
|
7040
7076
|
...DEFAULT_PACKAGE_JSON,
|
|
7041
|
-
dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.ui.map((dependency) => splitVersion(dependency))),
|
|
7042
|
-
devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.ui.map((dependency) => splitVersion(dependency))),
|
|
7077
|
+
dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.ui.map((dependency) => splitVersion(replaceVersion(dependency, PACKAGE_NAME, tag)))),
|
|
7078
|
+
devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.ui.map((dependency) => splitVersion(replaceVersion(dependency, PACKAGE_NAME, tag)))),
|
|
7043
7079
|
exports: exports$1
|
|
7044
7080
|
}), merge(config$1, { format: { parser: "json" } }));
|
|
7045
7081
|
task.title = `Generated ${c.cyan("package.json")}`;
|
|
@@ -7049,7 +7085,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7049
7085
|
{
|
|
7050
7086
|
task: async (_, task) => {
|
|
7051
7087
|
const targetPath = path$1.resolve(outdirPath, src ? "src" : "");
|
|
7052
|
-
const registry = await fetchRegistry("index");
|
|
7088
|
+
const registry = await fetchRegistry("index", { tag });
|
|
7053
7089
|
let content = registry.sources[0].content;
|
|
7054
7090
|
if (jsx) content = transformTsToJs(content);
|
|
7055
7091
|
await Promise.all([writeFileSafe(path$1.join(targetPath, indexFileName), content, config$1), writeFileSafe(path$1.join(targetPath, REGISTRY_FILE_NAME), JSON.stringify(registry), merge(config$1, { format: { parser: "json" } }))]);
|
|
@@ -7077,27 +7113,29 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7077
7113
|
title: `Generating ${c.cyan("tsconfig.json")}`
|
|
7078
7114
|
});
|
|
7079
7115
|
await tasks.run();
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7116
|
+
if (isUndefined(install)) {
|
|
7117
|
+
install = (await prompts({
|
|
7118
|
+
type: !yes ? "confirm" : null,
|
|
7119
|
+
name: "install",
|
|
7120
|
+
initial: true,
|
|
7121
|
+
message: c.reset(`The workspace is generated. Do you want to install dependencies?`)
|
|
7122
|
+
})).install ?? true;
|
|
7123
|
+
if (install) dependencies$1 = [];
|
|
7124
|
+
} else if (install) dependencies$1 = [];
|
|
7087
7125
|
} else {
|
|
7088
7126
|
const notInstalledDependencies = [];
|
|
7089
7127
|
const notInstalledDevDependencies = [];
|
|
7090
7128
|
await new Listr([{
|
|
7091
7129
|
task: async (_, task) => {
|
|
7092
7130
|
const packageJson$2 = await getPackageJson(cwd$1);
|
|
7093
|
-
notInstalledDependencies.push(...getNotInstalledDependencies(packageJson$2, REQUIRED_DEPENDENCIES.ui));
|
|
7094
|
-
notInstalledDevDependencies.push(...getNotInstalledDependencies(packageJson$2, REQUIRED_DEV_DEPENDENCIES.ui));
|
|
7131
|
+
notInstalledDependencies.push(...getNotInstalledDependencies(packageJson$2, REQUIRED_DEPENDENCIES.ui.map((dependency) => replaceVersion(dependency, PACKAGE_NAME, tag))));
|
|
7132
|
+
notInstalledDevDependencies.push(...getNotInstalledDependencies(packageJson$2, REQUIRED_DEV_DEPENDENCIES.ui.map((dependency) => replaceVersion(dependency, PACKAGE_NAME, tag))));
|
|
7095
7133
|
task.title = `Checked ${c.cyan("package.json")} dependencies`;
|
|
7096
7134
|
},
|
|
7097
7135
|
title: `Checking ${c.cyan("package.json")} dependencies`
|
|
7098
7136
|
}, {
|
|
7099
7137
|
task: async (_, task) => {
|
|
7100
|
-
const registry = await fetchRegistry("index");
|
|
7138
|
+
const registry = await fetchRegistry("index", { tag });
|
|
7101
7139
|
let content = registry.sources[0].content;
|
|
7102
7140
|
if (jsx) content = transformTsToJs(content);
|
|
7103
7141
|
await Promise.all([writeFileSafe(path$1.resolve(outdirPath, indexFileName), content, config$1), writeFileSafe(path$1.resolve(outdirPath, REGISTRY_FILE_NAME), JSON.stringify(registry), merge(config$1, { format: { parser: "json" } }))]);
|
|
@@ -7107,19 +7145,19 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7107
7145
|
}], { concurrent: true }).run();
|
|
7108
7146
|
if (notInstalledDependencies.length || notInstalledDevDependencies.length) {
|
|
7109
7147
|
const colorizedNames = [...notInstalledDependencies, ...notInstalledDevDependencies].map((value) => c.cyan(isObject(value) ? value.current ? `${value.name}@${value.current}->${c.red(value.wanted)}` : value.name : value));
|
|
7110
|
-
|
|
7111
|
-
type: "confirm",
|
|
7148
|
+
if (isUndefined(install)) install = (await prompts({
|
|
7149
|
+
type: !yes ? "confirm" : null,
|
|
7112
7150
|
name: "install",
|
|
7113
7151
|
initial: true,
|
|
7114
7152
|
message: c.reset([`The following dependencies are not installed: ${colorizedNames.join(", ")}.`, "Do you want to install them?"].join(" "))
|
|
7115
|
-
});
|
|
7153
|
+
})).install ?? true;
|
|
7116
7154
|
if (install) {
|
|
7117
7155
|
dependencies$1 = notInstalledDependencies.map(getPackageNameWithVersion);
|
|
7118
7156
|
devDependencies$1 = notInstalledDevDependencies.map(getPackageNameWithVersion);
|
|
7119
7157
|
}
|
|
7120
7158
|
}
|
|
7121
7159
|
}
|
|
7122
|
-
if (dependencies$1 || devDependencies$1) {
|
|
7160
|
+
if (install && (dependencies$1 || devDependencies$1)) {
|
|
7123
7161
|
spinner.start("Installing dependencies");
|
|
7124
7162
|
if (dependencies$1) await installDependencies(dependencies$1, { cwd: cwd$1 });
|
|
7125
7163
|
if (devDependencies$1) await installDependencies(devDependencies$1, {
|
|
@@ -7152,7 +7190,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7152
7190
|
|
|
7153
7191
|
//#endregion
|
|
7154
7192
|
//#region src/commands/theme/index.ts
|
|
7155
|
-
const theme = new Command("theme").description("generate theme to your project").argument("[path]", "path to the theme directory").option("--cwd <path>", "current working directory", cwd).option("-c, --config <path>", "path to the config file", CONFIG_FILE_NAME).option("-o, --overwrite", "overwrite existing directory.", false).option("-j, --js", "use js instead of ts").option("-f, --format", "format the output files.").option("-l, --lint", "lint the output files.").action(async function(themePath, { config: configPath, cwd: cwd$1, format: format$2, js, lint, overwrite }) {
|
|
7193
|
+
const theme = new Command("theme").description("generate theme to your project.").argument("[path]", "path to the theme directory.").option("--cwd <path>", "current working directory.", cwd).option("-c, --config <path>", "path to the config file.", CONFIG_FILE_NAME).option("-o, --overwrite", "overwrite existing directory.", false).option("-j, --js", "use js instead of ts.").option("-y, --yes", "skip all confirmation prompts.", false).option("-p, --package-name <name>", "package name (for monorepo).").option("-s, --src", "use src/ directory.").option("--no-src", "do not use src/ directory.").option("-i, --install", "install dependencies when choice is monorepo.").option("--no-install", "do not install dependencies when choice is monorepo.").option("-f, --format", "format the output files.").option("--no-format", "do not format the output files.").option("-l, --lint", "lint the output files.").option("--no-lint", "do not lint the output files.").option("-t, --tag <name>", "tag for the registries (e.g. dev, next).").action(async function(themePath, { src, config: configPath, cwd: cwd$1, format: format$2, install, js, lint, overwrite, packageName, tag, yes }) {
|
|
7156
7194
|
const spinner = ora();
|
|
7157
7195
|
try {
|
|
7158
7196
|
const { end } = timer();
|
|
@@ -7168,42 +7206,39 @@ const theme = new Command("theme").description("generate theme to your project")
|
|
|
7168
7206
|
spinner.succeed("Fetched config");
|
|
7169
7207
|
themePath ??= config$1.theme?.path;
|
|
7170
7208
|
const defaultThemePath = config$1.monorepo ? DEFAULT_PATH.theme.monorepo : DEFAULT_PATH.theme.polyrepo;
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
outdir ||= defaultThemePath;
|
|
7180
|
-
themePath = outdir;
|
|
7181
|
-
}
|
|
7209
|
+
const answer = await prompts({
|
|
7210
|
+
type: !yes && !themePath ? "text" : null,
|
|
7211
|
+
name: "themePath",
|
|
7212
|
+
initial: defaultThemePath,
|
|
7213
|
+
message: "What is the path to the theme directory?"
|
|
7214
|
+
});
|
|
7215
|
+
themePath ??= (answer.themePath ?? "").replace(/\x17/g, "").trim();
|
|
7216
|
+
themePath ||= defaultThemePath;
|
|
7182
7217
|
const monorepoConfig = {
|
|
7183
7218
|
src: false,
|
|
7184
7219
|
packageName: ""
|
|
7185
7220
|
};
|
|
7186
7221
|
if (config$1.monorepo) {
|
|
7187
|
-
|
|
7188
|
-
type: "text",
|
|
7222
|
+
const answer$1 = await prompts([{
|
|
7223
|
+
type: !yes && !packageName ? "text" : null,
|
|
7189
7224
|
name: "packageName",
|
|
7190
7225
|
initial: DEFAULT_PACKAGE_NAME.theme,
|
|
7191
7226
|
message: c.reset("What is the package name?")
|
|
7192
7227
|
}, {
|
|
7193
|
-
type: "toggle",
|
|
7228
|
+
type: !yes && isUndefined(src) ? "toggle" : null,
|
|
7194
7229
|
name: "src",
|
|
7195
7230
|
active: "Yes",
|
|
7196
7231
|
inactive: "No",
|
|
7197
7232
|
initial: true,
|
|
7198
7233
|
message: c.reset("Would you like your code inside a `src/` directory?")
|
|
7199
7234
|
}]);
|
|
7200
|
-
packageName = packageName.replace(/\x17/g, "").trim();
|
|
7201
|
-
|
|
7202
|
-
monorepoConfig.
|
|
7203
|
-
monorepoConfig.packageName = packageName;
|
|
7235
|
+
packageName = (answer$1.packageName ?? "").replace(/\x17/g, "").trim();
|
|
7236
|
+
monorepoConfig.src = answer$1.src ?? true;
|
|
7237
|
+
monorepoConfig.packageName = packageName || DEFAULT_PACKAGE_NAME.theme;
|
|
7204
7238
|
}
|
|
7205
7239
|
const outdirPath = path$1.resolve(cwd$1, themePath);
|
|
7206
7240
|
if (!overwrite && existsSync(outdirPath)) {
|
|
7241
|
+
if (yes) throw new Error(`The directory already exists. Use ${c.cyan("--overwrite")} to overwrite it.`);
|
|
7207
7242
|
const { overwrite: overwrite$1 } = await prompts({
|
|
7208
7243
|
type: "confirm",
|
|
7209
7244
|
name: "overwrite",
|
|
@@ -7216,7 +7251,7 @@ const theme = new Command("theme").description("generate theme to your project")
|
|
|
7216
7251
|
spinner.succeed("Cleared directory");
|
|
7217
7252
|
}
|
|
7218
7253
|
spinner.start("Fetching registry");
|
|
7219
|
-
const registry = await fetchRegistry("theme");
|
|
7254
|
+
const registry = await fetchRegistry("theme", { tag });
|
|
7220
7255
|
spinner.succeed("Fetched registry");
|
|
7221
7256
|
const tasks = new Listr([{
|
|
7222
7257
|
task: async (_, task) => {
|
|
@@ -7250,8 +7285,8 @@ const theme = new Command("theme").description("generate theme to your project")
|
|
|
7250
7285
|
await writeFileSafe(targetPath, JSON.stringify({
|
|
7251
7286
|
name: monorepoConfig.packageName,
|
|
7252
7287
|
...DEFAULT_PACKAGE_JSON,
|
|
7253
|
-
dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.theme.map((dependency) => splitVersion(dependency))),
|
|
7254
|
-
devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.theme.map((dependency) => splitVersion(dependency))),
|
|
7288
|
+
dependencies: Object.fromEntries(REQUIRED_DEPENDENCIES.theme.map((dependency) => splitVersion(replaceVersion(dependency, PACKAGE_NAME, tag)))),
|
|
7289
|
+
devDependencies: Object.fromEntries(REQUIRED_DEV_DEPENDENCIES.theme.map((dependency) => splitVersion(replaceVersion(dependency, PACKAGE_NAME, tag)))),
|
|
7255
7290
|
exports: exports$1
|
|
7256
7291
|
}), merge(config$1, { format: { parser: "json" } }));
|
|
7257
7292
|
task.title = `Generated ${c.cyan("package.json")}`;
|
|
@@ -7270,12 +7305,13 @@ const theme = new Command("theme").description("generate theme to your project")
|
|
|
7270
7305
|
});
|
|
7271
7306
|
await tasks.run();
|
|
7272
7307
|
if (config$1.monorepo) {
|
|
7273
|
-
const
|
|
7274
|
-
type: "confirm",
|
|
7308
|
+
const answer$1 = await prompts({
|
|
7309
|
+
type: !yes && isUndefined(install) ? "confirm" : null,
|
|
7275
7310
|
name: "install",
|
|
7276
7311
|
initial: true,
|
|
7277
7312
|
message: c.reset(`The theme is generated. Do you want to install dependencies?`)
|
|
7278
7313
|
});
|
|
7314
|
+
install ??= answer$1.install ?? true;
|
|
7279
7315
|
if (install) {
|
|
7280
7316
|
spinner.start("Installing dependencies");
|
|
7281
7317
|
await installDependencies([], { cwd: cwd$1 });
|
|
@@ -7465,9 +7501,9 @@ function generateThemeTokens(theme$1, { internal = false, theme: { responsive =
|
|
|
7465
7501
|
`}`
|
|
7466
7502
|
].join("\n");
|
|
7467
7503
|
else return [
|
|
7468
|
-
`import type { UsageThemeTokens } from "
|
|
7504
|
+
`import type { UsageThemeTokens } from "${PACKAGE_NAME}"`,
|
|
7469
7505
|
``,
|
|
7470
|
-
`declare module
|
|
7506
|
+
`declare module "${PACKAGE_NAME}" {`,
|
|
7471
7507
|
` interface CustomThemeTokens extends UsageThemeTokens {`,
|
|
7472
7508
|
` ${print({
|
|
7473
7509
|
...tokens$1,
|
|
@@ -7490,7 +7526,7 @@ async function getTheme(path$9, cwd$1) {
|
|
|
7490
7526
|
theme: theme$1
|
|
7491
7527
|
};
|
|
7492
7528
|
}
|
|
7493
|
-
const tokens = new Command("tokens").description("generate theme typings").argument("[path]", "path to the theme file").option("--cwd <path>", "current working directory", cwd).option("-c, --config <path>", "path to the config file", CONFIG_FILE_NAME).option("-o, --out <path>", `output path
|
|
7529
|
+
const tokens = new Command("tokens").description("generate theme typings.").argument("[path]", "path to the theme file.").option("--cwd <path>", "current working directory.", cwd).option("-c, --config <path>", "path to the config file.", CONFIG_FILE_NAME).option("-o, --out <path>", `output path.`).option("-f, --format", "format the output file.").option("--no-format", "do not format the output file.").option("-l, --lint", "lint the output file.").option("--no-lint", "do not lint the output file.").option("--internal", "generate internal tokens.", false).action(async function(inputPath, { config: configPath, cwd: cwd$1, format: format$2, internal, lint, out: outPath }) {
|
|
7494
7530
|
const spinner = ora();
|
|
7495
7531
|
try {
|
|
7496
7532
|
const { end } = timer();
|
|
@@ -7541,7 +7577,7 @@ const tokens = new Command("tokens").description("generate theme typings").argum
|
|
|
7541
7577
|
|
|
7542
7578
|
//#endregion
|
|
7543
7579
|
//#region src/commands/update/index.ts
|
|
7544
|
-
const update = new Command("update").description("update components in your project").argument("[components...]", "components to update").option("--cwd <path>", "current working directory", cwd).option("-c, --config <path>", "path to the config file", CONFIG_FILE_NAME).option("-
|
|
7580
|
+
const update = new Command("update").description("update components in your project.").argument("[components...]", "components to update.").option("--cwd <path>", "current working directory.", cwd).option("-c, --config <path>", "path to the config file.", CONFIG_FILE_NAME).option("-s, --sequential", "run tasks sequentially.", false).option("-F, --force", "force update, overwriting local changes.", false).option("-y, --yes", "skip all confirmation prompts.", false).option("-i, --install", "install dependencies.").option("--no-install", "do not install dependencies.").option("-f, --format", "format the output files.").option("--no-format", "do not format the output files.").option("-l, --lint", "lint the output files.").option("--no-lint", "do not lint the output files.").option("-t, --tag <name>", "tag for the registries (e.g. dev, next).").action(async function(targetNames, { config: configPath, cwd: cwd$1, force, format: format$2, install, lint, sequential, tag, yes }) {
|
|
7545
7581
|
const spinner = ora();
|
|
7546
7582
|
try {
|
|
7547
7583
|
const { end } = timer();
|
|
@@ -7589,6 +7625,7 @@ const update = new Command("update").description("update components in your proj
|
|
|
7589
7625
|
const { registryMap } = await getRegistriesAndFiles(componentNames, config$1, {
|
|
7590
7626
|
concurrent: !sequential,
|
|
7591
7627
|
index,
|
|
7628
|
+
tag,
|
|
7592
7629
|
theme: theme$1
|
|
7593
7630
|
});
|
|
7594
7631
|
const { changeMap, dependencyMap } = await getDiff(generatedNames, registryMap, config$1, !sequential);
|
|
@@ -7600,7 +7637,8 @@ const update = new Command("update").description("update components in your proj
|
|
|
7600
7637
|
const conflictMap = await updateFiles(changeMap, dependencyMap, registryMap, config$1, {
|
|
7601
7638
|
concurrent: !sequential,
|
|
7602
7639
|
force,
|
|
7603
|
-
install
|
|
7640
|
+
install,
|
|
7641
|
+
yes
|
|
7604
7642
|
});
|
|
7605
7643
|
if (Object.keys(conflictMap).length) {
|
|
7606
7644
|
console.log("---------------------------------");
|