phpxui 0.0.3 → 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/README.md +30 -12
- package/dist/commands/icons.js +25 -0
- package/dist/index.js +52 -31
- package/dist/utils/load-config.js +41 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# **phpxui
|
|
1
|
+
# **phpxui‑cli** — Instant PHPXUI Component Generator 🚀
|
|
2
2
|
|
|
3
3
|
> **Generate fully‑typed PHPXUI components for Prisma PHP right from the terminal.**
|
|
4
4
|
> ⚡ **Single component** → `npx phpxui add Alert` | 🌌 **Whole library** → `npx phpxui add --all`
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
## ✨ Features
|
|
9
9
|
|
|
10
|
-
| Feature | Details
|
|
11
|
-
| --------------------- |
|
|
12
|
-
| **Bulk install** | `--all` downloads every component in
|
|
13
|
-
| **Ready‑to‑use code** | Each file already contains the `$class` merge logic and `{$attributes}` placeholder for Wave
|
|
14
|
-
| **Clean paths** | Files are written under `src/Lib/PHPXUI/FancyName.php` with OS‑agnostic separators.
|
|
15
|
-
| **Friendly output** | Clear green / red summary with relative paths only.
|
|
16
|
-
| **
|
|
10
|
+
| Feature | Details |
|
|
11
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
12
|
+
| **Bulk install** | `--all` downloads every component in one shot. |
|
|
13
|
+
| **Ready‑to‑use code** | Each file already contains the `$class` merge logic and `{$attributes}` placeholder for **Wave** reactivity. |
|
|
14
|
+
| **Clean paths** | Files are written under `src/Lib/PHPXUI/FancyName.php` with OS‑agnostic separators. |
|
|
15
|
+
| **Friendly output** | Clear green / red summary with relative paths only. |
|
|
16
|
+
| **Automatic icons** | Core **PPIcons** (`x`, `chevron‑down`, `chevron‑right`) are installed on the very first run. |
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -47,6 +47,10 @@ npx phpxui add --all
|
|
|
47
47
|
CLI output example:
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
+
📦 Installing ppicons CLI…
|
|
51
|
+
✨ Installing default icons: x chevron-down chevron-right
|
|
52
|
+
✔ Icons installed in src/Lib/PPIcons
|
|
53
|
+
|
|
50
54
|
✔ Alert → src/Lib/PHPXUI/Alert.php
|
|
51
55
|
✔ Dialog → src/Lib/PHPXUI/Dialog.php
|
|
52
56
|
✔ Badge → src/Lib/PHPXUI/Badge.php
|
|
@@ -84,9 +88,23 @@ class Alert extends PHPX
|
|
|
84
88
|
| --------------- | -------------------------------------------------------- |
|
|
85
89
|
| `<component …>` | One or more component names separated by space or comma. |
|
|
86
90
|
| `--all` | Download the full catalogue in one request. |
|
|
87
|
-
| `--out <dir>` | Destination folder (default `src/Lib/PHPXUI`). |
|
|
88
91
|
| `--force` | Overwrite existing files. |
|
|
89
92
|
|
|
93
|
+
> **Note:** The CLI automatically installs a default set of core icons (such as `x`, `chevron-down`, `chevron-right`) on first use. Extra icons are not yet selectable via `phpxui` directly.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🎨 Using Additional Icons
|
|
98
|
+
|
|
99
|
+
Need more icons? Use the **PPIcons** CLI directly:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx ppicons add menu chevron-left arrow-right
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This will place the requested icons under `src/Lib/PPIcons` with full PHPXUI typings.
|
|
106
|
+
Browse the complete icon catalogue and usage docs at **[https://ppicons.tsnc.tech/](https://ppicons.tsnc.tech/)**.
|
|
107
|
+
|
|
90
108
|
---
|
|
91
109
|
|
|
92
110
|
## 📚 Documentation
|
|
@@ -97,19 +115,19 @@ Full guides and examples live at the [PHPXUI documentation site](https://phpxui.
|
|
|
97
115
|
|
|
98
116
|
## 💡 Contributing
|
|
99
117
|
|
|
100
|
-
We welcome contributions to improve **phpxui
|
|
118
|
+
We welcome contributions to improve **phpxui‑cli**. If you have ideas, find bugs, or want to add features, open an issue or submit a pull request.
|
|
101
119
|
|
|
102
120
|
---
|
|
103
121
|
|
|
104
122
|
## 📄 License
|
|
105
123
|
|
|
106
|
-
`phpxui
|
|
124
|
+
`phpxui‑cli` is released under the MIT License. See `LICENSE` for details.
|
|
107
125
|
|
|
108
126
|
---
|
|
109
127
|
|
|
110
128
|
## 👤 Author
|
|
111
129
|
|
|
112
|
-
This project is developed and maintained by
|
|
130
|
+
This project is developed and maintained by **The Steel Ninja Code**, continuously pushing the boundaries of PHP development.
|
|
113
131
|
|
|
114
132
|
---
|
|
115
133
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.installIcons = installIcons;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const load_config_1 = require("../utils/load-config");
|
|
10
|
+
async function installIcons(iconList, config) {
|
|
11
|
+
try {
|
|
12
|
+
console.log(chalk_1.default.blue("📦 Installing ppicons CLI..."));
|
|
13
|
+
(0, child_process_1.execSync)("npm install -g ppicons", { stdio: "inherit" });
|
|
14
|
+
const args = iconList.join(" ");
|
|
15
|
+
console.log(chalk_1.default.blue(`✨ Installing default icons: ${args}`));
|
|
16
|
+
(0, child_process_1.execSync)(`npx ppicons add ${args}`, { stdio: "inherit" });
|
|
17
|
+
console.log(chalk_1.default.green("✔ Icons installed in src/Lib/PPIcons"));
|
|
18
|
+
config.iconsInstalled = true;
|
|
19
|
+
(0, load_config_1.savePhpXUIConfig)(config); // ⬅️ persist change
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error(chalk_1.default.red("✖ Failed to install icons:"), err.message);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -11,17 +11,16 @@ const php_component_1 = require("./generators/php-component");
|
|
|
11
11
|
const php_components_bulk_1 = require("./generators/php-components-bulk");
|
|
12
12
|
const ensure_package_1 = require("./generators/ensure-package");
|
|
13
13
|
const copy_tailwind_1 = require("./generators/copy-tailwind");
|
|
14
|
+
const load_config_1 = require("./utils/load-config");
|
|
15
|
+
const icons_1 = require("./commands/icons");
|
|
14
16
|
(async () => {
|
|
15
|
-
/* ─────────────────────────────────────────────
|
|
16
|
-
* 1. Parse command & flags
|
|
17
|
-
* ──────────────────────────────────────────── */
|
|
18
17
|
const args = process.argv.slice(2);
|
|
19
18
|
const [command, ...rest] = args;
|
|
20
19
|
if (command !== "add") {
|
|
21
|
-
console.log(chalk_1.default.blue("Usage: phpxui add [--all] [--
|
|
20
|
+
console.log(chalk_1.default.blue("Usage: phpxui add [--all] [--force] <component…>"));
|
|
22
21
|
process.exit(0);
|
|
23
22
|
}
|
|
24
|
-
const flags = { all: false, force: false
|
|
23
|
+
const flags = { all: false, force: false };
|
|
25
24
|
const names = [];
|
|
26
25
|
for (let i = 0; i < rest.length; i++) {
|
|
27
26
|
const tok = rest[i];
|
|
@@ -32,36 +31,55 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
|
|
|
32
31
|
case "--force":
|
|
33
32
|
flags.force = true;
|
|
34
33
|
break;
|
|
35
|
-
case "--out":
|
|
36
|
-
flags.out = rest[++i] || null;
|
|
37
|
-
break;
|
|
38
34
|
default:
|
|
39
35
|
names.push(tok);
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
|
-
/*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
/* 2) Load config + detect first run */
|
|
39
|
+
const { config, isFirstRun } = (0, load_config_1.loadPhpXUIConfig)();
|
|
40
|
+
if (!config.iconsInstalled) {
|
|
41
|
+
await (0, icons_1.installIcons)([
|
|
42
|
+
"chevron-down",
|
|
43
|
+
"x",
|
|
44
|
+
"chevron-right",
|
|
45
|
+
"ellipsis",
|
|
46
|
+
"chevron-left",
|
|
47
|
+
"arrow-left",
|
|
48
|
+
"arrow-right",
|
|
49
|
+
"check",
|
|
50
|
+
"chevrons-up-down",
|
|
51
|
+
"search",
|
|
52
|
+
"circle",
|
|
53
|
+
"calendar",
|
|
54
|
+
"minus",
|
|
55
|
+
"chevron-up",
|
|
56
|
+
"panel-left",
|
|
57
|
+
], config);
|
|
58
|
+
}
|
|
59
|
+
/* 3) Housekeeping */
|
|
46
60
|
(0, ensure_package_1.ensurePackageInstalled)("tw-animate-css");
|
|
47
|
-
//
|
|
48
|
-
|
|
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 */);
|
|
49
65
|
if (cssUpdated) {
|
|
50
66
|
const relCss = path_1.default
|
|
51
67
|
.relative(process.cwd(), "src/app/css/tailwind.css")
|
|
52
68
|
.replace(/\\/g, "/");
|
|
53
|
-
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}`));
|
|
54
72
|
}
|
|
55
|
-
/*
|
|
56
|
-
|
|
57
|
-
* ──────────────────────────────────────────── */
|
|
58
|
-
const targetDir = path_1.default.resolve(flags.out ?? "src/Lib/PHPXUI");
|
|
73
|
+
/* 4) Resolve output directory */
|
|
74
|
+
const targetDir = path_1.default.resolve(config.outputDir || "src/Lib/PHPXUI");
|
|
59
75
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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 */
|
|
63
81
|
if (flags.all) {
|
|
64
|
-
const { ok, fail } = await (0, php_components_bulk_1.generateAllComponents)(targetDir,
|
|
82
|
+
const { ok, fail } = await (0, php_components_bulk_1.generateAllComponents)(targetDir, componentForce);
|
|
65
83
|
console.log(chalk_1.default.green(`\n✔ Generated ${ok.length} components in ${path_1.default.relative(process.cwd(), targetDir)}`));
|
|
66
84
|
if (fail.length) {
|
|
67
85
|
console.log(chalk_1.default.red(`✖ ${fail.length} failures:`));
|
|
@@ -69,23 +87,26 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
|
|
|
69
87
|
}
|
|
70
88
|
process.exit(fail.length ? 1 : 0);
|
|
71
89
|
}
|
|
72
|
-
/*
|
|
73
|
-
* 5. Interactive prompt if no names given
|
|
74
|
-
* ───────────────────────────────────────── */
|
|
90
|
+
/* 6) Interactive prompt if no names given */
|
|
75
91
|
if (names.length === 0) {
|
|
76
92
|
const { componentList } = await (0, prompts_1.default)({
|
|
77
93
|
type: "text",
|
|
78
94
|
name: "componentList",
|
|
79
|
-
message: "Which components do you want to add? (space
|
|
95
|
+
message: "Which components do you want to add? (space- or comma-separated)",
|
|
80
96
|
validate: (v) => (v.trim() ? true : "Enter at least one name"),
|
|
81
97
|
});
|
|
82
98
|
names.push(...componentList.split(/[\s,]+/));
|
|
83
99
|
}
|
|
84
|
-
/*
|
|
85
|
-
|
|
86
|
-
|
|
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 */
|
|
87
108
|
for (const name of names) {
|
|
88
|
-
const saved = await (0, php_component_1.generateComponent)(name, targetDir,
|
|
109
|
+
const saved = await (0, php_component_1.generateComponent)(name, targetDir, componentForce);
|
|
89
110
|
const paths = Array.isArray(saved) ? saved : [saved];
|
|
90
111
|
for (const abs of paths) {
|
|
91
112
|
const rel = path_1.default.relative(process.cwd(), abs).replace(/\\/g, "/");
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadPhpXUIConfig = loadPhpXUIConfig;
|
|
7
|
+
exports.savePhpXUIConfig = savePhpXUIConfig;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const defaultConfig = {
|
|
11
|
+
style: "new-york",
|
|
12
|
+
force: false,
|
|
13
|
+
outputDir: "src/Lib/PHPXUI",
|
|
14
|
+
iconsInstalled: false,
|
|
15
|
+
tailwind: {
|
|
16
|
+
css: "src/app/css/tailwind.css",
|
|
17
|
+
baseColor: "neutral",
|
|
18
|
+
cssVariables: true,
|
|
19
|
+
prefix: "",
|
|
20
|
+
},
|
|
21
|
+
psr4: {
|
|
22
|
+
Components: "src/Lib/PHPXUI/",
|
|
23
|
+
Icons: "src/Lib/PPIcons/",
|
|
24
|
+
},
|
|
25
|
+
iconLibrary: "ppicons",
|
|
26
|
+
};
|
|
27
|
+
// ⬇️ CHANGED: return { config, isFirstRun }
|
|
28
|
+
function loadPhpXUIConfig() {
|
|
29
|
+
const configPath = path_1.default.resolve("phpxui.json");
|
|
30
|
+
const existed = fs_1.default.existsSync(configPath);
|
|
31
|
+
if (!existed) {
|
|
32
|
+
fs_1.default.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
33
|
+
console.log("📦 Created default phpxui.json");
|
|
34
|
+
}
|
|
35
|
+
const content = fs_1.default.readFileSync(configPath, "utf-8");
|
|
36
|
+
return { config: JSON.parse(content), isFirstRun: !existed };
|
|
37
|
+
}
|
|
38
|
+
function savePhpXUIConfig(config) {
|
|
39
|
+
const configPath = path_1.default.resolve("phpxui.json");
|
|
40
|
+
fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
41
|
+
}
|