hazo_env 0.15.3 → 0.17.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.
Files changed (67) hide show
  1. package/CHANGE_LOG.md +120 -0
  2. package/README.md +333 -0
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +17 -0
  6. package/dist/cli.js +178 -17
  7. package/dist/deploy/build.d.ts +1 -1
  8. package/dist/deploy/build.d.ts.map +1 -1
  9. package/dist/deploy/build.js +51 -14
  10. package/dist/deploy/clean.d.ts +2 -1
  11. package/dist/deploy/clean.d.ts.map +1 -1
  12. package/dist/deploy/clean.js +36 -6
  13. package/dist/deploy/generate-readme-cli.d.ts +3 -0
  14. package/dist/deploy/generate-readme-cli.d.ts.map +1 -0
  15. package/dist/deploy/generate-readme-cli.js +40 -0
  16. package/dist/deploy/help.d.ts +55 -0
  17. package/dist/deploy/help.d.ts.map +1 -0
  18. package/dist/deploy/help.js +545 -0
  19. package/dist/deploy/idle-slots.d.ts +42 -0
  20. package/dist/deploy/idle-slots.d.ts.map +1 -0
  21. package/dist/deploy/idle-slots.js +136 -0
  22. package/dist/deploy/index.d.ts +5 -0
  23. package/dist/deploy/index.d.ts.map +1 -1
  24. package/dist/deploy/index.js +5 -0
  25. package/dist/deploy/init.d.ts +14 -0
  26. package/dist/deploy/init.d.ts.map +1 -1
  27. package/dist/deploy/init.js +14 -1
  28. package/dist/deploy/preflight.d.ts +26 -0
  29. package/dist/deploy/preflight.d.ts.map +1 -0
  30. package/dist/deploy/preflight.js +91 -0
  31. package/dist/deploy/rollback.d.ts +10 -1
  32. package/dist/deploy/rollback.d.ts.map +1 -1
  33. package/dist/deploy/rollback.js +25 -1
  34. package/dist/deploy/share.d.ts +28 -0
  35. package/dist/deploy/share.d.ts.map +1 -0
  36. package/dist/deploy/share.js +53 -0
  37. package/dist/deploy/shared-dirs.d.ts +128 -0
  38. package/dist/deploy/shared-dirs.d.ts.map +1 -0
  39. package/dist/deploy/shared-dirs.js +486 -0
  40. package/dist/deploy/status.d.ts +8 -0
  41. package/dist/deploy/status.d.ts.map +1 -1
  42. package/dist/deploy/status.js +6 -0
  43. package/dist/deploy/switch.d.ts.map +1 -1
  44. package/dist/deploy/switch.js +25 -0
  45. package/dist/deploy/types.d.ts +18 -0
  46. package/dist/deploy/types.d.ts.map +1 -1
  47. package/dist/deploy/verify.d.ts.map +1 -1
  48. package/dist/deploy/verify.js +7 -1
  49. package/dist/envsync/engine.d.ts.map +1 -1
  50. package/dist/envsync/engine.js +21 -7
  51. package/dist/envsync/paths.d.ts +22 -0
  52. package/dist/envsync/paths.d.ts.map +1 -1
  53. package/dist/envsync/paths.js +55 -0
  54. package/dist/peer-hint.d.ts +8 -0
  55. package/dist/peer-hint.d.ts.map +1 -0
  56. package/dist/peer-hint.js +49 -0
  57. package/dist/resolve/config-hint.d.ts +2 -0
  58. package/dist/resolve/config-hint.d.ts.map +1 -0
  59. package/dist/resolve/config-hint.js +23 -0
  60. package/dist/resolve/connect.d.ts.map +1 -1
  61. package/dist/resolve/connect.js +2 -1
  62. package/dist/resolve/deploy.d.ts.map +1 -1
  63. package/dist/resolve/deploy.js +167 -1
  64. package/dist/resolve/envsync.d.ts +16 -0
  65. package/dist/resolve/envsync.d.ts.map +1 -1
  66. package/dist/resolve/envsync.js +19 -0
  67. package/package.json +4 -3
