@forgewp/compiler 0.1.7 → 0.1.9
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 +29 -2
- package/bin/add.js +33 -3
- package/bin/clean.js +37 -0
- package/bin/cli.js +97 -0
- package/bin/doctor.js +99 -0
- package/bin/export.js +0 -0
- package/bin/fresh.js +421 -0
- package/bin/make-block.js +130 -0
- package/bin/make-component.js +200 -0
- package/bin/make-post-type.js +129 -0
- package/bin/repair.js +69 -0
- package/bin/sync-routes.js +260 -0
- package/lib/add-component.js +19 -4
- package/lib/blueprints.js +501 -316
- package/lib/generate-theme.js +341 -11
- package/lib/index.d.ts +1 -0
- package/lib/render-static.js +4 -0
- package/lib/render-theme.mts +32 -0
- package/package.json +3 -4
package/lib/add-component.js
CHANGED
|
@@ -14,13 +14,16 @@ export async function addComponent(component, options) {
|
|
|
14
14
|
try {
|
|
15
15
|
const { createRequire } = await import("node:module");
|
|
16
16
|
const require = createRequire(import.meta.url);
|
|
17
|
-
registryPath = path.join(path.dirname(require.resolve("@forgewp/
|
|
17
|
+
registryPath = path.join(path.dirname(require.resolve("@forgewp/ui/package.json")), "components");
|
|
18
18
|
} catch (e) {
|
|
19
19
|
// Fallback for development/local execution
|
|
20
|
-
registryPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "../../
|
|
20
|
+
registryPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "../../ui/components");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let localComponentFile = path.join(registryPath, component, `${style}.tsx`);
|
|
24
|
+
if (!existsSync(localComponentFile)) {
|
|
25
|
+
localComponentFile = path.join(registryPath, component, "forgewp.tsx");
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
if (existsSync(localComponentFile)) {
|
|
26
29
|
console.log(pc.dim(` Found ${component} in ForgeWP local registry...`));
|
|
@@ -38,8 +41,20 @@ export async function addComponent(component, options) {
|
|
|
38
41
|
// 2. Run shadcn add (fallback)
|
|
39
42
|
console.log(pc.dim(` Fetching ${component} from shadcn/ui...`));
|
|
40
43
|
try {
|
|
44
|
+
// Auto-detect the package manager being used by the developer
|
|
45
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
46
|
+
let shadcnCmd = "npx shadcn@latest"; // Default fallback
|
|
47
|
+
|
|
48
|
+
if (userAgent.includes("pnpm")) {
|
|
49
|
+
shadcnCmd = "pnpm dlx shadcn@latest";
|
|
50
|
+
} else if (userAgent.includes("bun")) {
|
|
51
|
+
shadcnCmd = "bunx --bun shadcn@latest";
|
|
52
|
+
} else if (userAgent.includes("yarn")) {
|
|
53
|
+
shadcnCmd = "yarn dlx shadcn@latest";
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
// We use --yes to skip prompts
|
|
42
|
-
execSync(
|
|
57
|
+
execSync(`${shadcnCmd} add ${component} --yes`, {
|
|
43
58
|
stdio: "inherit",
|
|
44
59
|
cwd: projectRoot,
|
|
45
60
|
shell: process.platform === "win32",
|