@contentstack/cli-utilities 1.14.2 → 1.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,30 @@
1
1
  import Conf from 'conf';
2
+ declare class Config {
3
+ private config;
4
+ private inMemoryStore;
5
+ private isPrepackMode;
6
+ constructor();
7
+ init(): Conf<Record<string, unknown>>;
8
+ importOldConfig(): void;
9
+ setOldConfigStoreData(data: any, _path?: string): void;
10
+ isConfigFileValid(configPath: string): boolean;
11
+ safeDeleteConfigIfInvalid(configFilePath: string): void;
12
+ removeOldConfigStoreFile(): void;
13
+ private getOldConfig;
14
+ private fallbackInit;
15
+ private getObfuscationKey;
16
+ private getConfigDataAndUnlinkConfigFile;
17
+ private getEncryptedConfig;
18
+ private getDecryptedConfig;
19
+ get(key: any): string | any;
20
+ set(key: any, value: any): this | Conf<Record<string, unknown>>;
21
+ delete(key: any): this | Conf<Record<string, unknown>>;
22
+ clear(): void;
23
+ }
2
24
  declare const lazyConfig: {
3
25
  get(key: string): any;
4
- set(key: string, value: any): Conf<Record<string, unknown>>;
5
- delete(key: string): Conf<Record<string, unknown>>;
26
+ set(key: string, value: any): Config | Conf<Record<string, unknown>>;
27
+ delete(key: string): Config | Conf<Record<string, unknown>>;
6
28
  clear(): void;
7
29
  };
8
30
  export default lazyConfig;
@@ -22,10 +22,19 @@ const oldConfigPath = path.join(oldConfigDirectory, pathPrefix);
22
22
  const cwd = process.env.CS_CLI_CONFIG_PATH;
23
23
  class Config {
24
24
  constructor() {
25
+ this.inMemoryStore = new Map();
26
+ this.isPrepackMode = process.env.NODE_ENV === 'PREPACK_MODE';
25
27
  this.init();
26
- this.importOldConfig();
28
+ if (!this.isPrepackMode) {
29
+ this.importOldConfig();
30
+ }
27
31
  }
28
32
  init() {
33
+ // Skip file-based config during prepack to prevent race conditions
34
+ if (this.isPrepackMode) {
35
+ // Initialize with empty in-memory store for prepack
36
+ return;
37
+ }
29
38
  return ENCRYPT_CONF === true ? this.getEncryptedConfig() : this.getDecryptedConfig();
30
39
  }
31
40
  importOldConfig() {
@@ -189,20 +198,35 @@ class Config {
189
198
  }
190
199
  get(key) {
191
200
  var _a;
201
+ if (this.isPrepackMode) {
202
+ return this.inMemoryStore.get(key);
203
+ }
192
204
  return (_a = this.config) === null || _a === void 0 ? void 0 : _a.get(key);
193
205
  }
194
206
  set(key, value) {
195
207
  var _a;
208
+ if (this.isPrepackMode) {
209
+ this.inMemoryStore.set(key, value);
210
+ return this;
211
+ }
196
212
  (_a = this.config) === null || _a === void 0 ? void 0 : _a.set(key, value);
197
213
  return this.config;
198
214
  }
199
215
  delete(key) {
200
216
  var _a;
217
+ if (this.isPrepackMode) {
218
+ this.inMemoryStore.delete(key);
219
+ return this;
220
+ }
201
221
  (_a = this.config) === null || _a === void 0 ? void 0 : _a.delete(key);
202
222
  return this.config;
203
223
  }
204
224
  clear() {
205
225
  var _a;
226
+ if (this.isPrepackMode) {
227
+ this.inMemoryStore.clear();
228
+ return;
229
+ }
206
230
  (_a = this.config) === null || _a === void 0 ? void 0 : _a.clear();
207
231
  }
208
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/cli-utilities",
3
- "version": "1.14.2",
3
+ "version": "1.14.3",
4
4
  "description": "Utilities for contentstack projects",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",