Compare commits

..

No commits in common. "master" and "v6.0.7" have entirely different histories.

5 changed files with 3908 additions and 7726 deletions

View File

@ -1,16 +1,5 @@
# Changelog # Changelog
## 2024-11-22 - 6.1.0 - feat(core)
Added new method getEnvVarOnDemandStrict to throw error for unset env vars
- Introduced getEnvVarOnDemandStrict method in Qenv class for strict retrieval of environment variables.
- Upgraded various @git.zone and @push.rocks dependencies for improved functionality and security.
## 2024-11-18 - 6.0.8 - fix(Qenv)
Fix environment file path initialization logic.
- Corrected the logic for setting the environment file paths to prevent overwriting each other.
## 2024-11-18 - 6.0.7 - fix(Qenv) ## 2024-11-18 - 6.0.7 - fix(Qenv)
Fix file path initialization for environment variable files Fix file path initialization for environment variable files

View File

@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/qenv", "name": "@push.rocks/qenv",
"version": "6.1.0", "version": "6.0.7",
"private": false, "private": false,
"description": "A module for easily handling environment variables in Node.js projects with support for .yml and .json configuration.", "description": "A module for easily handling environment variables in Node.js projects with support for .yml and .json configuration.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -31,18 +31,18 @@
}, },
"homepage": "https://code.foss.global/push.rocks/qenv", "homepage": "https://code.foss.global/push.rocks/qenv",
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.2.0", "@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsrun": "^1.3.3", "@git.zone/tsrun": "^1.2.44",
"@git.zone/tstest": "^1.0.90", "@git.zone/tstest": "^1.0.86",
"@push.rocks/tapbundle": "^5.5.0", "@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^22.9.1" "@types/node": "^20.11.17"
}, },
"dependencies": { "dependencies": {
"@api.global/typedrequest": "^3.1.10", "@api.global/typedrequest": "^3.0.4",
"@configvault.io/interfaces": "^1.0.17", "@configvault.io/interfaces": "^1.0.17",
"@push.rocks/smartfile": "^11.0.21", "@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartlog": "^3.0.7", "@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartpath": "^5.0.18" "@push.rocks/smartpath": "^5.0.11"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

11562
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.1.0', version: '6.0.7',
description: 'A module for easily handling environment variables in Node.js projects with support for .yml and .json configuration.' description: 'A module for easily handling environment variables in Node.js projects with support for .yml and .json configuration.'
} }

View File

@ -32,21 +32,25 @@ export class Qenv {
plugins.path.resolve(qenvFileBasePathArg), plugins.path.resolve(qenvFileBasePathArg),
'qenv.yml' 'qenv.yml'
); );
if (envFileBasePathArg) { if (envFileBasePathArg) {
const envFileBasePath = plugins.path.resolve(envFileBasePathArg); const envFileJsonPath = this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
const envFileJsonPath = plugins.path.join(envFileBasePath, 'env.json'); 'env.json'
const envFileYmlPath = plugins.path.join(envFileBasePath, 'env.yml'); );
const envFileYamlPath = plugins.path.join(envFileBasePath, 'env.yaml'); const envFileYmlPath = this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
'env.yml'
);
const envFileYamlPath = this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
'env.yaml'
);
const envFileJsonExists = plugins.smartfile.fs.fileExistsSync(envFileJsonPath); const envFileJsonExists = plugins.smartfile.fs.fileExistsSync(envFileJsonPath);
const envFileYmlExists = plugins.smartfile.fs.fileExistsSync(envFileYmlPath); const envFileYmlExists = plugins.smartfile.fs.fileExistsSync(envFileYmlPath);
const envFileYamlExists = plugins.smartfile.fs.fileExistsSync(envFileYamlPath); const envFileYamlExists = plugins.smartfile.fs.fileExistsSync(envFileYamlPath);
if (envFileJsonExists && (envFileYmlExists || envFileYamlExists)) { if (envFileJsonExists && (envFileYamlExists || envFileYmlExists)) {
this.logger.log('warn', 'Both env.json and env.yml files exist! Using env.json'); this.logger.log('warn', 'Both env.json and env.yml files exist! Using env.json');
this.envFilePathAbsolute = envFileJsonPath;
} else if (envFileJsonExists) { } else if (envFileJsonExists) {
this.envFilePathAbsolute = envFileJsonPath; this.envFilePathAbsolute = envFileJsonPath;
} else if (envFileYmlExists) { } else if (envFileYmlExists) {
@ -111,21 +115,6 @@ export class Qenv {
} }
} }
/**
* Like getEnvVarOnDemand, but throws an error if the env var is not set.
* @param envVarNameOrNames
* @returns
*/
public async getEnvVarOnDemandStrict(
envVarNameOrNames: TEnvVarRef | TEnvVarRef[]
): Promise<string> {
const value = await this.getEnvVarOnDemand(envVarNameOrNames);
if (!value) {
throw new Error(`Env var ${envVarNameOrNames} is not set!`);
}
return value;
}
public getEnvVarOnDemandSync(envVarNameOrNames: string | string[]): string | undefined { public getEnvVarOnDemandSync(envVarNameOrNames: string | string[]): string | undefined {
console.warn('requesting env var sync leaves out potentially important async env sources.'); console.warn('requesting env var sync leaves out potentially important async env sources.');