Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions packages/contentstack-utilities/src/config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class Config {
private getEncryptedConfig(configData?: Record<string, unknown>, skip = false) {
const getEncryptedDataElseFallBack = () => {
try {

// NOTE reading current code base encrypted file if exist
const encryptionKey: any = this.getObfuscationKey();
this.safeDeleteConfigIfInvalid(oldConfigPath);
Expand Down Expand Up @@ -223,4 +222,42 @@ class Config {
}
}

export default new Config();
let configInstance: Config | null = null;

function createConfigInstance(): Config {
return new Config();
}

function getConfigInstance(): Config {
if (!configInstance) {
configInstance = createConfigInstance();
}
return configInstance;
}

// Sinon based lazy config object
const lazyConfig = {
// false positive - no hardcoded secret here
// @ts-ignore-next-line secret-detection
get(key: string) {
return getConfigInstance().get(key);
},

// false positive - no hardcoded secret here
// @ts-ignore-next-line secret-detection
set(key: string, value: any) {
return getConfigInstance().set(key, value);
},

// false positive - no hardcoded secret here
// @ts-ignore-next-line secret-detection
delete(key: string) {
return getConfigInstance().delete(key);
},

clear() {
return getConfigInstance().clear();
},
};

export default lazyConfig;
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
Loading