@contentstack/cli-utilities 2.0.0-beta.7 → 2.0.0-beta.9
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.
- package/lib/chalk.d.ts +6 -0
- package/lib/chalk.js +10 -4
- package/lib/fs-utility/core.js +0 -1
- package/lib/helpers.d.ts +2 -0
- package/lib/helpers.js +10 -0
- package/lib/http-client/http-response.js +1 -0
- package/lib/logger/cli-error-handler.js +1 -1
- package/package.json +10 -9
package/lib/chalk.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chalk 5 is ESM-only. We load it via dynamic import and cache for use in CommonJS.
|
|
3
|
+
*
|
|
4
|
+
* More than one physical copy of this package can load in one process (e.g. pnpm).
|
|
5
|
+
* Cache on globalThis via Symbol.for so loadChalk() from any copy warms getChalk() for all.
|
|
6
|
+
*/
|
|
1
7
|
export type ChalkInstance = typeof import('chalk').default;
|
|
2
8
|
/**
|
|
3
9
|
* Load chalk (ESM) and cache it. Call this once during CLI init before any chalk usage.
|
package/lib/chalk.js
CHANGED
|
@@ -35,17 +35,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.loadChalk = loadChalk;
|
|
37
37
|
exports.getChalk = getChalk;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const chalkGlobal = Symbol.for('@contentstack/cli-utilities/chalk');
|
|
39
|
+
function readCached() {
|
|
40
|
+
return globalThis[chalkGlobal];
|
|
41
|
+
}
|
|
42
|
+
function writeCached(chalkInstance) {
|
|
43
|
+
globalThis[chalkGlobal] = chalkInstance;
|
|
44
|
+
}
|
|
42
45
|
/**
|
|
43
46
|
* Load chalk (ESM) and cache it. Call this once during CLI init before any chalk usage.
|
|
44
47
|
*/
|
|
45
48
|
async function loadChalk() {
|
|
49
|
+
let chalkInstance = readCached();
|
|
46
50
|
if (!chalkInstance) {
|
|
47
51
|
const chalkModule = await Promise.resolve().then(() => __importStar(require('chalk')));
|
|
48
52
|
chalkInstance = chalkModule.default;
|
|
53
|
+
writeCached(chalkInstance);
|
|
49
54
|
}
|
|
50
55
|
return chalkInstance;
|
|
51
56
|
}
|
|
@@ -53,6 +58,7 @@ async function loadChalk() {
|
|
|
53
58
|
* Get the cached chalk instance. Must call loadChalk() first (e.g. in init hook).
|
|
54
59
|
*/
|
|
55
60
|
function getChalk() {
|
|
61
|
+
const chalkInstance = readCached();
|
|
56
62
|
if (!chalkInstance) {
|
|
57
63
|
throw new Error('Chalk not loaded. Ensure loadChalk() is called during init (e.g. in utils-init hook).');
|
|
58
64
|
}
|
package/lib/fs-utility/core.js
CHANGED
|
@@ -364,7 +364,6 @@ async function getFileList(dirName, onlyName = true) {
|
|
|
364
364
|
const items = (0, node_fs_1.readdirSync)(dirName, { withFileTypes: true });
|
|
365
365
|
for (const item of items) {
|
|
366
366
|
if (item.isDirectory()) {
|
|
367
|
-
/* eslint-disable no-await-in-loop */
|
|
368
367
|
files = [...files, ...(await getFileList(`${dirName}/${item.name}`))];
|
|
369
368
|
}
|
|
370
369
|
else {
|
package/lib/helpers.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare function getAuthenticationMethod(): string;
|
|
|
43
43
|
* @param authenticationMethod - Optional authentication method
|
|
44
44
|
* @returns Context object with all session-level metadata
|
|
45
45
|
*/
|
|
46
|
+
export declare function generateUid(): string;
|
|
47
|
+
export declare function generateShortUid(): string;
|
|
46
48
|
export declare function createLogContext(commandId: string, apiKey: string, authenticationMethod?: string): {
|
|
47
49
|
command: string;
|
|
48
50
|
module: string;
|
package/lib/helpers.js
CHANGED
|
@@ -3,10 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.redactObject = exports.formatError = exports.validateRegex = exports.validateFileName = exports.validateUids = exports.sanitizePath = exports.escapeRegExp = exports.validatePath = exports.createDeveloperHubUrl = exports.isManagementTokenValid = exports.getBranchFromAlias = exports.doesBranchExist = exports.isAuthenticated = void 0;
|
|
4
4
|
exports.clearProgressModuleSetting = clearProgressModuleSetting;
|
|
5
5
|
exports.getAuthenticationMethod = getAuthenticationMethod;
|
|
6
|
+
exports.generateUid = generateUid;
|
|
7
|
+
exports.generateShortUid = generateShortUid;
|
|
6
8
|
exports.createLogContext = createLogContext;
|
|
7
9
|
const tslib_1 = require("tslib");
|
|
8
10
|
const recheck_1 = require("recheck");
|
|
9
11
|
const traverse_1 = tslib_1.__importDefault(require("traverse"));
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
13
|
+
const short_uuid_1 = require("short-uuid");
|
|
10
14
|
const auth_handler_1 = tslib_1.__importDefault(require("./auth-handler"));
|
|
11
15
|
const _1 = require(".");
|
|
12
16
|
const proxy_helper_1 = require("./proxy-helper");
|
|
@@ -280,6 +284,12 @@ function getAuthenticationMethod() {
|
|
|
280
284
|
* @param authenticationMethod - Optional authentication method
|
|
281
285
|
* @returns Context object with all session-level metadata
|
|
282
286
|
*/
|
|
287
|
+
function generateUid() {
|
|
288
|
+
return (0, uuid_1.v4)();
|
|
289
|
+
}
|
|
290
|
+
function generateShortUid() {
|
|
291
|
+
return (0, short_uuid_1.generate)();
|
|
292
|
+
}
|
|
283
293
|
function createLogContext(commandId, apiKey, authenticationMethod) {
|
|
284
294
|
// Store apiKey in configHandler so it's available for session.json
|
|
285
295
|
if (apiKey) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpResponse = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
5
|
class HttpResponse {
|
|
5
6
|
/**
|
|
6
7
|
* Wrap the given Axios `response` into a new response instance.
|
|
@@ -174,7 +174,7 @@ class CLIErrorHandler {
|
|
|
174
174
|
*/
|
|
175
175
|
extractErrorPayload(error) {
|
|
176
176
|
var _a, _b, _c, _d;
|
|
177
|
-
const { name,
|
|
177
|
+
const { name, code, status, response, request, config, statusText } = error;
|
|
178
178
|
const payload = {
|
|
179
179
|
name,
|
|
180
180
|
message: this.extractClearMessage(error),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-utilities",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "Utilities for contentstack projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"author": "contentstack",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@contentstack/management": "~1.30.
|
|
31
|
-
"@contentstack/marketplace-sdk": "^1.5.
|
|
32
|
-
"@oclif/core": "^4.
|
|
33
|
-
"axios": "^1.
|
|
30
|
+
"@contentstack/management": "~1.30.3",
|
|
31
|
+
"@contentstack/marketplace-sdk": "^1.5.2",
|
|
32
|
+
"@oclif/core": "^4.11.4",
|
|
33
|
+
"axios": "^1.16.1",
|
|
34
34
|
"chalk": "^5.6.2",
|
|
35
35
|
"cli-cursor": "^3.1.0",
|
|
36
36
|
"cli-progress": "^3.12.0",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"traverse": "^0.6.11",
|
|
54
54
|
"tty-table": "^4.2.3",
|
|
55
55
|
"unique-string": "^2.0.0",
|
|
56
|
-
"uuid": "^
|
|
56
|
+
"short-uuid": "^6.0.3",
|
|
57
|
+
"uuid": "^14.0.0",
|
|
57
58
|
"winston": "^3.19.0",
|
|
58
59
|
"xdg-basedir": "^4.0.0"
|
|
59
60
|
},
|
|
@@ -71,13 +72,13 @@
|
|
|
71
72
|
"@types/sinon": "^21.0.0",
|
|
72
73
|
"@types/traverse": "^0.6.37",
|
|
73
74
|
"chai": "^4.5.0",
|
|
74
|
-
"eslint": "^
|
|
75
|
-
"eslint-config-oclif": "^6.0.
|
|
75
|
+
"eslint": "^9.26.0",
|
|
76
|
+
"eslint-config-oclif": "^6.0.62",
|
|
76
77
|
"eslint-config-oclif-typescript": "^3.1.14",
|
|
77
|
-
"fancy-test": "^2.0.42",
|
|
78
78
|
"mocha": "10.8.2",
|
|
79
79
|
"nyc": "^15.1.0",
|
|
80
80
|
"sinon": "^21.1.2",
|
|
81
|
+
"fancy-test": "^2.0.42",
|
|
81
82
|
"ts-node": "^10.9.2",
|
|
82
83
|
"typescript": "^5.9.3"
|
|
83
84
|
}
|