@geekmidas/cli 10.0.0-alpha.59 → 10.0.0-alpha.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-BTZd2u0f.cjs} +3 -3
- package/dist/{HostingerProvider-BZFGYYVA.cjs.map → HostingerProvider-BTZd2u0f.cjs.map} +1 -1
- package/dist/{HostingerProvider-YQY3rMpV.mjs → HostingerProvider-DgzKa_Tj.mjs} +2 -2
- package/dist/{HostingerProvider-YQY3rMpV.mjs.map → HostingerProvider-DgzKa_Tj.mjs.map} +1 -1
- package/dist/{LegacyStateStore-CB4ch3Dl.mjs → LegacyStateStore-CToa2hga.mjs} +2 -2
- package/dist/{LegacyStateStore-CB4ch3Dl.mjs.map → LegacyStateStore-CToa2hga.mjs.map} +1 -1
- package/dist/{LegacyStateStore-CQJqvmXw.cjs → LegacyStateStore-CidlPT0N.cjs} +7 -7
- package/dist/{LegacyStateStore-CQJqvmXw.cjs.map → LegacyStateStore-CidlPT0N.cjs.map} +1 -1
- package/dist/LocalStateStore-BFLiOocU.mjs +165 -0
- package/dist/LocalStateStore-BFLiOocU.mjs.map +1 -0
- package/dist/LocalStateStore-Dpuqka1N.cjs +176 -0
- package/dist/LocalStateStore-Dpuqka1N.cjs.map +1 -0
- package/dist/{OpenApiTsGenerator-BCWPRZwD.cjs → OpenApiTsGenerator-BTuUumsV.cjs} +3 -3
- package/dist/{OpenApiTsGenerator-BCWPRZwD.cjs.map → OpenApiTsGenerator-BTuUumsV.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BRWD1Wit.mjs → OpenApiTsGenerator-CvVr1Ilz.mjs} +3 -3
- package/dist/{OpenApiTsGenerator-BRWD1Wit.mjs.map → OpenApiTsGenerator-CvVr1Ilz.mjs.map} +1 -1
- package/dist/{S3StateStore-CXTenDTW.mjs → S3StateStore-aaGkjcxO.mjs} +2 -2
- package/dist/{S3StateStore-CXTenDTW.mjs.map → S3StateStore-aaGkjcxO.mjs.map} +1 -1
- package/dist/{S3StateStore-DLS4rEc0.cjs → S3StateStore-cnm813Xn.cjs} +5 -5
- package/dist/{S3StateStore-DLS4rEc0.cjs.map → S3StateStore-cnm813Xn.cjs.map} +1 -1
- package/dist/{SSMStateStore-hnP5deFJ.mjs → SSMStateStore-BllaJKGo.mjs} +2 -2
- package/dist/{SSMStateStore-hnP5deFJ.mjs.map → SSMStateStore-BllaJKGo.mjs.map} +1 -1
- package/dist/{SSMStateStore-EqsTBIOs.cjs → SSMStateStore-DwaGprVX.cjs} +9 -9
- package/dist/{SSMStateStore-EqsTBIOs.cjs.map → SSMStateStore-DwaGprVX.cjs.map} +1 -1
- package/dist/appPorts-C9z9Pzn9.mjs +223 -0
- package/dist/appPorts-C9z9Pzn9.mjs.map +1 -0
- package/dist/appPorts-Cu79hJF6.cjs +264 -0
- package/dist/appPorts-Cu79hJF6.cjs.map +1 -0
- package/dist/{bundler-By6_sXiL.cjs → bundler-CzXZPSBJ.cjs} +4 -4
- package/dist/{bundler-By6_sXiL.cjs.map → bundler-CzXZPSBJ.cjs.map} +1 -1
- package/dist/{bundler-ouDdNvk9.mjs → bundler-DJVR4QlW.mjs} +4 -4
- package/dist/{bundler-ouDdNvk9.mjs.map → bundler-DJVR4QlW.mjs.map} +1 -1
- package/dist/cli-D_qTl20Z.cjs +69 -0
- package/dist/cli-D_qTl20Z.cjs.map +1 -0
- package/dist/cli-DzR1hpum.mjs +69 -0
- package/dist/cli-DzR1hpum.mjs.map +1 -0
- package/dist/{config-EuzFEkcH.mjs → config-C5-EEdmr.mjs} +4 -4
- package/dist/config-C5-EEdmr.mjs.map +1 -0
- package/dist/{config-WMOB9bLL.cjs → config-DXnkCEq0.cjs} +4 -4
- package/dist/config-DXnkCEq0.cjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +1 -1
- package/dist/deploy/public.cjs +22 -0
- package/dist/deploy/public.d.cts +459 -0
- package/dist/deploy/public.d.cts.map +1 -0
- package/dist/deploy/public.d.mts +459 -0
- package/dist/deploy/public.d.mts.map +1 -0
- package/dist/deploy/public.mjs +5 -0
- package/dist/deploy/sniffer-hooks.cjs +1 -1
- package/dist/deploy/sniffer-hooks.mjs +1 -1
- package/dist/deploy/sniffer-loader.cjs +1 -1
- package/dist/deploy/sniffer-loader.mjs +1 -1
- package/dist/deploy-0fBVeWO-.cjs +3518 -0
- package/dist/deploy-0fBVeWO-.cjs.map +1 -0
- package/dist/deploy-D6Q09OkA.mjs +3429 -0
- package/dist/deploy-D6Q09OkA.mjs.map +1 -0
- package/dist/{discover-DXNviAh-.cjs → discover-Bc-4eA_p.cjs} +55 -3
- package/dist/discover-Bc-4eA_p.cjs.map +1 -0
- package/dist/{discover-Cf2jAcgF.mjs → discover-FrYvzkeC.mjs} +44 -4
- package/dist/discover-FrYvzkeC.mjs.map +1 -0
- package/dist/{encryption-BP8zfxEJ.cjs → encryption-CML4UaPi.cjs} +5 -5
- package/dist/{encryption-BP8zfxEJ.cjs.map → encryption-CML4UaPi.cjs.map} +1 -1
- package/dist/{encryption-BW7Gh51G.mjs → encryption-aDA2AzVx.mjs} +4 -4
- package/dist/{encryption-BW7Gh51G.mjs.map → encryption-aDA2AzVx.mjs.map} +1 -1
- package/dist/fakes-C9RiT6XG.mjs +125 -0
- package/dist/fakes-C9RiT6XG.mjs.map +1 -0
- package/dist/fakes-zW-jNAbQ.cjs +148 -0
- package/dist/fakes-zW-jNAbQ.cjs.map +1 -0
- package/dist/{github-DHpDMBT7.cjs → github-Cq57poPj.cjs} +7 -7
- package/dist/github-Cq57poPj.cjs.map +1 -0
- package/dist/{github-T_6sK3Rz.mjs → github-DmCj2u95.mjs} +7 -7
- package/dist/github-DmCj2u95.mjs.map +1 -0
- package/dist/home-DOzBaWaL.cjs +33 -0
- package/dist/home-DOzBaWaL.cjs.map +1 -0
- package/dist/home-GI7pJl1M.mjs +22 -0
- package/dist/home-GI7pJl1M.mjs.map +1 -0
- package/dist/{index-DV6j4Ydq.d.cts → index-Da1-oa9W.d.mts} +2 -2
- package/dist/{index-B5TJ-mB6.d.mts.map → index-Da1-oa9W.d.mts.map} +1 -1
- package/dist/{index-B5TJ-mB6.d.mts → index-UiWCaGzU.d.cts} +2 -2
- package/dist/{index-DV6j4Ydq.d.cts.map → index-UiWCaGzU.d.cts.map} +1 -1
- package/dist/index.cjs +341 -6412
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +289 -6335
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-CThJfVHR.cjs → migrate-BTqIflwc.cjs} +11 -11
- package/dist/{migrate-CThJfVHR.cjs.map → migrate-BTqIflwc.cjs.map} +1 -1
- package/dist/{migrate-BrFREmgQ.mjs → migrate-B_6KofUo.mjs} +6 -6
- package/dist/{migrate-BrFREmgQ.mjs.map → migrate-B_6KofUo.mjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/{ready-mR96orkJ.cjs → ready-CCLIAkwR.cjs} +7 -148
- package/dist/ready-CCLIAkwR.cjs.map +1 -0
- package/dist/{ready-DbDHneLR.mjs → ready-CIHpnUc5.mjs} +7 -124
- package/dist/ready-CIHpnUc5.mjs.map +1 -0
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{workspace-BRZ14o-o.mjs → sniffer-BM8fpCas.mjs} +3317 -27
- package/dist/sniffer-BM8fpCas.mjs.map +1 -0
- package/dist/{workspace-Dbn07ILl.cjs → sniffer-DIv12ncU.cjs} +3616 -91
- package/dist/sniffer-DIv12ncU.cjs.map +1 -0
- package/dist/store-BS8A7NcA.mjs +415 -0
- package/dist/store-BS8A7NcA.mjs.map +1 -0
- package/dist/store-KvNQwYaB.cjs +510 -0
- package/dist/store-KvNQwYaB.cjs.map +1 -0
- package/dist/{types-CipIIm8f.d.mts → types-Bp1mVxG0.d.mts} +17 -4
- package/dist/types-Bp1mVxG0.d.mts.map +1 -0
- package/dist/{types-D9b-IYdW.d.cts → types-efNLu9xu.d.cts} +17 -4
- package/dist/types-efNLu9xu.d.cts.map +1 -0
- package/dist/vitest.cjs +2 -2
- package/dist/vitest.mjs +2 -2
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace-B64Xk1Mb.cjs.map +1 -1
- package/dist/workspace-Bp1xVaOz.mjs.map +1 -1
- package/package.json +23 -13
- package/dist/StateStore-B4u0wx2t.cjs +0 -412
- package/dist/StateStore-B4u0wx2t.cjs.map +0 -1
- package/dist/StateStore-CYUfGYcx.mjs +0 -359
- package/dist/StateStore-CYUfGYcx.mjs.map +0 -1
- package/dist/backends-CjuCiE8h.mjs +0 -59
- package/dist/backends-CjuCiE8h.mjs.map +0 -1
- package/dist/backends-v3xDuhO0.cjs +0 -82
- package/dist/backends-v3xDuhO0.cjs.map +0 -1
- package/dist/config-EuzFEkcH.mjs.map +0 -1
- package/dist/config-WMOB9bLL.cjs.map +0 -1
- package/dist/discover-Cf2jAcgF.mjs.map +0 -1
- package/dist/discover-DXNviAh-.cjs.map +0 -1
- package/dist/github-DHpDMBT7.cjs.map +0 -1
- package/dist/github-T_6sK3Rz.mjs.map +0 -1
- package/dist/ready-DbDHneLR.mjs.map +0 -1
- package/dist/ready-mR96orkJ.cjs.map +0 -1
- package/dist/store-DQgxT_WR.cjs +0 -211
- package/dist/store-DQgxT_WR.cjs.map +0 -1
- package/dist/store-DeGATCS-.mjs +0 -182
- package/dist/store-DeGATCS-.mjs.map +0 -1
- package/dist/types-CipIIm8f.d.mts.map +0 -1
- package/dist/types-D9b-IYdW.d.cts.map +0 -1
- package/dist/workspace-BRZ14o-o.mjs.map +0 -1
- package/dist/workspace-Dbn07ILl.cjs.map +0 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
+
const require_sniffer = require("./sniffer-DIv12ncU.cjs");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let node_fs_promises = require("node:fs/promises");
|
|
5
|
+
let node_crypto = require("node:crypto");
|
|
6
|
+
//#region src/deploy/LocalStateStore.ts
|
|
7
|
+
/**
|
|
8
|
+
* Local filesystem state store.
|
|
9
|
+
*
|
|
10
|
+
* `.gkm/deploy-<stage>.json` holds the state, `.gkm/deploy-<stage>.lock` the
|
|
11
|
+
* lock. Every file is mode 0600: state holds database passwords and IAM keys.
|
|
12
|
+
*/
|
|
13
|
+
var LocalStateStore_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ LocalStateStore: () => LocalStateStore });
|
|
14
|
+
const FILE_MODE = 384;
|
|
15
|
+
/** How long a write waits for another process's write to finish. */
|
|
16
|
+
const MUTEX_TIMEOUT_MS = 5e3;
|
|
17
|
+
/**
|
|
18
|
+
* A write holds the mutex for milliseconds, so one this old was left by a
|
|
19
|
+
* process that died mid-write and is safe to take over.
|
|
20
|
+
*/
|
|
21
|
+
const MUTEX_STALE_MS = 3e4;
|
|
22
|
+
function isCode(error, code) {
|
|
23
|
+
return error?.code === code;
|
|
24
|
+
}
|
|
25
|
+
var LocalStateStore = class extends require_sniffer.DocumentStateStore {
|
|
26
|
+
workspaceRoot;
|
|
27
|
+
constructor(workspaceRoot) {
|
|
28
|
+
super();
|
|
29
|
+
this.workspaceRoot = workspaceRoot;
|
|
30
|
+
}
|
|
31
|
+
get dir() {
|
|
32
|
+
return (0, node_path.join)(this.workspaceRoot, ".gkm");
|
|
33
|
+
}
|
|
34
|
+
statePath(stage) {
|
|
35
|
+
return (0, node_path.join)(this.dir, `deploy-${stage}.json`);
|
|
36
|
+
}
|
|
37
|
+
lockPath(stage) {
|
|
38
|
+
return (0, node_path.join)(this.dir, `deploy-${stage}.lock`);
|
|
39
|
+
}
|
|
40
|
+
backupPath(stage) {
|
|
41
|
+
return (0, node_path.join)(this.dir, `deploy-${stage}.v1.json`);
|
|
42
|
+
}
|
|
43
|
+
mutexPath(stage) {
|
|
44
|
+
return (0, node_path.join)(this.dir, `deploy-${stage}.json.mutex`);
|
|
45
|
+
}
|
|
46
|
+
location(stage) {
|
|
47
|
+
return this.statePath(stage);
|
|
48
|
+
}
|
|
49
|
+
async readRaw(stage) {
|
|
50
|
+
try {
|
|
51
|
+
const body = await (0, node_fs_promises.readFile)(this.statePath(stage), "utf-8");
|
|
52
|
+
return {
|
|
53
|
+
body,
|
|
54
|
+
version: require_sniffer.contentVersion(body)
|
|
55
|
+
};
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (isCode(error, "ENOENT")) return null;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async writeRaw(stage, body, expectedVersion) {
|
|
62
|
+
await this.ensureDir();
|
|
63
|
+
return this.withMutex(stage, async () => {
|
|
64
|
+
const actual = (await this.readRaw(stage))?.version ?? null;
|
|
65
|
+
if (actual !== expectedVersion) throw new require_sniffer.StateVersionConflict(stage, expectedVersion, actual);
|
|
66
|
+
const target = this.statePath(stage);
|
|
67
|
+
const temp = `${target}.${(0, node_crypto.randomUUID)()}.tmp`;
|
|
68
|
+
try {
|
|
69
|
+
const handle = await (0, node_fs_promises.open)(temp, "wx", FILE_MODE);
|
|
70
|
+
try {
|
|
71
|
+
await handle.writeFile(body);
|
|
72
|
+
await handle.sync();
|
|
73
|
+
} finally {
|
|
74
|
+
await handle.close();
|
|
75
|
+
}
|
|
76
|
+
await (0, node_fs_promises.rename)(temp, target);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
await (0, node_fs_promises.rm)(temp, { force: true });
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
return require_sniffer.contentVersion(body);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async writeV1Backup(stage, body) {
|
|
85
|
+
try {
|
|
86
|
+
await (0, node_fs_promises.writeFile)(this.backupPath(stage), body, {
|
|
87
|
+
flag: "wx",
|
|
88
|
+
mode: FILE_MODE
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (!isCode(error, "EEXIST")) throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async createLock(stage, holder) {
|
|
95
|
+
await this.ensureDir();
|
|
96
|
+
let handle;
|
|
97
|
+
try {
|
|
98
|
+
handle = await (0, node_fs_promises.open)(this.lockPath(stage), "wx", FILE_MODE);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (isCode(error, "EEXIST")) throw new require_sniffer.StateLocked(stage, await this.readLock(stage), this.lockPath(stage));
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
await handle.writeFile(JSON.stringify(holder, null, 2));
|
|
105
|
+
} finally {
|
|
106
|
+
await handle.close();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async readLock(stage) {
|
|
110
|
+
try {
|
|
111
|
+
return JSON.parse(await (0, node_fs_promises.readFile)(this.lockPath(stage), "utf-8"));
|
|
112
|
+
} catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async removeLock(stage, holder) {
|
|
117
|
+
if (holder) {
|
|
118
|
+
if ((await this.readLock(stage))?.id !== holder.id) return;
|
|
119
|
+
}
|
|
120
|
+
await (0, node_fs_promises.rm)(this.lockPath(stage), { force: true });
|
|
121
|
+
}
|
|
122
|
+
async ensureDir() {
|
|
123
|
+
await (0, node_fs_promises.mkdir)(this.dir, {
|
|
124
|
+
recursive: true,
|
|
125
|
+
mode: 448
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Serialises the check-then-rename of a conditional write across
|
|
130
|
+
* processes. The stage lock is for whole runs; this is for the instant of
|
|
131
|
+
* a single write, so even writers that skip the lock never interleave.
|
|
132
|
+
*/
|
|
133
|
+
async withMutex(stage, fn) {
|
|
134
|
+
const path = this.mutexPath(stage);
|
|
135
|
+
const deadline = Date.now() + MUTEX_TIMEOUT_MS;
|
|
136
|
+
for (;;) try {
|
|
137
|
+
await (await (0, node_fs_promises.open)(path, "wx", FILE_MODE)).close();
|
|
138
|
+
break;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (!isCode(error, "EEXIST")) throw error;
|
|
141
|
+
if (await this.isStale(path)) {
|
|
142
|
+
await (0, node_fs_promises.unlink)(path).catch(() => {});
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (Date.now() > deadline) throw new require_sniffer.StateStoreBusy(stage, path);
|
|
146
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
return await fn();
|
|
150
|
+
} finally {
|
|
151
|
+
await (0, node_fs_promises.rm)(path, { force: true });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async isStale(path) {
|
|
155
|
+
try {
|
|
156
|
+
return Date.now() - (await (0, node_fs_promises.stat)(path)).mtimeMs > MUTEX_STALE_MS;
|
|
157
|
+
} catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
//#endregion
|
|
163
|
+
Object.defineProperty(exports, "LocalStateStore", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function() {
|
|
166
|
+
return LocalStateStore;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(exports, "LocalStateStore_exports", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function() {
|
|
172
|
+
return LocalStateStore_exports;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=LocalStateStore-Dpuqka1N.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalStateStore-Dpuqka1N.cjs","names":["DocumentStateStore","join","readFile","contentVersion","StateVersionConflict","randomUUID","open","rename","rm","writeFile","StateLocked","mkdir","unlink","StateStoreBusy","stat"],"sources":["../src/deploy/LocalStateStore.ts"],"sourcesContent":["/**\n * Local filesystem state store.\n *\n * `.gkm/deploy-<stage>.json` holds the state, `.gkm/deploy-<stage>.lock` the\n * lock. Every file is mode 0600: state holds database passwords and IAM keys.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n\tmkdir,\n\topen,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\tunlink,\n\twriteFile,\n} from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n\tcontentVersion,\n\tDocumentStateStore,\n\ttype LockHolder,\n\ttype RawState,\n\tStateLocked,\n\tStateStoreBusy,\n\ttype StateVersion,\n\tStateVersionConflict,\n} from './StateStore';\n\nconst FILE_MODE = 0o600;\n\n/** How long a write waits for another process's write to finish. */\nconst MUTEX_TIMEOUT_MS = 5_000;\n/**\n * A write holds the mutex for milliseconds, so one this old was left by a\n * process that died mid-write and is safe to take over.\n */\nconst MUTEX_STALE_MS = 30_000;\n\nfunction isCode(error: unknown, code: string): boolean {\n\treturn (error as NodeJS.ErrnoException)?.code === code;\n}\n\nexport class LocalStateStore extends DocumentStateStore {\n\tconstructor(readonly workspaceRoot: string) {\n\t\tsuper();\n\t}\n\n\tprivate get dir(): string {\n\t\treturn join(this.workspaceRoot, '.gkm');\n\t}\n\n\tstatePath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.json`);\n\t}\n\n\tlockPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.lock`);\n\t}\n\n\tbackupPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.v1.json`);\n\t}\n\n\tprivate mutexPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.json.mutex`);\n\t}\n\n\tprotected location(stage: string): string {\n\t\treturn this.statePath(stage);\n\t}\n\n\tprotected async readRaw(stage: string): Promise<RawState | null> {\n\t\ttry {\n\t\t\tconst body = await readFile(this.statePath(stage), 'utf-8');\n\t\t\treturn { body, version: contentVersion(body) };\n\t\t} catch (error) {\n\t\t\tif (isCode(error, 'ENOENT')) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async writeRaw(\n\t\tstage: string,\n\t\tbody: string,\n\t\texpectedVersion: StateVersion | null,\n\t): Promise<StateVersion> {\n\t\tawait this.ensureDir();\n\t\treturn this.withMutex(stage, async () => {\n\t\t\tconst current = await this.readRaw(stage);\n\t\t\tconst actual = current?.version ?? null;\n\t\t\tif (actual !== expectedVersion) {\n\t\t\t\tthrow new StateVersionConflict(stage, expectedVersion, actual);\n\t\t\t}\n\n\t\t\t// Written beside the target and renamed over it: a reader sees the\n\t\t\t// old file or the new one, never half of either.\n\t\t\tconst target = this.statePath(stage);\n\t\t\tconst temp = `${target}.${randomUUID()}.tmp`;\n\t\t\ttry {\n\t\t\t\tconst handle = await open(temp, 'wx', FILE_MODE);\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.writeFile(body);\n\t\t\t\t\tawait handle.sync();\n\t\t\t\t} finally {\n\t\t\t\t\tawait handle.close();\n\t\t\t\t}\n\t\t\t\tawait rename(temp, target);\n\t\t\t} catch (error) {\n\t\t\t\tawait rm(temp, { force: true });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn contentVersion(body);\n\t\t});\n\t}\n\n\tprotected async writeV1Backup(stage: string, body: string): Promise<void> {\n\t\ttry {\n\t\t\tawait writeFile(this.backupPath(stage), body, {\n\t\t\t\tflag: 'wx',\n\t\t\t\tmode: FILE_MODE,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// The first migration's backup is the one worth keeping.\n\t\t\tif (!isCode(error, 'EEXIST')) throw error;\n\t\t}\n\t}\n\n\tprotected async createLock(stage: string, holder: LockHolder): Promise<void> {\n\t\tawait this.ensureDir();\n\t\tlet handle: Awaited<ReturnType<typeof open>>;\n\t\ttry {\n\t\t\thandle = await open(this.lockPath(stage), 'wx', FILE_MODE);\n\t\t} catch (error) {\n\t\t\tif (isCode(error, 'EEXIST')) {\n\t\t\t\tthrow new StateLocked(\n\t\t\t\t\tstage,\n\t\t\t\t\tawait this.readLock(stage),\n\t\t\t\t\tthis.lockPath(stage),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\ttry {\n\t\t\tawait handle.writeFile(JSON.stringify(holder, null, 2));\n\t\t} finally {\n\t\t\tawait handle.close();\n\t\t}\n\t}\n\n\tprotected async readLock(stage: string): Promise<LockHolder | null> {\n\t\ttry {\n\t\t\treturn JSON.parse(\n\t\t\t\tawait readFile(this.lockPath(stage), 'utf-8'),\n\t\t\t) as LockHolder;\n\t\t} catch {\n\t\t\t// Missing, or created by a process that died before writing to it.\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprotected async removeLock(\n\t\tstage: string,\n\t\tholder: LockHolder | null,\n\t): Promise<void> {\n\t\tif (holder) {\n\t\t\tconst current = await this.readLock(stage);\n\t\t\tif (current?.id !== holder.id) return;\n\t\t}\n\t\tawait rm(this.lockPath(stage), { force: true });\n\t}\n\n\tprivate async ensureDir(): Promise<void> {\n\t\tawait mkdir(this.dir, { recursive: true, mode: 0o700 });\n\t}\n\n\t/**\n\t * Serialises the check-then-rename of a conditional write across\n\t * processes. The stage lock is for whole runs; this is for the instant of\n\t * a single write, so even writers that skip the lock never interleave.\n\t */\n\tprivate async withMutex<T>(stage: string, fn: () => Promise<T>): Promise<T> {\n\t\tconst path = this.mutexPath(stage);\n\t\tconst deadline = Date.now() + MUTEX_TIMEOUT_MS;\n\n\t\tfor (;;) {\n\t\t\ttry {\n\t\t\t\tconst handle = await open(path, 'wx', FILE_MODE);\n\t\t\t\tawait handle.close();\n\t\t\t\tbreak;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isCode(error, 'EEXIST')) throw error;\n\t\t\t\tif (await this.isStale(path)) {\n\t\t\t\t\tawait unlink(path).catch(() => {});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (Date.now() > deadline) throw new StateStoreBusy(stage, path);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} finally {\n\t\t\tawait rm(path, { force: true });\n\t\t}\n\t}\n\n\tprivate async isStale(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\treturn Date.now() - (await stat(path)).mtimeMs > MUTEX_STALE_MS;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,YAAY;;AAGlB,MAAM,mBAAmB;;;;;AAKzB,MAAM,iBAAiB;AAEvB,SAAS,OAAO,OAAgB,MAAuB;CACtD,OAAQ,OAAiC,SAAS;AACnD;AAEA,IAAa,kBAAb,cAAqCA,gBAAAA,mBAAmB;CAClC;CAArB,YAAY,eAAgC;EAC3C,MAAM;EADc,KAAA,gBAAA;CAErB;CAEA,IAAY,MAAc;EACzB,QAAA,GAAOC,UAAAA,KAAAA,CAAK,KAAK,eAAe,MAAM;CACvC;CAEA,UAAU,OAAuB;EAChC,QAAA,GAAOA,UAAAA,KAAAA,CAAK,KAAK,KAAK,UAAU,MAAM,MAAM;CAC7C;CAEA,SAAS,OAAuB;EAC/B,QAAA,GAAOA,UAAAA,KAAAA,CAAK,KAAK,KAAK,UAAU,MAAM,MAAM;CAC7C;CAEA,WAAW,OAAuB;EACjC,QAAA,GAAOA,UAAAA,KAAAA,CAAK,KAAK,KAAK,UAAU,MAAM,SAAS;CAChD;CAEA,UAAkB,OAAuB;EACxC,QAAA,GAAOA,UAAAA,KAAAA,CAAK,KAAK,KAAK,UAAU,MAAM,YAAY;CACnD;CAEA,SAAmB,OAA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AAG,MAAM;GACpC,IAAI,MAAM,KAAK,QAAQ,IAAI,GAAG;IAC7B,OAAA,GAAMM,iBAAAA,OAAAA,CAAO,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IACjC;GACD;GACA,IAAI,KAAK,IAAI,IAAI,UAAU,MAAM,IAAIC,gBAAAA,eAAe,OAAO,IAAI;GAC/D,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;EACvD;EAGD,IAAI;GACH,OAAO,MAAM,GAAG;EACjB,UAAU;GACT,OAAA,GAAML,iBAAAA,GAAAA,CAAG,MAAM,EAAE,OAAO,KAAK,CAAC;EAC/B;CACD;CAEA,MAAc,QAAQ,MAAgC;EACrD,IAAI;GACH,OAAO,KAAK,IAAI,KAAK,OAAA,GAAMM,iBAAAA,KAAAA,CAAK,IAAI,EAAA,CAAG,UAAU;EAClD,QAAQ;GACP,OAAO;EACR;CACD;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_discover = require("./discover-
|
|
1
|
+
const require_discover = require("./discover-Bc-4eA_p.cjs");
|
|
2
|
+
let node_path = require("node:path");
|
|
2
3
|
let node_fs = require("node:fs");
|
|
3
4
|
let node_fs_promises = require("node:fs/promises");
|
|
4
|
-
let node_path = require("node:path");
|
|
5
5
|
let _geekmidas_constructs_endpoints = require("@geekmidas/constructs/endpoints");
|
|
6
6
|
let _geekmidas_schema_conversion = require("@geekmidas/schema/conversion");
|
|
7
7
|
//#region src/build/endpoint-analyzer.ts
|
|
@@ -1933,4 +1933,4 @@ Object.defineProperty(exports, "telemetryFor", {
|
|
|
1933
1933
|
}
|
|
1934
1934
|
});
|
|
1935
1935
|
|
|
1936
|
-
//# sourceMappingURL=OpenApiTsGenerator-
|
|
1936
|
+
//# sourceMappingURL=OpenApiTsGenerator-BTuUumsV.cjs.map
|