@@ -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;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3E,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,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AC;CACjB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CAoJnH"}
@@ -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
@@ -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;IAC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AW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG"}
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/deploy/verify.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAe9D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,YAAY,GAAG,kBAAkB,CAAC;AAC3E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0FAA0F;IAC1F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,2FAA2F;IAC3F,SAAS,EAAE,OAAO,CAAC;CACpB;AAiID;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CA2DnH"}
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/deploy/verify.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAe9D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,YAAY,GAAG,kBAAkB,CAAC;AAC3E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0FAA0F;IAC1F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,2FAA2F;IAC3F,SAAS,EAAE,OAAO,CAAC;CACpB;AAoID;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CAgEnH"}
@@ -145,6 +145,8 @@ function checkMigrationParity(cwd, liveDir) {
145
145
  .join('; ');
146
146
  return { name: 'migration-parity', status: 'fail', detail };
147
147
  }
148
+ /** curl's exit code for "connection refused", as reported by checkHealth. */
149
+ const CURL_CONNECTION_REFUSED = 'curl_exit_7';
148
150
  /**
149
151
  * Run all three verify checks against `cwd` (the standby directory, which
150
152
  * should already be running on `config.staging_port`). Every check runs
@@ -172,7 +174,11 @@ export function runVerify(config, runner, opts = {}) {
172
174
  checks.push({
173
175
  name: 'health',
174
176
  status: 'fail',
175
- detail: `${healthUrl} returned "${result.lastCode}" (expected 200) after ${attempts} attempt(s).`,
177
+ detail: `${healthUrl} returned "${result.lastCode}" (expected 200) after ${attempts} attempt(s).` +
178
+ (result.lastCode === CURL_CONNECTION_REFUSED
179
+ ? ` Nothing is listening on staging port ${config.staging_port} — run "hazo-env deploy build" first ` +
180
+ `(it starts the standby app as "${config.app_name}-staging"), or check "pm2 ls".`
181
+ : ''),
176
182
  });
177
183
  }
178
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/envsync/engine.ts"],"names":[],"mappings":"AAaA,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAaD;;GAEG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,aAAa,EAClB,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,GAC7E,OAAO,CAAC,iBAAiB,CAAC,CAe5B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GACnF,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CA+BvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAA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'./retention.js';
12
12
  import { assertConfirmed, assertNotProd } from './guards.js';
13
13
  import { mergeEnvOverrides, diffEnvAgainstCurrent, parseDotenvText, resolveFinalEnv, serializeDotenv, } from './dotenv-merge.js';
14
- import { resolveArtifactPath } from './paths.js';
14
+ import { resolveArtifactPath, resolveFilesRoot } from './paths.js';
15
15
  import { redactingProgress, redactConnectionString } from './redact.js';
16
16
  // Free-space floor checked before writing a new dump/archive into work_dir.
17
17
  // Not configurable in Phase 1 — a fixed conservative floor is good enough
@@ -87,7 +87,11 @@ export async function uploadDb(cfg, dumpPath, opts) {
87
87
  export async function downloadFiles(cfg, opts) {
88
88
  assertFreeSpace(cfg.work_dir, MIN_FREE_BYTES);
89
89
  fs.mkdirSync(cfg.work_dir, { recursive: true });
90
- fs.mkdirSync(cfg.files_root, { recursive: true });
90
+ // Confine files_root to the literal configured path or a declared
91
+ // shared-dir link (see resolveFilesRoot) BEFORE touching it — a symlink
92
+ // pointing anywhere else is rejected here, not discovered mid-archive.
93
+ const realFilesRoot = resolveFilesRoot(cfg.files_root, cfg.shared_root, cfg.shared_dirs ?? []);
94
+ fs.mkdirSync(realFilesRoot, { recursive: true });
91
95
  const id = opts?.id ?? defaultId(opts?.now);
92
96
  const filePath = path.join(cfg.work_dir, `files-${id}.tar.gz`);
93
97
  const onProgress = redactingProgress(opts?.onProgress);
@@ -97,7 +101,7 @@ export async function downloadFiles(cfg, opts) {
97
101
  const stagedEnvLocal = path.join(stageDir, ENV_LOCAL_MEMBER);
98
102
  fs.writeFileSync(stagedEnvLocal, fs.existsSync(envLocalSrc) ? fs.readFileSync(envLocalSrc) : '');
99
103
  onProgress?.(`Archiving ${cfg.files_root} -> ${filePath}`);
100
- await runCmd('tar', ['-czf', filePath, '-C', cfg.files_root, '.', '-C', stageDir, ENV_LOCAL_MEMBER], { onProgress });
104
+ await runCmd('tar', ['-czf', filePath, '-C', realFilesRoot, '.', '-C', stageDir, ENV_LOCAL_MEMBER], { onProgress });
101
105
  }
102
106
  finally {
103
107
  fs.rmSync(stageDir, { recursive: true, force: true });
@@ -135,6 +139,10 @@ export async function uploadFiles(cfg, archivePath, opts) {
135
139
  const onProgress = redactingProgress(opts.onProgress);
136
140
  // ── validate the source artifact before ANY destructive step ────────────
137
141
  const safeArchivePath = resolveArtifactPath(archivePath, cfg.work_dir, 'archive path');
142
+ // Also confine files_root itself (see resolveFilesRoot) before anything
143
+ // destructive runs — an escaping symlink is rejected up front, same as a
144
+ // bad archive path, rather than discovered after the wipe below.
145
+ const realFilesRoot = resolveFilesRoot(cfg.files_root, cfg.shared_root, cfg.shared_dirs ?? []);
138
146
  try {
139
147
  // List-only pass: proves the file is a readable tar.gz. No onProgress —
140
148
  // this would otherwise dump every member name into the operator's log.
@@ -183,16 +191,22 @@ export async function uploadFiles(cfg, archivePath, opts) {
183
191
  const ts = Date.now();
184
192
  fs.copyFileSync(targetEnvLocalPath, `${targetEnvLocalPath}.bak-${ts}`);
185
193
  }
194
+ // Wipe+recreate the REAL target, not cfg.files_root's literal path — when
195
+ // files_root is a shared-dir symlink, rm/mkdir on the literal path would
196
+ // delete the symlink itself (fs.rmSync never follows a symlink) and leave
197
+ // a private real directory in its place, silently un-sharing this slot.
198
+ // Operating on realFilesRoot clears/recreates the shared target's
199
+ // contents instead, leaving the slot's symlink untouched.
186
200
  onProgress?.(`Clearing ${cfg.files_root}...`);
187
- fs.rmSync(cfg.files_root, { recursive: true, force: true });
188
- fs.mkdirSync(cfg.files_root, { recursive: true });
201
+ fs.rmSync(realFilesRoot, { recursive: true, force: true });
202
+ fs.mkdirSync(realFilesRoot, { recursive: true });
189
203
  onProgress?.(`Extracting ${safeArchivePath} -> ${cfg.files_root}...`);
190
- await runCmd('tar', ['-xzf', safeArchivePath, '-C', cfg.files_root], { onProgress });
204
+ await runCmd('tar', ['-xzf', safeArchivePath, '-C', realFilesRoot], { onProgress });
191
205
  // __env.local extracts as a real file inside files_root — it isn't a real
192
206
  // asset, so remove it rather than trying to get tar to exclude it during
193
207
  // extraction (simplest correct approach per spec). Done regardless of
194
208
  // skipEnv: the member is in the archive either way.
195
- const extractedEnvMember = path.join(cfg.files_root, ENV_LOCAL_MEMBER);
209
+ const extractedEnvMember = path.join(realFilesRoot, ENV_LOCAL_MEMBER);
196
210
  if (fs.existsSync(extractedEnvMember))
197
211
  fs.rmSync(extractedEnvMember, { force: true });
198
212
  if (!opts.skipEnv) {
@@ -7,4 +7,26 @@
7
7
  * is empty, or resolves outside `workDir`.
8
8
  */
