@dsmrt/axiom-config 1.2.7 → 1.2.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @dsmrt/axiom-config
2
2
 
3
+ ## 1.2.10
4
+
5
+ ### Patch Changes
6
+
7
+ - cbe2273: chore: bump all packages to pick up dependency updates
8
+
9
+ ## 1.2.9
10
+
11
+ ### Patch Changes
12
+
13
+ - d5d1a20: chore: remove glob dependency, update AWS SDK and tooling deps
14
+
15
+ Replace glob with native node:fs existsSync for config file discovery.
16
+ Bump @aws-sdk/* from 3.716 to 3.1127, @biomejs/biome to 2.5.12, tsup to 8.5.1.
17
+ - d5d1a20: fix: prod env uses no-suffix config file, falls back to .axiom.prod.*
18
+
19
+ When the active env equals `prodEnvName` (default `"prod"`), `loadConfig` now
20
+ treats the bare config file (`.axiom.js` / `.axiom.json` / `.axiom.ts`) as the
21
+ complete prod config and no longer also tries to load `.axiom.prod.*` on top of
22
+ it. `.axiom.prod.*` is only consulted as a fallback when no no-suffix file
23
+ exists. `ENV=prod` and `--env prod` no longer throw when only a bare config
24
+ file is present.
25
+
26
+ ## 1.2.8
27
+
28
+ ### Patch Changes
29
+
30
+ - e9ce7e2: fix: prod env uses no-suffix config file, falls back to .axiom.prod.\*
31
+
32
+ When the active env equals `prodEnvName` (default `"prod"`), `loadConfig` now
33
+ treats the bare config file (`.axiom.js` / `.axiom.json` / `.axiom.ts`) as the
34
+ complete prod config and no longer also tries to load `.axiom.prod.*` on top of
35
+ it. `.axiom.prod.*` is only consulted as a fallback when no no-suffix file
36
+ exists. `ENV=prod` and `--env prod` no longer throw when only a bare config
37
+ file is present.
38
+
3
39
  ## 1.2.7
4
40
 
5
41
  ### Patch Changes
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ __export(index_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(index_exports);
32
32
  var import_node_fs = require("fs");
33
- var import_glob = require("glob");
33
+ var import_node_path = require("path");
34
34
  var isDebugEnabled = () => process.env.AXIOM_DEBUG === "true" || process.env.AXIOM_DEBUG === "1";
35
35
  var debug = (message, ...args) => {
36
36
  if (isDebugEnabled()) {
@@ -112,22 +112,45 @@ var loadConfig = async (input) => {
112
112
  })
113
113
  );
114
114
  debug(`Looking for base config file...`);
115
- const baseConfigFile = configPath({
116
- ...input,
117
- env: void 0
118
- });
119
- debug(`Loading base config from: ${baseConfigFile}`);
120
- const baseConfig = await importConfigFromPath(baseConfigFile);
121
- debug(`Base config loaded: ${baseConfig.name} (env: ${baseConfig.env})`);
115
+ let baseConfigFile;
116
+ try {
117
+ baseConfigFile = configPath({ ...input, env: void 0 });
118
+ } catch {
119
+ }
120
+ let baseConfig;
122
121
  let overrides = input?.overrides || {};
123
122
  if (env) {
124
- debug(`Looking for environment-specific config for: ${env}`);
125
- const envConfigPath = configPath({ ...input, env });
126
- debug(`Loading env config from: ${envConfigPath}`);
127
- const devConfig = await importConfigFromPath(envConfigPath);
128
- debug(`Env config loaded: ${devConfig.name} (env: ${devConfig.env})`);
129
- overrides = mergeDeep(devConfig, overrides);
130
- debug(`Merged env config with overrides`);
123
+ const tempBase = baseConfigFile ? await importConfigFromPath(baseConfigFile) : null;
124
+ if (tempBase) {
125
+ debug(`Base config loaded: ${tempBase.name} (env: ${tempBase.env})`);
126
+ }
127
+ const prodEnvName = tempBase?.prodEnvName ?? "prod";
128
+ if (env === prodEnvName) {
129
+ if (tempBase) {
130
+ debug(`Using base config as prod config`);
131
+ baseConfig = tempBase;
132
+ } else {
133
+ const prodConfigFile = configPath({ ...input, env });
134
+ debug(`Loading prod config from: ${prodConfigFile}`);
135
+ baseConfig = await importConfigFromPath(prodConfigFile);
136
+ debug(`Prod config loaded: ${baseConfig.name} (env: ${baseConfig.env})`);
137
+ }
138
+ } else {
139
+ const file = baseConfigFile ?? configPath({ ...input, env: void 0 });
140
+ baseConfig = tempBase ?? await importConfigFromPath(file);
141
+ debug(`Looking for environment-specific config for: ${env}`);
142
+ const envConfigPath = configPath({ ...input, env });
143
+ debug(`Loading env config from: ${envConfigPath}`);
144
+ const envConfig = await importConfigFromPath(envConfigPath);
145
+ debug(`Env config loaded: ${envConfig.name} (env: ${envConfig.env})`);
146
+ overrides = mergeDeep(envConfig, overrides);
147
+ debug(`Merged env config with overrides`);
148
+ }
149
+ } else {
150
+ const file = baseConfigFile ?? configPath({ ...input, env: void 0 });
151
+ debug(`Loading base config from: ${file}`);
152
+ baseConfig = await importConfigFromPath(file);
153
+ debug(`Base config loaded: ${baseConfig.name} (env: ${baseConfig.env})`);
131
154
  }
132
155
  const configObject = mergeDeep(baseConfig, overrides);
133
156
  debug(
@@ -156,32 +179,28 @@ function mergeDeep(target, ...sources) {
156
179
  var configPath = (input) => {
157
180
  const envIndicator = input?.env ? `.${input.env}` : "";
158
181
  const extensions = ["json", "js", "mjs", "ts", "mts"];
159
- const pattern = `.axiom${envIndicator}.{${extensions.join(",")}}`;
182
+ const prefix = `.axiom${envIndicator}`;
160
183
  debug(
161
- `Searching for config files with pattern: ${pattern}`,
184
+ `Searching for config files matching: ${prefix}.{${extensions.join(",")}}`,
162
185
  input?.cwd ? `from ${input.cwd}` : "from current directory"
163
186
  );
164
187
  const cwd = input?.cwd || process.cwd();
165
188
  let currentDir = cwd;
166
189
  let found;
167
190
  while (true) {
168
- const matches = (0, import_glob.globSync)(pattern, {
169
- cwd: currentDir,
170
- absolute: true,
171
- nodir: true
172
- });
191
+ const matches = extensions.map((ext) => (0, import_node_path.join)(currentDir, `${prefix}.${ext}`)).filter(import_node_fs.existsSync);
173
192
  if (matches.length > 0) {
174
193
  found = matches[0];
175
194
  break;
176
195
  }
177
- const parent = require("path").dirname(currentDir);
196
+ const parent = (0, import_node_path.dirname)(currentDir);
178
197
  if (parent === currentDir) {
179
198
  break;
180
199
  }
181
200
  currentDir = parent;
182
201
  }
183
202
  if (found === void 0) {
184
- debug(`Config file not found! Searched for pattern: ${pattern}`);
203
+ debug(`Config file not found! Searched for: ${prefix}.{${extensions.join(",")}}`);
185
204
  throw new Error(
186
205
  `Axiom config files not found: .axiom${envIndicator}.json, .axiom${envIndicator}.js .axiom${envIndicator}.ts`
187
206
  );
package/dist/index.mjs CHANGED
@@ -6,8 +6,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  });
7
7
 
8
8
  // src/index.ts
9
- import { readFileSync } from "node:fs";
10
- import { globSync } from "glob";
9
+ import { existsSync, readFileSync } from "fs";
10
+ import { dirname, join } from "path";
11
11
  var isDebugEnabled = () => process.env.AXIOM_DEBUG === "true" || process.env.AXIOM_DEBUG === "1";
12
12
  var debug = (message, ...args) => {
13
13
  if (isDebugEnabled()) {
@@ -89,22 +89,45 @@ var loadConfig = async (input) => {
89
89
  })
90
90
  );
91
91
  debug(`Looking for base config file...`);
92
- const baseConfigFile = configPath({
93
- ...input,
94
- env: void 0
95
- });
96
- debug(`Loading base config from: ${baseConfigFile}`);
97
- const baseConfig = await importConfigFromPath(baseConfigFile);
98
- debug(`Base config loaded: ${baseConfig.name} (env: ${baseConfig.env})`);
92
+ let baseConfigFile;
93
+ try {
94
+ baseConfigFile = configPath({ ...input, env: void 0 });
95
+ } catch {
96
+ }
97
+ let baseConfig;
99
98
  let overrides = input?.overrides || {};
100
99
  if (env) {
101
- debug(`Looking for environment-specific config for: ${env}`);
102
- const envConfigPath = configPath({ ...input, env });
103
- debug(`Loading env config from: ${envConfigPath}`);
104
- const devConfig = await importConfigFromPath(envConfigPath);
105
- debug(`Env config loaded: ${devConfig.name} (env: ${devConfig.env})`);
106
- overrides = mergeDeep(devConfig, overrides);
107
- debug(`Merged env config with overrides`);
100
+ const tempBase = baseConfigFile ? await importConfigFromPath(baseConfigFile) : null;
101
+ if (tempBase) {
102
+ debug(`Base config loaded: ${tempBase.name} (env: ${tempBase.env})`);
103
+ }
104
+ const prodEnvName = tempBase?.prodEnvName ?? "prod";
105
+ if (env === prodEnvName) {
106
+ if (tempBase) {
107
+ debug(`Using base config as prod config`);
108
+ baseConfig = tempBase;
109
+ } else {
110
+ const prodConfigFile = configPath({ ...input, env });
111
+ debug(`Loading prod config from: ${prodConfigFile}`);
112
+ baseConfig = await importConfigFromPath(prodConfigFile);
113
+ debug(`Prod config loaded: ${baseConfig.name} (env: ${baseConfig.env})`);
114
+ }
115
+ } else {
116
+ const file = baseConfigFile ?? configPath({ ...input, env: void 0 });
117
+ baseConfig = tempBase ?? await importConfigFromPath(file);
118
+ debug(`Looking for environment-specific config for: ${env}`);
119
+ const envConfigPath = configPath({ ...input, env });
120
+ debug(`Loading env config from: ${envConfigPath}`);
121
+ const envConfig = await importConfigFromPath(envConfigPath);
122
+ debug(`Env config loaded: ${envConfig.name} (env: ${envConfig.env})`);
123
+ overrides = mergeDeep(envConfig, overrides);
124
+ debug(`Merged env config with overrides`);
125
+ }
126
+ } else {
127
+ const file = baseConfigFile ?? configPath({ ...input, env: void 0 });
128
+ debug(`Loading base config from: ${file}`);
129
+ baseConfig = await importConfigFromPath(file);
130
+ debug(`Base config loaded: ${baseConfig.name} (env: ${baseConfig.env})`);
108
131
  }
109
132
  const configObject = mergeDeep(baseConfig, overrides);
110
133
  debug(
@@ -133,32 +156,28 @@ function mergeDeep(target, ...sources) {
133
156
  var configPath = (input) => {
134
157
  const envIndicator = input?.env ? `.${input.env}` : "";
135
158
  const extensions = ["json", "js", "mjs", "ts", "mts"];
136
- const pattern = `.axiom${envIndicator}.{${extensions.join(",")}}`;
159
+ const prefix = `.axiom${envIndicator}`;
137
160
  debug(
138
- `Searching for config files with pattern: ${pattern}`,
161
+ `Searching for config files matching: ${prefix}.{${extensions.join(",")}}`,
139
162
  input?.cwd ? `from ${input.cwd}` : "from current directory"
140
163
  );
141
164
  const cwd = input?.cwd || process.cwd();
142
165
  let currentDir = cwd;
143
166
  let found;
144
167
  while (true) {
145
- const matches = globSync(pattern, {
146
- cwd: currentDir,
147
- absolute: true,
148
- nodir: true
149
- });
168
+ const matches = extensions.map((ext) => join(currentDir, `${prefix}.${ext}`)).filter(existsSync);
150
169
  if (matches.length > 0) {
151
170
  found = matches[0];
152
171
  break;
153
172
  }
154
- const parent = __require("node:path").dirname(currentDir);
173
+ const parent = dirname(currentDir);
155
174
  if (parent === currentDir) {
156
175
  break;
157
176
  }
158
177
  currentDir = parent;
159
178
  }
160
179
  if (found === void 0) {
161
- debug(`Config file not found! Searched for pattern: ${pattern}`);
180
+ debug(`Config file not found! Searched for: ${prefix}.{${extensions.join(",")}}`);
162
181
  throw new Error(
163
182
  `Axiom config files not found: .axiom${envIndicator}.json, .axiom${envIndicator}.js .axiom${envIndicator}.ts`
164
183
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsmrt/axiom-config",
3
- "version": "1.2.7",
3
+ "version": "1.2.10",
4
4
  "description": "Config library for axiom cli",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -24,18 +24,17 @@
24
24
  },
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@biomejs/biome": "^2.3.8",
28
- "@changesets/cli": "^2.27.11",
29
- "@types/node": "^22.12.0",
30
- "@types/yargs": "^17.0.33",
31
- "@vitest/coverage-v8": "^4.0.0",
27
+ "@biomejs/biome": "^2.5.12",
28
+ "@changesets/cli": "^3.0.2",
29
+ "@types/node": "^26.4.1",
30
+ "@types/yargs": "^17.0.35",
31
+ "@vitest/coverage-v8": "^5.0.0",
32
32
  "ts-node": "^10.9.2",
33
- "tsup": "^8.3.5",
33
+ "tsup": "^8.5.1",
34
34
  "typescript": "^5.7.2",
35
- "vitest": "^4.1.0"
35
+ "vitest": "^5.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "glob": "^10.5.0",
39
38
  "yargs": "^17.7.2"
40
39
  },
41
40
  "scripts": {