@forgewp/compiler 0.4.3 → 0.4.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.
Files changed (133) hide show
  1. package/README.md +59 -0
  2. package/bin/add.js +20 -14
  3. package/bin/cli.js +145 -70
  4. package/bin/doctor.js +21 -12
  5. package/bin/export.js +69 -20
  6. package/bin/fresh.js +5 -0
  7. package/bin/i18n-extract.js +3 -10
  8. package/bin/i18n-translate.js +15 -24
  9. package/bin/make-block.js +13 -0
  10. package/bin/make-editable.js +166 -0
  11. package/bin/make-form.js +131 -0
  12. package/bin/make-loop.js +40 -43
  13. package/bin/make-mail.js +27 -0
  14. package/bin/make-post-type.js +57 -29
  15. package/bin/make-sandbox.js +62 -11
  16. package/bin/make-section.js +221 -0
  17. package/bin/make-shell.js +375 -0
  18. package/bin/repair.js +14 -26
  19. package/bin/seed.js +119 -0
  20. package/bin/sync-routes.js +107 -85
  21. package/lib/adapters/html-adapter.js +5 -0
  22. package/lib/adapters/stub-adapter.js +4 -0
  23. package/lib/add-component.js +153 -92
  24. package/lib/asset-loader.js +313 -3
  25. package/lib/assets/asset-graph.js +432 -0
  26. package/lib/assets/asset-pipeline.js +125 -0
  27. package/lib/assets/diagnostics-report.js +345 -0
  28. package/lib/assets/external-fetcher.js +173 -0
  29. package/lib/assets/font-orchestrator.js +348 -0
  30. package/lib/assets/font-usage-scanner.js +242 -0
  31. package/lib/assets/image-optimizer.js +229 -0
  32. package/lib/assets/index.js +51 -0
  33. package/lib/assets/preload-generator.js +70 -0
  34. package/lib/assets/public-url.js +153 -0
  35. package/lib/block-authoring-help.js +11 -0
  36. package/lib/blocks/ast-parser.js +67 -0
  37. package/lib/blocks/discover-blocks.js +146 -0
  38. package/lib/blocks/editor-scope.js +733 -0
  39. package/lib/blocks/editor-transpiler.js +1229 -0
  40. package/lib/blocks/index.js +2838 -0
  41. package/lib/blocks/php-transpiler.js +4928 -0
  42. package/lib/blocks/scanner.js +1487 -0
  43. package/lib/blocks/shared-utils.js +290 -0
  44. package/lib/blocks/source-sanitize.js +1449 -0
  45. package/lib/blueprints.js +31 -91
  46. package/lib/build-assets.js +38 -33
  47. package/lib/collect-page-template-routes.js +102 -0
  48. package/lib/collect-static-routes.js +175 -0
  49. package/lib/diagnostics.js +58 -33
  50. package/lib/export-theme.js +84 -5
  51. package/lib/extract-template-content.js +90 -0
  52. package/lib/forms-preview.js +42 -0
  53. package/lib/functions/cpt-routing.js +69 -0
  54. package/lib/functions/forms.js +2461 -0
  55. package/lib/functions/hydration-enqueuer.js +400 -0
  56. package/lib/functions/index.js +1623 -0
  57. package/lib/functions/load-menus.js +112 -0
  58. package/lib/functions/load-translations.js +148 -0
  59. package/lib/functions/rest-endpoints.js +2923 -0
  60. package/lib/functions/routing.js +765 -0
  61. package/lib/functions/seed-mock-data.js +392 -0
  62. package/lib/functions/seed-products.js +481 -0
  63. package/lib/functions/settings-page.js +273 -0
  64. package/lib/functions/theme-setup.js +494 -0
  65. package/lib/generate-theme.js +1916 -339
  66. package/lib/hydration/editable-schemas.js +332 -0
  67. package/lib/hydration/enter-hidden-initial.js +65 -0
  68. package/lib/hydration/form-schemas.js +227 -0
  69. package/lib/hydration/index.js +12 -0
  70. package/lib/hydration/is-interactive.js +951 -0
  71. package/lib/hydration/island-split.js +1231 -0
  72. package/lib/hydration/islands-scanner.js +599 -0
  73. package/lib/hydration/resolve-island-chunk.js +103 -0
  74. package/lib/hydration/resolve-island-component.js +52 -0
  75. package/lib/hydration/rollup-inputs.js +81 -0
  76. package/lib/hydration/root-class-extractor.js +220 -0
  77. package/lib/hydration/scan-app-providers.js +154 -0
  78. package/lib/hydration/static-lint.js +382 -0
  79. package/lib/hydration/transform.js +257 -0
  80. package/lib/hydration/uses-block-area.js +49 -0
  81. package/lib/hydration/utils.js +119 -0
  82. package/lib/i18n/translation-cache.js +141 -0
  83. package/lib/icon-registry.js +72 -0
  84. package/lib/index.d.ts +287 -8
  85. package/lib/index.js +2 -1
  86. package/lib/load-config.js +338 -242
  87. package/lib/mail-templates.js +37 -0
  88. package/lib/markup-processor.js +388 -102
  89. package/lib/node-runtime.js +7 -0
  90. package/lib/page-config-plugin.js +64 -20
  91. package/lib/php-builders.js +383 -44
  92. package/lib/react-adapter.js +983 -235
  93. package/lib/registration-metadata.js +11 -0
  94. package/lib/render-theme.mts +1410 -616
  95. package/lib/route-layout.js +76 -0
  96. package/lib/template-discovery.js +58 -0
  97. package/lib/theme-compatibility.js +32 -0
  98. package/lib/validate-export.js +2 -2
  99. package/lib/validate.js +27 -5
  100. package/lib/virtual-plugin.js +319 -0
  101. package/lib/walkthrough.md +26 -0
  102. package/package.json +16 -5
  103. package/templates/auth/cms/email-logs.json +9 -0
  104. package/templates/auth/cms/menus.json +11 -0
  105. package/templates/auth/cms/mock-data.json +123 -0
  106. package/templates/auth/cms/roles.json +7 -0
  107. package/templates/auth/cms/sessions.json +1 -0
  108. package/templates/auth/cms/site-settings.json +28 -0
  109. package/templates/auth/cms/translations.json +4 -0
  110. package/templates/auth/cms/users.json +46 -0
  111. package/templates/auth/components/forgot-password-form-wrapper.tsx +10 -2
  112. package/templates/auth/components/login-form-wrapper.tsx +118 -21
  113. package/templates/auth/components/reset-password-form-wrapper.tsx +10 -2
  114. package/templates/auth/components/signup-form-wrapper.tsx +2 -2
  115. package/templates/auth/components/verify-email-view-wrapper.tsx +5 -5
  116. package/templates/auth/pages/DashboardPage.tsx +1 -4
  117. package/templates/auth/pages/ForgotPasswordPage.tsx +1 -4
  118. package/templates/auth/pages/LoginPage.tsx +1 -4
  119. package/templates/auth/pages/ResetPasswordPage.tsx +1 -4
  120. package/templates/auth/pages/SignUpPage.tsx +1 -4
  121. package/templates/auth/pages/VerifyEmailPage.tsx +1 -4
  122. package/templates/auth/ui/button.tsx +57 -0
  123. package/templates/auth/ui/card.tsx +76 -0
  124. package/templates/auth/ui/field.tsx +242 -0
  125. package/templates/auth/ui/input.tsx +22 -0
  126. package/templates/auth/ui/label.tsx +24 -0
  127. package/templates/auth/ui/separator.tsx +31 -0
  128. package/templates/menus.json +12 -10
  129. package/templates/users.json +8 -4
  130. package/templates/wordpress.tsx +690 -245
  131. package/lib/block-compiler.js +0 -552
  132. package/lib/functions-builder.js +0 -2970
  133. package/lib/hydration-scanner.js +0 -833
