@contentstack/cli-utilities 1.5.11 → 1.6.0
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/auth-handler.js +1 -1
- package/lib/helpers.d.ts +3 -0
- package/lib/helpers.js +26 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/path-validator.d.ts +1 -0
- package/lib/path-validator.js +9 -0
- package/package.json +5 -5
package/lib/auth-handler.js
CHANGED
|
@@ -21,7 +21,7 @@ class AuthHandler {
|
|
|
21
21
|
}
|
|
22
22
|
constructor() {
|
|
23
23
|
this.checkExpiryAndRefresh = (force = false) => this.compareOAuthExpiry(force);
|
|
24
|
-
this.codeVerifier = crypto.
|
|
24
|
+
this.codeVerifier = crypto.randomBytes(32).toString('hex');
|
|
25
25
|
this.OAuthAppId = process.env.OAUTH_APP_ID || '6400aa06db64de001a31c8a9';
|
|
26
26
|
this.OAuthClientId = process.env.OAUTH_CLIENT_ID || 'Ie0FEfTzlfAHL4xM';
|
|
27
27
|
this.OAuthRedirectURL = process.env.OAUTH_APP_REDIRECT_URL || 'http://localhost:8184';
|
package/lib/helpers.d.ts
CHANGED
|
@@ -10,3 +10,6 @@ export declare const isManagementTokenValid: (stackAPIKey: any, managementToken:
|
|
|
10
10
|
valid: string;
|
|
11
11
|
message: string;
|
|
12
12
|
}>;
|
|
13
|
+
export declare const createDeveloperHubUrl: (developerHubBaseUrl: string) => string;
|
|
14
|
+
export declare const validatePath: (input: string) => boolean;
|
|
15
|
+
export declare const escapeRegExp: (str: string) => string;
|
package/lib/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isManagementTokenValid = exports.doesBranchExist = exports.isAuthenticated = void 0;
|
|
3
|
+
exports.escapeRegExp = exports.validatePath = exports.createDeveloperHubUrl = exports.isManagementTokenValid = exports.doesBranchExist = exports.isAuthenticated = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const auth_handler_1 = tslib_1.__importDefault(require("./auth-handler"));
|
|
6
6
|
const _1 = require(".");
|
|
@@ -35,3 +35,28 @@ const isManagementTokenValid = async (stackAPIKey, managementToken) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
exports.isManagementTokenValid = isManagementTokenValid;
|
|
38
|
+
const createDeveloperHubUrl = (developerHubBaseUrl) => {
|
|
39
|
+
developerHubBaseUrl = developerHubBaseUrl === null || developerHubBaseUrl === void 0 ? void 0 : developerHubBaseUrl.replace('api', 'developerhub-api');
|
|
40
|
+
developerHubBaseUrl = developerHubBaseUrl.startsWith('dev11')
|
|
41
|
+
? developerHubBaseUrl.replace('dev11', 'dev')
|
|
42
|
+
: developerHubBaseUrl;
|
|
43
|
+
developerHubBaseUrl = developerHubBaseUrl.endsWith('io')
|
|
44
|
+
? developerHubBaseUrl.replace('io', 'com')
|
|
45
|
+
: developerHubBaseUrl;
|
|
46
|
+
return developerHubBaseUrl.startsWith('http') ? developerHubBaseUrl : `https://${developerHubBaseUrl}`;
|
|
47
|
+
};
|
|
48
|
+
exports.createDeveloperHubUrl = createDeveloperHubUrl;
|
|
49
|
+
const validatePath = (input) => {
|
|
50
|
+
const pattern = /[*$%#<>{}!&?]/g;
|
|
51
|
+
if (pattern.test(input)) {
|
|
52
|
+
_1.cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
|
|
53
|
+
color: 'yellow',
|
|
54
|
+
});
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
59
|
+
exports.validatePath = validatePath;
|
|
60
|
+
// To escape special characters in a string
|
|
61
|
+
const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
62
|
+
exports.escapeRegExp = escapeRegExp;
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './helpers';
|
|
|
16
16
|
export * from './interfaces';
|
|
17
17
|
export * from './date-time';
|
|
18
18
|
export * from './add-locale';
|
|
19
|
+
export * from './path-validator';
|
|
19
20
|
export { App, AppData, Installation, marketplaceSDKClient, MarketplaceSDKInitiator, marketplaceSDKInitiator, ContentstackMarketplaceClient, ContentstackMarketplaceConfig, };
|
|
20
21
|
export { Args, CommandHelp, Config, Errors, Flags, loadHelpClass, Help, HelpBase, HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable, Hook, Interfaces, Parser, Plugin, run, toCached, tsPath, toStandardizedId, toConfiguredId, settings, Settings, flush, ux, execute, stderr, stdout, } from '@oclif/core';
|
|
21
22
|
export { FlagInput, ArgInput, FlagDefinition } from '@oclif/core/lib/interfaces/parser';
|
package/lib/index.js
CHANGED
|
@@ -37,6 +37,7 @@ tslib_1.__exportStar(require("./helpers"), exports);
|
|
|
37
37
|
tslib_1.__exportStar(require("./interfaces"), exports);
|
|
38
38
|
tslib_1.__exportStar(require("./date-time"), exports);
|
|
39
39
|
tslib_1.__exportStar(require("./add-locale"), exports);
|
|
40
|
+
tslib_1.__exportStar(require("./path-validator"), exports);
|
|
40
41
|
// NOTE Exporting all @oclif/core modules: So that all the module can be acessed through cli-utility
|
|
41
42
|
var core_1 = require("@oclif/core");
|
|
42
43
|
Object.defineProperty(exports, "Args", { enumerable: true, get: function () { return core_1.Args; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pathValidator: (filePath: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pathValidator = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const pathValidator = (filePath) => {
|
|
6
|
+
return (0, path_1.normalize)((0, path_1.resolve)(process.cwd(), filePath)).replace(/^(\.\.(\/|\\|$))+/, "");
|
|
7
|
+
;
|
|
8
|
+
};
|
|
9
|
+
exports.pathValidator = pathValidator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-utilities",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Utilities for contentstack projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"posttest": "npm run lint",
|
|
15
15
|
"lint": "eslint src/**/*.ts",
|
|
16
16
|
"format": "eslint src/**/*.ts --fix",
|
|
17
|
-
"test:unit": "mocha --forbid-only \"test/unit
|
|
17
|
+
"test:unit": "mocha --forbid-only \"test/unit/**/helper.test.ts\"",
|
|
18
18
|
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"author": "contentstack",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@contentstack/management": "~1.
|
|
35
|
+
"@contentstack/management": "~1.15.3",
|
|
36
36
|
"@contentstack/marketplace-sdk": "^1.0.1",
|
|
37
37
|
"@oclif/core": "^2.9.3",
|
|
38
38
|
"axios": "^1.6.4",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@contentstack/cli-dev-dependencies": "^1.2.4",
|
|
62
|
-
"@oclif/test": "^2.
|
|
62
|
+
"@oclif/test": "^2.5.6",
|
|
63
63
|
"@types/chai": "^4.2.18",
|
|
64
64
|
"@types/inquirer": "^9.0.3",
|
|
65
65
|
"@types/mkdirp": "^1.0.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"nyc": "^15.1.0",
|
|
79
79
|
"rimraf": "^2.7.1",
|
|
80
80
|
"sinon": "^15.0.1",
|
|
81
|
-
"tmp": "^0.2.
|
|
81
|
+
"tmp": "^0.2.2",
|
|
82
82
|
"ts-node": "^10.9.1",
|
|
83
83
|
"tslib": "^1.13.0",
|
|
84
84
|
"typescript": "^4.9.3"
|