@contentstack/cli 2.0.0-beta → 2.0.0-beta.10

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.
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../../utils");
4
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
5
  /**
5
6
  * Set the cli context
6
7
  */
7
8
  function default_1(opts) {
9
+ // Store command ID for session-based log organization
10
+ if (opts.id) {
11
+ cli_utilities_1.configHandler.set('currentCommandId', opts.id);
12
+ }
8
13
  this.config.context = new utils_1.CsdxContext(opts, this.config);
9
14
  }
10
15
  exports.default = default_1;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_utilities_1 = require("@contentstack/cli-utilities");
4
- const cli_utilities_2 = require("@contentstack/cli-utilities");
5
4
  // TBD: run region command if region is not there
6
5
  async function default_1(opts) {
7
- const newLogger = new cli_utilities_2.LoggerService(process.cwd(), 'cli-log');
8
6
  const { context: { plugin: { config: { protectedCommands = {} } = {} } = {}, region = null } = {} } = this.config;
9
7
  if (opts.Command.id !== 'config:set:region') {
10
8
  if (!region) {
@@ -12,28 +10,28 @@ async function default_1(opts) {
12
10
  this.exit();
13
11
  return;
14
12
  }
15
- cli_utilities_1.cliux.print(`\n Currently using ${region.name} region \n`, { color: 'grey' });
13
+ cli_utilities_1.cliux.print(`Currently using region: ${region.name}`, { color: 'grey' });
16
14
  }
17
15
  // Auth guard
18
16
  if (protectedCommands[opts.Command.id]) {
19
17
  if (!(0, cli_utilities_1.isAuthenticated)()) {
20
- newLogger.error('No auth token found for command', opts.Command.id);
21
- cli_utilities_1.cliux.error('Please login to execute the command');
18
+ (0, cli_utilities_1.handleAndLogError)(new Error('Authentication required for this command'), { module: 'auth-guard', commandId: opts.Command.id });
19
+ cli_utilities_1.cliux.error('Please log in to execute the command');
22
20
  this.exit();
23
21
  }
24
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) {
28
- newLogger.error('error in auth validation');
29
- cli_utilities_1.cliux.error('Please login to execute the command');
26
+ (0, cli_utilities_1.handleAndLogError)(new Error('Error in auth validation'), { module: 'auth-guard' });
27
+ cli_utilities_1.cliux.error('Please log in to execute the command');
30
28
  this.exit();
31
29
  }
32
- newLogger.debug('logged in user', result.data);
30
+ cli_utilities_1.log.debug('Logged-in user', { module: 'auth-guard', userData: result.data });
33
31
  }
34
32
  catch (error) {
35
- newLogger.error('error in auth validation', error);
36
- cli_utilities_1.cliux.error('Please login to execute the command');
33
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'auth-guard' }, 'Error in auth validation');
34
+ cli_utilities_1.cliux.error('Please log in to execute the command');
37
35
  process.exit();
38
36
  }
39
37
  }
@@ -4,14 +4,17 @@ const tslib_1 = require("tslib");
4
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
5
  const semver = tslib_1.__importStar(require("semver"));
6
6
  const versionUpgradeWarningFrequency = {
7
- versionSyncDuration: 3 * 24 * 60 * 60 * 1000,
7
+ versionSyncDuration: 3 * 24 * 60 * 60 * 1000, // 3 days
8
8
  };
