@bakers-build/core 0.19.1-next.3 → 0.19.1-next.4

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.
@@ -27,3 +27,15 @@ export declare function layeredEnv(key: EnvKey, files: EnvFiles, home?: string):
27
27
  values: Record<string, string>;
28
28
  sources: Record<string, string>;
29
29
  };
30
+ /** The sorted, unique non-empty string values of `*_env` keys at any depth of an addon's options. */
31
+ export declare function envOptionNames(options: unknown): string[];
32
+ /** An addon's resolved `*_env` names: values, per name `shell` or a file path, and every source searched. */
33
+ export interface AddonEnv {
34
+ values: Record<string, string>;
35
+ sources: Record<string, string>;
36
+ searched: string[];
37
+ }
38
+ /** An addon's `names` from a non-empty shell value, else the project file, else the machine file. */
39
+ export declare function addonEnv(names: readonly string[], project: string, files: EnvFiles, shell?: Readonly<Record<string, string | undefined>>, home?: string): AddonEnv;
40
+ /** Per addon, each named variable's source (`shell`, a file path or `unset`); never a value. */
41
+ export declare function addonEnvSources(addonNames: Readonly<Record<string, readonly string[]>>, project: string, files: EnvFiles, shell?: Readonly<Record<string, string | undefined>>, home?: string): Record<string, Record<string, string>>;
@@ -117,3 +117,50 @@ export function layeredEnv(key, files, home) {
117
117
  }
118
118
  return { values, sources };
119
119
  }
120
+ /** The sorted, unique non-empty string values of `*_env` keys at any depth of an addon's options. */
121
+ export function envOptionNames(options) {
122
+ const names = new Set();
123
+ const walk = (value) => {
124
+ if (Array.isArray(value))
125
+ value.forEach(walk);
126
+ else if (value && typeof value === 'object')
127
+ for (const [key, child] of Object.entries(value)) {
128
+ if (/_env$/.test(key) && typeof child === 'string' && child)
129
+ names.add(child);
130
+ else
131
+ walk(child);
132
+ }
133
+ };
134
+ walk(options);
135
+ return [...names].sort();
136
+ }
137
+ /** An addon's `names` from a non-empty shell value, else the project file, else the machine file. */
138
+ export function addonEnv(names, project, files, shell = process.env, home) {
139
+ const key = { project, runtime: '', harness: '', alias: '' };
140
+ const layered = layeredEnv(key, files, home);
141
+ const values = {};
142
+ const sources = {};
143
+ for (const name of names) {
144
+ const fromShell = shell[name];
145
+ const value = fromShell || layered.values[name];
146
+ if (!value)
147
+ continue;
148
+ values[name] = value;
149
+ sources[name] = fromShell ? 'shell' : layered.sources[name];
150
+ }
151
+ return {
152
+ values,
153
+ sources,
154
+ searched: ['shell', ...envLayerPaths(key, home).reverse()],
155
+ };
156
+ }
157
+ /** Per addon, each named variable's source (`shell`, a file path or `unset`); never a value. */
158
+ export function addonEnvSources(addonNames, project, files, shell = process.env, home) {
159
+ return Object.fromEntries(Object.entries(addonNames).map(([addon, names]) => {
160
+ const { sources } = addonEnv(names, project, files, shell, home);
161
+ return [
162
+ addon,
163
+ Object.fromEntries(names.map((n) => [n, sources[n] ?? 'unset'])),
164
+ ];
165
+ }));
166
+ }
@@ -29,7 +29,7 @@ export { protectedProjectPaths } from './core/protected-project-paths.js';
29
29
  export { normalizeRepoUrl } from './core/repo-url.js';
30
30
  export { createRunClone, loadRunClone, type RunClone, type RunCloneOptions, registerRunCloneWorktree, removeRunClone, runCloneGitDir, saveRunClone, } from './core/run-clone.js';
31
31
  export { cliRootOf } from './core/runtime-paths.js';
32
- export { type EnvFiles, type EnvKey, envLayerPaths, envsDir, layeredEnv, loadEnvFiles, loadSecretsFile, parseSecretsFile, pickSecrets, type Secrets, secretsFilePath, } from './core/secrets-file.js';
32
+ export { type AddonEnv, addonEnv, addonEnvSources, type EnvFiles, type EnvKey, envLayerPaths, envOptionNames, envsDir, layeredEnv, loadEnvFiles, loadSecretsFile, parseSecretsFile, pickSecrets, type Secrets, secretsFilePath, } from './core/secrets-file.js';
33
33
  export { shellQuote } from './core/shell.js';
34
34
  export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
35
35
  export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
package/dist/src/index.js CHANGED
@@ -30,7 +30,7 @@ export { protectedProjectPaths } from './core/protected-project-paths.js';
30
30
  export { normalizeRepoUrl } from './core/repo-url.js';
31
31
  export { createRunClone, loadRunClone, registerRunCloneWorktree, removeRunClone, runCloneGitDir, saveRunClone, } from './core/run-clone.js';
32
32
  export { cliRootOf } from './core/runtime-paths.js';
33
- export { envLayerPaths, envsDir, layeredEnv, loadEnvFiles, loadSecretsFile, parseSecretsFile, pickSecrets, secretsFilePath, } from './core/secrets-file.js';
33
+ export { addonEnv, addonEnvSources, envLayerPaths, envOptionNames, envsDir, layeredEnv, loadEnvFiles, loadSecretsFile, parseSecretsFile, pickSecrets, secretsFilePath, } from './core/secrets-file.js';
34
34
  export { shellQuote } from './core/shell.js';
35
35
  export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
36
36
  export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/core",
3
- "version": "0.19.1-next.3",
3
+ "version": "0.19.1-next.4",
4
4
  "description": "bakers.build surface-agnostic kernel: host contract, split-config helpers, addon preset/discovery machinery, shared primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "yaml": "^2.7.0"
41
41
  },
42
42
  "bakersBuild": {
43
- "commit": "81f2970d26d8cf6b4367eb513b68032c8aabe616",
43
+ "commit": "682730a11f21199f6bccc581bce98fead5655458",
44
44
  "channel": "next"
45
45
  }
46
46
  }