@happlyui/cli 0.3.1 → 0.3.2
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 +38 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -187131,7 +187131,7 @@ var require_dist2 = __commonJS((exports) => {
|
|
|
187131
187131
|
});
|
|
187132
187132
|
|
|
187133
187133
|
// src/types/index.ts
|
|
187134
|
-
var REGISTRY_URL = "https://raw.githubusercontent.com/Mindful-Connect/happly-ui-npm/production/packages/registry", CONFIG_FILE = "components.json", BASE_COLORS;
|
|
187134
|
+
var REGISTRY_URL = "https://raw.githubusercontent.com/Mindful-Connect/happly-ui-npm/production/packages/registry", CONFIG_FILE = "happly-ui-components.json", BASE_COLORS;
|
|
187135
187135
|
var init_types = __esm(() => {
|
|
187136
187136
|
BASE_COLORS = [
|
|
187137
187137
|
"slate",
|
|
@@ -187205,7 +187205,7 @@ function getComponentPath(componentName, componentType, config, fileName) {
|
|
|
187205
187205
|
case "registry:hook":
|
|
187206
187206
|
return path2.join(srcPrefix + (config.aliases.hooks || "@/hooks").replace("@/", ""), finalFileName);
|
|
187207
187207
|
case "registry:lib":
|
|
187208
|
-
return path2.join(srcPrefix + (config.aliases.lib || "@/lib").replace("@/", ""), finalFileName);
|
|
187208
|
+
return path2.join(srcPrefix + (config.aliases.lib || "@/lib").replace("@/", ""), "happly-ui", finalFileName);
|
|
187209
187209
|
default:
|
|
187210
187210
|
return path2.join(srcPrefix + config.aliases.ui.replace("@/", ""), finalFileName);
|
|
187211
187211
|
}
|
|
@@ -189691,7 +189691,8 @@ async function updateTailwindConfig(cwd, config, tailwindVersion) {
|
|
|
189691
189691
|
}
|
|
189692
189692
|
function generateCssVariables() {
|
|
189693
189693
|
const vars = [];
|
|
189694
|
-
const
|
|
189694
|
+
const colorsObj = colors;
|
|
189695
|
+
const ds = colorsObj.ds || {};
|
|
189695
189696
|
Object.entries(ds).forEach(([key, value]) => {
|
|
189696
189697
|
if (key === "primary")
|
|
189697
189698
|
return;
|
|
@@ -189731,7 +189732,8 @@ function generateThemeBlock() {
|
|
|
189731
189732
|
Object.entries(borderRadii).forEach(([key, value]) => {
|
|
189732
189733
|
lines.push(` --radius-${key}: ${value};`);
|
|
189733
189734
|
});
|
|
189734
|
-
const
|
|
189735
|
+
const colorsObj = colors;
|
|
189736
|
+
const ds = colorsObj.ds || {};
|
|
189735
189737
|
const flattenDs = (obj, prefix) => {
|
|
189736
189738
|
Object.entries(obj).forEach(([key, value]) => {
|
|
189737
189739
|
if (typeof value === "object" && value !== null) {
|
|
@@ -190130,13 +190132,13 @@ async function init(options) {
|
|
|
190130
190132
|
type: "text",
|
|
190131
190133
|
name: "componentsPath",
|
|
190132
190134
|
message: "Where should components be installed?",
|
|
190133
|
-
initial: projectInfo.isSrcDir ? "src/components/ui" : "components/ui"
|
|
190135
|
+
initial: projectInfo.isSrcDir ? "src/components/happly-ui" : "components/happly-ui"
|
|
190134
190136
|
},
|
|
190135
190137
|
{
|
|
190136
190138
|
type: "text",
|
|
190137
190139
|
name: "utilsPath",
|
|
190138
190140
|
message: "Where should utils be installed?",
|
|
190139
|
-
initial: projectInfo.isSrcDir ? "src/lib/utils" : "lib/utils"
|
|
190141
|
+
initial: projectInfo.isSrcDir ? "src/lib/happly-ui/happly-ui-utils" : "lib/happly-ui/happly-ui-utils"
|
|
190140
190142
|
}
|
|
190141
190143
|
]);
|
|
190142
190144
|
if (!responses.baseColor) {
|
|
@@ -190148,7 +190150,7 @@ async function init(options) {
|
|
|
190148
190150
|
const writeSpinner = ora("Writing configuration...").start();
|
|
190149
190151
|
try {
|
|
190150
190152
|
await writeConfig(cwd, config);
|
|
190151
|
-
writeSpinner.text =
|
|
190153
|
+
writeSpinner.text = `Created ${CONFIG_FILE}`;
|
|
190152
190154
|
const srcPrefix = config.srcDir ? "src/" : "";
|
|
190153
190155
|
const utilsPath = srcPrefix + config.aliases.utils.replace("@/", "");
|
|
190154
190156
|
const utilsContent = config.tsx ? UTILS_TEMPLATE : UTILS_JS_TEMPLATE;
|
|
@@ -190205,13 +190207,13 @@ async function init(options) {
|
|
|
190205
190207
|
logger.success("Project initialized successfully!");
|
|
190206
190208
|
logger.break();
|
|
190207
190209
|
logger.info("You can now add components:");
|
|
190208
|
-
logger.log(` ${logger.highlight("bunx --bun happlyui add button")}`);
|
|
190210
|
+
logger.log(` ${logger.highlight("bunx --bun @happlyui/cli add button")}`);
|
|
190209
190211
|
logger.break();
|
|
190210
190212
|
}
|
|
190211
190213
|
function createDefaultConfig(projectInfo) {
|
|
190212
190214
|
const isSrcDir = projectInfo.isSrcDir;
|
|
190213
190215
|
return {
|
|
190214
|
-
$schema: "https://cdn.jsdelivr.net/gh/Mindful-Connect/happly-ui-npm@production/schemas/components.json",
|
|
190216
|
+
$schema: "https://cdn.jsdelivr.net/gh/Mindful-Connect/happly-ui-npm@production/schemas/happly-ui-components.json",
|
|
190215
190217
|
srcDir: isSrcDir,
|
|
190216
190218
|
tailwind: {
|
|
190217
190219
|
config: projectInfo.tailwindConfig || "tailwind.config.ts",
|
|
@@ -190222,8 +190224,8 @@ function createDefaultConfig(projectInfo) {
|
|
|
190222
190224
|
tsx: projectInfo.isTypeScript,
|
|
190223
190225
|
aliases: {
|
|
190224
190226
|
components: "@/components",
|
|
190225
|
-
utils: "@/lib/utils",
|
|
190226
|
-
ui: "@/components/ui",
|
|
190227
|
+
utils: "@/lib/happly-ui/happly-ui-utils",
|
|
190228
|
+
ui: "@/components/happly-ui",
|
|
190227
190229
|
hooks: "@/hooks",
|
|
190228
190230
|
lib: "@/lib"
|
|
190229
190231
|
}
|
|
@@ -190231,7 +190233,7 @@ function createDefaultConfig(projectInfo) {
|
|
|
190231
190233
|
}
|
|
190232
190234
|
function createConfig(projectInfo, responses) {
|
|
190233
190235
|
return {
|
|
190234
|
-
$schema: "https://cdn.jsdelivr.net/gh/Mindful-Connect/happly-ui-npm@production/schemas/components.json",
|
|
190236
|
+
$schema: "https://cdn.jsdelivr.net/gh/Mindful-Connect/happly-ui-npm@production/schemas/happly-ui-components.json",
|
|
190235
190237
|
srcDir: projectInfo.isSrcDir,
|
|
190236
190238
|
tailwind: {
|
|
190237
190239
|
config: projectInfo.tailwindConfig || "tailwind.config.ts",
|
|
@@ -190270,22 +190272,21 @@ function transformImports(content, config) {
|
|
|
190270
190272
|
"@/components/ui": config.aliases.ui,
|
|
190271
190273
|
"@/components": config.aliases.components,
|
|
190272
190274
|
"@/lib/utils": config.aliases.utils,
|
|
190273
|
-
"@/lib": config.aliases.
|
|
190275
|
+
"@/lib/happly-ui-utils": config.aliases.utils,
|
|
190276
|
+
"@/lib": (config.aliases.lib || "@/lib") + "/happly-ui",
|
|
190274
190277
|
"@/hooks": config.aliases.hooks || "@/hooks"
|
|
190275
190278
|
};
|
|
190276
|
-
|
|
190277
|
-
|
|
190278
|
-
const
|
|
190279
|
-
|
|
190280
|
-
|
|
190281
|
-
|
|
190282
|
-
|
|
190283
|
-
|
|
190284
|
-
return match.replace(from, to);
|
|
190285
|
-
});
|
|
190279
|
+
const keys = Object.keys(pathMappings).sort((a, b) => b.length - a.length);
|
|
190280
|
+
return content.replace(/((?:from|import)\s+["'])([^"']*)(["'])/g, (match, prefix, path6, suffix) => {
|
|
190281
|
+
for (const key of keys) {
|
|
190282
|
+
if (path6 === key || path6.startsWith(key + "/")) {
|
|
190283
|
+
const to = pathMappings[key];
|
|
190284
|
+
const newPath = path6.replace(key, to);
|
|
190285
|
+
return `${prefix}${newPath}${suffix}`;
|
|
190286
|
+
}
|
|
190286
190287
|
}
|
|
190287
|
-
|
|
190288
|
-
|
|
190288
|
+
return match;
|
|
190289
|
+
});
|
|
190289
190290
|
}
|
|
190290
190291
|
function transformToJs(content) {
|
|
190291
190292
|
content = content.replace(/import\s+type\s*\{[^}]*\}\s*from\s*['"][^'"]+['"];?\n?/g, "");
|
|
@@ -190296,9 +190297,6 @@ function transformToJs(content) {
|
|
|
190296
190297
|
content = content.replace(/\s+as\s+\w+(\[\])?/g, "");
|
|
190297
190298
|
return content;
|
|
190298
190299
|
}
|
|
190299
|
-
function escapeRegex(str) {
|
|
190300
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
190301
|
-
}
|
|
190302
190300
|
|
|
190303
190301
|
// src/commands/add.ts
|
|
190304
190302
|
async function add(components, options) {
|
|
@@ -190367,7 +190365,12 @@ async function add(components, options) {
|
|
|
190367
190365
|
for (const item of items) {
|
|
190368
190366
|
for (const file of item.files) {
|
|
190369
190367
|
const fileType = file.type || item.type;
|
|
190370
|
-
|
|
190368
|
+
let fileName = path6.basename(file.path);
|
|
190369
|
+
if (fileType === "registry:lib") {
|
|
190370
|
+
if (file.path.startsWith("lib/")) {
|
|
190371
|
+
fileName = file.path.substring(4);
|
|
190372
|
+
}
|
|
190373
|
+
}
|
|
190371
190374
|
const targetPath = getComponentPath(item.name, fileType, config, fileName);
|
|
190372
190375
|
if (componentExists(cwd, targetPath)) {
|
|
190373
190376
|
existingFiles.push(targetPath);
|
|
@@ -190395,7 +190398,12 @@ async function add(components, options) {
|
|
|
190395
190398
|
for (const item of items) {
|
|
190396
190399
|
for (const file of item.files) {
|
|
190397
190400
|
const fileType = file.type || item.type;
|
|
190398
|
-
|
|
190401
|
+
let fileName = path6.basename(file.path);
|
|
190402
|
+
if (fileType === "registry:lib") {
|
|
190403
|
+
if (file.path.startsWith("lib/")) {
|
|
190404
|
+
fileName = file.path.substring(4);
|
|
190405
|
+
}
|
|
190406
|
+
}
|
|
190399
190407
|
const targetPath = getComponentPath(item.name, fileType, config, fileName);
|
|
190400
190408
|
const transformedContent = transformComponent(file, config);
|
|
190401
190409
|
await writeComponentFile(cwd, targetPath, transformedContent);
|