nx-factory-cli 2.0.0
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 +244 -0
- package/dist/commands/add-app.d.ts +15 -0
- package/dist/commands/add-app.d.ts.map +1 -0
- package/dist/commands/add-app.js +365 -0
- package/dist/commands/add-app.js.map +1 -0
- package/dist/commands/add-component.d.ts +2 -0
- package/dist/commands/add-component.d.ts.map +1 -0
- package/dist/commands/add-component.js +110 -0
- package/dist/commands/add-component.js.map +1 -0
- package/dist/commands/add-lib.d.ts +9 -0
- package/dist/commands/add-lib.d.ts.map +1 -0
- package/dist/commands/add-lib.js +190 -0
- package/dist/commands/add-lib.js.map +1 -0
- package/dist/commands/add-storybook.d.ts +6 -0
- package/dist/commands/add-storybook.d.ts.map +1 -0
- package/dist/commands/add-storybook.js +181 -0
- package/dist/commands/add-storybook.js.map +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +230 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +505 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +130 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/publish.d.ts +8 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +179 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/remove-component.d.ts +5 -0
- package/dist/commands/remove-component.d.ts.map +1 -0
- package/dist/commands/remove-component.js +172 -0
- package/dist/commands/remove-component.js.map +1 -0
- package/dist/commands/update.d.ts +5 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +126 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +35 -0
- package/dist/config.js.map +1 -0
- package/dist/exec.d.ts +25 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +80 -0
- package/dist/exec.js.map +1 -0
- package/dist/files.d.ts +7 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +23 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/ui.d.ts +44 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +149 -0
- package/dist/ui.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { pathExists } from "../files.js";
|
|
4
|
+
import { loadConfig } from "../config.js";
|
|
5
|
+
import { run, pmx, pmxArgs, detectPackageManager } from "../exec.js";
|
|
6
|
+
import { c, q, createStepRunner, printSuccess, printError } from "../ui.js";
|
|
7
|
+
export async function updateCommand(components, opts) {
|
|
8
|
+
const cfg = await loadConfig();
|
|
9
|
+
const uiPkgDir = await detectUiPackageDir(cfg?.uiPackage);
|
|
10
|
+
if (!uiPkgDir) {
|
|
11
|
+
printError({
|
|
12
|
+
title: "UI package not found",
|
|
13
|
+
detail: "Run from the monorepo root.",
|
|
14
|
+
recovery: [{ label: "", cmd: "nx-shadcn update" }],
|
|
15
|
+
});
|
|
16
|
+
process.exit(1);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const installed = await getInstalledComponents(uiPkgDir);
|
|
20
|
+
if (installed.length === 0) {
|
|
21
|
+
console.log(`\n ${c.dim("No components installed. Nothing to update.")}\n`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Determine which components to update
|
|
25
|
+
let targets = components.length > 0 ? components : installed;
|
|
26
|
+
// Validate any explicitly-named components exist
|
|
27
|
+
const unknown = targets.filter((t) => !installed.includes(t));
|
|
28
|
+
if (unknown.length > 0) {
|
|
29
|
+
printError({
|
|
30
|
+
title: `Unknown component${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`,
|
|
31
|
+
detail: "These are not installed in the UI package.",
|
|
32
|
+
recovery: [{ label: "Installed components:", cmd: installed.join(" ") }],
|
|
33
|
+
});
|
|
34
|
+
process.exit(1);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// If updating all, confirm unless --yes
|
|
38
|
+
if (components.length === 0 && !opts.yes) {
|
|
39
|
+
const { selected } = await inquirer.prompt({
|
|
40
|
+
type: "checkbox",
|
|
41
|
+
name: "selected",
|
|
42
|
+
message: q("Which components do you want to update?", "defaults to all · space to deselect"),
|
|
43
|
+
choices: installed.map((comp) => ({ name: comp, value: comp, checked: true })),
|
|
44
|
+
validate: (v) => v.length > 0 || "Select at least one component",
|
|
45
|
+
});
|
|
46
|
+
targets = selected;
|
|
47
|
+
}
|
|
48
|
+
const pm = (await detectPackageManager()) ?? (cfg?.pkgManager ?? "npm");
|
|
49
|
+
console.log(`\n ${c.dim("─".repeat(44))}`);
|
|
50
|
+
console.log(` ${c.whiteBold("Updating")} ${c.dim(targets.join(", "))}`);
|
|
51
|
+
console.log(` ${c.dim("─".repeat(44))}\n`);
|
|
52
|
+
if (opts.dryRun) {
|
|
53
|
+
const step = createStepRunner(targets.length, true);
|
|
54
|
+
for (const comp of targets) {
|
|
55
|
+
await step(`Update ${comp}`, async () => { });
|
|
56
|
+
}
|
|
57
|
+
printSuccess({
|
|
58
|
+
title: `${targets.length} component${targets.length > 1 ? "s" : ""} would be updated (dry run)`,
|
|
59
|
+
commands: [{ cmd: `nx-shadcn update ${targets.join(" ")}`, comment: "run without --dry-run to apply" }],
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const step = createStepRunner(targets.length);
|
|
64
|
+
const updated = [];
|
|
65
|
+
const failed = [];
|
|
66
|
+
for (const comp of targets) {
|
|
67
|
+
await step(`Update ${comp}`, async () => {
|
|
68
|
+
try {
|
|
69
|
+
await run(pmx(pm), pmxArgs(pm, "shadcn@latest", ["add", "--yes", "--overwrite", comp]), { cwd: uiPkgDir });
|
|
70
|
+
updated.push(comp);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
failed.push(comp);
|
|
74
|
+
throw new Error(`shadcn update failed for ${comp}`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (failed.length > 0) {
|
|
79
|
+
printError({
|
|
80
|
+
title: `Failed to update: ${failed.join(", ")}`,
|
|
81
|
+
recovery: failed.map((comp) => ({
|
|
82
|
+
label: "",
|
|
83
|
+
cmd: `${pmx(pm)} ${pmxArgs(pm, "shadcn@latest", ["add", "--overwrite", comp]).join(" ")}`,
|
|
84
|
+
})),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (updated.length > 0) {
|
|
88
|
+
printSuccess({
|
|
89
|
+
title: `${updated.length} component${updated.length > 1 ? "s" : ""} updated`,
|
|
90
|
+
commands: [
|
|
91
|
+
{ cmd: `pnpm nx build @workspace/${cfg?.uiPackage ?? "ui"}`, comment: "rebuild to pick up changes" },
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function getInstalledComponents(uiPkgDir) {
|
|
97
|
+
const dir = path.join(uiPkgDir, "src/components/ui");
|
|
98
|
+
if (!(await pathExists(dir)))
|
|
99
|
+
return [];
|
|
100
|
+
const { default: fs } = await import("fs-extra");
|
|
101
|
+
const files = await fs.readdir(dir);
|
|
102
|
+
return files
|
|
103
|
+
.filter((f) => f.endsWith(".tsx") || f.endsWith(".ts"))
|
|
104
|
+
.map((f) => f.replace(/\.tsx?$/, ""))
|
|
105
|
+
.sort();
|
|
106
|
+
}
|
|
107
|
+
async function detectUiPackageDir(uiPackage) {
|
|
108
|
+
const base = uiPackage ?? "ui";
|
|
109
|
+
const configured = path.join(process.cwd(), "packages", base);
|
|
110
|
+
if (await pathExists(path.join(configured, "components.json")))
|
|
111
|
+
return configured;
|
|
112
|
+
if (await pathExists(path.join(process.cwd(), "components.json")))
|
|
113
|
+
return process.cwd();
|
|
114
|
+
const packagesDir = path.join(process.cwd(), "packages");
|
|
115
|
+
if (await pathExists(packagesDir)) {
|
|
116
|
+
const { default: fs } = await import("fs-extra");
|
|
117
|
+
const dirs = await fs.readdir(packagesDir);
|
|
118
|
+
for (const d of dirs) {
|
|
119
|
+
const candidate = path.join(packagesDir, d);
|
|
120
|
+
if (await pathExists(path.join(candidate, "components.json")))
|
|
121
|
+
return candidate;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAoB,EACpB,IAAyC;IAEzC,MAAM,GAAG,GAAQ,MAAM,UAAU,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAE1D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,UAAU,CAAC;YACT,KAAK,EAAK,sBAAsB;YAChC,MAAM,EAAI,6BAA6B;YACvC,QAAQ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
export declare const CONFIG_FILENAME = "nx-shadcn.config.json";
|
|
2
|
+
export interface NxShadcnConfig {
|
|
3
|
+
workspaceName: string;
|
|
4
|
+
pkgManager: "pnpm" | "npm" | "yarn" | "bun";
|
|
5
|
+
uiPackage: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}
|
|
8
|
+
/** Find the config file walking up from cwd, or return null. */
|
|
9
|
+
export declare function findConfig(startDir?: string): Promise<string | null>;
|
|
10
|
+
/** Load config from the nearest nx-shadcn.config.json, or return null. */
|
|
11
|
+
export declare function loadConfig(): Promise<NxShadcnConfig | null>;
|
|
12
|
+
/** Write config to cwd/nx-shadcn.config.json. */
|
|
13
|
+
export declare function saveConfig(cfg: NxShadcnConfig): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAK,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IAC/C,SAAS,EAAM,MAAM,CAAC;IACtB,OAAO,EAAQ,MAAM,CAAC;CACvB;AAED,gEAAgE;AAChE,wBAAsB,UAAU,CAAC,QAAQ,SAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUjF;AAED,0EAA0E;AAC1E,wBAAsB,UAAU,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQjE;AAED,iDAAiD;AACjD,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { pathExists, readJson, writeJson } from "./files.js";
|
|
3
|
+
export const CONFIG_FILENAME = "nx-shadcn.config.json";
|
|
4
|
+
/** Find the config file walking up from cwd, or return null. */
|
|
5
|
+
export async function findConfig(startDir = process.cwd()) {
|
|
6
|
+
let dir = startDir;
|
|
7
|
+
for (let i = 0; i < 6; i++) {
|
|
8
|
+
const candidate = path.join(dir, CONFIG_FILENAME);
|
|
9
|
+
if (await pathExists(candidate))
|
|
10
|
+
return candidate;
|
|
11
|
+
const parent = path.dirname(dir);
|
|
12
|
+
if (parent === dir)
|
|
13
|
+
break;
|
|
14
|
+
dir = parent;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/** Load config from the nearest nx-shadcn.config.json, or return null. */
|
|
19
|
+
export async function loadConfig() {
|
|
20
|
+
const file = await findConfig();
|
|
21
|
+
if (!file)
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
return await readJson(file);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Write config to cwd/nx-shadcn.config.json. */
|
|
31
|
+
export async function saveConfig(cfg) {
|
|
32
|
+
const file = path.join(process.cwd(), CONFIG_FILENAME);
|
|
33
|
+
await writeJson(file, cfg);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AASvD,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;IACvD,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAClD,IAAI,MAAM,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;IAChC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAmB;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;IACvD,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/exec.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Options } from "execa";
|
|
2
|
+
export declare function run(cmd: string, args: string[], opts?: Options & {
|
|
3
|
+
label?: string;
|
|
4
|
+
}): Promise<void>;
|
|
5
|
+
/** Always inherits stdio — use for interactive CLIs (create-next-app, create-remix, etc.) */
|
|
6
|
+
export declare function runInteractive(cmd: string, args: string[], opts?: Omit<Options, "stdio">): Promise<void>;
|
|
7
|
+
export declare function runInDir(cwd: string, cmd: string, args: string[], label?: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Detects the package manager in use by inspecting lockfiles in `cwd` (defaults to process.cwd()).
|
|
10
|
+
* Returns null if no lockfile is found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectPackageManager(cwd?: string): Promise<string | null>;
|
|
13
|
+
export declare function pmx(pm: string): string;
|
|
14
|
+
/** Args to prefix a dlx-style command, e.g. ["dlx", "shadcn@latest", ...] for pnpm */
|
|
15
|
+
export declare function pmxArgs(pm: string, pkg: string, args: string[]): string[];
|
|
16
|
+
/** The subcommand used to add a dependency ("add" vs "install") */
|
|
17
|
+
export declare function pmAdd(pm: string): string;
|
|
18
|
+
export declare function pmRun(pm: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Returns the correct workspace version specifier for the given package manager.
|
|
21
|
+
* pnpm / bun / yarn use "workspace:*"
|
|
22
|
+
* npm uses "*" (relies on workspaces field in root package.json)
|
|
23
|
+
*/
|
|
24
|
+
export declare function pmWorkspaceProtocol(pm: string): string;
|
|
25
|
+
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAI5C,wBAAsB,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,GAAE,OAAO,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GACtC,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,6FAA6F;AAC7F,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,GAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAM,GAChC,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,SAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQtF;AAED,wBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKtC;AAED,sFAAsF;AACtF,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAIzE;AAED,mEAAmE;AACnE,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAGxC;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAK1C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
package/dist/exec.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
export async function run(cmd, args, opts = {}) {
|
|
5
|
+
const { label, ...execaOpts } = opts;
|
|
6
|
+
const spinner = label ? ora(label).start() : null;
|
|
7
|
+
try {
|
|
8
|
+
await execa(cmd, args, { stdio: spinner ? "pipe" : "inherit", ...execaOpts });
|
|
9
|
+
spinner?.succeed(chalk.green(label));
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
spinner?.fail(chalk.red(label));
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Always inherits stdio — use for interactive CLIs (create-next-app, create-remix, etc.) */
|
|
17
|
+
export async function runInteractive(cmd, args, opts = {}) {
|
|
18
|
+
await execa(cmd, args, { stdio: "inherit", ...opts });
|
|
19
|
+
}
|
|
20
|
+
export async function runInDir(cwd, cmd, args, label) {
|
|
21
|
+
await run(cmd, args, { cwd, label });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Detects the package manager in use by inspecting lockfiles in `cwd` (defaults to process.cwd()).
|
|
25
|
+
* Returns null if no lockfile is found.
|
|
26
|
+
*/
|
|
27
|
+
export async function detectPackageManager(cwd = process.cwd()) {
|
|
28
|
+
const { default: fs } = await import("fs-extra");
|
|
29
|
+
if (await fs.pathExists(`${cwd}/pnpm-workspace.yaml`))
|
|
30
|
+
return "pnpm";
|
|
31
|
+
if (await fs.pathExists(`${cwd}/pnpm-lock.yaml`))
|
|
32
|
+
return "pnpm";
|
|
33
|
+
if (await fs.pathExists(`${cwd}/bun.lockb`))
|
|
34
|
+
return "bun";
|
|
35
|
+
if (await fs.pathExists(`${cwd}/yarn.lock`))
|
|
36
|
+
return "yarn";
|
|
37
|
+
if (await fs.pathExists(`${cwd}/package-lock.json`))
|
|
38
|
+
return "npm";
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
export function pmx(pm) {
|
|
42
|
+
if (pm === "pnpm")
|
|
43
|
+
return "pnpm";
|
|
44
|
+
if (pm === "bun")
|
|
45
|
+
return "bunx";
|
|
46
|
+
if (pm === "yarn")
|
|
47
|
+
return "yarn";
|
|
48
|
+
return "npx"; // npm
|
|
49
|
+
}
|
|
50
|
+
/** Args to prefix a dlx-style command, e.g. ["dlx", "shadcn@latest", ...] for pnpm */
|
|
51
|
+
export function pmxArgs(pm, pkg, args) {
|
|
52
|
+
if (pm === "pnpm")
|
|
53
|
+
return ["dlx", pkg, ...args];
|
|
54
|
+
if (pm === "yarn")
|
|
55
|
+
return ["dlx", pkg, ...args];
|
|
56
|
+
return [pkg, ...args]; // npx / bunx — cmd is the binary itself
|
|
57
|
+
}
|
|
58
|
+
/** The subcommand used to add a dependency ("add" vs "install") */
|
|
59
|
+
export function pmAdd(pm) {
|
|
60
|
+
// npm is the odd one out; everyone else uses "add"
|
|
61
|
+
return pm === "npm" ? "install" : "add";
|
|
62
|
+
}
|
|
63
|
+
export function pmRun(pm) {
|
|
64
|
+
if (pm === "pnpm")
|
|
65
|
+
return ["pnpm", "run"];
|
|
66
|
+
if (pm === "bun")
|
|
67
|
+
return ["bun", "run"];
|
|
68
|
+
if (pm === "yarn")
|
|
69
|
+
return ["yarn", "run"];
|
|
70
|
+
return ["npm", "run"];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the correct workspace version specifier for the given package manager.
|
|
74
|
+
* pnpm / bun / yarn use "workspace:*"
|
|
75
|
+
* npm uses "*" (relies on workspaces field in root package.json)
|
|
76
|
+
*/
|
|
77
|
+
export function pmWorkspaceProtocol(pm) {
|
|
78
|
+
return pm === "npm" ? "*" : "workspace:*";
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=exec.js.map
|
package/dist/exec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,OAAO,CAAC;AAC5C,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,GAAW,EACX,IAAc,EACd,OAAqC,EAAE;IAEvC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;QAC9E,OAAO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,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC;AAC5C,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function writeJson(filePath: string, data: unknown): Promise<void>;
|
|
2
|
+
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
3
|
+
export declare function pathExists(p: string): Promise<boolean>;
|
|
4
|
+
export declare function ensureDir(p: string): Promise<void>;
|
|
5
|
+
export declare function readJson<T = unknown>(filePath: string): Promise<T>;
|
|
6
|
+
export declare function appendToFile(filePath: string, content: string): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../files.ts"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhF;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5D;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExD;AAED,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAExE;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export async function writeJson(filePath, data) {
|
|
4
|
+
await fs.ensureDir(path.dirname(filePath));
|
|
5
|
+
await fs.writeJson(filePath, data, { spaces: 2 });
|
|
6
|
+
}
|
|
7
|
+
export async function writeFile(filePath, content) {
|
|
8
|
+
await fs.ensureDir(path.dirname(filePath));
|
|
9
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
10
|
+
}
|
|
11
|
+
export async function pathExists(p) {
|
|
12
|
+
return fs.pathExists(p);
|
|
13
|
+
}
|
|
14
|
+
export async function ensureDir(p) {
|
|
15
|
+
await fs.ensureDir(p);
|
|
16
|
+
}
|
|
17
|
+
export async function readJson(filePath) {
|
|
18
|
+
return fs.readJson(filePath);
|
|
19
|
+
}
|
|
20
|
+
export async function appendToFile(filePath, content) {
|
|
21
|
+
await fs.appendFile(filePath, content, "utf-8");
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAa;IAC7D,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAe;IAC/D,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,CAAS;IACxC,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,CAAS;IACvC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAc,QAAgB;IAC1D,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAe,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,OAAe;IAClE,MAAM,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { printBanner } from "./ui.js";
|
|
4
|
+
import { initCommand } from "./commands/init.js";
|
|
5
|
+
import { addAppCommand } from "./commands/add-app.js";
|
|
6
|
+
import { addComponentCommand } from "./commands/add-component.js";
|
|
7
|
+
import { removeComponentCommand } from "./commands/remove-component.js";
|
|
8
|
+
import { updateCommand } from "./commands/update.js";
|
|
9
|
+
import { listCommand } from "./commands/list.js";
|
|
10
|
+
import { doctorCommand } from "./commands/doctor.js";
|
|
11
|
+
import { addLibCommand } from "./commands/add-lib.js";
|
|
12
|
+
import { addStorybookCommand } from "./commands/add-storybook.js";
|
|
13
|
+
import { publishCommand } from "./commands/publish.js";
|
|
14
|
+
const program = new Command();
|
|
15
|
+
printBanner();
|
|
16
|
+
program
|
|
17
|
+
.name("nx-shadcn")
|
|
18
|
+
.description("Initialize and manage an Nx monorepo with shared shadcn/ui components")
|
|
19
|
+
.version("1.0.0");
|
|
20
|
+
program
|
|
21
|
+
.command("init")
|
|
22
|
+
.description("Initialize a new Nx monorepo with a shared UI package")
|
|
23
|
+
.option("-n, --name <n>", "Workspace name")
|
|
24
|
+
.option("-p, --pkg-manager <manager>", "Package manager (npm|pnpm|yarn|bun)")
|
|
25
|
+
.option("-y, --yes", "Skip all prompts and use defaults")
|
|
26
|
+
.option("--dry-run", "Preview files that would be created without writing anything")
|
|
27
|
+
.action(initCommand);
|
|
28
|
+
program
|
|
29
|
+
.command("add-app")
|
|
30
|
+
.description("Scaffold a new app inside the monorepo that consumes the shared UI")
|
|
31
|
+
.option("-n, --name <n>", "App name")
|
|
32
|
+
.option("-f, --framework <framework>", "Framework (nextjs|vite)")
|
|
33
|
+
.option("-y, --yes", "Skip all prompts and use defaults")
|
|
34
|
+
.option("--dry-run", "Preview files that would be created without writing anything")
|
|
35
|
+
.action(addAppCommand);
|
|
36
|
+
program
|
|
37
|
+
.command("add-component")
|
|
38
|
+
.description("Add a shadcn component to the shared UI package")
|
|
39
|
+
.argument("[components...]", "Component name(s) to add")
|
|
40
|
+
.option("--dry-run", "Preview what would be added without writing anything")
|
|
41
|
+
.action(addComponentCommand);
|
|
42
|
+
program
|
|
43
|
+
.command("remove-component")
|
|
44
|
+
.description("Remove a shadcn component from the shared UI package")
|
|
45
|
+
.argument("[components...]", "Component name(s) to remove")
|
|
46
|
+
.option("-y, --yes", "Skip confirmation prompts")
|
|
47
|
+
.option("--dry-run", "Preview what would be removed without writing anything")
|
|
48
|
+
.action((components, opts) => removeComponentCommand(components, opts));
|
|
49
|
+
program
|
|
50
|
+
.command("update")
|
|
51
|
+
.description("Update installed shadcn components to their latest versions")
|
|
52
|
+
.argument("[components...]", "Specific components to update (defaults to all)")
|
|
53
|
+
.option("-y, --yes", "Skip confirmation, update all without prompting")
|
|
54
|
+
.option("--dry-run", "Preview what would be updated without writing anything")
|
|
55
|
+
.action((components, opts) => updateCommand(components, opts));
|
|
56
|
+
program
|
|
57
|
+
.command("list")
|
|
58
|
+
.description("List installed shadcn components and their usage across apps")
|
|
59
|
+
.action(listCommand);
|
|
60
|
+
program
|
|
61
|
+
.command("doctor")
|
|
62
|
+
.description("Validate workspace health and auto-fix barrel export issues")
|
|
63
|
+
.action(doctorCommand);
|
|
64
|
+
program
|
|
65
|
+
.command("add-lib")
|
|
66
|
+
.description("Scaffold a generic shared library in packages/")
|
|
67
|
+
.option("-n, --name <n>", "Library name")
|
|
68
|
+
.option("-t, --type <type>", "Library type (utils|hooks|config|types|api)")
|
|
69
|
+
.option("-y, --yes", "Skip all prompts and use defaults")
|
|
70
|
+
.option("--dry-run", "Preview files that would be created without writing anything")
|
|
71
|
+
.action(addLibCommand);
|
|
72
|
+
program
|
|
73
|
+
.command("add-storybook")
|
|
74
|
+
.description("Add Storybook to the shared UI package with auto-generated component stories")
|
|
75
|
+
.option("--dry-run", "Preview what would be created without writing anything")
|
|
76
|
+
.action(addStorybookCommand);
|
|
77
|
+
program
|
|
78
|
+
.command("publish")
|
|
79
|
+
.description("Build and publish the shared UI package to npm")
|
|
80
|
+
.option("--tag <tag>", "npm dist-tag (default: latest)")
|
|
81
|
+
.option("-y, --yes", "Skip all prompts and use defaults")
|
|
82
|
+
.option("--dry-run", "Preview the publish steps without actually publishing")
|
|
83
|
+
.action(publishCommand);
|
|
84
|
+
program.parse();
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAiB,oBAAoB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAe,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAS,6BAA6B,CAAC;AACrE,OAAO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AAW,EAAa,8DAA8D,CAAC;KAC9F,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CAAC,8EAA8E,CAAC;KAC3F,MAAM,CAAC,WAAW,EAAa,wDAAwD,CAAC;KACxF,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAE/B,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,gDAAgD,CAAC;KAC7D,MAAM,CAAC,aAAa,EAAW,gCAAgC,CAAC;KAChE,MAAM,CAAC,WAAW,EAAa,mCAAmC,CAAC;KACnE,MAAM,CAAC,WAAW,EAAa,uDAAuD,CAAC;KACvF,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const c: {
|
|
2
|
+
purple: import("chalk").ChalkInstance;
|
|
3
|
+
purpleDim: import("chalk").ChalkInstance;
|
|
4
|
+
purpleBold: import("chalk").ChalkInstance;
|
|
5
|
+
green: import("chalk").ChalkInstance;
|
|
6
|
+
greenBold: import("chalk").ChalkInstance;
|
|
7
|
+
yellow: import("chalk").ChalkInstance;
|
|
8
|
+
red: import("chalk").ChalkInstance;
|
|
9
|
+
cyan: import("chalk").ChalkInstance;
|
|
10
|
+
white: import("chalk").ChalkInstance;
|
|
11
|
+
whiteBold: import("chalk").ChalkInstance;
|
|
12
|
+
dim: import("chalk").ChalkInstance;
|
|
13
|
+
dimItalic: import("chalk").ChalkInstance;
|
|
14
|
+
muted: import("chalk").ChalkInstance;
|
|
15
|
+
};
|
|
16
|
+
export declare function printBanner(): void;
|
|
17
|
+
export declare function printSection(label: string): void;
|
|
18
|
+
export type StepRunner = (label: string, fn: () => Promise<void>) => Promise<void>;
|
|
19
|
+
export declare function createStepRunner(total: number, dryRun?: boolean): StepRunner;
|
|
20
|
+
export declare function q(label: string, hint?: string): string;
|
|
21
|
+
export declare function detected(value: string): string;
|
|
22
|
+
export interface SuccessOptions {
|
|
23
|
+
title: string;
|
|
24
|
+
commands: Array<{
|
|
25
|
+
cmd: string;
|
|
26
|
+
comment?: string;
|
|
27
|
+
}>;
|
|
28
|
+
tips?: Array<{
|
|
29
|
+
label: string;
|
|
30
|
+
cmd: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
export declare function printSuccess(opts: SuccessOptions): void;
|
|
34
|
+
export interface ErrorOptions {
|
|
35
|
+
title: string;
|
|
36
|
+
detail?: string;
|
|
37
|
+
recovery: Array<{
|
|
38
|
+
label: string;
|
|
39
|
+
cmd: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export declare function printError(opts: ErrorOptions): void;
|
|
43
|
+
export declare function printWarn(message: string, hint?: string): void;
|
|
44
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../ui.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;CAcb,CAAC;AAGF,wBAAgB,WAAW,IAAI,IAAI,CAkBlC;AASD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAKhD;AAOD,MAAM,MAAM,UAAU,GAAG,CACvB,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACpB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,UAAU,CAuB1E;AAKD,wBAAgB,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAGtD;AAID,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAGD,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