@achs/env 5.0.0-alpha.2 → 5.0.0-alpha.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.
- package/README.md +2 -2
- package/assets/logo-achs.svg +16 -0
- package/assets/logo.svg +30 -0
- package/commands/env.command.d.ts.map +1 -1
- package/commands/env.command.js +35 -25
- package/commands/env.command.js.map +1 -1
- package/commands/export.command.d.ts.map +1 -1
- package/commands/export.command.js +12 -11
- package/commands/export.command.js.map +1 -1
- package/commands/pull.command.js +7 -6
- package/commands/pull.command.js.map +1 -1
- package/commands/push.command.js +7 -6
- package/commands/push.command.js.map +1 -1
- package/commands/schema.command.d.ts.map +1 -1
- package/commands/schema.command.js +7 -6
- package/commands/schema.command.js.map +1 -1
- package/exec.d.ts.map +1 -1
- package/exec.js +40 -41
- package/exec.js.map +1 -1
- package/package.json +1 -1
- package/providers/azure-key-vault.provider.d.ts.map +1 -1
- package/providers/azure-key-vault.provider.js +48 -47
- package/providers/azure-key-vault.provider.js.map +1 -1
- package/utils/command.util.d.ts +1 -1
- package/utils/command.util.d.ts.map +1 -1
- package/utils/command.util.js +3 -3
- package/utils/command.util.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +2 -1
- package/utils/json.util.d.ts.map +1 -1
- package/utils/json.util.js +7 -2
- package/utils/json.util.js.map +1 -1
- package/utils/schema.util.d.ts +6 -6
- package/utils/schema.util.d.ts.map +1 -1
- package/utils/schema.util.js +20 -19
- package/utils/schema.util.js.map +1 -1
- package/utils/ui.d.ts +12 -0
- package/utils/ui.d.ts.map +1 -0
- package/utils/ui.js +49 -0
- package/utils/ui.js.map +1 -0
- package/assets/logo-achs.png +0 -0
- package/assets/logo.png +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div id="top" align="center">
|
|
2
|
-
<img alt="@achs/env logo" src="assets/logo.
|
|
2
|
+
<img alt="@achs/env logo" src="https://cdn.jsdelivr.net/npm/@achs/env@%5E5.0.0-0/assets/logo.svg" width="150" />
|
|
3
3
|
|
|
4
4
|
<h1 align="center"><b>env</b></h1>
|
|
5
5
|
<h4 align="center">Environment variables made easy — load, validate, inject.</h4>
|
|
@@ -574,7 +574,7 @@ process.env.GROUP1__SHARED; // "sharedValue2"
|
|
|
574
574
|
<br />
|
|
575
575
|
|
|
576
576
|
<p align="center">
|
|
577
|
-
<img width="25%" src="
|
|
577
|
+
<img width="25%" src="https://cdn.jsdelivr.net/npm/@achs/env@%5E5.0.0-0/assets/logo-achs.svg" alt="ACHS" />
|
|
578
578
|
<h3 align="center">ASOCIACIÓN CHILENA DE SEGURIDAD</h3>
|
|
579
579
|
<h4 align="center">Transformación Digital ▪ Equipo de Desarrollo</h4>
|
|
580
580
|
</p>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="7680" height="7680"
|
|
3
|
+
viewBox="0 0 7680 7680" version="1.1">
|
|
4
|
+
<g id="surface1">
|
|
5
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:#13c045;fill-opacity:1;"
|
|
6
|
+
d="M 6144 7680 L 1536 7680 C 688.941406 7680 0 6991.058594 0 6144 L 0 1536 C 0 688.941406 688.941406 0 1536 0 L 6144 0 C 6991.058594 0 7680 688.941406 7680 1536 L 7680 6144 C 7680 6991.058594 6991.058594 7680 6144 7680 Z M 6144 7680 " />
|
|
7
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:#ffffff;fill-opacity:1;"
|
|
8
|
+
d="M 1694.117188 4551.53125 C 1728 4517.648438 1739.292969 4461.175781 1739.292969 4393.410156 L 1739.292969 4167.53125 L 1423.058594 4235.292969 C 1355.292969 4246.589844 1310.117188 4269.175781 1287.53125 4303.058594 C 1264.941406 4336.941406 1242.351562 4382.117188 1242.351562 4427.292969 C 1242.351562 4483.765625 1264.941406 4528.941406 1287.53125 4551.53125 C 1321.410156 4585.410156 1377.882812 4596.707031 1445.648438 4596.707031 L 1547.292969 4596.707031 C 1615.058594 4608 1660.234375 4585.410156 1694.117188 4551.53125 M 903.53125 4856.46875 C 813.175781 4766.117188 768 4641.882812 768 4483.765625 C 768 4382.117188 779.292969 4303.058594 813.175781 4235.292969 C 847.058594 4167.53125 903.53125 4111.058594 982.589844 4065.882812 C 1061.648438 4020.707031 1174.589844 3975.53125 1310.117188 3952.941406 L 1547.292969 3907.765625 C 1603.765625 3896.46875 1637.648438 3885.175781 1660.234375 3873.882812 C 1682.824219 3862.589844 1705.410156 3840 1716.707031 3828.707031 C 1728 3806.117188 1728 3783.53125 1728 3749.648438 C 1728 3715.765625 1716.707031 3693.175781 1705.410156 3670.589844 C 1694.117188 3648 1671.53125 3636.707031 1648.941406 3636.707031 C 1626.351562 3614.117188 1581.175781 3614.117188 1536 3614.117188 L 858.351562 3614.117188 L 858.351562 3275.292969 C 926.117188 3252.707031 1016.46875 3241.410156 1140.707031 3230.117188 C 1253.648438 3218.824219 1366.589844 3207.53125 1479.53125 3207.53125 C 1660.234375 3207.53125 1807.058594 3230.117188 1920 3275.292969 C 2032.941406 3320.46875 2100.707031 3376.941406 2145.882812 3467.292969 C 2191.058594 3557.648438 2213.648438 3659.292969 2213.648438 3794.824219 L 2213.648438 4958.117188 L 1829.648438 4958.117188 L 1739.292969 4709.648438 C 1705.410156 4800 1648.941406 4879.058594 1569.882812 4924.234375 C 1502.117188 4969.410156 1400.46875 4992 1287.53125 4992 C 1118.117188 4992 993.882812 4946.824219 903.53125 4856.46875 " />
|
|
9
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:#ffffff;fill-opacity:1;"
|
|
10
|
+
d="M 2676.707031 4777.410156 C 2541.175781 4641.882812 2473.410156 4416 2473.410156 4099.765625 C 2473.410156 3783.53125 2541.175781 3557.648438 2676.707031 3422.117188 C 2812.234375 3286.589844 3004.234375 3218.824219 3264 3218.824219 C 3422.117188 3218.824219 3568.941406 3241.410156 3715.765625 3275.292969 L 3715.765625 3614.117188 L 3365.648438 3614.117188 C 3241.410156 3614.117188 3162.351562 3636.707031 3105.882812 3659.292969 C 3049.410156 3693.175781 3015.53125 3738.351562 2992.941406 3806.117188 C 2981.648438 3873.882812 2970.351562 3964.234375 2970.351562 4099.765625 C 2970.351562 4224 2981.648438 4336.941406 2992.941406 4393.410156 C 3004.234375 4461.175781 3049.410156 4506.351562 3105.882812 4551.53125 C 3162.351562 4585.410156 3252.707031 4608 3365.648438 4608 L 3715.765625 4608 L 3715.765625 4924.234375 C 3568.941406 4969.410156 3422.117188 4992 3264 4992 C 3004.234375 4992 2800.941406 4924.234375 2676.707031 4777.410156 Z M 2676.707031 4777.410156 " />
|
|
11
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:#ffffff;fill-opacity:1;"
|
|
12
|
+
d="M 4879.058594 3636.707031 C 4856.46875 3625.410156 4811.292969 3614.117188 4732.234375 3614.117188 L 4393.410156 3614.117188 L 4393.410156 3444.707031 C 4517.648438 3286.589844 4687.058594 3218.824219 4879.058594 3218.824219 C 5048.46875 3218.824219 5172.707031 3264 5263.058594 3343.058594 C 5353.410156 3433.410156 5387.292969 3546.351562 5387.292969 3704.46875 L 5387.292969 4958.117188 L 4912.941406 4958.117188 L 4912.941406 3760.941406 C 4924.234375 3704.46875 4912.941406 3659.292969 4879.058594 3636.707031 M 3952.941406 2778.351562 L 4427.292969 2699.292969 L 4427.292969 4958.117188 L 3952.941406 4958.117188 Z M 3952.941406 2778.351562 " />
|
|
13
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:#ffffff;fill-opacity:1;"
|
|
14
|
+
d="M 5906.824219 4969.410156 C 5816.46875 4958.117188 5737.410156 4935.53125 5658.351562 4912.941406 L 5658.351562 4596.707031 L 6392.46875 4596.707031 C 6415.058594 4596.707031 6426.351562 4585.410156 6437.648438 4574.117188 C 6448.941406 4562.824219 6460.234375 4540.234375 6460.234375 4506.351562 C 6460.234375 4483.765625 6460.234375 4472.46875 6448.941406 4461.175781 C 6437.648438 4449.882812 6426.351562 4438.589844 6403.765625 4416 C 6381.175781 4393.410156 6358.589844 4382.117188 6324.707031 4359.53125 L 5974.589844 4156.234375 C 5872.941406 4099.765625 5793.882812 4032 5748.707031 3952.941406 C 5703.53125 3873.882812 5680.941406 3783.53125 5680.941406 3670.589844 C 5680.941406 3523.765625 5737.410156 3410.824219 5850.351562 3320.46875 C 5963.292969 3241.410156 6110.117188 3196.234375 6302.117188 3196.234375 C 6494.117188 3196.234375 6663.53125 3230.117188 6832.941406 3286.589844 L 6832.941406 3614.117188 L 6189.175781 3614.117188 C 6166.589844 3614.117188 6144 3614.117188 6132.707031 3625.410156 C 6121.410156 3636.707031 6121.410156 3648 6121.410156 3670.589844 C 6121.410156 3693.175781 6121.410156 3715.765625 6132.707031 3727.058594 C 6144 3738.351562 6155.292969 3749.648438 6177.882812 3760.941406 L 6640.941406 4009.410156 C 6742.589844 4065.882812 6821.648438 4122.351562 6866.824219 4190.117188 C 6912 4257.882812 6934.589844 4348.234375 6934.589844 4461.175781 C 6934.589844 4641.882812 6878.117188 4777.410156 6765.175781 4856.46875 C 6652.234375 4935.53125 6482.824219 4980.707031 6245.648438 4980.707031 C 6098.824219 4992 5997.175781 4980.707031 5906.824219 4969.410156 " />
|
|
15
|
+
</g>
|
|
16
|
+
</svg>
|
package/assets/logo.svg
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="env">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="card" x1="32" y1="24" x2="224" y2="232" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#101A2E"/>
|
|
5
|
+
<stop offset="1" stop-color="#0A1120"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="accent" x1="72" y1="104" x2="184" y2="168" gradientUnits="userSpaceOnUse">
|
|
8
|
+
<stop stop-color="#34D399"/>
|
|
9
|
+
<stop offset="1" stop-color="#22D3EE"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
|
|
13
|
+
<!-- terminal card -->
|
|
14
|
+
<rect x="20" y="20" width="216" height="216" rx="46" fill="url(#card)"/>
|
|
15
|
+
<rect x="21" y="21" width="214" height="214" rx="45" fill="none" stroke="#22D3EE" stroke-opacity="0.18" stroke-width="2"/>
|
|
16
|
+
|
|
17
|
+
<!-- title bar dots -->
|
|
18
|
+
<circle cx="58" cy="62" r="7" fill="#F87171"/>
|
|
19
|
+
<circle cx="82" cy="62" r="7" fill="#FBBF24"/>
|
|
20
|
+
<circle cx="106" cy="62" r="7" fill="#34D399"/>
|
|
21
|
+
|
|
22
|
+
<!-- separator -->
|
|
23
|
+
<line x1="40" y1="86" x2="216" y2="86" stroke="#22D3EE" stroke-opacity="0.12" stroke-width="2"/>
|
|
24
|
+
|
|
25
|
+
<!-- [ > _ ] : env brackets + CLI prompt -->
|
|
26
|
+
<path d="M104 108 H82 V184 H104" stroke="url(#accent)" stroke-width="14" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
27
|
+
<path d="M152 108 H174 V184 H152" stroke="url(#accent)" stroke-width="14" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
28
|
+
<path d="M110 128 L132 146 L110 164" stroke="#E2F7F2" stroke-width="13" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
29
|
+
<rect x="128" y="158" width="22" height="11" rx="3" fill="#34D399"/>
|
|
30
|
+
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.command.d.ts","sourceRoot":"","sources":["../../src/commands/env.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.command.d.ts","sourceRoot":"","sources":["../../src/commands/env.command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAaxD,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAE5D,cAAc,EAAE,OAAO,CAAC;IAGxB,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,GAAG,EAAE,mBAAmB,CAmH9D,CAAC"}
|
package/commands/env.command.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { flatResults as e, loadVariablesFromProviders as t } from "../utils/command.util.js";
|
|
2
2
|
import { interpolate as n } from "../utils/interpolate.util.js";
|
|
3
3
|
import { logger as r } from "../utils/logger.js";
|
|
4
|
-
import {
|
|
5
|
-
import { createValidator as
|
|
4
|
+
import { flatten as i, normalize as a } from "../utils/normalize.util.js";
|
|
5
|
+
import { createValidator as o, flatSchema as s } from "../utils/schema.util.js";
|
|
6
|
+
import { ui as c } from "../utils/ui.js";
|
|
6
7
|
import "../utils/index.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { spawn as l } from "node:child_process";
|
|
8
|
+
import l from "merge-deep";
|
|
9
|
+
import { spawn as u } from "node:child_process";
|
|
10
10
|
//#region src/commands/env.command.ts
|
|
11
|
-
var
|
|
11
|
+
var d = {
|
|
12
12
|
command: "$0 [options..] [: <subcmd> :]",
|
|
13
13
|
describe: "Inject environment variables into process",
|
|
14
14
|
builder: (e) => (e.options({
|
|
@@ -23,35 +23,45 @@ var u = {
|
|
|
23
23
|
type: "array"
|
|
24
24
|
}
|
|
25
25
|
}).example("env -e dev -m test unit : npm test", "Loads \"dev\" environment variables, in \"test\" and \"unit\" modes, for \"npm start\" command").example("env -e dev -m debug : npm start : -c my-config.json", "Loads \"dev\" environment variables, in \"debug\" mode, for \"npm test\" command and custom config file").example("env -e dev -m debug -c [[root]]/[[env]].env.json : npm start", "Loads custom config file placed in root folder and named same as the env").check((e) => (e._.length === 0 && !e.subcmd && (r.error("No one subcommand provided for exec surrounded by :"), process.exit(1)), !0)), e),
|
|
26
|
-
handler: async ({ expand:
|
|
27
|
-
let m =
|
|
28
|
-
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
type: "object"
|
|
37
|
-
});
|
|
38
|
-
t(m) || (r.error("schema validation failed", t.errors), process.exit(1));
|
|
26
|
+
handler: async ({ expand: o, providers: s, schemaValidate: d, ...p }) => {
|
|
27
|
+
let m = performance.now(), h = d ? f(s, p) : void 0, g = await t(s, p);
|
|
28
|
+
for (let { key: e, value: t } of g) {
|
|
29
|
+
let n = Array.isArray(t) ? l({}, ...t.map((e) => i(e, p.nestingDelimiter))) : i(t, p.nestingDelimiter);
|
|
30
|
+
c.provider(e, Object.keys(n).length);
|
|
31
|
+
}
|
|
32
|
+
let _ = l({ NODE_ENV: "development" }, ...e(g, p.nestingDelimiter));
|
|
33
|
+
if (h) {
|
|
34
|
+
let e = await h;
|
|
35
|
+
e(_) || (r.error("schema validation failed", e.errors), process.exit(1));
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
for (let e in
|
|
42
|
-
|
|
37
|
+
_ = a(_, p.nestingDelimiter, p.arrayDescomposition), o && (_ = n(_, _), p.subcmd = n(p.subcmd, _)), r.debug("environment loaded:", _);
|
|
38
|
+
for (let e in _) process.env[e] = String(_[e]);
|
|
39
|
+
c.summary(Object.keys(_).length, performance.now() - m);
|
|
40
|
+
let v = p.subcmd.join(" ");
|
|
41
|
+
c.running(v), u(v, {
|
|
43
42
|
shell: !0,
|
|
44
43
|
stdio: "inherit"
|
|
45
44
|
}).on("exit", (e) => {
|
|
46
45
|
if (e === 0 || e === null) {
|
|
47
|
-
|
|
46
|
+
c.finished(performance.now() - m);
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
r.error("process finished with error"), process.exit(e);
|
|
49
|
+
c.failed(e), r.error("process finished with error"), process.exit(e);
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
52
|
};
|
|
53
|
+
function f(e, t) {
|
|
54
|
+
let n = {};
|
|
55
|
+
for (let { handler: { key: r } } of e) {
|
|
56
|
+
let e = t.schema?.[r];
|
|
57
|
+
e && (n = Object.assign(n, s(e, "", t.nestingDelimiter)));
|
|
58
|
+
}
|
|
59
|
+
return o({
|
|
60
|
+
properties: n,
|
|
61
|
+
type: "object"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
54
64
|
//#endregion
|
|
55
|
-
export {
|
|
65
|
+
export { d as envCommand };
|
|
56
66
|
|
|
57
67
|
//# sourceMappingURL=env.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.command.js","names":[],"sources":["../../src/commands/env.command.ts"],"sourcesContent":["import merge from 'merge-deep';\r\nimport { spawn } from 'node:child_process';\r\nimport
|
|
1
|
+
{"version":3,"file":"env.command.js","names":[],"sources":["../../src/commands/env.command.ts"],"sourcesContent":["import merge from 'merge-deep';\r\nimport { spawn } from 'node:child_process';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport {\r\n\tcreateValidator,\r\n\tflatResults,\r\n\tflatSchema,\r\n\tflatten,\r\n\tinterpolate,\r\n\tloadVariablesFromProviders,\r\n\tlogger,\r\n\tnormalize,\r\n\tui,\r\n} from '../utils/index.js';\r\n\r\nexport interface EnvCommandArguments extends CommandArguments {\r\n\t// whether validate schema before injecting variables\r\n\tschemaValidate: boolean;\r\n\t// command for execute after inject environment variables.\r\n\t// Should be prefixed or surrounded by ':' character.\r\n\tsubcmd: string[];\r\n}\r\n\r\n/**\r\n * Main command.\r\n * Injects environment variables into process.env.\r\n *\r\n * @example [>_]: env -e dev -m debug : npm start\r\n */\r\nexport const envCommand: CommandModule<any, EnvCommandArguments> = {\r\n\tcommand: '$0 [options..] [: <subcmd> :]',\r\n\tdescribe: 'Inject environment variables into process',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\tschemaValidate: {\r\n\t\t\t\t\talias: 'validate',\r\n\t\t\t\t\tdefault: true,\r\n\t\t\t\t\tdescribe: 'Whether validates variables using JSON schema',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t\tsubcmd: {\r\n\t\t\t\t\tdescribe: 'Command for inject environment variables',\r\n\t\t\t\t\ttype: 'array',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example(\r\n\t\t\t\t'env -e dev -m test unit : npm test',\r\n\t\t\t\t'Loads \"dev\" environment variables, in \"test\" and \"unit\" modes, for \"npm start\" command',\r\n\t\t\t)\r\n\t\t\t.example(\r\n\t\t\t\t'env -e dev -m debug : npm start : -c my-config.json',\r\n\t\t\t\t'Loads \"dev\" environment variables, in \"debug\" mode, for \"npm test\" command and custom config file',\r\n\t\t\t)\r\n\t\t\t.example(\r\n\t\t\t\t'env -e dev -m debug -c [[root]]/[[env]].env.json : npm start',\r\n\t\t\t\t'Loads custom config file placed in root folder and named same as the env',\r\n\t\t\t)\r\n\t\t\t.check((argv): boolean => {\r\n\t\t\t\t// special check for custom argument\r\n\t\t\t\tif (argv._.length === 0 && !argv.subcmd) {\r\n\t\t\t\t\tlogger.error(\r\n\t\t\t\t\t\t'No one subcommand provided for exec surrounded by :',\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\tprocess.exit(1);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t});\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({ expand, providers, schemaValidate, ...argv }) => {\r\n\t\tconst started = performance.now();\r\n\r\n\t\t// kick off validator build (lazy-imports AJV) in parallel with provider I/O\r\n\t\tconst validatorPromise = schemaValidate\r\n\t\t\t? buildEnvValidator(providers, argv)\r\n\t\t\t: undefined;\r\n\r\n\t\tconst results = await loadVariablesFromProviders(providers, argv);\r\n\r\n\t\t// per-provider variable counts\r\n\t\tfor (const { key, value } of results) {\r\n\t\t\tconst flat = Array.isArray(value)\r\n\t\t\t\t? merge(\r\n\t\t\t\t\t\t{},\r\n\t\t\t\t\t\t...value.map((v: any) =>\r\n\t\t\t\t\t\t\tflatten(v, argv.nestingDelimiter),\r\n\t\t\t\t\t\t),\r\n\t\t\t\t\t)\r\n\t\t\t\t: flatten(value, argv.nestingDelimiter);\r\n\r\n\t\t\tui.provider(key, Object.keys(flat).length);\r\n\t\t}\r\n\r\n\t\tlet env = merge(\r\n\t\t\t{ NODE_ENV: 'development' },\r\n\t\t\t...flatResults(results, argv.nestingDelimiter),\r\n\t\t);\r\n\r\n\t\tif (validatorPromise) {\r\n\t\t\tconst validator = await validatorPromise;\r\n\r\n\t\t\tif (!validator(env)) {\r\n\t\t\t\tlogger.error('schema validation failed', validator.errors);\r\n\r\n\t\t\t\tprocess.exit(1);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tenv = normalize(env, argv.nestingDelimiter, argv.arrayDescomposition);\r\n\t\tif (expand) {\r\n\t\t\tenv = interpolate(env, env);\r\n\t\t\targv.subcmd = interpolate(argv.subcmd, env);\r\n\t\t}\r\n\r\n\t\tlogger.debug('environment loaded:', env);\r\n\r\n\t\t// loads env vars to process.env\r\n\t\tfor (const varname in env) process.env[varname] = String(env[varname]);\r\n\r\n\t\tui.summary(Object.keys(env).length, performance.now() - started);\r\n\r\n\t\tconst cmdProcess = argv.subcmd.join(' ');\r\n\r\n\t\tui.running(cmdProcess);\r\n\r\n\t\tspawn(cmdProcess, {\r\n\t\t\tshell: true,\r\n\t\t\tstdio: 'inherit',\r\n\t\t}).on('exit', (code) => {\r\n\t\t\tif (code === 0 || code === null) {\r\n\t\t\t\tui.finished(performance.now() - started);\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tui.failed(code);\r\n\t\t\tlogger.error('process finished with error');\r\n\t\t\tprocess.exit(code);\r\n\t\t});\r\n\t},\r\n};\r\n\r\nfunction buildEnvValidator(\r\n\tproviders: EnvCommandArguments['providers'],\r\n\targv: Partial<EnvCommandArguments>,\r\n) {\r\n\tlet schema = {};\r\n\r\n\tfor (const {\r\n\t\thandler: { key },\r\n\t} of providers) {\r\n\t\tconst providerSchema = argv.schema?.[key];\r\n\r\n\t\tif (providerSchema)\r\n\t\t\tschema = Object.assign(\r\n\t\t\t\tschema,\r\n\t\t\t\tflatSchema(providerSchema, '', argv.nestingDelimiter),\r\n\t\t\t);\r\n\t}\r\n\r\n\treturn createValidator({ properties: schema, type: 'object' });\r\n}\r\n"],"mappings":";;;;;;;;;;AA8BA,IAAa,IAAsD;CAClE,SAAS;CACT,UAAU;CACV,UAAU,OACT,EACE,QAAQ;EACR,gBAAgB;GACf,OAAO;GACP,SAAS;GACT,UAAU;GACV,MAAM;EACP;EACA,QAAQ;GACP,UAAU;GACV,MAAM;EACP;CACD,CAAC,EACA,QACA,sCACA,gGACD,EACC,QACA,uDACA,yGACD,EACC,QACA,gEACA,0EACD,EACC,OAAO,OAEH,EAAK,EAAE,WAAW,KAAK,CAAC,EAAK,WAChC,EAAO,MACN,qDACD,GAEA,QAAQ,KAAK,CAAC,IAGR,GACP,GAEK;CAER,SAAS,OAAO,EAAE,WAAQ,cAAW,mBAAgB,GAAG,QAAW;EAClE,IAAM,IAAU,YAAY,IAAI,GAG1B,IAAmB,IACtB,EAAkB,GAAW,CAAI,IACjC,KAAA,GAEG,IAAU,MAAM,EAA2B,GAAW,CAAI;EAGhE,KAAK,IAAM,EAAE,QAAK,cAAW,GAAS;GACrC,IAAM,IAAO,MAAM,QAAQ,CAAK,IAC7B,EACA,CAAC,GACD,GAAG,EAAM,KAAK,MACb,EAAQ,GAAG,EAAK,gBAAgB,CACjC,CACD,IACC,EAAQ,GAAO,EAAK,gBAAgB;GAEvC,EAAG,SAAS,GAAK,OAAO,KAAK,CAAI,EAAE,MAAM;EAC1C;EAEA,IAAI,IAAM,EACT,EAAE,UAAU,cAAc,GAC1B,GAAG,EAAY,GAAS,EAAK,gBAAgB,CAC9C;EAEA,IAAI,GAAkB;GACrB,IAAM,IAAY,MAAM;GAExB,AAAK,EAAU,CAAG,MACjB,EAAO,MAAM,4BAA4B,EAAU,MAAM,GAEzD,QAAQ,KAAK,CAAC;EAEhB;EAQA,AANA,IAAM,EAAU,GAAK,EAAK,kBAAkB,EAAK,mBAAmB,GAChE,MACH,IAAM,EAAY,GAAK,CAAG,GAC1B,EAAK,SAAS,EAAY,EAAK,QAAQ,CAAG,IAG3C,EAAO,MAAM,uBAAuB,CAAG;EAGvC,KAAK,IAAM,KAAW,GAAK,QAAQ,IAAI,KAAW,OAAO,EAAI,EAAQ;EAErE,EAAG,QAAQ,OAAO,KAAK,CAAG,EAAE,QAAQ,YAAY,IAAI,IAAI,CAAO;EAE/D,IAAM,IAAa,EAAK,OAAO,KAAK,GAAG;EAIvC,AAFA,EAAG,QAAQ,CAAU,GAErB,EAAM,GAAY;GACjB,OAAO;GACP,OAAO;EACR,CAAC,EAAE,GAAG,SAAS,MAAS;GACvB,IAAI,MAAS,KAAK,MAAS,MAAM;IAChC,EAAG,SAAS,YAAY,IAAI,IAAI,CAAO;IAEvC;GACD;GAIA,AAFA,EAAG,OAAO,CAAI,GACd,EAAO,MAAM,6BAA6B,GAC1C,QAAQ,KAAK,CAAI;EAClB,CAAC;CACF;AACD;AAEA,SAAS,EACR,GACA,GACC;CACD,IAAI,IAAS,CAAC;CAEd,KAAK,IAAM,EACV,SAAS,EAAE,cACP,GAAW;EACf,IAAM,IAAiB,EAAK,SAAS;EAErC,AAAI,MACH,IAAS,OAAO,OACf,GACA,EAAW,GAAgB,IAAI,EAAK,gBAAgB,CACrD;CACF;CAEA,OAAO,EAAgB;EAAE,YAAY;EAAQ,MAAM;CAAS,CAAC;AAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.command.d.ts","sourceRoot":"","sources":["../../src/commands/export.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"export.command.d.ts","sourceRoot":"","sources":["../../src/commands/export.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYxD,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC/D,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;IAE1B,GAAG,EAAE,MAAM,CAAC;IAEZ,YAAY,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,GAAG,EAAE,sBAAsB,CA0FpE,CAAC"}
|
|
@@ -3,10 +3,11 @@ import { interpolate as n } from "../utils/interpolate.util.js";
|
|
|
3
3
|
import { writeEnvFromJson as r, writeJson as i } from "../utils/json.util.js";
|
|
4
4
|
import { logger as a } from "../utils/logger.js";
|
|
5
5
|
import { normalize as o } from "../utils/normalize.util.js";
|
|
6
|
+
import { ui as s } from "../utils/ui.js";
|
|
6
7
|
import "../utils/index.js";
|
|
7
|
-
import
|
|
8
|
+
import c from "merge-deep";
|
|
8
9
|
//#region src/commands/export.command.ts
|
|
9
|
-
var
|
|
10
|
+
var l = {
|
|
10
11
|
command: "export [options..]",
|
|
11
12
|
describe: "Export unified environment variables to a file from providers",
|
|
12
13
|
builder: (e) => (e.options({
|
|
@@ -34,22 +35,22 @@ var c = {
|
|
|
34
35
|
type: "string"
|
|
35
36
|
}
|
|
36
37
|
}).example("env export -e dev -m build", "Exports \"dev\" variables to a dotenv file at root as \".env\"").example("env export -e prod -m build -f json --uri [[env]].env.json", "Exports \"prod\" variables to a json file at root as \"prod.env.json\""), e),
|
|
37
|
-
handler: async ({ expand:
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
let { format:
|
|
41
|
-
switch (
|
|
38
|
+
handler: async ({ expand: l, exportIgnoreKeys: u, exportQuotes: d, providers: f, ...p }) => {
|
|
39
|
+
let m = c({ NODE_ENV: "development" }, ...await e(await t(f, p), p));
|
|
40
|
+
m = o(m, p.nestingDelimiter, p.arrayDescomposition), l && (m = n(m, m)), u && (a.silly("ignoring:", u), m = Object.fromEntries(Object.entries(m).filter(([e]) => !u.includes(e)))), a.debug("environment loaded:", m);
|
|
41
|
+
let { format: h, uri: g } = p;
|
|
42
|
+
switch (h) {
|
|
42
43
|
case "dotenv":
|
|
43
|
-
await r(
|
|
44
|
+
await r(g, m, !0, d), s.action("📤", `exported ${Object.keys(m).length} variables → ${g} (${h})`);
|
|
44
45
|
break;
|
|
45
46
|
case "json":
|
|
46
|
-
await i(
|
|
47
|
+
await i(g, m, !0), s.action("📤", `exported ${Object.keys(m).length} variables → ${g} (${h})`);
|
|
47
48
|
break;
|
|
48
|
-
default: a.error(`format ${
|
|
49
|
+
default: a.error(`format ${h} not recognized`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
//#endregion
|
|
53
|
-
export {
|
|
54
|
+
export { l as exportCommand };
|
|
54
55
|
|
|
55
56
|
//# sourceMappingURL=export.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.command.js","names":[],"sources":["../../src/commands/export.command.ts"],"sourcesContent":["import merge from 'merge-deep';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport {\r\n\tflatAndValidateResults,\r\n\tinterpolate,\r\n\tloadVariablesFromProviders,\r\n\tlogger,\r\n\tnormalize,\r\n\twriteEnvFromJson,\r\n\twriteJson,\r\n} from '../utils/index.js';\r\n\r\nexport interface ExportCommandArguments extends CommandArguments {\r\n\tformat: 'dotenv' | 'json';\r\n\r\n\turi: string;\r\n\r\n\texportQuotes: boolean;\r\n}\r\n\r\n/**\r\n * Export command.\r\n * Export environment variables to a file.\r\n *\r\n * @example [>_]: env export -e dev -m build\r\n */\r\nexport const exportCommand: CommandModule<any, ExportCommandArguments> = {\r\n\tcommand: 'export [options..]',\r\n\tdescribe: 'Export unified environment variables to a file from providers',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\texportQuotes: {\r\n\t\t\t\t\talias: ['quotes', 'q'],\r\n\t\t\t\t\tdefault: false,\r\n\t\t\t\t\tdescribe: 'Wraps values in quotes',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t\tformat: {\r\n\t\t\t\t\talias: 'f',\r\n\t\t\t\t\tchoices: ['json', 'dotenv'],\r\n\t\t\t\t\tdefault: 'dotenv',\r\n\t\t\t\t\tdescribe: 'Format for export variables',\r\n\t\t\t\t\ttype: 'string',\r\n\t\t\t\t},\r\n\t\t\t\turi: {\r\n\t\t\t\t\talias: ['u', 'p', 'path'],\r\n\t\t\t\t\tdefault: '.env',\r\n\t\t\t\t\tdescribe: 'Uri for export file with variables',\r\n\t\t\t\t\ttype: 'string',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example(\r\n\t\t\t\t'env export -e dev -m build',\r\n\t\t\t\t'Exports \"dev\" variables to a dotenv file at root as \".env\"',\r\n\t\t\t)\r\n\t\t\t.example(\r\n\t\t\t\t'env export -e prod -m build -f json --uri [[env]].env.json',\r\n\t\t\t\t'Exports \"prod\" variables to a json file at root as \"prod.env.json\"',\r\n\t\t\t);\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({\r\n\t\texpand,\r\n\t\texportIgnoreKeys,\r\n\t\texportQuotes,\r\n\t\tproviders,\r\n\t\t...argv\r\n\t}) => {\r\n\t\tconst results = await loadVariablesFromProviders(providers, argv);\r\n\r\n\t\tlet env = merge(\r\n\t\t\t{ NODE_ENV: 'development' },\r\n\t\t\t...flatAndValidateResults(results, argv),\r\n\t\t);\r\n\r\n\t\tenv = normalize(env, argv.nestingDelimiter, argv.arrayDescomposition);\r\n\t\tif (expand) env = interpolate(env, env);\r\n\t\tif (exportIgnoreKeys) {\r\n\t\t\tlogger.silly('ignoring:', exportIgnoreKeys);\r\n\t\t\tenv = Object.fromEntries(\r\n\t\t\t\tObject.entries(env).filter(\r\n\t\t\t\t\t([k]) => !exportIgnoreKeys.includes(k),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tlogger.debug('environment loaded:', env);\r\n\r\n\t\tconst { format, uri } = argv;\r\n\r\n\t\tswitch (format) {\r\n\t\t\tcase 'dotenv': {\r\n\t\t\t\tawait writeEnvFromJson(uri, env, true, exportQuotes);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 'json': {\r\n\t\t\t\tawait writeJson(uri, env, true);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tdefault: {\r\n\t\t\t\tlogger.error(`format ${format} not recognized`);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n};\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.command.js","names":[],"sources":["../../src/commands/export.command.ts"],"sourcesContent":["import merge from 'merge-deep';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport {\r\n\tflatAndValidateResults,\r\n\tinterpolate,\r\n\tloadVariablesFromProviders,\r\n\tlogger,\r\n\tnormalize,\r\n\tui,\r\n\twriteEnvFromJson,\r\n\twriteJson,\r\n} from '../utils/index.js';\r\n\r\nexport interface ExportCommandArguments extends CommandArguments {\r\n\tformat: 'dotenv' | 'json';\r\n\r\n\turi: string;\r\n\r\n\texportQuotes: boolean;\r\n}\r\n\r\n/**\r\n * Export command.\r\n * Export environment variables to a file.\r\n *\r\n * @example [>_]: env export -e dev -m build\r\n */\r\nexport const exportCommand: CommandModule<any, ExportCommandArguments> = {\r\n\tcommand: 'export [options..]',\r\n\tdescribe: 'Export unified environment variables to a file from providers',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\texportQuotes: {\r\n\t\t\t\t\talias: ['quotes', 'q'],\r\n\t\t\t\t\tdefault: false,\r\n\t\t\t\t\tdescribe: 'Wraps values in quotes',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t\tformat: {\r\n\t\t\t\t\talias: 'f',\r\n\t\t\t\t\tchoices: ['json', 'dotenv'],\r\n\t\t\t\t\tdefault: 'dotenv',\r\n\t\t\t\t\tdescribe: 'Format for export variables',\r\n\t\t\t\t\ttype: 'string',\r\n\t\t\t\t},\r\n\t\t\t\turi: {\r\n\t\t\t\t\talias: ['u', 'p', 'path'],\r\n\t\t\t\t\tdefault: '.env',\r\n\t\t\t\t\tdescribe: 'Uri for export file with variables',\r\n\t\t\t\t\ttype: 'string',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example(\r\n\t\t\t\t'env export -e dev -m build',\r\n\t\t\t\t'Exports \"dev\" variables to a dotenv file at root as \".env\"',\r\n\t\t\t)\r\n\t\t\t.example(\r\n\t\t\t\t'env export -e prod -m build -f json --uri [[env]].env.json',\r\n\t\t\t\t'Exports \"prod\" variables to a json file at root as \"prod.env.json\"',\r\n\t\t\t);\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({\r\n\t\texpand,\r\n\t\texportIgnoreKeys,\r\n\t\texportQuotes,\r\n\t\tproviders,\r\n\t\t...argv\r\n\t}) => {\r\n\t\tconst results = await loadVariablesFromProviders(providers, argv);\r\n\r\n\t\tlet env = merge(\r\n\t\t\t{ NODE_ENV: 'development' },\r\n\t\t\t...(await flatAndValidateResults(results, argv)),\r\n\t\t);\r\n\r\n\t\tenv = normalize(env, argv.nestingDelimiter, argv.arrayDescomposition);\r\n\t\tif (expand) env = interpolate(env, env);\r\n\t\tif (exportIgnoreKeys) {\r\n\t\t\tlogger.silly('ignoring:', exportIgnoreKeys);\r\n\t\t\tenv = Object.fromEntries(\r\n\t\t\t\tObject.entries(env).filter(\r\n\t\t\t\t\t([k]) => !exportIgnoreKeys.includes(k),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tlogger.debug('environment loaded:', env);\r\n\r\n\t\tconst { format, uri } = argv;\r\n\r\n\t\tswitch (format) {\r\n\t\t\tcase 'dotenv': {\r\n\t\t\t\tawait writeEnvFromJson(uri, env, true, exportQuotes);\r\n\t\t\t\tui.action(\r\n\t\t\t\t\t'📤',\r\n\t\t\t\t\t`exported ${Object.keys(env).length} variables → ${uri} (${format})`,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 'json': {\r\n\t\t\t\tawait writeJson(uri, env, true);\r\n\t\t\t\tui.action(\r\n\t\t\t\t\t'📤',\r\n\t\t\t\t\t`exported ${Object.keys(env).length} variables → ${uri} (${format})`,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tdefault: {\r\n\t\t\t\tlogger.error(`format ${format} not recognized`);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n};\r\n"],"mappings":";;;;;;;;;AA4BA,IAAa,IAA4D;CACxE,SAAS;CACT,UAAU;CACV,UAAU,OACT,EACE,QAAQ;EACR,cAAc;GACb,OAAO,CAAC,UAAU,GAAG;GACrB,SAAS;GACT,UAAU;GACV,MAAM;EACP;EACA,QAAQ;GACP,OAAO;GACP,SAAS,CAAC,QAAQ,QAAQ;GAC1B,SAAS;GACT,UAAU;GACV,MAAM;EACP;EACA,KAAK;GACJ,OAAO;IAAC;IAAK;IAAK;GAAM;GACxB,SAAS;GACT,UAAU;GACV,MAAM;EACP;CACD,CAAC,EACA,QACA,8BACA,gEACD,EACC,QACA,8DACA,wEACD,GAEM;CAER,SAAS,OAAO,EACf,WACA,qBACA,iBACA,cACA,GAAG,QACE;EAGL,IAAI,IAAM,EACT,EAAE,UAAU,cAAc,GAC1B,GAAI,MAAM,EAAuB,MAJZ,EAA2B,GAAW,CAAI,GAIrB,CAAI,CAC/C;EAaA,AAXA,IAAM,EAAU,GAAK,EAAK,kBAAkB,EAAK,mBAAmB,GAChE,MAAQ,IAAM,EAAY,GAAK,CAAG,IAClC,MACH,EAAO,MAAM,aAAa,CAAgB,GAC1C,IAAM,OAAO,YACZ,OAAO,QAAQ,CAAG,EAAE,QAClB,CAAC,OAAO,CAAC,EAAiB,SAAS,CAAC,CACtC,CACD,IAGD,EAAO,MAAM,uBAAuB,CAAG;EAEvC,IAAM,EAAE,WAAQ,WAAQ;EAExB,QAAQ,GAAR;GACC,KAAK;IAEJ,AADA,MAAM,EAAiB,GAAK,GAAK,IAAM,CAAY,GACnD,EAAG,OACF,MACA,YAAY,OAAO,KAAK,CAAG,EAAE,OAAO,eAAe,EAAI,IAAI,EAAO,EACnE;IACA;GAGD,KAAK;IAEJ,AADA,MAAM,EAAU,GAAK,GAAK,EAAI,GAC9B,EAAG,OACF,MACA,YAAY,OAAO,KAAK,CAAG,EAAE,OAAO,eAAe,EAAI,IAAI,EAAO,EACnE;IACA;GAGD,SACC,EAAO,MAAM,UAAU,EAAO,gBAAgB;EAEhD;CACD;AACD"}
|
package/commands/pull.command.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { logger as e } from "../utils/logger.js";
|
|
2
|
+
import { ui as t } from "../utils/ui.js";
|
|
2
3
|
import "../utils/index.js";
|
|
3
|
-
import
|
|
4
|
+
import n from "picocolors";
|
|
4
5
|
//#region src/commands/pull.command.ts
|
|
5
|
-
var
|
|
6
|
+
var r = {
|
|
6
7
|
command: "pull [options..]",
|
|
7
8
|
describe: "Pulls environment variables from providers",
|
|
8
9
|
builder: (e) => (e.options({ overwrite: {
|
|
@@ -11,12 +12,12 @@ var n = {
|
|
|
11
12
|
describe: "Overwrite local variables",
|
|
12
13
|
type: "boolean"
|
|
13
14
|
} }).example("env pull -e dev", "Download \"dev\" environment secrets").example("env pull -e dev -o", "Download and overwrite (if any exists) \"dev\" environment secrets"), e),
|
|
14
|
-
handler: async ({ providers:
|
|
15
|
-
let
|
|
16
|
-
|
|
15
|
+
handler: async ({ providers: r, ...i }) => {
|
|
16
|
+
let a = r.filter(({ handler: { pull: e } }) => !!e), o = await Promise.all(a.map(({ config: t, handler: { key: r, pull: a } }) => (e.silly(`pulling from ${n.yellow(r)} provider`), a(i, t))));
|
|
17
|
+
o.length > 0 ? t.action("⬇️", `pulled from ${o.length} provider(s)`) : e.warn("no providers for pull variables");
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
//#endregion
|
|
20
|
-
export {
|
|
21
|
+
export { r as pullCommand };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=pull.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.command.js","names":[],"sources":["../../src/commands/pull.command.ts"],"sourcesContent":["import pc from 'picocolors';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport { logger } from '../utils/index.js';\r\n\r\nexport interface PullCommandArguments extends CommandArguments {\r\n\t// whether variables should be overwritten in already exists\r\n\toverwrite: boolean;\r\n}\r\n\r\n/**\r\n * Pulls environment variables from providers.\r\n *\r\n * @example [>_]: env pull -e dev\r\n */\r\nexport const pullCommand: CommandModule<any, PullCommandArguments> = {\r\n\tcommand: 'pull [options..]',\r\n\tdescribe: 'Pulls environment variables from providers',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\toverwrite: {\r\n\t\t\t\t\talias: 'o',\r\n\t\t\t\t\tdefault: false,\r\n\t\t\t\t\tdescribe: 'Overwrite local variables',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example('env pull -e dev', 'Download \"dev\" environment secrets')\r\n\t\t\t.example(\r\n\t\t\t\t'env pull -e dev -o',\r\n\t\t\t\t'Download and overwrite (if any exists) \"dev\" environment secrets',\r\n\t\t\t);\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({ providers, ...argv }) => {\r\n\t\tconst pullProviders = providers.filter(\r\n\t\t\t({ handler: { pull } }) => !!pull,\r\n\t\t);\r\n\t\tconst promises = await Promise.all(\r\n\t\t\tpullProviders.map(({ config, handler: { key, pull } }) => {\r\n\t\t\t\tlogger.silly(`pulling from ${pc.yellow(key)} provider`);\r\n\r\n\t\t\t\treturn pull!(argv, config);\r\n\t\t\t}),\r\n\t\t);\r\n\r\n\t\tif (promises.length > 0)\r\n\t\t\
|
|
1
|
+
{"version":3,"file":"pull.command.js","names":[],"sources":["../../src/commands/pull.command.ts"],"sourcesContent":["import pc from 'picocolors';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport { logger, ui } from '../utils/index.js';\r\n\r\nexport interface PullCommandArguments extends CommandArguments {\r\n\t// whether variables should be overwritten in already exists\r\n\toverwrite: boolean;\r\n}\r\n\r\n/**\r\n * Pulls environment variables from providers.\r\n *\r\n * @example [>_]: env pull -e dev\r\n */\r\nexport const pullCommand: CommandModule<any, PullCommandArguments> = {\r\n\tcommand: 'pull [options..]',\r\n\tdescribe: 'Pulls environment variables from providers',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\toverwrite: {\r\n\t\t\t\t\talias: 'o',\r\n\t\t\t\t\tdefault: false,\r\n\t\t\t\t\tdescribe: 'Overwrite local variables',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example('env pull -e dev', 'Download \"dev\" environment secrets')\r\n\t\t\t.example(\r\n\t\t\t\t'env pull -e dev -o',\r\n\t\t\t\t'Download and overwrite (if any exists) \"dev\" environment secrets',\r\n\t\t\t);\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({ providers, ...argv }) => {\r\n\t\tconst pullProviders = providers.filter(\r\n\t\t\t({ handler: { pull } }) => !!pull,\r\n\t\t);\r\n\t\tconst promises = await Promise.all(\r\n\t\t\tpullProviders.map(({ config, handler: { key, pull } }) => {\r\n\t\t\t\tlogger.silly(`pulling from ${pc.yellow(key)} provider`);\r\n\r\n\t\t\t\treturn pull!(argv, config);\r\n\t\t\t}),\r\n\t\t);\r\n\r\n\t\tif (promises.length > 0)\r\n\t\t\tui.action('⬇️', `pulled from ${promises.length} provider(s)`);\r\n\t\telse logger.warn('no providers for pull variables');\r\n\t},\r\n};\r\n"],"mappings":";;;;;AAeA,IAAa,IAAwD;CACpE,SAAS;CACT,UAAU;CACV,UAAU,OACT,EACE,QAAQ,EACR,WAAW;EACV,OAAO;EACP,SAAS;EACT,UAAU;EACV,MAAM;CACP,EACD,CAAC,EACA,QAAQ,mBAAmB,sCAAoC,EAC/D,QACA,sBACA,oEACD,GAEM;CAER,SAAS,OAAO,EAAE,cAAW,GAAG,QAAW;EAC1C,IAAM,IAAgB,EAAU,QAC9B,EAAE,SAAS,EAAE,gBAAa,CAAC,CAAC,CAC9B,GACM,IAAW,MAAM,QAAQ,IAC9B,EAAc,KAAK,EAAE,WAAQ,SAAS,EAAE,QAAK,iBAC5C,EAAO,MAAM,gBAAgB,EAAG,OAAO,CAAG,EAAE,UAAU,GAE/C,EAAM,GAAM,CAAM,EACzB,CACF;EAEA,AAAI,EAAS,SAAS,IACrB,EAAG,OAAO,MAAM,eAAe,EAAS,OAAO,aAAa,IACxD,EAAO,KAAK,iCAAiC;CACnD;AACD"}
|
package/commands/push.command.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { logger as e } from "../utils/logger.js";
|
|
2
|
+
import { ui as t } from "../utils/ui.js";
|
|
2
3
|
import "../utils/index.js";
|
|
3
|
-
import
|
|
4
|
+
import n from "picocolors";
|
|
4
5
|
//#region src/commands/push.command.ts
|
|
5
|
-
var
|
|
6
|
+
var r = {
|
|
6
7
|
command: "push [options..]",
|
|
7
8
|
describe: "Pushes environment variables to providers store",
|
|
8
9
|
builder: (e) => (e.options({ force: {
|
|
@@ -11,12 +12,12 @@ var n = {
|
|
|
11
12
|
describe: "Force push for secrets",
|
|
12
13
|
type: "boolean"
|
|
13
14
|
} }).example("env push -e dev", "Download \"dev\" environment secrets"), e),
|
|
14
|
-
handler: async ({ providers:
|
|
15
|
-
let
|
|
16
|
-
|
|
15
|
+
handler: async ({ providers: r, ...i }) => {
|
|
16
|
+
let a = r.filter(({ handler: { push: e } }) => !!e), o = await Promise.all(a.map(({ config: t, handler: { key: r, push: a } }) => (e.debug(`pushing to ${n.yellow(r)} provider`), a(i, t))));
|
|
17
|
+
o.length > 0 ? t.action("⬆️", `pushed to ${o.length} provider(s)`) : e.warn("no providers for push variables");
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
//#endregion
|
|
20
|
-
export {
|
|
21
|
+
export { r as pushCommand };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=push.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.command.js","names":[],"sources":["../../src/commands/push.command.ts"],"sourcesContent":["import pc from 'picocolors';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport { logger } from '../utils/index.js';\r\n\r\nexport interface PushCommandArguments extends CommandArguments {\r\n\t// forces to push in case of conflict\r\n\tforce: boolean;\r\n}\r\n\r\n/**\r\n * Pushes environment variables to providers store.\r\n *\r\n * @example [>_]: env push -e dev\r\n */\r\nexport const pushCommand: CommandModule<any, PushCommandArguments> = {\r\n\tcommand: 'push [options..]',\r\n\tdescribe: 'Pushes environment variables to providers store',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\tforce: {\r\n\t\t\t\t\talias: 'f',\r\n\t\t\t\t\tdefault: false,\r\n\t\t\t\t\tdescribe: 'Force push for secrets',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example('env push -e dev', 'Download \"dev\" environment secrets');\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({ providers, ...argv }) => {\r\n\t\tconst pushProviders = providers.filter(\r\n\t\t\t({ handler: { push } }) => !!push,\r\n\t\t);\r\n\t\tconst promises = await Promise.all(\r\n\t\t\tpushProviders.map(({ config, handler: { key, push } }) => {\r\n\t\t\t\tlogger.debug(`pushing to ${pc.yellow(key)} provider`);\r\n\r\n\t\t\t\treturn push!(argv, config);\r\n\t\t\t}),\r\n\t\t);\r\n\r\n\t\tif (promises.length > 0)\r\n\t\t\
|
|
1
|
+
{"version":3,"file":"push.command.js","names":[],"sources":["../../src/commands/push.command.ts"],"sourcesContent":["import pc from 'picocolors';\r\nimport type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport { logger, ui } from '../utils/index.js';\r\n\r\nexport interface PushCommandArguments extends CommandArguments {\r\n\t// forces to push in case of conflict\r\n\tforce: boolean;\r\n}\r\n\r\n/**\r\n * Pushes environment variables to providers store.\r\n *\r\n * @example [>_]: env push -e dev\r\n */\r\nexport const pushCommand: CommandModule<any, PushCommandArguments> = {\r\n\tcommand: 'push [options..]',\r\n\tdescribe: 'Pushes environment variables to providers store',\r\n\tbuilder: (builder) => {\r\n\t\tbuilder\r\n\t\t\t.options({\r\n\t\t\t\tforce: {\r\n\t\t\t\t\talias: 'f',\r\n\t\t\t\t\tdefault: false,\r\n\t\t\t\t\tdescribe: 'Force push for secrets',\r\n\t\t\t\t\ttype: 'boolean',\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t.example('env push -e dev', 'Download \"dev\" environment secrets');\r\n\r\n\t\treturn builder;\r\n\t},\r\n\thandler: async ({ providers, ...argv }) => {\r\n\t\tconst pushProviders = providers.filter(\r\n\t\t\t({ handler: { push } }) => !!push,\r\n\t\t);\r\n\t\tconst promises = await Promise.all(\r\n\t\t\tpushProviders.map(({ config, handler: { key, push } }) => {\r\n\t\t\t\tlogger.debug(`pushing to ${pc.yellow(key)} provider`);\r\n\r\n\t\t\t\treturn push!(argv, config);\r\n\t\t\t}),\r\n\t\t);\r\n\r\n\t\tif (promises.length > 0)\r\n\t\t\tui.action('⬆️', `pushed to ${promises.length} provider(s)`);\r\n\t\telse logger.warn('no providers for push variables');\r\n\t},\r\n};\r\n"],"mappings":";;;;;AAeA,IAAa,IAAwD;CACpE,SAAS;CACT,UAAU;CACV,UAAU,OACT,EACE,QAAQ,EACR,OAAO;EACN,OAAO;EACP,SAAS;EACT,UAAU;EACV,MAAM;CACP,EACD,CAAC,EACA,QAAQ,mBAAmB,sCAAoC,GAE1D;CAER,SAAS,OAAO,EAAE,cAAW,GAAG,QAAW;EAC1C,IAAM,IAAgB,EAAU,QAC9B,EAAE,SAAS,EAAE,gBAAa,CAAC,CAAC,CAC9B,GACM,IAAW,MAAM,QAAQ,IAC9B,EAAc,KAAK,EAAE,WAAQ,SAAS,EAAE,QAAK,iBAC5C,EAAO,MAAM,cAAc,EAAG,OAAO,CAAG,EAAE,UAAU,GAE7C,EAAM,GAAM,CAAM,EACzB,CACF;EAEA,AAAI,EAAS,SAAS,IACrB,EAAG,OAAO,MAAM,aAAa,EAAS,OAAO,aAAa,IACtD,EAAO,KAAK,iCAAiC;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.command.d.ts","sourceRoot":"","sources":["../../src/commands/schema.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.command.d.ts","sourceRoot":"","sources":["../../src/commands/schema.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAQxD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,GAAG,EAAE,gBAAgB,CAmB9D,CAAC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { generateSchemaFrom as e, loadVariablesFromProviders as t } from "../utils/command.util.js";
|
|
2
2
|
import { logger as n } from "../utils/logger.js";
|
|
3
|
+
import { ui as r } from "../utils/ui.js";
|
|
3
4
|
import "../utils/index.js";
|
|
4
5
|
//#region src/commands/schema.command.ts
|
|
5
|
-
var
|
|
6
|
+
var i = {
|
|
6
7
|
command: "schema [options..]",
|
|
7
8
|
describe: "Generates validation schema from providers",
|
|
8
9
|
builder: (e) => e.example("env schema --generate -e dev -m debug unit", "Updates JSON schema"),
|
|
9
|
-
handler: async (
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
n.silly("schema:",
|
|
10
|
+
handler: async (i) => {
|
|
11
|
+
i.ci = !0;
|
|
12
|
+
let a = await e(await t(i.providers, i), i);
|
|
13
|
+
n.silly("schema:", a), r.action("📐", `schema updated → ${i.schemaFile}`);
|
|
13
14
|
}
|
|
14
15
|
};
|
|
15
16
|
//#endregion
|
|
16
|
-
export {
|
|
17
|
+
export { i as schemaCommand };
|
|
17
18
|
|
|
18
19
|
//# sourceMappingURL=schema.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.command.js","names":[],"sources":["../../src/commands/schema.command.ts"],"sourcesContent":["import type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport {\r\n\tgenerateSchemaFrom,\r\n\tloadVariablesFromProviders,\r\n\tlogger,\r\n} from '../utils/index.js';\r\n\r\n/**\r\n * Generates validation schema from providers environment variables.\r\n *\r\n * @example [>_]: env schema -e dev -m build\r\n */\r\nexport const schemaCommand: CommandModule<any, CommandArguments> = {\r\n\tcommand: 'schema [options..]',\r\n\tdescribe: 'Generates validation schema from providers',\r\n\tbuilder: (builder) => {\r\n\t\treturn builder.example(\r\n\t\t\t'env schema --generate -e dev -m debug unit',\r\n\t\t\t'Updates JSON schema',\r\n\t\t);\r\n\t},\r\n\thandler: async (argv) => {\r\n\t\targv.ci = true;\r\n\r\n\t\tconst results = await loadVariablesFromProviders(argv.providers, argv);\r\n\r\n\t\tconst schema = await generateSchemaFrom(results, argv);\r\n\r\n\t\tlogger.silly('schema:', schema);\r\n\t\
|
|
1
|
+
{"version":3,"file":"schema.command.js","names":[],"sources":["../../src/commands/schema.command.ts"],"sourcesContent":["import type { CommandModule } from 'yargs';\r\nimport type { CommandArguments } from '../arguments.js';\r\nimport {\r\n\tgenerateSchemaFrom,\r\n\tloadVariablesFromProviders,\r\n\tlogger,\r\n\tui,\r\n} from '../utils/index.js';\r\n\r\n/**\r\n * Generates validation schema from providers environment variables.\r\n *\r\n * @example [>_]: env schema -e dev -m build\r\n */\r\nexport const schemaCommand: CommandModule<any, CommandArguments> = {\r\n\tcommand: 'schema [options..]',\r\n\tdescribe: 'Generates validation schema from providers',\r\n\tbuilder: (builder) => {\r\n\t\treturn builder.example(\r\n\t\t\t'env schema --generate -e dev -m debug unit',\r\n\t\t\t'Updates JSON schema',\r\n\t\t);\r\n\t},\r\n\thandler: async (argv) => {\r\n\t\targv.ci = true;\r\n\r\n\t\tconst results = await loadVariablesFromProviders(argv.providers, argv);\r\n\r\n\t\tconst schema = await generateSchemaFrom(results, argv);\r\n\r\n\t\tlogger.silly('schema:', schema);\r\n\t\tui.action('📐', `schema updated → ${argv.schemaFile}`);\r\n\t},\r\n};\r\n"],"mappings":";;;;;AAcA,IAAa,IAAsD;CAClE,SAAS;CACT,UAAU;CACV,UAAU,MACF,EAAQ,QACd,8CACA,qBACD;CAED,SAAS,OAAO,MAAS;EACxB,EAAK,KAAK;EAIV,IAAM,IAAS,MAAM,EAAmB,MAFlB,EAA2B,EAAK,WAAW,CAAI,GAEpB,CAAI;EAGrD,AADA,EAAO,MAAM,WAAW,CAAM,GAC9B,EAAG,OAAO,MAAM,oBAAoB,EAAK,YAAY;CACtD;AACD"}
|
package/exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":"AAuFA;;;;;;GAMG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,iBA2D3C"}
|
package/exec.js
CHANGED
|
@@ -2,23 +2,24 @@ import { getSubcommand as e, loadConfigFile as t, loadProjectInfo as n, loadSche
|
|
|
2
2
|
import { interpolateJson as i } from "./utils/interpolate.util.js";
|
|
3
3
|
import { resolvePath as a } from "./utils/json.util.js";
|
|
4
4
|
import { configureLogger as o, logger as s } from "./utils/logger.js";
|
|
5
|
+
import { ui as c } from "./utils/ui.js";
|
|
5
6
|
import "./utils/index.js";
|
|
6
|
-
import { IntegratedProviders as
|
|
7
|
-
import { args as
|
|
8
|
-
import { envCommand as
|
|
9
|
-
import { exportCommand as
|
|
10
|
-
import { pullCommand as
|
|
11
|
-
import { pushCommand as
|
|
12
|
-
import { schemaCommand as
|
|
7
|
+
import { IntegratedProviders as l } from "./providers/index.js";
|
|
8
|
+
import { args as u } from "./arguments.js";
|
|
9
|
+
import { envCommand as d } from "./commands/env.command.js";
|
|
10
|
+
import { exportCommand as f } from "./commands/export.command.js";
|
|
11
|
+
import { pullCommand as p } from "./commands/pull.command.js";
|
|
12
|
+
import { pushCommand as m } from "./commands/push.command.js";
|
|
13
|
+
import { schemaCommand as h } from "./commands/schema.command.js";
|
|
13
14
|
import "./commands/index.js";
|
|
14
|
-
import
|
|
15
|
-
import { readFileSync as
|
|
16
|
-
import { fileURLToPath as
|
|
17
|
-
import
|
|
18
|
-
import { Parser as
|
|
15
|
+
import g from "picocolors";
|
|
16
|
+
import { readFileSync as _ } from "node:fs";
|
|
17
|
+
import { fileURLToPath as v } from "node:url";
|
|
18
|
+
import y from "yargs";
|
|
19
|
+
import { Parser as b } from "yargs/helpers";
|
|
19
20
|
//#region src/exec.ts
|
|
20
|
-
async function
|
|
21
|
-
let i =
|
|
21
|
+
async function x(e, n, r) {
|
|
22
|
+
let i = b.detailed(e, {
|
|
22
23
|
array: [
|
|
23
24
|
"modes",
|
|
24
25
|
"logMaskAnyRegEx",
|
|
@@ -34,55 +35,53 @@ async function b(e, n, r) {
|
|
|
34
35
|
"logLevel"
|
|
35
36
|
],
|
|
36
37
|
alias: {
|
|
37
|
-
configFile:
|
|
38
|
-
env:
|
|
39
|
-
logLevel:
|
|
40
|
-
logMaskAnyRegEx:
|
|
41
|
-
logMaskValuesOfKeys:
|
|
42
|
-
modes:
|
|
38
|
+
configFile: u.configFile.alias,
|
|
39
|
+
env: u.env.alias,
|
|
40
|
+
logLevel: u.logLevel.alias,
|
|
41
|
+
logMaskAnyRegEx: u.logMaskAnyRegEx.alias,
|
|
42
|
+
logMaskValuesOfKeys: u.logMaskValuesOfKeys.alias,
|
|
43
|
+
modes: u.modes.alias
|
|
43
44
|
},
|
|
44
45
|
default: {
|
|
45
|
-
configFile:
|
|
46
|
-
root:
|
|
46
|
+
configFile: u.configFile.default,
|
|
47
|
+
root: u.root.default
|
|
47
48
|
}
|
|
48
49
|
}).argv;
|
|
49
|
-
await t(i, r), i.logLevel ??=
|
|
50
|
-
let { logLevel: a, logMaskAnyRegEx: c, logMaskValuesOfKeys:
|
|
50
|
+
await t(i, r), i.logLevel ??= u.logLevel.default, i.logMaskAnyRegEx ??= u.logMaskAnyRegEx.default, i.logMaskValuesOfKeys ??= u.logMaskValuesOfKeys.default, i.providers ??= u.providers.default;
|
|
51
|
+
let { logLevel: a, logMaskAnyRegEx: c, logMaskValuesOfKeys: l } = i;
|
|
51
52
|
return o(s, {
|
|
52
53
|
maskAnyRegEx: c,
|
|
53
|
-
maskValuesOfKeys:
|
|
54
|
+
maskValuesOfKeys: l,
|
|
54
55
|
minLevel: a
|
|
55
56
|
}), (a === "silly" || a === "trace") && (process.env.AKV_DEBUG = "true"), i;
|
|
56
57
|
}
|
|
57
|
-
async function
|
|
58
|
-
let { config: n, version: r } = JSON.parse(
|
|
59
|
-
|
|
60
|
-
let
|
|
61
|
-
|
|
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];
|
|
58
|
+
async function S(t) {
|
|
59
|
+
let { config: n, version: r } = JSON.parse(_(v(new URL("package.json", "" + import.meta.url)), "utf8")), i = e(t, n.delimiters.subcommand), o = await x(t, n.parser, n.delimiters.template), { env: u, help: d, modes: f, providers: p } = o;
|
|
60
|
+
d && C(t, o, i, n, r), (!Array.isArray(p) || p.length === 0) && (s.error("no providers found"), process.exit(1)), c.header(r, u, f);
|
|
61
|
+
for (let e of p) try {
|
|
62
|
+
if (s.debug(`using ${g.yellow(e.path)} provider`), !e.type || e.type === "integrated") e.handler = l[e.path];
|
|
64
63
|
else {
|
|
65
64
|
let { default: t } = await (e.type === "module" ? import(e.path) : import(a(e.path)));
|
|
66
65
|
e.handler = t;
|
|
67
66
|
}
|
|
68
67
|
} catch {
|
|
69
|
-
s.error(`${
|
|
68
|
+
s.error(`${g.yellow(e.path)} provider not found or not compatible`), process.exit(1);
|
|
70
69
|
}
|
|
71
|
-
|
|
70
|
+
C(t, o, i, n, r);
|
|
72
71
|
}
|
|
73
|
-
function
|
|
74
|
-
let
|
|
75
|
-
a?.length > 0 && (e.subcmd = a), Object.assign(e, t), s.silly("interpolating arguments surrounded by",
|
|
72
|
+
function C(e, t, a, o, c = "unknown") {
|
|
73
|
+
let l = y(e).strict().scriptName("env").version(c).detectLocale(!1).showHelpOnFail(!1).parserConfiguration(o.parser).usage("Usage: $0 [command] [options..] [: subcmd [:]] [options..]").options(u).middleware(async (e) => {
|
|
74
|
+
a?.length > 0 && (e.subcmd = a), Object.assign(e, t), s.silly("interpolating arguments surrounded by", g.bold(g.yellow(`${o.delimiters.template[0]} ${o.delimiters.template[1]}`)));
|
|
76
75
|
let c = e.subcmd;
|
|
77
76
|
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
77
|
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
78
|
});
|
|
80
|
-
|
|
79
|
+
l.command(d), l.command(f), l.command(p), l.command(m), l.command(h);
|
|
81
80
|
let { providers: _ } = t;
|
|
82
|
-
for (let { handler: e } of _) e?.builder && e.builder(
|
|
83
|
-
|
|
81
|
+
for (let { handler: e } of _) e?.builder && e.builder(l);
|
|
82
|
+
l.parse();
|
|
84
83
|
}
|
|
85
84
|
//#endregion
|
|
86
|
-
export {
|
|
85
|
+
export { S as exec };
|
|
87
86
|
|
|
88
87
|
//# sourceMappingURL=exec.js.map
|