myoperator-ui 0.0.190 → 0.0.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +137 -61
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12915,10 +12915,44 @@ async function sync(options) {
|
|
|
12915
12915
|
}
|
|
12916
12916
|
}
|
|
12917
12917
|
}
|
|
12918
|
+
const knownFileNames = /* @__PURE__ */ new Set();
|
|
12919
|
+
const knownDirNames = /* @__PURE__ */ new Set();
|
|
12920
|
+
for (const name of availableComponents) {
|
|
12921
|
+
const comp = registry[name];
|
|
12922
|
+
if (comp.isMultiFile && comp.directory) {
|
|
12923
|
+
knownDirNames.add(comp.directory);
|
|
12924
|
+
} else {
|
|
12925
|
+
const fn = comp.files[0]?.name;
|
|
12926
|
+
if (fn) knownFileNames.add(fn);
|
|
12927
|
+
}
|
|
12928
|
+
}
|
|
12929
|
+
const orphaned = [];
|
|
12930
|
+
const orphanScanDir = path6.join(cwd, options.path);
|
|
12931
|
+
if (await fs6.pathExists(orphanScanDir)) {
|
|
12932
|
+
const entries = await fs6.readdir(orphanScanDir, { withFileTypes: true });
|
|
12933
|
+
for (const entry of entries) {
|
|
12934
|
+
if (entry.isDirectory() && !knownDirNames.has(entry.name)) {
|
|
12935
|
+
orphaned.push({
|
|
12936
|
+
displayPath: `${options.path}/${entry.name}/`,
|
|
12937
|
+
fullPath: path6.join(orphanScanDir, entry.name),
|
|
12938
|
+
isDir: true
|
|
12939
|
+
});
|
|
12940
|
+
} else if (entry.isFile() && entry.name.endsWith(".tsx") && !knownFileNames.has(entry.name)) {
|
|
12941
|
+
orphaned.push({
|
|
12942
|
+
displayPath: `${options.path}/${entry.name}`,
|
|
12943
|
+
fullPath: path6.join(orphanScanDir, entry.name),
|
|
12944
|
+
isDir: false
|
|
12945
|
+
});
|
|
12946
|
+
}
|
|
12947
|
+
}
|
|
12948
|
+
}
|
|
12918
12949
|
console.log(chalk5.cyan(" Summary:"));
|
|
12919
12950
|
console.log(chalk5.green(` New components to add: ${toAdd.length}`));
|
|
12920
12951
|
console.log(chalk5.yellow(` Components to update: ${toUpdate.length}`));
|
|
12921
12952
|
console.log(chalk5.gray(` Already up to date: ${upToDate.length}`));
|
|
12953
|
+
if (orphaned.length > 0) {
|
|
12954
|
+
console.log(chalk5.red(` Not in current registry: ${orphaned.length}`));
|
|
12955
|
+
}
|
|
12922
12956
|
console.log("");
|
|
12923
12957
|
if (prefix) {
|
|
12924
12958
|
const utilsResult = await ensureUtilsPrefixConfig(cwd);
|
|
@@ -12987,7 +13021,7 @@ async function sync(options) {
|
|
|
12987
13021
|
`));
|
|
12988
13022
|
}
|
|
12989
13023
|
}
|
|
12990
|
-
if (toAdd.length === 0 && toUpdate.length === 0) {
|
|
13024
|
+
if (toAdd.length === 0 && toUpdate.length === 0 && orphaned.length === 0) {
|
|
12991
13025
|
console.log(chalk5.green(" \u2713 All components are up to date!\n"));
|
|
12992
13026
|
return;
|
|
12993
13027
|
}
|
|
@@ -13001,7 +13035,7 @@ async function sync(options) {
|
|
|
13001
13035
|
toUpdate.forEach((c) => console.log(chalk5.yellow(` ~ ${c}`)));
|
|
13002
13036
|
console.log("");
|
|
13003
13037
|
}
|
|
13004
|
-
if (!options.yes) {
|
|
13038
|
+
if (!options.yes && (toAdd.length > 0 || toUpdate.length > 0)) {
|
|
13005
13039
|
const { confirm } = await prompts3({
|
|
13006
13040
|
type: "confirm",
|
|
13007
13041
|
name: "confirm",
|
|
@@ -13013,75 +13047,117 @@ async function sync(options) {
|
|
|
13013
13047
|
process.exit(0);
|
|
13014
13048
|
}
|
|
13015
13049
|
}
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
const
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13050
|
+
if (toAdd.length > 0 || toUpdate.length > 0) {
|
|
13051
|
+
const spinner = ora4("Syncing components...").start();
|
|
13052
|
+
try {
|
|
13053
|
+
const installed = [];
|
|
13054
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
13055
|
+
const processedComponents = /* @__PURE__ */ new Set();
|
|
13056
|
+
const componentsDir = path6.join(cwd, options.path);
|
|
13057
|
+
const installComponent = async (componentName, action) => {
|
|
13058
|
+
if (processedComponents.has(componentName)) return;
|
|
13059
|
+
const component = registry[componentName];
|
|
13060
|
+
if (!component) return;
|
|
13061
|
+
if (component.internalDependencies && component.internalDependencies.length > 0) {
|
|
13062
|
+
for (const depName of component.internalDependencies) {
|
|
13063
|
+
const depComponent = registry[depName];
|
|
13064
|
+
if (depComponent) {
|
|
13065
|
+
const depTargetDir = depComponent.isMultiFile ? path6.join(componentsDir, depComponent.directory) : componentsDir;
|
|
13066
|
+
const depMainFile = depComponent.isMultiFile ? depComponent.mainFile : depComponent.files[0]?.name;
|
|
13067
|
+
if (depMainFile) {
|
|
13068
|
+
const depExists = await fs6.pathExists(path6.join(depTargetDir, depMainFile));
|
|
13069
|
+
if (!depExists) {
|
|
13070
|
+
await installComponent(depName, "added");
|
|
13071
|
+
}
|
|
13036
13072
|
}
|
|
13037
13073
|
}
|
|
13038
13074
|
}
|
|
13039
13075
|
}
|
|
13076
|
+
spinner.text = `${action === "added" ? "Adding" : "Updating"} ${componentName}...`;
|
|
13077
|
+
const targetDir = component.isMultiFile ? path6.join(componentsDir, component.directory) : componentsDir;
|
|
13078
|
+
for (const file of component.files) {
|
|
13079
|
+
const filePath = path6.join(targetDir, file.name);
|
|
13080
|
+
await fs6.ensureDir(path6.dirname(filePath));
|
|
13081
|
+
await fs6.writeFile(filePath, file.content);
|
|
13082
|
+
const relativePath = component.isMultiFile ? `${component.directory}/${file.name}` : file.name;
|
|
13083
|
+
installed.push({ path: relativePath, basePath: options.path, action });
|
|
13084
|
+
}
|
|
13085
|
+
if (component.dependencies) {
|
|
13086
|
+
component.dependencies.forEach((dep) => dependencies.add(dep));
|
|
13087
|
+
}
|
|
13088
|
+
processedComponents.add(componentName);
|
|
13089
|
+
};
|
|
13090
|
+
for (const componentName of toAdd) {
|
|
13091
|
+
await installComponent(componentName, "added");
|
|
13040
13092
|
}
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
for (const file of component.files) {
|
|
13044
|
-
const filePath = path6.join(targetDir, file.name);
|
|
13045
|
-
await fs6.ensureDir(path6.dirname(filePath));
|
|
13046
|
-
await fs6.writeFile(filePath, file.content);
|
|
13047
|
-
const relativePath = component.isMultiFile ? `${component.directory}/${file.name}` : file.name;
|
|
13048
|
-
installed.push({ path: relativePath, basePath: options.path, action });
|
|
13093
|
+
for (const componentName of toUpdate) {
|
|
13094
|
+
await installComponent(componentName, "updated");
|
|
13049
13095
|
}
|
|
13050
|
-
|
|
13051
|
-
|
|
13096
|
+
spinner.succeed("Sync complete!");
|
|
13097
|
+
const added = installed.filter((f) => f.action === "added");
|
|
13098
|
+
const updated = installed.filter((f) => f.action === "updated");
|
|
13099
|
+
if (added.length > 0) {
|
|
13100
|
+
console.log(chalk5.green("\n Added:"));
|
|
13101
|
+
added.forEach((file) => {
|
|
13102
|
+
console.log(chalk5.green(` + ${file.basePath}/${file.path}`));
|
|
13103
|
+
});
|
|
13052
13104
|
}
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
});
|
|
13105
|
+
if (updated.length > 0) {
|
|
13106
|
+
console.log(chalk5.yellow("\n Updated:"));
|
|
13107
|
+
updated.forEach((file) => {
|
|
13108
|
+
console.log(chalk5.yellow(` ~ ${file.basePath}/${file.path}`));
|
|
13109
|
+
});
|
|
13110
|
+
}
|
|
13111
|
+
if (dependencies.size > 0) {
|
|
13112
|
+
console.log(chalk5.yellow("\n Required dependencies:"));
|
|
13113
|
+
console.log(chalk5.cyan(` npm install ${Array.from(dependencies).join(" ")}`));
|
|
13114
|
+
}
|
|
13115
|
+
console.log("");
|
|
13116
|
+
} catch (error) {
|
|
13117
|
+
spinner.fail("Sync failed");
|
|
13118
|
+
console.error(error);
|
|
13119
|
+
process.exit(1);
|
|
13069
13120
|
}
|
|
13070
|
-
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13121
|
+
}
|
|
13122
|
+
if (orphaned.length > 0) {
|
|
13123
|
+
console.log(chalk5.yellow("\n \u26A0 The following were not found in the current myOperator UI registry."));
|
|
13124
|
+
console.log(chalk5.gray(" They may be outdated components or your own custom files \u2014 review before deleting.\n"));
|
|
13125
|
+
orphaned.forEach((o) => console.log(chalk5.gray(` ${o.isDir ? "\u{1F4C1}" : "\u{1F4C4}"} ${o.displayPath}`)));
|
|
13126
|
+
console.log("");
|
|
13127
|
+
if (options.yes) {
|
|
13128
|
+
console.log(chalk5.gray(" Run sync without --yes to interactively choose which to remove.\n"));
|
|
13129
|
+
} else {
|
|
13130
|
+
const { toDelete } = await prompts3({
|
|
13131
|
+
type: "multiselect",
|
|
13132
|
+
name: "toDelete",
|
|
13133
|
+
message: "Select items to delete (space to select, enter to confirm \u2014 leave all unselected to keep everything)",
|
|
13134
|
+
choices: orphaned.map((o) => ({
|
|
13135
|
+
title: o.displayPath,
|
|
13136
|
+
value: o,
|
|
13137
|
+
selected: false
|
|
13138
|
+
}))
|
|
13074
13139
|
});
|
|
13140
|
+
const selected = toDelete ?? [];
|
|
13141
|
+
if (selected.length > 0) {
|
|
13142
|
+
const { confirmed } = await prompts3({
|
|
13143
|
+
type: "confirm",
|
|
13144
|
+
name: "confirmed",
|
|
13145
|
+
message: `Permanently delete ${selected.length} item(s)? This cannot be undone.`,
|
|
13146
|
+
initial: false
|
|
13147
|
+
});
|
|
13148
|
+
if (confirmed) {
|
|
13149
|
+
for (const item of selected) {
|
|
13150
|
+
await fs6.remove(item.fullPath);
|
|
13151
|
+
console.log(chalk5.red(` \u2715 Deleted ${item.displayPath}`));
|
|
13152
|
+
}
|
|
13153
|
+
console.log("");
|
|
13154
|
+
} else {
|
|
13155
|
+
console.log(chalk5.gray("\n Nothing deleted.\n"));
|
|
13156
|
+
}
|
|
13157
|
+
} else {
|
|
13158
|
+
console.log(chalk5.gray(" No items selected \u2014 all kept.\n"));
|
|
13159
|
+
}
|
|
13075
13160
|
}
|
|
13076
|
-
if (dependencies.size > 0) {
|
|
13077
|
-
console.log(chalk5.yellow("\n Required dependencies:"));
|
|
13078
|
-
console.log(chalk5.cyan(` npm install ${Array.from(dependencies).join(" ")}`));
|
|
13079
|
-
}
|
|
13080
|
-
console.log("");
|
|
13081
|
-
} catch (error) {
|
|
13082
|
-
spinner.fail("Sync failed");
|
|
13083
|
-
console.error(error);
|
|
13084
|
-
process.exit(1);
|
|
13085
13161
|
}
|
|
13086
13162
|
}
|
|
13087
13163
|
|