@geekmidas/cli 10.0.0-alpha.84 → 10.0.0-alpha.85
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/{LegacyStateStore-CTsUFLNQ.mjs → LegacyStateStore-CJ2o18nT.mjs} +2 -2
- package/dist/{LegacyStateStore-CTsUFLNQ.mjs.map → LegacyStateStore-CJ2o18nT.mjs.map} +1 -1
- package/dist/{LegacyStateStore-EDT2TUSe.cjs → LegacyStateStore-xGxPwP-m.cjs} +2 -2
- package/dist/{LegacyStateStore-EDT2TUSe.cjs.map → LegacyStateStore-xGxPwP-m.cjs.map} +1 -1
- package/dist/{LocalStateStore-D1VfxRuK.mjs → LocalStateStore-ByVjUIvS.mjs} +12 -10
- package/dist/LocalStateStore-ByVjUIvS.mjs.map +1 -0
- package/dist/{LocalStateStore-CdpzTvPn.cjs → LocalStateStore-CkjFD-4b.cjs} +11 -9
- package/dist/LocalStateStore-CkjFD-4b.cjs.map +1 -0
- package/dist/{S3StateStore-BPM74zwv.cjs → S3StateStore-iqMezbES.cjs} +2 -2
- package/dist/{S3StateStore-BPM74zwv.cjs.map → S3StateStore-iqMezbES.cjs.map} +1 -1
- package/dist/{S3StateStore-DVZ1YuGJ.mjs → S3StateStore-kpFlGVLE.mjs} +2 -2
- package/dist/{S3StateStore-DVZ1YuGJ.mjs.map → S3StateStore-kpFlGVLE.mjs.map} +1 -1
- package/dist/{SSMStateStore-DLvnGyyl.mjs → SSMStateStore-Bkz5ztfo.mjs} +2 -2
- package/dist/{SSMStateStore-DLvnGyyl.mjs.map → SSMStateStore-Bkz5ztfo.mjs.map} +1 -1
- package/dist/{SSMStateStore-qerm5c36.cjs → SSMStateStore-Z2OMVCtq.cjs} +2 -2
- package/dist/{SSMStateStore-qerm5c36.cjs.map → SSMStateStore-Z2OMVCtq.cjs.map} +1 -1
- package/dist/{add-BQ8v1ZII.cjs → add-CM7RLj89.cjs} +2 -2
- package/dist/{add-BQ8v1ZII.cjs.map → add-CM7RLj89.cjs.map} +1 -1
- package/dist/{add-DbnzC7Kl.mjs → add-jpX7M8RB.mjs} +2 -2
- package/dist/{add-DbnzC7Kl.mjs.map → add-jpX7M8RB.mjs.map} +1 -1
- package/dist/{bundler-D4030Afw.mjs → bundler-CaAKsbcN.mjs} +5 -5
- package/dist/{bundler-D4030Afw.mjs.map → bundler-CaAKsbcN.mjs.map} +1 -1
- package/dist/{bundler-DjrRffko.cjs → bundler-lEBH8ENP.cjs} +5 -5
- package/dist/{bundler-DjrRffko.cjs.map → bundler-lEBH8ENP.cjs.map} +1 -1
- package/dist/{cli-DwTa9d_8.mjs → cli-BV3jzbk0.mjs} +3 -3
- package/dist/{cli-DwTa9d_8.mjs.map → cli-BV3jzbk0.mjs.map} +1 -1
- package/dist/{cli-D8YQAYUX.cjs → cli-DQCBcNlN.cjs} +3 -3
- package/dist/{cli-D8YQAYUX.cjs.map → cli-DQCBcNlN.cjs.map} +1 -1
- package/dist/{compose-C5wz8mf9.mjs → compose-CQK6StuE.mjs} +24 -6
- package/dist/compose-CQK6StuE.mjs.map +1 -0
- package/dist/{compose-DqWh1TaO.cjs → compose-CSR0yEJm.cjs} +23 -5
- package/dist/compose-CSR0yEJm.cjs.map +1 -0
- package/dist/deploy/public.cjs +6 -6
- package/dist/deploy/public.mjs +6 -6
- package/dist/{deploy-BwIKGxWH.mjs → deploy-BuU117CA.mjs} +4 -4
- package/dist/{deploy-BwIKGxWH.mjs.map → deploy-BuU117CA.mjs.map} +1 -1
- package/dist/{deploy-C8sWg81_.cjs → deploy-Bw2Mm3x3.cjs} +4 -4
- package/dist/{deploy-C8sWg81_.cjs.map → deploy-Bw2Mm3x3.cjs.map} +1 -1
- package/dist/{dokploy-BkRxJbfi.cjs → dokploy-C81J1MVK.cjs} +2 -2
- package/dist/{dokploy-BkRxJbfi.cjs.map → dokploy-C81J1MVK.cjs.map} +1 -1
- package/dist/{dokploy-ijjms1-h.mjs → dokploy-DWALWk7u.mjs} +2 -2
- package/dist/{dokploy-ijjms1-h.mjs.map → dokploy-DWALWk7u.mjs.map} +1 -1
- package/dist/{encryption-g6PzwwfL.cjs → encryption-B8h8Tna0.cjs} +2 -2
- package/dist/{encryption-g6PzwwfL.cjs.map → encryption-B8h8Tna0.cjs.map} +1 -1
- package/dist/{encryption-BRcBAmjL.mjs → encryption-DpAum8W7.mjs} +2 -2
- package/dist/{encryption-BRcBAmjL.mjs.map → encryption-DpAum8W7.mjs.map} +1 -1
- package/dist/{engine-DLEJsZ3i.cjs → engine-B01fjhLt.cjs} +3 -3
- package/dist/{engine-DLEJsZ3i.cjs.map → engine-B01fjhLt.cjs.map} +1 -1
- package/dist/{engine-BP0CZ5fh.mjs → engine-BXCtEhSH.mjs} +3 -3
- package/dist/{engine-BP0CZ5fh.mjs.map → engine-BXCtEhSH.mjs.map} +1 -1
- package/dist/{github-Zs-dVJbR.mjs → github-8B68qrLs.mjs} +2 -2
- package/dist/{github-Zs-dVJbR.mjs.map → github-8B68qrLs.mjs.map} +1 -1
- package/dist/{github-B8YjwdLK.cjs → github-Cis9tYur.cjs} +2 -2
- package/dist/{github-B8YjwdLK.cjs.map → github-Cis9tYur.cjs.map} +1 -1
- package/dist/index.cjs +45 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +45 -45
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-BfZN1S32.cjs → migrate-BBCp5blp.cjs} +2 -2
- package/dist/{migrate-BfZN1S32.cjs.map → migrate-BBCp5blp.cjs.map} +1 -1
- package/dist/{migrate-CdXcX0XR.mjs → migrate-BeTWLSeC.mjs} +2 -2
- package/dist/{migrate-CdXcX0XR.mjs.map → migrate-BeTWLSeC.mjs.map} +1 -1
- package/dist/{migrate-FoL_mZIz.cjs → migrate-CPWn7A51.cjs} +2 -2
- package/dist/{migrate-FoL_mZIz.cjs.map → migrate-CPWn7A51.cjs.map} +1 -1
- package/dist/{migrate-DOMU4uKe.mjs → migrate-sDq7NApJ.mjs} +2 -2
- package/dist/{migrate-DOMU4uKe.mjs.map → migrate-sDq7NApJ.mjs.map} +1 -1
- package/dist/{resolve-r7PAs6ng.mjs → resolve-CXbwJ_iu.mjs} +3 -3
- package/dist/{resolve-r7PAs6ng.mjs.map → resolve-CXbwJ_iu.mjs.map} +1 -1
- package/dist/{resolve-T2I-5FcT.cjs → resolve-CztIqBOI.cjs} +3 -3
- package/dist/{resolve-T2I-5FcT.cjs.map → resolve-CztIqBOI.cjs.map} +1 -1
- package/dist/{rollback-BSdxnW3X.mjs → rollback-ByyFE5lV.mjs} +4 -4
- package/dist/{rollback-BSdxnW3X.mjs.map → rollback-ByyFE5lV.mjs.map} +1 -1
- package/dist/{rollback-CPSDjGse.cjs → rollback-CyIJ4xGJ.cjs} +4 -4
- package/dist/{rollback-CPSDjGse.cjs.map → rollback-CyIJ4xGJ.cjs.map} +1 -1
- package/dist/{seeds-BK8caVMm.mjs → seeds-9C5CkDon.mjs} +31 -3
- package/dist/seeds-9C5CkDon.mjs.map +1 -0
- package/dist/{seeds-DQ0FG57Z.cjs → seeds-B_Beuv0o.cjs} +30 -2
- package/dist/seeds-B_Beuv0o.cjs.map +1 -0
- package/dist/{sniffer-hSf5mRgV.cjs → sniffer-3fA0iExx.cjs} +5 -5
- package/dist/{sniffer-hSf5mRgV.cjs.map → sniffer-3fA0iExx.cjs.map} +1 -1
- package/dist/{sniffer-CqE_KTTp.mjs → sniffer-DgBkaLAu.mjs} +5 -5
- package/dist/{sniffer-CqE_KTTp.mjs.map → sniffer-DgBkaLAu.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/package.json +15 -15
- package/dist/LocalStateStore-CdpzTvPn.cjs.map +0 -1
- package/dist/LocalStateStore-D1VfxRuK.mjs.map +0 -1
- package/dist/compose-C5wz8mf9.mjs.map +0 -1
- package/dist/compose-DqWh1TaO.cjs.map +0 -1
- package/dist/seeds-BK8caVMm.mjs.map +0 -1
- package/dist/seeds-DQ0FG57Z.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollback-
|
|
1
|
+
{"version":3,"file":"rollback-ByyFE5lV.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 { createStateStore } from '../../deploy/StateStore';\nimport {\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\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 Error {\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 Error {\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 Error {\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\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});\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(store, input.stage, () =>\n\t\t\t\tcreateEmptyState(input.stage, '', ''),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,IAAa,mBAAb,cAAsC,MAAM;CAEjC;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,MAAM;CAElC;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,MAAM;CACxB;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,gBAAgB,CAAC,CAAC;CACrD,MAAM,MAAM,MAAM,cAAc,CAAC;CACjC,MAAM,cAAc,MAAM,eAAe,kBAAkB;CAC3D,MAAM,UACL,MAAM,WACN,IAAI,aAAa,EAAE,MAAM,kBAAkB,QAAQ,MAAM,GAAG,CAAC,EAAE,CAAC;CAEjE,OAAO,YAAY,SAAS,YAAY;EACvC,MAAM,EAAE,cAAc,MAAM,oBAAoB,QAAQ,MAAM,GAAG,GAAG,EACnE,QACD,CAAC;EACD,oBAAoB,UAAU,QAAQ,MAAM,KAAK;EAEjD,MAAM,QAAQ,MAAM,iBAAiB;GACpC,QAAQ,UAAU;GAClB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ClB;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"}
|
|
@@ -3,9 +3,9 @@ const require_credentials = require("./credentials-BVs7mrtw.cjs");
|
|
|
3
3
|
const require_sandbox = require("./sandbox-CL--ZDui.cjs");
|
|
4
4
|
const require_workspace = require("./workspace-Bic_R3tz.cjs");
|
|
5
5
|
const require_config = require("./config.cjs");
|
|
6
|
-
const require_seeds = require("./seeds-
|
|
7
|
-
const require_sniffer = require("./sniffer-
|
|
8
|
-
const require_engine = require("./engine-
|
|
6
|
+
const require_seeds = require("./seeds-B_Beuv0o.cjs");
|
|
7
|
+
const require_sniffer = require("./sniffer-3fA0iExx.cjs");
|
|
8
|
+
const require_engine = require("./engine-B01fjhLt.cjs");
|
|
9
9
|
let node_path = require("node:path");
|
|
10
10
|
//#region src/target/dokploy/rollback.ts
|
|
11
11
|
/**
|
|
@@ -158,4 +158,4 @@ Object.defineProperty(exports, "rollback_exports", {
|
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
//# sourceMappingURL=rollback-
|
|
161
|
+
//# sourceMappingURL=rollback-CyIJ4xGJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollback-
|
|
1
|
+
{"version":3,"file":"rollback-CyIJ4xGJ.cjs","names":["storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","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 { createStateStore } from '../../deploy/StateStore';\nimport {\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\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 Error {\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 Error {\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 Error {\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\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});\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(store, input.stage, () =>\n\t\t\t\tcreateEmptyState(input.stage, '', ''),\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":";;;;;;;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,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"}
|
|
@@ -6,7 +6,7 @@ import { I as stageSampleRate, L as telemetryEnv, R as LOGS_PORT, U as UnknownSe
|
|
|
6
6
|
import { ConfigNotFound, NotInAnApp, loadWorkspaceAppInfo, loadWorkspaceConfig } from "./config.mjs";
|
|
7
7
|
import { a as telemetryArgs, c as startTelemetryCode, n as runtimeFor, u as writeTelemetryModule } from "./EndpointGenerator-CVc6Oi1Y.mjs";
|
|
8
8
|
import { a as DEFAULT_STORAGE, i as DEFAULT_EVENTS$1, n as readFakes, o as holdsEveryCache, r as DEFAULT_CACHE, t as SubscriberGenerator } from "./SubscriberGenerator-BPqQf8fB.mjs";
|
|
9
|
-
import { c as runtimeOf } from "./resolve-
|
|
9
|
+
import { c as runtimeOf } from "./resolve-CXbwJ_iu.mjs";
|
|
10
10
|
import { basename, dirname, isAbsolute, join, parse, relative, resolve, sep } from "node:path";
|
|
11
11
|
import { constants, existsSync, readFileSync } from "node:fs";
|
|
12
12
|
import { appendFile, chmod, copyFile, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -14,7 +14,7 @@ import { homedir, networkInterfaces } from "node:os";
|
|
|
14
14
|
import { promisify } from "node:util";
|
|
15
15
|
import { Cron } from "@geekmidas/constructs/crons";
|
|
16
16
|
import { Queue } from "@geekmidas/constructs/queue";
|
|
17
|
-
import { DEFAULT_POSTGRES_VERSION, TELEMETRY_KEYS, cacheTable, cookieDomain, dependenciesOf, dependentsOf, externalApiUrl, kebabCase, mobileOrigins, provideKey, providedKeyFor, provisionOrder, publicEnvFor, schemeBase, scopedName } from "@geekmidas/manifest";
|
|
17
|
+
import { CLIENT_IP_HEADER, DEFAULT_POSTGRES_VERSION, TELEMETRY_KEYS, cacheTable, cookieDomain, dependenciesOf, dependentsOf, externalApiUrl, kebabCase, mobileOrigins, provideKey, providedKeyFor, provisionOrder, publicEnvFor, schemeBase, scopedName } from "@geekmidas/manifest";
|
|
18
18
|
import { createServer } from "node:net";
|
|
19
19
|
import { execFile, spawn } from "node:child_process";
|
|
20
20
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, randomInt } from "node:crypto";
|
|
@@ -1369,6 +1369,30 @@ function siteClientTelemetry(manifest, appName, workspace, stage) {
|
|
|
1369
1369
|
//#endregion
|
|
1370
1370
|
//#region src/reconcile/caddyfile.ts
|
|
1371
1371
|
/**
|
|
1372
|
+
* The Caddy configuration a plan implies.
|
|
1373
|
+
*
|
|
1374
|
+
* A file server is a *domain that serves a bucket*, and locally it had neither:
|
|
1375
|
+
* `UPLOADS_SERVER_URL` resolved to MinIO's path-style address, which works and
|
|
1376
|
+
* is not the deployed shape. MinIO's own virtual-host mode cannot fix that —
|
|
1377
|
+
* it reads the leading label *as the bucket name*, so it produces the right
|
|
1378
|
+
* shape only when the server's id and the bucket's happen to agree, and never
|
|
1379
|
+
* for a server fronting two buckets.
|
|
1380
|
+
*
|
|
1381
|
+
* So the mapping lives in front of MinIO instead: one host per file server,
|
|
1382
|
+
* rewriting the bucket in as a path prefix. That is the whole of it — no
|
|
1383
|
+
* caching, because caching is not what is missing locally, and a caching proxy
|
|
1384
|
+
* would add an invalidation story a local stack has no use for.
|
|
1385
|
+
*
|
|
1386
|
+
* What it buys beyond the shape is a certificate. Caddy issues one per host
|
|
1387
|
+
* from its own CA, so a local address is `https://` like the deployed one, and
|
|
1388
|
+
* everything downstream of that — `Secure` cookies, `SameSite`, a cookie domain
|
|
1389
|
+
* with more than one host under it — starts behaving the way it will in
|
|
1390
|
+
* production rather than the way `http://localhost` allows.
|
|
1391
|
+
*
|
|
1392
|
+
* Pure, like `composeFor`: what should exist is data, and rendering it is one
|
|
1393
|
+
* line at the edge.
|
|
1394
|
+
*/
|
|
1395
|
+
/**
|
|
1372
1396
|
* The kinds the edge serves.
|
|
1373
1397
|
*
|
|
1374
1398
|
* Everything that owns a *public address*. Deployed, each of these has a real
|
|
@@ -1515,6 +1539,10 @@ function toCaddyfile(sites) {
|
|
|
1515
1539
|
https://${host} {
|
|
1516
1540
|
tls internal
|
|
1517
1541
|
|
|
1542
|
+
# gkm's own header, which only a service of this stack may send: the auth
|
|
1543
|
+
# server rate-limits by the client address it carries.
|
|
1544
|
+
request_header -${CLIENT_IP_HEADER}
|
|
1545
|
+
|
|
1518
1546
|
reverse_proxy ${upstream} {${rewrite ? `
|
|
1519
1547
|
rewrite ${rewrite}
|
|
1520
1548
|
# MinIO routes and signs on the Host header, so forwarding the requested
|
|
@@ -7548,4 +7576,4 @@ function reportPlannedSeeds(planned, log) {
|
|
|
7548
7576
|
//#endregion
|
|
7549
7577
|
export { postgresSuperuser as $, describeServices as $t, UnknownDevService as A, maskPassword as An, WORKER_PORT as At, WorkerGenerator as B, NoDomainForStage as Bn, composeFor as Bt, workerDockerfile as C, imageName as Cn, networkEnv as Ct, DevServicesNeedServerTarget as D, ownershipMarker as Dn, composeBuildPaths as Dt, DEV_SERVICES as E, markerOf as En, localRolePassword as Et, parseDevServices as F, LOGS_SERVICE as Fn, cacheBackendFor as Ft, FAKE_ENV as G, hostFor as Gt, workerEntryDir as H, resolveHost as Hn, TELEMETRY_CONTAINER as Ht, reportDevServices as I, logsAccess as In, eventsBackendFor as It, derivedContainers as J, scopeTelemetryEnv as Jt, backendsOf as K, appTelemetry as Kt, requiredStageKeys as L, logsService as Ln, providerOf as Lt, devServicesUsed as M, toEmbeddableSecrets as Mn, findBuildRoot as Mt, externalServices as N, withCustomSecret as Nn, imageBuildCredentials as Nt, ExternalServicesNotConfigured as O, projectName as On, imageLayout as Ot, manifestServiceDeclarations as P, LOCAL_LOGS_EMAIL as Pn, isImageBuild as Pt, loadLocalCredentials as Q, DEFAULT_IMAGES as Qt, suppliedOnly as R, stackLogs as Rn, storageBackendFor as Rt, ensureDockerignore as S, deployIdentity as Sn, dockerfileOf as St, validateImageRef as T, isOwnedBy as Tn, envFor as Tt, QueueGenerator as U, planFor as Ut, workerBundleName as V, isMainFrontendApp as Vn, EMULATOR_ACCESS_KEY_ID as Vt, CronGenerator as W, resourceName as Wt, workspace_exports as X, telemetryOf as Xt, reconcileWorkspace as Y, surfaceClientTraced as Yt, LOCAL_RABBITMQ_USER as Z, usesTelemetry as Zt, DeployJournal as _, getKeyPath as _n, LEGACY_LOCAL_LOGIN as _t, createEmptyState as a, createEntryWrapper as an, runsRedis as at, appDockerfile as b, readKey as bn, pgClient as bt, isDnsVerified as c, loadEnvFiles as cn, LOCAL_CA_PATH as ct, setApplicationId as d, prepareEntryCredentials as dn, applyPolicies as dt, fakeKey as en, readLocalCredentials as et, setBackupState as f, isRemoteStore as fn, applyPostgres as ft, setPostgresBackupId as g, FileSecretsStore as gn, quoteIdentifier as gt, setGeneratedSecret as h, store_exports as hn, postgresStatements as ht, assertNoStaleSecrets as i, createCredentialsPreload as in, redisService as it, assertExternalServices as j, storage_exports as jn, detectPackageManager as jt, STORAGE_KEY_PAIR as k, initStageSecrets as kn, TURBO_VERSION as kt, recordRelease as l, loadPortState as ln, forgetState as lt, setDnsVerification as m, storeFromConfig as mn, postgresDatabaseNames as mt, reportDatabaseRuns as n, portsOf as nn, REDIS_SERVICE as nt, getBackupState as o, findAvailablePort as on, stackRedis as ot, setDnsRecord as p, secretsStoreFor as pn, bucketPolicies as pt, constructGlobs as q, isTelemetryKey as qt, reportPlannedSeeds as r, primaryPortKey as rn, STACK_CACHE as rt, getGeneratedSecret as s, isPortAvailable as sn, withRedisPassword as st, DeploySeedsFailed as t, portKeys as tn, withGeneratedSecrets as tt, recordRollback as u, loadSecretsForApp as un, applyBuckets as ut, DockerBuildFailed as v, keystoreProject as vn, ensurePostgresLogin as vt, workerDockerfileOf as w, imageRef as wn, workerEnvKeys as wt, dockerCommand as x, applicationName as xn, appEnvKeys as xt, DockerPushFailed as y, projectKey as yn, bucketClient as yt, workerUnits as z, withLogsPassword as zn, CLUSTER_DATABASE as zt };
|
|
7550
7578
|
|
|
7551
|
-
//# sourceMappingURL=seeds-
|
|
7579
|
+
//# sourceMappingURL=seeds-9C5CkDon.mjs.map
|