@happlyui/cli 0.1.3 → 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.
- package/dist/index.js +107 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -187362,6 +187362,9 @@ var {
|
|
|
187362
187362
|
Help
|
|
187363
187363
|
} = import__.default;
|
|
187364
187364
|
|
|
187365
|
+
// src/index.ts
|
|
187366
|
+
import { createRequire as createRequire2 } from "module";
|
|
187367
|
+
|
|
187365
187368
|
// src/commands/init.ts
|
|
187366
187369
|
var import_prompts = __toESM(require_prompts3(), 1);
|
|
187367
187370
|
|
|
@@ -188723,6 +188726,7 @@ async function detectProject(cwd) {
|
|
|
188723
188726
|
isSrcDir: false,
|
|
188724
188727
|
tailwindConfig: null,
|
|
188725
188728
|
tailwindCss: null,
|
|
188729
|
+
tailwindVersion: 3,
|
|
188726
188730
|
packageManager: "bun",
|
|
188727
188731
|
aliases: {},
|
|
188728
188732
|
framework: "unknown"
|
|
@@ -188732,6 +188736,7 @@ async function detectProject(cwd) {
|
|
|
188732
188736
|
info.packageManager = await detectPackageManager(cwd);
|
|
188733
188737
|
info.tailwindConfig = await detectTailwindConfig(cwd);
|
|
188734
188738
|
info.tailwindCss = await detectTailwindCss(cwd);
|
|
188739
|
+
info.tailwindVersion = await detectTailwindVersion(cwd, info.tailwindCss);
|
|
188735
188740
|
info.framework = await detectFramework(cwd);
|
|
188736
188741
|
if (info.isTypeScript) {
|
|
188737
188742
|
info.aliases = await detectAliases(cwd);
|
|
@@ -188792,6 +188797,37 @@ async function detectTailwindCss(cwd) {
|
|
|
188792
188797
|
}
|
|
188793
188798
|
return null;
|
|
188794
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
|
+
}
|
|
188795
188831
|
async function detectFramework(cwd) {
|
|
188796
188832
|
if (existsSync(path.join(cwd, "next.config.js")) || existsSync(path.join(cwd, "next.config.ts")) || existsSync(path.join(cwd, "next.config.mjs"))) {
|
|
188797
188833
|
return "next";
|
|
@@ -188985,7 +189021,7 @@ export function cn(...inputs) {
|
|
|
188985
189021
|
return twMerge(clsx(inputs));
|
|
188986
189022
|
}
|
|
188987
189023
|
`;
|
|
188988
|
-
var
|
|
189024
|
+
var CSS_TEMPLATE_V3 = `@tailwind base;
|
|
188989
189025
|
@tailwind components;
|
|
188990
189026
|
@tailwind utilities;
|
|
188991
189027
|
|
|
@@ -189045,6 +189081,64 @@ var CSS_TEMPLATE = `@tailwind base;
|
|
|
189045
189081
|
}
|
|
189046
189082
|
}
|
|
189047
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
|
+
`;
|
|
189048
189142
|
async function init(options) {
|
|
189049
189143
|
const cwd = options.cwd || process.cwd();
|
|
189050
189144
|
const nonInteractive = isNonInteractive();
|
|
@@ -189076,6 +189170,7 @@ async function init(options) {
|
|
|
189076
189170
|
logger.info(`Framework: ${logger.highlight(projectInfo.framework)}`);
|
|
189077
189171
|
logger.info(`TypeScript: ${logger.highlight(String(projectInfo.isTypeScript))}`);
|
|
189078
189172
|
logger.info(`Package Manager: ${logger.highlight(projectInfo.packageManager)}`);
|
|
189173
|
+
logger.info(`Tailwind CSS: ${logger.highlight(`v${projectInfo.tailwindVersion}`)}`);
|
|
189079
189174
|
if (projectInfo.tailwindConfig) {
|
|
189080
189175
|
logger.info(`Tailwind Config: ${logger.highlight(projectInfo.tailwindConfig)}`);
|
|
189081
189176
|
}
|
|
@@ -189138,14 +189233,20 @@ async function init(options) {
|
|
|
189138
189233
|
writeSpinner.text = `Created ${utilsPath}${utilsExt}`;
|
|
189139
189234
|
const cssPath = config.tailwind.css;
|
|
189140
189235
|
const fullCssPath = path3.join(cwd, cssPath);
|
|
189236
|
+
const cssTemplate = projectInfo.tailwindVersion === 4 ? CSS_TEMPLATE_V4 : CSS_TEMPLATE_V3;
|
|
189141
189237
|
if (!existsSync3(fullCssPath)) {
|
|
189142
|
-
await writeComponentFile(cwd, cssPath,
|
|
189238
|
+
await writeComponentFile(cwd, cssPath, cssTemplate);
|
|
189143
189239
|
writeSpinner.text = `Created ${cssPath}`;
|
|
189144
189240
|
} else {
|
|
189145
189241
|
const existingCss = await readFile3(fullCssPath, "utf-8");
|
|
189146
189242
|
if (!existingCss.includes("--background:")) {
|
|
189147
|
-
|
|
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 + `
|
|
189148
189248
|
` + existingCss, "utf-8");
|
|
189249
|
+
}
|
|
189149
189250
|
writeSpinner.text = `Updated ${cssPath}`;
|
|
189150
189251
|
}
|
|
189151
189252
|
}
|
|
@@ -189418,8 +189519,10 @@ function pascalCase(str) {
|
|
|
189418
189519
|
|
|
189419
189520
|
// src/index.ts
|
|
189420
189521
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
189522
|
+
var require2 = createRequire2(import.meta.url);
|
|
189523
|
+
var { version } = require2("../package.json");
|
|
189421
189524
|
var program2 = new Command;
|
|
189422
|
-
program2.name("happlyui").description("Add HapplyUI components to your project").version(
|
|
189525
|
+
program2.name("happlyui").description("Add HapplyUI components to your project").version(version);
|
|
189423
189526
|
program2.command("init").description("Initialize your project with HapplyUI").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-y, --yes", "Skip prompts and use defaults").option("--defaults", "Use default configuration").option("--base-color <color>", "Base color theme (slate, gray, zinc, neutral, stone)").option("--no-css-variables", "Disable CSS variables for colors").action(init);
|
|
189424
189527
|
program2.command("add").description("Add components to your project").argument("[components...]", "Components to add").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-y, --yes", "Skip prompts").option("-o, --overwrite", "Overwrite existing files").option("-a, --all", "Add all available components").option("-p, --path <path>", "Custom path for components").action(add);
|
|
189425
189528
|
program2.command("list").description("List all available components").option("-c, --cwd <path>", "Working directory", process.cwd()).action(async (options) => {
|