@achs/env 4.11.0 → 5.0.0-alpha.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 +31 -0
- package/README.md +98 -110
- package/arguments.d.ts +14 -14
- package/arguments.d.ts.map +1 -1
- package/arguments.js +135 -131
- package/arguments.js.map +1 -1
- package/commands/env.command.d.ts +8 -2
- package/commands/env.command.d.ts.map +1 -1
- package/commands/env.command.js +55 -82
- package/commands/env.command.js.map +1 -1
- package/commands/export.command.d.ts +8 -2
- package/commands/export.command.d.ts.map +1 -1
- package/commands/export.command.js +53 -62
- package/commands/export.command.js.map +1 -1
- package/commands/index.d.ts +5 -5
- package/commands/index.d.ts.map +1 -1
- package/commands/index.js +5 -14
- package/commands/pull.command.d.ts +6 -1
- package/commands/pull.command.d.ts.map +1 -1
- package/commands/pull.command.js +20 -37
- package/commands/pull.command.js.map +1 -1
- package/commands/push.command.d.ts +6 -1
- package/commands/push.command.d.ts.map +1 -1
- package/commands/push.command.js +20 -36
- package/commands/push.command.js.map +1 -1
- package/commands/schema.command.d.ts +6 -1
- package/commands/schema.command.d.ts.map +1 -1
- package/commands/schema.command.js +16 -17
- package/commands/schema.command.js.map +1 -1
- package/exec.d.ts +7 -1
- package/exec.d.ts.map +1 -1
- package/exec.js +84 -158
- package/exec.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +3 -20
- package/interfaces/index.d.ts +1 -1
- package/interfaces/index.d.ts.map +1 -1
- package/interfaces/loader.interface.d.ts +29 -3
- package/interfaces/loader.interface.d.ts.map +1 -1
- package/main.d.ts +0 -1
- package/main.js +7 -26
- package/main.js.map +1 -1
- package/package.json +56 -35
- package/providers/app-settings.provider.d.ts +5 -2
- package/providers/app-settings.provider.d.ts.map +1 -1
- package/providers/app-settings.provider.js +36 -49
- package/providers/app-settings.provider.js.map +1 -1
- package/providers/azure-key-vault.provider.d.ts +12 -7
- package/providers/azure-key-vault.provider.d.ts.map +1 -1
- package/providers/azure-key-vault.provider.js +138 -158
- package/providers/azure-key-vault.provider.js.map +1 -1
- package/providers/index.d.ts +2 -2
- package/providers/index.d.ts.map +1 -1
- package/providers/index.js +18 -28
- package/providers/index.js.map +1 -1
- package/providers/local.provider.d.ts +5 -2
- package/providers/local.provider.d.ts.map +1 -1
- package/providers/local.provider.js +27 -40
- package/providers/local.provider.js.map +1 -1
- package/providers/package-json.provider.d.ts +5 -2
- package/providers/package-json.provider.d.ts.map +1 -1
- package/providers/package-json.provider.js +26 -28
- package/providers/package-json.provider.js.map +1 -1
- package/utils/argv.util.d.ts +10 -0
- package/utils/argv.util.d.ts.map +1 -0
- package/utils/argv.util.js +24 -0
- package/utils/argv.util.js.map +1 -0
- package/utils/command.util.d.ts +70 -3
- package/utils/command.util.d.ts.map +1 -1
- package/utils/command.util.js +60 -140
- package/utils/command.util.js.map +1 -1
- package/utils/index.d.ts +7 -6
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +8 -23
- package/utils/interpolate.util.d.ts +29 -1
- package/utils/interpolate.util.d.ts.map +1 -1
- package/utils/interpolate.util.js +12 -30
- package/utils/interpolate.util.js.map +1 -1
- package/utils/json.util.d.ts +41 -3
- package/utils/json.util.d.ts.map +1 -1
- package/utils/json.util.js +24 -42
- package/utils/json.util.js.map +1 -1
- package/utils/logger.d.ts +21 -2
- package/utils/logger.d.ts.map +1 -1
- package/utils/logger.js +31 -17
- package/utils/logger.js.map +1 -1
- package/utils/normalize.util.d.ts +24 -2
- package/utils/normalize.util.d.ts.map +1 -1
- package/utils/normalize.util.js +35 -56
- package/utils/normalize.util.js.map +1 -1
- package/utils/schema.util.d.ts +59 -0
- package/utils/schema.util.d.ts.map +1 -1
- package/utils/schema.util.js +62 -97
- package/utils/schema.util.js.map +1 -1
- package/commands/index.js.map +0 -1
- package/index.js.map +0 -1
- package/interfaces/index.js +0 -18
- package/interfaces/index.js.map +0 -1
- package/interfaces/loader.interface.js +0 -3
- package/interfaces/loader.interface.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils/index.js.map +0 -1
package/exec.js
CHANGED
|
@@ -1,162 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
modes: arguments_1.args.modes.alias,
|
|
57
|
-
configFile: arguments_1.args.configFile.alias,
|
|
58
|
-
logLevel: arguments_1.args.logLevel.alias,
|
|
59
|
-
logMaskAnyRegEx: arguments_1.args.logMaskAnyRegEx.alias,
|
|
60
|
-
logMaskValuesOfKeys: arguments_1.args.logMaskValuesOfKeys.alias
|
|
61
|
-
},
|
|
62
|
-
default: {
|
|
63
|
-
root: arguments_1.args.root.default,
|
|
64
|
-
configFile: arguments_1.args.configFile.default
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
await (0, utils_1.loadConfigFile)(preloadedArgv, delimiters);
|
|
68
|
-
preloadedArgv.logLevel ??= arguments_1.args.logLevel.default;
|
|
69
|
-
preloadedArgv.logMaskAnyRegEx ??= arguments_1.args.logMaskAnyRegEx.default;
|
|
70
|
-
preloadedArgv.logMaskValuesOfKeys ??= arguments_1.args.logMaskValuesOfKeys.default;
|
|
71
|
-
preloadedArgv.providers ??= arguments_1.args.providers.default;
|
|
72
|
-
const { logLevel, logMaskAnyRegEx, logMaskValuesOfKeys } = preloadedArgv;
|
|
73
|
-
utils_1.logger.setSettings({
|
|
74
|
-
minLevel: logLevel,
|
|
75
|
-
maskAnyRegEx: logMaskAnyRegEx,
|
|
76
|
-
maskValuesOfKeys: logMaskValuesOfKeys
|
|
77
|
-
});
|
|
78
|
-
if (logLevel === 'silly' || logLevel === 'trace')
|
|
79
|
-
process.env.AKV_DEBUG = 'true';
|
|
80
|
-
return preloadedArgv;
|
|
1
|
+
import { getSubcommand as e, loadConfigFile as t, loadProjectInfo as n, loadSchemaFile as r } from "./utils/command.util.js";
|
|
2
|
+
import { interpolateJson as i } from "./utils/interpolate.util.js";
|
|
3
|
+
import { resolvePath as a } from "./utils/json.util.js";
|
|
4
|
+
import { configureLogger as o, logger as s } from "./utils/logger.js";
|
|
5
|
+
import "./utils/index.js";
|
|
6
|
+
import { IntegratedProviders as c } from "./providers/index.js";
|
|
7
|
+
import { args as l } from "./arguments.js";
|
|
8
|
+
import { envCommand as u } from "./commands/env.command.js";
|
|
9
|
+
import { exportCommand as d } from "./commands/export.command.js";
|
|
10
|
+
import { pullCommand as f } from "./commands/pull.command.js";
|
|
11
|
+
import { pushCommand as p } from "./commands/push.command.js";
|
|
12
|
+
import { schemaCommand as m } from "./commands/schema.command.js";
|
|
13
|
+
import "./commands/index.js";
|
|
14
|
+
import h from "picocolors";
|
|
15
|
+
import { readFileSync as g } from "node:fs";
|
|
16
|
+
import { fileURLToPath as _ } from "node:url";
|
|
17
|
+
import v from "yargs";
|
|
18
|
+
import { Parser as y } from "yargs/helpers";
|
|
19
|
+
//#region src/exec.ts
|
|
20
|
+
async function b(e, n, r) {
|
|
21
|
+
let i = y.detailed(e, {
|
|
22
|
+
array: [
|
|
23
|
+
"modes",
|
|
24
|
+
"logMaskAnyRegEx",
|
|
25
|
+
"logMaskValuesOfKeys"
|
|
26
|
+
],
|
|
27
|
+
boolean: ["help"],
|
|
28
|
+
configuration: n,
|
|
29
|
+
string: [
|
|
30
|
+
"root",
|
|
31
|
+
"env",
|
|
32
|
+
"configFile",
|
|
33
|
+
"schemaFile",
|
|
34
|
+
"logLevel"
|
|
35
|
+
],
|
|
36
|
+
alias: {
|
|
37
|
+
configFile: l.configFile.alias,
|
|
38
|
+
env: l.env.alias,
|
|
39
|
+
logLevel: l.logLevel.alias,
|
|
40
|
+
logMaskAnyRegEx: l.logMaskAnyRegEx.alias,
|
|
41
|
+
logMaskValuesOfKeys: l.logMaskValuesOfKeys.alias,
|
|
42
|
+
modes: l.modes.alias
|
|
43
|
+
},
|
|
44
|
+
default: {
|
|
45
|
+
configFile: l.configFile.default,
|
|
46
|
+
root: l.root.default
|
|
47
|
+
}
|
|
48
|
+
}).argv;
|
|
49
|
+
await t(i, r), i.logLevel ??= l.logLevel.default, i.logMaskAnyRegEx ??= l.logMaskAnyRegEx.default, i.logMaskValuesOfKeys ??= l.logMaskValuesOfKeys.default, i.providers ??= l.providers.default;
|
|
50
|
+
let { logLevel: a, logMaskAnyRegEx: c, logMaskValuesOfKeys: u } = i;
|
|
51
|
+
return o(s, {
|
|
52
|
+
maskAnyRegEx: c,
|
|
53
|
+
maskValuesOfKeys: u,
|
|
54
|
+
minLevel: a
|
|
55
|
+
}), (a === "silly" || a === "trace") && (process.env.AKV_DEBUG = "true"), i;
|
|
81
56
|
}
|
|
82
|
-
async function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
utils_1.logger.info(`loading${envMsg}${env && modes ? ' in' : ''}${modesMsg}`);
|
|
98
|
-
for (const provider of providers) {
|
|
99
|
-
try {
|
|
100
|
-
utils_1.logger.debug(`using ${picocolors_1.default.yellow(provider.path)} provider`);
|
|
101
|
-
if (!provider.type || provider.type === 'integrated') {
|
|
102
|
-
provider.handler = providers_1.IntegratedProviders[provider.path];
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const { default: module } = await Promise.resolve(`${provider.type === 'module'
|
|
106
|
-
? provider.path
|
|
107
|
-
: (0, utils_1.resolvePath)(provider.path)}`).then(s => __importStar(require(s)));
|
|
108
|
-
provider.handler = module;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
utils_1.logger.error(`${picocolors_1.default.yellow(provider.path)} provider not found or not compatible`);
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
build(rawArgv, preloadedArgv, subcommand, config, version);
|
|
57
|
+
async function x(t) {
|
|
58
|
+
let { config: n, version: r } = JSON.parse(g(_(new URL("package.json", "" + import.meta.url)), "utf8")), i = e(t, n.delimiters.subcommand), o = await b(t, n.parser, n.delimiters.template), { env: l, help: u, modes: d, providers: f } = o;
|
|
59
|
+
u && S(t, o, i, n, r), (!Array.isArray(f) || f.length === 0) && (s.error("no providers found"), process.exit(1));
|
|
60
|
+
let p = l ? ` ${h.bold(h.underline(h.green(l)))} environment` : "", m = d ? ` ${h.bold(h.magenta(d.join("+")))} mode` : "";
|
|
61
|
+
s.info(`loading${p}${l && d ? " in" : ""}${m}`);
|
|
62
|
+
for (let e of f) try {
|
|
63
|
+
if (s.debug(`using ${h.yellow(e.path)} provider`), !e.type || e.type === "integrated") e.handler = c[e.path];
|
|
64
|
+
else {
|
|
65
|
+
let { default: t } = await (e.type === "module" ? import(e.path) : import(a(e.path)));
|
|
66
|
+
e.handler = t;
|
|
67
|
+
}
|
|
68
|
+
} catch {
|
|
69
|
+
s.error(`${h.yellow(e.path)} provider not found or not compatible`), process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
S(t, o, i, n, r);
|
|
117
72
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (subcommand?.length > 0)
|
|
130
|
-
argv.subcmd = subcommand;
|
|
131
|
-
Object.assign(argv, preloadedArgv);
|
|
132
|
-
utils_1.logger.silly('interpolating arguments surrounded by', picocolors_1.default.bold(picocolors_1.default.yellow(`${config.delimiters.template[0]} ${config.delimiters.template[1]}`)));
|
|
133
|
-
const subcmdAux = argv.subcmd;
|
|
134
|
-
(0, utils_1.interpolateJson)(argv, argv, config.delimiters.template);
|
|
135
|
-
if (Array.isArray(argv.subcmd)) {
|
|
136
|
-
for (const index in argv.subcmd) {
|
|
137
|
-
if (argv.subcmd[index]?.includes('undefined'))
|
|
138
|
-
argv.subcmd[index] = subcmdAux[index];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
utils_1.logger.silly('config loaded:', argv);
|
|
142
|
-
[argv.projectInfo, argv.schema] = await Promise.all([
|
|
143
|
-
(0, utils_1.loadProjectInfo)((argv.packageJson ?? argv.pkg)),
|
|
144
|
-
(0, utils_1.loadSchemaFile)(argv, config.delimiters.template)
|
|
145
|
-
]);
|
|
146
|
-
if (argv.schemaValidate) {
|
|
147
|
-
argv.schemaValidate = !!argv.schema;
|
|
148
|
-
if (argv.schemaValidate)
|
|
149
|
-
utils_1.logger.silly('schema loaded:', argv.schema);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
builder.command(commands_1.envCommand);
|
|
153
|
-
builder.command(commands_1.exportCommand);
|
|
154
|
-
builder.command(commands_1.pullCommand);
|
|
155
|
-
builder.command(commands_1.pushCommand);
|
|
156
|
-
builder.command(commands_1.schemaCommand);
|
|
157
|
-
const { providers } = preloadedArgv;
|
|
158
|
-
for (const { handler } of providers)
|
|
159
|
-
handler?.builder && handler.builder(builder);
|
|
160
|
-
builder.parse();
|
|
73
|
+
function S(e, t, a, o, c = "unknown") {
|
|
74
|
+
let g = v(e).strict().scriptName("env").version(c).detectLocale(!1).showHelpOnFail(!1).parserConfiguration(o.parser).usage("Usage: $0 [command] [options..] [: subcmd [:]] [options..]").options(l).middleware(async (e) => {
|
|
75
|
+
a?.length > 0 && (e.subcmd = a), Object.assign(e, t), s.silly("interpolating arguments surrounded by", h.bold(h.yellow(`${o.delimiters.template[0]} ${o.delimiters.template[1]}`)));
|
|
76
|
+
let c = e.subcmd;
|
|
77
|
+
if (i(e, e, o.delimiters.template), Array.isArray(e.subcmd)) for (let t in e.subcmd) e.subcmd[t]?.includes("undefined") && (e.subcmd[t] = c[t]);
|
|
78
|
+
s.silly("config loaded:", e), [e.projectInfo, e.schema] = await Promise.all([n(e.packageJson ?? e.pkg), r(e, o.delimiters.template)]), e.schemaValidate && (e.schemaValidate = !!e.schema, e.schemaValidate && s.silly("schema loaded:", e.schema));
|
|
79
|
+
});
|
|
80
|
+
g.command(u), g.command(d), g.command(f), g.command(p), g.command(m);
|
|
81
|
+
let { providers: _ } = t;
|
|
82
|
+
for (let { handler: e } of _) e?.builder && e.builder(g);
|
|
83
|
+
g.parse();
|
|
161
84
|
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { x as exec };
|
|
87
|
+
|
|
162
88
|
//# sourceMappingURL=exec.js.map
|
package/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,oBA0DC;AAlJD,4DAA4B;AAC5B,gEAAuC;AACvC,kDAAyC;AACzC,2CAAkD;AAClD,2CAAqD;AACrD,yCAMoB;AACpB,mCAQiB;AAajB,KAAK,UAAU,aAAa,CAC3B,OAAiB,EACjB,MAA0C,EAC1C,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AAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAIrC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACnD,IAAA,uBAAe,EAAC,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,CAAW,CAAC;YACzD,IAAA,sBAAc,EAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;SAChD,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;YAEpC,IAAI,IAAI,CAAC,cAAc;gBACtB,cAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC,CAAC,CAAC;IAGJ,OAAO,CAAC,OAAO,CAAC,qBAAU,CAAC,CAAC;IAC5B,OAAO,CAAC,OAAO,CAAC,wBAAa,CAAC,CAAC;IAC/B,OAAO,CAAC,OAAO,CAAC,sBAAW,CAAC,CAAC;IAC7B,OAAO,CAAC,OAAO,CAAC,sBAAW,CAAC,CAAC;IAC7B,OAAO,CAAC,OAAO,CAAC,wBAAa,CAAC,CAAC;IAE/B,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;IAGpC,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,SAAU;QACnC,OAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAG9C,OAAO,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"exec.js","names":[],"sources":["../src/exec.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\r\nimport { fileURLToPath } from 'node:url';\r\nimport pc from 'picocolors';\r\nimport yargs from 'yargs';\r\nimport type { Arguments } from 'yargs';\r\nimport { Parser } from 'yargs/helpers';\r\nimport { args } from './arguments.js';\r\nimport type { CommandArguments } from './arguments.js';\r\nimport {\r\n\tenvCommand,\r\n\texportCommand,\r\n\tpullCommand,\r\n\tpushCommand,\r\n\tschemaCommand,\r\n} from './commands/index.js';\r\nimport { IntegratedProviders } from './providers/index.js';\r\nimport {\r\n\tconfigureLogger,\r\n\tgetSubcommand,\r\n\tinterpolateJson,\r\n\tloadConfigFile,\r\n\tloadProjectInfo,\r\n\tloadSchemaFile,\r\n\tlogger,\r\n\tresolvePath,\r\n} from './utils/index.js';\r\n\r\ntype Alias = string[] | string;\r\n\r\n/**\r\n * Preload basic config from command line and config file.\r\n *\r\n * @param {string[]} rawArgv process.argv\r\n * @param {Partial<yargsParser.Configuration>} parser yargs parser config\r\n * @param {[string, string]} delimiters\r\n *\r\n * @returns {Promise<Partial<CommandArguments>>} preloaded config\r\n */\r\nasync function preloadConfig(\r\n\trawArgv: string[],\r\n\tparser: Record<string, unknown>,\r\n\tdelimiters: [string, string],\r\n): Promise<Partial<CommandArguments>> {\r\n\t// preload base config\r\n\tconst preloadedArgv = Parser.detailed(rawArgv, {\r\n\t\tarray: ['modes', 'logMaskAnyRegEx', 'logMaskValuesOfKeys'],\r\n\t\tboolean: ['help'],\r\n\t\tconfiguration: parser as any,\r\n\t\tstring: ['root', 'env', 'configFile', 'schemaFile', 'logLevel'],\r\n\t\talias: {\r\n\t\t\tconfigFile: args.configFile.alias as Alias,\r\n\t\t\tenv: args.env.alias as Alias,\r\n\t\t\tlogLevel: args.logLevel.alias as Alias,\r\n\t\t\tlogMaskAnyRegEx: args.logMaskAnyRegEx.alias as Alias,\r\n\t\t\tlogMaskValuesOfKeys: args.logMaskValuesOfKeys.alias as Alias,\r\n\t\t\tmodes: args.modes.alias as Alias,\r\n\t\t},\r\n\t\tdefault: {\r\n\t\t\tconfigFile: args.configFile.default,\r\n\t\t\troot: args.root.default,\r\n\t\t},\r\n\t}).argv;\r\n\r\n\t// loads configuration file\r\n\tawait loadConfigFile(preloadedArgv, delimiters);\r\n\r\n\tpreloadedArgv.logLevel ??= args.logLevel.default;\r\n\tpreloadedArgv.logMaskAnyRegEx ??= args.logMaskAnyRegEx.default;\r\n\tpreloadedArgv.logMaskValuesOfKeys ??= args.logMaskValuesOfKeys.default;\r\n\tpreloadedArgv.providers ??= args.providers.default;\r\n\r\n\tconst { logLevel, logMaskAnyRegEx, logMaskValuesOfKeys } = preloadedArgv;\r\n\r\n\t// logging level\r\n\tconfigureLogger(logger, {\r\n\t\tmaskAnyRegEx: logMaskAnyRegEx,\r\n\t\tmaskValuesOfKeys: logMaskValuesOfKeys,\r\n\t\tminLevel: logLevel,\r\n\t});\r\n\r\n\tif (logLevel === 'silly' || logLevel === 'trace')\r\n\t\tprocess.env.AKV_DEBUG = 'true';\r\n\r\n\treturn preloadedArgv;\r\n}\r\n\r\n/**\r\n * Command preprocessing and lib info\r\n * reading from package.json.\r\n * Preloads config file and setup basic config.\r\n *\r\n * @param {string[]} rawArgv process.argv\r\n */\r\nexport async function exec(rawArgv: string[]) {\r\n\t// reads some lib base config from package.json\r\n\tconst pkg = JSON.parse(\r\n\t\treadFileSync(\r\n\t\t\tfileURLToPath(new URL('package.json', import.meta.url)),\r\n\t\t\t'utf8',\r\n\t\t),\r\n\t) as { config: Record<string, any>; version: string };\r\n\tconst { config, version } = pkg;\r\n\r\n\t// execs yargs\r\n\tconst subcommand = getSubcommand(rawArgv, config.delimiters.subcommand);\r\n\r\n\tconst preloadedArgv = await preloadConfig(\r\n\t\trawArgv,\r\n\t\tconfig.parser,\r\n\t\tconfig.delimiters.template,\r\n\t);\r\n\r\n\tconst { env, help, modes, providers } = preloadedArgv;\r\n\r\n\tif (help) build(rawArgv, preloadedArgv, subcommand, config, version);\r\n\r\n\tif (!Array.isArray(providers) || providers.length === 0) {\r\n\t\tlogger.error('no providers found');\r\n\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconst envMsg = env\r\n\t\t? ` ${pc.bold(pc.underline(pc.green(env)))} environment`\r\n\t\t: '';\r\n\tconst modesMsg = modes\r\n\t\t? ` ${pc.bold(pc.magenta(modes.join('+')))} mode`\r\n\t\t: '';\r\n\r\n\tlogger.info(`loading${envMsg}${env && modes ? ' in' : ''}${modesMsg}`);\r\n\r\n\t// read loaders from config\r\n\tfor (const provider of providers!) {\r\n\t\ttry {\r\n\t\t\tlogger.debug(`using ${pc.yellow(provider.path)} provider`);\r\n\r\n\t\t\tif (!provider.type || provider.type === 'integrated') {\r\n\t\t\t\tprovider.handler = IntegratedProviders[provider.path];\r\n\t\t\t} else {\r\n\t\t\t\tconst { default: module } = await import(\r\n\t\t\t\t\tprovider.type === 'module'\r\n\t\t\t\t\t\t? provider.path\r\n\t\t\t\t\t\t: resolvePath(provider.path)\r\n\t\t\t\t);\r\n\r\n\t\t\t\tprovider.handler = module;\r\n\t\t\t}\r\n\t\t} catch {\r\n\t\t\tlogger.error(\r\n\t\t\t\t`${pc.yellow(\r\n\t\t\t\t\tprovider.path,\r\n\t\t\t\t)} provider not found or not compatible`,\r\n\t\t\t);\r\n\r\n\t\t\tprocess.exit(1);\r\n\t\t}\r\n\t}\r\n\r\n\tbuild(rawArgv, preloadedArgv, subcommand, config, version);\r\n}\r\n\r\n/**\r\n * Builds commands and execs Yargs.\r\n *\r\n * @param {string[]} rawArgv process.argv.slice(2)\r\n * @param {Partial<Arguments<CommandArguments>>} preloadedArgv\r\n * @param {string[]} subcommand subcommand for wrap if exists\r\n * @param {Record<string, any>} config lib config from package.json\r\n * @param {string} version lib version from package.json\r\n */\r\nfunction build(\r\n\trawArgv: string[],\r\n\tpreloadedArgv: Partial<Arguments<CommandArguments>>,\r\n\tsubcommand: string[],\r\n\tconfig: Record<string, any>,\r\n\tversion = 'unknown',\r\n): void {\r\n\tconst builder = yargs(rawArgv)\r\n\t\t.strict()\r\n\t\t.scriptName('env')\r\n\t\t.version(version)\r\n\t\t.detectLocale(false)\r\n\t\t.showHelpOnFail(false)\r\n\t\t.parserConfiguration(config.parser)\r\n\t\t.usage('Usage: $0 [command] [options..] [: subcmd [:]] [options..]')\r\n\t\t.options(args)\r\n\t\t.middleware(async (argv): Promise<void> => {\r\n\t\t\t// in case of subcommand argument for main\r\n\t\t\tif (subcommand?.length > 0) argv.subcmd = subcommand;\r\n\r\n\t\t\t// merges preloaded args\r\n\t\t\tObject.assign(argv, preloadedArgv);\r\n\r\n\t\t\tlogger.silly(\r\n\t\t\t\t'interpolating arguments surrounded by',\r\n\t\t\t\tpc.bold(\r\n\t\t\t\t\tpc.yellow(\r\n\t\t\t\t\t\t`${config.delimiters.template[0]} ${config.delimiters.template[1]}`,\r\n\t\t\t\t\t),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\r\n\t\t\tconst subcmdAux = argv.subcmd as string[];\r\n\t\t\t// applies string templating with current vars\r\n\t\t\tinterpolateJson(argv, argv, config.delimiters.template);\r\n\r\n\t\t\tif (Array.isArray(argv.subcmd)) {\r\n\t\t\t\t// fix for argv interpolation pre env interpolation for subcommand\r\n\t\t\t\tfor (const index in argv.subcmd) {\r\n\t\t\t\t\tif (argv.subcmd[index]?.includes('undefined'))\r\n\t\t\t\t\t\targv.subcmd[index] = subcmdAux[index];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlogger.silly('config loaded:', argv);\r\n\r\n\t\t\t// loads environment JSON schema if exists\r\n\t\t\t// and current project info from package.json\r\n\t\t\t[argv.projectInfo, argv.schema] = await Promise.all([\r\n\t\t\t\tloadProjectInfo((argv.packageJson ?? argv.pkg) as string),\r\n\t\t\t\tloadSchemaFile(argv, config.delimiters.template),\r\n\t\t\t]);\r\n\r\n\t\t\tif (argv.schemaValidate) {\r\n\t\t\t\targv.schemaValidate = !!argv.schema;\r\n\r\n\t\t\t\tif (argv.schemaValidate)\r\n\t\t\t\t\tlogger.silly('schema loaded:', argv.schema);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t// integrated commands builder\r\n\tbuilder.command(envCommand);\r\n\tbuilder.command(exportCommand);\r\n\tbuilder.command(pullCommand);\r\n\tbuilder.command(pushCommand);\r\n\tbuilder.command(schemaCommand);\r\n\r\n\tconst { providers } = preloadedArgv;\r\n\r\n\t// extends command from plugins\r\n\tfor (const { handler } of providers!)\r\n\t\tif (handler?.builder) handler.builder(builder);\r\n\r\n\t// executes command processing\r\n\tvoid builder.parse();\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,eAAe,EACd,GACA,GACA,GACqC;CAErC,IAAM,IAAgB,EAAO,SAAS,GAAS;EAC9C,OAAO;GAAC;GAAS;GAAmB;EAAqB;EACzD,SAAS,CAAC,MAAM;EAChB,eAAe;EACf,QAAQ;GAAC;GAAQ;GAAO;GAAc;GAAc;EAAU;EAC9D,OAAO;GACN,YAAY,EAAK,WAAW;GAC5B,KAAK,EAAK,IAAI;GACd,UAAU,EAAK,SAAS;GACxB,iBAAiB,EAAK,gBAAgB;GACtC,qBAAqB,EAAK,oBAAoB;GAC9C,OAAO,EAAK,MAAM;EACnB;EACA,SAAS;GACR,YAAY,EAAK,WAAW;GAC5B,MAAM,EAAK,KAAK;EACjB;CACD,CAAC,EAAE;CAQH,AALA,MAAM,EAAe,GAAe,CAAU,GAE9C,EAAc,aAAa,EAAK,SAAS,SACzC,EAAc,oBAAoB,EAAK,gBAAgB,SACvD,EAAc,wBAAwB,EAAK,oBAAoB,SAC/D,EAAc,cAAc,EAAK,UAAU;CAE3C,IAAM,EAAE,aAAU,oBAAiB,2BAAwB;CAY3D,OATA,EAAgB,GAAQ;EACvB,cAAc;EACd,kBAAkB;EAClB,UAAU;CACX,CAAC,IAEG,MAAa,WAAW,MAAa,aACxC,QAAQ,IAAI,YAAY,SAElB;AACR;AASA,eAAsB,EAAK,GAAmB;CAQ7C,IAAM,EAAE,WAAQ,eANJ,KAAK,MAChB,EACC,EAAc,IAAA,IAAA,gBAAA,KAAA,OAAA,KAAA,GAAA,CAAwC,GACtD,MACD,CAE2B,GAGtB,IAAa,EAAc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AwB;EAO1C,AALI,GAAY,SAAS,MAAG,EAAK,SAAS,IAG1C,OAAO,OAAO,GAAM,CAAa,GAEjC,EAAO,MACN,yCACA,EAAG,KACF,EAAG,OACF,GAAG,EAAO,WAAW,SAAS,GAAG,GAAG,EAAO,WAAW,SAAS,IAChE,CACD,CACD;EAEA,IAAM,IAAY,EAAK;EAIvB,IAFA,EAAgB,GAAM,GAAM,EAAO,WAAW,QAAQ,GAElD,MAAM,QAAQ,EAAK,MAAM,QAEvB,IAAM,KAAS,EAAK,QACxB,AAAI,EAAK,OAAO,IAAQ,SAAS,WAAW,MAC3C,EAAK,OAAO,KAAS,EAAU;EAalC,AATA,EAAO,MAAM,kBAAkB,CAAI,GAInC,CAAC,EAAK,aAAa,EAAK,UAAU,MAAM,QAAQ,IAAI,CACnD,EAAiB,EAAK,eAAe,EAAK,GAAc,GACxD,EAAe,GAAM,EAAO,WAAW,QAAQ,CAChD,CAAC,GAEG,EAAK,mBACR,EAAK,iBAAiB,CAAC,CAAC,EAAK,QAEzB,EAAK,kBACR,EAAO,MAAM,kBAAkB,EAAK,MAAM;CAE7C,CAAC;CAOF,AAJA,EAAQ,QAAQ,CAAU,GAC1B,EAAQ,QAAQ,CAAa,GAC7B,EAAQ,QAAQ,CAAW,GAC3B,EAAQ,QAAQ,CAAW,GAC3B,EAAQ,QAAQ,CAAa;CAE7B,IAAM,EAAE,iBAAc;CAGtB,KAAK,IAAM,EAAE,gBAAa,GACzB,AAAI,GAAS,WAAS,EAAQ,QAAQ,CAAO;CAG9C,EAAa,MAAM;AACpB"}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './arguments.js';
|
|
2
|
+
export * from './interfaces/index.js';
|
|
3
|
+
export * from './utils/logger.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./interfaces"), exports);
|
|
18
|
-
__exportStar(require("./utils/logger"), exports);
|
|
19
|
-
__exportStar(require("./arguments"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { LOG_LEVELS as e, configureLogger as t, createLogger as n, logger as r } from "./utils/logger.js";
|
|
2
|
+
import { args as i } from "./arguments.js";
|
|
3
|
+
export { e as LOG_LEVELS, i as args, t as configureLogger, n as createLogger, r as logger };
|
package/interfaces/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './loader.interface';
|
|
1
|
+
export * from './loader.interface.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { Arguments, Argv } from 'yargs';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Result of provider environment load.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @type EnvResult
|
|
7
|
+
*/
|
|
8
|
+
export type EnvResult = Promise<Record<string, unknown>[]> | Promise<Record<string, unknown>> | Record<string, unknown> | Record<string, unknown>[];
|
|
9
|
+
/**
|
|
10
|
+
* Wrapped provider result for inject to env.
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @interface EnvProviderResult
|
|
14
|
+
*/
|
|
3
15
|
export interface EnvProviderResult {
|
|
4
16
|
key: string;
|
|
5
|
-
config?: Record<string, unknown>;
|
|
6
17
|
value: Record<string, any> | Record<string, any>[];
|
|
18
|
+
config?: Record<string, unknown>;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Provider handler.
|
|
22
|
+
*
|
|
23
|
+
* @export
|
|
24
|
+
* @interface EnvProvider
|
|
25
|
+
* @template A define arguments used by provider
|
|
26
|
+
* @template C define config used by provider
|
|
27
|
+
*/
|
|
8
28
|
export interface EnvProvider<A, C extends Record<string, any> | undefined = undefined> {
|
|
9
29
|
key: string;
|
|
10
30
|
builder?: (builder: Argv<unknown>) => void;
|
|
@@ -12,10 +32,16 @@ export interface EnvProvider<A, C extends Record<string, any> | undefined = unde
|
|
|
12
32
|
pull?: (argv: Arguments<A>, config?: C) => void;
|
|
13
33
|
push?: (argv: Arguments<A>, config?: C) => void;
|
|
14
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Provider definition for config file.
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
* @interface EnvProviderConfig
|
|
40
|
+
*/
|
|
15
41
|
export interface EnvProviderConfig {
|
|
42
|
+
handler: EnvProvider<any, any>;
|
|
16
43
|
path: string;
|
|
17
44
|
type: 'integrated' | 'module' | 'script';
|
|
18
|
-
handler: EnvProvider<any, any>;
|
|
19
45
|
config?: Record<string, unknown>;
|
|
20
46
|
}
|
|
21
47
|
//# sourceMappingURL=loader.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/loader.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/loader.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW,CAC3B,CAAC,EACD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GAAG,SAAS;IAGrD,GAAG,EAAE,MAAM,CAAC;IAGZ,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAG3C,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,SAAS,GAAG,KAAK,CAAC;IAG5D,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAGhD,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;CAChD;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC"}
|
package/main.d.ts
CHANGED
package/main.js
CHANGED
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let arg = argv[i];
|
|
10
|
-
if (arg.includes(' '))
|
|
11
|
-
arg = `"${arg}"`;
|
|
12
|
-
if (arg.at(-1) === "'") {
|
|
13
|
-
cmdArgs.push(`${composite} ${arg}`.replaceAll("'", '"'));
|
|
14
|
-
composite = '';
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
if (arg[0] === "'") {
|
|
18
|
-
composite += arg;
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
if (composite) {
|
|
22
|
-
composite += ` ${arg}`;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
cmdArgs.push(arg);
|
|
26
|
-
}
|
|
27
|
-
(0, exec_1.exec)(cmdArgs.slice(2));
|
|
2
|
+
import { normalizeRawArgv as e } from "./utils/argv.util.js";
|
|
3
|
+
import "./utils/index.js";
|
|
4
|
+
import { exec as t } from "./exec.js";
|
|
5
|
+
//#region src/main.ts
|
|
6
|
+
t(e(process.argv));
|
|
7
|
+
//#endregion
|
|
8
|
+
|
|
28
9
|
//# sourceMappingURL=main.js.map
|
package/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","
|
|
1
|
+
{"version":3,"file":"main.js","names":[],"sources":["../src/main.ts"],"sourcesContent":["import { exec } from './exec.js';\nimport { normalizeRawArgv } from './utils/index.js';\n\nvoid exec(normalizeRawArgv(process.argv));\n"],"mappings":";;;;;AAGK,EAAK,EAAiB,QAAQ,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "5.0.0-alpha.0",
|
|
3
3
|
"project": "common",
|
|
4
4
|
"name": "@achs/env",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"title": "Environment Variables CLI Tool",
|
|
6
7
|
"description": "Extensible environment variables handler for NodeJS apps",
|
|
7
8
|
"author": "Alvear Candia, Cristopher Alejandro <caalvearc@achs.cl>",
|
|
@@ -13,42 +14,53 @@
|
|
|
13
14
|
"typescript"
|
|
14
15
|
],
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@achs/azure-key-vault": "^4.
|
|
17
|
-
"ajv": "^8.
|
|
17
|
+
"@achs/azure-key-vault": "^4.6.0",
|
|
18
|
+
"ajv": "^8.20.0",
|
|
18
19
|
"ajv-formats": "^3.0.1",
|
|
19
20
|
"ci-info": "^4.4.0",
|
|
20
21
|
"merge-deep": "^3.0.3",
|
|
21
22
|
"picocolors": "^1.1.1",
|
|
22
23
|
"subslate": "^1.0.0",
|
|
23
24
|
"to-json-schema": "^0.2.5",
|
|
24
|
-
"tslog": "^
|
|
25
|
-
"yargs": "^
|
|
26
|
-
"yargs-parser": "^21.1.1"
|
|
25
|
+
"tslog": "^4.10.2",
|
|
26
|
+
"yargs": "^18.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/jest": "^29.5.12",
|
|
30
29
|
"@types/merge-deep": "^3.0.3",
|
|
31
|
-
"@types/node": "^
|
|
30
|
+
"@types/node": "^25.9.1",
|
|
32
31
|
"@types/to-json-schema": "^0.2.4",
|
|
33
|
-
"@types/yargs": "^17.0.
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@typescript-eslint/parser": "^6.20.0",
|
|
32
|
+
"@types/yargs": "^17.0.35",
|
|
33
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
34
|
+
"@vitest/eslint-plugin": "^1.6.18",
|
|
37
35
|
"copyfiles": "^2.4.1",
|
|
38
|
-
"del-cli": "^
|
|
39
|
-
"eslint": "^
|
|
40
|
-
"eslint-config-prettier": "^
|
|
41
|
-
"eslint-plugin-
|
|
42
|
-
"eslint-plugin-
|
|
43
|
-
"eslint-plugin-
|
|
44
|
-
"eslint-plugin-
|
|
45
|
-
"eslint-plugin-
|
|
46
|
-
"eslint-plugin-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
36
|
+
"del-cli": "^7.0.0",
|
|
37
|
+
"eslint": "^10.4.1",
|
|
38
|
+
"eslint-config-prettier": "^10.1.8",
|
|
39
|
+
"eslint-plugin-perfectionist": "^5.9.0",
|
|
40
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
41
|
+
"eslint-plugin-promise": "^7.3.0",
|
|
42
|
+
"eslint-plugin-regexp": "^3.1.0",
|
|
43
|
+
"eslint-plugin-sonarjs": "^4.0.3",
|
|
44
|
+
"eslint-plugin-unicorn": "^64.0.0",
|
|
45
|
+
"globals": "^17.6.0",
|
|
46
|
+
"prettier": "^3.8.3",
|
|
47
|
+
"typescript": "^6.0.3",
|
|
48
|
+
"typescript-eslint": "^8.60.0",
|
|
49
|
+
"vite": "^8.0.14",
|
|
50
|
+
"vite-plugin-dts": "^5.0.1",
|
|
51
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
52
|
+
"vitest": "^4.1.7"
|
|
53
|
+
},
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./index.d.ts",
|
|
57
|
+
"import": "./index.js"
|
|
58
|
+
},
|
|
59
|
+
"./utils": {
|
|
60
|
+
"types": "./utils/index.d.ts",
|
|
61
|
+
"import": "./utils/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./package.json": "./package.json"
|
|
52
64
|
},
|
|
53
65
|
"main": "index.js",
|
|
54
66
|
"types": "index.d.ts",
|
|
@@ -56,9 +68,8 @@
|
|
|
56
68
|
"env": "main.js"
|
|
57
69
|
},
|
|
58
70
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
60
|
-
"
|
|
61
|
-
"pnpm": ">=7"
|
|
71
|
+
"node": ">=20",
|
|
72
|
+
"pnpm": ">=9"
|
|
62
73
|
},
|
|
63
74
|
"config": {
|
|
64
75
|
"delimiters": {
|
|
@@ -79,13 +90,23 @@
|
|
|
79
90
|
"boolean-negation": false
|
|
80
91
|
}
|
|
81
92
|
},
|
|
93
|
+
"contributors": [
|
|
94
|
+
"Cristopher Alvear Candia <caalvearc@achs.cl>"
|
|
95
|
+
],
|
|
82
96
|
"scripts": {
|
|
83
|
-
"build": "pnpm prebuild &&
|
|
84
|
-
"test": "
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
97
|
+
"build": "pnpm prebuild && vite build && pnpm postbuild",
|
|
98
|
+
"test": "vitest run --project unit",
|
|
99
|
+
"test:watch": "vitest --project unit",
|
|
100
|
+
"test:cov": "vitest run --project unit --coverage",
|
|
101
|
+
"test:int": "vitest run --project integration",
|
|
102
|
+
"typecheck": "tsc --noEmit",
|
|
103
|
+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint/ .",
|
|
104
|
+
"lint:fix": "eslint --fix --cache --cache-location node_modules/.cache/eslint/ .",
|
|
105
|
+
"format": "prettier --cache --write \"**/*.{ts,cts,mts,js,cjs,mjs,json,md,yml,yaml}\"",
|
|
106
|
+
"format:check": "prettier --cache --check \"**/*.{ts,cts,mts,js,cjs,mjs,json,md,yml,yaml}\"",
|
|
107
|
+
"pub": "pnpm typecheck && pnpm lint && pnpm test:cov && pnpm build && pnpm publish dist --access public --no-git-checks",
|
|
108
|
+
"pub:alpha": "pnpm typecheck && pnpm lint && pnpm test:cov && pnpm build && pnpm publish dist --tag alpha --access public --no-git-checks",
|
|
109
|
+
"prebuild": "del-cli dist",
|
|
89
110
|
"postbuild": "copyfiles package.json README.md LICENSE.md CHANGELOG.md schemas/env.schema.json schemas/settings.schema.json assets/* dist"
|
|
90
111
|
}
|
|
91
112
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { CommandArguments } from '../arguments';
|
|
2
|
-
import { EnvProvider } from '../interfaces';
|
|
1
|
+
import { CommandArguments } from '../arguments.js';
|
|
2
|
+
import { EnvProvider } from '../interfaces/index.js';
|
|
3
3
|
interface AppSettingsCommandArguments extends CommandArguments {
|
|
4
4
|
envFile: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Loads config from appsettings.json.
|
|
8
|
+
*/
|
|
6
9
|
export declare const AppSettingsProvider: EnvProvider<AppSettingsCommandArguments>;
|
|
7
10
|
export {};
|
|
8
11
|
//# sourceMappingURL=app-settings.provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-settings.provider.d.ts","sourceRoot":"","sources":["../../src/providers/app-settings.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"app-settings.provider.d.ts","sourceRoot":"","sources":["../../src/providers/app-settings.provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAS1D,UAAU,2BAA4B,SAAQ,gBAAgB;IAC7D,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,2BAA2B,CAyDxE,CAAC"}
|