@yamada-ui/cli 2.0.10-dev-20260305142428 → 2.1.0-dev-20260305232700
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 +67 -59
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6132,7 +6132,7 @@ async function fetchRegistries(names, config$1, { cache = true, dependencies: wi
|
|
|
6132
6132
|
await fetch$1(names);
|
|
6133
6133
|
return results;
|
|
6134
6134
|
}
|
|
6135
|
-
async function
|
|
6135
|
+
async function fetchLocalRegistry(path$9) {
|
|
6136
6136
|
return JSON.parse(await readFile(path$9, "utf-8"));
|
|
6137
6137
|
}
|
|
6138
6138
|
async function getGeneratedNameMap(config$1) {
|
|
@@ -6459,7 +6459,7 @@ function printConflicts(conflictMap, config$1) {
|
|
|
6459
6459
|
function getDirPath(section, name$1, config$1) {
|
|
6460
6460
|
return config$1.isSection(section) ? path$1.join(config$1.getSectionResolvedPath(section), name$1) : config$1.paths[section === "theme" ? "theme" : "ui"].src;
|
|
6461
6461
|
}
|
|
6462
|
-
async function getDiff(generatedNames, {
|
|
6462
|
+
async function getDiff(generatedNames, { local, remote }, config$1, concurrent = true) {
|
|
6463
6463
|
const changeMap = {};
|
|
6464
6464
|
const dependencyMap = {
|
|
6465
6465
|
add: [],
|
|
@@ -6468,29 +6468,29 @@ async function getDiff(generatedNames, { locale, remote }, config$1, concurrent
|
|
|
6468
6468
|
};
|
|
6469
6469
|
await new Listr(Object.entries(remote).map(([componentName, { dependencies: dependencies$1, section, sources }]) => ({
|
|
6470
6470
|
task: async (_, task) => {
|
|
6471
|
-
const
|
|
6471
|
+
const localRegistry = local[componentName];
|
|
6472
6472
|
if (componentName === "index") {
|
|
6473
6473
|
const [source] = sources;
|
|
6474
6474
|
const fileName = transformExtension(source.name, config$1.jsx);
|
|
6475
|
-
const [remote$1,
|
|
6476
|
-
const diff$1 = diffLines(
|
|
6475
|
+
const [remote$1, local$1] = await Promise.all([transformIndexWithFormatAndLint(source.content, config$1, generatedNames), transformIndexWithFormatAndLint(localRegistry.sources[0].content, config$1, generatedNames)]);
|
|
6476
|
+
const diff$1 = diffLines(local$1, remote$1);
|
|
6477
6477
|
if (diff$1.length < 2) return;
|
|
6478
6478
|
changeMap[componentName] ??= {};
|
|
6479
6479
|
changeMap[componentName][fileName] = {
|
|
6480
6480
|
diff: diff$1,
|
|
6481
|
-
|
|
6481
|
+
local: local$1,
|
|
6482
6482
|
remote: remote$1
|
|
6483
6483
|
};
|
|
6484
6484
|
} else {
|
|
6485
6485
|
const dirPath = getDirPath(section, componentName, config$1);
|
|
6486
|
-
if (dependencies$1 ||
|
|
6486
|
+
if (dependencies$1 || localRegistry.dependencies) {
|
|
6487
6487
|
const remoteDependencies = dependencies$1?.externals ?? [];
|
|
6488
|
-
const
|
|
6488
|
+
const localDependencies = localRegistry.dependencies?.externals ?? [];
|
|
6489
6489
|
const remotePackageNames = remoteDependencies.map(getPackageName);
|
|
6490
|
-
const
|
|
6491
|
-
const add$1 = remotePackageNames.filter((name$1) => !
|
|
6492
|
-
const remove =
|
|
6493
|
-
const update$1 =
|
|
6490
|
+
const localPackageNames = localDependencies.map(getPackageName);
|
|
6491
|
+
const add$1 = remotePackageNames.filter((name$1) => !localPackageNames.includes(name$1));
|
|
6492
|
+
const remove = localPackageNames.filter((name$1) => !remotePackageNames.includes(name$1));
|
|
6493
|
+
const update$1 = localDependencies.map((name$1) => {
|
|
6494
6494
|
const [packageName, current] = splitVersion(name$1);
|
|
6495
6495
|
const remoteDependency = remoteDependencies.find((name$2) => getPackageName(name$2) === packageName);
|
|
6496
6496
|
if (!remoteDependency) return;
|
|
@@ -6507,17 +6507,17 @@ async function getDiff(generatedNames, { locale, remote }, config$1, concurrent
|
|
|
6507
6507
|
dependencyMap.update.push(...update$1);
|
|
6508
6508
|
}
|
|
6509
6509
|
await Promise.all(sources.map(async ({ name: name$1, content, data, template }) => {
|
|
6510
|
-
const source =
|
|
6510
|
+
const source = localRegistry.sources.find((source$1) => source$1.name === name$1);
|
|
6511
6511
|
name$1 = transformExtension(name$1, config$1.jsx);
|
|
6512
6512
|
const targetPath = path$1.join(dirPath, name$1);
|
|
6513
6513
|
if (content) if (source) {
|
|
6514
|
-
const [remote$1,
|
|
6515
|
-
const diff$1 = diffLines(
|
|
6514
|
+
const [remote$1, local$1] = await Promise.all([transformContentWithFormatAndLint(targetPath, section, content, config$1, generatedNames), transformContentWithFormatAndLint(targetPath, section, source.content, config$1, generatedNames)]);
|
|
6515
|
+
const diff$1 = diffLines(local$1, remote$1);
|
|
6516
6516
|
if (diff$1.length < 2) return;
|
|
6517
6517
|
changeMap[componentName] ??= {};
|
|
6518
6518
|
changeMap[componentName][name$1] = {
|
|
6519
6519
|
diff: diff$1,
|
|
6520
|
-
|
|
6520
|
+
local: local$1,
|
|
6521
6521
|
remote: remote$1
|
|
6522
6522
|
};
|
|
6523
6523
|
} else {
|
|
@@ -6536,18 +6536,18 @@ async function getDiff(generatedNames, { locale, remote }, config$1, concurrent
|
|
|
6536
6536
|
};
|
|
6537
6537
|
}
|
|
6538
6538
|
else if (template && data) await Promise.all(data.map(async ({ name: fileName, ...remoteRest }) => {
|
|
6539
|
-
const
|
|
6539
|
+
const localData = source?.data?.find(({ name: name$2 }) => name$2 === fileName);
|
|
6540
6540
|
fileName = transformExtension(fileName, config$1.jsx);
|
|
6541
|
-
if (
|
|
6541
|
+
if (localData) {
|
|
6542
6542
|
if (template === source?.template) return;
|
|
6543
|
-
const { name: _name, ...
|
|
6544
|
-
const [remote$1,
|
|
6545
|
-
const diff$1 = diffLines(
|
|
6543
|
+
const { name: _name, ...localRest } = localData;
|
|
6544
|
+
const [remote$1, local$1] = await Promise.all([transformContentWithFormatAndLint(path$1.join(targetPath, fileName), section, transformTemplateContent(template, remoteRest), config$1, generatedNames), transformContentWithFormatAndLint(path$1.join(targetPath, fileName), section, transformTemplateContent(source.template, localRest), config$1, generatedNames)]);
|
|
6545
|
+
const diff$1 = diffLines(local$1, remote$1);
|
|
6546
6546
|
if (diff$1.length < 2) return;
|
|
6547
6547
|
changeMap[componentName] ??= {};
|
|
6548
6548
|
changeMap[componentName][`${name$1}/${fileName}`] = {
|
|
6549
6549
|
diff: diff$1,
|
|
6550
|
-
|
|
6550
|
+
local: local$1,
|
|
6551
6551
|
remote: remote$1
|
|
6552
6552
|
};
|
|
6553
6553
|
} else {
|
|
@@ -6567,34 +6567,34 @@ async function getDiff(generatedNames, { locale, remote }, config$1, concurrent
|
|
|
6567
6567
|
}
|
|
6568
6568
|
}));
|
|
6569
6569
|
}));
|
|
6570
|
-
|
|
6570
|
+
localRegistry.sources.filter(({ name: name$1 }) => !sources.some((source) => source.name === name$1)).forEach(({ name: name$1, content, data, template }) => {
|
|
6571
6571
|
if (content) {
|
|
6572
|
-
let
|
|
6573
|
-
if (config$1.jsx)
|
|
6572
|
+
let local$1 = transformContent(section, content, config$1, generatedNames);
|
|
6573
|
+
if (config$1.jsx) local$1 = isJsx(name$1) ? transformTsxToJsx(local$1) : transformTsToJs(local$1);
|
|
6574
6574
|
const diff$1 = [{
|
|
6575
6575
|
added: false,
|
|
6576
|
-
count:
|
|
6576
|
+
count: local$1.length,
|
|
6577
6577
|
removed: true,
|
|
6578
|
-
value:
|
|
6578
|
+
value: local$1
|
|
6579
6579
|
}];
|
|
6580
6580
|
changeMap[componentName] ??= {};
|
|
6581
6581
|
changeMap[componentName][name$1] = {
|
|
6582
6582
|
diff: diff$1,
|
|
6583
|
-
|
|
6583
|
+
local: local$1
|
|
6584
6584
|
};
|
|
6585
6585
|
} else if (template && data) data.forEach(({ name: fileName, ...remoteRest }) => {
|
|
6586
|
-
let
|
|
6587
|
-
if (config$1.jsx)
|
|
6586
|
+
let local$1 = transformContent(section, transformTemplateContent(template, remoteRest), config$1, generatedNames);
|
|
6587
|
+
if (config$1.jsx) local$1 = isJsx(fileName) ? transformTsxToJsx(local$1) : transformTsToJs(local$1);
|
|
6588
6588
|
const diff$1 = [{
|
|
6589
6589
|
added: true,
|
|
6590
|
-
count:
|
|
6590
|
+
count: local$1.length,
|
|
6591
6591
|
removed: false,
|
|
6592
|
-
value:
|
|
6592
|
+
value: local$1
|
|
6593
6593
|
}];
|
|
6594
6594
|
changeMap[componentName] ??= {};
|
|
6595
6595
|
changeMap[componentName][`${name$1}/${fileName}`] = {
|
|
6596
6596
|
diff: diff$1,
|
|
6597
|
-
|
|
6597
|
+
local: local$1
|
|
6598
6598
|
};
|
|
6599
6599
|
});
|
|
6600
6600
|
});
|
|
@@ -6611,14 +6611,14 @@ async function getDiff(generatedNames, { locale, remote }, config$1, concurrent
|
|
|
6611
6611
|
|
|
6612
6612
|
//#endregion
|
|
6613
6613
|
//#region src/commands/update/update-files.ts
|
|
6614
|
-
async function mergeContent(remotePath,
|
|
6614
|
+
async function mergeContent(remotePath, localPath, currentPath, fallback) {
|
|
6615
6615
|
let content = "";
|
|
6616
6616
|
let conflict = false;
|
|
6617
6617
|
try {
|
|
6618
6618
|
const { stdout } = await execa("diff3", [
|
|
6619
6619
|
"-m",
|
|
6620
6620
|
remotePath,
|
|
6621
|
-
|
|
6621
|
+
localPath,
|
|
6622
6622
|
currentPath
|
|
6623
6623
|
]);
|
|
6624
6624
|
content = stdout;
|
|
@@ -6629,7 +6629,7 @@ async function mergeContent(remotePath, localePath, currentPath, fallback) {
|
|
|
6629
6629
|
} else content = fallback;
|
|
6630
6630
|
}
|
|
6631
6631
|
content = content.replaceAll(remotePath, "remote");
|
|
6632
|
-
content = content.replaceAll(
|
|
6632
|
+
content = content.replaceAll(localPath, "local");
|
|
6633
6633
|
content = content.replaceAll(currentPath, "current");
|
|
6634
6634
|
content = content.replace(/\|\|\|\|\|\|\|[\s\S]*?=======/g, "=======");
|
|
6635
6635
|
return {
|
|
@@ -6637,7 +6637,7 @@ async function mergeContent(remotePath, localePath, currentPath, fallback) {
|
|
|
6637
6637
|
content
|
|
6638
6638
|
};
|
|
6639
6639
|
}
|
|
6640
|
-
async function updateFiles(changeMap, { add: add$1, remove, update: update$1 }, { remote }, config$1, { concurrent = true, install = false } = {}) {
|
|
6640
|
+
async function updateFiles(changeMap, { add: add$1, remove, update: update$1 }, { remote }, config$1, { concurrent = true, force = false, install = false } = {}) {
|
|
6641
6641
|
const conflictMap = {};
|
|
6642
6642
|
const disabledFormatAndLint = {
|
|
6643
6643
|
format: { enabled: false },
|
|
@@ -6652,29 +6652,34 @@ async function updateFiles(changeMap, { add: add$1, remove, update: update$1 },
|
|
|
6652
6652
|
if (componentName === "index") {
|
|
6653
6653
|
const name$1 = config$1.paths.ui.index.split("/").at(-1);
|
|
6654
6654
|
const data = changes[name$1];
|
|
6655
|
-
if (!("
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6655
|
+
if (!("local" in data && "remote" in data)) return;
|
|
6656
|
+
if (force) await writeFileSafe(config$1.paths.ui.index, data.remote, config$1);
|
|
6657
|
+
else {
|
|
6658
|
+
const remotePath = path$1.join(tempDirPath, `remote-${name$1}`);
|
|
6659
|
+
const localPath = path$1.join(tempDirPath, `local-${name$1}`);
|
|
6660
|
+
await Promise.all([writeFileSafe(remotePath, data.remote, disabledFormatAndLint), writeFileSafe(localPath, data.local, disabledFormatAndLint)]);
|
|
6661
|
+
const { conflict, content: mergedContent } = await mergeContent(remotePath, localPath, config$1.paths.ui.index, data.remote);
|
|
6662
|
+
await writeFileSafe(config$1.paths.ui.index, mergedContent, conflict ? merge(config$1, disabledFormatAndLint) : config$1);
|
|
6663
|
+
if (conflict) {
|
|
6664
|
+
conflictMap[componentName] ??= {};
|
|
6665
|
+
conflictMap[componentName][name$1] = config$1.paths.ui.index;
|
|
6666
|
+
}
|
|
6664
6667
|
}
|
|
6665
6668
|
} else await Promise.all(Object.entries(changes).map(async ([name$1, { ...data }]) => {
|
|
6666
6669
|
const currentPath = path$1.join(dirPath, name$1);
|
|
6667
|
-
if ("
|
|
6670
|
+
if ("local" in data && "remote" in data) if (force) await writeFileSafe(currentPath, data.remote, config$1);
|
|
6671
|
+
else {
|
|
6668
6672
|
const remotePath = path$1.join(tempDirPath, `remote-${name$1}`);
|
|
6669
|
-
const
|
|
6670
|
-
await Promise.all([writeFileSafe(remotePath, data.remote, disabledFormatAndLint), writeFileSafe(
|
|
6671
|
-
const { conflict, content: mergedContent } = await mergeContent(remotePath,
|
|
6673
|
+
const localPath = path$1.join(tempDirPath, `local-${name$1}`);
|
|
6674
|
+
await Promise.all([writeFileSafe(remotePath, data.remote, disabledFormatAndLint), writeFileSafe(localPath, data.local, disabledFormatAndLint)]);
|
|
6675
|
+
const { conflict, content: mergedContent } = await mergeContent(remotePath, localPath, currentPath, data.remote);
|
|
6672
6676
|
await writeFileSafe(currentPath, mergedContent, conflict ? merge(config$1, disabledFormatAndLint) : config$1);
|
|
6673
6677
|
if (conflict) {
|
|
6674
6678
|
conflictMap[componentName] ??= {};
|
|
6675
6679
|
conflictMap[componentName][name$1] = currentPath;
|
|
6676
6680
|
}
|
|
6677
|
-
}
|
|
6681
|
+
}
|
|
6682
|
+
else if ("remote" in data) await writeFileSafe(currentPath, data.remote, config$1);
|
|
6678
6683
|
else await rimraf(currentPath);
|
|
6679
6684
|
}));
|
|
6680
6685
|
await writeFileSafe(path$1.resolve(dirPath, REGISTRY_FILE_NAME), JSON.stringify(registry), merge(config$1, { format: { parser: "json" } }));
|
|
@@ -6718,14 +6723,14 @@ async function validateDiff3() {
|
|
|
6718
6723
|
async function getRegistriesAndFiles(componentNames, config$1, { concurrent = true, index = false, theme: theme$1 = false } = {}) {
|
|
6719
6724
|
const fileMap = {};
|
|
6720
6725
|
const registryMap = {
|
|
6721
|
-
|
|
6726
|
+
local: {},
|
|
6722
6727
|
remote: {}
|
|
6723
6728
|
};
|
|
6724
6729
|
const tasks = new Listr([], { concurrent });
|
|
6725
6730
|
if (index) tasks.add([{
|
|
6726
6731
|
task: async (_, task) => {
|
|
6727
6732
|
fileMap.index = { [transformExtension("index.ts", config$1.jsx)]: await readFile(config$1.paths.ui.index, "utf-8") };
|
|
6728
|
-
registryMap.
|
|
6733
|
+
registryMap.local.index = await fetchLocalRegistry(config$1.paths.ui.registry);
|
|
6729
6734
|
task.title = `Got ${c.cyan("index")} file`;
|
|
6730
6735
|
},
|
|
6731
6736
|
title: `Getting ${c.cyan("index")} file`
|
|
@@ -6741,7 +6746,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
|
|
|
6741
6746
|
if (!config$1.theme?.path) return;
|
|
6742
6747
|
const { dirPath, files: files$1 } = await getFiles(config$1.paths.theme.src);
|
|
6743
6748
|
fileMap.theme = files$1;
|
|
6744
|
-
registryMap.
|
|
6749
|
+
registryMap.local.theme = await fetchLocalRegistry(path$1.posix.join(dirPath, REGISTRY_FILE_NAME));
|
|
6745
6750
|
task.title = `Got ${c.cyan("theme")} files`;
|
|
6746
6751
|
},
|
|
6747
6752
|
title: `Getting ${c.cyan("theme")} files`
|
|
@@ -6756,7 +6761,7 @@ async function getRegistriesAndFiles(componentNames, config$1, { concurrent = tr
|
|
|
6756
6761
|
task: async (_, task) => {
|
|
6757
6762
|
const { dirPath, files: files$1 } = await getFiles(path$1.posix.join(config$1.paths.ui.src, "**", componentName));
|
|
6758
6763
|
fileMap[componentName] = files$1;
|
|
6759
|
-
registryMap.
|
|
6764
|
+
registryMap.local[componentName] = await fetchLocalRegistry(path$1.posix.join(dirPath, REGISTRY_FILE_NAME));
|
|
6760
6765
|
task.title = `Got ${c.cyan(componentName)} files`;
|
|
6761
6766
|
},
|
|
6762
6767
|
title: `Getting ${c.cyan(componentName)} files`
|
|
@@ -7536,7 +7541,7 @@ const tokens = new Command("tokens").description("generate theme typings").argum
|
|
|
7536
7541
|
|
|
7537
7542
|
//#endregion
|
|
7538
7543
|
//#region src/commands/update/index.ts
|
|
7539
|
-
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("-i, --install", "install dependencies", false).option("-s, --sequential", "run tasks sequentially.", false).option("-f, --format", "format the output files.").option("-l, --lint", "lint the output files.").action(async function(targetNames, { config: configPath, cwd: cwd$1, format: format$2, install, lint, sequential }) {
|
|
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("-i, --install", "install dependencies", false).option("-s, --sequential", "run tasks sequentially.", false).option("-F, --force", "force update, overwriting local changes.", false).option("-f, --format", "format the output files.").option("-l, --lint", "lint the output files.").action(async function(targetNames, { config: configPath, cwd: cwd$1, force, format: format$2, install, lint, sequential }) {
|
|
7540
7545
|
const spinner = ora();
|
|
7541
7546
|
try {
|
|
7542
7547
|
const { end } = timer();
|
|
@@ -7546,9 +7551,11 @@ const update = new Command("update").description("update components in your proj
|
|
|
7546
7551
|
spinner.start("Validating directory");
|
|
7547
7552
|
await validateDir(cwd$1);
|
|
7548
7553
|
spinner.succeed("Validated directory");
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7554
|
+
if (!force) {
|
|
7555
|
+
spinner.start("Validating methods");
|
|
7556
|
+
await validateDiff3();
|
|
7557
|
+
spinner.succeed("Validated methods");
|
|
7558
|
+
}
|
|
7552
7559
|
spinner.start("Fetching config");
|
|
7553
7560
|
const config$1 = await getConfig(cwd$1, configPath, {
|
|
7554
7561
|
format: format$2,
|
|
@@ -7592,6 +7599,7 @@ const update = new Command("update").description("update components in your proj
|
|
|
7592
7599
|
else {
|
|
7593
7600
|
const conflictMap = await updateFiles(changeMap, dependencyMap, registryMap, config$1, {
|
|
7594
7601
|
concurrent: !sequential,
|
|
7602
|
+
force,
|
|
7595
7603
|
install
|
|
7596
7604
|
});
|
|
7597
7605
|
if (Object.keys(conflictMap).length) {
|