hazo_env 0.15.2 → 0.16.0
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/CHANGE_LOG.md +84 -0
- package/README.md +316 -0
- package/dist/cli.js +102 -14
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +19 -0
- package/dist/deploy/clean.d.ts +2 -1
- package/dist/deploy/clean.d.ts.map +1 -1
- package/dist/deploy/clean.js +36 -6
- package/dist/deploy/generate-readme-cli.d.ts +3 -0
- package/dist/deploy/generate-readme-cli.d.ts.map +1 -0
- package/dist/deploy/generate-readme-cli.js +40 -0
- package/dist/deploy/help.d.ts +55 -0
- package/dist/deploy/help.d.ts.map +1 -0
- package/dist/deploy/help.js +526 -0
- package/dist/deploy/index.d.ts +3 -0
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/index.js +3 -0
- package/dist/deploy/init.d.ts +8 -0
- package/dist/deploy/init.d.ts.map +1 -1
- package/dist/deploy/init.js +12 -1
- package/dist/deploy/rollback.d.ts +10 -1
- package/dist/deploy/rollback.d.ts.map +1 -1
- package/dist/deploy/rollback.js +25 -1
- package/dist/deploy/share.d.ts +28 -0
- package/dist/deploy/share.d.ts.map +1 -0
- package/dist/deploy/share.js +53 -0
- package/dist/deploy/shared-dirs.d.ts +128 -0
- package/dist/deploy/shared-dirs.d.ts.map +1 -0
- package/dist/deploy/shared-dirs.js +486 -0
- package/dist/deploy/status.d.ts +8 -0
- package/dist/deploy/status.d.ts.map +1 -1
- package/dist/deploy/status.js +6 -0
- package/dist/deploy/switch.d.ts.map +1 -1
- package/dist/deploy/switch.js +25 -0
- package/dist/deploy/types.d.ts +18 -0
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/envsync/engine.d.ts.map +1 -1
- package/dist/envsync/engine.js +21 -7
- package/dist/envsync/paths.d.ts +22 -0
- package/dist/envsync/paths.d.ts.map +1 -1
- package/dist/envsync/paths.js +55 -0
- package/dist/resolve/deploy.d.ts.map +1 -1
- package/dist/resolve/deploy.js +165 -0
- package/dist/resolve/envsync.d.ts +16 -0
- package/dist/resolve/envsync.d.ts.map +1 -1
- package/dist/resolve/envsync.js +19 -0
- package/package.json +3 -2
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
// hazo_env/src/deploy/shared-dirs.ts — Shared-dirs core module
|
|
2
|
+
//
|
|
3
|
+
// Deep module for the "shared dirs" feature (see spec at
|
|
4
|
+
// .scratch/deploy-shared-dirs/spec.md): folders declared in
|
|
5
|
+
// `[deploy] shared_dirs` that live once under `shared_root` and are
|
|
6
|
+
// symlinked into each blue-green slot, so uploads survive `deploy switch`.
|
|
7
|
+
//
|
|
8
|
+
// Two responsibilities, deliberately kept apart from every other deploy
|
|
9
|
+
// command: inspecting what's actually on disk (`inspectSharedDirs`, pure
|
|
10
|
+
// read, never throws for a "bad" state — it just reports it) and enforcing
|
|
11
|
+
// the expected link (`ensureLinks`, throws a typed `SharedDirError` for any
|
|
12
|
+
// state it isn't explicitly told to fix). Every other deploy command
|
|
13
|
+
// (init/build/switch/rollback/status/clean) is expected to call through
|
|
14
|
+
// this module rather than touching shared-dir paths with raw fs calls
|
|
15
|
+
// itself — this file is the only place that does.
|
|
16
|
+
//
|
|
17
|
+
// All operations here are plain node:fs against real paths — no
|
|
18
|
+
// CommandRunner involved (there's no external command to run; symlink/mkdir
|
|
19
|
+
// are syscalls, not shell commands), matching how init.ts's
|
|
20
|
+
// `ensurePeerDataDir` also reaches for fs directly rather than routing
|
|
21
|
+
// through CommandRunner.
|
|
22
|
+
import crypto from 'node:crypto';
|
|
23
|
+
import fs from 'node:fs';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
/**
|
|
26
|
+
* Recursively count regular files under `dirPath`. Symlinks found inside are
|
|
27
|
+
* counted (something is there) but never followed, both to avoid loops and
|
|
28
|
+
* because a shared dir containing a symlink is already an unexpected state
|
|
29
|
+
* this module doesn't try to interpret further.
|
|
30
|
+
*/
|
|
31
|
+
function countFilesRecursive(dirPath) {
|
|
32
|
+
let count = 0;
|
|
33
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
if (entry.isSymbolicLink()) {
|
|
36
|
+
count += 1;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
count += countFilesRecursive(path.join(dirPath, entry.name));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (entry.isFile()) {
|
|
44
|
+
count += 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return count;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Inspect a single shared dir in a single slot. Never throws for a "bad"
|
|
51
|
+
* on-disk state (real-dir, wrong-link, ...) — reporting those states is the
|
|
52
|
+
* whole point; only an unexpected fs error (not ENOENT) propagates.
|
|
53
|
+
*/
|
|
54
|
+
function inspectOneDir(slotDir, dir, expectedTarget) {
|
|
55
|
+
const fullPath = path.join(slotDir, dir);
|
|
56
|
+
let st;
|
|
57
|
+
try {
|
|
58
|
+
st = fs.lstatSync(fullPath);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (err.code === 'ENOENT')
|
|
62
|
+
return { state: 'missing' };
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
if (st.isSymbolicLink()) {
|
|
66
|
+
const rawTarget = fs.readlinkSync(fullPath);
|
|
67
|
+
const resolvedTarget = path.isAbsolute(rawTarget) ? rawTarget : path.resolve(path.dirname(fullPath), rawTarget);
|
|
68
|
+
if (path.resolve(resolvedTarget) === path.resolve(expectedTarget)) {
|
|
69
|
+
return { state: 'linked' };
|
|
70
|
+
}
|
|
71
|
+
return { state: 'wrong-link', linkTarget: resolvedTarget };
|
|
72
|
+
}
|
|
73
|
+
if (st.isDirectory()) {
|
|
74
|
+
const fileCount = countFilesRecursive(fullPath);
|
|
75
|
+
return fileCount === 0 ? { state: 'empty-dir' } : { state: 'real-dir', fileCount };
|
|
76
|
+
}
|
|
77
|
+
// A plain file sitting where a directory/symlink was expected — treat it
|
|
78
|
+
// like any other unexpected real object blocking the link.
|
|
79
|
+
return { state: 'real-dir', fileCount: 1 };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Inspect every `config.shared_dirs` entry in both `slots.live` and
|
|
83
|
+
* `slots.standby`. Pure read — safe to call at any time, including from
|
|
84
|
+
* `deploy status`.
|
|
85
|
+
*/
|
|
86
|
+
export function inspectSharedDirs(config, slots) {
|
|
87
|
+
return config.shared_dirs.map((dir) => {
|
|
88
|
+
const expectedTarget = path.join(config.shared_root, dir);
|
|
89
|
+
return {
|
|
90
|
+
dir,
|
|
91
|
+
expectedTarget,
|
|
92
|
+
live: inspectOneDir(slots.live, dir, expectedTarget),
|
|
93
|
+
standby: inspectOneDir(slots.standby, dir, expectedTarget),
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** Thrown by `ensureLinks` for any shared dir it refuses to touch or can't fix without an option it wasn't given. */
|
|
98
|
+
export class SharedDirError extends Error {
|
|
99
|
+
constructor(code, dir, message) {
|
|
100
|
+
super(message);
|
|
101
|
+
this.name = 'SharedDirError';
|
|
102
|
+
this.code = code;
|
|
103
|
+
this.dir = dir;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Ensure every `config.shared_dirs` entry is correctly linked in `slotDir`.
|
|
108
|
+
*
|
|
109
|
+
* - `linked` (already points at the right target): no-op.
|
|
110
|
+
* - `missing`: created only if `allowCreate` — otherwise throws
|
|
111
|
+
* `HAZO_ENV_SHARED_DIR_MISSING`.
|
|
112
|
+
* - `empty-dir`: replaced only if `allowReplaceEmpty` — otherwise throws
|
|
113
|
+
* `HAZO_ENV_SHARED_DIR_EMPTY_DIR`.
|
|
114
|
+
* - `real-dir` (non-empty) and `wrong-link`: ALWAYS throw
|
|
115
|
+
* (`HAZO_ENV_SHARED_DIR_REAL_DIR` / `HAZO_ENV_SHARED_DIR_WRONG_LINK`),
|
|
116
|
+
* regardless of options — these states mean real data (or someone else's
|
|
117
|
+
* link) is sitting there, and only `deploy share`'s explicit migration is
|
|
118
|
+
* allowed to touch that, never an automatic "ensure" call.
|
|
119
|
+
*
|
|
120
|
+
* Processes entries in order and throws on the first blocking one — callers
|
|
121
|
+
* that want a full report before any error should call `inspectSharedDirs`
|
|
122
|
+
* first.
|
|
123
|
+
*/
|
|
124
|
+
export function ensureLinks(config, slotDir, opts = {}) {
|
|
125
|
+
const results = [];
|
|
126
|
+
for (const dir of config.shared_dirs) {
|
|
127
|
+
const expectedTarget = path.join(config.shared_root, dir);
|
|
128
|
+
const fullPath = path.join(slotDir, dir);
|
|
129
|
+
const slotState = inspectOneDir(slotDir, dir, expectedTarget);
|
|
130
|
+
if (slotState.state === 'linked') {
|
|
131
|
+
results.push({ dir, action: 'already-linked', target: expectedTarget });
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (slotState.state === 'wrong-link') {
|
|
135
|
+
throw new SharedDirError('HAZO_ENV_SHARED_DIR_WRONG_LINK', dir, `Shared dir "${dir}" at ${fullPath} is a symlink to "${slotState.linkTarget}", not the expected target "${expectedTarget}". Refusing to touch it — remove the link by hand, or run "hazo-env deploy share" to adopt it.`);
|
|
136
|
+
}
|
|
137
|
+
if (slotState.state === 'real-dir') {
|
|
138
|
+
throw new SharedDirError('HAZO_ENV_SHARED_DIR_REAL_DIR', dir, `Shared dir "${dir}" at ${fullPath} is a real directory with ${slotState.fileCount} file(s). Refusing to replace it with a link — run "hazo-env deploy share" to migrate its contents first.`);
|
|
139
|
+
}
|
|
140
|
+
if (slotState.state === 'empty-dir') {
|
|
141
|
+
if (!opts.allowReplaceEmpty) {
|
|
142
|
+
throw new SharedDirError('HAZO_ENV_SHARED_DIR_EMPTY_DIR', dir, `Shared dir "${dir}" at ${fullPath} is an empty real directory, not a link. Pass allowReplaceEmpty to replace it, or run "hazo-env deploy share".`);
|
|
143
|
+
}
|
|
144
|
+
fs.mkdirSync(expectedTarget, { recursive: true });
|
|
145
|
+
fs.rmdirSync(fullPath);
|
|
146
|
+
fs.symlinkSync(expectedTarget, fullPath, 'dir');
|
|
147
|
+
results.push({ dir, action: 'replaced-empty', target: expectedTarget });
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
// slotState.state === 'missing'
|
|
151
|
+
if (!opts.allowCreate) {
|
|
152
|
+
throw new SharedDirError('HAZO_ENV_SHARED_DIR_MISSING', dir, `Shared dir "${dir}" is missing at ${fullPath}. Pass allowCreate to create the link, or run "hazo-env deploy init".`);
|
|
153
|
+
}
|
|
154
|
+
fs.mkdirSync(expectedTarget, { recursive: true });
|
|
155
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
156
|
+
fs.symlinkSync(expectedTarget, fullPath, 'dir');
|
|
157
|
+
results.push({ dir, action: 'created', target: expectedTarget });
|
|
158
|
+
}
|
|
159
|
+
return results;
|
|
160
|
+
}
|
|
161
|
+
/** sha256 + size compare — cheap size check first, full hash only when sizes match. */
|
|
162
|
+
function filesIdentical(pathA, pathB) {
|
|
163
|
+
const statA = fs.statSync(pathA);
|
|
164
|
+
const statB = fs.statSync(pathB);
|
|
165
|
+
if (statA.size !== statB.size)
|
|
166
|
+
return false;
|
|
167
|
+
const hash = (p) => crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
|
|
168
|
+
return hash(pathA) === hash(pathB);
|
|
169
|
+
}
|
|
170
|
+
/** Copy a file, preserving its mtime and mode (user story 14). Creates the destination's parent dirs. */
|
|
171
|
+
function copyFilePreserving(src, dest) {
|
|
172
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
173
|
+
fs.copyFileSync(src, dest);
|
|
174
|
+
const st = fs.statSync(src);
|
|
175
|
+
fs.utimesSync(dest, st.atime, st.mtime);
|
|
176
|
+
fs.chmodSync(dest, st.mode);
|
|
177
|
+
}
|
|
178
|
+
/** Recursively list regular files under `baseDir`, as paths relative to it. `[]` if `baseDir` doesn't exist. Nested symlinks are skipped (not expected inside an uploads-style shared dir; never followed). */
|
|
179
|
+
function listFilesRecursive(baseDir, subDir = '') {
|
|
180
|
+
const fullDir = path.join(baseDir, subDir);
|
|
181
|
+
let entries;
|
|
182
|
+
try {
|
|
183
|
+
entries = fs.readdirSync(fullDir, { withFileTypes: true });
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
const results = [];
|
|
189
|
+
for (const entry of entries) {
|
|
190
|
+
const relPath = path.join(subDir, entry.name);
|
|
191
|
+
if (entry.isDirectory()) {
|
|
192
|
+
results.push(...listFilesRecursive(baseDir, relPath));
|
|
193
|
+
}
|
|
194
|
+
else if (entry.isFile()) {
|
|
195
|
+
results.push(relPath);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return results;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Park a losing/incoming source file under
|
|
202
|
+
* `shared_root/.conflicts/<slot-basename>/<dir>/<relPath>` (user story 10).
|
|
203
|
+
* Never touches the source. `slotLabel` is the SLOT's own basename (e.g.
|
|
204
|
+
* "gotimer-green"), not the shared dir's — callers must pass the slot root
|
|
205
|
+
* dir's basename, never a deeper source path's.
|
|
206
|
+
*/
|
|
207
|
+
function parkConflictFile(config, slotLabel, dir, relPath, sourcePath, dryRun) {
|
|
208
|
+
const conflictDest = path.join(config.shared_root, '.conflicts', slotLabel, dir, relPath);
|
|
209
|
+
if (!dryRun)
|
|
210
|
+
copyFilePreserving(sourcePath, conflictDest);
|
|
211
|
+
return conflictDest;
|
|
212
|
+
}
|
|
213
|
+
function conflictWarning(dir, relPath, conflictDest) {
|
|
214
|
+
return (`"${dir}/${path.normalize(relPath)}" already exists in the shared target with different content — ` +
|
|
215
|
+
`parked the incoming copy at ${conflictDest} instead of overwriting it.`);
|
|
216
|
+
}
|
|
217
|
+
function mergeFilesIntoTarget(standby, live, targetDir, dir, config, dryRun) {
|
|
218
|
+
const outcome = {
|
|
219
|
+
filesFromLive: 0,
|
|
220
|
+
filesFromStandby: 0,
|
|
221
|
+
identical: 0,
|
|
222
|
+
conflicts: 0,
|
|
223
|
+
conflictFiles: [],
|
|
224
|
+
warnings: [],
|
|
225
|
+
};
|
|
226
|
+
const standbySet = new Set(standby.files);
|
|
227
|
+
const liveSet = new Set(live.files);
|
|
228
|
+
function copyUniqueIntoTarget(relPath, sourcePath, slotLabel, category) {
|
|
229
|
+
const destPath = path.join(targetDir, relPath);
|
|
230
|
+
if (fs.existsSync(destPath)) {
|
|
231
|
+
if (filesIdentical(sourcePath, destPath)) {
|
|
232
|
+
outcome.identical++;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const conflictDest = parkConflictFile(config, slotLabel, dir, relPath, sourcePath, dryRun);
|
|
236
|
+
outcome.conflicts++;
|
|
237
|
+
outcome.conflictFiles.push(conflictDest);
|
|
238
|
+
outcome.warnings.push(conflictWarning(dir, relPath, conflictDest));
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!dryRun)
|
|
242
|
+
copyFilePreserving(sourcePath, destPath);
|
|
243
|
+
if (category === 'live')
|
|
244
|
+
outcome.filesFromLive++;
|
|
245
|
+
else
|
|
246
|
+
outcome.filesFromStandby++;
|
|
247
|
+
}
|
|
248
|
+
// Files unique to standby.
|
|
249
|
+
for (const relPath of standby.files) {
|
|
250
|
+
if (liveSet.has(relPath))
|
|
251
|
+
continue;
|
|
252
|
+
copyUniqueIntoTarget(relPath, path.join(standby.sourceDir, relPath), standby.slotLabel, 'standby');
|
|
253
|
+
}
|
|
254
|
+
// Files unique to live.
|
|
255
|
+
for (const relPath of live.files) {
|
|
256
|
+
if (standbySet.has(relPath))
|
|
257
|
+
continue;
|
|
258
|
+
copyUniqueIntoTarget(relPath, path.join(live.sourceDir, relPath), live.slotLabel, 'live');
|
|
259
|
+
}
|
|
260
|
+
// Files present in both slots: dedupe identical content, or live-wins + park standby's.
|
|
261
|
+
for (const relPath of live.files) {
|
|
262
|
+
if (!standbySet.has(relPath))
|
|
263
|
+
continue;
|
|
264
|
+
const standbyPath = path.join(standby.sourceDir, relPath);
|
|
265
|
+
const livePath = path.join(live.sourceDir, relPath);
|
|
266
|
+
const destPath = path.join(targetDir, relPath);
|
|
267
|
+
const bothIdentical = filesIdentical(standbyPath, livePath);
|
|
268
|
+
if (bothIdentical) {
|
|
269
|
+
if (fs.existsSync(destPath)) {
|
|
270
|
+
if (filesIdentical(livePath, destPath)) {
|
|
271
|
+
outcome.identical++;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const conflictDest = parkConflictFile(config, live.slotLabel, dir, relPath, livePath, dryRun);
|
|
275
|
+
outcome.conflicts++;
|
|
276
|
+
outcome.conflictFiles.push(conflictDest);
|
|
277
|
+
outcome.warnings.push(conflictWarning(dir, relPath, conflictDest));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
if (!dryRun)
|
|
282
|
+
copyFilePreserving(livePath, destPath);
|
|
283
|
+
outcome.identical++;
|
|
284
|
+
}
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
// Differ between slots: live wins into target (subject to the same
|
|
288
|
+
// never-overwrite-target rule); standby's version is ALWAYS parked,
|
|
289
|
+
// independent of what happened to live's.
|
|
290
|
+
if (fs.existsSync(destPath)) {
|
|
291
|
+
if (!filesIdentical(livePath, destPath)) {
|
|
292
|
+
const conflictDest = parkConflictFile(config, live.slotLabel, dir, relPath, livePath, dryRun);
|
|
293
|
+
outcome.conflicts++;
|
|
294
|
+
outcome.conflictFiles.push(conflictDest);
|
|
295
|
+
outcome.warnings.push(conflictWarning(dir, relPath, conflictDest));
|
|
296
|
+
}
|
|
297
|
+
// else: target already holds live's content (idempotent re-run) — nothing to do for the live side.
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
if (!dryRun)
|
|
301
|
+
copyFilePreserving(livePath, destPath);
|
|
302
|
+
outcome.filesFromLive++;
|
|
303
|
+
}
|
|
304
|
+
const standbyConflictDest = parkConflictFile(config, standby.slotLabel, dir, relPath, standbyPath, dryRun);
|
|
305
|
+
outcome.conflicts++;
|
|
306
|
+
outcome.conflictFiles.push(standbyConflictDest);
|
|
307
|
+
}
|
|
308
|
+
return outcome;
|
|
309
|
+
}
|
|
310
|
+
function backupSuffix(now) {
|
|
311
|
+
return now.toISOString().replace(/[:.]/g, '-');
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Ensure a single slot's shared-dir path is a symlink to `target`, handling
|
|
315
|
+
* every state `inspectOneDir` can report:
|
|
316
|
+
*
|
|
317
|
+
* - `linked`: no-op.
|
|
318
|
+
* - `wrong-link`: throws `SharedDirError` — `deploy share` refuses to
|
|
319
|
+
* clobber a hand-made link to somewhere else (user story 18).
|
|
320
|
+
* - `missing`: the path (and any missing parent dirs) is created directly
|
|
321
|
+
* as a symlink — there's nothing to preserve (user story 21).
|
|
322
|
+
* - `real-dir` / `empty-dir`: the directory is renamed aside to
|
|
323
|
+
* `<dir>.pre-share-<timestamp>` (never deleted) and the symlink is
|
|
324
|
+
* created in its place (user stories 12/13).
|
|
325
|
+
*
|
|
326
|
+
* `backupDir`'s planned name is still returned in dry-run mode (for the
|
|
327
|
+
* report) even though nothing is actually renamed.
|
|
328
|
+
*/
|
|
329
|
+
/**
|
|
330
|
+
* Shared `wrong-link` guard for `deploy share` — thrown both by the
|
|
331
|
+
* pre-flight validation pass (before anything is touched) and by
|
|
332
|
+
* `swapSlotToLink` itself (belt-and-suspenders: the pre-flight pass already
|
|
333
|
+
* catches this for every configured dir, but a direct caller of
|
|
334
|
+
* `swapSlotToLink` should still get a safe refusal, not a corrupted symlink).
|
|
335
|
+
*/
|
|
336
|
+
function assertNotWrongLink(state, slotDescription, fullPath, dir, target) {
|
|
337
|
+
if (state.state !== 'wrong-link')
|
|
338
|
+
return;
|
|
339
|
+
throw new SharedDirError('HAZO_ENV_SHARED_DIR_WRONG_LINK', dir, `Shared dir "${dir}" ${slotDescription} (${fullPath}) is a symlink to "${state.linkTarget}", not the expected target "${target}". ` +
|
|
340
|
+
`Refusing to run "deploy share" — remove the link by hand first if it's stale.`);
|
|
341
|
+
}
|
|
342
|
+
function swapSlotToLink(slotRootDir, dir, target, now, dryRun) {
|
|
343
|
+
const fullPath = path.join(slotRootDir, dir);
|
|
344
|
+
const state = inspectOneDir(slotRootDir, dir, target);
|
|
345
|
+
if (state.state === 'linked')
|
|
346
|
+
return { action: 'already-linked' };
|
|
347
|
+
assertNotWrongLink(state, 'at', fullPath, dir, target);
|
|
348
|
+
if (state.state === 'missing') {
|
|
349
|
+
if (!dryRun) {
|
|
350
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
351
|
+
fs.symlinkSync(target, fullPath, 'dir');
|
|
352
|
+
}
|
|
353
|
+
return { action: 'created' };
|
|
354
|
+
}
|
|
355
|
+
// real-dir or empty-dir: rename aside (never delete), then symlink.
|
|
356
|
+
const backupDir = `${fullPath}.pre-share-${backupSuffix(now)}`;
|
|
357
|
+
if (!dryRun) {
|
|
358
|
+
fs.renameSync(fullPath, backupDir);
|
|
359
|
+
fs.symlinkSync(target, fullPath, 'dir');
|
|
360
|
+
}
|
|
361
|
+
return { action: 'swapped', backupDir };
|
|
362
|
+
}
|
|
363
|
+
function migrateOneDir(config, dir, liveRoot, standbyRoot, dryRun, now) {
|
|
364
|
+
const target = path.join(config.shared_root, dir);
|
|
365
|
+
const liveState = inspectOneDir(liveRoot, dir, target);
|
|
366
|
+
const standbyState = standbyRoot ? inspectOneDir(standbyRoot, dir, target) : undefined;
|
|
367
|
+
const report = {
|
|
368
|
+
dir,
|
|
369
|
+
target,
|
|
370
|
+
filesFromLive: 0,
|
|
371
|
+
filesFromStandby: 0,
|
|
372
|
+
identical: 0,
|
|
373
|
+
conflicts: 0,
|
|
374
|
+
conflictFiles: [],
|
|
375
|
+
liveAction: 'linked',
|
|
376
|
+
standbyAction: standbyRoot ? 'linked' : 'no-peer',
|
|
377
|
+
lateMergedFiles: 0,
|
|
378
|
+
warnings: [],
|
|
379
|
+
};
|
|
380
|
+
const liveAlreadyLinked = liveState.state === 'linked';
|
|
381
|
+
const standbyAlreadyLinked = !standbyRoot || standbyState?.state === 'linked';
|
|
382
|
+
if (liveAlreadyLinked && standbyAlreadyLinked) {
|
|
383
|
+
// Fully migrated already (user story 16: idempotent re-run) — nothing to merge or swap.
|
|
384
|
+
report.liveAction = 'already-linked';
|
|
385
|
+
if (standbyRoot)
|
|
386
|
+
report.standbyAction = 'already-linked';
|
|
387
|
+
return report;
|
|
388
|
+
}
|
|
389
|
+
if (!dryRun) {
|
|
390
|
+
fs.mkdirSync(target, { recursive: true });
|
|
391
|
+
}
|
|
392
|
+
const standbySourceDir = standbyState && (standbyState.state === 'real-dir' || standbyState.state === 'empty-dir')
|
|
393
|
+
? path.join(standbyRoot, dir)
|
|
394
|
+
: undefined;
|
|
395
|
+
const liveSourceDir = liveState.state === 'real-dir' || liveState.state === 'empty-dir' ? path.join(liveRoot, dir) : undefined;
|
|
396
|
+
// Slot labels for conflict parking (`.conflicts/<slot-basename>/...`) —
|
|
397
|
+
// always the SLOT root's own basename (e.g. "gotimer-green"), never a
|
|
398
|
+
// deeper shared-dir path's, and stay the same for the late-merge pass
|
|
399
|
+
// below even though it reads from the renamed backup dir instead.
|
|
400
|
+
const standbySlotLabel = standbyRoot ? path.basename(standbyRoot) : 'standby';
|
|
401
|
+
const liveSlotLabel = path.basename(liveRoot);
|
|
402
|
+
const standbyFilesAtMergeTime = standbySourceDir ? listFilesRecursive(standbySourceDir) : [];
|
|
403
|
+
const liveFilesAtMergeTime = liveSourceDir ? listFilesRecursive(liveSourceDir) : [];
|
|
404
|
+
const merge = mergeFilesIntoTarget({ files: standbyFilesAtMergeTime, sourceDir: standbySourceDir, slotLabel: standbySlotLabel }, { files: liveFilesAtMergeTime, sourceDir: liveSourceDir, slotLabel: liveSlotLabel }, target, dir, config, dryRun);
|
|
405
|
+
report.filesFromLive = merge.filesFromLive;
|
|
406
|
+
report.filesFromStandby = merge.filesFromStandby;
|
|
407
|
+
report.identical = merge.identical;
|
|
408
|
+
report.conflicts = merge.conflicts;
|
|
409
|
+
report.conflictFiles.push(...merge.conflictFiles);
|
|
410
|
+
report.warnings.push(...merge.warnings);
|
|
411
|
+
// Swap standby first, live last (user story 12) — the running (live) app
|
|
412
|
+
// sees its folder replaced as late and as briefly as possible.
|
|
413
|
+
let standbyBackupDir;
|
|
414
|
+
if (standbyRoot) {
|
|
415
|
+
const standbySwap = swapSlotToLink(standbyRoot, dir, target, now, dryRun);
|
|
416
|
+
report.standbyAction = standbySwap.action === 'already-linked' ? 'already-linked' : 'linked';
|
|
417
|
+
standbyBackupDir = standbySwap.backupDir;
|
|
418
|
+
if (standbyBackupDir)
|
|
419
|
+
report.standbyBackupDir = standbyBackupDir;
|
|
420
|
+
}
|
|
421
|
+
const liveSwap = swapSlotToLink(liveRoot, dir, target, now, dryRun);
|
|
422
|
+
report.liveAction = liveSwap.action === 'already-linked' ? 'already-linked' : 'linked';
|
|
423
|
+
if (liveSwap.backupDir)
|
|
424
|
+
report.liveBackupDir = liveSwap.backupDir;
|
|
425
|
+
// Late-write re-scan (user story: backups re-scanned for late writes): a
|
|
426
|
+
// file written into the real dir between the initial merge scan above and
|
|
427
|
+
// the rename-to-backup just now would otherwise be stranded in the backup
|
|
428
|
+
// dir, invisible through the new symlink. Only meaningful (and only run)
|
|
429
|
+
// for a real apply — dry-run never created a backup dir to rescan.
|
|
430
|
+
//
|
|
431
|
+
// The backup dir is the exact same directory that was just scanned and
|
|
432
|
+
// merged above (rename doesn't remove any content) — re-scanning it whole
|
|
433
|
+
// would re-merge every already-merged file a second time. Diff against
|
|
434
|
+
// the file lists captured at merge time so only genuinely NEW relPaths
|
|
435
|
+
// (written during the rename race window) go through the merge again.
|
|
436
|
+
const standbyFilesAfterSwap = standbyBackupDir ? listFilesRecursive(standbyBackupDir) : [];
|
|
437
|
+
const liveFilesAfterSwap = liveSwap.backupDir ? listFilesRecursive(liveSwap.backupDir) : [];
|
|
438
|
+
const standbyAlreadyMergedSet = new Set(standbyFilesAtMergeTime);
|
|
439
|
+
const liveAlreadyMergedSet = new Set(liveFilesAtMergeTime);
|
|
440
|
+
const lateStandbyFiles = standbyFilesAfterSwap.filter((p) => !standbyAlreadyMergedSet.has(p));
|
|
441
|
+
const lateLiveFiles = liveFilesAfterSwap.filter((p) => !liveAlreadyMergedSet.has(p));
|
|
442
|
+
if (!dryRun && (lateStandbyFiles.length || lateLiveFiles.length)) {
|
|
443
|
+
const lateMerge = mergeFilesIntoTarget({ files: lateStandbyFiles, sourceDir: standbyBackupDir, slotLabel: standbySlotLabel }, { files: lateLiveFiles, sourceDir: liveSwap.backupDir, slotLabel: liveSlotLabel }, target, dir, config, false);
|
|
444
|
+
report.filesFromLive += lateMerge.filesFromLive;
|
|
445
|
+
report.filesFromStandby += lateMerge.filesFromStandby;
|
|
446
|
+
report.identical += lateMerge.identical;
|
|
447
|
+
report.conflicts += lateMerge.conflicts;
|
|
448
|
+
report.conflictFiles.push(...lateMerge.conflictFiles);
|
|
449
|
+
report.warnings.push(...lateMerge.warnings);
|
|
450
|
+
report.lateMergedFiles = lateMerge.filesFromLive + lateMerge.filesFromStandby;
|
|
451
|
+
}
|
|
452
|
+
return report;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* One-time migration: merge whatever is already on disk in `opts.live` (and
|
|
456
|
+
* `opts.standby`, when present) into `config.shared_root`, then replace each
|
|
457
|
+
* slot's real directory with a symlink to it. See this file's header above
|
|
458
|
+
* (and `.scratch/deploy-shared-dirs/issues/02-deploy-share-migration.md`)
|
|
459
|
+
* for the full behavior. Idempotent — re-running after a successful run (or
|
|
460
|
+
* after a `--dry-run`) is safe; already-linked dirs are reported as such and
|
|
461
|
+
* untouched.
|
|
462
|
+
*
|
|
463
|
+
* Validates every configured dir's live/standby state BEFORE writing
|
|
464
|
+
* anything: if any dir has a `wrong-link` in either slot, the whole call
|
|
465
|
+
* throws `SharedDirError` without touching ANY dir (even ones that would
|
|
466
|
+
* otherwise have been fine) — a destructive-adjacent migration should fail
|
|
467
|
+
* atomically rather than leave some dirs migrated and others not because a
|
|
468
|
+
* later one hit a problem it can't safely resolve on its own.
|
|
469
|
+
*/
|
|
470
|
+
export function migrateSharedDirs(config, opts) {
|
|
471
|
+
const dryRun = opts.dryRun ?? false;
|
|
472
|
+
const liveRoot = opts.live;
|
|
473
|
+
const standbyRoot = opts.standby;
|
|
474
|
+
const now = new Date();
|
|
475
|
+
for (const dir of config.shared_dirs) {
|
|
476
|
+
const target = path.join(config.shared_root, dir);
|
|
477
|
+
const liveState = inspectOneDir(liveRoot, dir, target);
|
|
478
|
+
assertNotWrongLink(liveState, 'in the live slot', path.join(liveRoot, dir), dir, target);
|
|
479
|
+
if (standbyRoot) {
|
|
480
|
+
const standbyState = inspectOneDir(standbyRoot, dir, target);
|
|
481
|
+
assertNotWrongLink(standbyState, 'in the standby slot', path.join(standbyRoot, dir), dir, target);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const dirs = config.shared_dirs.map((dir) => migrateOneDir(config, dir, liveRoot, standbyRoot, dryRun, now));
|
|
485
|
+
return { dryRun, dirs };
|
|
486
|
+
}
|
package/dist/deploy/status.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandRunner, DeployConfig } from './types.js';
|
|
2
|
+
import type { SharedDirInspection } from './shared-dirs.js';
|
|
2
3
|
/** Snapshot of one directory's role in the blue/green pair. */
|
|
3
4
|
export interface DeployDirStatus {
|
|
4
5
|
role: 'live' | 'standby';
|
|
@@ -40,6 +41,13 @@ export interface DeployStatusResult {
|
|
|
40
41
|
pm_cwd?: string;
|
|
41
42
|
stale: boolean;
|
|
42
43
|
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Per-dir, per-slot state for each `config.shared_dirs` entry (see
|
|
46
|
+
* shared-dirs.ts). `[]` when `shared_dirs` is empty (feature unused) or
|
|
47
|
+
* when `!stateFound` (live/standby dirs aren't known yet) — same
|
|
48
|
+
* convention as `sidecars`.
|
|
49
|
+
*/
|
|
50
|
+
sharedDirs: SharedDirInspection[];
|
|
43
51
|
/** Non-fatal problems encountered while gathering status (pm2 unavailable, unparsable df output, ...). */
|
|
44
52
|
warnings: string[];
|
|
45
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/deploy/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/deploy/status.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC;;;;;;;;;OASG;IACH,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvH;;;;;OAKG;IACH,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,0GAA0G;IAC1G,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAoID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAe/F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAO1G;AAED,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE,gBAAqB,GAC1B,kBAAkB,CA4DpB"}
|
package/dist/deploy/status.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// does the printing, this file only returns data.
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { readState } from './state.js';
|
|
11
|
+
import { inspectSharedDirs } from './shared-dirs.js';
|
|
11
12
|
/**
|
|
12
13
|
* Query `pm2 jlist` and parse the JSON process list. Returns an empty list
|
|
13
14
|
* (plus a warning) rather than throwing when pm2 isn't installed/running or
|
|
@@ -176,6 +177,7 @@ export function runStatus(config, runner, opts = {}) {
|
|
|
176
177
|
minMemoryMb: config.min_memory_mb,
|
|
177
178
|
memoryLow,
|
|
178
179
|
sidecars: [],
|
|
180
|
+
sharedDirs: [],
|
|
179
181
|
warnings,
|
|
180
182
|
};
|
|
181
183
|
}
|
|
@@ -193,6 +195,9 @@ export function runStatus(config, runner, opts = {}) {
|
|
|
193
195
|
stale: !!proc && (pmCwd === undefined || path.resolve(pmCwd) !== liveDirResolved),
|
|
194
196
|
};
|
|
195
197
|
});
|
|
198
|
+
const sharedDirs = config.shared_dirs.length > 0
|
|
199
|
+
? inspectSharedDirs(config, { live: state.live_dir, standby: state.standby_dir })
|
|
200
|
+
: [];
|
|
196
201
|
return {
|
|
197
202
|
appName: config.app_name,
|
|
198
203
|
stateFound: true,
|
|
@@ -206,6 +211,7 @@ export function runStatus(config, runner, opts = {}) {
|
|
|
206
211
|
lastBuild: state.last_build,
|
|
207
212
|
lastBuildStatus: state.last_build_status,
|
|
208
213
|
sidecars,
|
|
214
|
+
sharedDirs,
|
|
209
215
|
warnings,
|
|
210
216
|
};
|
|
211
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/deploy/switch.ts"],"names":[],"mappings":"AA8DA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/deploy/switch.ts"],"names":[],"mappings":"AA8DA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAa3E,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,cAAc,EAAE,OAAO,CAAC;IACxB,2FAA2F;IAC3F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,8GAA8G;IAC9G,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,KAAK,EAAE,WAAW,CAAC;IACnB;;;;;;OAMG;IACH,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,uFAAuF;AACvF,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CAoJnH"}
|
package/dist/deploy/switch.js
CHANGED
|
@@ -60,6 +60,17 @@ import path from 'node:path';
|
|
|
60
60
|
import { readState, updateState } from './state.js';
|
|
61
61
|
import { promoteDirFresh, PromoteDirFreshError } from './pm2-start.js';
|
|
62
62
|
import { syncSidecars } from './sidecar.js';
|
|
63
|
+
import { inspectSharedDirs } from './shared-dirs.js';
|
|
64
|
+
/**
|
|
65
|
+
* Describe every `shared_dirs` entry that isn't `linked` in BOTH slots, for
|
|
66
|
+
* the abort message below. `[]` means every entry is fully linked in both
|
|
67
|
+
* — safe to promote.
|
|
68
|
+
*/
|
|
69
|
+
function describeSharedDirDrift(inspections) {
|
|
70
|
+
return inspections
|
|
71
|
+
.filter((i) => i.live.state !== 'linked' || i.standby.state !== 'linked')
|
|
72
|
+
.map((i) => `"${i.dir}" (live=${i.live.state}, standby=${i.standby.state})`);
|
|
73
|
+
}
|
|
63
74
|
/** Thrown when there's nothing to switch (no state file yet) or a fatal step fails. */
|
|
64
75
|
export class SwitchAbortError extends Error {
|
|
65
76
|
constructor(message) {
|
|
@@ -98,6 +109,20 @@ export function runSwitch(config, runner, opts = {}) {
|
|
|
98
109
|
}
|
|
99
110
|
const oldLiveDir = path.resolve(state.live_dir);
|
|
100
111
|
const oldStandbyDir = path.resolve(state.standby_dir);
|
|
112
|
+
// Shared dirs (ticket 03, deploy-shared-dirs spec, user story 27):
|
|
113
|
+
// re-verify both slots' shared-dir links before promoting — a switch must
|
|
114
|
+
// never land on a slot with private, unlinked uploads. Unlike build.ts's
|
|
115
|
+
// `ensureLinks` (which self-heals), this is read-only (`inspectSharedDirs`)
|
|
116
|
+
// and ANY non-`linked` state in either slot aborts; only `--force` (the
|
|
117
|
+
// same flag that already bypasses the build-recency check above) can
|
|
118
|
+
// override it. A no-op when shared_dirs is empty (feature off).
|
|
119
|
+
if (config.shared_dirs.length > 0 && !opts.force) {
|
|
120
|
+
const drift = describeSharedDirDrift(inspectSharedDirs(config, { live: oldLiveDir, standby: oldStandbyDir }));
|
|
121
|
+
if (drift.length > 0) {
|
|
122
|
+
throw new SwitchAbortError(`Shared dir(s) not fully linked in both slots: ${drift.join(', ')}. Run "hazo-env deploy share" to fix, ` +
|
|
123
|
+
`or pass --force to override.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
101
126
|
// Step 2: read the new live dir's git ref FIRST, before anything is
|
|
102
127
|
// stopped/started — read-only, so no ordering reason to delay it, and
|
|
103
128
|
// delaying it risks a late failure leaving state stale relative to a
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -52,6 +52,24 @@ export interface DeployConfig {
|
|
|
52
52
|
* "npx tsc --noEmit -p tsconfig.verify.json" to exclude test files.
|
|
53
53
|
*/
|
|
54
54
|
verify_tsc_cmd: string;
|
|
55
|
+
/**
|
|
56
|
+
* Absolute directory, outside both slot dirs, that persistent folders
|
|
57
|
+
* (`shared_dirs`) are symlinked from into each slot. `~` is expanded.
|
|
58
|
+
* Default: `~/<app_name>-shared`. Always resolved/absolute — see
|
|
59
|
+
* resolve/deploy.ts's validation (must be absolute, outside both the
|
|
60
|
+
* current and peer slot dirs).
|
|
61
|
+
*/
|
|
62
|
+
shared_root: string;
|
|
63
|
+
/**
|
|
64
|
+
* Slot-relative folders (e.g. `var/uploads`) that must persist across
|
|
65
|
+
* blue-green slots instead of being duplicated per clone — see
|
|
66
|
+
* shared-dirs.ts. Comma-separated in the INI. Default: [] (feature off;
|
|
67
|
+
* every other deploy command behaves exactly as before this field
|
|
68
|
+
* existed). Validated: no absolute paths, no `..` traversal, no
|
|
69
|
+
* duplicates, no entry nested inside another, and (when the resolved db
|
|
70
|
+
* strategy is "copy") none containing the sqlite db path.
|
|
71
|
+
*/
|
|
72
|
+
shared_dirs: string[];
|
|
55
73
|
}
|
|
56
74
|
/** Result of a single command execution. */
|
|
57
75
|
export interface CommandResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/deploy/types.ts"],"names":[],"mappings":"AAMA,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,0GAA0G;IAC1G,QAAQ,EAAE,MAAM,CAAC;IACjB,gHAAgH;IAChH,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,aAAa,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IACxC,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAg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