Compare commits

...

6 Commits

Author SHA1 Message Date
b644ca0c1a 6.0.4 2023-10-20 18:18:48 +02:00
9f638d687b fix(core): update 2023-10-20 18:18:47 +02:00
a9bdfe9373 6.0.3 2023-10-20 17:21:52 +02:00
2017d51f11 fix(core): update 2023-10-20 17:21:51 +02:00
765011ad2a 6.0.2 2023-08-09 17:47:21 +02:00
d807cc6de2 fix(core): update 2023-08-09 17:47:20 +02:00
8 changed files with 1819 additions and 1046 deletions

View File

@ -119,6 +119,6 @@ jobs:
run: | run: |
npmci node install stable npmci node install stable
npmci npm install npmci npm install
pnpm install -g @gitzone/tsdoc pnpm install -g @git.zone/tsdoc
npmci command tsdoc npmci command tsdoc
continue-on-error: true continue-on-error: true

View File

@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/qenv", "name": "@push.rocks/qenv",
"version": "6.0.1", "version": "6.0.4",
"private": false, "private": false,
"description": "easy promised environments", "description": "easy promised environments",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -27,15 +27,16 @@
}, },
"homepage": "https://gitlab.com/pushrocks/qenv#README", "homepage": "https://gitlab.com/pushrocks/qenv#README",
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.66", "@git.zone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44", "@git.zone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77", "@git.zone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.12", "@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.4.6" "@types/node": "^20.8.7"
}, },
"dependencies": { "dependencies": {
"@configvault.io/interfaces": "^1.0.2", "@api.global/typedrequest": "^3.0.2",
"@push.rocks/smartfile": "^10.0.28", "@configvault.io/interfaces": "^1.0.13",
"@push.rocks/smartfile": "^10.0.33",
"@push.rocks/smartlog": "^3.0.3", "@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartpath": "^5.0.11" "@push.rocks/smartpath": "^5.0.11"
}, },

2769
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/qenv', name: '@push.rocks/qenv',
version: '6.0.1', version: '6.0.4',
description: 'easy promised environments' description: 'easy promised environments'
} }

View File

@ -0,0 +1,30 @@
import * as plugins from './qenv.plugins.js';
export class ConfigVaultAdapter {
public configVaultUrl: string;
constructor(configVaultUrl?: string) {
this.configVaultUrl = configVaultUrl;
}
public async getConfigBundle(): Promise<plugins.configvaultInterfaces.data.IConfigBundle> {
if (this.configVaultUrl) {
console.log(`ConfigVault specified through constructor`)
} else if (process.env['CONFIGVAULT_URL']) {
this.configVaultUrl = process.env['CONFIGVAULT_URL'];
} else {
return null;
}
const parsedUrl = new URL(this.configVaultUrl);
const tr =
new plugins.typedrequest.TypedRequest<plugins.configvaultInterfaces.requests.IReq_GetEnvBundle>(
`${parsedUrl.host}/typedrequest`,
'getEnvBundle'
);
const response = await tr.fire({
authorization: parsedUrl.pathname.replace('/', ''),
})
}
}

View File

@ -1,5 +1,8 @@
import { ConfigVaultAdapter } from './qenv.classes.configvaultadapter.js';
import * as plugins from './qenv.plugins.js'; import * as plugins from './qenv.plugins.js';
export type TEnvVarRef = string | (() => Promise<string>);
export class Qenv { export class Qenv {
public requiredEnvVars: string[] = []; public requiredEnvVars: string[] = [];
public availableEnvVars: string[] = []; public availableEnvVars: string[] = [];
@ -7,6 +10,8 @@ export class Qenv {
public keyValueObject: { [key: string]: any } = {}; public keyValueObject: { [key: string]: any } = {};
public logger = new plugins.smartlog.ConsoleLog(); public logger = new plugins.smartlog.ConsoleLog();
public configVaultAdapter: ConfigVaultAdapter;
public qenvFilePathAbsolute: string; public qenvFilePathAbsolute: string;
public envFilePathAbsolute: string; public envFilePathAbsolute: string;
@ -15,6 +20,7 @@ export class Qenv {
envFileBasePathArg: string, envFileBasePathArg: string,
failOnMissing: boolean = true failOnMissing: boolean = true
) { ) {
this.configVaultAdapter = new ConfigVaultAdapter();
this.initializeFilePaths(qenvFileBasePathArg, envFileBasePathArg); this.initializeFilePaths(qenvFileBasePathArg, envFileBasePathArg);
this.loadRequiredEnvVars(); this.loadRequiredEnvVars();
this.loadAvailableEnvVars(); this.loadAvailableEnvVars();
@ -71,7 +77,7 @@ export class Qenv {
} }
public async getEnvVarOnDemand( public async getEnvVarOnDemand(
envVarNameOrNames: string | string[] envVarNameOrNames: TEnvVarRef | TEnvVarRef[]
): Promise<string | undefined> { ): Promise<string | undefined> {
if (Array.isArray(envVarNameOrNames)) { if (Array.isArray(envVarNameOrNames)) {
for (const envVarName of envVarNameOrNames) { for (const envVarName of envVarNameOrNames) {
@ -111,12 +117,16 @@ export class Qenv {
return rawValue; return rawValue;
} }
private async tryGetEnvVar(envVarName: string): Promise<string | undefined> { private async tryGetEnvVar(envVarRefArg: TEnvVarRef): Promise<string | undefined> {
if (typeof envVarRefArg === 'function') {
return await envVarRefArg();
}
return ( return (
this.getFromEnvironmentVariable(envVarName) || this.getFromEnvironmentVariable(envVarRefArg) ||
this.getFromEnvJsonFile(envVarName) || this.getFromEnvJsonFile(envVarRefArg) ||
this.getFromDockerSecret(envVarName) || this.getFromDockerSecret(envVarRefArg) ||
this.getFromDockerSecretJson(envVarName) this.getFromDockerSecretJson(envVarRefArg)
); );
} }

View File

@ -3,8 +3,20 @@ import * as path from 'path';
export { path }; export { path };
// @api.global scope
import * as typedrequest from '@api.global/typedrequest';
export {
typedrequest,
}
// @pushrocks scope // @pushrocks scope
import * as smartfile from '@push.rocks/smartfile'; import * as smartfile from '@push.rocks/smartfile';
import * as smartlog from '@push.rocks/smartlog'; import * as smartlog from '@push.rocks/smartlog';
export { smartfile, smartlog }; export { smartfile, smartlog };
// @configvault.io scope
import * as configvaultInterfaces from '@configvault.io/interfaces';
export { configvaultInterfaces };

View File

@ -3,9 +3,12 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": false, "useDefineForClassFields": false,
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "NodeNext",
"moduleResolution": "nodenext", "moduleResolution": "NodeNext",
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true, "verbatimModuleSyntax": true
} },
"exclude": [
"dist_*/**/*.d.ts"
]
} }