9
9
  export declare function resolveArtifactPath(candidate: string, workDir: string, label: string): string;
10
+ /**
11
+ * Resolve `files_root` for a downloadFiles/uploadFiles call, confining it to
12
+ * either the literal configured location (the ordinary, per-slot case) or a
13
+ * configured shared dir (`[deploy] shared_root`/`shared_dirs` — see
14
+ * ../deploy/shared-dirs.ts) that it's been symlinked into.
15
+ *
16
+ * Deliberately NOT a realpath-diff like resolveArtifactPath above: an
17
+ * ancestor directory outside envsync's control (the OS temp dir, a
18
+ * symlinked home dir, ...) can legitimately differ between its lexical and
19
+ * real form without files_root itself being the shared-dir link this check
20
+ * cares about. So this lstats files_root itself — if it isn't a symlink,
21
+ * it's the ordinary case and always in-bounds (zero behavior change for
22
+ * every app that doesn't use shared dirs); only when it IS a symlink does
23
+ * its target have to resolve into one of the configured shared dirs.
24
+ *
25
+ * Returns the path callers should use for every fs/tar operation against
26
+ * files_root: the literal path in the ordinary case, or the symlink's real
27
+ * (fully resolved) target when it's an allowed shared-dir link — so a
28
+ * destructive rm+mkdir (uploadFiles) clears and recreates the shared
29
+ * target's contents instead of deleting the slot's symlink itself.
30
+ */
31
+ export declare function resolveFilesRoot(filesRoot: string, sharedRoot: string | undefined, sharedDirs: string[]): string;
10
32
  //# sourceMappingURL=paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/envsync/paths.ts"],"names":[],"mappings":"AAiCA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkC7F"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/envsync/paths.ts"],"names":[],"mappings":"AA2CA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkC7F;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CA8BhH"}
