@happlyui/cli 0.1.4 → 0.1.5

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 +101 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -188726,6 +188726,7 @@ async function detectProject(cwd) {
188726
188726
  isSrcDir: false,
188727
188727
  tailwindConfig: null,
188728
188728
  tailwindCss: null,
188729
+ tailwindVersion: 3,
188729
188730
  packageManager: "bun",
188730
188731
  aliases: {},
188731
188732
  framework: "unknown"
@@ -188735,6 +188736,7 @@ async function detectProject(cwd) {
188735
188736
  info.packageManager = await detectPackageManager(cwd);
188736
188737
  info.tailwindConfig = await detectTailwindConfig(cwd);
188737
188738
  info.tailwindCss = await detectTailwindCss(cwd);
188739
+ info.tailwindVersion = await detectTailwindVersion(cwd, info.tailwindCss);
188738
188740
  info.framework = await detectFramework(cwd);
188739
188741
  if (info.isTypeScript) {
188740
188742
  info.aliases = await detectAliases(cwd);
@@ -188795,6 +188797,37 @@ async function detectTailwindCss(cwd) {
188795
188797
  }
188796
188798
  return null;
188797
188799
  }
188800
+ async function detectTailwindVersion(cwd, cssFile) {
188801
+ try {
188802
+ const pkgPath = path.join(cwd, "package.json");
188803
+ if (existsSync(pkgPath)) {
188804
+ const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
188805
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
188806
+ if (deps["@tailwindcss/vite"] || deps["@tailwindcss/postcss"] || deps["@tailwindcss/cli"]) {
188807
+ return 4;
188808
+ }
188809
+ const twVersion = deps["tailwindcss"];
188810
+ if (twVersion) {
188811
+ const versionMatch = twVersion.match(/(\d+)\./);
188812
+ if (versionMatch && parseInt(versionMatch[1], 10) >= 4) {
188813
+ return 4;
188814
+ }
188815
+ }
188816
+ }
188817
+ } catch {}
188818
+ if (cssFile) {
188819
+ try {
188820
+ const cssPath = path.join(cwd, cssFile);
188821
+ if (existsSync(cssPath)) {
188822
+ const content = await readFile(cssPath, "utf-8");
188823
+ if (content.includes('@import "tailwindcss"') || content.includes("@import 'tailwindcss'")) {
188824
+ return 4;
188825
+ }
188826
+ }
188827
+ } catch {}
188828
+ }
188829
+ return 3;
188830
+ }
188798
188831
  async function detectFramework(cwd) {
188799
188832
  if (existsSync(path.join(cwd, "next.config.js")) || existsSync(path.join(cwd, "next.config.ts")) || existsSync(path.join(cwd, "next.config.mjs"))) {
188800
188833
  return "next";
@@ -188988,7 +189021,7 @@ export function cn(...inputs) {
188988
189021
  return twMerge(clsx(inputs));
188989
189022
  }
188990
189023
  `;
188991
- var CSS_TEMPLATE = `@tailwind base;
189024
+ var CSS_TEMPLATE_V3 = `@tailwind base;
188992
189025
  @tailwind components;
188993
189026
  @tailwind utilities;
188994
189027
 
@@ -189048,6 +189081,64 @@ var CSS_TEMPLATE = `@tailwind base;
189048
189081
  }
189049
189082
  }
189050
189083
  `;
189084
+ var CSS_TEMPLATE_V4 = `@import "tailwindcss";
189085
+
189086
+ @layer base {
189087
+ :root {
189088
+ --background: 0 0% 100%;
189089
+ --foreground: 222.2 84% 4.9%;
189090
+ --card: 0 0% 100%;
189091
+ --card-foreground: 222.2 84% 4.9%;
189092
+ --popover: 0 0% 100%;
189093
+ --popover-foreground: 222.2 84% 4.9%;
189094
+ --primary: 222.2 47.4% 11.2%;
189095
+ --primary-foreground: 210 40% 98%;
189096
+ --secondary: 210 40% 96.1%;
189097
+ --secondary-foreground: 222.2 47.4% 11.2%;
189098
+ --muted: 210 40% 96.1%;
189099
+ --muted-foreground: 215.4 16.3% 46.9%;
189100
+ --accent: 210 40% 96.1%;
189101
+ --accent-foreground: 222.2 47.4% 11.2%;
189102
+ --destructive: 0 84.2% 60.2%;
189103
+ --destructive-foreground: 210 40% 98%;
189104
+ --border: 214.3 31.8% 91.4%;
189105
+ --input: 214.3 31.8% 91.4%;
189106
+ --ring: 222.2 84% 4.9%;
189107
+ --radius: 0.5rem;
189108
+ }
189109
+
189110
+ .dark {
189111
+ --background: 222.2 84% 4.9%;
189112
+ --foreground: 210 40% 98%;
189113
+ --card: 222.2 84% 4.9%;
189114
+ --card-foreground: 210 40% 98%;
189115
+ --popover: 222.2 84% 4.9%;
189116
+ --popover-foreground: 210 40% 98%;
189117
+ --primary: 210 40% 98%;
189118
+ --primary-foreground: 222.2 47.4% 11.2%;
189119
+ --secondary: 217.2 32.6% 17.5%;
189120
+ --secondary-foreground: 210 40% 98%;
189121
+ --muted: 217.2 32.6% 17.5%;
189122
+ --muted-foreground: 215 20.2% 65.1%;
189123
+ --accent: 217.2 32.6% 17.5%;
189124
+ --accent-foreground: 210 40% 98%;
189125
+ --destructive: 0 62.8% 30.6%;
189126
+ --destructive-foreground: 210 40% 98%;
189127
+ --border: 217.2 32.6% 17.5%;
189128
+ --input: 217.2 32.6% 17.5%;
189129
+ --ring: 212.7 26.8% 83.9%;
189130
+ }
189131
+
189132
+ * {
189133
+ border-color: hsl(var(--border));
189134
+ }
189135
+
189136
+ body {
189137
+ background-color: hsl(var(--background));
189138
+ color: hsl(var(--foreground));
189139
+ }
189140
+ }
189141
+ `;
189051
189142
  async function init(options) {
189052
189143
  const cwd = options.cwd || process.cwd();
189053
189144
  const nonInteractive = isNonInteractive();
@@ -189079,6 +189170,7 @@ async function init(options) {
189079
189170
  logger.info(`Framework: ${logger.highlight(projectInfo.framework)}`);
189080
189171
  logger.info(`TypeScript: ${logger.highlight(String(projectInfo.isTypeScript))}`);
189081
189172
  logger.info(`Package Manager: ${logger.highlight(projectInfo.packageManager)}`);
189173
+ logger.info(`Tailwind CSS: ${logger.highlight(`v${projectInfo.tailwindVersion}`)}`);
189082
189174
  if (projectInfo.tailwindConfig) {
189083
189175
  logger.info(`Tailwind Config: ${logger.highlight(projectInfo.tailwindConfig)}`);
189084
189176
  }
@@ -189141,14 +189233,20 @@ async function init(options) {
189141
189233
  writeSpinner.text = `Created ${utilsPath}${utilsExt}`;
189142
189234
  const cssPath = config.tailwind.css;
189143
189235
  const fullCssPath = path3.join(cwd, cssPath);
189236
+ const cssTemplate = projectInfo.tailwindVersion === 4 ? CSS_TEMPLATE_V4 : CSS_TEMPLATE_V3;
189144
189237
  if (!existsSync3(fullCssPath)) {
189145
- await writeComponentFile(cwd, cssPath, CSS_TEMPLATE);
189238
+ await writeComponentFile(cwd, cssPath, cssTemplate);
189146
189239
  writeSpinner.text = `Created ${cssPath}`;
189147
189240
  } else {
189148
189241
  const existingCss = await readFile3(fullCssPath, "utf-8");
189149
189242
  if (!existingCss.includes("--background:")) {
189150
- await writeFile2(fullCssPath, CSS_TEMPLATE + `
189243
+ if (projectInfo.tailwindVersion === 4 && existingCss.includes('@import "tailwindcss"')) {
189244
+ const updatedCss = existingCss.replace('@import "tailwindcss";', cssTemplate);
189245
+ await writeFile2(fullCssPath, updatedCss, "utf-8");
189246
+ } else {
189247
+ await writeFile2(fullCssPath, cssTemplate + `
189151
189248
  ` + existingCss, "utf-8");
189249
+ }
189152
189250
  writeSpinner.text = `Updated ${cssPath}`;
189153
189251
  }
189154
189252
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happlyui/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Add HapplyUI components to your project",
5
5
  "type": "module",
6
6
  "bin": {