@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
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
const require_define = require("./define-Cv_QvDrg.cjs");
|
|
2
|
-
const require_runtime = require("./runtime-CMwtq0AL.cjs");
|
|
3
|
-
//#region src/target/provider.ts
|
|
4
|
-
/**
|
|
5
|
-
* `gkm deploy --provider`, from before there were targets.
|
|
6
|
-
*
|
|
7
|
-
* It named three things, and only one of them ever deployed a workspace:
|
|
8
|
-
* `dokploy` is now the target of that name; `docker` and `aws-lambda` were
|
|
9
|
-
* accepted and always failed, so they are gone with a pointer to what does
|
|
10
|
-
* the job.
|
|
11
|
-
*/
|
|
12
|
-
/** What each removed provider's job is done with now. */
|
|
13
|
-
const REMOVED = {
|
|
14
|
-
docker: "Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`",
|
|
15
|
-
"aws-lambda": "Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm build && sst deploy --stage <stage>`"
|
|
16
|
-
};
|
|
17
|
-
/** A `--provider` that no longer exists. */
|
|
18
|
-
var ProviderRemoved = class extends Error {
|
|
19
|
-
provider;
|
|
20
|
-
instead;
|
|
21
|
-
constructor(provider, instead) {
|
|
22
|
-
super(`--provider ${provider} has been removed. ${instead}.`);
|
|
23
|
-
this.provider = provider;
|
|
24
|
-
this.instead = instead;
|
|
25
|
-
this.name = "ProviderRemoved";
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/** The deprecation `--provider` prints when it still means something. */
|
|
29
|
-
function providerDeprecation(provider) {
|
|
30
|
-
return `--provider is deprecated; use --target ${provider}.`;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The target a `--provider` value means. `warn` hears the deprecation; a
|
|
34
|
-
* provider that is gone, or a target not deployable yet, throws.
|
|
35
|
-
*/
|
|
36
|
-
function targetForProvider(provider, warn) {
|
|
37
|
-
const removed = REMOVED[provider];
|
|
38
|
-
if (removed) throw new ProviderRemoved(provider, removed);
|
|
39
|
-
if (provider === "vercel" || provider === "cloudflare") throw new require_define.DeployTargetNotYetSupported(provider);
|
|
40
|
-
warn(providerDeprecation(provider));
|
|
41
|
-
return provider;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/target/resolve.ts
|
|
45
|
-
/**
|
|
46
|
-
* From a target's name to the target.
|
|
47
|
-
*
|
|
48
|
-
* In this order, the first that has the name wins:
|
|
49
|
-
*
|
|
50
|
-
* 1. the host's own targets — what a program calling `deploy()` passes
|
|
51
|
-
* 2. the built-ins — `dokploy`
|
|
52
|
-
* 3. `deploy.targets` in gkm.config.ts — a package, an object, or either
|
|
53
|
-
* with options
|
|
54
|
-
*
|
|
55
|
-
* Built-ins come before the config so that a dependency cannot take over
|
|
56
|
-
* `dokploy` by being listed under its name. A name nothing has is
|
|
57
|
-
* `UnknownDeployTarget`. There is deliberately no fourth step that guesses a
|
|
58
|
-
* package from the name (`acme` → `@acme/gkm-target`): an npm scope nobody
|
|
59
|
-
* has claimed can be claimed by anyone, and a deploy would then run their
|
|
60
|
-
* code with the stage's credentials. A target is installed and named.
|
|
61
|
-
*/
|
|
62
|
-
/** A target package whose default export is not a target. */
|
|
63
|
-
var TargetPackageInvalid = class extends Error {
|
|
64
|
-
target;
|
|
65
|
-
packageName;
|
|
66
|
-
constructor(target, packageName) {
|
|
67
|
-
super(`deploy.targets.${target} names "${packageName}", whose default export is not a deploy target. A target package exports one as default: export default defineTarget({ … }) from '@geekmidas/cli/target'.`);
|
|
68
|
-
this.target = target;
|
|
69
|
-
this.packageName = packageName;
|
|
70
|
-
this.name = "TargetPackageInvalid";
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
/** A `deploy.targets` entry that is not a target, a package name or a pair. */
|
|
74
|
-
var TargetEntryInvalid = class extends Error {
|
|
75
|
-
target;
|
|
76
|
-
constructor(target) {
|
|
77
|
-
super(`deploy.targets.${target} must be a package name, a target object (defineTarget), or [package or target, options].`);
|
|
78
|
-
this.target = target;
|
|
79
|
-
this.name = "TargetEntryInvalid";
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
/** A target whose `runtime` is not the one its package declares. */
|
|
83
|
-
var TargetRuntimeMismatch = class extends Error {
|
|
84
|
-
target;
|
|
85
|
-
packageName;
|
|
86
|
-
declared;
|
|
87
|
-
actual;
|
|
88
|
-
constructor(target, packageName, declared, actual) {
|
|
89
|
-
super(`The deploy target "${target}" runs on "${actual}", but ${packageName}'s package.json declares gkm.runtime "${declared}". gkm dev and gkm build chose backends for "${declared}", so the two must agree — fix the package.`);
|
|
90
|
-
this.target = target;
|
|
91
|
-
this.packageName = packageName;
|
|
92
|
-
this.declared = declared;
|
|
93
|
-
this.actual = actual;
|
|
94
|
-
this.name = "TargetRuntimeMismatch";
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
/** Options a target's schema rejected. */
|
|
98
|
-
var InvalidTargetOptions = class extends Error {
|
|
99
|
-
target;
|
|
100
|
-
issues;
|
|
101
|
-
constructor(target, issues) {
|
|
102
|
-
const lines = issues.map((issue) => {
|
|
103
|
-
const path = (issue.path ?? []).map((segment) => typeof segment === "object" ? String(segment.key) : String(segment)).join(".");
|
|
104
|
-
return ` - ${path ? `${path}: ` : ""}${issue.message}`;
|
|
105
|
-
});
|
|
106
|
-
super(`The options for deploy target "${target}" are invalid — fix them in deploy.targets.${target} in gkm.config.ts:\n${lines.join("\n")}`);
|
|
107
|
-
this.target = target;
|
|
108
|
-
this.issues = issues;
|
|
109
|
-
this.name = "InvalidTargetOptions";
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
/** The built-ins `gkm deploy` deploys through, loaded only when used. */
|
|
113
|
-
const BUILTIN_LOADERS = { dokploy: async () => (await Promise.resolve().then(() => require("./dokploy-QJxMhxdf.cjs"))).dokployTarget };
|
|
114
|
-
/** The target `name` means, in this workspace, for this host. */
|
|
115
|
-
async function resolveTarget(name, { workspace, host, stage }) {
|
|
116
|
-
if (host && Object.hasOwn(host, name)) return {
|
|
117
|
-
name,
|
|
118
|
-
target: host[name],
|
|
119
|
-
source: "host",
|
|
120
|
-
options: void 0
|
|
121
|
-
};
|
|
122
|
-
const builtin = require_define.builtinTarget(name);
|
|
123
|
-
if (builtin) {
|
|
124
|
-
const load = BUILTIN_LOADERS[name];
|
|
125
|
-
if (builtin.status !== "available" || !load) throw new require_define.DeployTargetNotYetSupported(name, builtin.instead?.(stage));
|
|
126
|
-
return {
|
|
127
|
-
name,
|
|
128
|
-
target: await load(),
|
|
129
|
-
source: "builtin",
|
|
130
|
-
options: void 0
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
const entry = require_define.configuredTarget(workspace.deploy, name);
|
|
134
|
-
if (entry === void 0) throw new require_define.UnknownDeployTarget(name, [...require_define.configurableBuiltins(), ...Object.keys(workspace.deploy?.targets ?? {})]);
|
|
135
|
-
const [implementation, options] = Array.isArray(entry) ? entry : [entry, void 0];
|
|
136
|
-
if (typeof implementation === "string") {
|
|
137
|
-
const declared = require_runtime.declaredRuntime(name, implementation, workspace.root);
|
|
138
|
-
const target = (await require_runtime.importPackage(name, implementation, workspace.root)).default;
|
|
139
|
-
if (!require_define.isDeployTarget(target)) throw new TargetPackageInvalid(name, implementation);
|
|
140
|
-
if (target.runtime !== declared) throw new TargetRuntimeMismatch(name, implementation, declared, target.runtime);
|
|
141
|
-
return {
|
|
142
|
-
name,
|
|
143
|
-
target,
|
|
144
|
-
source: "config",
|
|
145
|
-
options
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
if (!require_define.isDeployTarget(implementation)) throw new TargetEntryInvalid(name);
|
|
149
|
-
return {
|
|
150
|
-
name,
|
|
151
|
-
target: implementation,
|
|
152
|
-
source: "config",
|
|
153
|
-
options
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
/** The target's options, parsed by its schema. */
|
|
157
|
-
async function parseTargetOptions(resolved) {
|
|
158
|
-
const { name, target, options } = resolved;
|
|
159
|
-
if (!target.options) {
|
|
160
|
-
if (options !== void 0) throw new InvalidTargetOptions(name, [{ message: "this target takes no options" }]);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const result = await target.options["~standard"].validate(options);
|
|
164
|
-
if (result.issues) throw new InvalidTargetOptions(name, result.issues);
|
|
165
|
-
return result.value;
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
Object.defineProperty(exports, "InvalidTargetOptions", {
|
|
169
|
-
enumerable: true,
|
|
170
|
-
get: function() {
|
|
171
|
-
return InvalidTargetOptions;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
Object.defineProperty(exports, "ProviderRemoved", {
|
|
175
|
-
enumerable: true,
|
|
176
|
-
get: function() {
|
|
177
|
-
return ProviderRemoved;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(exports, "TargetEntryInvalid", {
|
|
181
|
-
enumerable: true,
|
|
182
|
-
get: function() {
|
|
183
|
-
return TargetEntryInvalid;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
Object.defineProperty(exports, "TargetPackageInvalid", {
|
|
187
|
-
enumerable: true,
|
|
188
|
-
get: function() {
|
|
189
|
-
return TargetPackageInvalid;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
Object.defineProperty(exports, "TargetRuntimeMismatch", {
|
|
193
|
-
enumerable: true,
|
|
194
|
-
get: function() {
|
|
195
|
-
return TargetRuntimeMismatch;
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(exports, "parseTargetOptions", {
|
|
199
|
-
enumerable: true,
|
|
200
|
-
get: function() {
|
|
201
|
-
return parseTargetOptions;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
Object.defineProperty(exports, "resolveTarget", {
|
|
205
|
-
enumerable: true,
|
|
206
|
-
get: function() {
|
|
207
|
-
return resolveTarget;
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
Object.defineProperty(exports, "targetForProvider", {
|
|
211
|
-
enumerable: true,
|
|
212
|
-
get: function() {
|
|
213
|
-
return targetForProvider;
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
//# sourceMappingURL=resolve-xytBTtG4.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-xytBTtG4.cjs","names":["DeployTargetNotYetSupported","builtinTarget","DeployTargetNotYetSupported","configuredTarget","UnknownDeployTarget","configurableBuiltins","declaredRuntime","importPackage","isDeployTarget"],"sources":["../src/target/provider.ts","../src/target/resolve.ts"],"sourcesContent":["/**\n * `gkm deploy --provider`, from before there were targets.\n *\n * It named three things, and only one of them ever deployed a workspace:\n * `dokploy` is now the target of that name; `docker` and `aws-lambda` were\n * accepted and always failed, so they are gone with a pointer to what does\n * the job.\n */\n\nimport { DeployTargetNotYetSupported } from './builtins';\n\n/** What each removed provider's job is done with now. */\nconst REMOVED: Record<string, string> = {\n\tdocker:\n\t\t'Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`',\n\t'aws-lambda':\n\t\t\"Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm build && sst deploy --stage <stage>`\",\n};\n\n/** A `--provider` that no longer exists. */\nexport class ProviderRemoved extends Error {\n\tconstructor(\n\t\treadonly provider: string,\n\t\t/** What to use instead. */\n\t\treadonly instead: string,\n\t) {\n\t\tsuper(`--provider ${provider} has been removed. ${instead}.`);\n\t\tthis.name = 'ProviderRemoved';\n\t}\n}\n\n/** The deprecation `--provider` prints when it still means something. */\nexport function providerDeprecation(provider: string): string {\n\treturn `--provider is deprecated; use --target ${provider}.`;\n}\n\n/**\n * The target a `--provider` value means. `warn` hears the deprecation; a\n * provider that is gone, or a target not deployable yet, throws.\n */\nexport function targetForProvider(\n\tprovider: string,\n\twarn: (message: string) => void,\n): string {\n\tconst removed = REMOVED[provider];\n\tif (removed) throw new ProviderRemoved(provider, removed);\n\tif (provider === 'vercel' || provider === 'cloudflare') {\n\t\tthrow new DeployTargetNotYetSupported(provider);\n\t}\n\twarn(providerDeprecation(provider));\n\treturn provider;\n}\n","/**\n * From a target's name to the target.\n *\n * In this order, the first that has the name wins:\n *\n * 1. the host's own targets — what a program calling `deploy()` passes\n * 2. the built-ins — `dokploy`\n * 3. `deploy.targets` in gkm.config.ts — a package, an object, or either\n * with options\n *\n * Built-ins come before the config so that a dependency cannot take over\n * `dokploy` by being listed under its name. A name nothing has is\n * `UnknownDeployTarget`. There is deliberately no fourth step that guesses a\n * package from the name (`acme` → `@acme/gkm-target`): an npm scope nobody\n * has claimed can be claimed by anyone, and a deploy would then run their\n * code with the stage's credentials. A target is installed and named.\n */\n\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tDeployTargetNotYetSupported,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { isDeployTarget } from './define';\nimport { importPackage } from './package';\nimport { declaredRuntime } from './runtime';\nimport type {\n\tAnyDeployTarget,\n\tDeployRuntime,\n\tDeployTargetEntry,\n\tTargetOptionsIssue,\n} from './types';\n\n/** Where a target came from. */\nexport type TargetSourceKind = 'host' | 'builtin' | 'config';\n\nexport interface ResolvedTarget {\n\t/** The name it was asked for by. */\n\tname: string;\n\ttarget: AnyDeployTarget;\n\tsource: TargetSourceKind;\n\t/** Its options as written in the config, before its schema parsed them. */\n\toptions: unknown;\n}\n\nexport interface ResolveTargetOptions {\n\t/** The workspace whose `deploy.targets` is consulted. */\n\tworkspace: {\n\t\troot: string;\n\t\tdeploy?: { targets?: Record<string, DeployTargetEntry> } | undefined;\n\t};\n\t/** The host's targets, consulted first. */\n\thost?: Record<string, AnyDeployTarget>;\n\t/** The stage being deployed, for what to do instead of a refused target. */\n\tstage: string;\n}\n\n/** A target package whose default export is not a target. */\nexport class TargetPackageInvalid extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names \"${packageName}\", whose default export is not a deploy target. A target package exports one as default: export default defineTarget({ … }) from '@geekmidas/cli/target'.`,\n\t\t);\n\t\tthis.name = 'TargetPackageInvalid';\n\t}\n}\n\n/** A `deploy.targets` entry that is not a target, a package name or a pair. */\nexport class TargetEntryInvalid extends Error {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} must be a package name, a target object (defineTarget), or [package or target, options].`,\n\t\t);\n\t\tthis.name = 'TargetEntryInvalid';\n\t}\n}\n\n/** A target whose `runtime` is not the one its package declares. */\nexport class TargetRuntimeMismatch extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly declared: DeployRuntime,\n\t\treadonly actual: DeployRuntime,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" runs on \"${actual}\", but ${packageName}'s package.json declares gkm.runtime \"${declared}\". gkm dev and gkm build chose backends for \"${declared}\", so the two must agree — fix the package.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeMismatch';\n\t}\n}\n\n/** Options a target's schema rejected. */\nexport class InvalidTargetOptions extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly issues: readonly TargetOptionsIssue[],\n\t) {\n\t\tconst lines = issues.map((issue) => {\n\t\t\tconst path = (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\t\t\treturn ` - ${path ? `${path}: ` : ''}${issue.message}`;\n\t\t});\n\t\tsuper(\n\t\t\t`The options for deploy target \"${target}\" are invalid — fix them in deploy.targets.${target} in gkm.config.ts:\\n${lines.join('\\n')}`,\n\t\t);\n\t\tthis.name = 'InvalidTargetOptions';\n\t}\n}\n\n/** The built-ins `gkm deploy` deploys through, loaded only when used. */\nconst BUILTIN_LOADERS: Record<string, () => Promise<AnyDeployTarget>> = {\n\tdokploy: async () => (await import('./dokploy')).dokployTarget,\n};\n\n/** The target `name` means, in this workspace, for this host. */\nexport async function resolveTarget(\n\tname: string,\n\t{ workspace, host, stage }: ResolveTargetOptions,\n): Promise<ResolvedTarget> {\n\tif (host && Object.hasOwn(host, name)) {\n\t\treturn { name, target: host[name]!, source: 'host', options: undefined };\n\t}\n\n\tconst builtin = builtinTarget(name);\n\tif (builtin) {\n\t\tconst load = BUILTIN_LOADERS[name];\n\t\tif (builtin.status !== 'available' || !load) {\n\t\t\tthrow new DeployTargetNotYetSupported(name, builtin.instead?.(stage));\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\ttarget: await load(),\n\t\t\tsource: 'builtin',\n\t\t\toptions: undefined,\n\t\t};\n\t}\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst [implementation, options] = Array.isArray(entry)\n\t\t? (entry as readonly [unknown, unknown])\n\t\t: [entry, undefined];\n\n\tif (typeof implementation === 'string') {\n\t\t// Before the import: a package that does not say where it runs is\n\t\t// refused without running any of its code.\n\t\tconst declared = declaredRuntime(name, implementation, workspace.root);\n\t\tconst loaded = await importPackage(name, implementation, workspace.root);\n\t\tconst target = loaded.default;\n\t\tif (!isDeployTarget(target)) {\n\t\t\tthrow new TargetPackageInvalid(name, implementation);\n\t\t}\n\t\tif (target.runtime !== declared) {\n\t\t\tthrow new TargetRuntimeMismatch(\n\t\t\t\tname,\n\t\t\t\timplementation,\n\t\t\t\tdeclared,\n\t\t\t\ttarget.runtime,\n\t\t\t);\n\t\t}\n\t\treturn { name, target, source: 'config', options };\n\t}\n\n\tif (!isDeployTarget(implementation)) throw new TargetEntryInvalid(name);\n\treturn { name, target: implementation, source: 'config', options };\n}\n\n/** The target's options, parsed by its schema. */\nexport async function parseTargetOptions(\n\tresolved: ResolvedTarget,\n): Promise<unknown> {\n\tconst { name, target, options } = resolved;\n\tif (!target.options) {\n\t\tif (options !== undefined) {\n\t\t\tthrow new InvalidTargetOptions(name, [\n\t\t\t\t{ message: 'this target takes no options' },\n\t\t\t]);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst result = await target.options['~standard'].validate(options);\n\tif (result.issues) throw new InvalidTargetOptions(name, result.issues);\n\treturn result.value;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,UAAkC;CACvC,QACC;CACD,cACC;AACF;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CAEhC;CAEA;CAHV,YACC,UAEA,SACC;EACD,MAAM,cAAc,SAAS,qBAAqB,QAAQ,EAAE;EAJnD,KAAA,WAAA;EAEA,KAAA,UAAA;EAGT,KAAK,OAAO;CACb;AACD;;AAGA,SAAgB,oBAAoB,UAA0B;CAC7D,OAAO,0CAA0C,SAAS;AAC3D;;;;;AAMA,SAAgB,kBACf,UACA,MACS;CACT,MAAM,UAAU,QAAQ;CACxB,IAAI,SAAS,MAAM,IAAI,gBAAgB,UAAU,OAAO;CACxD,IAAI,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I;CACtE,OAAO;EAAE;EAAM,QAAQ;EAAgB,QAAQ;EAAU;CAAQ;AAClE;;AAGA,eAAsB,mBACrB,UACmB;CACnB,MAAM,EAAE,MAAM,QAAQ,YAAY;CAClC,IAAI,CAAC,OAAO,SAAS;EACpB,IAAI,YAAY,KAAA,GACf,MAAM,IAAI,qBAAqB,MAAM,CACpC,EAAE,SAAS,+BAA+B,CAC3C,CAAC;EAEF;CACD;CAEA,MAAM,SAAS,MAAM,OAAO,QAAQ,YAAY,CAAC,SAAS,OAAO;CACjE,IAAI,OAAO,QAAQ,MAAM,IAAI,qBAAqB,MAAM,OAAO,MAAM;CACrE,OAAO,OAAO;AACf"}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
const require_define = require("./define-Cv_QvDrg.cjs");
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
let node_url = require("node:url");
|
|
5
|
-
//#region src/target/package.ts
|
|
6
|
-
/**
|
|
7
|
-
* A target package, found the way the project would find it.
|
|
8
|
-
*
|
|
9
|
-
* From the workspace root, never from the CLI's own location or the process's
|
|
10
|
-
* working directory: the package is the project's dependency, and a CLI run
|
|
11
|
-
* through `pnpm dlx` — or a host deploying a checkout elsewhere — has neither
|
|
12
|
-
* in common with the project.
|
|
13
|
-
*/
|
|
14
|
-
/** A target package the project does not have installed. */
|
|
15
|
-
var TargetPackageNotFound = class extends Error {
|
|
16
|
-
target;
|
|
17
|
-
packageName;
|
|
18
|
-
from;
|
|
19
|
-
constructor(target, packageName, from) {
|
|
20
|
-
super(`deploy.targets.${target} names the package "${packageName}", which is not installed in ${from}. Add it to the workspace root: pnpm add -D ${packageName}`);
|
|
21
|
-
this.target = target;
|
|
22
|
-
this.packageName = packageName;
|
|
23
|
-
this.from = from;
|
|
24
|
-
this.name = "TargetPackageNotFound";
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* `name`'s directory and `package.json`, from the nearest `node_modules` at
|
|
29
|
-
* or above `from` — Node's own lookup, without the exports map getting in
|
|
30
|
-
* the way of reading `package.json`.
|
|
31
|
-
*/
|
|
32
|
-
function locatePackage(name, from) {
|
|
33
|
-
let dir = from;
|
|
34
|
-
while (true) {
|
|
35
|
-
const manifestPath = (0, node_path.join)(dir, "node_modules", name, "package.json");
|
|
36
|
-
if ((0, node_fs.existsSync)(manifestPath)) return {
|
|
37
|
-
dir: (0, node_fs.realpathSync)((0, node_path.dirname)(manifestPath)),
|
|
38
|
-
manifest: JSON.parse((0, node_fs.readFileSync)(manifestPath, "utf-8"))
|
|
39
|
-
};
|
|
40
|
-
const parent = (0, node_path.dirname)(dir);
|
|
41
|
-
if (parent === dir) return void 0;
|
|
42
|
-
dir = parent;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** The first file a conditions object leads to, as an `import` would. */
|
|
46
|
-
function pick(node) {
|
|
47
|
-
if (typeof node === "string") return node;
|
|
48
|
-
if (Array.isArray(node)) {
|
|
49
|
-
for (const option of node) {
|
|
50
|
-
const found = pick(option);
|
|
51
|
-
if (found) return found;
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (node && typeof node === "object") {
|
|
56
|
-
const conditions = node;
|
|
57
|
-
for (const condition of [
|
|
58
|
-
"import",
|
|
59
|
-
"node",
|
|
60
|
-
"default",
|
|
61
|
-
"require"
|
|
62
|
-
]) if (condition in conditions) {
|
|
63
|
-
const found = pick(conditions[condition]);
|
|
64
|
-
if (found) return found;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/** The file `import(name)` loads, relative to the package directory. */
|
|
69
|
-
function packageEntry(manifest) {
|
|
70
|
-
const { exports } = manifest;
|
|
71
|
-
let root = exports;
|
|
72
|
-
if (exports && typeof exports === "object" && !Array.isArray(exports)) {
|
|
73
|
-
if (Object.keys(exports).some((key) => key.startsWith("."))) root = exports["."];
|
|
74
|
-
}
|
|
75
|
-
return pick(root) ?? manifest.module ?? manifest.main ?? "index.js";
|
|
76
|
-
}
|
|
77
|
-
/** The module `name` is, imported from where the project would import it. */
|
|
78
|
-
async function importPackage(target, name, from) {
|
|
79
|
-
const located = locatePackage(name, from);
|
|
80
|
-
if (!located) throw new TargetPackageNotFound(target, name, from);
|
|
81
|
-
const entry = (0, node_path.join)(located.dir, packageEntry(located.manifest));
|
|
82
|
-
return await import((0, node_url.pathToFileURL)(entry).href);
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/target/runtime.ts
|
|
86
|
-
/**
|
|
87
|
-
* A target's runtime, without loading the target.
|
|
88
|
-
*
|
|
89
|
-
* `gkm dev` and `gkm build` choose a project's backends by it on every start,
|
|
90
|
-
* synchronously, and must not import a deploy plugin to do so — a plugin may
|
|
91
|
-
* pull in a cloud SDK, and a broken one would stop `gkm dev` for a project
|
|
92
|
-
* that is only being developed. So a built-in's runtime is in the table, an
|
|
93
|
-
* inline target carries its own, and a package declares it in its
|
|
94
|
-
* `package.json`:
|
|
95
|
-
*
|
|
96
|
-
* ```json
|
|
97
|
-
* { "name": "@acme/gkm-target", "gkm": { "runtime": "server" } }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
const RUNTIMES = ["server", "aws"];
|
|
101
|
-
/** A target package whose `package.json` does not say where it runs. */
|
|
102
|
-
var TargetRuntimeUndeclared = class extends Error {
|
|
103
|
-
target;
|
|
104
|
-
packageName;
|
|
105
|
-
found;
|
|
106
|
-
constructor(target, packageName, found) {
|
|
107
|
-
super(`The deploy target "${target}" (${packageName}) does not declare its runtime${found === void 0 ? "" : ` (gkm.runtime is ${JSON.stringify(found)})`}. Its package.json needs "gkm": { "runtime": "server" } or "aws", so gkm dev and gkm build can choose backends without loading it.`);
|
|
108
|
-
this.target = target;
|
|
109
|
-
this.packageName = packageName;
|
|
110
|
-
this.found = found;
|
|
111
|
-
this.name = "TargetRuntimeUndeclared";
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
/** The runtime a target package declares in `package.json#gkm.runtime`. */
|
|
115
|
-
function declaredRuntime(target, packageName, root) {
|
|
116
|
-
const located = root ? locatePackage(packageName, root) : void 0;
|
|
117
|
-
if (!located) throw new TargetPackageNotFound(target, packageName, root ?? "the workspace");
|
|
118
|
-
const runtime = located.manifest.gkm?.runtime;
|
|
119
|
-
if (!RUNTIMES.includes(runtime)) throw new TargetRuntimeUndeclared(target, packageName, runtime);
|
|
120
|
-
return runtime;
|
|
121
|
-
}
|
|
122
|
-
/** The runtime of the target `name`, as the workspace resolves it. */
|
|
123
|
-
function runtimeOf(name, workspace) {
|
|
124
|
-
const builtin = require_define.builtinTarget(name);
|
|
125
|
-
if (builtin) return builtin.runtime;
|
|
126
|
-
const entry = require_define.configuredTarget(workspace.deploy, name);
|
|
127
|
-
if (entry === void 0) throw new require_define.UnknownDeployTarget(name, [...require_define.configurableBuiltins(), ...Object.keys(workspace.deploy?.targets ?? {})]);
|
|
128
|
-
const implementation = Array.isArray(entry) ? entry[0] : entry;
|
|
129
|
-
return typeof implementation === "string" ? declaredRuntime(name, implementation, workspace.root) : implementation.runtime;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
Object.defineProperty(exports, "TargetPackageNotFound", {
|
|
133
|
-
enumerable: true,
|
|
134
|
-
get: function() {
|
|
135
|
-
return TargetPackageNotFound;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
Object.defineProperty(exports, "TargetRuntimeUndeclared", {
|
|
139
|
-
enumerable: true,
|
|
140
|
-
get: function() {
|
|
141
|
-
return TargetRuntimeUndeclared;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(exports, "declaredRuntime", {
|
|
145
|
-
enumerable: true,
|
|
146
|
-
get: function() {
|
|
147
|
-
return declaredRuntime;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
Object.defineProperty(exports, "importPackage", {
|
|
151
|
-
enumerable: true,
|
|
152
|
-
get: function() {
|
|
153
|
-
return importPackage;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
Object.defineProperty(exports, "runtimeOf", {
|
|
157
|
-
enumerable: true,
|
|
158
|
-
get: function() {
|
|
159
|
-
return runtimeOf;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
//# sourceMappingURL=runtime-CMwtq0AL.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-CMwtq0AL.cjs","names":["join","existsSync","realpathSync","dirname","readFileSync","pathToFileURL","builtinTarget","configuredTarget","UnknownDeployTarget","configurableBuiltins"],"sources":["../src/target/package.ts","../src/target/runtime.ts"],"sourcesContent":["/**\n * A target package, found the way the project would find it.\n *\n * From the workspace root, never from the CLI's own location or the process's\n * working directory: the package is the project's dependency, and a CLI run\n * through `pnpm dlx` — or a host deploying a checkout elsewhere — has neither\n * in common with the project.\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nexport interface TargetPackageManifest {\n\tname?: string;\n\tmain?: string;\n\tmodule?: string;\n\texports?: unknown;\n\tgkm?: { runtime?: unknown };\n}\n\nexport interface LocatedPackage {\n\t/** The package's directory, symlinks resolved. */\n\tdir: string;\n\tmanifest: TargetPackageManifest;\n}\n\n/** A target package the project does not have installed. */\nexport class TargetPackageNotFound extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly from: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names the package \"${packageName}\", which is not installed in ${from}. Add it to the workspace root: pnpm add -D ${packageName}`,\n\t\t);\n\t\tthis.name = 'TargetPackageNotFound';\n\t}\n}\n\n/**\n * `name`'s directory and `package.json`, from the nearest `node_modules` at\n * or above `from` — Node's own lookup, without the exports map getting in\n * the way of reading `package.json`.\n */\nexport function locatePackage(\n\tname: string,\n\tfrom: string,\n): LocatedPackage | undefined {\n\tlet dir = from;\n\twhile (true) {\n\t\tconst manifestPath = join(dir, 'node_modules', name, 'package.json');\n\t\tif (existsSync(manifestPath)) {\n\t\t\treturn {\n\t\t\t\tdir: realpathSync(dirname(manifestPath)),\n\t\t\t\tmanifest: JSON.parse(\n\t\t\t\t\treadFileSync(manifestPath, 'utf-8'),\n\t\t\t\t) as TargetPackageManifest,\n\t\t\t};\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n}\n\n/** The first file a conditions object leads to, as an `import` would. */\nfunction pick(node: unknown): string | undefined {\n\tif (typeof node === 'string') return node;\n\tif (Array.isArray(node)) {\n\t\tfor (const option of node) {\n\t\t\tconst found = pick(option);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (node && typeof node === 'object') {\n\t\tconst conditions = node as Record<string, unknown>;\n\t\tfor (const condition of ['import', 'node', 'default', 'require']) {\n\t\t\tif (condition in conditions) {\n\t\t\t\tconst found = pick(conditions[condition]);\n\t\t\t\tif (found) return found;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** The file `import(name)` loads, relative to the package directory. */\nexport function packageEntry(manifest: TargetPackageManifest): string {\n\tconst { exports } = manifest;\n\tlet root: unknown = exports;\n\tif (exports && typeof exports === 'object' && !Array.isArray(exports)) {\n\t\tconst keys = Object.keys(exports);\n\t\t// A subpath map — `{ \".\": …, \"./x\": … }` — rather than one conditions\n\t\t// object for the root.\n\t\tif (keys.some((key) => key.startsWith('.'))) {\n\t\t\troot = (exports as Record<string, unknown>)['.'];\n\t\t}\n\t}\n\treturn pick(root) ?? manifest.module ?? manifest.main ?? 'index.js';\n}\n\n/** The module `name` is, imported from where the project would import it. */\nexport async function importPackage(\n\ttarget: string,\n\tname: string,\n\tfrom: string,\n): Promise<Record<string, unknown>> {\n\tconst located = locatePackage(name, from);\n\tif (!located) throw new TargetPackageNotFound(target, name, from);\n\n\tconst entry = join(located.dir, packageEntry(located.manifest));\n\treturn (await import(pathToFileURL(entry).href)) as Record<string, unknown>;\n}\n","/**\n * A target's runtime, without loading the target.\n *\n * `gkm dev` and `gkm build` choose a project's backends by it on every start,\n * synchronously, and must not import a deploy plugin to do so — a plugin may\n * pull in a cloud SDK, and a broken one would stop `gkm dev` for a project\n * that is only being developed. So a built-in's runtime is in the table, an\n * inline target carries its own, and a package declares it in its\n * `package.json`:\n *\n * ```json\n * { \"name\": \"@acme/gkm-target\", \"gkm\": { \"runtime\": \"server\" } }\n * ```\n */\n\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { locatePackage, TargetPackageNotFound } from './package';\nimport type { DeployRuntime, DeployTargetEntry } from './types';\n\nconst RUNTIMES: readonly DeployRuntime[] = ['server', 'aws'];\n\n/** A target package whose `package.json` does not say where it runs. */\nexport class TargetRuntimeUndeclared extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\t/** What `gkm.runtime` held instead, when it held anything. */\n\t\treadonly found?: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" (${packageName}) does not declare its runtime${found === undefined ? '' : ` (gkm.runtime is ${JSON.stringify(found)})`}. Its package.json needs \"gkm\": { \"runtime\": \"server\" } or \"aws\", so gkm dev and gkm build can choose backends without loading it.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeUndeclared';\n\t}\n}\n\n/** What a workspace's deploy config is read for here. */\nexport interface TargetSource {\n\t/** Where the target packages are installed from. */\n\troot?: string;\n\tdeploy?:\n\t\t| { default?: string; targets?: Record<string, DeployTargetEntry> }\n\t\t| undefined;\n}\n\n/** The runtime a target package declares in `package.json#gkm.runtime`. */\nexport function declaredRuntime(\n\ttarget: string,\n\tpackageName: string,\n\troot: string | undefined,\n): DeployRuntime {\n\tconst located = root ? locatePackage(packageName, root) : undefined;\n\tif (!located) {\n\t\tthrow new TargetPackageNotFound(\n\t\t\ttarget,\n\t\t\tpackageName,\n\t\t\troot ?? 'the workspace',\n\t\t);\n\t}\n\tconst runtime = located.manifest.gkm?.runtime;\n\tif (!RUNTIMES.includes(runtime as DeployRuntime)) {\n\t\tthrow new TargetRuntimeUndeclared(target, packageName, runtime);\n\t}\n\treturn runtime as DeployRuntime;\n}\n\n/** The runtime of the target `name`, as the workspace resolves it. */\nexport function runtimeOf(\n\tname: string,\n\tworkspace: TargetSource,\n): DeployRuntime {\n\tconst builtin = builtinTarget(name);\n\tif (builtin) return builtin.runtime;\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst implementation = Array.isArray(entry) ? entry[0] : entry;\n\treturn typeof implementation === 'string'\n\t\t? declaredRuntime(name, implementation, workspace.root)\n\t\t: (implementation as { runtime: DeployRuntime }).runtime;\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CACA;CAHV,YACC,QACA,aACA,MACC;EACD,MACC,kBAAkB,OAAO,sBAAsB,YAAY,+BAA+B,KAAK,8CAA8C,aAC9I;EANS,KAAA,SAAA;EACA,KAAA,cAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD;;;;;;AAOA,SAAgB,cACf,MACA,MAC6B;CAC7B,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,gBAAA,GAAeA,UAAAA,KAAAA,CAAK,KAAK,gBAAgB,MAAM,cAAc;EACnE,KAAA,GAAIC,QAAAA,WAAAA,CAAW,YAAY,GAC1B,OAAO;GACN,MAAA,GAAKC,QAAAA,aAAAA,EAAAA,GAAaC,UAAAA,QAAAA,CAAQ,YAAY,CAAC;GACvC,UAAU,KAAK,OAAA,GACdC,QAAAA,aAAAA,CAAa,c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,cAA6C,MAAM;CAExC;CACA;CAEA;CAJV,YACC,QACA,aAEA,OACC;EACD,MACC,sBAAsB,OAAO,KAAK,YAAY,gCAAgC,UAAU,KAAA,IAAY,KAAK,oBAAoB,KAAK,UAAU,KAAK,EAAE,GAAG,mIACvJ;EAPS,KAAA,SAAA;EACA,KAAA,cAAA;EAEA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;;AAYA,SAAgB,gBACf,QACA,aACA,MACgB;CAChB,MAAM,UAAU,OAAO,cAAc,aAAa,IAAI,IAAI,KAAA;CAC1D,IAAI,CAAC,SACJ,MAAM,IAAI,sBACT,QACA,aACA,QAAQ,eACT;CAED,MAAM,UAAU,QAAQ,SAAS,KAAK;CACtC,IAAI,CAAC,SAAS,SAAS,OAAwB,GAC9C,MAAM,IAAI,wBAAwB,QAAQ,aAAa,OAAO;CAE/D,OAAO;AACR;;AAGA,SAAgB,UACf,MACA,WACgB;CAChB,MAAM,UAAUC,eAAAA,cAAc,IAAI;CAClC,IAAI,SAAS,OAAO,QAAQ;CAE5B,MAAM,QAAQC,eAAAA,iBAAiB,UAAU,QAAQ,IAAI;CACrD,IAAI,UAAU,KAAA,GACb,MAAM,IAAIC,eAAAA,oBAAoB,MAAM,CACnC,GAAGC,eAAAA,qBAAqB,GACxB,GAAG,OAAO,KAAK,UAAU,QAAQ,WAAW,CAAC,CAAC,CAC/C,CAAC;CAGF,MAAM,iBAAiB,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;CACzD,OAAO,OAAO,mBAAmB,WAC9B,gBAAgB,MAAM,gBAAgB,UAAU,IAAI,IACnD,eAA8C;AACnD"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { a as UnknownDeployTarget, c as configuredTarget, o as builtinTarget, s as configurableBuiltins } from "./define-CHBIEc5j.mjs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
//#region src/target/package.ts
|
|
6
|
-
/**
|
|
7
|
-
* A target package, found the way the project would find it.
|
|
8
|
-
*
|
|
9
|
-
* From the workspace root, never from the CLI's own location or the process's
|
|
10
|
-
* working directory: the package is the project's dependency, and a CLI run
|
|
11
|
-
* through `pnpm dlx` — or a host deploying a checkout elsewhere — has neither
|
|
12
|
-
* in common with the project.
|
|
13
|
-
*/
|
|
14
|
-
/** A target package the project does not have installed. */
|
|
15
|
-
var TargetPackageNotFound = class extends Error {
|
|
16
|
-
target;
|
|
17
|
-
packageName;
|
|
18
|
-
from;
|
|
19
|
-
constructor(target, packageName, from) {
|
|
20
|
-
super(`deploy.targets.${target} names the package "${packageName}", which is not installed in ${from}. Add it to the workspace root: pnpm add -D ${packageName}`);
|
|
21
|
-
this.target = target;
|
|
22
|
-
this.packageName = packageName;
|
|
23
|
-
this.from = from;
|
|
24
|
-
this.name = "TargetPackageNotFound";
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* `name`'s directory and `package.json`, from the nearest `node_modules` at
|
|
29
|
-
* or above `from` — Node's own lookup, without the exports map getting in
|
|
30
|
-
* the way of reading `package.json`.
|
|
31
|
-
*/
|
|
32
|
-
function locatePackage(name, from) {
|
|
33
|
-
let dir = from;
|
|
34
|
-
while (true) {
|
|
35
|
-
const manifestPath = join(dir, "node_modules", name, "package.json");
|
|
36
|
-
if (existsSync(manifestPath)) return {
|
|
37
|
-
dir: realpathSync(dirname(manifestPath)),
|
|
38
|
-
manifest: JSON.parse(readFileSync(manifestPath, "utf-8"))
|
|
39
|
-
};
|
|
40
|
-
const parent = dirname(dir);
|
|
41
|
-
if (parent === dir) return void 0;
|
|
42
|
-
dir = parent;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** The first file a conditions object leads to, as an `import` would. */
|
|
46
|
-
function pick(node) {
|
|
47
|
-
if (typeof node === "string") return node;
|
|
48
|
-
if (Array.isArray(node)) {
|
|
49
|
-
for (const option of node) {
|
|
50
|
-
const found = pick(option);
|
|
51
|
-
if (found) return found;
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (node && typeof node === "object") {
|
|
56
|
-
const conditions = node;
|
|
57
|
-
for (const condition of [
|
|
58
|
-
"import",
|
|
59
|
-
"node",
|
|
60
|
-
"default",
|
|
61
|
-
"require"
|
|
62
|
-
]) if (condition in conditions) {
|
|
63
|
-
const found = pick(conditions[condition]);
|
|
64
|
-
if (found) return found;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/** The file `import(name)` loads, relative to the package directory. */
|
|
69
|
-
function packageEntry(manifest) {
|
|
70
|
-
const { exports } = manifest;
|
|
71
|
-
let root = exports;
|
|
72
|
-
if (exports && typeof exports === "object" && !Array.isArray(exports)) {
|
|
73
|
-
if (Object.keys(exports).some((key) => key.startsWith("."))) root = exports["."];
|
|
74
|
-
}
|
|
75
|
-
return pick(root) ?? manifest.module ?? manifest.main ?? "index.js";
|
|
76
|
-
}
|
|
77
|
-
/** The module `name` is, imported from where the project would import it. */
|
|
78
|
-
async function importPackage(target, name, from) {
|
|
79
|
-
const located = locatePackage(name, from);
|
|
80
|
-
if (!located) throw new TargetPackageNotFound(target, name, from);
|
|
81
|
-
const entry = join(located.dir, packageEntry(located.manifest));
|
|
82
|
-
return await import(pathToFileURL(entry).href);
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/target/runtime.ts
|
|
86
|
-
/**
|
|
87
|
-
* A target's runtime, without loading the target.
|
|
88
|
-
*
|
|
89
|
-
* `gkm dev` and `gkm build` choose a project's backends by it on every start,
|
|
90
|
-
* synchronously, and must not import a deploy plugin to do so — a plugin may
|
|
91
|
-
* pull in a cloud SDK, and a broken one would stop `gkm dev` for a project
|
|
92
|
-
* that is only being developed. So a built-in's runtime is in the table, an
|
|
93
|
-
* inline target carries its own, and a package declares it in its
|
|
94
|
-
* `package.json`:
|
|
95
|
-
*
|
|
96
|
-
* ```json
|
|
97
|
-
* { "name": "@acme/gkm-target", "gkm": { "runtime": "server" } }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
const RUNTIMES = ["server", "aws"];
|
|
101
|
-
/** A target package whose `package.json` does not say where it runs. */
|
|
102
|
-
var TargetRuntimeUndeclared = class extends Error {
|
|
103
|
-
target;
|
|
104
|
-
packageName;
|
|
105
|
-
found;
|
|
106
|
-
constructor(target, packageName, found) {
|
|
107
|
-
super(`The deploy target "${target}" (${packageName}) does not declare its runtime${found === void 0 ? "" : ` (gkm.runtime is ${JSON.stringify(found)})`}. Its package.json needs "gkm": { "runtime": "server" } or "aws", so gkm dev and gkm build can choose backends without loading it.`);
|
|
108
|
-
this.target = target;
|
|
109
|
-
this.packageName = packageName;
|
|
110
|
-
this.found = found;
|
|
111
|
-
this.name = "TargetRuntimeUndeclared";
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
/** The runtime a target package declares in `package.json#gkm.runtime`. */
|
|
115
|
-
function declaredRuntime(target, packageName, root) {
|
|
116
|
-
const located = root ? locatePackage(packageName, root) : void 0;
|
|
117
|
-
if (!located) throw new TargetPackageNotFound(target, packageName, root ?? "the workspace");
|
|
118
|
-
const runtime = located.manifest.gkm?.runtime;
|
|
119
|
-
if (!RUNTIMES.includes(runtime)) throw new TargetRuntimeUndeclared(target, packageName, runtime);
|
|
120
|
-
return runtime;
|
|
121
|
-
}
|
|
122
|
-
/** The runtime of the target `name`, as the workspace resolves it. */
|
|
123
|
-
function runtimeOf(name, workspace) {
|
|
124
|
-
const builtin = builtinTarget(name);
|
|
125
|
-
if (builtin) return builtin.runtime;
|
|
126
|
-
const entry = configuredTarget(workspace.deploy, name);
|
|
127
|
-
if (entry === void 0) throw new UnknownDeployTarget(name, [...configurableBuiltins(), ...Object.keys(workspace.deploy?.targets ?? {})]);
|
|
128
|
-
const implementation = Array.isArray(entry) ? entry[0] : entry;
|
|
129
|
-
return typeof implementation === "string" ? declaredRuntime(name, implementation, workspace.root) : implementation.runtime;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
export { importPackage as a, TargetPackageNotFound as i, declaredRuntime as n, runtimeOf as r, TargetRuntimeUndeclared as t };
|
|
133
|
-
|
|
134
|
-
//# sourceMappingURL=runtime-DbakJS8u.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-DbakJS8u.mjs","names":[],"sources":["../src/target/package.ts","../src/target/runtime.ts"],"sourcesContent":["/**\n * A target package, found the way the project would find it.\n *\n * From the workspace root, never from the CLI's own location or the process's\n * working directory: the package is the project's dependency, and a CLI run\n * through `pnpm dlx` — or a host deploying a checkout elsewhere — has neither\n * in common with the project.\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nexport interface TargetPackageManifest {\n\tname?: string;\n\tmain?: string;\n\tmodule?: string;\n\texports?: unknown;\n\tgkm?: { runtime?: unknown };\n}\n\nexport interface LocatedPackage {\n\t/** The package's directory, symlinks resolved. */\n\tdir: string;\n\tmanifest: TargetPackageManifest;\n}\n\n/** A target package the project does not have installed. */\nexport class TargetPackageNotFound extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly from: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names the package \"${packageName}\", which is not installed in ${from}. Add it to the workspace root: pnpm add -D ${packageName}`,\n\t\t);\n\t\tthis.name = 'TargetPackageNotFound';\n\t}\n}\n\n/**\n * `name`'s directory and `package.json`, from the nearest `node_modules` at\n * or above `from` — Node's own lookup, without the exports map getting in\n * the way of reading `package.json`.\n */\nexport function locatePackage(\n\tname: string,\n\tfrom: string,\n): LocatedPackage | undefined {\n\tlet dir = from;\n\twhile (true) {\n\t\tconst manifestPath = join(dir, 'node_modules', name, 'package.json');\n\t\tif (existsSync(manifestPath)) {\n\t\t\treturn {\n\t\t\t\tdir: realpathSync(dirname(manifestPath)),\n\t\t\t\tmanifest: JSON.parse(\n\t\t\t\t\treadFileSync(manifestPath, 'utf-8'),\n\t\t\t\t) as TargetPackageManifest,\n\t\t\t};\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n}\n\n/** The first file a conditions object leads to, as an `import` would. */\nfunction pick(node: unknown): string | undefined {\n\tif (typeof node === 'string') return node;\n\tif (Array.isArray(node)) {\n\t\tfor (const option of node) {\n\t\t\tconst found = pick(option);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (node && typeof node === 'object') {\n\t\tconst conditions = node as Record<string, unknown>;\n\t\tfor (const condition of ['import', 'node', 'default', 'require']) {\n\t\t\tif (condition in conditions) {\n\t\t\t\tconst found = pick(conditions[condition]);\n\t\t\t\tif (found) return found;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** The file `import(name)` loads, relative to the package directory. */\nexport function packageEntry(manifest: TargetPackageManifest): string {\n\tconst { exports } = manifest;\n\tlet root: unknown = exports;\n\tif (exports && typeof exports === 'object' && !Array.isArray(exports)) {\n\t\tconst keys = Object.keys(exports);\n\t\t// A subpath map — `{ \".\": …, \"./x\": … }` — rather than one conditions\n\t\t// object for the root.\n\t\tif (keys.some((key) => key.startsWith('.'))) {\n\t\t\troot = (exports as Record<string, unknown>)['.'];\n\t\t}\n\t}\n\treturn pick(root) ?? manifest.module ?? manifest.main ?? 'index.js';\n}\n\n/** The module `name` is, imported from where the project would import it. */\nexport async function importPackage(\n\ttarget: string,\n\tname: string,\n\tfrom: string,\n): Promise<Record<string, unknown>> {\n\tconst located = locatePackage(name, from);\n\tif (!located) throw new TargetPackageNotFound(target, name, from);\n\n\tconst entry = join(located.dir, packageEntry(located.manifest));\n\treturn (await import(pathToFileURL(entry).href)) as Record<string, unknown>;\n}\n","/**\n * A target's runtime, without loading the target.\n *\n * `gkm dev` and `gkm build` choose a project's backends by it on every start,\n * synchronously, and must not import a deploy plugin to do so — a plugin may\n * pull in a cloud SDK, and a broken one would stop `gkm dev` for a project\n * that is only being developed. So a built-in's runtime is in the table, an\n * inline target carries its own, and a package declares it in its\n * `package.json`:\n *\n * ```json\n * { \"name\": \"@acme/gkm-target\", \"gkm\": { \"runtime\": \"server\" } }\n * ```\n */\n\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { locatePackage, TargetPackageNotFound } from './package';\nimport type { DeployRuntime, DeployTargetEntry } from './types';\n\nconst RUNTIMES: readonly DeployRuntime[] = ['server', 'aws'];\n\n/** A target package whose `package.json` does not say where it runs. */\nexport class TargetRuntimeUndeclared extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\t/** What `gkm.runtime` held instead, when it held anything. */\n\t\treadonly found?: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" (${packageName}) does not declare its runtime${found === undefined ? '' : ` (gkm.runtime is ${JSON.stringify(found)})`}. Its package.json needs \"gkm\": { \"runtime\": \"server\" } or \"aws\", so gkm dev and gkm build can choose backends without loading it.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeUndeclared';\n\t}\n}\n\n/** What a workspace's deploy config is read for here. */\nexport interface TargetSource {\n\t/** Where the target packages are installed from. */\n\troot?: string;\n\tdeploy?:\n\t\t| { default?: string; targets?: Record<string, DeployTargetEntry> }\n\t\t| undefined;\n}\n\n/** The runtime a target package declares in `package.json#gkm.runtime`. */\nexport function declaredRuntime(\n\ttarget: string,\n\tpackageName: string,\n\troot: string | undefined,\n): DeployRuntime {\n\tconst located = root ? locatePackage(packageName, root) : undefined;\n\tif (!located) {\n\t\tthrow new TargetPackageNotFound(\n\t\t\ttarget,\n\t\t\tpackageName,\n\t\t\troot ?? 'the workspace',\n\t\t);\n\t}\n\tconst runtime = located.manifest.gkm?.runtime;\n\tif (!RUNTIMES.includes(runtime as DeployRuntime)) {\n\t\tthrow new TargetRuntimeUndeclared(target, packageName, runtime);\n\t}\n\treturn runtime as DeployRuntime;\n}\n\n/** The runtime of the target `name`, as the workspace resolves it. */\nexport function runtimeOf(\n\tname: string,\n\tworkspace: TargetSource,\n): DeployRuntime {\n\tconst builtin = builtinTarget(name);\n\tif (builtin) return builtin.runtime;\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst implementation = Array.isArray(entry) ? entry[0] : entry;\n\treturn typeof implementation === 'string'\n\t\t? declaredRuntime(name, implementation, workspace.root)\n\t\t: (implementation as { runtime: DeployRuntime }).runtime;\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CACA;CAHV,YACC,QACA,aACA,MACC;EACD,MACC,kBAAkB,OAAO,sBAAsB,YAAY,+BAA+B,KAAK,8CAA8C,aAC9I;EANS,KAAA,SAAA;EACA,KAAA,cAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD;;;;;;AAOA,SAAgB,cACf,MACA,MAC6B;CAC7B,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,eAAe,KAAK,KAAK,gBAAgB,MAAM,cAAc;EACnE,IAAI,WAAW,YAAY,GAC1B,OAAO;GACN,KAAK,aAAa,QAAQ,YAAY,CAAC;GACvC,UAAU,KAAK,MACd,aAAa,cAAc,OAAO,CACnC;EACD;EAED,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO,KAAA;EAC3B,MAAM;CACP;AACD;;AAGA,SAAS,KAAK,MAAmC;CAChD,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,MAAM,QAAQ,IAAI,GAAG;EACxB,KAA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