@@ -1,9 +1,15 @@
1
- import { execSync } from "node:child_process";
2
- import { readFileSync, writeFileSync, readdirSync, existsSync, mkdirSync } from "node:fs";
3
- import { createRequire } from "node:module";
4
- import { fileURLToPath } from "node:url";
5
- import path from "node:path";
6
- import pc from "picocolors";
1
+ import { execSync } from 'node:child_process';
2
+ import {
3
+ readFileSync,
4
+ writeFileSync,
5
+ readdirSync,
6
+ existsSync,
7
+ mkdirSync,
8
+ } from 'node:fs';
9
+ import { createRequire } from 'node:module';
10
+ import { fileURLToPath } from 'node:url';
11
+ import path from 'node:path';
12
+ import pc from 'picocolors';
7
13
 
8
14
  // ─────────────────────────────────────────────────────────────────────────────
9
15
  // CONSTANTS
@@ -15,25 +21,25 @@ import pc from "picocolors";
15
21
  * It points to the standard ForgeWP project layout.
16
22
  */
17
23
  const SHADCN_COMPONENTS_JSON = {
18
- "$schema": "https://ui.shadcn.com/schema.json",
19
- "style": "new-york",
20
- "rsc": false,
21
- "tsx": true,
22
- "tailwind": {
23
- "config": "tailwind.config.js",
24
- "css": "src/app/globals.css",
25
- "baseColor": "zinc",
26
- "cssVariables": true,
27
- "prefix": ""
24
+ $schema: 'https://ui.shadcn.com/schema.json',
25
+ style: 'new-york',
26
+ rsc: false,
27
+ tsx: true,
28
+ tailwind: {
29
+ config: 'tailwind.config.js',
30
+ css: 'src/app/globals.css',
31
+ baseColor: 'zinc',
32
+ cssVariables: true,
33
+ prefix: '',
28
34
  },
29
- "aliases": {
30
- "components": "@/components",
31
- "utils": "@/lib/utils",
32
- "ui": "@/components/ui",
33
- "lib": "@/lib",
34
- "hooks": "@/hooks"
35
+ aliases: {
36
+ components: '@/components',
37
+ utils: '@/lib/utils',
38
+ ui: '@/components/ui',
39
+ lib: '@/lib',
40
+ hooks: '@/hooks',
35
41
  },
36
- "iconLibrary": "lucide"
42
+ iconLibrary: 'lucide',
37
43
  };
38
44
 
39
45
  // ─────────────────────────────────────────────────────────────────────────────
@@ -56,11 +62,28 @@ const SHADCN_COMPONENTS_JSON = {
56
62
  * 4. If style === "forgewp", apply the neo-brutalist sharpening transform.
57
63
  *
58
64
  * @param {string} component - The component name (e.g. "sheet", "navbar").
59
- * @param {{ style?: "shadcn" | "forgewp" }} options
65
+ * @param {{ style?: "shadcn" | "forgewp", overwrite?: boolean }} options
60
66
  */
61
67
  export async function addComponent(component, options) {
62
- const { style = "shadcn" } = options;
68
+ const { style = 'shadcn', overwrite = false } = options || {};
63
69
  const projectRoot = process.cwd();
70
+ const localRegistry = resolveLocalRegistry(component);
71
+ const hasLocalOverride =
72
+ localRegistry !== null && existsSync(localRegistry.tsxPath);
73
+ const targetFile = path.join(
74
+ projectRoot,
75
+ 'src',
76
+ 'components',
77
+ 'ui',
78
+ `${component}.tsx`,
79
+ );
80
+
81
+ if (hasLocalOverride && existsSync(targetFile) && !overwrite) {
82
+ throw new Error(
83
+ `ForgeWP component "${component}" already exists at src/components/ui/${component}.tsx. ` +
84
+ `Your file was left unchanged. Use --overwrite to replace it with the registry version.`,
85
+ );
86
+ }
64
87
 
65
88
  console.log(pc.cyan(`\n ForgeWP add — ${component}\n`));
66
89
 
@@ -70,17 +93,13 @@ export async function addComponent(component, options) {
70
93
  // ── Step 2: Detect package manager ────────────────────────────────────────
71
94
  const { installCmd, shadcnCmd } = detectPackageManager(projectRoot);
72
95
 
73
- // ── Step 3: Check for a ForgeWP local override ────────────────────────────
74
- const localRegistry = resolveLocalRegistry(component);
75
- const hasLocalOverride = localRegistry !== null && existsSync(localRegistry.tsxPath);
76
-
77
- // ── Step 4: Run shadcn add (primary install source for everything) ─────────
96
+ // ── Step 3: Run shadcn add (primary install source for everything) ─────────
78
97
  console.log(pc.dim(` Installing ${component} via shadcn...`));
79
98
  try {
80
99
  execSync(`${shadcnCmd} add ${component} --yes`, {
81
- stdio: "inherit",
100
+ stdio: 'inherit',
82
101
  cwd: projectRoot,
83
- shell: process.platform === "win32",
102
+ shell: process.platform === 'win32',
84
103
  });
85
104
  } catch (err) {
86
105
  // shadcn may fail for ForgeWP-native components not in the shadcn registry.
@@ -88,43 +107,54 @@ export async function addComponent(component, options) {
88
107
  if (!hasLocalOverride) {
89
108
  throw new Error(
90
109
  `Failed to install "${component}" via shadcn, and no ForgeWP local override exists.\n` +
91
- `Details: ${err.message}`
110
+ `Details: ${err.message}`,
92
111
  );
93
112
  }
94
- console.log(pc.yellow(` ⚠ shadcn does not know "${component}" — using ForgeWP local registry instead.`));
113
+ console.log(
114
+ pc.yellow(
115
+ ` ⚠ shadcn does not know "${component}" — using ForgeWP local registry instead.`,
116
+ ),
117
+ );
95
118
  }
96
119
 
97
120
  // ── Step 5: Install ForgeWP local override (if present) ───────────────────
98
121
  if (hasLocalOverride) {
99
122
  console.log(pc.dim(` Applying ForgeWP override for ${component}...`));
100
123
 
101
- const targetDir = path.join(projectRoot, "src", "components", "ui");
124
+ const targetDir = path.join(projectRoot, 'src', 'components', 'ui');
102
125
  if (!existsSync(targetDir)) mkdirSync(targetDir, { recursive: true });
103
126
 
104
127
  const targetFile = path.join(targetDir, `${component}.tsx`);
105
- const content = readFileSync(localRegistry.tsxPath, "utf8");
106
- writeFileSync(targetFile, content, "utf8");
128
+ const content = readFileSync(localRegistry.tsxPath, 'utf8');
129
+ writeFileSync(targetFile, content, 'utf8');
107
130
 
108
131
  // Install any extra Tailwind plugins declared in the ForgeWP registry.json
109
132
  // that shadcn's remote registry wouldn't know about (ForgeWP-native components).
110
133
  if (localRegistry.meta?.tailwindPlugins?.length > 0) {
111
- await ensureTailwindPlugins(localRegistry.meta.tailwindPlugins, installCmd, projectRoot);
134
+ await ensureTailwindPlugins(
135
+ localRegistry.meta.tailwindPlugins,
136
+ installCmd,
137
+ projectRoot,
138
+ );
112
139
  }
113
140
 
114
- console.log(pc.dim(` ↳ Override written to src/components/ui/${component}.tsx`));
141
+ console.log(
142
+ pc.dim(` ↳ Override written to src/components/ui/${component}.tsx`),
143
+ );
115
144
  }
116
145
 
117
146
  // ── Step 6: Apply ForgeWP sharpening (when style === "forgewp") ────────────
118
- if (style === "forgewp") {
119
- const uiDir = path.join(projectRoot, "src", "components", "ui");
147
+ if (style === 'forgewp') {
148
+ const uiDir = path.join(projectRoot, 'src', 'components', 'ui');
120
149
  if (existsSync(uiDir)) {
121
- const files = readdirSync(uiDir).filter(f =>
122
- f.toLowerCase().includes(component.toLowerCase().replace(/-/g, "")) ||
123
- f.toLowerCase().includes(component.toLowerCase())
150
+ const files = readdirSync(uiDir).filter(
151
+ (f) =>
152
+ f.toLowerCase().includes(component.toLowerCase().replace(/-/g, '')) ||
153
+ f.toLowerCase().includes(component.toLowerCase()),
124
154
  );
125
155
  const targets = files.length > 0 ? files : readdirSync(uiDir);
126
- targets.forEach(f => {
127
- if (f.endsWith(".tsx")) sharpenFile(path.join(uiDir, f));
156
+ targets.forEach((f) => {
157
+ if (f.endsWith('.tsx')) sharpenFile(path.join(uiDir, f));
128
158
  });
129
159
  }
130
160
  }
@@ -142,15 +172,27 @@ export async function addComponent(component, options) {
142
172
  * without requiring the developer to run `shadcn init` manually.
143
173
  */
144
174
  function ensureComponentsJson(projectRoot) {
145
- const targetPath = path.join(projectRoot, "components.json");
175
+ const targetPath = path.join(projectRoot, 'components.json');
146
176
  if (existsSync(targetPath)) return;
147
177
 
148
178
  try {
149
- writeFileSync(targetPath, JSON.stringify(SHADCN_COMPONENTS_JSON, null, 2), "utf8");
150
- console.log(pc.green(` ✅ Created components.json (shadcn configuration)`));
179
+ writeFileSync(
180
+ targetPath,
181
+ JSON.stringify(SHADCN_COMPONENTS_JSON, null, 2),
182
+ 'utf8',
183
+ );
184
+ console.log(
185
+ pc.green(` ✅ Created components.json (shadcn configuration)`),
186
+ );
151
187
  } catch (err) {
152
- console.log(pc.yellow(` ⚠ Could not create components.json: ${err.message}`));
153
- console.log(pc.yellow(` Run "pnpm dlx shadcn@latest init" to initialize shadcn manually.`));
188
+ console.log(
189
+ pc.yellow(` ⚠ Could not create components.json: ${err.message}`),
190
+ );
191
+ console.log(
192
+ pc.yellow(
193
+ ` Run "pnpm dlx shadcn@latest init" to initialize shadcn manually.`,
194
+ ),
195
+ );
154
196
  }
155
197
  }
156
198
 
@@ -159,24 +201,24 @@ function ensureComponentsJson(projectRoot) {
159
201
  * the appropriate install and shadcn CLI commands.
160
202
  */
161
203
  function detectPackageManager(projectRoot) {
162
- let installCmd = "npm install --save-dev";
163
- let shadcnCmd = "npx shadcn@latest";
204
+ let installCmd = 'npm install --save-dev';
205
+ let shadcnCmd = 'npx shadcn@latest';
164
206
 
165
207
  let current = projectRoot;
166
208
  while (current) {
167
- if (existsSync(path.join(current, "pnpm-lock.yaml"))) {
168
- installCmd = "pnpm add -D";
169
- shadcnCmd = "pnpm dlx shadcn@latest";
209
+ if (existsSync(path.join(current, 'pnpm-lock.yaml'))) {
210
+ installCmd = 'pnpm add -D';
211
+ shadcnCmd = 'pnpm dlx shadcn@latest';
170
212
  break;
171
213
  }
172
- if (existsSync(path.join(current, "yarn.lock"))) {
173
- installCmd = "yarn add -D";
174
- shadcnCmd = "yarn dlx shadcn@latest";
214
+ if (existsSync(path.join(current, 'yarn.lock'))) {
215
+ installCmd = 'yarn add -D';
216
+ shadcnCmd = 'yarn dlx shadcn@latest';
175
217
  break;
176
218
  }
177
- if (existsSync(path.join(current, "bun.lockb"))) {
178
- installCmd = "bun add -d";
179
- shadcnCmd = "bunx --bun shadcn@latest";
219
+ if (existsSync(path.join(current, 'bun.lockb'))) {
220
+ installCmd = 'bun add -d';
221
+ shadcnCmd = 'bunx --bun shadcn@latest';
180
222
  break;
181
223
  }
182
224
  const parent = path.dirname(current);
@@ -199,27 +241,27 @@ function resolveLocalRegistry(component) {
199
241
  try {
200
242
  const req = createRequire(import.meta.url);
201
243
  registryBase = path.join(
202
- path.dirname(req.resolve("@forgewp/ui/package.json")),
203
- "components"
244
+ path.dirname(req.resolve('@forgewp/ui/package.json')),
245
+ 'components',
204
246
  );
205
247
  } catch {
206
248
  // Fallback for local monorepo development
207
249
  registryBase = path.resolve(
208
250
  path.dirname(fileURLToPath(import.meta.url)),
209
- "../../ui/components"
251
+ '../../ui/components',
210
252
  );
211
253
  }
212
254
 
213
255
  const componentDir = path.join(registryBase, component);
214
- const tsxPath = path.join(componentDir, "forgewp.tsx");
215
- const registryPath = path.join(componentDir, "registry.json");
256
+ const tsxPath = path.join(componentDir, 'forgewp.tsx');
257
+ const registryPath = path.join(componentDir, 'registry.json');
216
258
 
217
259
  if (!existsSync(tsxPath) && !existsSync(registryPath)) return null;
218
260
 
219
261
  let meta = {};
220
262
  if (existsSync(registryPath)) {
221
263
  try {
222
- meta = JSON.parse(readFileSync(registryPath, "utf8"));
264
+ meta = JSON.parse(readFileSync(registryPath, 'utf8'));
223
265
  } catch {
224
266
  // Malformed registry.json — proceed with empty meta
225
267
  }
@@ -241,56 +283,71 @@ function resolveLocalRegistry(component) {
241
283
  * @param {string} projectRoot
242
284
  */
243
285
  async function ensureTailwindPlugins(plugins, installCmd, projectRoot) {
244
- const pkgJsonPath = path.join(projectRoot, "package.json");
286
+ const pkgJsonPath = path.join(projectRoot, 'package.json');
245
287
  if (!existsSync(pkgJsonPath)) return;
246
288
 
247
- const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
248
- const currentDeps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
289
+ const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
290
+ const currentDeps = {
291
+ ...(pkg.dependencies || {}),
292
+ ...(pkg.devDependencies || {}),
293
+ };
249
294
 
250
295
  for (const plugin of plugins) {
251
296
  // Install if missing
252
297
  if (!currentDeps[plugin]) {
253
- console.log(pc.yellow(`\n ⚡ Requires Tailwind plugin: ${pc.bold(plugin)}`));
298
+ console.log(
299
+ pc.yellow(`\n ⚡ Requires Tailwind plugin: ${pc.bold(plugin)}`),
300
+ );
254
301
  try {
255
302
  execSync(`${installCmd} ${plugin}`, {
256
- stdio: "inherit",
303
+ stdio: 'inherit',
257
304
  cwd: projectRoot,
258
- shell: process.platform === "win32",
305
+ shell: process.platform === 'win32',
259
306
  });
260
307
  console.log(pc.green(` ✅ Installed ${plugin}`));
261
308
  } catch (err) {
262
309
  console.log(pc.red(` ❌ Failed to install ${plugin}: ${err.message}`));
263
- console.log(pc.yellow(` Please manually run: ${installCmd} ${plugin}\n`));
310
+ console.log(
311
+ pc.yellow(` Please manually run: ${installCmd} ${plugin}\n`),
312
+ );
264
313
  continue;
265
314
  }
266
315
  }
267
316
 
268
317
  // Register @plugin in globals.css if not already present
269
318
  const cssSearchPaths = [
270
- path.join(projectRoot, "src", "app", "globals.css"),
271
- path.join(projectRoot, "src", "styles", "globals.css"),
272
- path.join(projectRoot, "src", "index.css"),
273
- path.join(projectRoot, "src", "global.css"),
319
+ path.join(projectRoot, 'src', 'app', 'globals.css'),
320
+ path.join(projectRoot, 'src', 'styles', 'globals.css'),
321
+ path.join(projectRoot, 'src', 'index.css'),
322
+ path.join(projectRoot, 'src', 'global.css'),
274
323
  ];
275
324
 
276
- const globalsPath = cssSearchPaths.find(p => existsSync(p));
325
+ const globalsPath = cssSearchPaths.find((p) => existsSync(p));
277
326
  if (!globalsPath) {
278
- console.log(pc.yellow(` ⚠ Could not find globals.css. Add manually: @plugin "${plugin}";`));
327
+ console.log(
328
+ pc.yellow(
329
+ ` ⚠ Could not find globals.css. Add manually: @plugin "${plugin}";`,
330
+ ),
331
+ );
279
332
  continue;
280
333
  }
281
334
 
282
- let css = readFileSync(globalsPath, "utf8");
335
+ let css = readFileSync(globalsPath, 'utf8');
283
336
  const directive = `@plugin "${plugin}";`;
284
337
  if (css.includes(directive)) {
285
- console.log(pc.dim(` ↳ ${plugin} already registered in ${path.basename(globalsPath)}`));
338
+ console.log(
339
+ pc.dim(
340
+ ` ↳ ${plugin} already registered in ${path.basename(globalsPath)}`,
341
+ ),
342
+ );
286
343
  continue;
287
344
  }
288
345
 
289
346
  // Insert after the last @import line
290
- const lines = css.split("\n");
347
+ const lines = css.split('\n');
291
348
  let lastImportIdx = -1;
292
349
  lines.forEach((line, i) => {
293
- if (line.trimStart().startsWith("@import")) lastImportIdx = i;
350
+ if (line.trimStart().startsWith('@import')) lastImportIdx = i;
294
351
  });
295
352
 
296
353
  if (lastImportIdx !== -1) {
@@ -299,8 +356,12 @@ async function ensureTailwindPlugins(plugins, installCmd, projectRoot) {
299
356
  lines.unshift(directive);
300
357
  }
301
358
 
302
- writeFileSync(globalsPath, lines.join("\n"), "utf8");
303
- console.log(pc.green(` ✅ Registered @plugin "${plugin}" in ${path.basename(globalsPath)}`));
359
+ writeFileSync(globalsPath, lines.join('\n'), 'utf8');
360
+ console.log(
361
+ pc.green(
362
+ ` ✅ Registered @plugin "${plugin}" in ${path.basename(globalsPath)}`,
363
+ ),
364
+ );
304
365
  }
305
366
  }
306
367
 
@@ -310,21 +371,21 @@ async function ensureTailwindPlugins(plugins, installCmd, projectRoot) {
310
371
  * Used only when the project's wp.config.ts sets style: "forgewp".
311
372
  */
312
373
  function sharpenFile(filePath) {
313
- let content = readFileSync(filePath, "utf8");
374
+ let content = readFileSync(filePath, 'utf8');
314
375
 
315
376
  const sharpened = content.replace(
316
377
  /(?:\b|['"\s])([a-z0-9-:]+)?rounded(-[a-z0-9\[\]]+)?(?=["'\s])/g,
317
378
  (match) => {
318
- if (match.includes("rounded")) {
319
- const cleanPrefix = match.split("rounded")[0];
379
+ if (match.includes('rounded')) {
380
+ const cleanPrefix = match.split('rounded')[0];
320
381
  return `${cleanPrefix}rounded-none`;
321
382
  }
322
383
  return match;
323
- }
384
+ },
324
385
  );
325
386
 
326
387
  if (content !== sharpened) {
327
- writeFileSync(filePath, sharpened, "utf8");
388
+ writeFileSync(filePath, sharpened, 'utf8');
328
389
  console.log(pc.dim(` Sharpened ${path.basename(filePath)}`));
329
390
  }
330
391
  }