9
9
  async function default_1(_opts) {
10
10
  var _a, _b;
11
11
  const now = Date.now();
12
12
  const today = new Date().toISOString().split('T')[0];
13
- const logger = new cli_utilities_1.LoggerService(process.env.CS_CLI_LOG_PATH || process.cwd(), 'cli-log');
14
13
  let cache = { lastChecked: 0, lastWarnedDate: '', latestVersion: '' };
14
+ // if CLI_VERSION is not set or is not the same as the current version, set it
15
+ if (!cli_utilities_1.configHandler.get('CLI_VERSION') || cli_utilities_1.configHandler.get('CLI_VERSION') !== this.config.version) {
16
+ cli_utilities_1.configHandler.set('CLI_VERSION', this.config.version); // set current version in configHandler
17
+ }
15
18
  if (!cli_utilities_1.configHandler.get('versionUpgradeWarningFrequency')) {
16
19
  cli_utilities_1.configHandler.set('versionUpgradeWarningFrequency', versionUpgradeWarningFrequency);
17
20
  }
@@ -26,7 +29,7 @@ async function default_1(_opts) {
26
29
  try {
27
30
  const latestVersion = (_b = (_a = (await httpClient.get(`https://registry.npmjs.org/@contentstack/cli/latest`))) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.version;
28
31
  if (!latestVersion) {
29
- logger.error('Failed to retrieve the latest version from the registry.');
32
+ (0, cli_utilities_1.handleAndLogError)(new Error('Failed to retrieve the latest version from the registry.'), { module: 'latest-version-warning' });
30
33
  return;
31
34
  }
32
35
  cache.latestVersion = latestVersion;
@@ -35,7 +38,7 @@ async function default_1(_opts) {
35
38
  cli_utilities_1.configHandler.set('versionUpgradeWarningCache', cache);
36
39
  }
37
40
  catch (error) {
38
- logger.error('Failed to check the latest version', error);
41
+ (0, cli_utilities_1.handleAndLogError)(error, { module: 'latest-version-warning' }, 'Failed to check the latest version');
39
42
  return;
40
43
  }
41
44
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "commands": {},
3
- "version": "2.0.0-beta"
3
+ "version": "2.0.0-beta.10"
4
4
  }
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": "2.0.0-beta",
4
+ "version": "2.0.0-beta.10",
5
5
  "author": "Contentstack",
6
6
  "bin": {
7
7
  "csdx": "./bin/run.js"
@@ -22,46 +22,46 @@
22
22
  "prepack": "pnpm compile && oclif manifest && oclif readme"
23
23
  },
24
24
  "dependencies": {
25
- "@contentstack/cli-audit": "~1.14.1",
26
- "@contentstack/cli-auth": "~1.6.1",
27
- "@contentstack/cli-cm-bootstrap": "~2.0.0-beta",
28
- "@contentstack/cli-cm-branches": "~1.6.0",
29
- "@contentstack/cli-cm-bulk-publish": "~1.10.0",
30
- "@contentstack/cli-cm-clone": "~2.0.0-beta",
31
- "@contentstack/cli-cm-export": "~2.0.0-beta",
32
- "@contentstack/cli-cm-export-to-csv": "~1.9.1",
33
- "@contentstack/cli-cm-import": "~2.0.0-beta",
34
- "@contentstack/cli-cm-import-setup": "1.6.0",
35
- "@contentstack/cli-cm-migrate-rte": "~1.6.1",
36
- "@contentstack/cli-cm-seed": "~2.0.0-beta",
37
- "@contentstack/cli-command": "~1.6.1",
38
- "@contentstack/cli-config": "~1.15.2",
39
- "@contentstack/cli-launch": "^1.9.2",
40
- "@contentstack/cli-migration": "~1.8.1",
41
- "@contentstack/cli-utilities": "~1.14.3",
42
- "@contentstack/cli-variants": "~2.0.0-beta",
43
- "@contentstack/management": "~1.22.0",
44
- "@oclif/core": "^4.3.0",
45
- "@oclif/plugin-help": "^6.2.28",
46
- "@oclif/plugin-not-found": "^3.2.53",
47
- "@oclif/plugin-plugins": "^5.4.38",
25
+ "@contentstack/cli-audit": "~2.0.0-beta.3",
26
+ "@contentstack/cli-cm-export": "~2.0.0-beta.8",
27
+ "@contentstack/cli-cm-import": "~2.0.0-beta.7",
28
+ "@contentstack/cli-auth": "~2.0.0-beta.4",
29
+ "@contentstack/cli-bulk-operations": "^1.0.0-beta",
30
+ "@contentstack/cli-cm-bootstrap": "~2.0.0-beta.7",
31
+ "@contentstack/cli-cm-branches": "~1.6.3",
32
+ "@contentstack/cli-cm-clone": "~2.0.0-beta.8",
33
+ "@contentstack/cli-cm-export-to-csv": "~1.11.0",
34
+ "@contentstack/cli-cm-import-setup": "~2.0.0-beta.3",
35
+ "@contentstack/cli-cm-seed": "~2.0.0-beta.7",
36
+ "@contentstack/cli-command": "~1.7.2",
37
+ "@contentstack/cli-config": "~2.0.0-beta",
38
+ "@contentstack/cli-launch": "^1.9.6",
39
+ "@contentstack/cli-migration": "~2.0.0-beta.4",
40
+ "@contentstack/cli-utilities": "~1.17.2",
41
+ "@contentstack/cli-variants": "~2.0.0-beta.4",
42
+ "@contentstack/management": "~1.27.5",
43
+ "@contentstack/utils": "~1.7.0",
44
+ "@oclif/core": "^4.8.0",
45
+ "@oclif/plugin-help": "^6.2.37",
46
+ "@oclif/plugin-not-found": "^3.2.74",
47
+ "@oclif/plugin-plugins": "^5.4.56",
48
48
  "chalk": "^4.1.2",
49
49
  "cli-progress": "^3.12.0",
50
- "debug": "^4.4.1",
51
- "figlet": "1.8.1",
52
- "inquirer": "8.2.6",
50
+ "debug": "^4.4.3",
51
+ "figlet": "1.8.2",
52
+ "inquirer": "8.2.7",
53
53
  "node-machine-id": "^1.1.12",
54
54
  "open": "^8.4.2",
55
55
  "ora": "^8.2.0",
56
- "semver": "^7.7.2",
56
+ "semver": "^7.7.4",
57
57
  "short-uuid": "^4.2.2",
58
58
  "uuid": "^9.0.1",
59
59
  "winston": "^3.17.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@oclif/test": "^4.1.13",
62
+ "@oclif/test": "^4.1.16",
63
63
  "@types/chai": "^4.3.20",
64
- "@types/inquirer": "^9.0.8",
64
+ "@types/inquirer": "^9.0.9",
65
65
  "@types/mkdirp": "^1.0.2",
66
66
  "@types/mocha": "^8.2.3",
67
67
  "@types/node": "^14.18.63",
@@ -69,17 +69,17 @@
69
69
  "@types/sinon": "^10.0.20",
70
70
  "chai": "^4.5.0",
71
71
  "eslint": "^8.57.1",
72
- "eslint-config-oclif": "^6.0.62",
72
+ "eslint-config-oclif": "^6.0.137",
73
73
  "eslint-config-oclif-typescript": "^3.1.14",
74
74
  "globby": "^10.0.2",
75
75
  "mocha": "10.8.2",
76
76
  "nock": "^13.5.6",
77
77
  "nyc": "^15.1.0",
78
- "oclif": "^4.17.46",
78
+ "oclif": "^4.22.77",
79
79
  "rimraf": "^5.0.10",
80
80
  "shelljs": "^0.10.0",
81
- "sinon": "^19.0.5",
82
- "tmp": "^0.2.3",
81
+ "sinon": "^21.0.1",
82
+ "tmp": "^0.2.5",
83
83
  "ts-node": "^10.9.2",
84
84
  "tslib": "^2.8.1",
85
85
  "typescript": "^4.9.5"
@@ -148,17 +148,15 @@
148
148
  "@contentstack/cli-cm-bootstrap",
149
149
  "@contentstack/cli-cm-export-to-csv",
150
150
  "@contentstack/cli-cm-clone",
151
- "@contentstack/cli-cm-migrate-rte",
152
151
  "@contentstack/cli-migration",
153
- "@contentstack/cli-cm-bulk-publish",
154
152
  "@contentstack/cli-cm-branches",
155
153
  "@contentstack/cli-audit",
156
154
  "@contentstack/cli-cm-import-setup",
157
- "@contentstack/cli-launch"
155
+ "@contentstack/cli-launch",
156
+ "@contentstack/cli-bulk-operations"
158
157
  ],
159
158
  "hooks": {
160
159
  "prerun": [
161
- "./lib/hooks/prerun/command-deprecation-check",
162
160
  "./lib/hooks/prerun/default-rate-limit-check",
163
161
  "./lib/hooks/prerun/latest-version-warning"
164
162
  ],
@@ -169,4 +167,4 @@
169
167
  }
170
168
  },
171
169
  "repository": "https://github.com/contentstack/cli"
172
- }
170
+ }
@@ -1 +0,0 @@
1
- export default function (_opts: any): Promise<void>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_utilities_1 = require("@contentstack/cli-utilities");
4
- async function default_1(_opts) {
5
- const { context: { plugin: { config: { expiredCommands = {} } = {} } = {}, info: { command = null } = {} } = {} } = this.config;
6
- if (expiredCommands.hasOwnProperty(command)) {
7
- cli_utilities_1.cliux.print(`WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI command. We recommend you to use the latest ${expiredCommands[command]} command.`, { color: 'yellow' });
8
- }
9
- }
10
- exports.default = default_1;