myoperator-ui 0.0.38 → 0.0.40

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 +36 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1075,13 +1075,29 @@ async function init() {
1075
1075
  const packageJsonPath = path2.join(cwd, "package.json");
1076
1076
  let hasBootstrap = false;
1077
1077
  let isESM = false;
1078
+ let detectedTailwindVersion = null;
1078
1079
  if (await fs2.pathExists(packageJsonPath)) {
1079
1080
  const packageJson2 = await fs2.readJson(packageJsonPath);
1080
1081
  hasBootstrap = !!(packageJson2.dependencies?.bootstrap || packageJson2.devDependencies?.bootstrap);
1081
1082
  isESM = packageJson2.type === "module";
1083
+ const tailwindDep = packageJson2.dependencies?.tailwindcss || packageJson2.devDependencies?.tailwindcss;
1084
+ if (tailwindDep) {
1085
+ if (tailwindDep.match(/^[\^~]?4/)) {
1086
+ detectedTailwindVersion = "v4";
1087
+ } else if (tailwindDep.match(/^[\^~]?3/)) {
1088
+ detectedTailwindVersion = "v3";
1089
+ }
1090
+ }
1091
+ if (packageJson2.dependencies?.["@tailwindcss/postcss"] || packageJson2.devDependencies?.["@tailwindcss/postcss"]) {
1092
+ detectedTailwindVersion = "v4";
1093
+ }
1082
1094
  if (hasBootstrap) {
1083
1095
  console.log(chalk2.blue(" \u2139 Bootstrap detected - will configure Tailwind to avoid conflicts\n"));
1084
1096
  }
1097
+ if (detectedTailwindVersion) {
1098
+ console.log(chalk2.blue(` \u2139 Tailwind CSS ${detectedTailwindVersion} detected
1099
+ `));
1100
+ }
1085
1101
  }
1086
1102
  const detectGlobalCss = async () => {
1087
1103
  const cssOptions = [
@@ -1115,18 +1131,22 @@ async function init() {
1115
1131
  };
1116
1132
  const detectedCss = await detectGlobalCss();
1117
1133
  const detectedTailwindConfig = await detectTailwindConfig();
1118
- const response = await prompts2([
1119
- {
1120
- type: "select",
1121
- name: "tailwindVersion",
1122
- message: "Which Tailwind CSS version are you using?",
1123
- choices: [
1124
- { title: "Tailwind CSS v4 (latest)", value: "v4" },
1125
- { title: "Tailwind CSS v3", value: "v3" }
1126
- ],
1127
- initial: 0
1128
- }
1129
- ]);
1134
+ let tailwindVersion = detectedTailwindVersion;
1135
+ if (!tailwindVersion) {
1136
+ const response2 = await prompts2([
1137
+ {
1138
+ type: "select",
1139
+ name: "tailwindVersion",
1140
+ message: "Which Tailwind CSS version are you using?",
1141
+ choices: [
1142
+ { title: "Tailwind CSS v4 (latest)", value: "v4" },
1143
+ { title: "Tailwind CSS v3", value: "v3" }
1144
+ ],
1145
+ initial: 0
1146
+ }
1147
+ ]);
1148
+ tailwindVersion = response2.tailwindVersion;
1149
+ }
1130
1150
  const componentsPath = "src/components/ui";
1131
1151
  const utilsPath = "src/lib/utils.ts";
1132
1152
  const tailwindConfig = detectedTailwindConfig;
@@ -1193,7 +1213,7 @@ export function cn(...inputs: ClassValue[]) {
1193
1213
  await fs2.ensureDir(componentsFullPath);
1194
1214
  const globalCssPath = path2.join(cwd, globalCss);
1195
1215
  let cssContent;
1196
- if (response.tailwindVersion === "v4") {
1216
+ if (tailwindVersion === "v4") {
1197
1217
  cssContent = hasBootstrap ? CSS_VARIABLES_V4_BOOTSTRAP : CSS_VARIABLES_V4;
1198
1218
  } else {
1199
1219
  cssContent = CSS_VARIABLES_V3;
@@ -1206,7 +1226,7 @@ export function cn(...inputs: ClassValue[]) {
1206
1226
  } else {
1207
1227
  const existingCss = await fs2.readFile(globalCssPath, "utf-8");
1208
1228
  if (!existingCss.includes("myOperator UI") && !existingCss.includes("--mo-background:")) {
1209
- let updateCss = response.tailwindVersion === "v3";
1229
+ let updateCss = tailwindVersion === "v3";
1210
1230
  if (!updateCss) {
1211
1231
  spinner.stop();
1212
1232
  const result = await prompts2({
@@ -1229,7 +1249,7 @@ export function cn(...inputs: ClassValue[]) {
1229
1249
  }
1230
1250
  }
1231
1251
  let tailwindUpdated = false;
1232
- if (response.tailwindVersion === "v3" && tailwindConfig) {
1252
+ if (tailwindVersion === "v3" && tailwindConfig) {
1233
1253
  const tailwindConfigPath = path2.join(cwd, tailwindConfig);
1234
1254
  if (!await fs2.pathExists(tailwindConfigPath)) {
1235
1255
  await fs2.writeFile(tailwindConfigPath, getTailwindConfig(scopeTailwind));
@@ -1244,7 +1264,7 @@ export function cn(...inputs: ClassValue[]) {
1244
1264
  }
1245
1265
  const postcssConfigPath = path2.join(cwd, "postcss.config.js");
1246
1266
  let postcssConfigContent;
1247
- if (response.tailwindVersion === "v4") {
1267
+ if (tailwindVersion === "v4") {
1248
1268
  postcssConfigContent = isESM ? `export default {
1249
1269
  plugins: {
1250
1270
  '@tailwindcss/postcss': {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",