phpxui 0.0.1 → 0.0.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.
@@ -0,0 +1,122 @@
1
+ @import "tailwindcss";
2
+ @import "tw-animate-css";
3
+
4
+ @custom-variant dark (&:is(.dark *));
5
+
6
+ @theme inline {
7
+ --color-background: var(--background);
8
+ --color-foreground: var(--foreground);
9
+ --font-sans: var(--font-geist-sans);
10
+ --font-mono: var(--font-geist-mono);
11
+ --color-sidebar-ring: var(--sidebar-ring);
12
+ --color-sidebar-border: var(--sidebar-border);
13
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
14
+ --color-sidebar-accent: var(--sidebar-accent);
15
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
16
+ --color-sidebar-primary: var(--sidebar-primary);
17
+ --color-sidebar-foreground: var(--sidebar-foreground);
18
+ --color-sidebar: var(--sidebar);
19
+ --color-chart-5: var(--chart-5);
20
+ --color-chart-4: var(--chart-4);
21
+ --color-chart-3: var(--chart-3);
22
+ --color-chart-2: var(--chart-2);
23
+ --color-chart-1: var(--chart-1);
24
+ --color-ring: var(--ring);
25
+ --color-input: var(--input);
26
+ --color-border: var(--border);
27
+ --color-destructive: var(--destructive);
28
+ --color-accent-foreground: var(--accent-foreground);
29
+ --color-accent: var(--accent);
30
+ --color-muted-foreground: var(--muted-foreground);
31
+ --color-muted: var(--muted);
32
+ --color-secondary-foreground: var(--secondary-foreground);
33
+ --color-secondary: var(--secondary);
34
+ --color-primary-foreground: var(--primary-foreground);
35
+ --color-primary: var(--primary);
36
+ --color-popover-foreground: var(--popover-foreground);
37
+ --color-popover: var(--popover);
38
+ --color-card-foreground: var(--card-foreground);
39
+ --color-card: var(--card);
40
+ --radius-sm: calc(var(--radius) - 4px);
41
+ --radius-md: calc(var(--radius) - 2px);
42
+ --radius-lg: var(--radius);
43
+ --radius-xl: calc(var(--radius) + 4px);
44
+ }
45
+
46
+ :root {
47
+ --radius: 0.625rem;
48
+ --background: oklch(1 0 0);
49
+ --foreground: oklch(0.145 0 0);
50
+ --card: oklch(1 0 0);
51
+ --card-foreground: oklch(0.145 0 0);
52
+ --popover: oklch(1 0 0);
53
+ --popover-foreground: oklch(0.145 0 0);
54
+ --primary: oklch(0.205 0 0);
55
+ --primary-foreground: oklch(0.985 0 0);
56
+ --secondary: oklch(0.97 0 0);
57
+ --secondary-foreground: oklch(0.205 0 0);
58
+ --muted: oklch(0.97 0 0);
59
+ --muted-foreground: oklch(0.556 0 0);
60
+ --accent: oklch(0.97 0 0);
61
+ --accent-foreground: oklch(0.205 0 0);
62
+ --destructive: oklch(0.577 0.245 27.325);
63
+ --border: oklch(0.922 0 0);
64
+ --input: oklch(0.922 0 0);
65
+ --ring: oklch(0.708 0 0);
66
+ --chart-1: oklch(0.646 0.222 41.116);
67
+ --chart-2: oklch(0.6 0.118 184.704);
68
+ --chart-3: oklch(0.398 0.07 227.392);
69
+ --chart-4: oklch(0.828 0.189 84.429);
70
+ --chart-5: oklch(0.769 0.188 70.08);
71
+ --sidebar: oklch(0.985 0 0);
72
+ --sidebar-foreground: oklch(0.145 0 0);
73
+ --sidebar-primary: oklch(0.205 0 0);
74
+ --sidebar-primary-foreground: oklch(0.985 0 0);
75
+ --sidebar-accent: oklch(0.97 0 0);
76
+ --sidebar-accent-foreground: oklch(0.205 0 0);
77
+ --sidebar-border: oklch(0.922 0 0);
78
+ --sidebar-ring: oklch(0.708 0 0);
79
+ }
80
+
81
+ .dark {
82
+ --background: oklch(0.145 0 0);
83
+ --foreground: oklch(0.985 0 0);
84
+ --card: oklch(0.205 0 0);
85
+ --card-foreground: oklch(0.985 0 0);
86
+ --popover: oklch(0.205 0 0);
87
+ --popover-foreground: oklch(0.985 0 0);
88
+ --primary: oklch(0.922 0 0);
89
+ --primary-foreground: oklch(0.205 0 0);
90
+ --secondary: oklch(0.269 0 0);
91
+ --secondary-foreground: oklch(0.985 0 0);
92
+ --muted: oklch(0.269 0 0);
93
+ --muted-foreground: oklch(0.708 0 0);
94
+ --accent: oklch(0.269 0 0);
95
+ --accent-foreground: oklch(0.985 0 0);
96
+ --destructive: oklch(0.704 0.191 22.216);
97
+ --border: oklch(1 0 0 / 10%);
98
+ --input: oklch(1 0 0 / 15%);
99
+ --ring: oklch(0.556 0 0);
100
+ --chart-1: oklch(0.488 0.243 264.376);
101
+ --chart-2: oklch(0.696 0.17 162.48);
102
+ --chart-3: oklch(0.769 0.188 70.08);
103
+ --chart-4: oklch(0.627 0.265 303.9);
104
+ --chart-5: oklch(0.645 0.246 16.439);
105
+ --sidebar: oklch(0.205 0 0);
106
+ --sidebar-foreground: oklch(0.985 0 0);
107
+ --sidebar-primary: oklch(0.488 0.243 264.376);
108
+ --sidebar-primary-foreground: oklch(0.985 0 0);
109
+ --sidebar-accent: oklch(0.269 0 0);
110
+ --sidebar-accent-foreground: oklch(0.985 0 0);
111
+ --sidebar-border: oklch(1 0 0 / 10%);
112
+ --sidebar-ring: oklch(0.556 0 0);
113
+ }
114
+
115
+ @layer base {
116
+ * {
117
+ @apply border-border outline-ring/50;
118
+ }
119
+ body {
120
+ @apply bg-background text-foreground;
121
+ }
122
+ }
@@ -0,0 +1,27 @@
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.copyTailwindCss = copyTailwindCss;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
+ /**
10
+ * Copy dist/css/tailwind.css into src/app/css/tailwind.css.
11
+ *
12
+ * @param force Overwrite even if the target exists.
13
+ * @returns true → file was copied / overwritten
14
+ * false → skipped (already exists and !force)
15
+ */
16
+ function copyTailwindCss(force = false) {
17
+ // Path to the CSS bundled with the CLI
18
+ const source = path_1.default.resolve(__dirname, "../dist/css/tailwind.css");
19
+ // Path inside the user’s project
20
+ const target = path_1.default.resolve(process.cwd(), "src/app/css/tailwind.css");
21
+ if (!force && fs_extra_1.default.existsSync(target)) {
22
+ return false; // skip quietly
23
+ }
24
+ fs_extra_1.default.ensureDirSync(path_1.default.dirname(target));
25
+ fs_extra_1.default.copyFileSync(source, target);
26
+ return true;
27
+ }
@@ -0,0 +1,32 @@
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.ensurePackageInstalled = ensurePackageInstalled;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const child_process_1 = require("child_process");
9
+ /**
10
+ * Ensures a package is present in dependencies/devDependencies.
11
+ * Installs it with `npm i -D <pkg>` if missing.
12
+ *
13
+ * @param pkg Package name, e.g. "tw-animate-css"
14
+ * @param quiet If true, suppress install output.
15
+ * @returns true → package was installed now
16
+ * false → package already present
17
+ */
18
+ function ensurePackageInstalled(pkg, quiet = false) {
19
+ const pkgJsonPath = "package.json";
20
+ if (!fs_extra_1.default.existsSync(pkgJsonPath))
21
+ return false;
22
+ const pkgJson = fs_extra_1.default.readJsonSync(pkgJsonPath);
23
+ const hasIt = (pkgJson.dependencies && pkgJson.dependencies[pkg]) ||
24
+ (pkgJson.devDependencies && pkgJson.devDependencies[pkg]);
25
+ if (hasIt)
26
+ return false;
27
+ const cmd = `npm i -D ${pkg}`;
28
+ if (!quiet)
29
+ console.log(`⬇ Installing missing package: ${pkg} …`);
30
+ (0, child_process_1.execSync)(cmd, { stdio: quiet ? "ignore" : "inherit" });
31
+ return true;
32
+ }
package/dist/index.js CHANGED
@@ -9,9 +9,11 @@ const chalk_1 = __importDefault(require("chalk"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const php_component_1 = require("./generators/php-component");
11
11
  const php_components_bulk_1 = require("./generators/php-components-bulk");
12
+ const ensure_package_1 = require("./generators/ensure-package");
13
+ const copy_tailwind_1 = require("./generators/copy-tailwind");
12
14
  (async () => {
13
15
  /* ─────────────────────────────────────────────
14
- * 1. Parse command + flags
16
+ * 1. Parse command & flags
15
17
  * ──────────────────────────────────────────── */
16
18
  const args = process.argv.slice(2);
17
19
  const [command, ...rest] = args;
@@ -38,12 +40,25 @@ const php_components_bulk_1 = require("./generators/php-components-bulk");
38
40
  }
39
41
  }
40
42
  /* ─────────────────────────────────────────────
41
- * 2. Destination directory
43
+ * 2. Housekeeping steps (always run)
44
+ * ──────────────────────────────────────────── */
45
+ // 2.a Ensure tw-animate-css is installed
46
+ (0, ensure_package_1.ensurePackageInstalled)("tw-animate-css");
47
+ // 2.b Keep Tailwind theme up‑to‑date in the project
48
+ const cssUpdated = (0, copy_tailwind_1.copyTailwindCss)(flags.force);
49
+ if (cssUpdated) {
50
+ const relCss = path_1.default
51
+ .relative(process.cwd(), "src/app/css/tailwind.css")
52
+ .replace(/\\/g, "/");
53
+ console.log(chalk_1.default.green(`✔ Updated Tailwind CSS → ${relCss}`));
54
+ }
55
+ /* ─────────────────────────────────────────────
56
+ * 3. Destination directory for components
42
57
  * ──────────────────────────────────────────── */
43
58
  const targetDir = path_1.default.resolve(flags.out ?? "src/Lib/PHPXUI");
44
59
  try {
45
60
  /* ─────────────────────────────────────────
46
- * 3. Bulk mode (all components)
61
+ * 4. Bulk mode (--all)
47
62
  * ───────────────────────────────────────── */
48
63
  if (flags.all) {
49
64
  const { ok, fail } = await (0, php_components_bulk_1.generateAllComponents)(targetDir, flags.force);
@@ -55,7 +70,7 @@ const php_components_bulk_1 = require("./generators/php-components-bulk");
55
70
  process.exit(fail.length ? 1 : 0);
56
71
  }
57
72
  /* ─────────────────────────────────────────
58
- * 4. Single or multiple names
73
+ * 5. Interactive prompt if no names given
59
74
  * ───────────────────────────────────────── */
60
75
  if (names.length === 0) {
61
76
  const { componentList } = await (0, prompts_1.default)({
@@ -66,10 +81,11 @@ const php_components_bulk_1 = require("./generators/php-components-bulk");
66
81
  });
67
82
  names.push(...componentList.split(/[\s,]+/));
68
83
  }
69
- /* -------- single / multiple names -------- */
84
+ /* ─────────────────────────────────────────
85
+ * 6. Generate each requested component
86
+ * ───────────────────────────────────────── */
70
87
  for (const name of names) {
71
88
  const saved = await (0, php_component_1.generateComponent)(name, targetDir, flags.force);
72
- // Normalize to array ― generateComponent may return string | string[]
73
89
  const paths = Array.isArray(saved) ? saved : [saved];
74
90
  for (const abs of paths) {
75
91
  const rel = path_1.default.relative(process.cwd(), abs).replace(/\\/g, "/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phpxui",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A package for generating Prisma PHP components with a CLI interface.",
5
5
  "main": "index.js",
6
6
  "scripts": {