@achs/env 5.0.0-alpha.4 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arguments.d.ts.map +1 -1
- package/arguments.js +13 -6
- package/arguments.js.map +1 -1
- package/commands/env.command.js +2 -2
- package/commands/env.command.js.map +1 -1
- package/commands/pull.command.js +1 -1
- package/commands/pull.command.js.map +1 -1
- package/commands/push.command.js +1 -1
- package/commands/push.command.js.map +1 -1
- package/commands/schema.command.js +1 -1
- package/commands/schema.command.js.map +1 -1
- package/exec.js +10 -5
- package/exec.js.map +1 -1
- package/package.json +1 -1
- package/utils/ui.d.ts +2 -0
- package/utils/ui.d.ts.map +1 -1
- package/utils/ui.js +35 -9
- package/utils/ui.js.map +1 -1
package/arguments.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../src/arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../src/arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAU/D,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IAClD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IACnE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAChD;AAGD,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,gBAAgB,EAAE,OAAO,CA6HxD,CAAC"}
|
package/arguments.js
CHANGED
|
@@ -2,6 +2,7 @@ import { IntegratedProviderConfig as e } from "./providers/index.js";
|
|
|
2
2
|
import t from "ci-info";
|
|
3
3
|
//#region src/arguments.ts
|
|
4
4
|
var n = {
|
|
5
|
+
CORE: "Core Options",
|
|
5
6
|
GROUP_WORKSPACE: "Workspace Options",
|
|
6
7
|
JSON_SCHEMA_WORKSPACE: "JSON Schema Options",
|
|
7
8
|
LOG_WORKSPACE: "Logger Options"
|
|
@@ -10,12 +11,13 @@ var n = {
|
|
|
10
11
|
alias: "arrDesc",
|
|
11
12
|
default: !1,
|
|
12
13
|
describe: "Whether serialize or break down arrays",
|
|
14
|
+
group: n.CORE,
|
|
13
15
|
type: "boolean"
|
|
14
16
|
},
|
|
15
17
|
ci: {
|
|
16
|
-
alias: "ci",
|
|
17
18
|
default: t.isCI,
|
|
18
|
-
describe: "
|
|
19
|
+
describe: "Run providers in continuous-integration mode (skips local files)",
|
|
20
|
+
group: n.CORE,
|
|
19
21
|
type: "boolean"
|
|
20
22
|
},
|
|
21
23
|
configFile: {
|
|
@@ -34,13 +36,15 @@ var n = {
|
|
|
34
36
|
},
|
|
35
37
|
env: {
|
|
36
38
|
alias: "e",
|
|
37
|
-
describe: "Environment
|
|
39
|
+
describe: "Environment to load, i.e. dev, prod",
|
|
40
|
+
group: n.CORE,
|
|
38
41
|
type: "string"
|
|
39
42
|
},
|
|
40
43
|
expand: {
|
|
41
44
|
alias: "x",
|
|
42
45
|
default: !1,
|
|
43
|
-
describe: "
|
|
46
|
+
describe: "Interpolate environment variables using themselves",
|
|
47
|
+
group: n.CORE,
|
|
44
48
|
type: "boolean"
|
|
45
49
|
},
|
|
46
50
|
exportIgnoreKeys: {
|
|
@@ -61,31 +65,34 @@ var n = {
|
|
|
61
65
|
"error"
|
|
62
66
|
],
|
|
63
67
|
default: "info",
|
|
68
|
+
describe: "Log verbosity level",
|
|
64
69
|
group: n.LOG_WORKSPACE,
|
|
65
70
|
type: "string"
|
|
66
71
|
},
|
|
67
72
|
logMaskAnyRegEx: {
|
|
68
73
|
alias: "mrx",
|
|
69
74
|
default: [],
|
|
75
|
+
describe: "Mask log values matching these regular expressions",
|
|
70
76
|
group: n.LOG_WORKSPACE,
|
|
71
|
-
hidden: !0,
|
|
72
77
|
type: "array"
|
|
73
78
|
},
|
|
74
79
|
logMaskValuesOfKeys: {
|
|
75
80
|
alias: "mvk",
|
|
76
81
|
default: [],
|
|
82
|
+
describe: "Mask the values of these keys in logs",
|
|
77
83
|
group: n.LOG_WORKSPACE,
|
|
78
|
-
hidden: !0,
|
|
79
84
|
type: "array"
|
|
80
85
|
},
|
|
81
86
|
modes: {
|
|
82
87
|
alias: "m",
|
|
83
88
|
describe: "Execution modes, i.e. debug, test",
|
|
89
|
+
group: n.CORE,
|
|
84
90
|
type: "array"
|
|
85
91
|
},
|
|
86
92
|
nestingDelimiter: {
|
|
87
93
|
alias: "nd",
|
|
88
94
|
default: "__",
|
|
95
|
+
group: n.CORE,
|
|
89
96
|
type: "string",
|
|
90
97
|
describe: "Nesting level delimiter for flatten, i.e. { l1: { l2: \"value\" } } turns into { l1__l2: \"value\" }"
|
|
91
98
|
},
|
package/arguments.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arguments.js","names":[],"sources":["../src/arguments.ts"],"sourcesContent":["import type { JSONSchemaType } from 'ajv';\r\nimport ci from 'ci-info';\r\nimport type { Arguments, Options } from 'yargs';\r\nimport type { EnvProviderConfig } from './interfaces/index.js';\r\nimport { IntegratedProviderConfig } from './providers/index.js';\r\n\r\nconst GROUPS = {\r\n\tGROUP_WORKSPACE: 'Workspace Options',\r\n\tJSON_SCHEMA_WORKSPACE: 'JSON Schema Options',\r\n\tLOG_WORKSPACE: 'Logger Options',\r\n};\r\n\r\nexport interface CommandArguments extends Arguments {\r\n\tarrayDescomposition: boolean;\r\n\tci: boolean;\r\n\tconfigFile: string;\r\n\tdetectFormat: boolean;\r\n\tenv: string;\r\n\texpand: boolean;\r\n\tnestingDelimiter: string;\r\n\tnullable: boolean;\r\n\tpackageJson: string;\r\n\tprojectInfo: Record<string, string>;\r\n\tproviders: EnvProviderConfig[];\r\n\tresolve: 'merge' | 'override';\r\n\troot: string;\r\n\tschemaFile: string;\r\n\texportIgnoreKeys?: string[];\r\n\tlogLevel?: 'debug' | 'error' | 'info' | 'silly' | 'trace' | 'warn';\r\n\tlogMaskAnyRegEx?: string[];\r\n\tlogMaskValuesOfKeys?: string[];\r\n\tmodes?: string[];\r\n\tschema?: Record<string, JSONSchemaType<object>>;\r\n}\r\n\r\n// common CLI arguments\r\nexport const args: Record<keyof CommandArguments, Options> = {\r\n\tarrayDescomposition: {\r\n\t\talias: 'arrDesc',\r\n\t\tdefault: false,\r\n\t\tdescribe: 'Whether serialize or break down arrays',\r\n\t\ttype: 'boolean',\r\n\t},\r\n\tci: {\r\n\t\
|
|
1
|
+
{"version":3,"file":"arguments.js","names":[],"sources":["../src/arguments.ts"],"sourcesContent":["import type { JSONSchemaType } from 'ajv';\r\nimport ci from 'ci-info';\r\nimport type { Arguments, Options } from 'yargs';\r\nimport type { EnvProviderConfig } from './interfaces/index.js';\r\nimport { IntegratedProviderConfig } from './providers/index.js';\r\n\r\nconst GROUPS = {\r\n\tCORE: 'Core Options',\r\n\tGROUP_WORKSPACE: 'Workspace Options',\r\n\tJSON_SCHEMA_WORKSPACE: 'JSON Schema Options',\r\n\tLOG_WORKSPACE: 'Logger Options',\r\n};\r\n\r\nexport interface CommandArguments extends Arguments {\r\n\tarrayDescomposition: boolean;\r\n\tci: boolean;\r\n\tconfigFile: string;\r\n\tdetectFormat: boolean;\r\n\tenv: string;\r\n\texpand: boolean;\r\n\tnestingDelimiter: string;\r\n\tnullable: boolean;\r\n\tpackageJson: string;\r\n\tprojectInfo: Record<string, string>;\r\n\tproviders: EnvProviderConfig[];\r\n\tresolve: 'merge' | 'override';\r\n\troot: string;\r\n\tschemaFile: string;\r\n\texportIgnoreKeys?: string[];\r\n\tlogLevel?: 'debug' | 'error' | 'info' | 'silly' | 'trace' | 'warn';\r\n\tlogMaskAnyRegEx?: string[];\r\n\tlogMaskValuesOfKeys?: string[];\r\n\tmodes?: string[];\r\n\tschema?: Record<string, JSONSchemaType<object>>;\r\n}\r\n\r\n// common CLI arguments\r\nexport const args: Record<keyof CommandArguments, Options> = {\r\n\tarrayDescomposition: {\r\n\t\talias: 'arrDesc',\r\n\t\tdefault: false,\r\n\t\tdescribe: 'Whether serialize or break down arrays',\r\n\t\tgroup: GROUPS.CORE,\r\n\t\ttype: 'boolean',\r\n\t},\r\n\tci: {\r\n\t\tdefault: ci.isCI,\r\n\t\tdescribe: 'Run providers in continuous-integration mode (skips local files)',\r\n\t\tgroup: GROUPS.CORE,\r\n\t\ttype: 'boolean',\r\n\t},\r\n\tconfigFile: {\r\n\t\talias: 'c',\r\n\t\tdefault: '[[root]]/settings/settings.json',\r\n\t\tdescribe: 'Config JSON file path',\r\n\t\tgroup: GROUPS.GROUP_WORKSPACE,\r\n\t\ttype: 'string',\r\n\t},\r\n\tdetectFormat: {\r\n\t\talias: 'df',\r\n\t\tdefault: false,\r\n\t\tdescribe: 'Whether format of strings variables are included in schema',\r\n\t\tgroup: GROUPS.JSON_SCHEMA_WORKSPACE,\r\n\t\ttype: 'boolean',\r\n\t},\r\n\tenv: {\r\n\t\talias: 'e',\r\n\t\tdescribe: 'Environment to load, i.e. dev, prod',\r\n\t\tgroup: GROUPS.CORE,\r\n\t\ttype: 'string',\r\n\t},\r\n\texpand: {\r\n\t\talias: 'x',\r\n\t\tdefault: false,\r\n\t\tdescribe: 'Interpolate environment variables using themselves',\r\n\t\tgroup: GROUPS.CORE,\r\n\t\ttype: 'boolean',\r\n\t},\r\n\texportIgnoreKeys: {\r\n\t\talias: 'iek',\r\n\t\tdefault: [],\r\n\t\tgroup: GROUPS.JSON_SCHEMA_WORKSPACE,\r\n\t\thidden: true,\r\n\t\ttype: 'array',\r\n\t},\r\n\tlogLevel: {\r\n\t\talias: 'log',\r\n\t\tchoices: ['silly', 'trace', 'debug', 'info', 'warn', 'error'],\r\n\t\tdefault: 'info',\r\n\t\tdescribe: 'Log verbosity level',\r\n\t\tgroup: GROUPS.LOG_WORKSPACE,\r\n\t\ttype: 'string',\r\n\t},\r\n\tlogMaskAnyRegEx: {\r\n\t\talias: 'mrx',\r\n\t\tdefault: [],\r\n\t\tdescribe: 'Mask log values matching these regular expressions',\r\n\t\tgroup: GROUPS.LOG_WORKSPACE,\r\n\t\ttype: 'array',\r\n\t},\r\n\tlogMaskValuesOfKeys: {\r\n\t\talias: 'mvk',\r\n\t\tdefault: [],\r\n\t\tdescribe: 'Mask the values of these keys in logs',\r\n\t\tgroup: GROUPS.LOG_WORKSPACE,\r\n\t\ttype: 'array',\r\n\t},\r\n\tmodes: {\r\n\t\talias: 'm',\r\n\t\tdescribe: 'Execution modes, i.e. debug, test',\r\n\t\tgroup: GROUPS.CORE,\r\n\t\ttype: 'array',\r\n\t},\r\n\tnestingDelimiter: {\r\n\t\talias: 'nd',\r\n\t\tdefault: '__',\r\n\t\tgroup: GROUPS.CORE,\r\n\t\ttype: 'string',\r\n\t\tdescribe:\r\n\t\t\t'Nesting level delimiter for flatten, i.e. { l1: { l2: \"value\" } } turns into { l1__l2: \"value\" }',\r\n\t},\r\n\tnullable: {\r\n\t\talias: 'null',\r\n\t\tdefault: true,\r\n\t\tdescribe: 'Whether variables are nullable',\r\n\t\tgroup: GROUPS.JSON_SCHEMA_WORKSPACE,\r\n\t\ttype: 'boolean',\r\n\t},\r\n\tpackageJson: {\r\n\t\talias: ['pkg'],\r\n\t\tdefault: '',\r\n\t\tdescribe: 'package.json path',\r\n\t\tgroup: GROUPS.GROUP_WORKSPACE,\r\n\t\ttype: 'string',\r\n\t},\r\n\tproviders: {\r\n\t\tdefault: IntegratedProviderConfig,\r\n\t\tdescribe: 'Providers handling variables loading',\r\n\t\thidden: true,\r\n\t\ttype: 'array',\r\n\t},\r\n\tresolve: {\r\n\t\talias: 'r',\r\n\t\tchoices: ['merge', 'override'],\r\n\t\tdefault: 'merge',\r\n\t\tdescribe: 'Whether merges new schema or override',\r\n\t\tgroup: GROUPS.JSON_SCHEMA_WORKSPACE,\r\n\t\ttype: 'string',\r\n\t},\r\n\troot: {\r\n\t\tdefault: 'env',\r\n\t\tdescribe: 'Default environment folder path',\r\n\t\tgroup: GROUPS.GROUP_WORKSPACE,\r\n\t\ttype: 'string',\r\n\t},\r\n\tschemaFile: {\r\n\t\talias: ['s', 'schema'],\r\n\t\tdefault: '[[root]]/settings/schema.json',\r\n\t\tdescribe: 'Environment Schema JSON file path',\r\n\t\tgroup: GROUPS.GROUP_WORKSPACE,\r\n\t\ttype: 'string',\r\n\t},\r\n};\r\n"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;EACd,MAAM;CACP;CACA,WAAW;EACV,SAAS;EACT,UAAU;EACV,QAAQ;EACR,MAAM;CACP;CACA,SAAS;EACR,OAAO;EACP,SAAS,CAAC,SAAS,UAAU;EAC7B,SAAS;EACT,UAAU;EACV,OAAO,EAAO;EACd,MAAM;CACP;CACA,MAAM;EACL,SAAS;EACT,UAAU;EACV,OAAO,EAAO;EACd,MAAM;CACP;CACA,YAAY;EACX,OAAO,CAAC,KAAK,QAAQ;EACrB,SAAS;EACT,UAAU;EACV,OAAO,EAAO;EACd,MAAM;CACP;AACD"}
|
package/commands/env.command.js
CHANGED
|
@@ -10,7 +10,7 @@ import { spawn as u } from "node:child_process";
|
|
|
10
10
|
//#region src/commands/env.command.ts
|
|
11
11
|
var d = {
|
|
12
12
|
command: "$0 [options..] [: <subcmd> :]",
|
|
13
|
-
describe: "Inject environment variables into process",
|
|
13
|
+
describe: "Inject environment variables into a process and run a command",
|
|
14
14
|
builder: (e) => (e.options({
|
|
15
15
|
schemaValidate: {
|
|
16
16
|
alias: "validate",
|
|
@@ -34,7 +34,7 @@ var d = {
|
|
|
34
34
|
let e = await h;
|
|
35
35
|
e(_) || (r.error("schema validation failed", e.errors), process.exit(1));
|
|
36
36
|
}
|
|
37
|
-
_ = a(_, p.nestingDelimiter, p.arrayDescomposition), o && (_ = n(_, _), p.subcmd = n(p.subcmd, _)),
|
|
37
|
+
_ = a(_, p.nestingDelimiter, p.arrayDescomposition), o && (_ = n(_, _), p.subcmd = n(p.subcmd, _)), c.variables(_);
|
|
38
38
|
for (let e in _) process.env[e] = String(_[e]);
|
|
39
39
|
c.summary(Object.keys(_).length, performance.now() - m);
|
|
40
40
|
let v = p.subcmd.join(" ");
|
|
@@ -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 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\
|
|
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 a process and run a command',\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\tui.variables(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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ErB,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"}
|
package/commands/pull.command.js
CHANGED
|
@@ -5,7 +5,7 @@ import n from "picocolors";
|
|
|
5
5
|
//#region src/commands/pull.command.ts
|
|
6
6
|
var r = {
|
|
7
7
|
command: "pull [options..]",
|
|
8
|
-
describe: "
|
|
8
|
+
describe: "Pull environment variables from provider stores",
|
|
9
9
|
builder: (e) => (e.options({ overwrite: {
|
|
10
10
|
alias: "o",
|
|
11
11
|
default: !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.command.js","names":[],"sources":["../../src/commands/pull.command.ts"],"sourcesContent":["import pc from 'picocolors';\
|
|
1
|
+
{"version":3,"file":"pull.command.js","names":[],"sources":["../../src/commands/pull.command.ts"],"sourcesContent":["import pc from 'picocolors';\nimport type { CommandModule } from 'yargs';\nimport type { CommandArguments } from '../arguments.js';\nimport { logger, ui } from '../utils/index.js';\n\nexport interface PullCommandArguments extends CommandArguments {\n\t// whether variables should be overwritten in already exists\n\toverwrite: boolean;\n}\n\n/**\n * Pulls environment variables from providers.\n *\n * @example [>_]: env pull -e dev\n */\nexport const pullCommand: CommandModule<any, PullCommandArguments> = {\n\tcommand: 'pull [options..]',\n\tdescribe: 'Pull environment variables from provider stores',\n\tbuilder: (builder) => {\n\t\tbuilder\n\t\t\t.options({\n\t\t\t\toverwrite: {\n\t\t\t\t\talias: 'o',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tdescribe: 'Overwrite local variables',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t},\n\t\t\t})\n\t\t\t.example('env pull -e dev', 'Download \"dev\" environment secrets')\n\t\t\t.example(\n\t\t\t\t'env pull -e dev -o',\n\t\t\t\t'Download and overwrite (if any exists) \"dev\" environment secrets',\n\t\t\t);\n\n\t\treturn builder;\n\t},\n\thandler: async ({ providers, ...argv }) => {\n\t\tconst pullProviders = providers.filter(\n\t\t\t({ handler: { pull } }) => !!pull,\n\t\t);\n\t\tconst promises = await Promise.all(\n\t\t\tpullProviders.map(({ config, handler: { key, pull } }) => {\n\t\t\t\tlogger.silly(`pulling from ${pc.yellow(key)} provider`);\n\n\t\t\t\treturn pull!(argv, config);\n\t\t\t}),\n\t\t);\n\n\t\tif (promises.length > 0)\n\t\t\tui.action('⬇️', `pulled from ${promises.length} provider(s)`);\n\t\telse logger.warn('no providers for pull variables');\n\t},\n};\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
|
@@ -5,7 +5,7 @@ import n from "picocolors";
|
|
|
5
5
|
//#region src/commands/push.command.ts
|
|
6
6
|
var r = {
|
|
7
7
|
command: "push [options..]",
|
|
8
|
-
describe: "
|
|
8
|
+
describe: "Push environment variables to provider stores",
|
|
9
9
|
builder: (e) => (e.options({ force: {
|
|
10
10
|
alias: "f",
|
|
11
11
|
default: !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.command.js","names":[],"sources":["../../src/commands/push.command.ts"],"sourcesContent":["import pc from 'picocolors';\
|
|
1
|
+
{"version":3,"file":"push.command.js","names":[],"sources":["../../src/commands/push.command.ts"],"sourcesContent":["import pc from 'picocolors';\nimport type { CommandModule } from 'yargs';\nimport type { CommandArguments } from '../arguments.js';\nimport { logger, ui } from '../utils/index.js';\n\nexport interface PushCommandArguments extends CommandArguments {\n\t// forces to push in case of conflict\n\tforce: boolean;\n}\n\n/**\n * Pushes environment variables to providers store.\n *\n * @example [>_]: env push -e dev\n */\nexport const pushCommand: CommandModule<any, PushCommandArguments> = {\n\tcommand: 'push [options..]',\n\tdescribe: 'Push environment variables to provider stores',\n\tbuilder: (builder) => {\n\t\tbuilder\n\t\t\t.options({\n\t\t\t\tforce: {\n\t\t\t\t\talias: 'f',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tdescribe: 'Force push for secrets',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t},\n\t\t\t})\n\t\t\t.example('env push -e dev', 'Download \"dev\" environment secrets');\n\n\t\treturn builder;\n\t},\n\thandler: async ({ providers, ...argv }) => {\n\t\tconst pushProviders = providers.filter(\n\t\t\t({ handler: { push } }) => !!push,\n\t\t);\n\t\tconst promises = await Promise.all(\n\t\t\tpushProviders.map(({ config, handler: { key, push } }) => {\n\t\t\t\tlogger.debug(`pushing to ${pc.yellow(key)} provider`);\n\n\t\t\t\treturn push!(argv, config);\n\t\t\t}),\n\t\t);\n\n\t\tif (promises.length > 0)\n\t\t\tui.action('⬆️', `pushed to ${promises.length} provider(s)`);\n\t\telse logger.warn('no providers for push variables');\n\t},\n};\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"}
|
|
@@ -5,7 +5,7 @@ import "../utils/index.js";
|
|
|
5
5
|
//#region src/commands/schema.command.ts
|
|
6
6
|
var i = {
|
|
7
7
|
command: "schema [options..]",
|
|
8
|
-
describe: "
|
|
8
|
+
describe: "Generate the JSON validation schema from providers",
|
|
9
9
|
builder: (e) => e.example("env schema --generate -e dev -m debug unit", "Updates JSON schema"),
|
|
10
10
|
handler: async (i) => {
|
|
11
11
|
i.ci = !0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.command.js","names":[],"sources":["../../src/commands/schema.command.ts"],"sourcesContent":["import type { CommandModule } from 'yargs';\
|
|
1
|
+
{"version":3,"file":"schema.command.js","names":[],"sources":["../../src/commands/schema.command.ts"],"sourcesContent":["import type { CommandModule } from 'yargs';\nimport type { CommandArguments } from '../arguments.js';\nimport {\n\tgenerateSchemaFrom,\n\tloadVariablesFromProviders,\n\tlogger,\n\tui,\n} from '../utils/index.js';\n\n/**\n * Generates validation schema from providers environment variables.\n *\n * @example [>_]: env schema -e dev -m build\n */\nexport const schemaCommand: CommandModule<any, CommandArguments> = {\n\tcommand: 'schema [options..]',\n\tdescribe: 'Generate the JSON validation schema from providers',\n\tbuilder: (builder) => {\n\t\treturn builder.example(\n\t\t\t'env schema --generate -e dev -m debug unit',\n\t\t\t'Updates JSON schema',\n\t\t);\n\t},\n\thandler: async (argv) => {\n\t\targv.ci = true;\n\n\t\tconst results = await loadVariablesFromProviders(argv.providers, argv);\n\n\t\tconst schema = await generateSchemaFrom(results, argv);\n\n\t\tlogger.silly('schema:', schema);\n\t\tui.action('📐', `schema updated → ${argv.schemaFile}`);\n\t},\n};\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.js
CHANGED
|
@@ -70,16 +70,21 @@ async function S(t) {
|
|
|
70
70
|
C(t, o, i, n, r);
|
|
71
71
|
}
|
|
72
72
|
function C(e, t, a, o, c = "unknown") {
|
|
73
|
-
let l =
|
|
73
|
+
let l = g.dim(`v${c}`), _ = [
|
|
74
|
+
"",
|
|
75
|
+
`${g.bold(g.yellow("⚡ env"))} ${l} ${g.dim("· environment variables made easy")}`,
|
|
76
|
+
"",
|
|
77
|
+
`${g.bold("Usage:")} $0 [command] [options..] ${g.dim(": <subcmd> :")} [options..]`
|
|
78
|
+
].join("\n"), v = [`${g.dim("Run")} ${g.cyan("env <command> --help")} ${g.dim("for command-specific options.")}`, `${g.dim("Use")} ${g.cyan("--log debug")} ${g.dim("to inspect the resolved environment (secrets stay masked).")}`].join("\n"), b = y(e).strict().scriptName("env").version(c).detectLocale(!1).showHelpOnFail(!1).parserConfiguration(o.parser).wrap(Math.min(110, process.stdout.columns ?? 110)).usage(_).epilog(v).options(u).middleware(async (e) => {
|
|
74
79
|
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]}`)));
|
|
75
80
|
let c = e.subcmd;
|
|
76
81
|
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]);
|
|
77
82
|
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));
|
|
78
83
|
});
|
|
79
|
-
|
|
80
|
-
let { providers:
|
|
81
|
-
for (let { handler: e } of
|
|
82
|
-
|
|
84
|
+
b.command(d), b.command(f), b.command(p), b.command(m), b.command(h);
|
|
85
|
+
let { providers: x } = t;
|
|
86
|
+
for (let { handler: e } of x) e?.builder && e.builder(b);
|
|
87
|
+
b.parse();
|
|
83
88
|
}
|
|
84
89
|
//#endregion
|
|
85
90
|
export { S as exec };
|
package/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\tui,\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\tui.header(version, env, modes);\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.par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,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"}
|
|
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\tui,\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\tui.header(version, env, modes);\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 versionTag = pc.dim(`v${version}`);\r\n\tconst banner = [\r\n\t\t'',\r\n\t\t`${pc.bold(pc.yellow('⚡ env'))} ${versionTag} ${pc.dim('· environment variables made easy')}`,\r\n\t\t'',\r\n\t\t`${pc.bold('Usage:')} $0 [command] [options..] ${pc.dim(': <subcmd> :')} [options..]`,\r\n\t].join('\\n');\r\n\tconst epilog = [\r\n\t\t`${pc.dim('Run')} ${pc.cyan('env <command> --help')} ${pc.dim('for command-specific options.')}`,\r\n\t\t`${pc.dim('Use')} ${pc.cyan('--log debug')} ${pc.dim('to inspect the resolved environment (secrets stay masked).')}`,\r\n\t].join('\\n');\r\n\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.wrap(Math.min(110, process.stdout.columns ?? 110))\r\n\t\t.usage(banner)\r\n\t\t.epilog(epilog)\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":";;;;;;;;;;;;;;;;;;;;A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M,EACZ,OAAO,CAAM,EACb,QAAQ,CAAI,EACZ,WAAW,OAAO,MAAwB;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/package.json
CHANGED
package/utils/ui.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare function formatDuration(ms: number): string;
|
|
|
3
3
|
export declare const ui: {
|
|
4
4
|
header(version: string, env?: string, modes?: string[]): void;
|
|
5
5
|
provider(key: string, count: number): void;
|
|
6
|
+
/** Pretty, sorted, masked dump of the resolved environment (debug level). */
|
|
7
|
+
variables(env: Record<string, unknown>): void;
|
|
6
8
|
summary(total: number, ms: number): void;
|
|
7
9
|
running(command: string): void;
|
|
8
10
|
finished(ms: number): void;
|
package/utils/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAqDA,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,eAAO,MAAM,EAAE;oBACE,MAAM,QAAQ,MAAM,UAAU,MAAM,EAAE,GAAG,IAAI;kBAY/C,MAAM,SAAS,MAAM,GAAG,IAAI;IAS1C,6EAA6E;mBAC9D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;mBA2B9B,MAAM,MAAM,MAAM,GAAG,IAAI;qBAQvB,MAAM,GAAG,IAAI;iBAMjB,MAAM,GAAG,IAAI;iBAKb,MAAM,GAAG,IAAI;kBAKZ,MAAM,WAAW,MAAM,GAAG,IAAI;CAG5C,CAAC"}
|
package/utils/ui.js
CHANGED
|
@@ -7,16 +7,32 @@ var r = {
|
|
|
7
7
|
local: "📂",
|
|
8
8
|
"package-json": "📦"
|
|
9
9
|
};
|
|
10
|
-
function i() {
|
|
11
|
-
return (t.settings.minLevel ?? e.info) <=
|
|
10
|
+
function i(n) {
|
|
11
|
+
return (t.settings.minLevel ?? e.info) <= n;
|
|
12
12
|
}
|
|
13
|
-
function a(
|
|
14
|
-
i() && process.stdout.write(`${
|
|
13
|
+
function a(t = "", n = e.info) {
|
|
14
|
+
i(n) && process.stdout.write(`${t}\n`);
|
|
15
15
|
}
|
|
16
|
-
function o(e) {
|
|
16
|
+
function o(e, n) {
|
|
17
|
+
let { maskPlaceholder: r = "***", maskValuesOfKeys: i = [], maskValuesRegEx: a = [] } = t.settings;
|
|
18
|
+
if (i.some((t) => t.toLowerCase() === e.toLowerCase())) return {
|
|
19
|
+
masked: !0,
|
|
20
|
+
value: r
|
|
21
|
+
};
|
|
22
|
+
let o = !1, s = n;
|
|
23
|
+
for (let e of a) {
|
|
24
|
+
let t = s.replaceAll(new RegExp(e.source, "g"), r);
|
|
25
|
+
t !== s && (o = !0), s = t;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
masked: o,
|
|
29
|
+
value: s
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function s(e) {
|
|
17
33
|
return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
18
34
|
}
|
|
19
|
-
var
|
|
35
|
+
var c = {
|
|
20
36
|
header(e, t, r) {
|
|
21
37
|
let i = [n.bold("⚡ env") + n.dim(` v${e}`)];
|
|
22
38
|
t && i.push(`🌎 ${n.bold(n.green(t))}`), r && r.length > 0 && i.push(`🧩 ${n.magenta(r.join("+"))}`), a(), a(i.join(n.dim(" · "))), a();
|
|
@@ -25,15 +41,25 @@ var s = {
|
|
|
25
41
|
let i = r[e] ?? "🧩", o = e === "azure-key-vault" ? "secrets" : "vars";
|
|
26
42
|
a(` ${i} ${n.cyan(e.padEnd(16))} ${n.bold(String(t))} ${n.dim(o)}`);
|
|
27
43
|
},
|
|
44
|
+
variables(t) {
|
|
45
|
+
if (!i(e.debug)) return;
|
|
46
|
+
let r = Object.entries(t).sort(([e], [t]) => e.localeCompare(t)), s = r.reduce((e, [t]) => Math.max(e, t.length), 0);
|
|
47
|
+
a(` ${n.dim(`environment (${r.length} variables)`)}`, e.debug);
|
|
48
|
+
for (let [t, i] of r) {
|
|
49
|
+
let { masked: r, value: c } = o(t, String(i)), l = r ? n.yellow(c) : n.green(c);
|
|
50
|
+
a(` ${n.cyan(t.padEnd(s))} ${n.dim("=")} ${l}`, e.debug);
|
|
51
|
+
}
|
|
52
|
+
a("", e.debug);
|
|
53
|
+
},
|
|
28
54
|
summary(e, t) {
|
|
29
|
-
let r = n.dim(`in ${
|
|
55
|
+
let r = n.dim(`in ${s(t)}`);
|
|
30
56
|
a(), a(` ${n.green("✓")} ${n.bold(String(e))} variables loaded ${r}`);
|
|
31
57
|
},
|
|
32
58
|
running(e) {
|
|
33
59
|
a(), a(` ${n.yellow("▶")} ${n.bold(e)}`), a();
|
|
34
60
|
},
|
|
35
61
|
finished(e) {
|
|
36
|
-
let t = n.dim(`finished in ${
|
|
62
|
+
let t = n.dim(`finished in ${s(e)}`);
|
|
37
63
|
a(` ${n.green("✓")} ${t}`);
|
|
38
64
|
},
|
|
39
65
|
failed(e) {
|
|
@@ -44,6 +70,6 @@ var s = {
|
|
|
44
70
|
}
|
|
45
71
|
};
|
|
46
72
|
//#endregion
|
|
47
|
-
export {
|
|
73
|
+
export { s as formatDuration, c as ui };
|
|
48
74
|
|
|
49
75
|
//# sourceMappingURL=ui.js.map
|
package/utils/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","names":[],"sources":["../../src/utils/ui.ts"],"sourcesContent":["import pc from 'picocolors';\nimport { LOG_LEVELS, logger } from './logger.js';\n\n// emoji per known integrated provider key\nconst PROVIDER_ICONS: Record<string, string> = {\n\t'app-settings': '🗂️',\n\t'azure-key-vault': '🔐',\n\tlocal: '📂',\n\t'package-json': '📦',\n};\n\n/** Whether
|
|
1
|
+
{"version":3,"file":"ui.js","names":[],"sources":["../../src/utils/ui.ts"],"sourcesContent":["import pc from 'picocolors';\nimport { LOG_LEVELS, logger } from './logger.js';\n\n// emoji per known integrated provider key\nconst PROVIDER_ICONS: Record<string, string> = {\n\t'app-settings': '🗂️',\n\t'azure-key-vault': '🔐',\n\tlocal: '📂',\n\t'package-json': '📦',\n};\n\n/** Whether output is visible at the given verbosity (lower = more verbose). */\nfunction visibleAt(level: number): boolean {\n\treturn (logger.settings.minLevel ?? LOG_LEVELS.info) <= level;\n}\n\nfunction line(text = '', level = LOG_LEVELS.info): void {\n\tif (visibleAt(level)) process.stdout.write(`${text}\\n`);\n}\n\n/**\n * Masks a value the same way the logger does, reusing its mask settings, so the\n * pretty variables view never leaks secrets.\n */\nfunction maskValue(\n\tkey: string,\n\tvalue: string,\n): { masked: boolean; value: string } {\n\tconst {\n\t\tmaskPlaceholder = '***',\n\t\tmaskValuesOfKeys = [],\n\t\tmaskValuesRegEx = [],\n\t} = logger.settings;\n\n\tif (maskValuesOfKeys.some((k) => k.toLowerCase() === key.toLowerCase()))\n\t\treturn { masked: true, value: maskPlaceholder };\n\n\tlet masked = false;\n\tlet out = value;\n\n\tfor (const regex of maskValuesRegEx) {\n\t\tconst next = out.replaceAll(\n\t\t\tnew RegExp(regex.source, 'g'),\n\t\t\tmaskPlaceholder,\n\t\t);\n\n\t\tif (next !== out) masked = true;\n\t\tout = next;\n\t}\n\n\treturn { masked, value: out };\n}\n\n/** Formats a duration in ms as \"142ms\" or \"1.4s\". */\nexport function formatDuration(ms: number): string {\n\treturn ms < 1000 ? `${Math.round(ms)}ms` : `${(ms / 1000).toFixed(1)}s`;\n}\n\nexport const ui = {\n\theader(version: string, env?: string, modes?: string[]): void {\n\t\tconst parts = [pc.bold('⚡ env') + pc.dim(` v${version}`)];\n\n\t\tif (env) parts.push(`🌎 ${pc.bold(pc.green(env))}`);\n\t\tif (modes && modes.length > 0)\n\t\t\tparts.push(`🧩 ${pc.magenta(modes.join('+'))}`);\n\n\t\tline();\n\t\tline(parts.join(pc.dim(' · ')));\n\t\tline();\n\t},\n\n\tprovider(key: string, count: number): void {\n\t\tconst icon = PROVIDER_ICONS[key] ?? '🧩';\n\t\tconst noun = key === 'azure-key-vault' ? 'secrets' : 'vars';\n\n\t\tline(\n\t\t\t` ${icon} ${pc.cyan(key.padEnd(16))} ${pc.bold(String(count))} ${pc.dim(noun)}`,\n\t\t);\n\t},\n\n\t/** Pretty, sorted, masked dump of the resolved environment (debug level). */\n\tvariables(env: Record<string, unknown>): void {\n\t\tif (!visibleAt(LOG_LEVELS.debug)) return;\n\n\t\tconst entries = Object.entries(env).sort(([a], [b]) =>\n\t\t\ta.localeCompare(b),\n\t\t);\n\t\tconst width = entries.reduce(\n\t\t\t(max, [key]) => Math.max(max, key.length),\n\t\t\t0,\n\t\t);\n\t\tconst heading = pc.dim(`environment (${entries.length} variables)`);\n\n\t\tline(` ${heading}`, LOG_LEVELS.debug);\n\n\t\tfor (const [key, value] of entries) {\n\t\t\tconst { masked, value: shown } = maskValue(key, String(value));\n\t\t\tconst colored = masked ? pc.yellow(shown) : pc.green(shown);\n\n\t\t\tline(\n\t\t\t\t` ${pc.cyan(key.padEnd(width))} ${pc.dim('=')} ${colored}`,\n\t\t\t\tLOG_LEVELS.debug,\n\t\t\t);\n\t\t}\n\n\t\tline('', LOG_LEVELS.debug);\n\t},\n\n\tsummary(total: number, ms: number): void {\n\t\tconst duration = pc.dim(`in ${formatDuration(ms)}`);\n\t\tline();\n\t\tline(\n\t\t\t` ${pc.green('✓')} ${pc.bold(String(total))} variables loaded ${duration}`,\n\t\t);\n\t},\n\n\trunning(command: string): void {\n\t\tline();\n\t\tline(` ${pc.yellow('▶')} ${pc.bold(command)}`);\n\t\tline();\n\t},\n\n\tfinished(ms: number): void {\n\t\tconst duration = pc.dim(`finished in ${formatDuration(ms)}`);\n\t\tline(` ${pc.green('✓')} ${duration}`);\n\t},\n\n\tfailed(code: number): void {\n\t\tconst msg = pc.red(`✗ exited with code ${code}`);\n\t\tline(` ${msg}`);\n\t},\n\n\taction(emoji: string, message: string): void {\n\t\tline(` ${emoji} ${message}`);\n\t},\n};\n"],"mappings":";;;AAIA,IAAM,IAAyC;CAC9C,gBAAgB;CAChB,mBAAmB;CACnB,OAAO;CACP,gBAAgB;AACjB;AAGA,SAAS,EAAU,GAAwB;CAC1C,QAAQ,EAAO,SAAS,YAAY,EAAW,SAAS;AACzD;AAEA,SAAS,EAAK,IAAO,IAAI,IAAQ,EAAW,MAAY;CACvD,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