@@ -16,8 +16,17 @@
16
16
  // inside work_dir pointing at /etc, or a `../..` traversal, both fail. The
17
17
  // resolved path is what callers should pass to the child process — that also
18
18
  // closes the symlink-swap window between check and use.
19
+ //
20
+ // resolveFilesRoot below is a second, narrower containment check for
21
+ // files_root specifically — see its own doc comment for why it's a
22
+ // lstat/readlink check rather than a realpath diff like the one above.
19
23
  import fs from 'node:fs';
20
24
  import path from 'node:path';
25
+ /** True when `child` is `parent` itself, or lives anywhere underneath it. */
26
+ function isInsideOrEqual(child, parent) {
27
+ const rel = path.relative(parent, child);
28
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
29
+ }
21
30
  function realDirOrResolve(dir) {
22
31
  try {
23
32
  return fs.realpathSync(dir);
@@ -65,3 +74,49 @@ export function resolveArtifactPath(candidate, workDir, label) {
65
74
  }
66
75
  return real;
67
76
  }
77
+ /**
78
+ * Resolve `files_root` for a downloadFiles/uploadFiles call, confining it to
79
+ * either the literal configured location (the ordinary, per-slot case) or a
80
+ * configured shared dir (`[deploy] shared_root`/`shared_dirs` — see
81
+ * ../deploy/shared-dirs.ts) that it's been symlinked into.
82
+ *
83
+ * Deliberately NOT a realpath-diff like resolveArtifactPath above: an
84
+ * ancestor directory outside envsync's control (the OS temp dir, a
85
+ * symlinked home dir, ...) can legitimately differ between its lexical and
86
+ * real form without files_root itself being the shared-dir link this check
87
+ * cares about. So this lstats files_root itself — if it isn't a symlink,
88
+ * it's the ordinary case and always in-bounds (zero behavior change for
89
+ * every app that doesn't use shared dirs); only when it IS a symlink does
90
+ * its target have to resolve into one of the configured shared dirs.
91
+ *
92
+ * Returns the path callers should use for every fs/tar operation against
93
+ * files_root: the literal path in the ordinary case, or the symlink's real
94
+ * (fully resolved) target when it's an allowed shared-dir link — so a
95
+ * destructive rm+mkdir (uploadFiles) clears and recreates the shared
96
+ * target's contents instead of deleting the slot's symlink itself.
97
+ */
98
+ export function resolveFilesRoot(filesRoot, sharedRoot, sharedDirs) {
99
+ const literal = path.resolve(filesRoot);
100
+ let st;
101
+ try {
102
+ st = fs.lstatSync(literal);
103
+ }
104
+ catch {
105
+ // Nothing on disk yet (first download/restore here) — nothing to
106
+ // resolve through; the caller will mkdir the literal path fresh.
107
+ return literal;
108
+ }
109
+ if (!st.isSymbolicLink()) {
110
+ return literal;
111
+ }
112
+ const real = fs.realpathSync(literal);
113
+ // Resolve each allowed root the same way `real` was resolved (ancestor
114
+ // symlinks and all — e.g. macOS's /var -> /private/var) so a shared_root
115
+ // that itself sits behind OS-level symlinks still compares equal.
116
+ const allowedRoots = sharedRoot ? sharedDirs.map((dir) => realDirOrResolve(path.join(sharedRoot, dir))) : [];
117
+ const inBounds = allowedRoots.some((root) => isInsideOrEqual(real, root));
118
+ if (!inBounds) {
119
+ throw new Error(`Refusing: files_root "${filesRoot}" is a symlink to "${real}", which is not one of the configured shared dirs ([deploy] shared_root/shared_dirs). Envsync only follows files_root through a declared shared-dir link.`);
120
+ }
121
+ return real;
122
+ }
@@ -0,0 +1,8 @@
1
+ /** Peer dependency names declared in this package's own package.json. */
2
+ export declare function readPeerNames(): string[];
3
+ /**
4
+ * If `err` is an ERR_MODULE_NOT_FOUND for one of `peerNames`, return a
5
+ * user-facing explanation and fix; otherwise undefined (caller rethrows).
6
+ */
7
+ export declare function missingPeerMessage(err: unknown, peerNames?: string[]): string | undefined;
8
+ //# sourceMappingURL=peer-hint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer-hint.d.ts","sourceRoot":"","sources":["../src/peer-hint.ts"],"names":[],"mappings":"AAYA,yEAAyE;AACzE,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAQxC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,GAAE,MAAM,EAAoB,GAAG,MAAM,GAAG,SAAS,CAmB1G"}
@@ -0,0 +1,49 @@
1
+ // hazo_env/src/peer-hint.ts — Friendly message for a missing peer dependency
2
+ //
3
+ // hazo_env's peers (hazo_core, hazo_config, ...) are only resolvable when the
4
+ // CLI runs from inside an app that installs them. `npx hazo_env ...` outside
5
+ // such an app (or in an app where hazo_env isn't a dependency, so npx fetches
6
+ // a lone copy into ~/.npm/_npx) dies at module load with a raw
7
+ // ERR_MODULE_NOT_FOUND stack. This turns that into an actionable message.
8
+ // Deliberately import-free (beyond node builtins) so it can run before any
9
+ // peer has been loaded.
10
+ import fs from 'node:fs';
11
+ /** Peer dependency names declared in this package's own package.json. */
12
+ export function readPeerNames() {
13
+ try {
14
+ const pkgUrl = new URL('../package.json', import.meta.url);
15
+ const pkg = JSON.parse(fs.readFileSync(pkgUrl, 'utf-8'));
16
+ return Object.keys(pkg.peerDependencies ?? {});
17
+ }
18
+ catch {
19
+ return [];
20
+ }
21
+ }
22
+ /**
23
+ * If `err` is an ERR_MODULE_NOT_FOUND for one of `peerNames`, return a
24
+ * user-facing explanation and fix; otherwise undefined (caller rethrows).
25
+ */
26
+ export function missingPeerMessage(err, peerNames = readPeerNames()) {
27
+ if (!err || typeof err !== 'object')
28
+ return undefined;
29
+ const e = err;
30
+ if (e.code !== 'ERR_MODULE_NOT_FOUND' || typeof e.message !== 'string')
31
+ return undefined;
32
+ const match = e.message.match(/Cannot find package '([^']+)'/);
33
+ if (!match)
34
+ return undefined;
35
+ const pkg = match[1];
36
+ if (!peerNames.includes(pkg))
37
+ return undefined;
38
+ return [
39
+ `hazo-env: cannot load its peer dependency "${pkg}".`,
40
+ '',
41
+ 'hazo_env must run from inside your app, where its peers are installed. Running it via',
42
+ 'npx outside the app (or in an app that does not list hazo_env as a dependency) fetches a',
43
+ 'standalone copy that cannot see them.',
44
+ '',
45
+ 'Fix: cd into the app directory and install it as a devDependency, then re-run:',
46
+ ' npm i -D hazo_env',
47
+ ' npx hazo_env <command>',
48
+ ].join('\n');
49
+ }
@@ -0,0 +1,2 @@
1
+ export declare function missingConfigMessage(filePath: string, cwd?: string): string;
2
+ //# sourceMappingURL=config-hint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-hint.d.ts","sourceRoot":"","sources":["../../src/resolve/config-hint.ts"],"names":[],"mappings":"AAUA,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAe1F"}
@@ -0,0 +1,23 @@
1
+ // hazo_env/src/resolve/config-hint.ts — Error text for a missing hazo_env_config.ini
2
+ //
3
+ // The INI is per-slot in a blue/green deploy (dir_suffix differs) and must
4
+ // stay untracked, so a slot can legitimately lose it (e.g. a pull that
5
+ // removes a previously-tracked copy). When the cwd looks like a slot dir,
6
+ // point at the peer slot's copy with the exact command to restore it.
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+ export function missingConfigMessage(filePath, cwd = process.cwd()) {
10
+ const base = `Config file not found: ${filePath}. Create config/hazo_env_config.ini.`;
11
+ const match = path.basename(cwd).match(/^(.*)-(blue|green)$/);
12
+ if (!match)
13
+ return base;
14
+ const [, stem, suffix] = match;
15
+ const peerSuffix = suffix === 'blue' ? 'green' : 'blue';
16
+ const peerConfig = path.join(path.dirname(cwd), `${stem}-${peerSuffix}`, 'config', 'hazo_env_config.ini');
17
+ if (!fs.existsSync(peerConfig)) {
18
+ return `${base} In a blue/green slot, copy the peer slot's file and set dir_suffix = ${suffix} (keep it out of git).`;
19
+ }
20
+ return (`${base} This looks like the "${suffix}" slot — restore it from the peer slot with dir_suffix swapped ` +
21
+ `(the file is per-slot; keep it out of git):\n` +
22
+ ` sed 's/^\\(dir_suffix *= *\\)${peerSuffix}/\\1${suffix}/' ${JSON.stringify(peerConfig)} > config/hazo_env_config.ini`);
23
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/resolve/connect.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAmB5E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,qBAA0B,GAAG,WAAW,CA+GlF"}
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/resolve/connect.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAoB5E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,qBAA0B,GAAG,WAAW,CA+GlF"}
@@ -5,6 +5,7 @@ import { HazoConfigError } from 'hazo_core';
5
5
  import { getEnv } from '../index.client.js';
6
6
  import { substitutePlaceholders } from './secrets.js';
7
7
  import { resolveFilesConfig } from './files.js';
8
+ import { missingConfigMessage } from './config-hint.js';
8
9
  function findConfigFile(pkg) {
9
10
  return path.resolve(process.cwd(), 'config', `${pkg}_config.ini`);
10
11
  }
@@ -17,7 +18,7 @@ function loadConfig() {
17
18
  throw new HazoConfigError({
18
19
  code: 'HAZO_ENV_CONFIG_FILE_MISSING',
19
20
  pkg: 'hazo_env',
20
- message: `Config file not found: ${filePath}. Create config/hazo_env_config.ini.`,
21
+ message: missingConfigMessage(filePath),
21
22
  });
22
23
  }
23
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/resolve/deploy.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0GvD;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CA0DlD"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/resolve/deploy.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0RvD;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CA+DlD"}