phpxui 0.0.3 → 0.0.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- # **phpxui-cli** — Instant PHPXUI Component Generator 🚀
1
+ # **phpxuicli** — 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 a single compressed request. |
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
- | **Cross‑platform** | Works equally on Windows, macOS and Linux. |
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-cli**. If you have ideas, found bugs, or want to add features, open an issue or submit a pull request.
118
+ We welcome contributions to improve **phpxuicli**. 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-cli` is released under the MIT License. See `LICENSE` for details.
124
+ `phpxuicli` 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 [The Steel Ninja Code](https://thesteelninjacode.com/), continuously pushing the boundaries of PHP development.
130
+ This project is developed and maintained by **TheSteelNinjaCode**, 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,6 +11,8 @@ 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
17
  /* ─────────────────────────────────────────────
16
18
  * 1. Parse command & flags
@@ -18,10 +20,10 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
18
20
  const args = process.argv.slice(2);
19
21
  const [command, ...rest] = args;
20
22
  if (command !== "add") {
21
- console.log(chalk_1.default.blue("Usage: phpxui add [--all] [--out <dir>] [--force] <component…>"));
23
+ console.log(chalk_1.default.blue("Usage: phpxui add [--all] [--force] <component…>"));
22
24
  process.exit(0);
23
25
  }
24
- const flags = { all: false, force: false, out: null };
26
+ const flags = { all: false, force: false };
25
27
  const names = [];
26
28
  for (let i = 0; i < rest.length; i++) {
27
29
  const tok = rest[i];
@@ -32,19 +34,37 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
32
34
  case "--force":
33
35
  flags.force = true;
34
36
  break;
35
- case "--out":
36
- flags.out = rest[++i] || null;
37
- break;
38
37
  default:
39
38
  names.push(tok);
40
39
  }
41
40
  }
42
41
  /* ─────────────────────────────────────────────
43
- * 2. Housekeeping steps (always run)
42
+ * 2. Load config and run first-time icon install
43
+ * ──────────────────────────────────────────── */
44
+ const config = (0, load_config_1.loadPhpXUIConfig)();
45
+ if (!config.iconsInstalled) {
46
+ await (0, icons_1.installIcons)([
47
+ "chevron-down",
48
+ "x",
49
+ "chevron-right",
50
+ "ellipsis",
51
+ "chevron-left",
52
+ "arrow-left",
53
+ "arrow-right",
54
+ "check",
55
+ "chevrons-up-down",
56
+ "search",
57
+ "circle",
58
+ "calendar",
59
+ "minus",
60
+ "chevron-up",
61
+ "panel-left",
62
+ ], config);
63
+ }
64
+ /* ─────────────────────────────────────────────
65
+ * 3. Housekeeping steps (always run)
44
66
  * ──────────────────────────────────────────── */
45
- // 2.a Ensure tw-animate-css is installed
46
67
  (0, ensure_package_1.ensurePackageInstalled)("tw-animate-css");
47
- // 2.b Keep Tailwind theme up‑to‑date in the project
48
68
  const cssUpdated = (0, copy_tailwind_1.copyTailwindCss)(flags.force);
49
69
  if (cssUpdated) {
50
70
  const relCss = path_1.default
@@ -53,12 +73,12 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
53
73
  console.log(chalk_1.default.green(`✔ Updated Tailwind CSS → ${relCss}`));
54
74
  }
55
75
  /* ─────────────────────────────────────────────
56
- * 3. Destination directory for components
76
+ * 4. Resolve output directory
57
77
  * ──────────────────────────────────────────── */
58
- const targetDir = path_1.default.resolve(flags.out ?? "src/Lib/PHPXUI");
78
+ const targetDir = path_1.default.resolve(config.outputDir || "src/Lib/PHPXUI");
59
79
  try {
60
80
  /* ─────────────────────────────────────────
61
- * 4. Bulk mode (--all)
81
+ * 5. Bulk mode (--all)
62
82
  * ───────────────────────────────────────── */
63
83
  if (flags.all) {
64
84
  const { ok, fail } = await (0, php_components_bulk_1.generateAllComponents)(targetDir, flags.force);
@@ -70,7 +90,7 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
70
90
  process.exit(fail.length ? 1 : 0);
71
91
  }
72
92
  /* ─────────────────────────────────────────
73
- * 5. Interactive prompt if no names given
93
+ * 6. Interactive prompt if no names given
74
94
  * ───────────────────────────────────────── */
75
95
  if (names.length === 0) {
76
96
  const { componentList } = await (0, prompts_1.default)({
@@ -82,7 +102,7 @@ const copy_tailwind_1 = require("./generators/copy-tailwind");
82
102
  names.push(...componentList.split(/[\s,]+/));
83
103
  }
84
104
  /* ─────────────────────────────────────────
85
- * 6. Generate each requested component
105
+ * 7. Generate each requested component
86
106
  * ───────────────────────────────────────── */
87
107
  for (const name of names) {
88
108
  const saved = await (0, php_component_1.generateComponent)(name, targetDir, flags.force);
@@ -0,0 +1,39 @@
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
+ function loadPhpXUIConfig() {
28
+ const configPath = path_1.default.resolve("phpxui.json");
29
+ if (!fs_1.default.existsSync(configPath)) {
30
+ fs_1.default.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
31
+ console.log("📦 Created default phpxui.json");
32
+ }
33
+ const content = fs_1.default.readFileSync(configPath, "utf-8");
34
+ return JSON.parse(content);
35
+ }
36
+ function savePhpXUIConfig(config) {
37
+ const configPath = path_1.default.resolve("phpxui.json");
38
+ fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2));
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phpxui",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "A package for generating Prisma PHP components with a CLI interface.",
5
5
  "main": "index.js",
6
6
  "scripts": {