hazo_env 0.14.1 → 0.15.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 CHANGED
@@ -1,6 +1,26 @@
1
1
  # hazo_env — Change Log
2
2
 
3
- ## 0.14.1 — 2026-11-23
3
+ ## 0.15.0 — 2026-11-23
4
+
5
+ New: `deploy init` now copies gitignored env files (`.env.local`,
6
+ `.env.production`, etc.) from the live directory to the freshly-cloned peer.
7
+
8
+ - **`env_files`** config field (`[deploy]` section): comma-separated list of
9
+ files to copy. Default: `.env.local`. Kinstripe sets
10
+ `env_files = .env.local, .env.production`.
11
+ - **`RunInitResult`**: gains `envFilesCopied` and `envFilesMissing` arrays.
12
+ - **CLI**: `deploy init` output now reports which env files were copied and
13
+ warns about any that were listed but not found.
14
+
15
+ Also includes the 0.14.1/0.14.2 fix (resolvePeerDir configSuffix).
16
+
17
+ ## 0.14.2 — 2026-11-23
18
+
19
+ Republish of 0.14.1 — the 0.14.1 tarball was published with a stale dist/
20
+ that didn't contain the peer.ts fix. This version is built from the same
21
+ source with correct compiled output.
22
+
23
+ ## 0.14.1 — 2026-11-23 (broken publish — use 0.14.2)
4
24
 
5
25
  Fix: `resolvePeerDir()` no longer requires the current directory's basename
6
26
  to end in `-blue`/`-green`. When no color suffix is found, it reads the
