@yamada-ui/cli 2.1.0-dev-20260308051035 → 2.1.0-dev-20260310090858
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 +114 -91
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6268,7 +6268,7 @@ async function generateSources(dirPath, registry, config$1, generatedNames = [])
|
|
|
6268
6268
|
|
|
6269
6269
|
//#endregion
|
|
6270
6270
|
//#region src/commands/add/index.ts
|
|
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("-
|
|
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 }) {
|
|
6272
6272
|
const spinner = ora();
|
|
6273
6273
|
try {
|
|
6274
6274
|
const { end } = timer();
|
|
@@ -6284,14 +6284,17 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6284
6284
|
let generatedNameMap;
|
|
6285
6285
|
const omittedGeneratedNames = [];
|
|
6286
6286
|
if (!componentNames.length) {
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
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
|
+
}
|
|
6294
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.`);
|
|
6295
6298
|
const { overwrite: overwrite$1 } = await prompts({
|
|
6296
6299
|
type: "confirm",
|
|
6297
6300
|
name: "overwrite",
|
|
@@ -6310,6 +6313,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6310
6313
|
const existsNames = componentNames.filter((name$1) => generatedNames.includes(name$1));
|
|
6311
6314
|
spinner.succeed("Got generated components");
|
|
6312
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.`);
|
|
6313
6317
|
const colorizedNames = existsNames.map((name$1) => c.yellow(name$1));
|
|
6314
6318
|
const { overwrite: overwrite$1 } = await prompts({
|
|
6315
6319
|
type: "confirm",
|
|
@@ -6337,14 +6341,16 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6337
6341
|
]).flat().filter((dependent) => omittedGeneratedNames.includes(dependent)))];
|
|
6338
6342
|
spinner.succeed("Fetched registries");
|
|
6339
6343
|
if (componentNames.length !== registryNames.length) {
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
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
|
+
}
|
|
6348
6354
|
}
|
|
6349
6355
|
const targetNames = [...new Set([...omittedGeneratedNames, ...registryNames])];
|
|
6350
6356
|
const tasks = new Listr(Object.entries(registries).map(([name$1, registry]) => {
|
|
@@ -6360,7 +6366,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6360
6366
|
};
|
|
6361
6367
|
}).filter((task) => !isUndefined(task)), { concurrent: !sequential });
|
|
6362
6368
|
if (affectedNames.length && generatedNameMap) {
|
|
6363
|
-
if (!overwrite) {
|
|
6369
|
+
if (!overwrite) if (!yes) {
|
|
6364
6370
|
const colorizedNames = affectedNames.map((name$1) => c.yellow(name$1));
|
|
6365
6371
|
const { update: update$1 } = await prompts({
|
|
6366
6372
|
type: "confirm",
|
|
@@ -6368,8 +6374,8 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6368
6374
|
initial: true,
|
|
6369
6375
|
message: c.reset([`The following generated files will be updated: ${colorizedNames.join(", ")}.`, "Do you want to update them?"].join(" "))
|
|
6370
6376
|
});
|
|
6371
|
-
|
|
6372
|
-
}
|
|
6377
|
+
overwrite = update$1;
|
|
6378
|
+
} else overwrite = true;
|
|
6373
6379
|
if (overwrite) Object.entries(generatedNameMap).forEach(([section, names]) => {
|
|
6374
6380
|
names.forEach((name$1) => {
|
|
6375
6381
|
if (!affectedNames.includes(name$1)) return;
|
|
@@ -6427,7 +6433,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6427
6433
|
spinner.start(`Checking ${c.cyan("package.json")} dependencies`);
|
|
6428
6434
|
const notInstalledDependencies = getNotInstalledDependencies(await getPackageJson(targetPath), dependencies$1);
|
|
6429
6435
|
spinner.succeed(`Checked ${c.cyan("package.json")} dependencies`);
|
|
6430
|
-
if (!install && notInstalledDependencies.length) {
|
|
6436
|
+
if (!install && notInstalledDependencies.length) if (!yes) {
|
|
6431
6437
|
const colorizedNames = notInstalledDependencies.map((value) => c.yellow(isObject(value) ? value.current ? `${value.name}@${value.current}->${c.red(value.wanted)}` : value.name : value));
|
|
6432
6438
|
const { proceed } = await prompts({
|
|
6433
6439
|
type: "confirm",
|
|
@@ -6436,7 +6442,7 @@ const add = new Command("add").description("add a component to your project").ar
|
|
|
6436
6442
|
message: c.reset([`The following dependencies are not installed: ${colorizedNames.join(", ")}.`, "Do you want to install them?"].join(" "))
|
|
6437
6443
|
});
|
|
6438
6444
|
install = proceed;
|
|
6439
|
-
}
|
|
6445
|
+
} else install = true;
|
|
6440
6446
|
if (install) tasks.add({
|
|
6441
6447
|
task: async (_, task) => {
|
|
6442
6448
|
await installDependencies(notInstalledDependencies.map(getPackageNameWithVersion), { cwd: targetPath });
|
|
@@ -6650,7 +6656,7 @@ async function mergeContent(remotePath, localPath, currentPath, fallback) {
|
|
|
6650
6656
|
content
|
|
6651
6657
|
};
|
|
6652
6658
|
}
|
|
6653
|
-
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 } = {}) {
|
|
6654
6660
|
const conflictMap = {};
|
|
6655
6661
|
const disabledFormatAndLint = {
|
|
6656
6662
|
format: { enabled: false },
|
|
@@ -6704,13 +6710,14 @@ async function updateFiles(changeMap, { add: add$1, remove, update: update$1 },
|
|
|
6704
6710
|
title: `Changing ${c.cyan(componentName)}`
|
|
6705
6711
|
})), { concurrent }).run();
|
|
6706
6712
|
if (!install && (add$1.length || remove.length || update$1.length)) {
|
|
6707
|
-
const
|
|
6708
|
-
type: "confirm",
|
|
6713
|
+
const answer = await prompts({
|
|
6714
|
+
type: !yes && isUndefined(install) ? "confirm" : null,
|
|
6709
6715
|
name: "install",
|
|
6710
6716
|
initial: true,
|
|
6711
6717
|
message: c.reset("There are dependency updates. Do you want to install them?")
|
|
6712
6718
|
});
|
|
6713
|
-
|
|
6719
|
+
install ??= answer.install ?? true;
|
|
6720
|
+
if (!install) return conflictMap;
|
|
6714
6721
|
}
|
|
6715
6722
|
const cwd$1 = config$1.monorepo ? config$1.paths.ui.root : config$1.cwd;
|
|
6716
6723
|
remove.push(...update$1.map(({ name: name$1 }) => name$1));
|
|
@@ -6843,7 +6850,7 @@ function printDiffDependencies({ add: add$1, remove, update: update$1 }) {
|
|
|
6843
6850
|
|
|
6844
6851
|
//#endregion
|
|
6845
6852
|
//#region src/commands/diff/index.ts
|
|
6846
|
-
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("-t, --tag <name>", "tag for the registries (e.g. dev, next)").action(async function(targetName, { config: configPath, cwd: cwd$1, detail, sequential, tag }) {
|
|
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 }) {
|
|
6847
6854
|
const spinner = ora();
|
|
6848
6855
|
try {
|
|
6849
6856
|
const { end } = timer();
|
|
@@ -6910,17 +6917,22 @@ const diff = new Command("diff").description("check for updates against the regi
|
|
|
6910
6917
|
}
|
|
6911
6918
|
if (hasDependencyChanges) printDiffDependencies(dependencyMap);
|
|
6912
6919
|
console.log("---------------------------------");
|
|
6913
|
-
const
|
|
6914
|
-
type: "confirm",
|
|
6920
|
+
const answer = await prompts({
|
|
6921
|
+
type: !yes && isUndefined(update$1) ? "confirm" : null,
|
|
6915
6922
|
name: "update",
|
|
6916
6923
|
initial: true,
|
|
6917
6924
|
message: c.reset("Do you want to update the files?")
|
|
6918
6925
|
});
|
|
6926
|
+
update$1 ??= answer.update ?? true;
|
|
6919
6927
|
if (update$1) {
|
|
6920
6928
|
spinner.start("Validating methods");
|
|
6921
6929
|
await validateDiff3();
|
|
6922
6930
|
spinner.succeed("Validated methods");
|
|
6923
|
-
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
|
+
});
|
|
6924
6936
|
if (Object.keys(conflictMap).length) {
|
|
6925
6937
|
console.log("---------------------------------");
|
|
6926
6938
|
spinner.warn("There are conflicts. Please check the following files:");
|
|
@@ -6937,7 +6949,7 @@ const diff = new Command("diff").description("check for updates against the regi
|
|
|
6937
6949
|
|
|
6938
6950
|
//#endregion
|
|
6939
6951
|
//#region src/commands/init/index.ts
|
|
6940
|
-
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).action(async function({ config: configPath, cwd: cwd$1, jsx, overwrite, tag }) {
|
|
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 }) {
|
|
6941
6953
|
const spinner = ora();
|
|
6942
6954
|
try {
|
|
6943
6955
|
const { end } = timer();
|
|
@@ -6948,9 +6960,9 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6948
6960
|
configPath = path$1.resolve(cwd$1, configPath);
|
|
6949
6961
|
let dependencies$1;
|
|
6950
6962
|
let devDependencies$1;
|
|
6951
|
-
|
|
6963
|
+
const answer = await prompts([
|
|
6952
6964
|
{
|
|
6953
|
-
type: "toggle",
|
|
6965
|
+
type: !yes && isUndefined(monorepo) ? "toggle" : null,
|
|
6954
6966
|
name: "monorepo",
|
|
6955
6967
|
active: "Yes",
|
|
6956
6968
|
inactive: "No",
|
|
@@ -6958,19 +6970,19 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6958
6970
|
message: c.reset(`Would you like to use monorepo? (recommended)`)
|
|
6959
6971
|
},
|
|
6960
6972
|
{
|
|
6961
|
-
type: "text",
|
|
6973
|
+
type: !yes && !outdir ? "text" : null,
|
|
6962
6974
|
name: "outdir",
|
|
6963
|
-
initial: (_,
|
|
6964
|
-
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?`)
|
|
6965
6977
|
},
|
|
6966
6978
|
{
|
|
6967
|
-
type: (_,
|
|
6979
|
+
type: !yes && !packageName ? (_, answer$1) => answer$1.monorepo ?? monorepo ? "text" : null : null,
|
|
6968
6980
|
name: "packageName",
|
|
6969
6981
|
initial: DEFAULT_PACKAGE_NAME.ui,
|
|
6970
6982
|
message: c.reset("What is the package name?")
|
|
6971
6983
|
},
|
|
6972
6984
|
{
|
|
6973
|
-
type: (_,
|
|
6985
|
+
type: !yes && isUndefined(src) ? (_, answer$1) => answer$1.monorepo ?? monorepo ? "toggle" : null : null,
|
|
6974
6986
|
name: "src",
|
|
6975
6987
|
active: "Yes",
|
|
6976
6988
|
inactive: "No",
|
|
@@ -6978,7 +6990,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6978
6990
|
message: c.reset("Would you like your code inside a `src/` directory?")
|
|
6979
6991
|
},
|
|
6980
6992
|
{
|
|
6981
|
-
type: "toggle",
|
|
6993
|
+
type: !yes && isUndefined(format$2) ? "toggle" : null,
|
|
6982
6994
|
name: "format",
|
|
6983
6995
|
active: "Yes",
|
|
6984
6996
|
inactive: "No",
|
|
@@ -6986,7 +6998,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6986
6998
|
message: c.reset(`Would you like to use Prettier?`)
|
|
6987
6999
|
},
|
|
6988
7000
|
{
|
|
6989
|
-
type: "toggle",
|
|
7001
|
+
type: !yes && isUndefined(lint) ? "toggle" : null,
|
|
6990
7002
|
name: "lint",
|
|
6991
7003
|
active: "Yes",
|
|
6992
7004
|
inactive: "No",
|
|
@@ -6994,23 +7006,30 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
6994
7006
|
message: c.reset(`Would you like to use ESLint?`)
|
|
6995
7007
|
}
|
|
6996
7008
|
]);
|
|
6997
|
-
|
|
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();
|
|
6998
7014
|
outdir ||= monorepo ? DEFAULT_PATH.ui.monorepo : DEFAULT_PATH.ui.polyrepo;
|
|
6999
|
-
packageName = packageName.replace(/\x17/g, "").trim();
|
|
7000
|
-
packageName ||= DEFAULT_PACKAGE_NAME;
|
|
7015
|
+
packageName = (answer.packageName ?? "").replace(/\x17/g, "").trim();
|
|
7016
|
+
packageName ||= DEFAULT_PACKAGE_NAME.ui;
|
|
7001
7017
|
if (monorepo) config$1.monorepo = monorepo;
|
|
7002
7018
|
if (jsx) config$1.jsx = jsx;
|
|
7003
7019
|
config$1.path = outdir;
|
|
7004
7020
|
config$1.format = { enabled: format$2 };
|
|
7005
7021
|
config$1.lint = { enabled: lint };
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
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
|
+
}
|
|
7013
7031
|
if (!overwrite && existsSync(configPath)) {
|
|
7032
|
+
if (yes) throw new Error(`The config file already exists. Use ${c.cyan("--overwrite")} to overwrite it.`);
|
|
7014
7033
|
const { overwrite: overwrite$1 } = await prompts({
|
|
7015
7034
|
type: "confirm",
|
|
7016
7035
|
name: "overwrite",
|
|
@@ -7024,6 +7043,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7024
7043
|
spinner.succeed(`Generated ${c.cyan(configFileName)}`);
|
|
7025
7044
|
const outdirPath = path$1.resolve(cwd$1, outdir);
|
|
7026
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.`);
|
|
7027
7047
|
const { overwrite: overwrite$1 } = await prompts({
|
|
7028
7048
|
type: "confirm",
|
|
7029
7049
|
name: "overwrite",
|
|
@@ -7036,13 +7056,15 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7036
7056
|
spinner.succeed("Cleared directory");
|
|
7037
7057
|
}
|
|
7038
7058
|
if (monorepo) {
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
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
|
+
}
|
|
7046
7068
|
const tasks = new Listr([
|
|
7047
7069
|
{
|
|
7048
7070
|
task: async (_, task) => {
|
|
@@ -7091,13 +7113,15 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7091
7113
|
title: `Generating ${c.cyan("tsconfig.json")}`
|
|
7092
7114
|
});
|
|
7093
7115
|
await tasks.run();
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
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 = [];
|
|
7101
7125
|
} else {
|
|
7102
7126
|
const notInstalledDependencies = [];
|
|
7103
7127
|
const notInstalledDevDependencies = [];
|
|
@@ -7121,19 +7145,19 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7121
7145
|
}], { concurrent: true }).run();
|
|
7122
7146
|
if (notInstalledDependencies.length || notInstalledDevDependencies.length) {
|
|
7123
7147
|
const colorizedNames = [...notInstalledDependencies, ...notInstalledDevDependencies].map((value) => c.cyan(isObject(value) ? value.current ? `${value.name}@${value.current}->${c.red(value.wanted)}` : value.name : value));
|
|
7124
|
-
|
|
7125
|
-
type: "confirm",
|
|
7148
|
+
if (isUndefined(install)) install = (await prompts({
|
|
7149
|
+
type: !yes ? "confirm" : null,
|
|
7126
7150
|
name: "install",
|
|
7127
7151
|
initial: true,
|
|
7128
7152
|
message: c.reset([`The following dependencies are not installed: ${colorizedNames.join(", ")}.`, "Do you want to install them?"].join(" "))
|
|
7129
|
-
});
|
|
7153
|
+
})).install ?? true;
|
|
7130
7154
|
if (install) {
|
|
7131
7155
|
dependencies$1 = notInstalledDependencies.map(getPackageNameWithVersion);
|
|
7132
7156
|
devDependencies$1 = notInstalledDevDependencies.map(getPackageNameWithVersion);
|
|
7133
7157
|
}
|
|
7134
7158
|
}
|
|
7135
7159
|
}
|
|
7136
|
-
if (dependencies$1 || devDependencies$1) {
|
|
7160
|
+
if (install && (dependencies$1 || devDependencies$1)) {
|
|
7137
7161
|
spinner.start("Installing dependencies");
|
|
7138
7162
|
if (dependencies$1) await installDependencies(dependencies$1, { cwd: cwd$1 });
|
|
7139
7163
|
if (devDependencies$1) await installDependencies(devDependencies$1, {
|
|
@@ -7166,7 +7190,7 @@ const init = new Command("init").description("initialize your project and instal
|
|
|
7166
7190
|
|
|
7167
7191
|
//#endregion
|
|
7168
7192
|
//#region src/commands/theme/index.ts
|
|
7169
|
-
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.").option("-t, --tag <name>", "tag for the registries (e.g. dev, next)").action(async function(themePath, { config: configPath, cwd: cwd$1, format: format$2, js, lint, overwrite, tag }) {
|
|
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 }) {
|
|
7170
7194
|
const spinner = ora();
|
|
7171
7195
|
try {
|
|
7172
7196
|
const { end } = timer();
|
|
@@ -7182,42 +7206,39 @@ const theme = new Command("theme").description("generate theme to your project")
|
|
|
7182
7206
|
spinner.succeed("Fetched config");
|
|
7183
7207
|
themePath ??= config$1.theme?.path;
|
|
7184
7208
|
const defaultThemePath = config$1.monorepo ? DEFAULT_PATH.theme.monorepo : DEFAULT_PATH.theme.polyrepo;
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
outdir ||= defaultThemePath;
|
|
7194
|
-
themePath = outdir;
|
|
7195
|
-
}
|
|
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;
|
|
7196
7217
|
const monorepoConfig = {
|
|
7197
7218
|
src: false,
|
|
7198
7219
|
packageName: ""
|
|
7199
7220
|
};
|
|
7200
7221
|
if (config$1.monorepo) {
|
|
7201
|
-
|
|
7202
|
-
type: "text",
|
|
7222
|
+
const answer$1 = await prompts([{
|
|
7223
|
+
type: !yes && !packageName ? "text" : null,
|
|
7203
7224
|
name: "packageName",
|
|
7204
7225
|
initial: DEFAULT_PACKAGE_NAME.theme,
|
|
7205
7226
|
message: c.reset("What is the package name?")
|
|
7206
7227
|
}, {
|
|
7207
|
-
type: "toggle",
|
|
7228
|
+
type: !yes && isUndefined(src) ? "toggle" : null,
|
|
7208
7229
|
name: "src",
|
|
7209
7230
|
active: "Yes",
|
|
7210
7231
|
inactive: "No",
|
|
7211
7232
|
initial: true,
|
|
7212
7233
|
message: c.reset("Would you like your code inside a `src/` directory?")
|
|
7213
7234
|
}]);
|
|
7214
|
-
packageName = packageName.replace(/\x17/g, "").trim();
|
|
7215
|
-
|
|
7216
|
-
monorepoConfig.
|
|
7217
|
-
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;
|
|
7218
7238
|
}
|
|
7219
7239
|
const outdirPath = path$1.resolve(cwd$1, themePath);
|
|
7220
7240
|
if (!overwrite && existsSync(outdirPath)) {
|
|
7241
|
+
if (yes) throw new Error(`The directory already exists. Use ${c.cyan("--overwrite")} to overwrite it.`);
|
|
7221
7242
|
const { overwrite: overwrite$1 } = await prompts({
|
|
7222
7243
|
type: "confirm",
|
|
7223
7244
|
name: "overwrite",
|
|
@@ -7284,12 +7305,13 @@ const theme = new Command("theme").description("generate theme to your project")
|
|
|
7284
7305
|
});
|
|
7285
7306
|
await tasks.run();
|
|
7286
7307
|
if (config$1.monorepo) {
|
|
7287
|
-
const
|
|
7288
|
-
type: "confirm",
|
|
7308
|
+
const answer$1 = await prompts({
|
|
7309
|
+
type: !yes && isUndefined(install) ? "confirm" : null,
|
|
7289
7310
|
name: "install",
|
|
7290
7311
|
initial: true,
|
|
7291
7312
|
message: c.reset(`The theme is generated. Do you want to install dependencies?`)
|
|
7292
7313
|
});
|
|
7314
|
+
install ??= answer$1.install ?? true;
|
|
7293
7315
|
if (install) {
|
|
7294
7316
|
spinner.start("Installing dependencies");
|
|
7295
7317
|
await installDependencies([], { cwd: cwd$1 });
|
|
@@ -7504,7 +7526,7 @@ async function getTheme(path$9, cwd$1) {
|
|
|
7504
7526
|
theme: theme$1
|
|
7505
7527
|
};
|
|
7506
7528
|
}
|
|
7507
|
-
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 }) {
|
|
7508
7530
|
const spinner = ora();
|
|
7509
7531
|
try {
|
|
7510
7532
|
const { end } = timer();
|
|
@@ -7555,7 +7577,7 @@ const tokens = new Command("tokens").description("generate theme typings").argum
|
|
|
7555
7577
|
|
|
7556
7578
|
//#endregion
|
|
7557
7579
|
//#region src/commands/update/index.ts
|
|
7558
|
-
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 }) {
|
|
7559
7581
|
const spinner = ora();
|
|
7560
7582
|
try {
|
|
7561
7583
|
const { end } = timer();
|
|
@@ -7615,7 +7637,8 @@ const update = new Command("update").description("update components in your proj
|
|
|
7615
7637
|
const conflictMap = await updateFiles(changeMap, dependencyMap, registryMap, config$1, {
|
|
7616
7638
|
concurrent: !sequential,
|
|
7617
7639
|
force,
|
|
7618
|
-
install
|
|
7640
|
+
install,
|
|
7641
|
+
yes
|
|
7619
7642
|
});
|
|
7620
7643
|
if (Object.keys(conflictMap).length) {
|
|
7621
7644
|
console.log("---------------------------------");
|