myoperator-ui 0.0.144 → 0.0.146
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 +225 -66
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3146,7 +3146,8 @@ export {
|
|
|
3146
3146
|
"class-variance-authority",
|
|
3147
3147
|
"clsx",
|
|
3148
3148
|
"tailwind-merge",
|
|
3149
|
-
"lucide-react"
|
|
3149
|
+
"lucide-react",
|
|
3150
|
+
"tailwindcss-animate"
|
|
3150
3151
|
],
|
|
3151
3152
|
files: [
|
|
3152
3153
|
{
|
|
@@ -3340,7 +3341,8 @@ export {
|
|
|
3340
3341
|
"@radix-ui/react-dropdown-menu@^2.1.16",
|
|
3341
3342
|
"clsx",
|
|
3342
3343
|
"tailwind-merge",
|
|
3343
|
-
"lucide-react"
|
|
3344
|
+
"lucide-react",
|
|
3345
|
+
"tailwindcss-animate"
|
|
3344
3346
|
],
|
|
3345
3347
|
files: [
|
|
3346
3348
|
{
|
|
@@ -3555,7 +3557,8 @@ export {
|
|
|
3555
3557
|
dependencies: [
|
|
3556
3558
|
"@radix-ui/react-tooltip@^1.2.8",
|
|
3557
3559
|
"clsx",
|
|
3558
|
-
"tailwind-merge"
|
|
3560
|
+
"tailwind-merge",
|
|
3561
|
+
"tailwindcss-animate"
|
|
3559
3562
|
],
|
|
3560
3563
|
files: [
|
|
3561
3564
|
{
|
|
@@ -4489,7 +4492,8 @@ export { Alert, AlertTitle, AlertDescription, alertVariants };
|
|
|
4489
4492
|
"class-variance-authority",
|
|
4490
4493
|
"lucide-react",
|
|
4491
4494
|
"clsx",
|
|
4492
|
-
"tailwind-merge"
|
|
4495
|
+
"tailwind-merge",
|
|
4496
|
+
"tailwindcss-animate"
|
|
4493
4497
|
],
|
|
4494
4498
|
files: [
|
|
4495
4499
|
{
|
|
@@ -5862,13 +5866,13 @@ EventSelector.displayName = "EventSelector";
|
|
|
5862
5866
|
name: "event-group.tsx",
|
|
5863
5867
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
5864
5868
|
import { cn } from "../../../lib/utils";
|
|
5865
|
-
import { Checkbox, type CheckedState } from "
|
|
5869
|
+
import { Checkbox, type CheckedState } from "../../ui/checkbox";
|
|
5866
5870
|
import {
|
|
5867
5871
|
Accordion,
|
|
5868
5872
|
AccordionItem,
|
|
5869
5873
|
AccordionTrigger,
|
|
5870
5874
|
AccordionContent,
|
|
5871
|
-
} from "
|
|
5875
|
+
} from "../../ui/accordion";
|
|
5872
5876
|
import { EventItemComponent } from "./event-item";
|
|
5873
5877
|
import type { EventGroupComponentProps } from "./types";
|
|
5874
5878
|
|
|
@@ -6048,7 +6052,7 @@ EventGroupComponent.displayName = "EventGroupComponent";
|
|
|
6048
6052
|
name: "event-item.tsx",
|
|
6049
6053
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
6050
6054
|
import { cn } from "../../../lib/utils";
|
|
6051
|
-
import { Checkbox } from "
|
|
6055
|
+
import { Checkbox } from "../../ui/checkbox";
|
|
6052
6056
|
import type { EventItemComponentProps } from "./types";
|
|
6053
6057
|
|
|
6054
6058
|
/**
|
|
@@ -6226,7 +6230,7 @@ export interface EventItemComponentProps {
|
|
|
6226
6230
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
6227
6231
|
import { Plus } from "lucide-react";
|
|
6228
6232
|
import { cn } from "../../../lib/utils";
|
|
6229
|
-
import { Button } from "
|
|
6233
|
+
import { Button } from "../../ui/button";
|
|
6230
6234
|
import { KeyValueRow } from "./key-value-row";
|
|
6231
6235
|
import type { KeyValueInputProps, KeyValuePair } from "./types";
|
|
6232
6236
|
|
|
@@ -6469,8 +6473,8 @@ KeyValueInput.displayName = "KeyValueInput";
|
|
|
6469
6473
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
6470
6474
|
import { Trash2 } from "lucide-react";
|
|
6471
6475
|
import { cn } from "../../../lib/utils";
|
|
6472
|
-
import { Input } from "
|
|
6473
|
-
import { Button } from "
|
|
6476
|
+
import { Input } from "../../ui/input";
|
|
6477
|
+
import { Button } from "../../ui/button";
|
|
6474
6478
|
import type { KeyValueRowProps } from "./types";
|
|
6475
6479
|
|
|
6476
6480
|
/**
|
|
@@ -6657,7 +6661,7 @@ export interface KeyValueRowProps {
|
|
|
6657
6661
|
{
|
|
6658
6662
|
name: "api-feature-card.tsx",
|
|
6659
6663
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
6660
|
-
import { Button } from "
|
|
6664
|
+
import { Button } from "../../ui/button";
|
|
6661
6665
|
import { cn } from "../../../lib/utils";
|
|
6662
6666
|
|
|
6663
6667
|
export interface Capability {
|
|
@@ -6824,7 +6828,7 @@ export type { ApiFeatureCardProps, Capability } from "./api-feature-card";
|
|
|
6824
6828
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
6825
6829
|
import { XCircle } from "lucide-react";
|
|
6826
6830
|
import { cn } from "../../../lib/utils";
|
|
6827
|
-
import { ReadableField } from "
|
|
6831
|
+
import { ReadableField } from "../../ui/readable-field";
|
|
6828
6832
|
|
|
6829
6833
|
export interface EndpointDetailsProps
|
|
6830
6834
|
extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -7055,7 +7059,7 @@ export type { EndpointDetailsProps } from "./endpoint-details";
|
|
|
7055
7059
|
{
|
|
7056
7060
|
name: "alert-configuration.tsx",
|
|
7057
7061
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
7058
|
-
import { Button } from "
|
|
7062
|
+
import { Button } from "../../ui/button";
|
|
7059
7063
|
import { Pencil } from "lucide-react";
|
|
7060
7064
|
import { cn } from "../../../lib/utils";
|
|
7061
7065
|
|
|
@@ -7182,8 +7186,8 @@ AlertConfiguration.displayName = "AlertConfiguration";
|
|
|
7182
7186
|
{
|
|
7183
7187
|
name: "alert-values-modal.tsx",
|
|
7184
7188
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
7185
|
-
import { FormModal } from "
|
|
7186
|
-
import { Input } from "
|
|
7189
|
+
import { FormModal } from "../../ui/form-modal";
|
|
7190
|
+
import { Input } from "../../ui/input";
|
|
7187
7191
|
|
|
7188
7192
|
export interface AlertValuesModalProps {
|
|
7189
7193
|
/** Whether the modal is open */
|
|
@@ -7349,13 +7353,13 @@ export type { AlertValuesModalProps } from "./alert-values-modal";
|
|
|
7349
7353
|
name: "auto-pay-setup.tsx",
|
|
7350
7354
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
7351
7355
|
import { cn } from "../../../lib/utils";
|
|
7352
|
-
import { Button } from "
|
|
7356
|
+
import { Button } from "../../ui/button";
|
|
7353
7357
|
import {
|
|
7354
7358
|
Accordion,
|
|
7355
7359
|
AccordionItem,
|
|
7356
7360
|
AccordionTrigger,
|
|
7357
7361
|
AccordionContent,
|
|
7358
|
-
} from "
|
|
7362
|
+
} from "../../ui/accordion";
|
|
7359
7363
|
import type { AutoPaySetupProps } from "./types";
|
|
7360
7364
|
|
|
7361
7365
|
/**
|
|
@@ -7544,7 +7548,7 @@ import {
|
|
|
7544
7548
|
AccordionItem,
|
|
7545
7549
|
AccordionTrigger,
|
|
7546
7550
|
AccordionContent,
|
|
7547
|
-
} from "
|
|
7551
|
+
} from "../../ui/accordion";
|
|
7548
7552
|
import type { BankDetailsProps, BankDetailItem } from "./types";
|
|
7549
7553
|
|
|
7550
7554
|
/**
|
|
@@ -7763,7 +7767,7 @@ import {
|
|
|
7763
7767
|
TooltipProvider,
|
|
7764
7768
|
TooltipTrigger,
|
|
7765
7769
|
TooltipArrow,
|
|
7766
|
-
} from "
|
|
7770
|
+
} from "../../ui/tooltip";
|
|
7767
7771
|
|
|
7768
7772
|
/**
|
|
7769
7773
|
* Represents a single row in the payment summary.
|
|
@@ -7941,14 +7945,14 @@ export type {
|
|
|
7941
7945
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
7942
7946
|
import { Check, Ticket } from "lucide-react";
|
|
7943
7947
|
import { cn } from "../../../lib/utils";
|
|
7944
|
-
import { Button } from "
|
|
7945
|
-
import { Input } from "
|
|
7948
|
+
import { Button } from "../../ui/button";
|
|
7949
|
+
import { Input } from "../../ui/input";
|
|
7946
7950
|
import {
|
|
7947
7951
|
Accordion,
|
|
7948
7952
|
AccordionItem,
|
|
7949
7953
|
AccordionTrigger,
|
|
7950
7954
|
AccordionContent,
|
|
7951
|
-
} from "
|
|
7955
|
+
} from "../../ui/accordion";
|
|
7952
7956
|
import type { AmountOption, WalletTopupProps } from "./types";
|
|
7953
7957
|
|
|
7954
7958
|
/**
|
|
@@ -9427,12 +9431,166 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
9427
9431
|
}
|
|
9428
9432
|
}
|
|
9429
9433
|
|
|
9430
|
-
// src/commands/
|
|
9434
|
+
// src/commands/sync.ts
|
|
9431
9435
|
import chalk3 from "chalk";
|
|
9432
9436
|
import fs4 from "fs-extra";
|
|
9433
9437
|
import path4 from "path";
|
|
9434
9438
|
import prompts3 from "prompts";
|
|
9435
9439
|
import ora3 from "ora";
|
|
9440
|
+
async function sync(options) {
|
|
9441
|
+
const cwd = process.cwd();
|
|
9442
|
+
if (!await configExists(cwd)) {
|
|
9443
|
+
console.log(chalk3.red("\n Error: Project not initialized."));
|
|
9444
|
+
console.log(chalk3.yellow(" Run `npx myoperator-ui init` first.\n"));
|
|
9445
|
+
process.exit(1);
|
|
9446
|
+
}
|
|
9447
|
+
const prefix = await getTailwindPrefix(cwd);
|
|
9448
|
+
if (prefix) {
|
|
9449
|
+
console.log(chalk3.blue(`
|
|
9450
|
+
\u2139 Applying Tailwind prefix: "${prefix}"
|
|
9451
|
+
`));
|
|
9452
|
+
}
|
|
9453
|
+
const registry = await getRegistry(prefix);
|
|
9454
|
+
const availableComponents = Object.keys(registry);
|
|
9455
|
+
console.log(chalk3.blue(` Scanning for ${availableComponents.length} components...
|
|
9456
|
+
`));
|
|
9457
|
+
const toAdd = [];
|
|
9458
|
+
const toUpdate = [];
|
|
9459
|
+
const upToDate = [];
|
|
9460
|
+
for (const componentName of availableComponents) {
|
|
9461
|
+
const component = registry[componentName];
|
|
9462
|
+
const isCustomComponent = component.category === "custom";
|
|
9463
|
+
const baseDir = isCustomComponent ? path4.join(cwd, "src/components/custom") : path4.join(cwd, options.path);
|
|
9464
|
+
const targetDir = component.isMultiFile ? path4.join(baseDir, component.directory) : baseDir;
|
|
9465
|
+
const mainFileName = component.isMultiFile ? component.mainFile : component.files[0]?.name;
|
|
9466
|
+
if (!mainFileName) continue;
|
|
9467
|
+
const mainFilePath = path4.join(targetDir, mainFileName);
|
|
9468
|
+
const exists = await fs4.pathExists(mainFilePath);
|
|
9469
|
+
if (!exists) {
|
|
9470
|
+
toAdd.push(componentName);
|
|
9471
|
+
} else {
|
|
9472
|
+
const existingContent = await fs4.readFile(mainFilePath, "utf-8");
|
|
9473
|
+
const registryFile = component.files.find((f) => f.name === mainFileName);
|
|
9474
|
+
if (registryFile && existingContent !== registryFile.content) {
|
|
9475
|
+
toUpdate.push(componentName);
|
|
9476
|
+
} else {
|
|
9477
|
+
upToDate.push(componentName);
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
}
|
|
9481
|
+
console.log(chalk3.cyan(" Summary:"));
|
|
9482
|
+
console.log(chalk3.green(` New components to add: ${toAdd.length}`));
|
|
9483
|
+
console.log(chalk3.yellow(` Components to update: ${toUpdate.length}`));
|
|
9484
|
+
console.log(chalk3.gray(` Already up to date: ${upToDate.length}`));
|
|
9485
|
+
console.log("");
|
|
9486
|
+
if (toAdd.length === 0 && toUpdate.length === 0) {
|
|
9487
|
+
console.log(chalk3.green(" \u2713 All components are up to date!\n"));
|
|
9488
|
+
return;
|
|
9489
|
+
}
|
|
9490
|
+
if (toAdd.length > 0) {
|
|
9491
|
+
console.log(chalk3.green(" Will add:"));
|
|
9492
|
+
toAdd.forEach((c) => console.log(chalk3.green(` + ${c}`)));
|
|
9493
|
+
console.log("");
|
|
9494
|
+
}
|
|
9495
|
+
if (toUpdate.length > 0) {
|
|
9496
|
+
console.log(chalk3.yellow(" Will update:"));
|
|
9497
|
+
toUpdate.forEach((c) => console.log(chalk3.yellow(` ~ ${c}`)));
|
|
9498
|
+
console.log("");
|
|
9499
|
+
}
|
|
9500
|
+
if (!options.yes) {
|
|
9501
|
+
const { confirm } = await prompts3({
|
|
9502
|
+
type: "confirm",
|
|
9503
|
+
name: "confirm",
|
|
9504
|
+
message: `Proceed with ${toAdd.length} additions and ${toUpdate.length} updates?`,
|
|
9505
|
+
initial: true
|
|
9506
|
+
});
|
|
9507
|
+
if (!confirm) {
|
|
9508
|
+
console.log(chalk3.yellow("\n Sync cancelled.\n"));
|
|
9509
|
+
process.exit(0);
|
|
9510
|
+
}
|
|
9511
|
+
}
|
|
9512
|
+
const spinner = ora3("Syncing components...").start();
|
|
9513
|
+
try {
|
|
9514
|
+
const installed = [];
|
|
9515
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
9516
|
+
const processedComponents = /* @__PURE__ */ new Set();
|
|
9517
|
+
const installComponent = async (componentName, action) => {
|
|
9518
|
+
if (processedComponents.has(componentName)) return;
|
|
9519
|
+
const component = registry[componentName];
|
|
9520
|
+
if (!component) return;
|
|
9521
|
+
if (component.internalDependencies && component.internalDependencies.length > 0) {
|
|
9522
|
+
for (const depName of component.internalDependencies) {
|
|
9523
|
+
const depComponent = registry[depName];
|
|
9524
|
+
if (depComponent) {
|
|
9525
|
+
const depIsCustom = depComponent.category === "custom";
|
|
9526
|
+
const depBaseDir = depIsCustom ? path4.join(cwd, "src/components/custom") : path4.join(cwd, options.path);
|
|
9527
|
+
const depTargetDir = depComponent.isMultiFile ? path4.join(depBaseDir, depComponent.directory) : depBaseDir;
|
|
9528
|
+
const depMainFile = depComponent.isMultiFile ? depComponent.mainFile : depComponent.files[0]?.name;
|
|
9529
|
+
if (depMainFile) {
|
|
9530
|
+
const depExists = await fs4.pathExists(path4.join(depTargetDir, depMainFile));
|
|
9531
|
+
if (!depExists) {
|
|
9532
|
+
await installComponent(depName, "added");
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9535
|
+
}
|
|
9536
|
+
}
|
|
9537
|
+
}
|
|
9538
|
+
spinner.text = `${action === "added" ? "Adding" : "Updating"} ${componentName}...`;
|
|
9539
|
+
const isCustomComponent = component.category === "custom";
|
|
9540
|
+
const baseDir = isCustomComponent ? path4.join(cwd, "src/components/custom") : path4.join(cwd, options.path);
|
|
9541
|
+
const targetDir = component.isMultiFile ? path4.join(baseDir, component.directory) : baseDir;
|
|
9542
|
+
for (const file of component.files) {
|
|
9543
|
+
const filePath = path4.join(targetDir, file.name);
|
|
9544
|
+
await fs4.ensureDir(path4.dirname(filePath));
|
|
9545
|
+
await fs4.writeFile(filePath, file.content);
|
|
9546
|
+
const basePath = isCustomComponent ? "src/components/custom" : options.path;
|
|
9547
|
+
const relativePath = component.isMultiFile ? `${component.directory}/${file.name}` : file.name;
|
|
9548
|
+
installed.push({ path: relativePath, basePath, action });
|
|
9549
|
+
}
|
|
9550
|
+
if (component.dependencies) {
|
|
9551
|
+
component.dependencies.forEach((dep) => dependencies.add(dep));
|
|
9552
|
+
}
|
|
9553
|
+
processedComponents.add(componentName);
|
|
9554
|
+
};
|
|
9555
|
+
for (const componentName of toAdd) {
|
|
9556
|
+
await installComponent(componentName, "added");
|
|
9557
|
+
}
|
|
9558
|
+
for (const componentName of toUpdate) {
|
|
9559
|
+
await installComponent(componentName, "updated");
|
|
9560
|
+
}
|
|
9561
|
+
spinner.succeed("Sync complete!");
|
|
9562
|
+
const added = installed.filter((f) => f.action === "added");
|
|
9563
|
+
const updated = installed.filter((f) => f.action === "updated");
|
|
9564
|
+
if (added.length > 0) {
|
|
9565
|
+
console.log(chalk3.green("\n Added:"));
|
|
9566
|
+
added.forEach((file) => {
|
|
9567
|
+
console.log(chalk3.green(` + ${file.basePath}/${file.path}`));
|
|
9568
|
+
});
|
|
9569
|
+
}
|
|
9570
|
+
if (updated.length > 0) {
|
|
9571
|
+
console.log(chalk3.yellow("\n Updated:"));
|
|
9572
|
+
updated.forEach((file) => {
|
|
9573
|
+
console.log(chalk3.yellow(` ~ ${file.basePath}/${file.path}`));
|
|
9574
|
+
});
|
|
9575
|
+
}
|
|
9576
|
+
if (dependencies.size > 0) {
|
|
9577
|
+
console.log(chalk3.yellow("\n Required dependencies:"));
|
|
9578
|
+
console.log(chalk3.cyan(` npm install ${Array.from(dependencies).join(" ")}`));
|
|
9579
|
+
}
|
|
9580
|
+
console.log("");
|
|
9581
|
+
} catch (error) {
|
|
9582
|
+
spinner.fail("Sync failed");
|
|
9583
|
+
console.error(error);
|
|
9584
|
+
process.exit(1);
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
|
|
9588
|
+
// src/commands/update.ts
|
|
9589
|
+
import chalk4 from "chalk";
|
|
9590
|
+
import fs5 from "fs-extra";
|
|
9591
|
+
import path5 from "path";
|
|
9592
|
+
import prompts4 from "prompts";
|
|
9593
|
+
import ora4 from "ora";
|
|
9436
9594
|
function normalizeContent(content) {
|
|
9437
9595
|
return content.split("\n").map((line) => line.trimEnd()).join("\n").replace(/\r\n/g, "\n").trimEnd();
|
|
9438
9596
|
}
|
|
@@ -9443,12 +9601,12 @@ function generateDiff(oldContent, newContent, filename) {
|
|
|
9443
9601
|
const oldLines = oldContent.split("\n");
|
|
9444
9602
|
const newLines = newContent.split("\n");
|
|
9445
9603
|
if (!hasRealChanges(oldContent, newContent)) {
|
|
9446
|
-
return
|
|
9604
|
+
return chalk4.gray(` ${filename}: No changes`);
|
|
9447
9605
|
}
|
|
9448
9606
|
const changes = [];
|
|
9449
|
-
changes.push(
|
|
9607
|
+
changes.push(chalk4.cyan(`
|
|
9450
9608
|
--- ${filename} (current)`));
|
|
9451
|
-
changes.push(
|
|
9609
|
+
changes.push(chalk4.cyan(` +++ ${filename} (new)
|
|
9452
9610
|
`));
|
|
9453
9611
|
const maxLines = Math.max(oldLines.length, newLines.length);
|
|
9454
9612
|
let hasChanges = false;
|
|
@@ -9462,20 +9620,20 @@ function generateDiff(oldContent, newContent, filename) {
|
|
|
9462
9620
|
if (contextBuffer.length > 0 && !inChange) {
|
|
9463
9621
|
const startContext = Math.max(0, contextBuffer.length - 2);
|
|
9464
9622
|
for (let j = startContext; j < contextBuffer.length; j++) {
|
|
9465
|
-
changes.push(
|
|
9623
|
+
changes.push(chalk4.gray(` ${i - contextBuffer.length + j + 1}: ${contextBuffer[j]}`));
|
|
9466
9624
|
}
|
|
9467
9625
|
}
|
|
9468
9626
|
inChange = true;
|
|
9469
9627
|
contextBuffer = [];
|
|
9470
9628
|
if (oldLine !== void 0) {
|
|
9471
|
-
changes.push(
|
|
9629
|
+
changes.push(chalk4.red(` - ${i + 1}: ${oldLine}`));
|
|
9472
9630
|
}
|
|
9473
9631
|
if (newLine !== void 0) {
|
|
9474
|
-
changes.push(
|
|
9632
|
+
changes.push(chalk4.green(` + ${i + 1}: ${newLine}`));
|
|
9475
9633
|
}
|
|
9476
9634
|
} else {
|
|
9477
9635
|
if (inChange) {
|
|
9478
|
-
changes.push(
|
|
9636
|
+
changes.push(chalk4.gray(` ${i + 1}: ${oldLine}`));
|
|
9479
9637
|
inChange = false;
|
|
9480
9638
|
}
|
|
9481
9639
|
contextBuffer.push(oldLine || "");
|
|
@@ -9485,47 +9643,47 @@ function generateDiff(oldContent, newContent, filename) {
|
|
|
9485
9643
|
}
|
|
9486
9644
|
}
|
|
9487
9645
|
if (!hasChanges) {
|
|
9488
|
-
return
|
|
9646
|
+
return chalk4.gray(` ${filename}: No changes`);
|
|
9489
9647
|
}
|
|
9490
9648
|
return changes.join("\n");
|
|
9491
9649
|
}
|
|
9492
9650
|
async function update(components, options) {
|
|
9493
9651
|
const cwd = process.cwd();
|
|
9494
9652
|
if (!await configExists(cwd)) {
|
|
9495
|
-
console.log(
|
|
9496
|
-
console.log(
|
|
9653
|
+
console.log(chalk4.red("\n Error: Project not initialized."));
|
|
9654
|
+
console.log(chalk4.yellow(" Run `npx myoperator-ui init` first.\n"));
|
|
9497
9655
|
process.exit(1);
|
|
9498
9656
|
}
|
|
9499
9657
|
const prefix = await getTailwindPrefix(cwd);
|
|
9500
9658
|
if (prefix) {
|
|
9501
|
-
console.log(
|
|
9659
|
+
console.log(chalk4.blue(`
|
|
9502
9660
|
\u2139 Using Tailwind prefix: "${prefix}"
|
|
9503
9661
|
`));
|
|
9504
9662
|
}
|
|
9505
9663
|
const registry = await getRegistry(prefix);
|
|
9506
9664
|
const availableComponents = Object.keys(registry);
|
|
9507
|
-
const componentsDir =
|
|
9665
|
+
const componentsDir = path5.join(cwd, options.path);
|
|
9508
9666
|
const getComponentFilePath = (component) => {
|
|
9509
9667
|
if (component.isMultiFile && component.directory) {
|
|
9510
|
-
return
|
|
9668
|
+
return path5.join(componentsDir, component.directory, component.files[0].name);
|
|
9511
9669
|
}
|
|
9512
|
-
return
|
|
9670
|
+
return path5.join(componentsDir, component.files[0].name);
|
|
9513
9671
|
};
|
|
9514
9672
|
if (options.all) {
|
|
9515
9673
|
const installedComponents = [];
|
|
9516
9674
|
for (const name of availableComponents) {
|
|
9517
9675
|
const component = registry[name];
|
|
9518
9676
|
const filePath = getComponentFilePath(component);
|
|
9519
|
-
if (await
|
|
9677
|
+
if (await fs5.pathExists(filePath)) {
|
|
9520
9678
|
installedComponents.push(name);
|
|
9521
9679
|
}
|
|
9522
9680
|
}
|
|
9523
9681
|
if (installedComponents.length === 0) {
|
|
9524
|
-
console.log(
|
|
9682
|
+
console.log(chalk4.yellow("\n No installed components found to update.\n"));
|
|
9525
9683
|
process.exit(0);
|
|
9526
9684
|
}
|
|
9527
9685
|
components = installedComponents;
|
|
9528
|
-
console.log(
|
|
9686
|
+
console.log(chalk4.blue(` Found ${installedComponents.length} installed component(s)
|
|
9529
9687
|
`));
|
|
9530
9688
|
}
|
|
9531
9689
|
if (!components || components.length === 0) {
|
|
@@ -9533,15 +9691,15 @@ async function update(components, options) {
|
|
|
9533
9691
|
for (const name of availableComponents) {
|
|
9534
9692
|
const component = registry[name];
|
|
9535
9693
|
const filePath = getComponentFilePath(component);
|
|
9536
|
-
if (await
|
|
9694
|
+
if (await fs5.pathExists(filePath)) {
|
|
9537
9695
|
installedComponents.push(name);
|
|
9538
9696
|
}
|
|
9539
9697
|
}
|
|
9540
9698
|
if (installedComponents.length === 0) {
|
|
9541
|
-
console.log(
|
|
9699
|
+
console.log(chalk4.yellow("\n No installed components found to update.\n"));
|
|
9542
9700
|
process.exit(0);
|
|
9543
9701
|
}
|
|
9544
|
-
const { selectedComponents } = await
|
|
9702
|
+
const { selectedComponents } = await prompts4({
|
|
9545
9703
|
type: "multiselect",
|
|
9546
9704
|
name: "selectedComponents",
|
|
9547
9705
|
message: "Which components would you like to update?",
|
|
@@ -9553,16 +9711,16 @@ async function update(components, options) {
|
|
|
9553
9711
|
min: 1
|
|
9554
9712
|
});
|
|
9555
9713
|
if (!selectedComponents || selectedComponents.length === 0) {
|
|
9556
|
-
console.log(
|
|
9714
|
+
console.log(chalk4.yellow("\n No components selected.\n"));
|
|
9557
9715
|
process.exit(0);
|
|
9558
9716
|
}
|
|
9559
9717
|
components = selectedComponents;
|
|
9560
9718
|
}
|
|
9561
9719
|
const invalidComponents = components.filter((c) => !availableComponents.includes(c));
|
|
9562
9720
|
if (invalidComponents.length > 0) {
|
|
9563
|
-
console.log(
|
|
9721
|
+
console.log(chalk4.red(`
|
|
9564
9722
|
Error: Unknown components: ${invalidComponents.join(", ")}`));
|
|
9565
|
-
console.log(
|
|
9723
|
+
console.log(chalk4.yellow(` Available: ${availableComponents.join(", ")}
|
|
9566
9724
|
`));
|
|
9567
9725
|
process.exit(1);
|
|
9568
9726
|
}
|
|
@@ -9571,29 +9729,29 @@ async function update(components, options) {
|
|
|
9571
9729
|
for (const name of components) {
|
|
9572
9730
|
const component = registry[name];
|
|
9573
9731
|
const filePath = getComponentFilePath(component);
|
|
9574
|
-
if (await
|
|
9732
|
+
if (await fs5.pathExists(filePath)) {
|
|
9575
9733
|
toUpdate.push(name);
|
|
9576
9734
|
} else {
|
|
9577
9735
|
notInstalled.push(name);
|
|
9578
9736
|
}
|
|
9579
9737
|
}
|
|
9580
9738
|
if (notInstalled.length > 0) {
|
|
9581
|
-
console.log(
|
|
9739
|
+
console.log(chalk4.yellow(`
|
|
9582
9740
|
Components not installed (use 'add' instead): ${notInstalled.join(", ")}`));
|
|
9583
9741
|
}
|
|
9584
9742
|
if (toUpdate.length === 0) {
|
|
9585
|
-
console.log(
|
|
9743
|
+
console.log(chalk4.yellow("\n No installed components to update.\n"));
|
|
9586
9744
|
process.exit(0);
|
|
9587
9745
|
}
|
|
9588
|
-
console.log(
|
|
9746
|
+
console.log(chalk4.bold("\n Changes to be applied:\n"));
|
|
9589
9747
|
const changesInfo = [];
|
|
9590
9748
|
for (const componentName of toUpdate) {
|
|
9591
9749
|
const component = registry[componentName];
|
|
9592
9750
|
const subDir = component.isMultiFile && component.directory ? component.directory : "";
|
|
9593
9751
|
for (const file of component.files) {
|
|
9594
|
-
const relativePath = subDir ?
|
|
9595
|
-
const filePath =
|
|
9596
|
-
const oldContent = await
|
|
9752
|
+
const relativePath = subDir ? path5.join(subDir, file.name) : file.name;
|
|
9753
|
+
const filePath = path5.join(componentsDir, relativePath);
|
|
9754
|
+
const oldContent = await fs5.readFile(filePath, "utf-8");
|
|
9597
9755
|
const newContent = file.content;
|
|
9598
9756
|
const hasChanges = hasRealChanges(oldContent, newContent);
|
|
9599
9757
|
changesInfo.push({ name: componentName, file: file.name, relativePath, oldContent, newContent, hasChanges });
|
|
@@ -9603,53 +9761,53 @@ async function update(components, options) {
|
|
|
9603
9761
|
}
|
|
9604
9762
|
const componentsWithChanges = changesInfo.filter((c) => c.hasChanges);
|
|
9605
9763
|
if (componentsWithChanges.length === 0) {
|
|
9606
|
-
console.log(
|
|
9764
|
+
console.log(chalk4.green("\n \u2713 All components are already up to date!\n"));
|
|
9607
9765
|
process.exit(0);
|
|
9608
9766
|
}
|
|
9609
|
-
console.log(
|
|
9767
|
+
console.log(chalk4.bold(`
|
|
9610
9768
|
${componentsWithChanges.length} file(s) will be updated.
|
|
9611
9769
|
`));
|
|
9612
9770
|
if (options.dryRun) {
|
|
9613
|
-
console.log(
|
|
9771
|
+
console.log(chalk4.blue(" Dry run complete. No files were modified.\n"));
|
|
9614
9772
|
process.exit(0);
|
|
9615
9773
|
}
|
|
9616
9774
|
if (!options.yes) {
|
|
9617
|
-
const { confirm } = await
|
|
9775
|
+
const { confirm } = await prompts4({
|
|
9618
9776
|
type: "confirm",
|
|
9619
9777
|
name: "confirm",
|
|
9620
9778
|
message: `Update ${componentsWithChanges.length} file(s)?`,
|
|
9621
9779
|
initial: true
|
|
9622
9780
|
});
|
|
9623
9781
|
if (!confirm) {
|
|
9624
|
-
console.log(
|
|
9782
|
+
console.log(chalk4.yellow("\n Update cancelled.\n"));
|
|
9625
9783
|
process.exit(0);
|
|
9626
9784
|
}
|
|
9627
9785
|
}
|
|
9628
|
-
const spinner =
|
|
9786
|
+
const spinner = ora4("Updating components...").start();
|
|
9629
9787
|
try {
|
|
9630
9788
|
const updated = [];
|
|
9631
9789
|
const backedUp = [];
|
|
9632
9790
|
for (const change of componentsWithChanges) {
|
|
9633
|
-
const filePath =
|
|
9791
|
+
const filePath = path5.join(componentsDir, change.relativePath);
|
|
9634
9792
|
if (options.backup) {
|
|
9635
9793
|
const backupPath = `${filePath}.backup.${Date.now()}`;
|
|
9636
|
-
await
|
|
9794
|
+
await fs5.copy(filePath, backupPath);
|
|
9637
9795
|
backedUp.push(change.relativePath);
|
|
9638
9796
|
}
|
|
9639
|
-
await
|
|
9797
|
+
await fs5.writeFile(filePath, change.newContent);
|
|
9640
9798
|
updated.push(change.relativePath);
|
|
9641
9799
|
}
|
|
9642
9800
|
spinner.succeed("Components updated successfully!");
|
|
9643
9801
|
if (backedUp.length > 0) {
|
|
9644
|
-
console.log(
|
|
9802
|
+
console.log(chalk4.blue("\n Backed up files:"));
|
|
9645
9803
|
backedUp.forEach((file) => {
|
|
9646
|
-
console.log(
|
|
9804
|
+
console.log(chalk4.blue(` \u{1F4C1} ${options.path}/${file}.backup.*`));
|
|
9647
9805
|
});
|
|
9648
9806
|
}
|
|
9649
9807
|
if (updated.length > 0) {
|
|
9650
|
-
console.log(
|
|
9808
|
+
console.log(chalk4.green("\n Updated files:"));
|
|
9651
9809
|
updated.forEach((file) => {
|
|
9652
|
-
console.log(
|
|
9810
|
+
console.log(chalk4.green(` \u2713 ${options.path}/${file}`));
|
|
9653
9811
|
});
|
|
9654
9812
|
}
|
|
9655
9813
|
console.log("");
|
|
@@ -9668,4 +9826,5 @@ program.name("myoperator-ui").description("CLI for adding myOperator UI componen
|
|
|
9668
9826
|
program.command("init").description("Initialize your project with myOperator UI").action(init);
|
|
9669
9827
|
program.command("add").description("Add a component to your project").argument("[components...]", "Components to add").option("-a, --all", "Add all available components", false).option("-c, --category <category>", "Add all components from a category (core, form, data, overlay, feedback, layout, custom)").option("-y, --yes", "Skip confirmation prompt", false).option("-o, --overwrite", "Overwrite existing files", false).option("-p, --path <path>", "Path to add components to", "src/components/ui").action(add);
|
|
9670
9828
|
program.command("update").description("Update installed components to the latest version").argument("[components...]", "Components to update (leave empty to select)").option("-y, --yes", "Skip confirmation prompt", false).option("-a, --all", "Update all installed components", false).option("-d, --dry-run", "Show what would change without making changes", false).option("-b, --backup", "Create backup files before updating", false).option("-p, --path <path>", "Path to components directory", "src/components/ui").action(update);
|
|
9829
|
+
program.command("sync").description("Add new components and update existing ones in one command").option("-y, --yes", "Skip confirmation prompt", false).option("-p, --path <path>", "Path to components directory", "src/components/ui").action(sync);
|
|
9671
9830
|
program.parse();
|