package/dist/cli.js CHANGED
@@ -275,6 +275,12 @@ async function runDeployInit() {
275
275
  const result = runInit(config, nodeCommandRunner);
276
276
  console.log(` ${pc.green('✓')} Peer directory created: ${result.peerDir}`);
277
277
  console.log(` ${pc.dim(`cloned from ${result.originUrl}`)}`);
278
+ if (result.envFilesCopied.length) {
279
+ console.log(` ${pc.green('✓')} Env files copied: ${result.envFilesCopied.join(', ')}`);
280
+ }
281
+ if (result.envFilesMissing.length) {
282
+ console.log(` ${pc.yellow('⚠')} Env files not found (copy manually): ${result.envFilesMissing.join(', ')}`);
283
+ }
278
284
  console.log('');
279
285
  console.log(` Next steps:`);
280
286
  console.log(` cd ${result.peerDir}`);
@@ -196,7 +196,7 @@ export function runBuild(config, runner, opts = {}) {
196
196
  ? resolvePeerDir(cwd, opts.peerDir)
197
197
  : state
198
198
  ? path.resolve(state.live_dir)
199
- : resolvePeerDir(cwd, opts.peerDir);
199
+ : resolvePeerDir(cwd, undefined, config.dir_suffix);
200
200
  // Step 1: auto-clean, then check disk free against min_disk_mb.
201
201
  const cleanResult = autoClean(config, runner);
202
202
  pass('clean', `reclaimed ${cleanResult.totalBytesReclaimed} bytes across ${cleanResult.targets.length} targets`);
@@ -9,6 +9,8 @@ export interface RunInitResult {
9
9
  currentDir: string;
10
10
  peerDir: string;
11
11
  originUrl: string;
12
+ envFilesCopied: string[];
13
+ envFilesMissing: string[];
12
14
  }
13
15
  /**
14
16
  * Create the peer (standby) directory: resolve its path, abort if it
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/deploy/init.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAgD3E,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;CACnB;AA0CD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,cAAmB,GAAG,aAAa,CAgC7G"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/deploy/init.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAgD3E,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;CAC3B;AA0CD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,GAAE,cAAmB,GAAG,aAAa,CA8C7G"}
@@ -106,7 +106,7 @@ function ensurePeerDataDir(config, peerIniPath, peerDir) {
106
106
  */
107
107
  export function runInit(config, runner, opts = {}) {
108
108
  const currentDir = path.resolve(opts.cwd ?? process.cwd());
109
- const peerDir = resolvePeerDir(currentDir, opts.peerDir);
109
+ const peerDir = resolvePeerDir(currentDir, opts.peerDir, config.dir_suffix);
110
110
  if (fs.existsSync(peerDir)) {
111
111
  throw new Error(`Peer directory already exists: ${peerDir}. "deploy init" only creates it fresh — remove it first (or run "deploy clean") if you want to re-init.`);
112
112
  }
@@ -119,6 +119,20 @@ export function runInit(config, runner, opts = {}) {
119
119
  fs.mkdirSync(path.dirname(peerIniPath), { recursive: true });
120
120
  fs.writeFileSync(peerIniPath, swappedIni, 'utf-8');
121
121
  ensurePeerDataDir(config, peerIniPath, peerDir);
122
+ const envFilesCopied = [];
123
+ const envFilesMissing = [];
124
+ for (const envFile of config.env_files) {
125
+ const src = path.join(currentDir, envFile);
126
+ const dest = path.join(peerDir, envFile);
127
+ if (fs.existsSync(src)) {
128
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
129
+ fs.copyFileSync(src, dest);
130
+ envFilesCopied.push(envFile);
131
+ }
132
+ else {
133
+ envFilesMissing.push(envFile);
134
+ }
135
+ }
122
136
  const state = {
123
137
  app_name: config.app_name,
124
138
  live_dir: currentDir,
@@ -127,5 +141,5 @@ export function runInit(config, runner, opts = {}) {
127
141
  staging_port: config.staging_port,
128
142
  };
129
143
  writeState(state);
130
- return { currentDir, peerDir, originUrl };
144
+ return { currentDir, peerDir, originUrl, envFilesCopied, envFilesMissing };
131
145
  }
@@ -11,8 +11,12 @@ export declare function swapColorSuffix(dirName: string): string | undefined;
11
11
  * `currentDir`'s parent if not already absolute).
12
12
  * - Otherwise, swap the blue/green suffix on `currentDir`'s basename and
13
13
  * resolve it as a sibling (same parent directory).
14
+ * - If the basename has no suffix but `configSuffix` names this dir's color
15
+ * (from the INI's `dir_suffix`), the peer is `<basename>-<opposite>` as a
16
+ * sibling. This lets `deploy init` / first `deploy build` work from an
17
+ * unsuffixed checkout (e.g. `~/kinstripe`) without requiring a rename.
14
18
  *
15
- * Throws if no override is given and the basename has no blue/green suffix.
19
+ * Throws if none of the above resolve a peer.
16
20
  */
17
- export declare function resolvePeerDir(currentDir: string, override?: string): string;
21
+ export declare function resolvePeerDir(currentDir: string, override?: string, configSuffix?: string): string;
18
22
  //# sourceMappingURL=peer.d.ts.map
@@ -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;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAiB5E"}
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"}
@@ -30,10 +30,14 @@ export function swapColorSuffix(dirName) {
30
30
  * `currentDir`'s parent if not already absolute).
31
31
  * - Otherwise, swap the blue/green suffix on `currentDir`'s basename and
32
32
  * resolve it as a sibling (same parent directory).
33
+ * - If the basename has no suffix but `configSuffix` names this dir's color
34
+ * (from the INI's `dir_suffix`), the peer is `<basename>-<opposite>` as a
35
+ * sibling. This lets `deploy init` / first `deploy build` work from an
36
+ * unsuffixed checkout (e.g. `~/kinstripe`) without requiring a rename.
33
37
  *
34
- * Throws if no override is given and the basename has no blue/green suffix.
38
+ * Throws if none of the above resolve a peer.
35
39
  */
36
- export function resolvePeerDir(currentDir, override) {
40
+ export function resolvePeerDir(currentDir, override, configSuffix) {
37
41
  const absCurrent = path.resolve(currentDir);
38
42
  const parent = path.dirname(absCurrent);
39
43
  if (override) {
@@ -41,8 +45,14 @@ export function resolvePeerDir(currentDir, override) {
41
45
  }
42
46
  const basename = path.basename(absCurrent);
43
47
  const peerBasename = swapColorSuffix(basename);
44
- if (!peerBasename) {
45
- throw new Error(`Cannot resolve peer directory for "${basename}": no "-blue" or "-green" suffix found. Pass an explicit peer dir override.`);
48
+ if (peerBasename) {
49
+ return path.join(parent, peerBasename);
46
50
  }
47
- return path.join(parent, peerBasename);
51
+ if (configSuffix) {
52
+ const opposite = SUFFIX_SWAP[configSuffix];
53
+ if (opposite) {
54
+ return path.join(parent, `${basename}-${opposite}`);
55
+ }
56
+ }
57
+ throw new Error(`Cannot resolve peer directory for "${basename}": no "-blue" or "-green" suffix found. Pass an explicit peer dir override.`);
48
58
  }
@@ -40,6 +40,12 @@ export interface DeployConfig {
40
40
  * Default: []
41
41
  */
42
42
  sidecar_apps: string[];
43
+ /**
44
+ * Gitignored files (relative to app root) copied from the live dir to the
45
+ * peer during `deploy init` — typically `.env.local`, `.env.production`.
46
+ * Comma-separated in the INI. Default: ['.env.local']
47
+ */
48
+ env_files: string[];
43
49
  }
44
50
  /** Result of a single command execution. */
45
51
  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,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAA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;IACrB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACzC,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG"}
@@ -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;AAiGvD;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAwDlD"}
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,CAyDlD"}
@@ -98,6 +98,15 @@ function collectSidecarApps(section) {
98
98
  .map((s) => s.trim())
99
99
  .filter((s) => s.length > 0);
100
100
  }
101
+ function collectEnvFiles(section) {
102
+ const raw = section['env_files'];
103
+ if (typeof raw !== 'string' || !raw.trim())
104
+ return ['.env.local'];
105
+ return raw
106
+ .split(',')
107
+ .map((s) => s.trim())
108
+ .filter((s) => s.length > 0);
109
+ }
101
110
  const VALID_DB_STRATEGIES = new Set(['auto', 'copy', 'shared']);
102
111
  /**
103
112
  * Resolve the `[deploy]` section of hazo_env_config.ini into a typed
@@ -154,5 +163,6 @@ export function resolveDeployConfig() {
154
163
  migrate_cmd: section['migrate_cmd'] ?? DEFAULTS.migrate_cmd,
155
164
  post_switch_cmds: collectPostSwitchCmds(section),
156
165
  sidecar_apps: collectSidecarApps(section),
166
+ env_files: collectEnvFiles(section),
157
167
  };
158
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_env",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "Canonical environment resolver — typed env names, per-env DB/file/secret config, doctor and CLI for hazo apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",