@geekmidas/cli 10.0.0-alpha.63 → 10.0.0-alpha.65
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 +1 -1
- package/dist/{HostingerProvider-mJ7YruxH.cjs → HostingerProvider-Dlmbfass.cjs} +3 -3
- package/dist/{HostingerProvider-mJ7YruxH.cjs.map → HostingerProvider-Dlmbfass.cjs.map} +1 -1
- package/dist/{HostingerProvider-DBBwpDjn.mjs → HostingerProvider-x9gQTAGZ.mjs} +2 -2
- package/dist/{HostingerProvider-DBBwpDjn.mjs.map → HostingerProvider-x9gQTAGZ.mjs.map} +1 -1
- package/dist/{LegacyStateStore-CP7SZwTP.cjs → LegacyStateStore-BGoo__sO.cjs} +2 -2
- package/dist/{LegacyStateStore-CP7SZwTP.cjs.map → LegacyStateStore-BGoo__sO.cjs.map} +1 -1
- package/dist/{LegacyStateStore-Q3GmKOdw.mjs → LegacyStateStore-BUu1nQ5u.mjs} +2 -2
- package/dist/{LegacyStateStore-Q3GmKOdw.mjs.map → LegacyStateStore-BUu1nQ5u.mjs.map} +1 -1
- package/dist/{LocalStateStore-sS8mvLeq.cjs → LocalStateStore-93urXyQe.cjs} +2 -2
- package/dist/{LocalStateStore-sS8mvLeq.cjs.map → LocalStateStore-93urXyQe.cjs.map} +1 -1
- package/dist/{LocalStateStore-BGIXcrvX.mjs → LocalStateStore-BRhMQRuy.mjs} +2 -2
- package/dist/{LocalStateStore-BGIXcrvX.mjs.map → LocalStateStore-BRhMQRuy.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-CjHWFRDd.cjs → OpenApiTsGenerator-BWuDRHe9.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-CjHWFRDd.cjs.map → OpenApiTsGenerator-BWuDRHe9.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-CnAwhGxi.mjs → OpenApiTsGenerator-C6v-IeHt.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-CnAwhGxi.mjs.map → OpenApiTsGenerator-C6v-IeHt.mjs.map} +1 -1
- package/dist/{S3StateStore-6jqITH2F.cjs → S3StateStore-F4dxw6kS.cjs} +2 -2
- package/dist/{S3StateStore-6jqITH2F.cjs.map → S3StateStore-F4dxw6kS.cjs.map} +1 -1
- package/dist/{S3StateStore-D7l_lWJ3.mjs → S3StateStore-pw1GhWwt.mjs} +2 -2
- package/dist/{S3StateStore-D7l_lWJ3.mjs.map → S3StateStore-pw1GhWwt.mjs.map} +1 -1
- package/dist/{SSMStateStore-B__F7IJa.cjs → SSMStateStore-Bt9acuAF.cjs} +2 -2
- package/dist/{SSMStateStore-B__F7IJa.cjs.map → SSMStateStore-Bt9acuAF.cjs.map} +1 -1
- package/dist/{SSMStateStore-CAQDVpoc.mjs → SSMStateStore-Dmj7zzFO.mjs} +2 -2
- package/dist/{SSMStateStore-CAQDVpoc.mjs.map → SSMStateStore-Dmj7zzFO.mjs.map} +1 -1
- package/dist/{bundler-DLfOn0ls.cjs → bundler-D6MlIfBT.cjs} +3 -3
- package/dist/{bundler-DLfOn0ls.cjs.map → bundler-D6MlIfBT.cjs.map} +1 -1
- package/dist/{bundler-DyWI41Iy.mjs → bundler-D_14JLZF.mjs} +3 -3
- package/dist/{bundler-DyWI41Iy.mjs.map → bundler-D_14JLZF.mjs.map} +1 -1
- package/dist/{cli-D-ZM-X2s.cjs → cli-BfH1deAT.cjs} +8 -7
- package/dist/{cli-D-ZM-X2s.cjs.map → cli-BfH1deAT.cjs.map} +1 -1
- package/dist/{cli-PkVF28LM.mjs → cli-P56vvrDQ.mjs} +5 -4
- package/dist/{cli-PkVF28LM.mjs.map → cli-P56vvrDQ.mjs.map} +1 -1
- package/dist/compose-391oEKj1.cjs +1982 -0
- package/dist/compose-391oEKj1.cjs.map +1 -0
- package/dist/compose-DprE3ASm.mjs +1862 -0
- package/dist/compose-DprE3ASm.mjs.map +1 -0
- package/dist/{config-C2BUosLm.d.mts → config-BonvTW8p.d.mts} +3 -3
- package/dist/{config-C2BUosLm.d.mts.map → config-BonvTW8p.d.mts.map} +1 -1
- package/dist/{config-CemHVcIr.d.cts → config-V_X_BMpm.d.cts} +3 -3
- package/dist/{config-CemHVcIr.d.cts.map → config-V_X_BMpm.d.cts.map} +1 -1
- package/dist/config.cjs +416 -17
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +401 -2
- package/dist/config.mjs.map +1 -0
- package/dist/credentials-Bzbg23n8.cjs +298 -0
- package/dist/credentials-Bzbg23n8.cjs.map +1 -0
- package/dist/credentials-Dq1MnWQf.mjs +233 -0
- package/dist/credentials-Dq1MnWQf.mjs.map +1 -0
- package/dist/{define-CHBIEc5j.mjs → define-DR8xGYfL.mjs} +6 -3
- package/dist/define-DR8xGYfL.mjs.map +1 -0
- package/dist/{define-Cv_QvDrg.cjs → define-DzRz8FgH.cjs} +6 -3
- package/dist/define-DzRz8FgH.cjs.map +1 -0
- package/dist/deploy/public.cjs +39 -33
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts +44 -5
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +44 -5
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +15 -12
- package/dist/deploy/public.mjs.map +1 -1
- package/dist/{deploy-CGW-QY9D.mjs → deploy-9MBG_QLd.mjs} +11 -9
- package/dist/deploy-9MBG_QLd.mjs.map +1 -0
- package/dist/{deploy-BiMrP9i7.cjs → deploy-B80idPUZ.cjs} +17 -15
- package/dist/deploy-B80idPUZ.cjs.map +1 -0
- package/dist/{deploy-CG8bfFij.mjs → deploy-CZ5nlpsu.mjs} +16 -119
- package/dist/deploy-CZ5nlpsu.mjs.map +1 -0
- package/dist/{deploy-ABBI0lf1.cjs → deploy-Cy8igpQF.cjs} +48 -151
- package/dist/deploy-Cy8igpQF.cjs.map +1 -0
- package/dist/derive-B4vDpzgP.mjs +150 -0
- package/dist/derive-B4vDpzgP.mjs.map +1 -0
- package/dist/derive-DAbo49sm.cjs +161 -0
- package/dist/derive-DAbo49sm.cjs.map +1 -0
- package/dist/{discover-C_6COHEv.cjs → discover-DHdECueV.cjs} +6 -157
- package/dist/discover-DHdECueV.cjs.map +1 -0
- package/dist/{discover-BaT6bpnA.mjs → discover-LMrqsWSU.mjs} +8 -117
- package/dist/discover-LMrqsWSU.mjs.map +1 -0
- package/dist/{dokploy-CwdmlyQL.mjs → dokploy-BdtBePjp.mjs} +3 -3
- package/dist/{dokploy-CwdmlyQL.mjs.map → dokploy-BdtBePjp.mjs.map} +1 -1
- package/dist/{dokploy-QJxMhxdf.cjs → dokploy-iFY8MY-L.cjs} +3 -3
- package/dist/{dokploy-QJxMhxdf.cjs.map → dokploy-iFY8MY-L.cjs.map} +1 -1
- package/dist/{encryption-DXw3jj0c.cjs → encryption-B1wJwgae.cjs} +6 -6
- package/dist/{encryption-DXw3jj0c.cjs.map → encryption-B1wJwgae.cjs.map} +1 -1
- package/dist/{encryption-CbQG_ayW.mjs → encryption-DF_hgIpl.mjs} +5 -5
- package/dist/{encryption-CbQG_ayW.mjs.map → encryption-DF_hgIpl.mjs.map} +1 -1
- package/dist/{github-ciwbIwVa.mjs → github-B0YYE98x.mjs} +4 -4
- package/dist/{github-ciwbIwVa.mjs.map → github-B0YYE98x.mjs.map} +1 -1
- package/dist/{github-BH_mETav.cjs → github-CYcmTdFs.cjs} +4 -4
- package/dist/{github-BH_mETav.cjs.map → github-CYcmTdFs.cjs.map} +1 -1
- package/dist/{index-DrKzpHl-.d.mts → index-DPUAGJaK.d.cts} +16 -3
- package/dist/index-DPUAGJaK.d.cts.map +1 -0
- package/dist/{index-BtXDZQuF.d.cts → index-DwKD_8lt.d.mts} +16 -3
- package/dist/index-DwKD_8lt.d.mts.map +1 -0
- package/dist/index.cjs +280 -1849
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +221 -1774
- package/dist/index.mjs.map +1 -1
- package/dist/local-BdH4XN0E.cjs +409 -0
- package/dist/local-BdH4XN0E.cjs.map +1 -0
- package/dist/local-CWR4Y_kW.mjs +350 -0
- package/dist/local-CWR4Y_kW.mjs.map +1 -0
- package/dist/{migrate-ImBKTBcW.mjs → migrate-B2qL5wj4.mjs} +8 -7
- package/dist/{migrate-ImBKTBcW.mjs.map → migrate-B2qL5wj4.mjs.map} +1 -1
- package/dist/{migrate-6oa9y_f2.cjs → migrate-q4pPAXtO.cjs} +21 -20
- package/dist/{migrate-6oa9y_f2.cjs.map → migrate-q4pPAXtO.cjs.map} +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/provider-C9_-45d5.cjs +56 -0
- package/dist/provider-C9_-45d5.cjs.map +1 -0
- package/dist/provider-q4lsYzYG.mjs +45 -0
- package/dist/provider-q4lsYzYG.mjs.map +1 -0
- package/dist/{ready-Bpdnn2ON.mjs → ready-bQfu9GES.mjs} +3 -3
- package/dist/{ready-Bpdnn2ON.mjs.map → ready-bQfu9GES.mjs.map} +1 -1
- package/dist/{ready-BiG0rt4h.cjs → ready-brEhh68f.cjs} +3 -3
- package/dist/{ready-BiG0rt4h.cjs.map → ready-brEhh68f.cjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/resolve-DLkIXTct.mjs +262 -0
- package/dist/resolve-DLkIXTct.mjs.map +1 -0
- package/dist/resolve-N_i4XNd-.cjs +315 -0
- package/dist/resolve-N_i4XNd-.cjs.map +1 -0
- package/dist/{runtime-Dn_n-29S.d.cts → runtime-BnD7Nn96.d.cts} +2 -2
- package/dist/{runtime-CXPlkZzs.d.mts.map → runtime-BnD7Nn96.d.cts.map} +1 -1
- package/dist/{runtime-CXPlkZzs.d.mts → runtime-j-tmFL65.d.mts} +2 -2
- package/dist/{runtime-Dn_n-29S.d.cts.map → runtime-j-tmFL65.d.mts.map} +1 -1
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox-CL--ZDui.cjs +164 -0
- package/dist/sandbox-CL--ZDui.cjs.map +1 -0
- package/dist/sandbox-Dm247NGx.mjs +117 -0
- package/dist/sandbox-Dm247NGx.mjs.map +1 -0
- package/dist/sniffer-BSwaL-dX.cjs +2236 -0
- package/dist/sniffer-BSwaL-dX.cjs.map +1 -0
- package/dist/sniffer-BZ-OJO4Y.mjs +2068 -0
- package/dist/sniffer-BZ-OJO4Y.mjs.map +1 -0
- package/dist/sst-B2HbrDR3.mjs +430 -0
- package/dist/sst-B2HbrDR3.mjs.map +1 -0
- package/dist/sst-DcfsVH6x.cjs +453 -0
- package/dist/sst-DcfsVH6x.cjs.map +1 -0
- package/dist/{sniffer-aO_-s5vq.mjs → state-B8YwmUZU.mjs} +1204 -3236
- package/dist/state-B8YwmUZU.mjs.map +1 -0
- package/dist/{sniffer-D_SYc_pO.cjs → state-DF26e_lo.cjs} +1251 -3494
- package/dist/state-DF26e_lo.cjs.map +1 -0
- package/dist/{store-KvNQwYaB.cjs → store-CJF1Tqkq.cjs} +4 -4
- package/dist/{store-KvNQwYaB.cjs.map → store-CJF1Tqkq.cjs.map} +1 -1
- package/dist/{store-BS8A7NcA.mjs → store-CLiHnqOY.mjs} +2 -2
- package/dist/{store-BS8A7NcA.mjs.map → store-CLiHnqOY.mjs.map} +1 -1
- package/dist/target/public.cjs +6 -6
- package/dist/target/public.d.cts +3 -3
- package/dist/target/public.d.mts +3 -3
- package/dist/target/public.mjs +3 -3
- package/dist/terminal-Bs5E1oxm.cjs +88 -0
- package/dist/terminal-Bs5E1oxm.cjs.map +1 -0
- package/dist/terminal-CfbiYUbZ.mjs +84 -0
- package/dist/terminal-CfbiYUbZ.mjs.map +1 -0
- package/dist/{types-DIA7Li-J.d.cts → types-BCzMWBb6.d.mts} +84 -17
- package/dist/types-BCzMWBb6.d.mts.map +1 -0
- package/dist/{types-CfLKGfC_.d.mts → types-ByMWkXKP.d.cts} +85 -16
- package/dist/types-ByMWkXKP.d.cts.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +3 -1
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/{workspace-Kl4NG9IH.cjs → workspace-BewAHZIo.cjs} +41 -6
- package/dist/workspace-BewAHZIo.cjs.map +1 -0
- package/dist/{workspace-Dh7rr7l4.mjs → workspace-C06_pW4g.mjs} +30 -7
- package/dist/workspace-C06_pW4g.mjs.map +1 -0
- package/package.json +13 -13
- package/dist/config-BEJYKd4s.cjs +0 -648
- package/dist/config-BEJYKd4s.cjs.map +0 -1
- package/dist/config-LKKCVCnC.mjs +0 -547
- package/dist/config-LKKCVCnC.mjs.map +0 -1
- package/dist/define-CHBIEc5j.mjs.map +0 -1
- package/dist/define-Cv_QvDrg.cjs.map +0 -1
- package/dist/deploy-ABBI0lf1.cjs.map +0 -1
- package/dist/deploy-BiMrP9i7.cjs.map +0 -1
- package/dist/deploy-CG8bfFij.mjs.map +0 -1
- package/dist/deploy-CGW-QY9D.mjs.map +0 -1
- package/dist/discover-BaT6bpnA.mjs.map +0 -1
- package/dist/discover-C_6COHEv.cjs.map +0 -1
- package/dist/home-DOzBaWaL.cjs +0 -33
- package/dist/home-DOzBaWaL.cjs.map +0 -1
- package/dist/home-GI7pJl1M.mjs +0 -22
- package/dist/home-GI7pJl1M.mjs.map +0 -1
- package/dist/index-BtXDZQuF.d.cts.map +0 -1
- package/dist/index-DrKzpHl-.d.mts.map +0 -1
- package/dist/resolve-B1T0hUaR.mjs +0 -170
- package/dist/resolve-B1T0hUaR.mjs.map +0 -1
- package/dist/resolve-xytBTtG4.cjs +0 -217
- package/dist/resolve-xytBTtG4.cjs.map +0 -1
- package/dist/runtime-CMwtq0AL.cjs +0 -163
- package/dist/runtime-CMwtq0AL.cjs.map +0 -1
- package/dist/runtime-DbakJS8u.mjs +0 -134
- package/dist/runtime-DbakJS8u.mjs.map +0 -1
- package/dist/sniffer-D_SYc_pO.cjs.map +0 -1
- package/dist/sniffer-aO_-s5vq.mjs.map +0 -1
- package/dist/terminal-D0f1u0LG.cjs +0 -576
- package/dist/terminal-D0f1u0LG.cjs.map +0 -1
- package/dist/terminal-gMxAo9Dj.mjs +0 -517
- package/dist/terminal-gMxAo9Dj.mjs.map +0 -1
- package/dist/types-CfLKGfC_.d.mts.map +0 -1
- package/dist/types-DIA7Li-J.d.cts.map +0 -1
- package/dist/workspace-Dh7rr7l4.mjs.map +0 -1
- package/dist/workspace-Kl4NG9IH.cjs.map +0 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let fast_glob = require("fast-glob");
|
|
5
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob, 1);
|
|
6
|
+
let yaml = require("yaml");
|
|
7
|
+
//#region src/init/utils.ts
|
|
8
|
+
/**
|
|
9
|
+
* Detect the package manager being used based on lockfiles or npm_config_user_agent
|
|
10
|
+
*/
|
|
11
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
12
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
13
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(cwd, "yarn.lock"))) return "yarn";
|
|
14
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(cwd, "bun.lockb"))) return "bun";
|
|
15
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(cwd, "package-lock.json"))) return "npm";
|
|
16
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
17
|
+
if (userAgent.includes("pnpm")) return "pnpm";
|
|
18
|
+
if (userAgent.includes("yarn")) return "yarn";
|
|
19
|
+
if (userAgent.includes("bun")) return "bun";
|
|
20
|
+
return "npm";
|
|
21
|
+
}
|
|
22
|
+
/** `gkm init`'s flags, which a name can swallow when a space goes missing. */
|
|
23
|
+
const INIT_FLAGS = [
|
|
24
|
+
"yes",
|
|
25
|
+
"name",
|
|
26
|
+
"template",
|
|
27
|
+
"monorepo",
|
|
28
|
+
"api-path",
|
|
29
|
+
"pm",
|
|
30
|
+
"skip-install"
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Validate project name for npm package naming conventions
|
|
34
|
+
*/
|
|
35
|
+
function validateProjectName(name) {
|
|
36
|
+
if (!name) return "Project name is required";
|
|
37
|
+
if (!/^[a-z0-9-_@/.]+$/i.test(name)) return "Project name can only contain letters, numbers, hyphens, underscores, @, /, and .";
|
|
38
|
+
const flag = name.match(/--(\w[\w-]*)$/)?.[1];
|
|
39
|
+
if (flag && INIT_FLAGS.includes(flag)) return `"${name}" ends in the --${flag} flag. Did you mean \`${name.slice(0, -(flag.length + 2))} --${flag}\`?`;
|
|
40
|
+
if ([
|
|
41
|
+
"node_modules",
|
|
42
|
+
".git",
|
|
43
|
+
"package.json",
|
|
44
|
+
"src"
|
|
45
|
+
].includes(name.toLowerCase())) return `"${name}" is a reserved name`;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if a directory already exists at the target path
|
|
50
|
+
*/
|
|
51
|
+
function checkDirectoryExists(name, cwd = process.cwd()) {
|
|
52
|
+
const targetPath = (0, node_path.join)(cwd, name);
|
|
53
|
+
if ((0, node_fs.existsSync)(targetPath)) return `Directory "${name}" already exists`;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the install command for a package manager
|
|
58
|
+
*/
|
|
59
|
+
function getInstallCommand(pkgManager) {
|
|
60
|
+
switch (pkgManager) {
|
|
61
|
+
case "pnpm": return "pnpm install";
|
|
62
|
+
case "yarn": return "yarn";
|
|
63
|
+
case "bun": return "bun install";
|
|
64
|
+
default: return "npm install";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the dev command for a package manager
|
|
69
|
+
*/
|
|
70
|
+
function getRunCommand(pkgManager, script) {
|
|
71
|
+
switch (pkgManager) {
|
|
72
|
+
case "pnpm": return `pnpm ${script}`;
|
|
73
|
+
case "yarn": return `yarn ${script}`;
|
|
74
|
+
case "bun": return `bun run ${script}`;
|
|
75
|
+
default: return `npm run ${script}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Run a binary the project installed, through its package manager — so it is
|
|
80
|
+
* the project's own version, not whatever \`npx\` would fetch.
|
|
81
|
+
*/
|
|
82
|
+
function getExecCommand(pkgManager, command) {
|
|
83
|
+
switch (pkgManager) {
|
|
84
|
+
case "pnpm": return `pnpm exec ${command}`;
|
|
85
|
+
case "yarn": return `yarn ${command}`;
|
|
86
|
+
case "bun": return `bunx ${command}`;
|
|
87
|
+
default: return `npx --no-install ${command}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const lockfileByPm = {
|
|
91
|
+
pnpm: "pnpm-lock.yaml",
|
|
92
|
+
yarn: "yarn.lock",
|
|
93
|
+
npm: "package-lock.json",
|
|
94
|
+
bun: "bun.lockb"
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Find the workspace/project root by walking up from cwd.
|
|
98
|
+
* Checks for PM-specific workspace config, package.json#workspaces,
|
|
99
|
+
* and lockfiles.
|
|
100
|
+
*/
|
|
101
|
+
function findWorkspaceRoot(cwd, pm) {
|
|
102
|
+
let dir = cwd;
|
|
103
|
+
const root = (0, node_path.parse)(dir).root;
|
|
104
|
+
const lockfile = lockfileByPm[pm];
|
|
105
|
+
while (dir !== root) {
|
|
106
|
+
if (pm === "pnpm" && (0, node_fs.existsSync)((0, node_path.join)(dir, "pnpm-workspace.yaml"))) return dir;
|
|
107
|
+
const pkgJsonPath = (0, node_path.join)(dir, "package.json");
|
|
108
|
+
if ((0, node_fs.existsSync)(pkgJsonPath)) try {
|
|
109
|
+
if (JSON.parse((0, node_fs.readFileSync)(pkgJsonPath, "utf-8")).workspaces) return dir;
|
|
110
|
+
} catch {}
|
|
111
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(dir, lockfile))) return dir;
|
|
112
|
+
dir = (0, node_path.dirname)(dir);
|
|
113
|
+
}
|
|
114
|
+
return cwd;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get workspace package glob patterns from pnpm-workspace.yaml
|
|
118
|
+
* or package.json#workspaces.
|
|
119
|
+
*/
|
|
120
|
+
function getWorkspaceGlobs(root) {
|
|
121
|
+
const pnpmWorkspacePath = (0, node_path.join)(root, "pnpm-workspace.yaml");
|
|
122
|
+
if ((0, node_fs.existsSync)(pnpmWorkspacePath)) {
|
|
123
|
+
const content = (0, node_fs.readFileSync)(pnpmWorkspacePath, "utf-8");
|
|
124
|
+
return (0, yaml.parse)(content)?.packages ?? [];
|
|
125
|
+
}
|
|
126
|
+
const rootPkgJsonPath = (0, node_path.join)(root, "package.json");
|
|
127
|
+
if ((0, node_fs.existsSync)(rootPkgJsonPath)) {
|
|
128
|
+
const pkg = JSON.parse((0, node_fs.readFileSync)(rootPkgJsonPath, "utf-8"));
|
|
129
|
+
if (Array.isArray(pkg.workspaces)) return pkg.workspaces;
|
|
130
|
+
if (pkg.workspaces?.packages) return pkg.workspaces.packages;
|
|
131
|
+
}
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Find all package.json files across a workspace.
|
|
136
|
+
* Returns the root package.json plus all workspace member package.json paths.
|
|
137
|
+
*/
|
|
138
|
+
function findWorkspacePackages(cwd, pm) {
|
|
139
|
+
const workspaceRoot = findWorkspaceRoot(cwd, pm);
|
|
140
|
+
const results = [];
|
|
141
|
+
const rootPkgJson = (0, node_path.join)(workspaceRoot, "package.json");
|
|
142
|
+
if ((0, node_fs.existsSync)(rootPkgJson)) results.push(rootPkgJson);
|
|
143
|
+
const globs = getWorkspaceGlobs(workspaceRoot);
|
|
144
|
+
for (const glob of globs) {
|
|
145
|
+
const pattern = `${glob}/package.json`;
|
|
146
|
+
const matches = fast_glob.default.sync(pattern, {
|
|
147
|
+
cwd: workspaceRoot,
|
|
148
|
+
absolute: true,
|
|
149
|
+
ignore: ["**/node_modules/**"]
|
|
150
|
+
});
|
|
151
|
+
results.push(...matches);
|
|
152
|
+
}
|
|
153
|
+
return [...new Set(results)];
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
Object.defineProperty(exports, "checkDirectoryExists", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function() {
|
|
159
|
+
return checkDirectoryExists;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "detectPackageManager", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function() {
|
|
165
|
+
return detectPackageManager;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "findWorkspacePackages", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function() {
|
|
171
|
+
return findWorkspacePackages;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "findWorkspaceRoot", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function() {
|
|
177
|
+
return findWorkspaceRoot;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "getExecCommand", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function() {
|
|
183
|
+
return getExecCommand;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "getInstallCommand", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function() {
|
|
189
|
+
return getInstallCommand;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "getRunCommand", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function() {
|
|
195
|
+
return getRunCommand;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(exports, "validateProjectName", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function() {
|
|
201
|
+
return validateProjectName;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
//# sourceMappingURL=utils-D2Nk1Nv2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-D2Nk1Nv2.cjs","names":["existsSync","join","parse","readFileSync","dirname","parseYaml","fg"],"sources":["../src/init/utils.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, parse } from 'node:path';\nimport fg from 'fast-glob';\nimport { parse as parseYaml } from 'yaml';\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';\n\n/**\n * Detect the package manager being used based on lockfiles or npm_config_user_agent\n */\nexport function detectPackageManager(\n\tcwd: string = process.cwd(),\n): PackageManager {\n\t// Check for lockfiles in cwd\n\tif (existsSync(join(cwd, 'pnpm-lock.yaml'))) return 'pnpm';\n\tif (existsSync(join(cwd, 'yarn.lock'))) return 'yarn';\n\tif (existsSync(join(cwd, 'bun.lockb'))) return 'bun';\n\tif (existsSync(join(cwd, 'package-lock.json'))) return 'npm';\n\n\t// Check npm_config_user_agent (set when running via npx/pnpm dlx/etc)\n\tconst userAgent = process.env.npm_config_user_agent || '';\n\tif (userAgent.includes('pnpm')) return 'pnpm';\n\tif (userAgent.includes('yarn')) return 'yarn';\n\tif (userAgent.includes('bun')) return 'bun';\n\n\treturn 'npm';\n}\n\n/** `gkm init`'s flags, which a name can swallow when a space goes missing. */\nconst INIT_FLAGS = [\n\t'yes',\n\t'name',\n\t'template',\n\t'monorepo',\n\t'api-path',\n\t'pm',\n\t'skip-install',\n];\n\n/**\n * Validate project name for npm package naming conventions\n */\nexport function validateProjectName(name: string): boolean | string {\n\tif (!name) {\n\t\treturn 'Project name is required';\n\t}\n\n\t// Check for valid npm package name characters\n\tif (!/^[a-z0-9-_@/.]+$/i.test(name)) {\n\t\treturn 'Project name can only contain letters, numbers, hyphens, underscores, @, /, and .';\n\t}\n\n\t// `init shop--monorepo` is `init shop --monorepo` with the space\n\t// lost, and the flag then ends up in every package scope and physical name.\n\tconst flag = name.match(/--(\\w[\\w-]*)$/)?.[1];\n\tif (flag && INIT_FLAGS.includes(flag)) {\n\t\tconst intended = name.slice(0, -(flag.length + 2));\n\t\treturn `\"${name}\" ends in the --${flag} flag. Did you mean \\`${intended} --${flag}\\`?`;\n\t}\n\n\t// Check for reserved names\n\tconst reserved = ['node_modules', '.git', 'package.json', 'src'];\n\tif (reserved.includes(name.toLowerCase())) {\n\t\treturn `\"${name}\" is a reserved name`;\n\t}\n\n\treturn true;\n}\n\n/**\n * Check if a directory already exists at the target path\n */\nexport function checkDirectoryExists(\n\tname: string,\n\tcwd: string = process.cwd(),\n): boolean | string {\n\tconst targetPath = join(cwd, name);\n\tif (existsSync(targetPath)) {\n\t\treturn `Directory \"${name}\" already exists`;\n\t}\n\treturn true;\n}\n\n/**\n * Get the install command for a package manager\n */\nexport function getInstallCommand(pkgManager: PackageManager): string {\n\tswitch (pkgManager) {\n\t\tcase 'pnpm':\n\t\t\treturn 'pnpm install';\n\t\tcase 'yarn':\n\t\t\treturn 'yarn';\n\t\tcase 'bun':\n\t\t\treturn 'bun install';\n\t\tdefault:\n\t\t\treturn 'npm install';\n\t}\n}\n\n/**\n * Get the dev command for a package manager\n */\nexport function getRunCommand(\n\tpkgManager: PackageManager,\n\tscript: string,\n): string {\n\tswitch (pkgManager) {\n\t\tcase 'pnpm':\n\t\t\treturn `pnpm ${script}`;\n\t\tcase 'yarn':\n\t\t\treturn `yarn ${script}`;\n\t\tcase 'bun':\n\t\t\treturn `bun run ${script}`;\n\t\tdefault:\n\t\t\treturn `npm run ${script}`;\n\t}\n}\n\n/**\n * Run a binary the project installed, through its package manager — so it is\n * the project's own version, not whatever \\`npx\\` would fetch.\n */\nexport function getExecCommand(\n\tpkgManager: PackageManager,\n\tcommand: string,\n): string {\n\tswitch (pkgManager) {\n\t\tcase 'pnpm':\n\t\t\treturn `pnpm exec ${command}`;\n\t\tcase 'yarn':\n\t\t\treturn `yarn ${command}`;\n\t\tcase 'bun':\n\t\t\treturn `bunx ${command}`;\n\t\tdefault:\n\t\t\treturn `npx --no-install ${command}`;\n\t}\n}\n\nconst lockfileByPm: Record<PackageManager, string> = {\n\tpnpm: 'pnpm-lock.yaml',\n\tyarn: 'yarn.lock',\n\tnpm: 'package-lock.json',\n\tbun: 'bun.lockb',\n};\n\n/**\n * Find the workspace/project root by walking up from cwd.\n * Checks for PM-specific workspace config, package.json#workspaces,\n * and lockfiles.\n */\nexport function findWorkspaceRoot(cwd: string, pm: PackageManager): string {\n\tlet dir = cwd;\n\tconst root = parse(dir).root;\n\tconst lockfile = lockfileByPm[pm];\n\n\twhile (dir !== root) {\n\t\tif (pm === 'pnpm' && existsSync(join(dir, 'pnpm-workspace.yaml'))) {\n\t\t\treturn dir;\n\t\t}\n\n\t\tconst pkgJsonPath = join(dir, 'package.json');\n\t\tif (existsSync(pkgJsonPath)) {\n\t\t\ttry {\n\t\t\t\tconst pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n\t\t\t\tif (pkg.workspaces) return dir;\n\t\t\t} catch {\n\t\t\t\t// ignore malformed package.json\n\t\t\t}\n\t\t}\n\n\t\tif (existsSync(join(dir, lockfile))) {\n\t\t\treturn dir;\n\t\t}\n\n\t\tdir = dirname(dir);\n\t}\n\n\treturn cwd;\n}\n\n/**\n * Get workspace package glob patterns from pnpm-workspace.yaml\n * or package.json#workspaces.\n */\nexport function getWorkspaceGlobs(root: string): string[] {\n\tconst pnpmWorkspacePath = join(root, 'pnpm-workspace.yaml');\n\tif (existsSync(pnpmWorkspacePath)) {\n\t\tconst content = readFileSync(pnpmWorkspacePath, 'utf-8');\n\t\tconst parsed = parseYaml(content);\n\t\treturn parsed?.packages ?? [];\n\t}\n\n\tconst rootPkgJsonPath = join(root, 'package.json');\n\tif (existsSync(rootPkgJsonPath)) {\n\t\tconst pkg = JSON.parse(readFileSync(rootPkgJsonPath, 'utf-8'));\n\t\tif (Array.isArray(pkg.workspaces)) {\n\t\t\treturn pkg.workspaces;\n\t\t}\n\t\tif (pkg.workspaces?.packages) {\n\t\t\treturn pkg.workspaces.packages;\n\t\t}\n\t}\n\n\treturn [];\n}\n\n/**\n * Find all package.json files across a workspace.\n * Returns the root package.json plus all workspace member package.json paths.\n */\nexport function findWorkspacePackages(\n\tcwd: string,\n\tpm: PackageManager,\n): string[] {\n\tconst workspaceRoot = findWorkspaceRoot(cwd, pm);\n\tconst results: string[] = [];\n\n\tconst rootPkgJson = join(workspaceRoot, 'package.json');\n\tif (existsSync(rootPkgJson)) {\n\t\tresults.push(rootPkgJson);\n\t}\n\n\tconst globs = getWorkspaceGlobs(workspaceRoot);\n\n\tfor (const glob of globs) {\n\t\tconst pattern = `${glob}/package.json`;\n\t\tconst matches = fg.sync(pattern, {\n\t\t\tcwd: workspaceRoot,\n\t\t\tabsolute: true,\n\t\t\tignore: ['**/node_modules/**'],\n\t\t});\n\t\tresults.push(...matches);\n\t}\n\n\treturn [...new Set(results)];\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,qBACf,MAAc,QAAQ,IAAI,GACT;CAEjB,KAAA,GAAIA,QAAAA,WAAAA,EAAAA,GAAWC,UAAAA,KAAAA,CAAK,KAAK,gBAAgB,CAAC,GAAG,OAAO;CACpD,KAAA,GAAID,QAAAA,WAAAA,EAAAA,GAAWC,UAAAA,KAAAA,CAAK,KAAK,WAAW,CAAC,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A,CAAW,iBAAiB,GAAG;EAClC,MAAM,WAAA,GAAUG,QAAAA,aAAAA,CAAa,mBAAmB,OAAO;EAEvD,QAAA,GADeE,KAAAA,MAAAA,CAAU,OACb,CAAC,EAAE,YAAY,CAAC;CAC7B;CAEA,MAAM,mBAAA,GAAkBJ,UAAAA,KAAAA,CAAK,MAAM,cAAc;CACjD,KAAA,GAAID,QAAAA,WAAAA,CAAW,eAAe,GAAG;EAChC,MAAM,MAAM,KAAK,OAAA,GAAMG,QAAAA,aAAAA,CAAa,iBAAiB,OAAO,CAAC;EAC7D,IAAI,MAAM,QAAQ,IAAI,UAAU,GAC/B,OAAO,IAAI;EAEZ,IAAI,IAAI,YAAY,UACnB,OAAO,IAAI,WAAW;CAExB;CAEA,OAAO,CAAC;AACT;;;;;AAMA,SAAgB,sBACf,KACA,IACW;CACX,MAAM,gBAAgB,kBAAkB,KAAK,EAAE;CAC/C,MAAM,UAAoB,CAAC;CAE3B,MAAM,eAAA,GAAcF,UAAAA,KAAAA,CAAK,eAAe,cAAc;CACtD,KAAA,GAAID,QAAAA,WAAAA,CAAW,WAAW,GACzB,QAAQ,KAAK,WAAW;CAGzB,MAAM,QAAQ,kBAAkB,aAAa;CAE7C,KAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,UAAU,GAAG,KAAK;EACxB,MAAM,UAAUM,UAAAA,QAAG,KAAK,SAAS;GAChC,KAAK;GACL,UAAU;GACV,QAAQ,CAAC,oBAAoB;EAC9B,CAAC;EACD,QAAQ,KAAK,GAAG,OAAO;CACxB;CAEA,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;AAC5B"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { dirname, join, parse } from "node:path";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import fg from "fast-glob";
|
|
4
|
+
import { parse as parse$1 } from "yaml";
|
|
5
|
+
//#region src/init/utils.ts
|
|
6
|
+
/**
|
|
7
|
+
* Detect the package manager being used based on lockfiles or npm_config_user_agent
|
|
8
|
+
*/
|
|
9
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
10
|
+
if (existsSync(join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
11
|
+
if (existsSync(join(cwd, "yarn.lock"))) return "yarn";
|
|
12
|
+
if (existsSync(join(cwd, "bun.lockb"))) return "bun";
|
|
13
|
+
if (existsSync(join(cwd, "package-lock.json"))) return "npm";
|
|
14
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
15
|
+
if (userAgent.includes("pnpm")) return "pnpm";
|
|
16
|
+
if (userAgent.includes("yarn")) return "yarn";
|
|
17
|
+
if (userAgent.includes("bun")) return "bun";
|
|
18
|
+
return "npm";
|
|
19
|
+
}
|
|
20
|
+
/** `gkm init`'s flags, which a name can swallow when a space goes missing. */
|
|
21
|
+
const INIT_FLAGS = [
|
|
22
|
+
"yes",
|
|
23
|
+
"name",
|
|
24
|
+
"template",
|
|
25
|
+
"monorepo",
|
|
26
|
+
"api-path",
|
|
27
|
+
"pm",
|
|
28
|
+
"skip-install"
|
|
29
|
+
];
|
|
30
|
+
/**
|
|
31
|
+
* Validate project name for npm package naming conventions
|
|
32
|
+
*/
|
|
33
|
+
function validateProjectName(name) {
|
|
34
|
+
if (!name) return "Project name is required";
|
|
35
|
+
if (!/^[a-z0-9-_@/.]+$/i.test(name)) return "Project name can only contain letters, numbers, hyphens, underscores, @, /, and .";
|
|
36
|
+
const flag = name.match(/--(\w[\w-]*)$/)?.[1];
|
|
37
|
+
if (flag && INIT_FLAGS.includes(flag)) return `"${name}" ends in the --${flag} flag. Did you mean \`${name.slice(0, -(flag.length + 2))} --${flag}\`?`;
|
|
38
|
+
if ([
|
|
39
|
+
"node_modules",
|
|
40
|
+
".git",
|
|
41
|
+
"package.json",
|
|
42
|
+
"src"
|
|
43
|
+
].includes(name.toLowerCase())) return `"${name}" is a reserved name`;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if a directory already exists at the target path
|
|
48
|
+
*/
|
|
49
|
+
function checkDirectoryExists(name, cwd = process.cwd()) {
|
|
50
|
+
const targetPath = join(cwd, name);
|
|
51
|
+
if (existsSync(targetPath)) return `Directory "${name}" already exists`;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the install command for a package manager
|
|
56
|
+
*/
|
|
57
|
+
function getInstallCommand(pkgManager) {
|
|
58
|
+
switch (pkgManager) {
|
|
59
|
+
case "pnpm": return "pnpm install";
|
|
60
|
+
case "yarn": return "yarn";
|
|
61
|
+
case "bun": return "bun install";
|
|
62
|
+
default: return "npm install";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get the dev command for a package manager
|
|
67
|
+
*/
|
|
68
|
+
function getRunCommand(pkgManager, script) {
|
|
69
|
+
switch (pkgManager) {
|
|
70
|
+
case "pnpm": return `pnpm ${script}`;
|
|
71
|
+
case "yarn": return `yarn ${script}`;
|
|
72
|
+
case "bun": return `bun run ${script}`;
|
|
73
|
+
default: return `npm run ${script}`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run a binary the project installed, through its package manager — so it is
|
|
78
|
+
* the project's own version, not whatever \`npx\` would fetch.
|
|
79
|
+
*/
|
|
80
|
+
function getExecCommand(pkgManager, command) {
|
|
81
|
+
switch (pkgManager) {
|
|
82
|
+
case "pnpm": return `pnpm exec ${command}`;
|
|
83
|
+
case "yarn": return `yarn ${command}`;
|
|
84
|
+
case "bun": return `bunx ${command}`;
|
|
85
|
+
default: return `npx --no-install ${command}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const lockfileByPm = {
|
|
89
|
+
pnpm: "pnpm-lock.yaml",
|
|
90
|
+
yarn: "yarn.lock",
|
|
91
|
+
npm: "package-lock.json",
|
|
92
|
+
bun: "bun.lockb"
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Find the workspace/project root by walking up from cwd.
|
|
96
|
+
* Checks for PM-specific workspace config, package.json#workspaces,
|
|
97
|
+
* and lockfiles.
|
|
98
|
+
*/
|
|
99
|
+
function findWorkspaceRoot(cwd, pm) {
|
|
100
|
+
let dir = cwd;
|
|
101
|
+
const root = parse(dir).root;
|
|
102
|
+
const lockfile = lockfileByPm[pm];
|
|
103
|
+
while (dir !== root) {
|
|
104
|
+
if (pm === "pnpm" && existsSync(join(dir, "pnpm-workspace.yaml"))) return dir;
|
|
105
|
+
const pkgJsonPath = join(dir, "package.json");
|
|
106
|
+
if (existsSync(pkgJsonPath)) try {
|
|
107
|
+
if (JSON.parse(readFileSync(pkgJsonPath, "utf-8")).workspaces) return dir;
|
|
108
|
+
} catch {}
|
|
109
|
+
if (existsSync(join(dir, lockfile))) return dir;
|
|
110
|
+
dir = dirname(dir);
|
|
111
|
+
}
|
|
112
|
+
return cwd;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get workspace package glob patterns from pnpm-workspace.yaml
|
|
116
|
+
* or package.json#workspaces.
|
|
117
|
+
*/
|
|
118
|
+
function getWorkspaceGlobs(root) {
|
|
119
|
+
const pnpmWorkspacePath = join(root, "pnpm-workspace.yaml");
|
|
120
|
+
if (existsSync(pnpmWorkspacePath)) {
|
|
121
|
+
const content = readFileSync(pnpmWorkspacePath, "utf-8");
|
|
122
|
+
return parse$1(content)?.packages ?? [];
|
|
123
|
+
}
|
|
124
|
+
const rootPkgJsonPath = join(root, "package.json");
|
|
125
|
+
if (existsSync(rootPkgJsonPath)) {
|
|
126
|
+
const pkg = JSON.parse(readFileSync(rootPkgJsonPath, "utf-8"));
|
|
127
|
+
if (Array.isArray(pkg.workspaces)) return pkg.workspaces;
|
|
128
|
+
if (pkg.workspaces?.packages) return pkg.workspaces.packages;
|
|
129
|
+
}
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Find all package.json files across a workspace.
|
|
134
|
+
* Returns the root package.json plus all workspace member package.json paths.
|
|
135
|
+
*/
|
|
136
|
+
function findWorkspacePackages(cwd, pm) {
|
|
137
|
+
const workspaceRoot = findWorkspaceRoot(cwd, pm);
|
|
138
|
+
const results = [];
|
|
139
|
+
const rootPkgJson = join(workspaceRoot, "package.json");
|
|
140
|
+
if (existsSync(rootPkgJson)) results.push(rootPkgJson);
|
|
141
|
+
const globs = getWorkspaceGlobs(workspaceRoot);
|
|
142
|
+
for (const glob of globs) {
|
|
143
|
+
const pattern = `${glob}/package.json`;
|
|
144
|
+
const matches = fg.sync(pattern, {
|
|
145
|
+
cwd: workspaceRoot,
|
|
146
|
+
absolute: true,
|
|
147
|
+
ignore: ["**/node_modules/**"]
|
|
148
|
+
});
|
|
149
|
+
results.push(...matches);
|
|
150
|
+
}
|
|
151
|
+
return [...new Set(results)];
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { getExecCommand as a, validateProjectName as c, findWorkspaceRoot as i, detectPackageManager as n, getInstallCommand as o, findWorkspacePackages as r, getRunCommand as s, checkDirectoryExists as t };
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=utils-D_fxUqvU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-D_fxUqvU.mjs","names":["parseYaml"],"sources":["../src/init/utils.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, parse } from 'node:path';\nimport fg from 'fast-glob';\nimport { parse as parseYaml } from 'yaml';\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';\n\n/**\n * Detect the package manager being used based on lockfiles or npm_config_user_agent\n */\nexport function detectPackageManager(\n\tcwd: string = process.cwd(),\n): PackageManager {\n\t// Check for lockfiles in cwd\n\tif (existsSync(join(cwd, 'pnpm-lock.yaml'))) return 'pnpm';\n\tif (existsSync(join(cwd, 'yarn.lock'))) return 'yarn';\n\tif (existsSync(join(cwd, 'bun.lockb'))) return 'bun';\n\tif (existsSync(join(cwd, 'package-lock.json'))) return 'npm';\n\n\t// Check npm_config_user_agent (set when running via npx/pnpm dlx/etc)\n\tconst userAgent = process.env.npm_config_user_agent || '';\n\tif (userAgent.includes('pnpm')) return 'pnpm';\n\tif (userAgent.includes('yarn')) return 'yarn';\n\tif (userAgent.includes('bun')) return 'bun';\n\n\treturn 'npm';\n}\n\n/** `gkm init`'s flags, which a name can swallow when a space goes missing. */\nconst INIT_FLAGS = [\n\t'yes',\n\t'name',\n\t'template',\n\t'monorepo',\n\t'api-path',\n\t'pm',\n\t'skip-install',\n];\n\n/**\n * Validate project name for npm package naming conventions\n */\nexport function validateProjectName(name: string): boolean | string {\n\tif (!name) {\n\t\treturn 'Project name is required';\n\t}\n\n\t// Check for valid npm package name characters\n\tif (!/^[a-z0-9-_@/.]+$/i.test(name)) {\n\t\treturn 'Project name can only contain letters, numbers, hyphens, underscores, @, /, and .';\n\t}\n\n\t// `init shop--monorepo` is `init shop --monorepo` with the space\n\t// lost, and the flag then ends up in every package scope and physical name.\n\tconst flag = name.match(/--(\\w[\\w-]*)$/)?.[1];\n\tif (flag && INIT_FLAGS.includes(flag)) {\n\t\tconst intended = name.slice(0, -(flag.length + 2));\n\t\treturn `\"${name}\" ends in the --${flag} flag. Did you mean \\`${intended} --${flag}\\`?`;\n\t}\n\n\t// Check for reserved names\n\tconst reserved = ['node_modules', '.git', 'package.json', 'src'];\n\tif (reserved.includes(name.toLowerCase())) {\n\t\treturn `\"${name}\" is a reserved name`;\n\t}\n\n\treturn true;\n}\n\n/**\n * Check if a directory already exists at the target path\n */\nexport function checkDirectoryExists(\n\tname: string,\n\tcwd: string = process.cwd(),\n): boolean | string {\n\tconst targetPath = join(cwd, name);\n\tif (existsSync(targetPath)) {\n\t\treturn `Directory \"${name}\" already exists`;\n\t}\n\treturn true;\n}\n\n/**\n * Get the install command for a package manager\n */\nexport function getInstallCommand(pkgManager: PackageManager): string {\n\tswitch (pkgManager) {\n\t\tcase 'pnpm':\n\t\t\treturn 'pnpm install';\n\t\tcase 'yarn':\n\t\t\treturn 'yarn';\n\t\tcase 'bun':\n\t\t\treturn 'bun install';\n\t\tdefault:\n\t\t\treturn 'npm install';\n\t}\n}\n\n/**\n * Get the dev command for a package manager\n */\nexport function getRunCommand(\n\tpkgManager: PackageManager,\n\tscript: string,\n): string {\n\tswitch (pkgManager) {\n\t\tcase 'pnpm':\n\t\t\treturn `pnpm ${script}`;\n\t\tcase 'yarn':\n\t\t\treturn `yarn ${script}`;\n\t\tcase 'bun':\n\t\t\treturn `bun run ${script}`;\n\t\tdefault:\n\t\t\treturn `npm run ${script}`;\n\t}\n}\n\n/**\n * Run a binary the project installed, through its package manager — so it is\n * the project's own version, not whatever \\`npx\\` would fetch.\n */\nexport function getExecCommand(\n\tpkgManager: PackageManager,\n\tcommand: string,\n): string {\n\tswitch (pkgManager) {\n\t\tcase 'pnpm':\n\t\t\treturn `pnpm exec ${command}`;\n\t\tcase 'yarn':\n\t\t\treturn `yarn ${command}`;\n\t\tcase 'bun':\n\t\t\treturn `bunx ${command}`;\n\t\tdefault:\n\t\t\treturn `npx --no-install ${command}`;\n\t}\n}\n\nconst lockfileByPm: Record<PackageManager, string> = {\n\tpnpm: 'pnpm-lock.yaml',\n\tyarn: 'yarn.lock',\n\tnpm: 'package-lock.json',\n\tbun: 'bun.lockb',\n};\n\n/**\n * Find the workspace/project root by walking up from cwd.\n * Checks for PM-specific workspace config, package.json#workspaces,\n * and lockfiles.\n */\nexport function findWorkspaceRoot(cwd: string, pm: PackageManager): string {\n\tlet dir = cwd;\n\tconst root = parse(dir).root;\n\tconst lockfile = lockfileByPm[pm];\n\n\twhile (dir !== root) {\n\t\tif (pm === 'pnpm' && existsSync(join(dir, 'pnpm-workspace.yaml'))) {\n\t\t\treturn dir;\n\t\t}\n\n\t\tconst pkgJsonPath = join(dir, 'package.json');\n\t\tif (existsSync(pkgJsonPath)) {\n\t\t\ttry {\n\t\t\t\tconst pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n\t\t\t\tif (pkg.workspaces) return dir;\n\t\t\t} catch {\n\t\t\t\t// ignore malformed package.json\n\t\t\t}\n\t\t}\n\n\t\tif (existsSync(join(dir, lockfile))) {\n\t\t\treturn dir;\n\t\t}\n\n\t\tdir = dirname(dir);\n\t}\n\n\treturn cwd;\n}\n\n/**\n * Get workspace package glob patterns from pnpm-workspace.yaml\n * or package.json#workspaces.\n */\nexport function getWorkspaceGlobs(root: string): string[] {\n\tconst pnpmWorkspacePath = join(root, 'pnpm-workspace.yaml');\n\tif (existsSync(pnpmWorkspacePath)) {\n\t\tconst content = readFileSync(pnpmWorkspacePath, 'utf-8');\n\t\tconst parsed = parseYaml(content);\n\t\treturn parsed?.packages ?? [];\n\t}\n\n\tconst rootPkgJsonPath = join(root, 'package.json');\n\tif (existsSync(rootPkgJsonPath)) {\n\t\tconst pkg = JSON.parse(readFileSync(rootPkgJsonPath, 'utf-8'));\n\t\tif (Array.isArray(pkg.workspaces)) {\n\t\t\treturn pkg.workspaces;\n\t\t}\n\t\tif (pkg.workspaces?.packages) {\n\t\t\treturn pkg.workspaces.packages;\n\t\t}\n\t}\n\n\treturn [];\n}\n\n/**\n * Find all package.json files across a workspace.\n * Returns the root package.json plus all workspace member package.json paths.\n */\nexport function findWorkspacePackages(\n\tcwd: string,\n\tpm: PackageManager,\n): string[] {\n\tconst workspaceRoot = findWorkspaceRoot(cwd, pm);\n\tconst results: string[] = [];\n\n\tconst rootPkgJson = join(workspaceRoot, 'package.json');\n\tif (existsSync(rootPkgJson)) {\n\t\tresults.push(rootPkgJson);\n\t}\n\n\tconst globs = getWorkspaceGlobs(workspaceRoot);\n\n\tfor (const glob of globs) {\n\t\tconst pattern = `${glob}/package.json`;\n\t\tconst matches = fg.sync(pattern, {\n\t\t\tcwd: workspaceRoot,\n\t\t\tabsolute: true,\n\t\t\tignore: ['**/node_modules/**'],\n\t\t});\n\t\tresults.push(...matches);\n\t}\n\n\treturn [...new Set(results)];\n}\n"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K,MAAM,aAAa,iBAAiB,OAAO,CAAC;EAC7D,IAAI,MAAM,QAAQ,IAAI,UAAU,GAC/B,OAAO,IAAI;EAEZ,IAAI,IAAI,YAAY,UACnB,OAAO,IAAI,WAAW;CAExB;CAEA,OAAO,CAAC;AACT;;;;;AAMA,SAAgB,sBACf,KACA,IACW;CACX,MAAM,gBAAgB,kBAAkB,KAAK,EAAE;CAC/C,MAAM,UAAoB,CAAC;CAE3B,MAAM,cAAc,KAAK,eAAe,cAAc;CACtD,IAAI,WAAW,WAAW,GACzB,QAAQ,KAAK,WAAW;CAGzB,MAAM,QAAQ,kBAAkB,aAAa;CAE7C,KAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,UAAU,GAAG,KAAK;EACxB,MAAM,UAAU,GAAG,KAAK,SAAS;GAChC,KAAK;GACL,UAAU;GACV,QAAQ,CAAC,oBAAoB;EAC9B,CAAC;EACD,QAAQ,KAAK,GAAG,OAAO;CACxB;CAEA,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;AAC5B"}
|
package/dist/vitest.cjs
CHANGED
package/dist/vitest.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as TEST_MANIFEST_ENV, n as TEST_READY_FILE } from "./ready-
|
|
1
|
+
import { i as TEST_MANIFEST_ENV, n as TEST_READY_FILE } from "./ready-bQfu9GES.mjs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
package/dist/workspace/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_workspace = require("../workspace-
|
|
2
|
+
const require_workspace = require("../workspace-BewAHZIo.cjs");
|
|
3
|
+
exports.DokployRegistryMoved = require_workspace.DokployRegistryMoved;
|
|
3
4
|
exports.PHASE_2_DEPLOY_TARGETS = require_workspace.PHASE_2_DEPLOY_TARGETS;
|
|
4
5
|
exports.PUBLIC_ENV_PREFIXES = require_workspace.PUBLIC_ENV_PREFIXES;
|
|
5
6
|
exports.SUPPORTED_DEPLOY_TARGETS = require_workspace.SUPPORTED_DEPLOY_TARGETS;
|
|
6
7
|
exports.WorkspaceConfigSchema = require_workspace.WorkspaceConfigSchema;
|
|
7
8
|
exports.allConstructGlobs = require_workspace.allConstructGlobs;
|
|
8
9
|
exports.appConstructGlobs = require_workspace.appConstructGlobs;
|
|
10
|
+
exports.assertNoMovedDeployKeys = require_workspace.assertNoMovedDeployKeys;
|
|
9
11
|
exports.constructPatterns = require_workspace.constructPatterns;
|
|
10
12
|
exports.defineWorkspace = require_workspace.defineWorkspace;
|
|
11
13
|
exports.formatValidationErrors = require_workspace.formatValidationErrors;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as PHASE_2_DEPLOY_TARGETS, C as WorkspaceConfig, E as BackendFramework, F as isDeployTargetSupported, I as isPhase2DeployTarget, L as safeValidateWorkspaceConfig, M as WorkspaceConfigSchema, N as formatValidationErrors, O as FrontendFramework, P as getDeployTargetError, R as validateWorkspaceConfig, S as SharedConfig, T as isWorkspaceConfig, _ as LoadedConfig, b as NormalizedWorkspace, c as AppInput, d as DeployConfig, f as DeployTargetName, g as InferredWorkspaceConfig, h as InferAppNames, j as SUPPORTED_DEPLOY_TARGETS, k as MobileFramework, l as AppsRecord, m as DokployWorkspaceConfig, o as AppConfig, s as AppConfigInput, u as ConstrainedApps, v as ModelsConfig, w as WorkspaceInput, x as SecretsConfig, y as NormalizedAppConfig } from "../types-
|
|
2
|
-
import { a as
|
|
3
|
-
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ConstrainedApps, type DeployConfig, type DeployTargetName, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
1
|
+
import { A as PHASE_2_DEPLOY_TARGETS, C as WorkspaceConfig, E as BackendFramework, F as isDeployTargetSupported, I as isPhase2DeployTarget, L as safeValidateWorkspaceConfig, M as WorkspaceConfigSchema, N as formatValidationErrors, O as FrontendFramework, P as getDeployTargetError, R as validateWorkspaceConfig, S as SharedConfig, T as isWorkspaceConfig, _ as LoadedConfig, b as NormalizedWorkspace, c as AppInput, d as DeployConfig, f as DeployTargetName, g as InferredWorkspaceConfig, h as InferAppNames, j as SUPPORTED_DEPLOY_TARGETS, k as MobileFramework, l as AppsRecord, m as DokployWorkspaceConfig, o as AppConfig, s as AppConfigInput, u as ConstrainedApps, v as ModelsConfig, w as WorkspaceInput, x as SecretsConfig, y as NormalizedAppConfig } from "../types-ByMWkXKP.cjs";
|
|
2
|
+
import { a as constructPatterns, c as getAppGkmConfig, d as processConfig, f as workspaceConstructGlobs, g as stripPublicPrefix, h as getPublicEnvPrefix, i as assertNoMovedDeployKeys, l as getEndpointForStage, m as PUBLIC_ENV_PREFIXES, n as allConstructGlobs, o as defineWorkspace, p as wrapSingleAppAsWorkspace, r as appConstructGlobs, s as getAppBuildOrder, t as DokployRegistryMoved, u as normalizeWorkspace } from "../index-DPUAGJaK.cjs";
|
|
3
|
+
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ConstrainedApps, type DeployConfig, type DeployTargetName, DokployRegistryMoved, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as PHASE_2_DEPLOY_TARGETS, C as WorkspaceConfig, E as BackendFramework, F as isDeployTargetSupported, I as isPhase2DeployTarget, L as safeValidateWorkspaceConfig, M as WorkspaceConfigSchema, N as formatValidationErrors, O as FrontendFramework, P as getDeployTargetError, R as validateWorkspaceConfig, S as SharedConfig, T as isWorkspaceConfig, _ as LoadedConfig, b as NormalizedWorkspace, c as AppInput, d as DeployConfig, f as DeployTargetName, g as InferredWorkspaceConfig, h as InferAppNames, j as SUPPORTED_DEPLOY_TARGETS, k as MobileFramework, l as AppsRecord, m as DokployWorkspaceConfig, o as AppConfig, s as AppConfigInput, u as ConstrainedApps, v as ModelsConfig, w as WorkspaceInput, x as SecretsConfig, y as NormalizedAppConfig } from "../types-
|
|
2
|
-
import { a as
|
|
3
|
-
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ConstrainedApps, type DeployConfig, type DeployTargetName, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
1
|
+
import { A as PHASE_2_DEPLOY_TARGETS, C as WorkspaceConfig, E as BackendFramework, F as isDeployTargetSupported, I as isPhase2DeployTarget, L as safeValidateWorkspaceConfig, M as WorkspaceConfigSchema, N as formatValidationErrors, O as FrontendFramework, P as getDeployTargetError, R as validateWorkspaceConfig, S as SharedConfig, T as isWorkspaceConfig, _ as LoadedConfig, b as NormalizedWorkspace, c as AppInput, d as DeployConfig, f as DeployTargetName, g as InferredWorkspaceConfig, h as InferAppNames, j as SUPPORTED_DEPLOY_TARGETS, k as MobileFramework, l as AppsRecord, m as DokployWorkspaceConfig, o as AppConfig, s as AppConfigInput, u as ConstrainedApps, v as ModelsConfig, w as WorkspaceInput, x as SecretsConfig, y as NormalizedAppConfig } from "../types-BCzMWBb6.mjs";
|
|
2
|
+
import { a as constructPatterns, c as getAppGkmConfig, d as processConfig, f as workspaceConstructGlobs, g as stripPublicPrefix, h as getPublicEnvPrefix, i as assertNoMovedDeployKeys, l as getEndpointForStage, m as PUBLIC_ENV_PREFIXES, n as allConstructGlobs, o as defineWorkspace, p as wrapSingleAppAsWorkspace, r as appConstructGlobs, s as getAppBuildOrder, t as DokployRegistryMoved, u as normalizeWorkspace } from "../index-DwKD_8lt.mjs";
|
|
3
|
+
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ConstrainedApps, type DeployConfig, type DeployTargetName, DokployRegistryMoved, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
package/dist/workspace/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, WorkspaceConfigSchema, allConstructGlobs, appConstructGlobs, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
1
|
+
import { C as isDeployTargetSupported, E as validateWorkspaceConfig, S as getDeployTargetError, T as safeValidateWorkspaceConfig, _ as isWorkspaceConfig, a as constructPatterns, b as WorkspaceConfigSchema, c as getAppGkmConfig, d as processConfig, f as workspaceConstructGlobs, g as stripPublicPrefix, h as getPublicEnvPrefix, i as assertNoMovedDeployKeys, l as getEndpointForStage, m as PUBLIC_ENV_PREFIXES, n as allConstructGlobs, o as defineWorkspace, p as wrapSingleAppAsWorkspace, r as appConstructGlobs, s as getAppBuildOrder, t as DokployRegistryMoved, u as normalizeWorkspace, v as PHASE_2_DEPLOY_TARGETS, w as isPhase2DeployTarget, x as formatValidationErrors, y as SUPPORTED_DEPLOY_TARGETS } from "../workspace-C06_pW4g.mjs";
|
|
2
|
+
export { DokployRegistryMoved, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, WorkspaceConfigSchema, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_schemas = require("./schemas-Ckm_aBnF.cjs");
|
|
2
|
-
const require_define = require("./define-
|
|
2
|
+
const require_define = require("./define-DzRz8FgH.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
//#region src/workspace/stages.ts
|
|
5
5
|
/**
|
|
@@ -143,9 +143,9 @@ const MOBILE_FRAMEWORKS = ["expo"];
|
|
|
143
143
|
*/
|
|
144
144
|
const DeployTargetSchema = require_schemas.string().min(1);
|
|
145
145
|
/**
|
|
146
|
-
* The built-in targets a config may name
|
|
147
|
-
* `
|
|
148
|
-
*
|
|
146
|
+
* The built-in targets a config may name, both deployed by `gkm deploy`:
|
|
147
|
+
* `dokploy`, and `sst`, which runs `sst deploy` on the manifest `gkm build`
|
|
148
|
+
* writes.
|
|
149
149
|
*/
|
|
150
150
|
const SUPPORTED_DEPLOY_TARGETS = require_define.configurableBuiltins();
|
|
151
151
|
/** Built-in names reserved for targets that do not exist yet. */
|
|
@@ -188,7 +188,6 @@ const DokployWorkspaceConfigSchema = require_schemas.object({
|
|
|
188
188
|
endpoint: require_schemas.url("Dokploy endpoint must be a valid URL").optional(),
|
|
189
189
|
/** Per-stage endpoints (stage name -> endpoint URL) */
|
|
190
190
|
endpoints: require_schemas.record(require_schemas.string(), require_schemas.url("Endpoint must be a valid URL")).optional(),
|
|
191
|
-
registry: require_schemas.string().optional(),
|
|
192
191
|
registryId: require_schemas.string().optional()
|
|
193
192
|
}).refine((data) => data.endpoint || data.endpoints, { message: "Either endpoint or endpoints must be provided" });
|
|
194
193
|
/**
|
|
@@ -393,6 +392,8 @@ const DeployConfigSchema = require_schemas.object({
|
|
|
393
392
|
namespace: require_schemas.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "deploy.namespace must be lowercase letters and digits with single '-' between them").optional(),
|
|
394
393
|
/** Each deployed stage's base domain (stage name -> domain). */
|
|
395
394
|
domains: require_schemas.record(require_schemas.string(), require_schemas.string()).optional(),
|
|
395
|
+
/** Where every target pushes and pulls the apps' images. */
|
|
396
|
+
registry: require_schemas.string().min(1).optional(),
|
|
396
397
|
dokploy: DokployWorkspaceConfigSchema.optional(),
|
|
397
398
|
dns: DnsConfigWithLegacySchema.optional(),
|
|
398
399
|
backups: BackupsConfigSchema.optional()
|
|
@@ -802,6 +803,7 @@ function validateDependencies(apps) {
|
|
|
802
803
|
* ```
|
|
803
804
|
*/
|
|
804
805
|
function defineWorkspace(config) {
|
|
806
|
+
assertNoMovedDeployKeys(config.deploy);
|
|
805
807
|
if (config.apps) validateDependencies(config.apps);
|
|
806
808
|
const result = safeValidateWorkspaceConfig(config);
|
|
807
809
|
if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
|
|
@@ -890,7 +892,28 @@ function wrapSingleAppAsWorkspace(config, cwd) {
|
|
|
890
892
|
* Process a loaded configuration (either single-app or workspace).
|
|
891
893
|
* Returns a normalized workspace in both cases.
|
|
892
894
|
*/
|
|
895
|
+
/**
|
|
896
|
+
* `deploy.dokploy.registry`, which became `deploy.registry`: every target
|
|
897
|
+
* pushes and pulls through the one registry, so it is not Dokploy's to hold.
|
|
898
|
+
*
|
|
899
|
+
* Refused by name rather than dropped: the schema strips keys it does not
|
|
900
|
+
* know, and a registry silently gone would deploy images under no registry.
|
|
901
|
+
*/
|
|
902
|
+
var DokployRegistryMoved = class extends Error {
|
|
903
|
+
registry;
|
|
904
|
+
constructor(registry) {
|
|
905
|
+
super(`deploy.dokploy.registry is now deploy.registry, read by every deploy target. In gkm.config.ts, move it up one level: deploy: { registry: ${JSON.stringify(registry)}, dokploy: { … } }.`);
|
|
906
|
+
this.registry = registry;
|
|
907
|
+
this.name = "DokployRegistryMoved";
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
/** Refuse a deploy key that has moved, naming where it lives now. */
|
|
911
|
+
function assertNoMovedDeployKeys(deploy) {
|
|
912
|
+
const dokploy = deploy?.dokploy;
|
|
913
|
+
if (dokploy && typeof dokploy === "object" && "registry" in dokploy) throw new DokployRegistryMoved(dokploy.registry);
|
|
914
|
+
}
|
|
893
915
|
function processConfig(config, cwd) {
|
|
916
|
+
assertNoMovedDeployKeys(config.deploy);
|
|
894
917
|
if (isWorkspaceConfig(config)) {
|
|
895
918
|
const result = safeValidateWorkspaceConfig(config);
|
|
896
919
|
if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
|
|
@@ -1018,6 +1041,12 @@ function getEndpointForStage(dokployConfig, stage) {
|
|
|
1018
1041
|
return dokployConfig.endpoint;
|
|
1019
1042
|
}
|
|
1020
1043
|
//#endregion
|
|
1044
|
+
Object.defineProperty(exports, "DokployRegistryMoved", {
|
|
1045
|
+
enumerable: true,
|
|
1046
|
+
get: function() {
|
|
1047
|
+
return DokployRegistryMoved;
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1021
1050
|
Object.defineProperty(exports, "InvalidStages", {
|
|
1022
1051
|
enumerable: true,
|
|
1023
1052
|
get: function() {
|
|
@@ -1072,6 +1101,12 @@ Object.defineProperty(exports, "assertDeployedStage", {
|
|
|
1072
1101
|
return assertDeployedStage;
|
|
1073
1102
|
}
|
|
1074
1103
|
});
|
|
1104
|
+
Object.defineProperty(exports, "assertNoMovedDeployKeys", {
|
|
1105
|
+
enumerable: true,
|
|
1106
|
+
get: function() {
|
|
1107
|
+
return assertNoMovedDeployKeys;
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1075
1110
|
Object.defineProperty(exports, "constructPatterns", {
|
|
1076
1111
|
enumerable: true,
|
|
1077
1112
|
get: function() {
|
|
@@ -1193,4 +1228,4 @@ Object.defineProperty(exports, "wrapSingleAppAsWorkspace", {
|
|
|
1193
1228
|
}
|
|
1194
1229
|
});
|
|
1195
1230
|
|
|
1196
|
-
//# sourceMappingURL=workspace-
|
|
1231
|
+
//# sourceMappingURL=workspace-BewAHZIo.cjs.map
|