Compare commits

...

6 Commits

Author SHA1 Message Date
7655318629 6.0.5 2024-02-09 15:42:01 +01:00
754ffa6cac fix(core): update 2024-02-09 15:42:00 +01:00
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
7 changed files with 2211 additions and 1127 deletions

View File

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

View File

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

3260
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,6 +1,6 @@
import * as plugins from './qenv.plugins.js';
export class ConfigVaultAdapter {
export class CloudlyAdapter {
public configVaultUrl: string;
constructor(configVaultUrl?: string) {
@ -19,9 +19,9 @@ export class ConfigVaultAdapter {
const parsedUrl = new URL(this.configVaultUrl);
const tr =
new plugins.typedrequest.TypedRequest<plugins.configvaultInterfaces.requests.IReq_GetConfigBundle>(
new plugins.typedrequest.TypedRequest<plugins.configvaultInterfaces.requests.IReq_GetEnvBundle>(
`${parsedUrl.host}/typedrequest`,
'getConfigBundle'
'getEnvBundle'
);
const response = await tr.fire({
authorization: parsedUrl.pathname.replace('/', ''),

View File

@ -1,6 +1,8 @@
import { ConfigVaultAdapter } from './qenv.classes.configvaultadapter.js';
import { CloudlyAdapter } from './qenv.classes.configvaultadapter.js';
import * as plugins from './qenv.plugins.js';
export type TEnvVarRef = string | (() => Promise<string>);
export class Qenv {
public requiredEnvVars: string[] = [];
public availableEnvVars: string[] = [];
@ -8,17 +10,17 @@ export class Qenv {
public keyValueObject: { [key: string]: any } = {};
public logger = new plugins.smartlog.ConsoleLog();
public configVaultAdapter: ConfigVaultAdapter;
public cloudlyAdapter: CloudlyAdapter;
public qenvFilePathAbsolute: string;
public envFilePathAbsolute: string;
constructor(
qenvFileBasePathArg: string = process.cwd(),
envFileBasePathArg: string,
envFileBasePathArg?: string,
failOnMissing: boolean = true
) {
this.configVaultAdapter = new ConfigVaultAdapter();
this.cloudlyAdapter = new CloudlyAdapter();
this.initializeFilePaths(qenvFileBasePathArg, envFileBasePathArg);
this.loadRequiredEnvVars();
this.loadAvailableEnvVars();
@ -30,10 +32,12 @@ export class Qenv {
plugins.path.resolve(qenvFileBasePathArg),
'qenv.yml'
);
this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
'env.json'
);
if (envFileBasePathArg) {
this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
'env.json'
);
}
}
private loadRequiredEnvVars() {
@ -75,7 +79,7 @@ export class Qenv {
}
public async getEnvVarOnDemand(
envVarNameOrNames: string | string[]
envVarNameOrNames: TEnvVarRef | TEnvVarRef[]
): Promise<string | undefined> {
if (Array.isArray(envVarNameOrNames)) {
for (const envVarName of envVarNameOrNames) {
@ -115,12 +119,16 @@ export class Qenv {
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 (
this.getFromEnvironmentVariable(envVarName) ||
this.getFromEnvJsonFile(envVarName) ||
this.getFromDockerSecret(envVarName) ||
this.getFromDockerSecretJson(envVarName)
this.getFromEnvironmentVariable(envVarRefArg) ||
this.getFromEnvJsonFile(envVarRefArg) ||
this.getFromDockerSecret(envVarRefArg) ||
this.getFromDockerSecretJson(envVarRefArg)
);
}
@ -138,6 +146,9 @@ export class Qenv {
}
private getFromEnvJsonFile(envVarName: string): string | undefined {
if (!plugins.smartfile.fs.fileExistsSync(this.envFilePathAbsolute)) {
return undefined;
}
try {
const envJson = plugins.smartfile.fs.toObjectSync(this.envFilePathAbsolute);
const value = envJson[envVarName];

View File

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