@contentstack/cli 1.4.0 → 1.5.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/README.md +1 -1
- package/lib/help.js +2 -1
- package/lib/hooks/init/utils-init.js +5 -3
- package/lib/hooks/prerun/auth-guard.js +2 -4
- package/lib/utils/context-handler.js +23 -7
- package/lib/utils/index.js +4 -1
- package/oclif.manifest.json +1 -1
- package/package.json +19 -17
package/README.md
CHANGED
package/lib/help.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const figlet = require("figlet");
|
|
5
|
+
const figlet = tslib_1.__importStar(require("figlet"));
|
|
5
6
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
7
|
class MyHelpClass extends core_1.Help {
|
|
7
8
|
constructor(config, opts) {
|
|
@@ -5,8 +5,10 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
|
5
5
|
* Initialize the utilities
|
|
6
6
|
*/
|
|
7
7
|
function default_1(_opts) {
|
|
8
|
-
|
|
9
|
-
cli_utilities_1.
|
|
10
|
-
cli_utilities_1.
|
|
8
|
+
const { context } = this.config;
|
|
9
|
+
cli_utilities_1.logger.init(context);
|
|
10
|
+
cli_utilities_1.messageHandler.init(context);
|
|
11
|
+
cli_utilities_1.cliux.init(context);
|
|
12
|
+
cli_utilities_1.managementSDKInitiator.init(context);
|
|
11
13
|
}
|
|
12
14
|
exports.default = default_1;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
4
|
-
const ContentstackManagementSDK = require("@contentstack/management");
|
|
5
4
|
// TBD: run region command if region is not there
|
|
6
5
|
async function default_1(opts) {
|
|
7
6
|
const { context: { plugin: { config: { protectedCommands = {} } = {} } = {}, region = null } = {} } = this.config;
|
|
@@ -15,13 +14,12 @@ async function default_1(opts) {
|
|
|
15
14
|
}
|
|
16
15
|
// Auth guard
|
|
17
16
|
if (protectedCommands[opts.Command.id]) {
|
|
18
|
-
|
|
19
|
-
if (!authToken) {
|
|
17
|
+
if (!(0, cli_utilities_1.isAuthenticated)()) {
|
|
20
18
|
cli_utilities_1.logger.error('No auth token found for command', opts.Command.id);
|
|
21
19
|
cli_utilities_1.cliux.error('Please login to execute the command');
|
|
22
20
|
this.exit();
|
|
23
21
|
}
|
|
24
|
-
const client =
|
|
22
|
+
const client = await (0, cli_utilities_1.managementSDKClient)({ host: region.cma });
|
|
25
23
|
try {
|
|
26
24
|
const result = await client.getUser();
|
|
27
25
|
if (!result) {
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const shortUUID = tslib_1.__importStar(require("short-uuid"));
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
5
6
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
7
|
+
const node_machine_id_1 = require("node-machine-id");
|
|
6
8
|
class CsdxContext {
|
|
7
9
|
constructor(cliOpts, cliConfig) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const analyticsInfo = [];
|
|
8
12
|
const command = cliConfig.findCommand(cliOpts.id) || {};
|
|
9
13
|
const config = cli_utilities_1.configHandler;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
const platform = cliConfig.platform && cliConfig.arch ? `${cliConfig.platform}-${cliConfig.arch}` : 'none';
|
|
15
|
+
analyticsInfo.push(platform);
|
|
16
|
+
const nodeVersion = process.versions.node ? `v${process.versions.node}` : process.version;
|
|
17
|
+
analyticsInfo.push(nodeVersion || 'none');
|
|
18
|
+
analyticsInfo.push(cliConfig.version || 'none');
|
|
19
|
+
this.clientId = cli_utilities_1.configHandler.get('clientId');
|
|
20
|
+
if (!this.clientId) {
|
|
21
|
+
this.clientId = (0, node_machine_id_1.machineIdSync)(true);
|
|
22
|
+
cli_utilities_1.configHandler.set('clientId', this.clientId);
|
|
14
23
|
}
|
|
15
|
-
this.
|
|
24
|
+
analyticsInfo.push(this.clientId);
|
|
25
|
+
const sessionId = shortUUID.generate();
|
|
26
|
+
cli_utilities_1.configHandler.set('sessionId', sessionId);
|
|
27
|
+
this.sessionId = sessionId;
|
|
28
|
+
analyticsInfo.push(this.sessionId);
|
|
16
29
|
this.user = {
|
|
17
30
|
authtoken: cli_utilities_1.configHandler.get('authtoken'),
|
|
18
31
|
email: cli_utilities_1.configHandler.get('email'),
|
|
@@ -25,8 +38,11 @@ class CsdxContext {
|
|
|
25
38
|
this.plugin.name = command.pluginName;
|
|
26
39
|
this.plugin.config = Object.assign({}, ((this.plugin.pjson && this.plugin.pjson.csdxConfig) || {}));
|
|
27
40
|
this.messageFilePath = path.resolve(this.plugin.root, this.plugin.config.messageFilePath || './messages/index.json');
|
|
41
|
+
this.info.shortCommandName = (_c = (_b = (_a = this.plugin) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.shortCommandName) === null || _c === void 0 ? void 0 : _c[cliOpts.id];
|
|
42
|
+
analyticsInfo.push(this.info.shortCommandName || cliOpts.id);
|
|
28
43
|
}
|
|
29
44
|
this.flagWarningPrintState = {};
|
|
45
|
+
this.analyticsInfo = analyticsInfo.join(';');
|
|
30
46
|
}
|
|
31
47
|
getToken(alias) {
|
|
32
48
|
if (alias) {
|
package/lib/utils/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.CsdxContext = void 0;
|
|
4
7
|
var context_handler_1 = require("./context-handler");
|
|
5
|
-
Object.defineProperty(exports, "CsdxContext", { enumerable: true, get: function () { return context_handler_1.default; } });
|
|
8
|
+
Object.defineProperty(exports, "CsdxContext", { enumerable: true, get: function () { return __importDefault(context_handler_1).default; } });
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli",
|
|
3
3
|
"description": "Command-line tool (CLI) to interact with Contentstack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bin": {
|
|
7
7
|
"csdx": "./bin/run"
|
|
@@ -21,20 +21,21 @@
|
|
|
21
21
|
"prepack": "pnpm compile && oclif manifest && oclif readme"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@contentstack/cli-auth": "^1.
|
|
25
|
-
"@contentstack/cli-cm-bootstrap": "^1.
|
|
26
|
-
"@contentstack/cli-cm-bulk-publish": "^1.
|
|
27
|
-
"@contentstack/cli-cm-clone": "^1.
|
|
28
|
-
"@contentstack/cli-cm-export": "^1.
|
|
29
|
-
"@contentstack/cli-cm-export-to-csv": "^1.
|
|
30
|
-
"@contentstack/cli-cm-import": "^1.
|
|
31
|
-
"@contentstack/cli-cm-migrate-rte": "^1.
|
|
32
|
-
"@contentstack/cli-cm-seed": "^1.
|
|
33
|
-
"@contentstack/cli-command": "^1.2.
|
|
34
|
-
"@contentstack/cli-config": "^1.
|
|
35
|
-
"@contentstack/cli-migration": "^1.
|
|
36
|
-
"@contentstack/cli-utilities": "^1.
|
|
24
|
+
"@contentstack/cli-auth": "^1.3.0",
|
|
25
|
+
"@contentstack/cli-cm-bootstrap": "^1.4.0",
|
|
26
|
+
"@contentstack/cli-cm-bulk-publish": "^1.3.0",
|
|
27
|
+
"@contentstack/cli-cm-clone": "^1.4.0",
|
|
28
|
+
"@contentstack/cli-cm-export": "^1.5.0",
|
|
29
|
+
"@contentstack/cli-cm-export-to-csv": "^1.3.0",
|
|
30
|
+
"@contentstack/cli-cm-import": "^1.5.0",
|
|
31
|
+
"@contentstack/cli-cm-migrate-rte": "^1.4.0",
|
|
32
|
+
"@contentstack/cli-cm-seed": "^1.4.0",
|
|
33
|
+
"@contentstack/cli-command": "^1.2.1",
|
|
34
|
+
"@contentstack/cli-config": "^1.3.0",
|
|
35
|
+
"@contentstack/cli-migration": "^1.3.0",
|
|
36
|
+
"@contentstack/cli-utilities": "^1.3.0",
|
|
37
37
|
"@contentstack/management": "^1.6.1",
|
|
38
|
+
"@oclif/core": "^2.3.0",
|
|
38
39
|
"@oclif/plugin-help": "^5",
|
|
39
40
|
"@oclif/plugin-not-found": "^2.3.9",
|
|
40
41
|
"@oclif/plugin-plugins": "^2.1.7",
|
|
@@ -43,7 +44,9 @@
|
|
|
43
44
|
"figlet": "^1.5.2",
|
|
44
45
|
"inquirer": "8.2.4",
|
|
45
46
|
"uuid": "^9.0.0",
|
|
46
|
-
"winston": "^3.7.2"
|
|
47
|
+
"winston": "^3.7.2",
|
|
48
|
+
"node-machine-id": "^1.1.12",
|
|
49
|
+
"short-uuid": "^4.2.2"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
52
|
"@oclif/test": "^2.2.10",
|
|
@@ -136,7 +139,6 @@
|
|
|
136
139
|
],
|
|
137
140
|
"hooks": {
|
|
138
141
|
"prerun": [
|
|
139
|
-
"./lib/hooks/prerun/auth-guard",
|
|
140
142
|
"./lib/hooks/prerun/command-deprecation-check"
|
|
141
143
|
],
|
|
142
144
|
"init": [
|
|
@@ -146,4 +148,4 @@
|
|
|
146
148
|
}
|
|
147
149
|
},
|
|
148
150
|
"repository": "https://github.com/contentstack/cli"
|
|
149
|
-
}
|
|
151
|
+
}
|