@dsmrt/axiom-config 0.2.3 → 1.0.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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -11
- package/dist/index.mjs +14 -9
- package/package.json +7 -10
- package/tsconfig.json +10 -10
- package/vitest.config.mts +9 -9
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -38,8 +38,8 @@ interface LoadConfigInput {
|
|
|
38
38
|
*/
|
|
39
39
|
cwd?: string;
|
|
40
40
|
}
|
|
41
|
-
declare const importConfigFromPath: (path: string) => Config
|
|
42
|
-
declare const loadConfig: <T extends object>(input?: LoadConfigInput) => ConfigContainer & T
|
|
41
|
+
declare const importConfigFromPath: (path: string) => Promise<Config>;
|
|
42
|
+
declare const loadConfig: <T extends object>(input?: LoadConfigInput) => Promise<ConfigContainer & T>;
|
|
43
43
|
/**
|
|
44
44
|
* Simple object check.
|
|
45
45
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ interface LoadConfigInput {
|
|
|
38
38
|
*/
|
|
39
39
|
cwd?: string;
|
|
40
40
|
}
|
|
41
|
-
declare const importConfigFromPath: (path: string) => Config
|
|
42
|
-
declare const loadConfig: <T extends object>(input?: LoadConfigInput) => ConfigContainer & T
|
|
41
|
+
declare const importConfigFromPath: (path: string) => Promise<Config>;
|
|
42
|
+
declare const loadConfig: <T extends object>(input?: LoadConfigInput) => Promise<ConfigContainer & T>;
|
|
43
43
|
/**
|
|
44
44
|
* Simple object check.
|
|
45
45
|
*/
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
mergeDeep: () => mergeDeep
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
var
|
|
31
|
+
var import_node_fs = require("fs");
|
|
32
32
|
var import_find_up = require("find-up");
|
|
33
33
|
var ConfigContainer = class {
|
|
34
34
|
name;
|
|
@@ -45,30 +45,35 @@ var ConfigContainer = class {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
isProd() {
|
|
48
|
-
return this.env
|
|
48
|
+
return this.env === this.prodEnvName;
|
|
49
49
|
}
|
|
50
50
|
asParameterPath(name) {
|
|
51
|
-
return this.aws.baseParameterPath.replace(
|
|
51
|
+
return `${this.aws.baseParameterPath.replace(/\/+$/, "")}/${name}`;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
var importConfigFromPath = (path) => {
|
|
54
|
+
var importConfigFromPath = async (path) => {
|
|
55
55
|
if (/\.json$/.test(path)) {
|
|
56
|
-
return JSON.parse((0,
|
|
56
|
+
return JSON.parse((0, import_node_fs.readFileSync)(path).toString());
|
|
57
57
|
}
|
|
58
|
-
if (/\.(m)?
|
|
59
|
-
|
|
58
|
+
if (/\.((m)?ts|mjs)$/.test(path)) {
|
|
59
|
+
const loaded = await import(path);
|
|
60
|
+
return loaded.default || loaded;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
if (/\.(m)?js$/.test(path)) {
|
|
63
|
+
const loaded = require(path);
|
|
64
|
+
return loaded.default || loaded;
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Unsupported file type or path not found: ${path}`);
|
|
62
67
|
};
|
|
63
|
-
var loadConfig = (input) => {
|
|
68
|
+
var loadConfig = async (input) => {
|
|
64
69
|
const baseConfigFile = configPath({
|
|
65
70
|
...input,
|
|
66
71
|
env: void 0
|
|
67
72
|
});
|
|
68
|
-
const baseConfig = importConfigFromPath(baseConfigFile);
|
|
73
|
+
const baseConfig = await importConfigFromPath(baseConfigFile);
|
|
69
74
|
let overrides = input?.overrides || {};
|
|
70
75
|
if (input?.env) {
|
|
71
|
-
const devConfig = importConfigFromPath(configPath(input));
|
|
76
|
+
const devConfig = await importConfigFromPath(configPath(input));
|
|
72
77
|
overrides = mergeDeep(devConfig, overrides);
|
|
73
78
|
}
|
|
74
79
|
const configObject = mergeDeep(baseConfig, overrides);
|
package/dist/index.mjs
CHANGED
|
@@ -23,30 +23,35 @@ var ConfigContainer = class {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
isProd() {
|
|
26
|
-
return this.env
|
|
26
|
+
return this.env === this.prodEnvName;
|
|
27
27
|
}
|
|
28
28
|
asParameterPath(name) {
|
|
29
|
-
return this.aws.baseParameterPath.replace(
|
|
29
|
+
return `${this.aws.baseParameterPath.replace(/\/+$/, "")}/${name}`;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
var importConfigFromPath = (path) => {
|
|
32
|
+
var importConfigFromPath = async (path) => {
|
|
33
33
|
if (/\.json$/.test(path)) {
|
|
34
34
|
return JSON.parse(readFileSync(path).toString());
|
|
35
35
|
}
|
|
36
|
-
if (/\.(m)?
|
|
37
|
-
|
|
36
|
+
if (/\.((m)?ts|mjs)$/.test(path)) {
|
|
37
|
+
const loaded = await import(path);
|
|
38
|
+
return loaded.default || loaded;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
if (/\.(m)?js$/.test(path)) {
|
|
41
|
+
const loaded = __require(path);
|
|
42
|
+
return loaded.default || loaded;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Unsupported file type or path not found: ${path}`);
|
|
40
45
|
};
|
|
41
|
-
var loadConfig = (input) => {
|
|
46
|
+
var loadConfig = async (input) => {
|
|
42
47
|
const baseConfigFile = configPath({
|
|
43
48
|
...input,
|
|
44
49
|
env: void 0
|
|
45
50
|
});
|
|
46
|
-
const baseConfig = importConfigFromPath(baseConfigFile);
|
|
51
|
+
const baseConfig = await importConfigFromPath(baseConfigFile);
|
|
47
52
|
let overrides = input?.overrides || {};
|
|
48
53
|
if (input?.env) {
|
|
49
|
-
const devConfig = importConfigFromPath(configPath(input));
|
|
54
|
+
const devConfig = await importConfigFromPath(configPath(input));
|
|
50
55
|
overrides = mergeDeep(devConfig, overrides);
|
|
51
56
|
}
|
|
52
57
|
const configObject = mergeDeep(baseConfig, overrides);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsmrt/axiom-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Config library for axiom cli",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -24,26 +24,23 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"@biomejs/biome": "^2.3.8",
|
|
27
28
|
"@changesets/cli": "^2.27.11",
|
|
28
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^22.12.0",
|
|
29
30
|
"@types/yargs": "^17.0.33",
|
|
30
|
-
"@
|
|
31
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
32
|
-
"@vitest/coverage-v8": "^1.6.0",
|
|
33
|
-
"eslint": "^8.57.1",
|
|
34
|
-
"prettier": "^3.4.2",
|
|
31
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
35
32
|
"ts-node": "^10.9.2",
|
|
36
33
|
"tsup": "^8.3.5",
|
|
37
34
|
"typescript": "^5.7.2",
|
|
38
|
-
"vitest": "^
|
|
35
|
+
"vitest": "^4.0.0"
|
|
39
36
|
},
|
|
40
37
|
"dependencies": {
|
|
41
38
|
"find-up": "^5.0.0",
|
|
42
39
|
"yargs": "^17.7.2"
|
|
43
40
|
},
|
|
44
41
|
"scripts": {
|
|
45
|
-
"lint": "
|
|
46
|
-
"lint:fix": "
|
|
42
|
+
"lint": "biome lint",
|
|
43
|
+
"lint:fix": "biome lint --fix",
|
|
47
44
|
"test": "vitest run --coverage",
|
|
48
45
|
"watch": "vitest watch --coverage",
|
|
49
46
|
"build": "tsup --entry ./src/bin/axiom.ts --entry ./src/index.ts --format cjs,esm --dts --clean",
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"noEmit": true
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/index.ts"]
|
|
12
12
|
}
|
package/vitest.config.mts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { defineConfig } from "vitest/config";
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
test: {
|
|
6
|
+
include: ["src/**/*.test.ts"],
|
|
7
|
+
coverage: {
|
|
8
|
+
provider: "v8",
|
|
9
|
+
all: true,
|
|
10
|
+
exclude: ["lib/**/*", "src/__mocks__/**/*"],
|
|
11
|
+
reporter: ["text-summary", "json-summary"],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
14
|
});
|