@contentstack/cli 1.3.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/LICENSE +1 -1
- package/README.md +11 -8
- package/bin/dev +4 -15
- package/bin/run +4 -3
- 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 +24 -25
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
|
|
|
18
18
|
$ csdx COMMAND
|
|
19
19
|
running command...
|
|
20
20
|
$ csdx (--version|-v)
|
|
21
|
-
@contentstack/cli/1.
|
|
21
|
+
@contentstack/cli/1.5.0 linux-x64 node-v16.20.0
|
|
22
22
|
$ csdx --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ csdx COMMAND
|
|
@@ -2362,6 +2362,9 @@ Set region for CLI
|
|
|
2362
2362
|
USAGE
|
|
2363
2363
|
$ csdx config:set:region [REGION] [-d <value> -m <value> -n <value>]
|
|
2364
2364
|
|
|
2365
|
+
ARGUMENTS
|
|
2366
|
+
REGION Name for the region
|
|
2367
|
+
|
|
2365
2368
|
FLAGS
|
|
2366
2369
|
-d, --cda=<value> Custom host to set for content delivery API, if this flag is added then cma and name flags are
|
|
2367
2370
|
required
|
|
@@ -2402,7 +2405,7 @@ DESCRIPTION
|
|
|
2402
2405
|
Display help for csdx.
|
|
2403
2406
|
```
|
|
2404
2407
|
|
|
2405
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.
|
|
2408
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.8/src/commands/help.ts)_
|
|
2406
2409
|
|
|
2407
2410
|
## `csdx login`
|
|
2408
2411
|
|
|
@@ -2477,7 +2480,7 @@ EXAMPLES
|
|
|
2477
2480
|
$ csdx plugins
|
|
2478
2481
|
```
|
|
2479
2482
|
|
|
2480
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3
|
|
2483
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.4.3/src/commands/plugins/index.ts)_
|
|
2481
2484
|
|
|
2482
2485
|
## `csdx plugins:install PLUGIN...`
|
|
2483
2486
|
|
|
@@ -2542,7 +2545,7 @@ EXAMPLES
|
|
|
2542
2545
|
$ csdx plugins:inspect myplugin
|
|
2543
2546
|
```
|
|
2544
2547
|
|
|
2545
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3
|
|
2548
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.4.3/src/commands/plugins/inspect.ts)_
|
|
2546
2549
|
|
|
2547
2550
|
## `csdx plugins:install PLUGIN...`
|
|
2548
2551
|
|
|
@@ -2582,7 +2585,7 @@ EXAMPLES
|
|
|
2582
2585
|
$ csdx plugins:install someuser/someplugin
|
|
2583
2586
|
```
|
|
2584
2587
|
|
|
2585
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3
|
|
2588
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.4.3/src/commands/plugins/install.ts)_
|
|
2586
2589
|
|
|
2587
2590
|
## `csdx plugins:link PLUGIN`
|
|
2588
2591
|
|
|
@@ -2611,7 +2614,7 @@ EXAMPLES
|
|
|
2611
2614
|
$ csdx plugins:link myplugin
|
|
2612
2615
|
```
|
|
2613
2616
|
|
|
2614
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3
|
|
2617
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.4.3/src/commands/plugins/link.ts)_
|
|
2615
2618
|
|
|
2616
2619
|
## `csdx plugins:uninstall PLUGIN...`
|
|
2617
2620
|
|
|
@@ -2659,7 +2662,7 @@ ALIASES
|
|
|
2659
2662
|
$ csdx plugins:remove
|
|
2660
2663
|
```
|
|
2661
2664
|
|
|
2662
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3
|
|
2665
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.4.3/src/commands/plugins/uninstall.ts)_
|
|
2663
2666
|
|
|
2664
2667
|
## `csdx plugins:uninstall PLUGIN...`
|
|
2665
2668
|
|
|
@@ -2700,7 +2703,7 @@ DESCRIPTION
|
|
|
2700
2703
|
Update installed plugins.
|
|
2701
2704
|
```
|
|
2702
2705
|
|
|
2703
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3
|
|
2706
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.4.3/src/commands/plugins/update.ts)_
|
|
2704
2707
|
|
|
2705
2708
|
## `csdx tokens`
|
|
2706
2709
|
|
package/bin/dev
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// In dev mode -> use ts-node and dev plugins
|
|
9
|
-
process.env.NODE_ENV = 'development'
|
|
10
|
-
|
|
11
|
-
require('ts-node').register({project})
|
|
12
|
-
|
|
13
|
-
// In dev mode, always show stack traces
|
|
14
|
-
oclif.settings.debug = true;
|
|
15
|
-
|
|
16
|
-
// Start the CLI
|
|
17
|
-
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
|
3
|
+
(async () => {
|
|
4
|
+
const oclif = require('@oclif/core')
|
|
5
|
+
await oclif.execute({type: 'cjs', development: true, dir: __dirname})
|
|
6
|
+
})()
|
package/bin/run
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
oclif.
|
|
3
|
+
(async () => {
|
|
4
|
+
const oclif = require('@oclif/core')
|
|
5
|
+
await oclif.execute({type: 'cjs', dir: __dirname})
|
|
6
|
+
})()
|
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"
|
|
@@ -9,33 +9,33 @@
|
|
|
9
9
|
"main": "lib/index.js",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "npm run clean && npm run compile",
|
|
12
|
-
"clean": "rm -rf ./lib
|
|
12
|
+
"clean": "rm -rf ./lib ./node_modules tsconfig.build.tsbuildinfo",
|
|
13
13
|
"compile": "tsc -b tsconfig.json",
|
|
14
14
|
"postpack": "rm -f oclif.manifest.json",
|
|
15
|
-
"prepack": "npm run build && oclif manifest && oclif readme",
|
|
16
15
|
"version": "oclif readme && git add README.md",
|
|
17
16
|
"test:report": "tsc -p test && nyc --reporter=lcov --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
18
17
|
"pretest": "tsc -p test",
|
|
19
18
|
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
20
19
|
"posttest": "npm run lint",
|
|
21
|
-
"lint": "eslint src/**/*.ts"
|
|
20
|
+
"lint": "eslint src/**/*.ts",
|
|
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.1
|
|
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": "^
|
|
38
|
+
"@oclif/core": "^2.3.0",
|
|
39
39
|
"@oclif/plugin-help": "^5",
|
|
40
40
|
"@oclif/plugin-not-found": "^2.3.9",
|
|
41
41
|
"@oclif/plugin-plugins": "^2.1.7",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"figlet": "^1.5.2",
|
|
45
45
|
"inquirer": "8.2.4",
|
|
46
46
|
"uuid": "^9.0.0",
|
|
47
|
-
"winston": "^3.7.2"
|
|
47
|
+
"winston": "^3.7.2",
|
|
48
|
+
"node-machine-id": "^1.1.12",
|
|
49
|
+
"short-uuid": "^4.2.2"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"oclif": "^3.1.2",
|
|
51
|
-
"@oclif/dev-cli": "^1.26.10",
|
|
52
52
|
"@oclif/test": "^2.2.10",
|
|
53
53
|
"@types/chai": "^4.2.18",
|
|
54
54
|
"@types/inquirer": "^9.0.3",
|
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"@types/mocha": "^8.2.2",
|
|
57
57
|
"@types/node": "^14.14.32",
|
|
58
58
|
"@types/sinon": "^10.0.2",
|
|
59
|
-
"@types/tar": "^4.0.3",
|
|
60
59
|
"chai": "^4.3.4",
|
|
61
60
|
"eslint": "^8.18.0",
|
|
62
|
-
"eslint-config-oclif": "^
|
|
61
|
+
"eslint-config-oclif": "^4.0.0",
|
|
63
62
|
"eslint-config-oclif-typescript": "^0.1.0",
|
|
64
63
|
"globby": "^10.0.2",
|
|
65
64
|
"mocha": "^10.0.0",
|
|
66
65
|
"nock": "^13.1.0",
|
|
67
66
|
"nyc": "^15.1.0",
|
|
67
|
+
"oclif": "^3.1.2",
|
|
68
68
|
"rimraf": "^2.7.1",
|
|
69
69
|
"shelljs": "^0.8.4",
|
|
70
70
|
"sinon": "^15.0.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"typescript": "^4.9.3"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
|
-
"node": ">=
|
|
76
|
+
"node": ">=14.0.0"
|
|
77
77
|
},
|
|
78
78
|
"files": [
|
|
79
79
|
"/bin",
|
|
@@ -139,7 +139,6 @@
|
|
|
139
139
|
],
|
|
140
140
|
"hooks": {
|
|
141
141
|
"prerun": [
|
|
142
|
-
"./lib/hooks/prerun/auth-guard",
|
|
143
142
|
"./lib/hooks/prerun/command-deprecation-check"
|
|
144
143
|
],
|
|
145
144
|
"init": [
|