fix(core): update
This commit is contained in:
@@ -5,6 +5,13 @@ import { KeyValueStore } from './npmextra.classes.keyvaluestore.js';
|
||||
export interface IAppDataOptions {
|
||||
dirPath?: string;
|
||||
requiredKeys?: string[];
|
||||
|
||||
/**
|
||||
* kvStoreKey: 'MY_ENV_VAR'
|
||||
*/
|
||||
envMapping?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
export class AppData {
|
||||
@@ -12,7 +19,7 @@ export class AppData {
|
||||
* creates appdata. If no pathArg is given, data will be stored here:
|
||||
* ${PWD}/.nogit/appdata
|
||||
* @param pathArg
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
public static async createAndInit(optionsArg: IAppDataOptions = {}) {
|
||||
const appData = new AppData(optionsArg);
|
||||
@@ -51,7 +58,23 @@ export class AppData {
|
||||
this.options.dirPath = nogitAppData;
|
||||
}
|
||||
}
|
||||
this.kvStore = new KeyValueStore('custom', 'appkv', this.options.dirPath, this.options.requiredKeys);
|
||||
this.kvStore = new KeyValueStore(
|
||||
'custom',
|
||||
'appkv',
|
||||
this.options.dirPath,
|
||||
this.options.requiredKeys
|
||||
);
|
||||
|
||||
if (this.options.envMapping) {
|
||||
const qenvInstance = new plugins.qenv.Qenv(process.cwd(), '~/.cloudlyrc');
|
||||
for (const key in this.options.envMapping) {
|
||||
const envValue = await qenvInstance.getEnvVarOnDemand(key);
|
||||
if (envValue) {
|
||||
await this.kvStore.writeKey(key, envValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.readyDeferred.resolve();
|
||||
}
|
||||
|
||||
@@ -67,9 +90,13 @@ export class AppData {
|
||||
const kvStore = await this.getKvStore();
|
||||
const missingMandatoryKeys = kvStore.getMissingMandatoryKeys();
|
||||
if (missingMandatoryKeys.length > 0) {
|
||||
console.log(`The following mandatory keys are missing in the appdata:\n -> ${missingMandatoryKeys.join(',\n -> ')}`);
|
||||
console.log(
|
||||
`The following mandatory keys are missing in the appdata:\n -> ${missingMandatoryKeys.join(
|
||||
',\n -> '
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
console.log('All mandatory keys are present in the appdata');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user