@geekmidas/cli 10.0.0-alpha.125 → 10.0.0-alpha.126
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/dist/{GoDaddyProvider-BN1dODm9.mjs → GoDaddyProvider-CvRVmN4W.mjs} +2 -2
- package/dist/{GoDaddyProvider-BN1dODm9.mjs.map → GoDaddyProvider-CvRVmN4W.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-BTdtqhI_.cjs → GoDaddyProvider-DFfpzCOP.cjs} +2 -2
- package/dist/{GoDaddyProvider-BTdtqhI_.cjs.map → GoDaddyProvider-DFfpzCOP.cjs.map} +1 -1
- package/dist/{LegacyStateStore-C2S8TGwx.cjs → LegacyStateStore-BFrCHrFQ.cjs} +3 -3
- package/dist/{LegacyStateStore-C2S8TGwx.cjs.map → LegacyStateStore-BFrCHrFQ.cjs.map} +1 -1
- package/dist/{LegacyStateStore-DgXmuG87.mjs → LegacyStateStore-CgfENrXF.mjs} +3 -3
- package/dist/{LegacyStateStore-DgXmuG87.mjs.map → LegacyStateStore-CgfENrXF.mjs.map} +1 -1
- package/dist/{LocalStateStore-CaJw9H-3.cjs → LocalStateStore-BU5z_IOE.cjs} +2 -2
- package/dist/{LocalStateStore-CaJw9H-3.cjs.map → LocalStateStore-BU5z_IOE.cjs.map} +1 -1
- package/dist/{LocalStateStore-ojY_BiMK.mjs → LocalStateStore-DxoNpiBg.mjs} +2 -2
- package/dist/{LocalStateStore-ojY_BiMK.mjs.map → LocalStateStore-DxoNpiBg.mjs.map} +1 -1
- package/dist/{S3StateStore-BSPkxhrx.mjs → S3StateStore-CGMSDilh.mjs} +2 -2
- package/dist/{S3StateStore-BSPkxhrx.mjs.map → S3StateStore-CGMSDilh.mjs.map} +1 -1
- package/dist/{S3StateStore-BqugXIcb.cjs → S3StateStore-DiekMLpn.cjs} +2 -2
- package/dist/{S3StateStore-BqugXIcb.cjs.map → S3StateStore-DiekMLpn.cjs.map} +1 -1
- package/dist/{SSMStateStore-B0OsuT_k.cjs → SSMStateStore-BDCOFdKq.cjs} +2 -2
- package/dist/{SSMStateStore-B0OsuT_k.cjs.map → SSMStateStore-BDCOFdKq.cjs.map} +1 -1
- package/dist/{SSMStateStore-DM85OiH0.mjs → SSMStateStore-Cq2H9MlF.mjs} +2 -2
- package/dist/{SSMStateStore-DM85OiH0.mjs.map → SSMStateStore-Cq2H9MlF.mjs.map} +1 -1
- package/dist/{SubscriberGenerator-ocQ2yj0K.mjs → SubscriberGenerator-BALddfuW.mjs} +2 -60
- package/dist/SubscriberGenerator-BALddfuW.mjs.map +1 -0
- package/dist/{SubscriberGenerator-BDUp7OeY.cjs → SubscriberGenerator-LgyTxZ8r.cjs} +1 -89
- package/dist/SubscriberGenerator-LgyTxZ8r.cjs.map +1 -0
- package/dist/{add-CrxvmSpq.cjs → add-BsiBYkAW.cjs} +3 -3
- package/dist/{add-CrxvmSpq.cjs.map → add-BsiBYkAW.cjs.map} +1 -1
- package/dist/{add-C7ZBXIzM.mjs → add-CamA9Uqv.mjs} +3 -3
- package/dist/{add-C7ZBXIzM.mjs.map → add-CamA9Uqv.mjs.map} +1 -1
- package/dist/{bundler-DpZ9uBGN.mjs → bundler-2V2PR_E-.mjs} +5 -5
- package/dist/{bundler-DpZ9uBGN.mjs.map → bundler-2V2PR_E-.mjs.map} +1 -1
- package/dist/{bundler-DVUXW95p.cjs → bundler-CijtdIZ2.cjs} +5 -5
- package/dist/{bundler-DVUXW95p.cjs.map → bundler-CijtdIZ2.cjs.map} +1 -1
- package/dist/{cli-BMRhE6cZ.cjs → cli-7gc1QG8X.cjs} +2 -2
- package/dist/{cli-BMRhE6cZ.cjs.map → cli-7gc1QG8X.cjs.map} +1 -1
- package/dist/{cli-BWfYyy1k.mjs → cli-PiyYqHGx.mjs} +2 -2
- package/dist/{cli-BWfYyy1k.mjs.map → cli-PiyYqHGx.mjs.map} +1 -1
- package/dist/{compose-Bqcy0lqo.cjs → compose-8e2xJ61E.cjs} +9 -8
- package/dist/compose-8e2xJ61E.cjs.map +1 -0
- package/dist/{compose-BFmdLig3.mjs → compose-CvHIjMDd.mjs} +8 -7
- package/dist/{compose-BFmdLig3.mjs.map → compose-CvHIjMDd.mjs.map} +1 -1
- package/dist/{databases-BPOgTn1u.mjs → databases-6GD0tI2F.mjs} +65 -3
- package/dist/databases-6GD0tI2F.mjs.map +1 -0
- package/dist/{databases-fOaoBInm.cjs → databases-CuVGf7-M.cjs} +75 -1
- package/dist/databases-CuVGf7-M.cjs.map +1 -0
- package/dist/deploy/public.cjs +6 -6
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +6 -6
- package/dist/{deploy-D8pUA9Y0.mjs → deploy-CIPwTJ47.mjs} +6 -6
- package/dist/{deploy-D8pUA9Y0.mjs.map → deploy-CIPwTJ47.mjs.map} +1 -1
- package/dist/{deploy-DVrNjX1X.cjs → deploy-wSlIRPn5.cjs} +6 -6
- package/dist/{deploy-DVrNjX1X.cjs.map → deploy-wSlIRPn5.cjs.map} +1 -1
- package/dist/{dokploy-TtK6Zyl3.cjs → dokploy-BKbUrz05.cjs} +2 -2
- package/dist/{dokploy-TtK6Zyl3.cjs.map → dokploy-BKbUrz05.cjs.map} +1 -1
- package/dist/{dokploy-CzDGNB6A.mjs → dokploy-BZf1AHd0.mjs} +2 -2
- package/dist/{dokploy-CzDGNB6A.mjs.map → dokploy-BZf1AHd0.mjs.map} +1 -1
- package/dist/{drivers-L29WvE95.cjs → drivers-C47nm-wB.cjs} +91 -4
- package/dist/drivers-C47nm-wB.cjs.map +1 -0
- package/dist/{drivers-C-VqMtld.mjs → drivers-CDjpjakg.mjs} +60 -3
- package/dist/drivers-CDjpjakg.mjs.map +1 -0
- package/dist/{eas-DaobzDks.mjs → eas-CxX2RCE_.mjs} +2 -2
- package/dist/{eas-DaobzDks.mjs.map → eas-CxX2RCE_.mjs.map} +1 -1
- package/dist/{eas-D3clzkni.cjs → eas-DzDMGzfc.cjs} +2 -2
- package/dist/{eas-D3clzkni.cjs.map → eas-DzDMGzfc.cjs.map} +1 -1
- package/dist/{encryption-DV31gEY8.mjs → encryption-BFSrt89F.mjs} +2 -2
- package/dist/{encryption-DV31gEY8.mjs.map → encryption-BFSrt89F.mjs.map} +1 -1
- package/dist/{encryption-DBkIFiR2.cjs → encryption-RNcBnG4Z.cjs} +2 -2
- package/dist/{encryption-DBkIFiR2.cjs.map → encryption-RNcBnG4Z.cjs.map} +1 -1
- package/dist/{engine-CuZUGbEh.cjs → engine-Dqe9KQCm.cjs} +7 -5
- package/dist/engine-Dqe9KQCm.cjs.map +1 -0
- package/dist/{engine-CFOR9h6X.mjs → engine-_0pjyCd_.mjs} +7 -5
- package/dist/engine-_0pjyCd_.mjs.map +1 -0
- package/dist/{github-CsvtWSBW.cjs → github-Csev5EFf.cjs} +4 -4
- package/dist/{github-CsvtWSBW.cjs.map → github-Csev5EFf.cjs.map} +1 -1
- package/dist/{github-Nep8pI4_.mjs → github-Dck0nLW9.mjs} +4 -4
- package/dist/{github-Nep8pI4_.mjs.map → github-Dck0nLW9.mjs.map} +1 -1
- package/dist/{googlePlay-C-UfBXJU.cjs → googlePlay-DBtDAGBk.cjs} +3 -3
- package/dist/{googlePlay-C-UfBXJU.cjs.map → googlePlay-DBtDAGBk.cjs.map} +1 -1
- package/dist/{googlePlay-lF7Atm_N.mjs → googlePlay-DTuvDHi5.mjs} +3 -3
- package/dist/{googlePlay-lF7Atm_N.mjs.map → googlePlay-DTuvDHi5.mjs.map} +1 -1
- package/dist/index.cjs +58 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +57 -56
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-hlNKNWmg.cjs → migrate-3ZEoqx5q.cjs} +2 -2
- package/dist/{migrate-hlNKNWmg.cjs.map → migrate-3ZEoqx5q.cjs.map} +1 -1
- package/dist/{migrate-_sBX0pve.mjs → migrate-BABIuzQj.mjs} +2 -2
- package/dist/{migrate-_sBX0pve.mjs.map → migrate-BABIuzQj.mjs.map} +1 -1
- package/dist/{migrate-NfbPVhi9.mjs → migrate-DZeNpuX2.mjs} +6 -4
- package/dist/migrate-DZeNpuX2.mjs.map +1 -0
- package/dist/{migrate-Dp3GhFnf.cjs → migrate-pGiUqvBi.cjs} +6 -4
- package/dist/migrate-pGiUqvBi.cjs.map +1 -0
- package/dist/{publish-BuUVaZVy.mjs → publish-BsnDeOVL.mjs} +2 -2
- package/dist/{publish-BuUVaZVy.mjs.map → publish-BsnDeOVL.mjs.map} +1 -1
- package/dist/{publish-ZOo4xEuZ.cjs → publish-CS6xDvGT.cjs} +2 -2
- package/dist/{publish-ZOo4xEuZ.cjs.map → publish-CS6xDvGT.cjs.map} +1 -1
- package/dist/{ready-qnqp6JAY.cjs → ready-CxPJm0Hc.cjs} +3 -3
- package/dist/{ready-qnqp6JAY.cjs.map → ready-CxPJm0Hc.cjs.map} +1 -1
- package/dist/{ready-Ca883OvY.mjs → ready-DrvaAwKv.mjs} +3 -3
- package/dist/{ready-Ca883OvY.mjs.map → ready-DrvaAwKv.mjs.map} +1 -1
- package/dist/{resolve-BCU9pYDx.mjs → resolve-fCGJmM-R.mjs} +3 -3
- package/dist/{resolve-BCU9pYDx.mjs.map → resolve-fCGJmM-R.mjs.map} +1 -1
- package/dist/{resolve-C9QqOl5t.cjs → resolve-zqCMFio0.cjs} +3 -3
- package/dist/{resolve-C9QqOl5t.cjs.map → resolve-zqCMFio0.cjs.map} +1 -1
- package/dist/{rollback-CWyyTQ0B.mjs → rollback-BkhVrtAf.mjs} +4 -4
- package/dist/{rollback-CWyyTQ0B.mjs.map → rollback-BkhVrtAf.mjs.map} +1 -1
- package/dist/{rollback-CTWdDBgB.cjs → rollback-qc79mj6L.cjs} +4 -4
- package/dist/{rollback-CTWdDBgB.cjs.map → rollback-qc79mj6L.cjs.map} +1 -1
- package/dist/sandbox/migrate-worker.cjs +4 -3
- package/dist/sandbox/migrate-worker.cjs.map +1 -1
- package/dist/sandbox/migrate-worker.mjs +4 -3
- package/dist/sandbox/migrate-worker.mjs.map +1 -1
- package/dist/{seeds-CPEcmoPn.cjs → seeds-3awh33Wz.cjs} +12 -11
- package/dist/{seeds-CPEcmoPn.cjs.map → seeds-3awh33Wz.cjs.map} +1 -1
- package/dist/{seeds-CK7w79VC.mjs → seeds-Cfejy8wj.mjs} +5 -4
- package/dist/{seeds-CK7w79VC.mjs.map → seeds-Cfejy8wj.mjs.map} +1 -1
- package/dist/{serverSetup-C6t6Vtt7.cjs → serverSetup-BFQuwUeL.cjs} +5 -5
- package/dist/{serverSetup-C6t6Vtt7.cjs.map → serverSetup-BFQuwUeL.cjs.map} +1 -1
- package/dist/{serverSetup-BAPNuNEX.mjs → serverSetup-C8ZbHTm_.mjs} +5 -5
- package/dist/{serverSetup-BAPNuNEX.mjs.map → serverSetup-C8ZbHTm_.mjs.map} +1 -1
- package/dist/{sniffer-g9v7cqDN.mjs → sniffer-CCkdzjiU.mjs} +6 -6
- package/dist/{sniffer-g9v7cqDN.mjs.map → sniffer-CCkdzjiU.mjs.map} +1 -1
- package/dist/{sniffer-DdX_WN_-.cjs → sniffer-Cq1nhxIB.cjs} +6 -6
- package/dist/{sniffer-DdX_WN_-.cjs.map → sniffer-Cq1nhxIB.cjs.map} +1 -1
- package/dist/{snsSubscriptions-5Cqww8S7.cjs → snsSubscriptions-DYyYP0Xf.cjs} +2 -2
- package/dist/{snsSubscriptions-5Cqww8S7.cjs.map → snsSubscriptions-DYyYP0Xf.cjs.map} +1 -1
- package/dist/{snsSubscriptions-BmYeeTH8.mjs → snsSubscriptions-R_AKBZYK.mjs} +2 -2
- package/dist/{snsSubscriptions-BmYeeTH8.mjs.map → snsSubscriptions-R_AKBZYK.mjs.map} +1 -1
- package/dist/{stage-CUE5pMmw.cjs → stage-BkgbVJ9Z.cjs} +4 -4
- package/dist/{stage-CUE5pMmw.cjs.map → stage-BkgbVJ9Z.cjs.map} +1 -1
- package/dist/{stage-C-I2dVw1.mjs → stage-DCaxqm-G.mjs} +4 -4
- package/dist/{stage-C-I2dVw1.mjs.map → stage-DCaxqm-G.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/package.json +15 -15
- package/dist/SubscriberGenerator-BDUp7OeY.cjs.map +0 -1
- package/dist/SubscriberGenerator-ocQ2yj0K.mjs.map +0 -1
- package/dist/compose-Bqcy0lqo.cjs.map +0 -1
- package/dist/databases-BPOgTn1u.mjs.map +0 -1
- package/dist/databases-fOaoBInm.cjs.map +0 -1
- package/dist/drivers-C-VqMtld.mjs.map +0 -1
- package/dist/drivers-L29WvE95.cjs.map +0 -1
- package/dist/engine-CFOR9h6X.mjs.map +0 -1
- package/dist/engine-CuZUGbEh.cjs.map +0 -1
- package/dist/migrate-Dp3GhFnf.cjs.map +0 -1
- package/dist/migrate-NfbPVhi9.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-C9QqOl5t.cjs","names":["GkmError","join","existsSync","realpathSync","dirname","readFileSync","pathToFileURL","GkmError","builtinTarget","configuredTarget","UnknownDeployTarget","configurableBuiltins","GkmError","builtinTarget","DeployTargetNotYetSupported","configuredTarget","UnknownDeployTarget","configurableBuiltins","isDeployTarget"],"sources":["../src/target/package.ts","../src/target/runtime.ts","../src/target/resolve.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';\nimport { GkmError } from '../errors';\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 GkmError {\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 { GkmError } from '../errors';\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 GkmError {\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","/**\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`, `compose`, `sst`\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 { GkmError } from '../errors';\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 GkmError {\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 GkmError {\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 GkmError {\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 GkmError {\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\tcompose: async () => (await import('./compose/index')).composeTarget(),\n\tsst: async () => (await import('./sst/index')).sstTarget,\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":";;;;;;;;;;;;;;;AA6BA,IAAa,wBAAb,cAA2CA,eAAAA,SAAS;CAEzC;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,GAAeC,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,cAAc,OAAO,CACnC;EACD;EAED,MAAM,UAAA,GAASD,UAAAA,QAAAA,CAAQ,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,KAAK,MAAM,UAAU,MAAM;GAC1B,MAAM,QAAQ,KAAK,MAAM;GACzB,IAAI,OAAO,OAAO;EACnB;EACA;CACD;CACA,IAAI,QAAQ,OAAO,SAAS,UAAU;EACrC,MAAM,aAAa;EACnB,KAAK,MAAM,aAAa;GAAC;GAAU;GAAQ;GAAW;EAAS,GAC9D,IAAI,aAAa,YAAY;GAC5B,M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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,CAAC,gBAAgB,WAAW,MAAM,QAAQ,KAAK,IACjD,QACD,CAAC,OAAO,KAAA,CAAS;CAEpB,IAAI,OAAO,mBAAmB,UAAU;EAGvC,MAAM,WAAW,gBAAgB,MAAM,gBAAgB,UAAU,IAAI;EAErE,MAAM,UAAS,MADM,cAAc,MAAM,gBAAgB,UAAU,IAAI,EAAA,CACjD;EACtB,IAAI,CAACC,eAAAA,eAAe,MAAM,GACzB,MAAM,IAAI,qBAAqB,MAAM,cAAc;EAEpD,IAAI,OAAO,YAAY,UACtB,MAAM,IAAI,sBACT,MACA,gBACA,UACA,OAAO,OACR;EAED,OAAO;GAAE;GAAM;GAAQ,QAAQ;GAAU;EAAQ;CAClD;CAEA,IAAI,CAACA,eAAAA,eAAe,cAAc,GAAG,MAAM,IAAI,mBAAmB,IAAI;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
|
+
{"version":3,"file":"resolve-zqCMFio0.cjs","names":["GkmError","join","existsSync","realpathSync","dirname","readFileSync","pathToFileURL","GkmError","builtinTarget","configuredTarget","UnknownDeployTarget","configurableBuiltins","GkmError","builtinTarget","DeployTargetNotYetSupported","configuredTarget","UnknownDeployTarget","configurableBuiltins","isDeployTarget"],"sources":["../src/target/package.ts","../src/target/runtime.ts","../src/target/resolve.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';\nimport { GkmError } from '../errors';\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 GkmError {\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 { GkmError } from '../errors';\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 GkmError {\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","/**\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`, `compose`, `sst`\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 { GkmError } from '../errors';\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 GkmError {\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 GkmError {\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 GkmError {\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 GkmError {\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\tcompose: async () => (await import('./compose/index')).composeTarget(),\n\tsst: async () => (await import('./sst/index')).sstTarget,\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":";;;;;;;;;;;;;;;AA6BA,IAAa,wBAAb,cAA2CA,eAAAA,SAAS;CAEzC;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,GAAeC,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,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AAQ;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"}
|
|
@@ -2,12 +2,12 @@ import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
|
2
2
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
3
3
|
import { r as storedCredentials } from "./credentials-DpfnUvIR.mjs";
|
|
4
4
|
import { N as assertDeployedStage } from "./workspace-DBHF9Gba.mjs";
|
|
5
|
-
import { C as recordRollback, _ as asDokployState, d as DeployJournal, y as createEmptyState } from "./seeds-
|
|
5
|
+
import { C as recordRollback, _ as asDokployState, d as DeployJournal, y as createEmptyState } from "./seeds-Cfejy8wj.mjs";
|
|
6
6
|
import { c as withSandbox } from "./sandbox-CbVB7uOD.mjs";
|
|
7
7
|
import { findWorkspaceRoot, loadWorkspaceConfig } from "./config.mjs";
|
|
8
8
|
import { t as LocalSandbox } from "./local-B7Zv1NoA.mjs";
|
|
9
|
-
import { S as createStateStore, v as assertStateOutlivesRun } from "./sniffer-
|
|
10
|
-
import { i as dokployApi, l as restoreImage, p as verifySettings } from "./engine-
|
|
9
|
+
import { S as createStateStore, v as assertStateOutlivesRun } from "./sniffer-CCkdzjiU.mjs";
|
|
10
|
+
import { i as dokployApi, l as restoreImage, p as verifySettings } from "./engine-_0pjyCd_.mjs";
|
|
11
11
|
import { resolve } from "node:path";
|
|
12
12
|
//#region src/target/dokploy/rollback.ts
|
|
13
13
|
/**
|
|
@@ -133,4 +133,4 @@ async function rollbackStage(input) {
|
|
|
133
133
|
//#endregion
|
|
134
134
|
export { rollback_exports as a, rollbackStage as i, RollbackNeedsApp as n, StageNeverDeployed as r, NothingToRollBack as t };
|
|
135
135
|
|
|
136
|
-
//# sourceMappingURL=rollback-
|
|
136
|
+
//# sourceMappingURL=rollback-BkhVrtAf.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollback-
|
|
1
|
+
{"version":3,"file":"rollback-BkhVrtAf.mjs","names":[],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t});\n\t\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsC,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,SAAS;CAErC;CACA;CAFV,YACC,OACA,KACC;EACD,MACC,IAAI,IAAI,+BAA+B,MAAM,oIAE9C;EANS,KAAA,QAAA;EACA,KAAA,MAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwC,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6JAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;;;;AAMA,eAAsB,cACrB,OACwB;CACxB,MAAM,SAAS,MAAM,UAAU,IAAI,gBAAg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O,UAAU;GAGnD,MAAM,EAAE,QAAQ,MAAM,WAAW,WAAW;IAAE;IAAa;GAAO,CAAC;GACnE,MAAM,SAAS,eAAe,UAAU,OAAO,SAAS,MAAM;GAC9D,MAAM,SAAuB,CAAC;GAE9B,KAAK,MAAM,OAAO,MAAM;IACvB,OAAO,eAAe;IACtB,MAAM,EAAE,SAAS,aAAa,SAAS;IACvC,MAAM,gBAAgB,MAAM,aAAa;IACzC,IAAI,CAAC,YAAY,CAAC,eACjB,MAAM,IAAI,kBAAkB,MAAM,OAAO,GAAG;IAG7C,IAAI,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,SAAS,KAAK;IAChD,MAAM,aAAa,KAAK;KACvB;KACA,OAAO;KACP,YAAY,MAAM;KAClB;KACA;IACD,CAAC;IACD,eAAe,OAAO,KAAK,QAAQ;IACnC,MAAM,QAAQ,KAAK;IACnB,IAAI,QAAQ,IAAI,cAAc,SAAS,KAAK;IAC5C,OAAO,KAAK;KAAE;KAAK,MAAM;KAAS,IAAI;IAAS,CAAC;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
|
|
@@ -2,12 +2,12 @@ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
|
2
2
|
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
3
3
|
const require_credentials = require("./credentials-D7XJypNd.cjs");
|
|
4
4
|
const require_workspace = require("./workspace-Du4Afb03.cjs");
|
|
5
|
-
const require_seeds = require("./seeds-
|
|
5
|
+
const require_seeds = require("./seeds-3awh33Wz.cjs");
|
|
6
6
|
const require_sandbox = require("./sandbox-CHv3OYXg.cjs");
|
|
7
7
|
const require_config = require("./config.cjs");
|
|
8
8
|
const require_local = require("./local-OPC9BCZt.cjs");
|
|
9
|
-
const require_sniffer = require("./sniffer-
|
|
10
|
-
const require_engine = require("./engine-
|
|
9
|
+
const require_sniffer = require("./sniffer-Cq1nhxIB.cjs");
|
|
10
|
+
const require_engine = require("./engine-Dqe9KQCm.cjs");
|
|
11
11
|
let node_path = require("node:path");
|
|
12
12
|
//#region src/target/dokploy/rollback.ts
|
|
13
13
|
/**
|
|
@@ -162,4 +162,4 @@ Object.defineProperty(exports, "rollback_exports", {
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
//# sourceMappingURL=rollback-
|
|
165
|
+
//# sourceMappingURL=rollback-qc79mj6L.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollback-
|
|
1
|
+
{"version":3,"file":"rollback-qc79mj6L.cjs","names":["GkmError","storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","asDokployState","dokployApi","verifySettings","restoreImage"],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t});\n\t\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAErC;CACA;CAFV,YACC,OACA,KACC;EACD,MACC,IAAI,IAAI,+BAA+B,MAAM,oIAE9C;EANS,KAAA,QAAA;EACA,KAAA,MAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAG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
|
const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
|
|
4
|
-
const require_databases = require("../databases-
|
|
4
|
+
const require_databases = require("../databases-CuVGf7-M.cjs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
let node_fs_promises = require("node:fs/promises");
|
|
7
7
|
//#region src/sandbox/migrate-worker.ts
|
|
@@ -10,7 +10,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
10
10
|
* what `gkm seed` runs, against URLs the deploy hands it as secret files.
|
|
11
11
|
*
|
|
12
12
|
* Usage (by the Dokploy target's release, never by hand):
|
|
13
|
-
* node --import=<tsx> migrate-worker.ts '{"root":"…","stage":"…","manifest":{…},"patterns":[…]}'
|
|
13
|
+
* node --import=<tsx> migrate-worker.ts '{"root":"…","stage":"…","manifest":{…},"patterns":[…],"backends":{…}}'
|
|
14
14
|
*
|
|
15
15
|
* Migrations and seeds are the project's own code, which is why they run
|
|
16
16
|
* here rather than in the deploy. Each owner URL arrives as a file in `GKM_SECRETS_DIR`,
|
|
@@ -44,7 +44,8 @@ async function main() {
|
|
|
44
44
|
const runs = await require_databases.migrateDatabases(options);
|
|
45
45
|
const seeds = await require_databases.seedDatabases({
|
|
46
46
|
...options,
|
|
47
|
-
stage: request.stage
|
|
47
|
+
stage: request.stage,
|
|
48
|
+
backends: request.backends
|
|
48
49
|
});
|
|
49
50
|
require_workerRuntime.answer({
|
|
50
51
|
reason: "migrated",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-worker.cjs","names":["SECRETS_DIR_ENV","readdir","readFile","join","registerAdjacentTsconfig","discover","migrateDatabases","seedDatabases","errorData","SeedFailed"],"sources":["../../src/sandbox/migrate-worker.ts"],"sourcesContent":["/**\n * Applies a deployed stage's migrations, then runs its seeds, in a sandbox —\n * what `gkm seed` runs, against URLs the deploy hands it as secret files.\n *\n * Usage (by the Dokploy target's release, never by hand):\n * node --import=<tsx> migrate-worker.ts '{\"root\":\"…\",\"stage\":\"…\",\"manifest\":{…},\"patterns\":[…]}'\n *\n * Migrations and seeds are the project's own code, which is why they run\n * here rather than in the deploy. Each owner URL arrives as a file in `GKM_SECRETS_DIR`,\n * named by its key, and is read into this process's memory only: never into\n * `process.env`, where a child the migration starts would inherit it.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport {\n\tmigrateDatabases,\n\tSeedFailed,\n\tseedDatabases,\n} from '../migrate/databases';\nimport { type ConstructSource, discover } from '../reconcile/discover';\nimport { SECRETS_DIR_ENV } from './sandbox';\nimport { answer, errorData, registerAdjacentTsconfig } from './workerRuntime';\n\n/** Every secret file the sandbox mounted, by name. */\nasync function mountedSecrets(): Promise<Record<string, string>> {\n\tconst dir = process.env[SECRETS_DIR_ENV];\n\tif (!dir) return {};\n\n\tconst secrets: Record<string, string> = {};\n\tfor (const name of await readdir(dir)) {\n\t\tsecrets[name] = (await readFile(join(dir, name), 'utf8')).trim();\n\t}\n\treturn secrets;\n}\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\troot: string;\n\t\t\tstage: string;\n\t\t\tmanifest: ConstructManifest;\n\t\t\tpatterns: string[];\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\t// Where each construct is declared, so a migration runs with the Kysely\n\t\t// its own file resolves. The manifest itself is the deploy's: what it\n\t\t// provisioned is what gets migrated, not a second reading of the files.\n\t\tconst sources: Record<string, ConstructSource> = {};\n\t\tif (request.patterns.length > 0) {\n\t\t\tawait discover({\n\t\t\t\tpatterns: request.patterns,\n\t\t\t\tcwd: request.root,\n\t\t\t\tsources,\n\t\t\t});\n\t\t}\n\n\t\tconst options = {\n\t\t\troot: request.root,\n\t\t\tmanifest: request.manifest,\n\t\t\tsources,\n\t\t\tenv: await mountedSecrets(),\n\t\t};\n\t\tconst runs = await migrateDatabases(options);\n\t\t// Every seed, every time, after the schema it was written for.\n\t\tconst seeds = await seedDatabases({
|
|
1
|
+
{"version":3,"file":"migrate-worker.cjs","names":["SECRETS_DIR_ENV","readdir","readFile","join","registerAdjacentTsconfig","discover","migrateDatabases","seedDatabases","errorData","SeedFailed"],"sources":["../../src/sandbox/migrate-worker.ts"],"sourcesContent":["/**\n * Applies a deployed stage's migrations, then runs its seeds, in a sandbox —\n * what `gkm seed` runs, against URLs the deploy hands it as secret files.\n *\n * Usage (by the Dokploy target's release, never by hand):\n * node --import=<tsx> migrate-worker.ts '{\"root\":\"…\",\"stage\":\"…\",\"manifest\":{…},\"patterns\":[…],\"backends\":{…}}'\n *\n * Migrations and seeds are the project's own code, which is why they run\n * here rather than in the deploy. Each owner URL arrives as a file in `GKM_SECRETS_DIR`,\n * named by its key, and is read into this process's memory only: never into\n * `process.env`, where a child the migration starts would inherit it.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport {\n\tmigrateDatabases,\n\tSeedFailed,\n\tseedDatabases,\n} from '../migrate/databases';\nimport type { SeedBackends } from '../migrate/seedDrivers';\nimport { type ConstructSource, discover } from '../reconcile/discover';\nimport { SECRETS_DIR_ENV } from './sandbox';\nimport { answer, errorData, registerAdjacentTsconfig } from './workerRuntime';\n\n/** Every secret file the sandbox mounted, by name. */\nasync function mountedSecrets(): Promise<Record<string, string>> {\n\tconst dir = process.env[SECRETS_DIR_ENV];\n\tif (!dir) return {};\n\n\tconst secrets: Record<string, string> = {};\n\tfor (const name of await readdir(dir)) {\n\t\tsecrets[name] = (await readFile(join(dir, name), 'utf8')).trim();\n\t}\n\treturn secrets;\n}\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\troot: string;\n\t\t\tstage: string;\n\t\t\tmanifest: ConstructManifest;\n\t\t\tpatterns: string[];\n\t\t\tbackends: SeedBackends;\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\t// Where each construct is declared, so a migration runs with the Kysely\n\t\t// its own file resolves. The manifest itself is the deploy's: what it\n\t\t// provisioned is what gets migrated, not a second reading of the files.\n\t\tconst sources: Record<string, ConstructSource> = {};\n\t\tif (request.patterns.length > 0) {\n\t\t\tawait discover({\n\t\t\t\tpatterns: request.patterns,\n\t\t\t\tcwd: request.root,\n\t\t\t\tsources,\n\t\t\t});\n\t\t}\n\n\t\tconst options = {\n\t\t\troot: request.root,\n\t\t\tmanifest: request.manifest,\n\t\t\tsources,\n\t\t\tenv: await mountedSecrets(),\n\t\t};\n\t\tconst runs = await migrateDatabases(options);\n\t\t// Every seed, every time, after the schema it was written for.\n\t\tconst seeds = await seedDatabases({\n\t\t\t...options,\n\t\t\tstage: request.stage,\n\t\t\tbackends: request.backends,\n\t\t});\n\n\t\tanswer({\n\t\t\treason: 'migrated',\n\t\t\truns: runs.map(({ target, applied }) => ({\n\t\t\t\tconstruct: target.id,\n\t\t\t\tmigrations: target.migrations,\n\t\t\t\tapplied,\n\t\t\t})),\n\t\t\tseeds: seeds.map(({ target, seeded }) => ({\n\t\t\t\tconstruct: target.id,\n\t\t\t\tseeds: target.seeds,\n\t\t\t\tseeded,\n\t\t\t})),\n\t\t});\n\t} catch (error) {\n\t\t// A seed's cause is the database's error — an Error, which `errorData`\n\t\t// leaves out — and it is what says what to fix.\n\t\tanswer({\n\t\t\treason: 'failed',\n\t\t\terror: {\n\t\t\t\t...errorData(error),\n\t\t\t\t...(error instanceof SeedFailed\n\t\t\t\t\t? { cause: errorData(error.cause) }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t});\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,eAAe,iBAAkD;CAChE,MAAM,MAAM,QAAQ,IAAIA,gBAAAA;CACxB,IAAI,CAAC,KAAK,OAAO,CAAC;CAElB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,OAAA,GAAMC,iBAAAA,QAAAA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mjs";
|
|
3
3
|
import { a as registerAdjacentTsconfig, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
|
|
4
|
-
import { o as SeedFailed, p as seedDatabases, u as migrateDatabases } from "../databases-
|
|
4
|
+
import { o as SeedFailed, p as seedDatabases, u as migrateDatabases } from "../databases-6GD0tI2F.mjs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { readFile, readdir } from "node:fs/promises";
|
|
7
7
|
//#region src/sandbox/migrate-worker.ts
|
|
@@ -10,7 +10,7 @@ import { readFile, readdir } from "node:fs/promises";
|
|
|
10
10
|
* what `gkm seed` runs, against URLs the deploy hands it as secret files.
|
|
11
11
|
*
|
|
12
12
|
* Usage (by the Dokploy target's release, never by hand):
|
|
13
|
-
* node --import=<tsx> migrate-worker.ts '{"root":"…","stage":"…","manifest":{…},"patterns":[…]}'
|
|
13
|
+
* node --import=<tsx> migrate-worker.ts '{"root":"…","stage":"…","manifest":{…},"patterns":[…],"backends":{…}}'
|
|
14
14
|
*
|
|
15
15
|
* Migrations and seeds are the project's own code, which is why they run
|
|
16
16
|
* here rather than in the deploy. Each owner URL arrives as a file in `GKM_SECRETS_DIR`,
|
|
@@ -44,7 +44,8 @@ async function main() {
|
|
|
44
44
|
const runs = await migrateDatabases(options);
|
|
45
45
|
const seeds = await seedDatabases({
|
|
46
46
|
...options,
|
|
47
|
-
stage: request.stage
|
|
47
|
+
stage: request.stage,
|
|
48
|
+
backends: request.backends
|
|
48
49
|
});
|
|
49
50
|
answer({
|
|
50
51
|
reason: "migrated",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-worker.mjs","names":[],"sources":["../../src/sandbox/migrate-worker.ts"],"sourcesContent":["/**\n * Applies a deployed stage's migrations, then runs its seeds, in a sandbox —\n * what `gkm seed` runs, against URLs the deploy hands it as secret files.\n *\n * Usage (by the Dokploy target's release, never by hand):\n * node --import=<tsx> migrate-worker.ts '{\"root\":\"…\",\"stage\":\"…\",\"manifest\":{…},\"patterns\":[…]}'\n *\n * Migrations and seeds are the project's own code, which is why they run\n * here rather than in the deploy. Each owner URL arrives as a file in `GKM_SECRETS_DIR`,\n * named by its key, and is read into this process's memory only: never into\n * `process.env`, where a child the migration starts would inherit it.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport {\n\tmigrateDatabases,\n\tSeedFailed,\n\tseedDatabases,\n} from '../migrate/databases';\nimport { type ConstructSource, discover } from '../reconcile/discover';\nimport { SECRETS_DIR_ENV } from './sandbox';\nimport { answer, errorData, registerAdjacentTsconfig } from './workerRuntime';\n\n/** Every secret file the sandbox mounted, by name. */\nasync function mountedSecrets(): Promise<Record<string, string>> {\n\tconst dir = process.env[SECRETS_DIR_ENV];\n\tif (!dir) return {};\n\n\tconst secrets: Record<string, string> = {};\n\tfor (const name of await readdir(dir)) {\n\t\tsecrets[name] = (await readFile(join(dir, name), 'utf8')).trim();\n\t}\n\treturn secrets;\n}\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\troot: string;\n\t\t\tstage: string;\n\t\t\tmanifest: ConstructManifest;\n\t\t\tpatterns: string[];\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\t// Where each construct is declared, so a migration runs with the Kysely\n\t\t// its own file resolves. The manifest itself is the deploy's: what it\n\t\t// provisioned is what gets migrated, not a second reading of the files.\n\t\tconst sources: Record<string, ConstructSource> = {};\n\t\tif (request.patterns.length > 0) {\n\t\t\tawait discover({\n\t\t\t\tpatterns: request.patterns,\n\t\t\t\tcwd: request.root,\n\t\t\t\tsources,\n\t\t\t});\n\t\t}\n\n\t\tconst options = {\n\t\t\troot: request.root,\n\t\t\tmanifest: request.manifest,\n\t\t\tsources,\n\t\t\tenv: await mountedSecrets(),\n\t\t};\n\t\tconst runs = await migrateDatabases(options);\n\t\t// Every seed, every time, after the schema it was written for.\n\t\tconst seeds = await seedDatabases({
|
|
1
|
+
{"version":3,"file":"migrate-worker.mjs","names":[],"sources":["../../src/sandbox/migrate-worker.ts"],"sourcesContent":["/**\n * Applies a deployed stage's migrations, then runs its seeds, in a sandbox —\n * what `gkm seed` runs, against URLs the deploy hands it as secret files.\n *\n * Usage (by the Dokploy target's release, never by hand):\n * node --import=<tsx> migrate-worker.ts '{\"root\":\"…\",\"stage\":\"…\",\"manifest\":{…},\"patterns\":[…],\"backends\":{…}}'\n *\n * Migrations and seeds are the project's own code, which is why they run\n * here rather than in the deploy. Each owner URL arrives as a file in `GKM_SECRETS_DIR`,\n * named by its key, and is read into this process's memory only: never into\n * `process.env`, where a child the migration starts would inherit it.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport {\n\tmigrateDatabases,\n\tSeedFailed,\n\tseedDatabases,\n} from '../migrate/databases';\nimport type { SeedBackends } from '../migrate/seedDrivers';\nimport { type ConstructSource, discover } from '../reconcile/discover';\nimport { SECRETS_DIR_ENV } from './sandbox';\nimport { answer, errorData, registerAdjacentTsconfig } from './workerRuntime';\n\n/** Every secret file the sandbox mounted, by name. */\nasync function mountedSecrets(): Promise<Record<string, string>> {\n\tconst dir = process.env[SECRETS_DIR_ENV];\n\tif (!dir) return {};\n\n\tconst secrets: Record<string, string> = {};\n\tfor (const name of await readdir(dir)) {\n\t\tsecrets[name] = (await readFile(join(dir, name), 'utf8')).trim();\n\t}\n\treturn secrets;\n}\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\troot: string;\n\t\t\tstage: string;\n\t\t\tmanifest: ConstructManifest;\n\t\t\tpatterns: string[];\n\t\t\tbackends: SeedBackends;\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\t// Where each construct is declared, so a migration runs with the Kysely\n\t\t// its own file resolves. The manifest itself is the deploy's: what it\n\t\t// provisioned is what gets migrated, not a second reading of the files.\n\t\tconst sources: Record<string, ConstructSource> = {};\n\t\tif (request.patterns.length > 0) {\n\t\t\tawait discover({\n\t\t\t\tpatterns: request.patterns,\n\t\t\t\tcwd: request.root,\n\t\t\t\tsources,\n\t\t\t});\n\t\t}\n\n\t\tconst options = {\n\t\t\troot: request.root,\n\t\t\tmanifest: request.manifest,\n\t\t\tsources,\n\t\t\tenv: await mountedSecrets(),\n\t\t};\n\t\tconst runs = await migrateDatabases(options);\n\t\t// Every seed, every time, after the schema it was written for.\n\t\tconst seeds = await seedDatabases({\n\t\t\t...options,\n\t\t\tstage: request.stage,\n\t\t\tbackends: request.backends,\n\t\t});\n\n\t\tanswer({\n\t\t\treason: 'migrated',\n\t\t\truns: runs.map(({ target, applied }) => ({\n\t\t\t\tconstruct: target.id,\n\t\t\t\tmigrations: target.migrations,\n\t\t\t\tapplied,\n\t\t\t})),\n\t\t\tseeds: seeds.map(({ target, seeded }) => ({\n\t\t\t\tconstruct: target.id,\n\t\t\t\tseeds: target.seeds,\n\t\t\t\tseeded,\n\t\t\t})),\n\t\t});\n\t} catch (error) {\n\t\t// A seed's cause is the database's error — an Error, which `errorData`\n\t\t// leaves out — and it is what says what to fix.\n\t\tanswer({\n\t\t\treason: 'failed',\n\t\t\terror: {\n\t\t\t\t...errorData(error),\n\t\t\t\t...(error instanceof SeedFailed\n\t\t\t\t\t? { cause: errorData(error.cause) }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t});\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,eAAe,iBAAkD;CAChE,MAAM,MAAM,QAAQ,IAAI;CACxB,IAAI,CAAC,KAAK,OAAO,CAAC;CAElB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,MAAM,QAAQ,GAAG,GACnC,QAAQ,SAAS,MAAM,SAAS,KAAK,KAAK,IAAI,GAAG,MAAM,EAAA,CAAG,KAAK;CAEhE,OAAO;AACR;AAEA,eAAe,OAAsB;CACpC,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI;EAOlD,MAAM,yBAAyB;EAK/B,MAAM,UAA2C,CAAC;EAClD,IAAI,QAAQ,SAAS,SAAS,GAC7B,MAAM,SAAS;GACd,UAAU,QAAQ;GAClB,KAAK,QAAQ;GACb;EACD,CAAC;EAGF,MAAM,UAAU;GACf,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB;GACA,KAAK,MAAM,eAAe;EAC3B;EACA,MAAM,OAAO,MAAM,iBAAiB,OAAO;EAE3C,MAAM,QAAQ,MAAM,cAAc;GACjC,GAAG;GACH,OAAO,QAAQ;GACf,UAAU,QAAQ;EACnB,CAAC;EAED,OAAO;GACN,QAAQ;GACR,MAAM,KAAK,KAAK,EAAE,QAAQ,eAAe;IACxC,WAAW,OAAO;IAClB,YAAY,OAAO;IACnB;GACD,EAAE;GACF,OAAO,MAAM,KAAK,EAAE,QAAQ,cAAc;IACzC,WAAW,OAAO;IAClB,OAAO,OAAO;IACd;GACD,EAAE;EACH,CAAC;CACF,SAAS,OAAO;EAGf,OAAO;GACN,QAAQ;GACR,OAAO;IACN,GAAG,UAAU,KAAK;IAClB,GAAI,iBAAiB,aAClB,EAAE,OAAO,UAAU,MAAM,KAAK,EAAE,IAChC,CAAC;GACL;EACD,CAAC;CACF;AACD;AAEK,KAAK"}
|
|
@@ -3,12 +3,13 @@ const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
|
3
3
|
const require_credentials = require("./credentials-D7XJypNd.cjs");
|
|
4
4
|
const require_workspace = require("./workspace-Du4Afb03.cjs");
|
|
5
5
|
const require_derive = require("./derive-DAbo49sm.cjs");
|
|
6
|
-
const
|
|
6
|
+
const require_drivers = require("./drivers-C47nm-wB.cjs");
|
|
7
7
|
const require_identity = require("./identity-CbLfgQNT.cjs");
|
|
8
8
|
const require_EndpointGenerator = require("./EndpointGenerator-BGxf9jWE.cjs");
|
|
9
9
|
const require_discover = require("./discover-DL6h-J97.cjs");
|
|
10
10
|
const require_config = require("./config.cjs");
|
|
11
|
-
const
|
|
11
|
+
const require_SubscriberGenerator = require("./SubscriberGenerator-LgyTxZ8r.cjs");
|
|
12
|
+
const require_resolve = require("./resolve-zqCMFio0.cjs");
|
|
12
13
|
let node_path = require("node:path");
|
|
13
14
|
let node_fs = require("node:fs");
|
|
14
15
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -1105,11 +1106,11 @@ function resourceName(id, kind, stage, localStage) {
|
|
|
1105
1106
|
* broker the project selected, which is why the backend is an argument here
|
|
1106
1107
|
* rather than a second pass that adds containers after the fact.
|
|
1107
1108
|
*/
|
|
1108
|
-
function containerFor(kind, events = DEFAULT_EVENTS, cache =
|
|
1109
|
+
function containerFor(kind, events = DEFAULT_EVENTS, cache = require_drivers.DEFAULT_CACHE.aws, derived = false, edge = true) {
|
|
1109
1110
|
if (EVENT_KINDS[kind]) return EVENT_CONTAINERS[events] ?? CONTAINERS.database;
|
|
1110
1111
|
if (kind === "file-server") return edge ? "caddy" : CONTAINERS.objects;
|
|
1111
1112
|
if (kind === "cache") {
|
|
1112
|
-
if (derived && !
|
|
1113
|
+
if (derived && !require_drivers.holdsEveryCache(cache)) return CONTAINERS.database;
|
|
1113
1114
|
return CACHE_CONTAINERS[cache] ?? CONTAINERS.database;
|
|
1114
1115
|
}
|
|
1115
1116
|
return CONTAINERS[kind];
|
|
@@ -1126,7 +1127,7 @@ function planFor(manifest, stage, order, options = {}) {
|
|
|
1126
1127
|
const resources = [];
|
|
1127
1128
|
const fakes = {};
|
|
1128
1129
|
const events = options.events ?? "pgboss";
|
|
1129
|
-
const cache = options.cache ??
|
|
1130
|
+
const cache = options.cache ?? require_drivers.DEFAULT_CACHE.aws;
|
|
1130
1131
|
for (const id of order) {
|
|
1131
1132
|
const declaration = manifest[id];
|
|
1132
1133
|
if (!declaration) continue;
|
|
@@ -1142,7 +1143,7 @@ function planFor(manifest, stage, order, options = {}) {
|
|
|
1142
1143
|
port: fake.port
|
|
1143
1144
|
} : {}
|
|
1144
1145
|
};
|
|
1145
|
-
const detached = declaration.kind === "cache" &&
|
|
1146
|
+
const detached = declaration.kind === "cache" && require_drivers.holdsEveryCache(cache);
|
|
1146
1147
|
const container = fake?.image ? fake.key : declaration.kind === "telemetry" ? usesTelemetry(manifest) ? TELEMETRY_CONTAINER : void 0 : containerFor(declaration.kind, events, cache, "of" in declaration && typeof declaration.of === "string", options.edge !== false);
|
|
1147
1148
|
if (!container && !CONTAINERLESS[declaration.kind]) continue;
|
|
1148
1149
|
if (container) {
|
|
@@ -4494,11 +4495,11 @@ function providerOf(workspace) {
|
|
|
4494
4495
|
* would be worse than a slower one.
|
|
4495
4496
|
*/
|
|
4496
4497
|
function cacheBackendFor(on) {
|
|
4497
|
-
return
|
|
4498
|
+
return require_drivers.DEFAULT_CACHE[on];
|
|
4498
4499
|
}
|
|
4499
4500
|
/** Where a declared bucket lives on a target. */
|
|
4500
4501
|
function storageBackendFor(on) {
|
|
4501
|
-
return
|
|
4502
|
+
return require_drivers.DEFAULT_STORAGE[on];
|
|
4502
4503
|
}
|
|
4503
4504
|
/**
|
|
4504
4505
|
* Which broker carries declared queues and topics on a target.
|
|
@@ -4507,7 +4508,7 @@ function storageBackendFor(on) {
|
|
|
4507
4508
|
* `Queue` has no events at all, whatever the target.
|
|
4508
4509
|
*/
|
|
4509
4510
|
function eventsBackendFor(on) {
|
|
4510
|
-
return
|
|
4511
|
+
return require_drivers.DEFAULT_EVENTS[on];
|
|
4511
4512
|
}
|
|
4512
4513
|
//#endregion
|
|
4513
4514
|
//#region src/reconcile/compose.ts
|
|
@@ -8285,7 +8286,7 @@ async function createDnsProvider(options) {
|
|
|
8285
8286
|
});
|
|
8286
8287
|
}
|
|
8287
8288
|
if (provider === "godaddy") {
|
|
8288
|
-
const { GoDaddyProvider } = await Promise.resolve().then(() => require("./GoDaddyProvider-
|
|
8289
|
+
const { GoDaddyProvider } = await Promise.resolve().then(() => require("./GoDaddyProvider-DFfpzCOP.cjs"));
|
|
8289
8290
|
return new GoDaddyProvider(options.godaddy ?? {});
|
|
8290
8291
|
}
|
|
8291
8292
|
if (provider === "cloudflare") throw new DnsProviderNotImplemented("cloudflare");
|
|
@@ -10239,4 +10240,4 @@ Object.defineProperty(exports, "workspace_exports", {
|
|
|
10239
10240
|
}
|
|
10240
10241
|
});
|
|
10241
10242
|
|
|
10242
|
-
//# sourceMappingURL=seeds-
|
|
10243
|
+
//# sourceMappingURL=seeds-3awh33Wz.cjs.map
|