phpxui 0.0.4 → 0.0.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 +28 -27
- package/dist/utils/load-config.js +4 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,9 +14,6 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
|
|
|
14
14
|
const load_config_1 = require("./utils/load-config");
|
|
15
15
|
const icons_1 = require("./commands/icons");
|
|
16
16
|
(async () => {
|
|
17
|
-
/* ─────────────────────────────────────────────
|
|
18
|
-
* 1. Parse command & flags
|
|
19
|
-
* ──────────────────────────────────────────── */
|
|
20
17
|
const args = process.argv.slice(2);
|
|
21
18
|
const [command, ...rest] = args;
|
|
22
19
|
if (command !== "add") {
|
|
@@ -38,10 +35,8 @@ const icons_1 = require("./commands/icons");
|
|
|
38
35
|
names.push(tok);
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
/*
|
|
42
|
-
|
|
43
|
-
* ──────────────────────────────────────────── */
|
|
44
|
-
const config = (0, load_config_1.loadPhpXUIConfig)();
|
|
38
|
+
/* 2) Load config + detect first run */
|
|
39
|
+
const { config, isFirstRun } = (0, load_config_1.loadPhpXUIConfig)();
|
|
45
40
|
if (!config.iconsInstalled) {
|
|
46
41
|
await (0, icons_1.installIcons)([
|
|
47
42
|
"chevron-down",
|
|
@@ -61,27 +56,30 @@ const icons_1 = require("./commands/icons");
|
|
|
61
56
|
"panel-left",
|
|
62
57
|
], config);
|
|
63
58
|
}
|
|
64
|
-
/*
|
|
65
|
-
* 3. Housekeeping steps (always run)
|
|
66
|
-
* ──────────────────────────────────────────── */
|
|
59
|
+
/* 3) Housekeeping */
|
|
67
60
|
(0, ensure_package_1.ensurePackageInstalled)("tw-animate-css");
|
|
68
|
-
|
|
61
|
+
// ⬇️ IMPORTANT:
|
|
62
|
+
// Tailwind base CSS should only be *forced* on *first run*.
|
|
63
|
+
// Later runs: copy only if missing (no overwrite), even if --force.
|
|
64
|
+
const cssUpdated = (0, copy_tailwind_1.copyTailwindCss)(isFirstRun /* ignore flags.force here */);
|
|
69
65
|
if (cssUpdated) {
|
|
70
66
|
const relCss = path_1.default
|
|
71
67
|
.relative(process.cwd(), "src/app/css/tailwind.css")
|
|
72
68
|
.replace(/\\/g, "/");
|
|
73
|
-
console.log(chalk_1.default.green(
|
|
69
|
+
console.log(chalk_1.default.green(isFirstRun
|
|
70
|
+
? `✔ Installed base Tailwind CSS → ${relCss}`
|
|
71
|
+
: `✔ Added Tailwind CSS (missing) → ${relCss}`));
|
|
74
72
|
}
|
|
75
|
-
/*
|
|
76
|
-
* 4. Resolve output directory
|
|
77
|
-
* ──────────────────────────────────────────── */
|
|
73
|
+
/* 4) Resolve output directory */
|
|
78
74
|
const targetDir = path_1.default.resolve(config.outputDir || "src/Lib/PHPXUI");
|
|
79
75
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
// ⬇️ Components overwrite policy:
|
|
77
|
+
// - First run: force overwrite (replace everything)
|
|
78
|
+
// - Otherwise: only overwrite when --force is passed
|
|
79
|
+
const componentForce = isFirstRun || flags.force;
|
|
80
|
+
/* 5) Bulk mode */
|
|
83
81
|
if (flags.all) {
|
|
84
|
-
const { ok, fail } = await (0, php_components_bulk_1.generateAllComponents)(targetDir,
|
|
82
|
+
const { ok, fail } = await (0, php_components_bulk_1.generateAllComponents)(targetDir, componentForce);
|
|
85
83
|
console.log(chalk_1.default.green(`\n✔ Generated ${ok.length} components in ${path_1.default.relative(process.cwd(), targetDir)}`));
|
|
86
84
|
if (fail.length) {
|
|
87
85
|
console.log(chalk_1.default.red(`✖ ${fail.length} failures:`));
|
|
@@ -89,23 +87,26 @@ const icons_1 = require("./commands/icons");
|
|
|
89
87
|
}
|
|
90
88
|
process.exit(fail.length ? 1 : 0);
|
|
91
89
|
}
|
|
92
|
-
/*
|
|
93
|
-
* 6. Interactive prompt if no names given
|
|
94
|
-
* ───────────────────────────────────────── */
|
|
90
|
+
/* 6) Interactive prompt if no names given */
|
|
95
91
|
if (names.length === 0) {
|
|
96
92
|
const { componentList } = await (0, prompts_1.default)({
|
|
97
93
|
type: "text",
|
|
98
94
|
name: "componentList",
|
|
99
|
-
message: "Which components do you want to add? (space
|
|
95
|
+
message: "Which components do you want to add? (space- or comma-separated)",
|
|
100
96
|
validate: (v) => (v.trim() ? true : "Enter at least one name"),
|
|
101
97
|
});
|
|
102
98
|
names.push(...componentList.split(/[\s,]+/));
|
|
103
99
|
}
|
|
104
|
-
/*
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
/* 6.5) First-run: ensure core 'Slot' is installed (unless --all) */
|
|
101
|
+
if (isFirstRun && !flags.all) {
|
|
102
|
+
const hasSlot = names.some((n) => n.toLowerCase() === "slot");
|
|
103
|
+
if (!hasSlot) {
|
|
104
|
+
names.unshift("Slot"); // put it first so it logs clearly
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/* 7) Generate each requested component */
|
|
107
108
|
for (const name of names) {
|
|
108
|
-
const saved = await (0, php_component_1.generateComponent)(name, targetDir,
|
|
109
|
+
const saved = await (0, php_component_1.generateComponent)(name, targetDir, componentForce);
|
|
109
110
|
const paths = Array.isArray(saved) ? saved : [saved];
|
|
110
111
|
for (const abs of paths) {
|
|
111
112
|
const rel = path_1.default.relative(process.cwd(), abs).replace(/\\/g, "/");
|
|
@@ -24,14 +24,16 @@ const defaultConfig = {
|
|
|
24
24
|
},
|
|
25
25
|
iconLibrary: "ppicons",
|
|
26
26
|
};
|
|
27
|
+
// ⬇️ CHANGED: return { config, isFirstRun }
|
|
27
28
|
function loadPhpXUIConfig() {
|
|
28
29
|
const configPath = path_1.default.resolve("phpxui.json");
|
|
29
|
-
|
|
30
|
+
const existed = fs_1.default.existsSync(configPath);
|
|
31
|
+
if (!existed) {
|
|
30
32
|
fs_1.default.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
31
33
|
console.log("📦 Created default phpxui.json");
|
|
32
34
|
}
|
|
33
35
|
const content = fs_1.default.readFileSync(configPath, "utf-8");
|
|
34
|
-
return JSON.parse(content);
|
|
36
|
+
return { config: JSON.parse(content), isFirstRun: !existed };
|
|
35
37
|
}
|
|
36
38
|
function savePhpXUIConfig(config) {
|
|
37
39
|
const configPath = path_1.default.resolve("phpxui.json");
|