myoperator-ui 0.0.29 → 0.0.30

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -604,15 +604,28 @@ export function cn(...inputs: ClassValue[]) {
604
604
  } else {
605
605
  const existingUtils = await fs2.readFile(utilsPath, "utf-8");
606
606
  if (!existingUtils.includes("export function cn") && !existingUtils.includes("export const cn")) {
607
- const cnFunctionOnly = `
608
- import { type ClassValue, clsx } from "clsx"
609
- import { twMerge } from "tailwind-merge"
610
-
607
+ let updatedContent = existingUtils;
608
+ const hasClsxImport = existingUtils.includes('from "clsx"') || existingUtils.includes("from 'clsx'");
609
+ const hasTwMergeImport = existingUtils.includes('from "tailwind-merge"') || existingUtils.includes("from 'tailwind-merge'");
610
+ let importsToAdd = "";
611
+ if (!hasClsxImport) {
612
+ importsToAdd += `import { type ClassValue, clsx } from "clsx"
613
+ `;
614
+ }
615
+ if (!hasTwMergeImport) {
616
+ importsToAdd += `import { twMerge } from "tailwind-merge"
617
+ `;
618
+ }
619
+ if (importsToAdd) {
620
+ updatedContent = importsToAdd + updatedContent;
621
+ }
622
+ const cnFunction = `
611
623
  export function cn(...inputs: ClassValue[]) {
612
624
  return twMerge(clsx(inputs))
613
625
  }
614
626
  `;
615
- await fs2.appendFile(utilsPath, cnFunctionOnly);
627
+ updatedContent = updatedContent.trimEnd() + "\n" + cnFunction;
628
+ await fs2.writeFile(utilsPath, updatedContent);
616
629
  utilsUpdated = true;
617
630
  }
618
631
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",