hazo_env 0.17.0 → 0.18.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 +23 -0
- package/README.md +4 -4
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +9 -5
- package/dist/deploy/help.js +6 -6
- package/dist/deploy/init.d.ts.map +1 -1
- package/dist/deploy/init.js +11 -3
- package/dist/deploy/peer.d.ts +9 -0
- package/dist/deploy/peer.d.ts.map +1 -1
- package/dist/deploy/peer.js +16 -0
- package/dist/deploy/preflight.d.ts +7 -0
- package/dist/deploy/preflight.d.ts.map +1 -1
- package/dist/deploy/preflight.js +25 -7
- package/dist/resolve/deploy.d.ts.map +1 -1
- package/dist/resolve/deploy.js +8 -3
- package/package.json +1 -1
package/CHANGE_LOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# hazo_env — Change Log
|
|
2
2
|
|
|
3
|
+
## 0.18.0 — 2026-11-27
|
|
4
|
+
|
|
5
|
+
New: `config/hazo_env_config.ini` can be committed to git. From the Kinstripe
|
|
6
|
+
prod deploy — the operator wants every INI change (e.g. `min_memory_mb`) to
|
|
7
|
+
ship through git, not be hand-edited per slot.
|
|
8
|
+
|
|
9
|
+
- **`[deploy] dir_suffix` is now optional.** When omitted, `resolveDeployConfig()`
|
|
10
|
+
infers it from the slot directory name (`<app>-blue` → `blue`, `<app>-green`
|
|
11
|
+
→ `green`, new `inferColorFromDir()` in `src/deploy/peer.ts`). Both slots
|
|
12
|
+
then hold a byte-identical INI. An explicit `dir_suffix` still wins; an
|
|
13
|
+
unsuffixed directory with no `dir_suffix` still throws
|
|
14
|
+
`HAZO_ENV_CONFIG_MISSING_DEPLOY_DIR_SUFFIX` (message now explains both fixes).
|
|
15
|
+
- **`deploy build` "config-untracked" pre-flight** now only aborts when the
|
|
16
|
+
tracked INI also pins `dir_suffix` (new `deployConfigPinsDirSuffix()` in
|
|
17
|
+
`src/deploy/preflight.ts`). A tracked INI without it passes, with detail
|
|
18
|
+
"tracked by git without dir_suffix". Step name unchanged. The abort message
|
|
19
|
+
offers both fixes (delete the `dir_suffix` line, or untrack).
|
|
20
|
+
- **`deploy init`** copies an INI with no `dir_suffix` line unchanged (no
|
|
21
|
+
swap, no "Could not find a dir_suffix line" error) and skips the
|
|
22
|
+
`.git/info/exclude` entry for it.
|
|
23
|
+
- Fully backwards compatible: an INI that sets `dir_suffix` behaves exactly
|
|
24
|
+
as in 0.17.0.
|
|
25
|
+
|
|
3
26
|
## 0.17.0 — 2026-11-25
|
|
4
27
|
|
|
5
28
|
New: deploy pre-flight checks and `deploy clean --idle-slots`, from the first
|
package/README.md
CHANGED
|
@@ -227,12 +227,12 @@ If `shared_dirs` is configured, also creates the peer's shared-dir symlinks so t
|
|
|
227
227
|
|
|
228
228
|
**Writes:**
|
|
229
229
|
- external: a new sibling directory — `git clone <origin>` into `<app>-<opposite dir_suffix>`
|
|
230
|
-
- standby slot: `config/hazo_env_config.ini`, with `dir_suffix` swapped blue↔green
|
|
230
|
+
- standby slot: `config/hazo_env_config.ini`, with `dir_suffix` swapped blue↔green (copied unchanged when the INI has no `dir_suffix` line — the suffix is then inferred from each slot's directory name)
|
|
231
231
|
- standby slot: the `[data] root` directory, when the app is sqlite-backed (`db_strategy` resolves to `copy`)
|
|
232
232
|
- standby slot: each found `env_files` entry, copied in (gitignored secrets never travel through `git clone`)
|
|
233
233
|
- shared root + standby slot: shared-dir symlinks — `ensureLinks(standbyDir, { allowCreate: true })` creates `shared_root/<dir>` and the standby's `<dir>` symlink for every `shared_dirs` entry not already linked
|
|
234
234
|
- state file: `~/.hazo-deploy/<app_name>.json` written fresh (`live_dir` = current dir, `standby_dir` = the new peer)
|
|
235
|
-
- live + standby slot: `.git/info/exclude` gains a `config/hazo_env_config.ini` entry
|
|
235
|
+
- live + standby slot: `.git/info/exclude` gains a `config/hazo_env_config.ini` entry when the INI pins `dir_suffix` (it is then per-slot, so it must never be committed; the exclude file is local to each clone and never dirties a tracked `.gitignore`). Skipped when the INI has no `dir_suffix` line — that file is identical in both slots and meant to be committed.
|
|
236
236
|
|
|
237
237
|
**Config keys used:** `app_name`, `dir_suffix`, `env_files`, `shared_root`, `shared_dirs`
|
|
238
238
|
|
|
@@ -285,7 +285,7 @@ The "shared-dirs" step runs BEFORE git-pull (the first destructive step) specifi
|
|
|
285
285
|
|
|
286
286
|
**Failure modes:**
|
|
287
287
|
- BuildAbortError (any step name above) — aborts on the first failing step; the error carries every step completed so far for reporting. If `--stop-prod` already stopped production before the abort, the message is prefixed "⚠ PRODUCTION IS DOWN" with the exact `pm2 start` command to bring it back up by hand.
|
|
288
|
-
- BuildAbortError at "config-untracked" — `config/hazo_env_config.ini` is tracked in git
|
|
288
|
+
- BuildAbortError at "config-untracked" — `config/hazo_env_config.ini` is tracked in git AND pins `dir_suffix` (which differs per slot), so a pull would overwrite or conflict with the slot's copy. Either delete the `dir_suffix` line (it is then inferred from the slot directory name, so one committed file serves both slots), or `git rm --cached` it, add it to `.gitignore`, commit, and keep each slot's local copy. A tracked INI without `dir_suffix` passes. Checked before `git-pull`, so `last_build` is untouched.
|
|
289
289
|
- BuildAbortError at "disk-check" — free disk still below `min_disk_mb` after cleanup; the message suggests `hazo-env deploy clean --idle-slots` to reclaim other apps' idle standby `node_modules`/`.next`.
|
|
290
290
|
- HazoConfigError "HAZO_ENV_CONFIG_FILE_MISSING" — no `config/hazo_env_config.ini` in the slot; when the cwd is a `-blue`/`-green` dir and the peer has one, the message gives the exact `sed` command to copy it with `dir_suffix` swapped.
|
|
291
291
|
- SharedDirError "HAZO_ENV_SHARED_DIR_REAL_DIR" / "HAZO_ENV_SHARED_DIR_WRONG_LINK" (surfaces as the "shared-dirs" build step's failure) — a non-empty real directory, or a symlink to the wrong target, is sitting where a shared-dir link belongs; build refuses and its message points at "hazo-env deploy share". ("HAZO_ENV_SHARED_DIR_MISSING" / "_EMPTY_DIR" never surface here — build always passes `allowCreate` and `allowReplaceEmpty`.)
|
|
@@ -484,7 +484,7 @@ hazo-env deploy share
|
|
|
484
484
|
| Key | Default | Meaning |
|
|
485
485
|
|---|---|---|
|
|
486
486
|
| `app_name` | (none — required) | Logical app name. Also names the state file: ~/.hazo-deploy/<app_name>.json. |
|
|
487
|
-
| `dir_suffix` | (
|
|
487
|
+
| `dir_suffix` | inferred from the slot directory name ("<app>-blue" → blue, "<app>-green" → green) | Which color suffix THIS directory is (must be exactly "blue" or "green"). The peer is resolved by swapping it on the current directory's basename. Omit it to have it inferred from the directory name — the INI is then identical in both slots and can be committed to git. Set it only for an unsuffixed checkout (e.g. `~/myapp`), and then keep the INI out of git. |
|
|
488
488
|
| `prod_port` | 3000 | Production PM2 port. |
|
|
489
489
|
| `staging_port` | 3001 | Staging port used by `deploy build`/`deploy verify` before switching. |
|
|
490
490
|
| `health_url` | /api/health | Path hit for health checks during build/verify/status. |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI9D,MAAM,WAAW,eAAe;IAC9B,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,GAAG,QAAQ,CAAC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,6FAA6F;AAC7F,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC;gBAEtB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE;CAKtD;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAMjF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAErE;AAiBD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,CASpH;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,eAAoB,GAAG,cAAc,CA8WhH"}
|
package/dist/deploy/build.js
CHANGED
|
@@ -30,7 +30,7 @@ import { readState, updateState } from './state.js';
|
|
|
30
30
|
import { SWAP_INCREASE_SUGGESTIONS } from './clean.js';
|
|
31
31
|
import { startNamedPm2Process, isPm2ProcessNotFound } from './pm2-start.js';
|
|
32
32
|
import { ensureLinks } from './shared-dirs.js';
|
|
33
|
-
import { cliDependencyWarning, commandFailureDetail, isDeployConfigGitTracked, TRACKED_DEPLOY_CONFIG_MESSAGE, } from './preflight.js';
|
|
33
|
+
import { cliDependencyWarning, commandFailureDetail, isDeployConfigGitTracked, deployConfigPinsDirSuffix, TRACKED_DEPLOY_CONFIG_MESSAGE, } from './preflight.js';
|
|
34
34
|
import { resolveConnectConfig } from '../resolve/connect.js';
|
|
35
35
|
/** Thrown when any pipeline step fails. Carries the steps completed so far for reporting. */
|
|
36
36
|
export class BuildAbortError extends Error {
|
|
@@ -270,12 +270,16 @@ export function runBuild(config, runner, opts = {}) {
|
|
|
270
270
|
else {
|
|
271
271
|
pass('shared-dirs', 'no shared_dirs configured — skipping');
|
|
272
272
|
}
|
|
273
|
-
// Pre-flight (read-only, so before the destructive marker below):
|
|
274
|
-
//
|
|
275
|
-
|
|
273
|
+
// Pre-flight (read-only, so before the destructive marker below): a
|
|
274
|
+
// git-tracked INI is only a problem when it pins the per-slot
|
|
275
|
+
// `dir_suffix` — see preflight.ts. (Step name kept for compatibility.)
|
|
276
|
+
const configTracked = runStep('config-untracked', () => isDeployConfigGitTracked(runner, cwd));
|
|
277
|
+
if (configTracked && deployConfigPinsDirSuffix(cwd)) {
|
|
276
278
|
abort('config-untracked', TRACKED_DEPLOY_CONFIG_MESSAGE);
|
|
277
279
|
}
|
|
278
|
-
pass('config-untracked',
|
|
280
|
+
pass('config-untracked', configTracked
|
|
281
|
+
? 'config/hazo_env_config.ini is tracked by git without dir_suffix (inferred from the slot dir name)'
|
|
282
|
+
: 'config/hazo_env_config.ini is not tracked by git');
|
|
279
283
|
// Fix 3: write a provisional/pessimistic `last_build` marker right
|
|
280
284
|
// before the first DESTRUCTIVE step (git pull) — everything above this
|
|
281
285
|
// point (guard, disk/memory checks, db-resolve) is read-only, so an
|
package/dist/deploy/help.js
CHANGED
|
@@ -50,12 +50,12 @@ export const DEPLOY_SUBCOMMAND_HELP = {
|
|
|
50
50
|
],
|
|
51
51
|
writes: [
|
|
52
52
|
'external: a new sibling directory — `git clone <origin>` into `<app>-<opposite dir_suffix>`',
|
|
53
|
-
'standby slot: `config/hazo_env_config.ini`, with `dir_suffix` swapped blue↔green',
|
|
53
|
+
'standby slot: `config/hazo_env_config.ini`, with `dir_suffix` swapped blue↔green (copied unchanged when the INI has no `dir_suffix` line — the suffix is then inferred from each slot\'s directory name)',
|
|
54
54
|
'standby slot: the `[data] root` directory, when the app is sqlite-backed (`db_strategy` resolves to `copy`)',
|
|
55
55
|
'standby slot: each found `env_files` entry, copied in (gitignored secrets never travel through `git clone`)',
|
|
56
56
|
'shared root + standby slot: shared-dir symlinks — `ensureLinks(standbyDir, { allowCreate: true })` creates `shared_root/<dir>` and the standby\'s `<dir>` symlink for every `shared_dirs` entry not already linked',
|
|
57
57
|
'state file: `~/.hazo-deploy/<app_name>.json` written fresh (`live_dir` = current dir, `standby_dir` = the new peer)',
|
|
58
|
-
'live + standby slot: `.git/info/exclude` gains a `config/hazo_env_config.ini` entry
|
|
58
|
+
'live + standby slot: `.git/info/exclude` gains a `config/hazo_env_config.ini` entry when the INI pins `dir_suffix` (it is then per-slot, so it must never be committed; the exclude file is local to each clone and never dirties a tracked `.gitignore`). Skipped when the INI has no `dir_suffix` line — that file is identical in both slots and meant to be committed.',
|
|
59
59
|
],
|
|
60
60
|
configKeys: ['app_name', 'dir_suffix', 'env_files', 'shared_root', 'shared_dirs'],
|
|
61
61
|
failureModes: [
|
|
@@ -106,7 +106,7 @@ export const DEPLOY_SUBCOMMAND_HELP = {
|
|
|
106
106
|
],
|
|
107
107
|
failureModes: [
|
|
108
108
|
'BuildAbortError (any step name above) — aborts on the first failing step; the error carries every step completed so far for reporting. If `--stop-prod` already stopped production before the abort, the message is prefixed "⚠ PRODUCTION IS DOWN" with the exact `pm2 start` command to bring it back up by hand.',
|
|
109
|
-
'BuildAbortError at "config-untracked" — `config/hazo_env_config.ini` is tracked in git
|
|
109
|
+
'BuildAbortError at "config-untracked" — `config/hazo_env_config.ini` is tracked in git AND pins `dir_suffix` (which differs per slot), so a pull would overwrite or conflict with the slot\'s copy. Either delete the `dir_suffix` line (it is then inferred from the slot directory name, so one committed file serves both slots), or `git rm --cached` it, add it to `.gitignore`, commit, and keep each slot\'s local copy. A tracked INI without `dir_suffix` passes. Checked before `git-pull`, so `last_build` is untouched.',
|
|
110
110
|
'BuildAbortError at "disk-check" — free disk still below `min_disk_mb` after cleanup; the message suggests `hazo-env deploy clean --idle-slots` to reclaim other apps\' idle standby `node_modules`/`.next`.',
|
|
111
111
|
'HazoConfigError "HAZO_ENV_CONFIG_FILE_MISSING" — no `config/hazo_env_config.ini` in the slot; when the cwd is a `-blue`/`-green` dir and the peer has one, the message gives the exact `sed` command to copy it with `dir_suffix` swapped.',
|
|
112
112
|
'SharedDirError "HAZO_ENV_SHARED_DIR_REAL_DIR" / "HAZO_ENV_SHARED_DIR_WRONG_LINK" (surfaces as the "shared-dirs" build step\'s failure) — a non-empty real directory, or a symlink to the wrong target, is sitting where a shared-dir link belongs; build refuses and its message points at "hazo-env deploy share". ("HAZO_ENV_SHARED_DIR_MISSING" / "_EMPTY_DIR" never surface here — build always passes `allowCreate` and `allowReplaceEmpty`.)',
|
|
@@ -294,9 +294,9 @@ export const DEPLOY_CONFIG_HELP = [
|
|
|
294
294
|
},
|
|
295
295
|
{
|
|
296
296
|
key: 'dir_suffix',
|
|
297
|
-
type: 'string
|
|
298
|
-
default: '(
|
|
299
|
-
meaning: 'Which color suffix THIS directory is (must be exactly "blue" or "green"). The peer is resolved by swapping it on the current directory\'s basename.',
|
|
297
|
+
type: 'string',
|
|
298
|
+
default: 'inferred from the slot directory name ("<app>-blue" → blue, "<app>-green" → green)',
|
|
299
|
+
meaning: 'Which color suffix THIS directory is (must be exactly "blue" or "green"). The peer is resolved by swapping it on the current directory\'s basename. Omit it to have it inferred from the directory name — the INI is then identical in both slots and can be committed to git. Set it only for an unsuffixed checkout (e.g. `~/myapp`), and then keep the INI out of git.',
|
|
300
300
|
example: 'dir_suffix = green',
|
|
301
301
|
},
|
|
302
302
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/deploy/init.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/deploy/init.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAoDzD,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;IACrC;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AA0CD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,cAAmB,GAAG,aAAa,CAgE7G"}
|
package/dist/deploy/init.js
CHANGED
|
@@ -19,7 +19,7 @@ import { resolvePeerDir } from './peer.js';
|
|
|
19
19
|
import { writeState } from './state.js';
|
|
20
20
|
import { getEnv } from '../index.client.js';
|
|
21
21
|
import { ensureLinks } from './shared-dirs.js';
|
|
22
|
-
import { excludeDeployConfigFromGit } from './preflight.js';
|
|
22
|
+
import { deployConfigPinsDirSuffix, excludeDeployConfigFromGit } from './preflight.js';
|
|
23
23
|
const CONFIG_RELATIVE_PATH = path.join('config', 'hazo_env_config.ini');
|
|
24
24
|
// Matches resolve/files.ts's DEFAULT_DATA_ROOT — kept as a local literal
|
|
25
25
|
// rather than importing that module, since resolveFilesConfig()/
|
|
@@ -51,12 +51,16 @@ function swapDirSuffixValue(value) {
|
|
|
51
51
|
/**
|
|
52
52
|
* Swap the `dir_suffix = <value>` line in the INI's [deploy] section to its
|
|
53
53
|
* blue/green opposite, leaving every other byte of the file untouched.
|
|
54
|
+
*
|
|
55
|
+
* An INI with no `dir_suffix` line is returned unchanged: the suffix is then
|
|
56
|
+
* inferred from each slot's directory name (see `inferColorFromDir`), so both
|
|
57
|
+
* slots share one byte-identical — committable — file.
|
|
54
58
|
*/
|
|
55
59
|
function swapDirSuffixInIni(iniContent) {
|
|
56
60
|
const pattern = /^(\s*dir_suffix\s*=\s*)(\S+)(\s*)$/m;
|
|
57
61
|
const match = iniContent.match(pattern);
|
|
58
62
|
if (!match) {
|
|
59
|
-
|
|
63
|
+
return iniContent;
|
|
60
64
|
}
|
|
61
65
|
const swapped = swapDirSuffixValue(match[2]);
|
|
62
66
|
return iniContent.replace(pattern, `$1${swapped}$3`);
|
|
@@ -145,7 +149,11 @@ export function runInit(config, runner, opts = {}) {
|
|
|
145
149
|
envFilesMissing.push(envFile);
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
|
-
|
|
152
|
+
// Only a dir_suffix-pinning INI is per-slot; one without it (suffix
|
|
153
|
+
// inferred from the dir name) is meant to be committed, so leave git alone.
|
|
154
|
+
const configExcludedFrom = deployConfigPinsDirSuffix(currentDir)
|
|
155
|
+
? [currentDir, peerDir].filter((dir) => excludeDeployConfigFromGit(dir))
|
|
156
|
+
: [];
|
|
149
157
|
const state = {
|
|
150
158
|
app_name: config.app_name,
|
|
151
159
|
live_dir: currentDir,
|
package/dist/deploy/peer.d.ts
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
* doesn't end in a recognized color suffix.
|
|
5
5
|
*/
|
|
6
6
|
export declare function swapColorSuffix(dirName: string): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Infer a slot's color from its directory basename: "kinstripe-blue" ->
|
|
9
|
+
* "blue", "gotimer-green" -> "green". Returns `undefined` when the basename
|
|
10
|
+
* has no recognized color suffix (e.g. an unsuffixed `~/kinstripe` checkout
|
|
11
|
+
* or a dev machine clone). Used by `resolveDeployConfig()` as the fallback
|
|
12
|
+
* for an INI with no `dir_suffix` line — which is what lets the INI be
|
|
13
|
+
* committed to git (identical in both slots).
|
|
14
|
+
*/
|
|
15
|
+
export declare function inferColorFromDir(dir: string): string | undefined;
|
|
7
16
|
/**
|
|
8
17
|
* Resolve the absolute path to the peer (standby) directory for `currentDir`.
|
|
9
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../src/deploy/peer.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBnG"}
|
|
1
|
+
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../src/deploy/peer.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQnE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBnG"}
|
package/dist/deploy/peer.js
CHANGED
|
@@ -23,6 +23,22 @@ export function swapColorSuffix(dirName) {
|
|
|
23
23
|
}
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Infer a slot's color from its directory basename: "kinstripe-blue" ->
|
|
28
|
+
* "blue", "gotimer-green" -> "green". Returns `undefined` when the basename
|
|
29
|
+
* has no recognized color suffix (e.g. an unsuffixed `~/kinstripe` checkout
|
|
30
|
+
* or a dev machine clone). Used by `resolveDeployConfig()` as the fallback
|
|
31
|
+
* for an INI with no `dir_suffix` line — which is what lets the INI be
|
|
32
|
+
* committed to git (identical in both slots).
|
|
33
|
+
*/
|
|
34
|
+
export function inferColorFromDir(dir) {
|
|
35
|
+
const basename = path.basename(path.resolve(dir));
|
|
36
|
+
for (const color of Object.keys(SUFFIX_SWAP)) {
|
|
37
|
+
if (basename.endsWith(`-${color}`))
|
|
38
|
+
return color;
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
26
42
|
/**
|
|
27
43
|
* Resolve the absolute path to the peer (standby) directory for `currentDir`.
|
|
28
44
|
*
|
|
@@ -10,6 +10,13 @@ export declare const FAILURE_OUTPUT_TAIL_LINES = 40;
|
|
|
10
10
|
export declare function cliDependencyWarning(cwd: string): string | undefined;
|
|
11
11
|
/** True when config/hazo_env_config.ini is tracked by git in `cwd`. */
|
|
12
12
|
export declare function isDeployConfigGitTracked(runner: CommandRunner, cwd: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* True when `cwd`'s config/hazo_env_config.ini pins `dir_suffix` explicitly.
|
|
15
|
+
* Such a file differs between blue and green, so it must not be tracked in
|
|
16
|
+
* git. Without the line, the suffix is inferred from the slot dir name and
|
|
17
|
+
* the file is identical in both slots — safe to commit.
|
|
18
|
+
*/
|
|
19
|
+
export declare function deployConfigPinsDirSuffix(cwd: string): boolean;
|
|
13
20
|
export declare const TRACKED_DEPLOY_CONFIG_MESSAGE: string;
|
|
14
21
|
/**
|
|
15
22
|
* Add the per-slot config path to `<dir>/.git/info/exclude` (local to that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/deploy/preflight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/deploy/preflight.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,2BAA2B,QAA6C,CAAC;AAEtF,0EAA0E;AAC1E,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAcpE;AAED,uEAAuE;AACvE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGpF;AAKD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAI9D;AAED,eAAO,MAAM,6BAA6B,QASyD,CAAC;AAEpG;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW/D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,SAA4B,GAAG,MAAM,CAc9F"}
|
package/dist/deploy/preflight.js
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
// - hazo_env not listed in the app's package.json: works once via a manual
|
|
5
5
|
// install, then `deploy build`'s own `npm ci` removes it and the next
|
|
6
6
|
// `npx hazo_env` fetches a standalone copy that can't resolve its peers.
|
|
7
|
-
// - config/hazo_env_config.ini tracked in git
|
|
8
|
-
// slot, so a tracked copy is either overwritten by
|
|
9
|
-
// suffix) or blocks the pull against the slot's
|
|
7
|
+
// - config/hazo_env_config.ini tracked in git while pinning `dir_suffix`:
|
|
8
|
+
// the value differs per slot, so a tracked copy is either overwritten by
|
|
9
|
+
// `git pull` (wrong suffix) or blocks the pull against the slot's
|
|
10
|
+
// untracked copy. Since 0.18.0 an INI WITHOUT `dir_suffix` (inferred from
|
|
11
|
+
// the slot dir name) is identical in both slots and may be tracked.
|
|
10
12
|
// - a failed install/build reporting only Next's last line ("Failed to type
|
|
11
13
|
// check.") because the actual tsc errors went to stdout, which execSync
|
|
12
14
|
// keeps on the error object rather than in its message.
|
|
@@ -41,13 +43,29 @@ export function isDeployConfigGitTracked(runner, cwd) {
|
|
|
41
43
|
const result = runner.spawn(`git ls-files --error-unmatch ${DEPLOY_CONFIG_RELATIVE_PATH}`, { cwd });
|
|
42
44
|
return result.code === 0;
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
/** Matches an active (uncommented) `dir_suffix = ...` line anywhere in the INI. */
|
|
47
|
+
const DIR_SUFFIX_LINE = /^\s*dir_suffix\s*=/m;
|
|
48
|
+
/**
|
|
49
|
+
* True when `cwd`'s config/hazo_env_config.ini pins `dir_suffix` explicitly.
|
|
50
|
+
* Such a file differs between blue and green, so it must not be tracked in
|
|
51
|
+
* git. Without the line, the suffix is inferred from the slot dir name and
|
|
52
|
+
* the file is identical in both slots — safe to commit.
|
|
53
|
+
*/
|
|
54
|
+
export function deployConfigPinsDirSuffix(cwd) {
|
|
55
|
+
const iniPath = path.join(cwd, DEPLOY_CONFIG_RELATIVE_PATH);
|
|
56
|
+
if (!fs.existsSync(iniPath))
|
|
57
|
+
return false;
|
|
58
|
+
return DIR_SUFFIX_LINE.test(fs.readFileSync(iniPath, 'utf-8'));
|
|
59
|
+
}
|
|
60
|
+
export const TRACKED_DEPLOY_CONFIG_MESSAGE = `${DEPLOY_CONFIG_RELATIVE_PATH} is tracked in git but pins dir_suffix, which differs between blue and ` +
|
|
61
|
+
`green — a pull would overwrite this slot's copy or conflict with it. Either:\n` +
|
|
62
|
+
` (a) delete the "dir_suffix = ..." line and commit — the suffix is then inferred from the slot ` +
|
|
63
|
+
`directory name ("<app>-blue" / "<app>-green"), so one committed file serves both slots; or\n` +
|
|
64
|
+
` (b) untrack it and keep a per-slot copy:\n` +
|
|
47
65
|
` git rm --cached ${DEPLOY_CONFIG_RELATIVE_PATH}\n` +
|
|
48
66
|
` echo "${DEPLOY_CONFIG_RELATIVE_PATH}" >> .gitignore\n` +
|
|
49
67
|
` git commit -m "untrack per-slot hazo_env config" && git push\n` +
|
|
50
|
-
`
|
|
68
|
+
` (restore each slot's copy from the peer slot with dir_suffix swapped if a pull deleted it).`;
|
|
51
69
|
/**
|
|
52
70
|
* Add the per-slot config path to `<dir>/.git/info/exclude` (local to that
|
|
53
71
|
* clone, so it never dirties a tracked .gitignore). Returns true if an entry
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAqElD"}
|
package/dist/resolve/deploy.js
CHANGED
|
@@ -8,7 +8,7 @@ import os from 'node:os';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { HazoConfig } from 'hazo_config/server';
|
|
10
10
|
import { HazoConfigError } from 'hazo_core';
|
|
11
|
-
import { resolvePeerDir } from '../deploy/peer.js';
|
|
11
|
+
import { inferColorFromDir, resolvePeerDir } from '../deploy/peer.js';
|
|
12
12
|
import { resolveConnectConfig } from './connect.js';
|
|
13
13
|
import { missingConfigMessage } from './config-hint.js';
|
|
14
14
|
const DEFAULTS = {
|
|
@@ -293,12 +293,17 @@ export function resolveDeployConfig() {
|
|
|
293
293
|
message: '[deploy] section is missing required field "app_name".',
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
// An explicit `dir_suffix` wins; otherwise infer it from the slot dir's
|
|
297
|
+
// basename ("<app>-blue" / "<app>-green"). Omitting it is what lets the INI
|
|
298
|
+
// be committed to git — both slots then hold a byte-identical file.
|
|
299
|
+
const dir_suffix = (section['dir_suffix']?.trim() || inferColorFromDir(process.cwd()));
|
|
297
300
|
if (!dir_suffix) {
|
|
298
301
|
throw new HazoConfigError({
|
|
299
302
|
code: 'HAZO_ENV_CONFIG_MISSING_DEPLOY_DIR_SUFFIX',
|
|
300
303
|
pkg: 'hazo_env',
|
|
301
|
-
message: '[deploy] section is missing
|
|
304
|
+
message: '[deploy] section is missing "dir_suffix" and it could not be inferred: the app directory name ' +
|
|
305
|
+
`("${path.basename(process.cwd())}") does not end in "-blue" or "-green". Rename the slot directory ` +
|
|
306
|
+
'(e.g. "myapp-blue") or set dir_suffix explicitly.',
|
|
302
307
|
});
|
|
303
308
|
}
|
|
304
309
|
const db_strategy_raw = section['db_strategy'] ?? DEFAULTS.db_strategy;
|
package/package.json
CHANGED