@contentstack/cli-utilities 1.14.2 → 1.14.4

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.
@@ -50,12 +50,6 @@ class AuthenticationHandler {
50
50
  }
51
51
  async refreshAccessToken(error, maxRetryCount = 1) {
52
52
  var _a, _b;
53
- // Add configurable delay only for CI/CD pipelines
54
- const delayMs = process.env.DELAY_MS;
55
- if (delayMs) {
56
- const delay = parseInt(delayMs, 10);
57
- await new Promise((resolve) => setTimeout(resolve, delay));
58
- }
59
53
  if (error.response && error.response.status) {
60
54
  switch (error.response.status) {
61
55
  case 401:
@@ -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
  }
@@ -19,6 +19,7 @@ class ManagementSDKInitiator {
19
19
  maxRequests: 10,
20
20
  retryLimit: 3,
21
21
  timeout: 60000,
22
+ delayMs: config.delayMs,
22
23
  httpsAgent: new node_https_1.Agent({
23
24
  maxSockets: 100,
24
25
  maxFreeSockets: 10,
@@ -36,6 +37,7 @@ class ManagementSDKInitiator {
36
37
  case 401:
37
38
  case 429:
38
39
  case 408:
40
+ case 422:
39
41
  return true;
40
42
  default:
41
43
  return false;
@@ -225,6 +225,13 @@ export declare class HttpClient implements IHttpClient {
225
225
  * @returns {Request}
226
226
  */
227
227
  createAndSendRequest(method: HttpMethod, url: string): Promise<AxiosResponse>;
228
+ /**
229
+ * Get the axios instance for interceptor access
230
+ */
231
+ get interceptors(): {
232
+ request: import("axios").AxiosInterceptorManager<import("axios").InternalAxiosRequestConfig<any>>;
233
+ response: import("axios").AxiosInterceptorManager<AxiosResponse<any, any, {}>>;
234
+ };
228
235
  /**
229
236
  * Returns the request payload depending on the selected request payload format.
230
237
  */
@@ -334,6 +334,12 @@ class HttpClient {
334
334
  return await this.axiosInstance(Object.assign(Object.assign({ url,
335
335
  method, withCredentials: true }, this.request), { data: this.prepareRequestPayload() }));
336
336
  }
337
+ /**
338
+ * Get the axios instance for interceptor access
339
+ */
340
+ get interceptors() {
341
+ return this.axiosInstance.interceptors;
342
+ }
337
343
  /**
338
344
  * Returns the request payload depending on the selected request payload format.
339
345
  */
@@ -37,9 +37,9 @@ class Logger {
37
37
  get loggerOptions() {
38
38
  return {
39
39
  filename: '',
40
- maxFiles: 20,
40
+ maxFiles: 50,
41
41
  tailable: true,
42
- maxsize: 1000000,
42
+ maxsize: 5000000, // 5MB
43
43
  };
44
44
  }
45
45
  createLogger(level, filePath) {
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.4",
4
4
  "description": "Utilities for contentstack projects",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  "author": "contentstack",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@contentstack/management": "~1.22.0",
36
- "@contentstack/marketplace-sdk": "^1.2.8",
35
+ "@contentstack/management": "~1.25.1",
36
+ "@contentstack/marketplace-sdk": "^1.4.0",
37
37
  "@oclif/core": "^4.3.0",
38
38
  "axios": "^1.9.0",
39
39
  "chalk": "^4.1.2",