@contentstack/cli 1.30.0 → 1.32.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 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.30.0 linux-x64 node-v18.20.4
21
+ @contentstack/cli/1.32.0 linux-x64 node-v18.20.5
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -3812,7 +3812,7 @@ EXAMPLES
3812
3812
  $ csdx plugins
3813
3813
  ```
3814
3814
 
3815
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/index.ts)_
3815
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/index.ts)_
3816
3816
 
3817
3817
  ## `csdx plugins:add PLUGIN`
3818
3818
 
@@ -3886,7 +3886,7 @@ EXAMPLES
3886
3886
  $ csdx plugins:inspect myplugin
3887
3887
  ```
3888
3888
 
3889
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/inspect.ts)_
3889
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/inspect.ts)_
3890
3890
 
3891
3891
  ## `csdx plugins:install PLUGIN`
3892
3892
 
@@ -3935,7 +3935,7 @@ EXAMPLES
3935
3935
  $ csdx plugins:install someuser/someplugin
3936
3936
  ```
3937
3937
 
3938
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/install.ts)_
3938
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/install.ts)_
3939
3939
 
3940
3940
  ## `csdx plugins:link PATH`
3941
3941
 
@@ -3966,7 +3966,7 @@ EXAMPLES
3966
3966
  $ csdx plugins:link myplugin
3967
3967
  ```
3968
3968
 
3969
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/link.ts)_
3969
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/link.ts)_
3970
3970
 
3971
3971
  ## `csdx plugins:remove [PLUGIN]`
3972
3972
 
@@ -4007,7 +4007,7 @@ FLAGS
4007
4007
  --reinstall Reinstall all plugins after uninstalling.
4008
4008
  ```
4009
4009
 
4010
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/reset.ts)_
4010
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/reset.ts)_
4011
4011
 
4012
4012
  ## `csdx plugins:uninstall [PLUGIN]`
4013
4013
 
@@ -4035,7 +4035,7 @@ EXAMPLES
4035
4035
  $ csdx plugins:uninstall myplugin
4036
4036
  ```
4037
4037
 
4038
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/uninstall.ts)_
4038
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/uninstall.ts)_
4039
4039
 
4040
4040
  ## `csdx plugins:unlink [PLUGIN]`
4041
4041
 
@@ -4079,7 +4079,7 @@ DESCRIPTION
4079
4079
  Update installed plugins.
4080
4080
  ```
4081
4081
 
4082
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/update.ts)_
4082
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/update.ts)_
4083
4083
 
4084
4084
  ## `csdx tokens`
4085
4085
 
@@ -0,0 +1 @@
1
+ export default function (_opts: any): Promise<void>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
5
+ const semver = tslib_1.__importStar(require("semver"));
6
+ const versionUpgradeWarningFrequency = {
7
+ versionSyncDuration: 3 * 24 * 60 * 60 * 1000,
8
+ };
9
+ async function default_1(_opts) {
10
+ var _a, _b;
11
+ const now = Date.now();
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
+ let cache = { lastChecked: 0, lastWarnedDate: '', latestVersion: '' };
15
+ if (!cli_utilities_1.configHandler.get('versionUpgradeWarningFrequency')) {
16
+ cli_utilities_1.configHandler.set('versionUpgradeWarningFrequency', versionUpgradeWarningFrequency);
17
+ }
18
+ const versionUpgradeWarningFrequencyConfig = cli_utilities_1.configHandler.get('versionUpgradeWarningFrequency');
19
+ // Load cache if it exists
20
+ if (cli_utilities_1.configHandler.get('versionUpgradeWarningCache')) {
21
+ cache = cli_utilities_1.configHandler.get('versionUpgradeWarningCache');
22
+ }
23
+ // Perform update check if needed
24
+ const httpClient = new cli_utilities_1.HttpClient();
25
+ if (now - cache.lastChecked > versionUpgradeWarningFrequencyConfig.versionSyncDuration) {
26
+ try {
27
+ 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
+ if (!latestVersion) {
29
+ logger.error('Failed to retrieve the latest version from the registry.');
30
+ return;
31
+ }
32
+ cache.latestVersion = latestVersion;
33
+ cache.lastChecked = now;
34
+ // Save updated cache
35
+ cli_utilities_1.configHandler.set('versionUpgradeWarningCache', cache);
36
+ }
37
+ catch (error) {
38
+ logger.error('Failed to check the latest version', error);
39
+ return;
40
+ }
41
+ }
42
+ // Show warning if an update is available and last warning was yesterday
43
+ if (semver.gt(cache.latestVersion, this.config.version) && cache.lastWarnedDate !== today) {
44
+ cli_utilities_1.cliux.print(`You are using version ${this.config.version}, but the latest version is ${cache.latestVersion}. Please update your CLI for the best experience.`, { color: 'yellow' });
45
+ // Update the last warned timestamp
46
+ cache.lastWarnedDate = today;
47
+ cli_utilities_1.configHandler.set('versionUpgradeWarningCache', cache);
48
+ }
49
+ }
50
+ exports.default = default_1;
@@ -29,3 +29,11 @@ export interface Context {
29
29
  export interface CLIConfig extends Config {
30
30
  context: Context;
31
31
  }
32
+ export interface IVersionUpgradeCache {
33
+ lastChecked: number;
34
+ lastWarnedDate: string;
35
+ latestVersion: string;
36
+ }
37
+ export interface IVersionUpgradeWarningFrequency {
38
+ versionSyncDuration: number;
39
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.30.0",
2
+ "version": "1.32.0",
3
3
  "commands": {}
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": "1.30.0",
4
+ "version": "1.32.0",
5
5
  "author": "Contentstack",
6
6
  "bin": {
7
7
  "csdx": "./bin/run.js"
@@ -30,37 +30,39 @@
30
30
  "@contentstack/cli-cm-export": "~1.14.1",
31
31
  "@contentstack/cli-cm-clone": "~1.13.0",
32
32
  "@contentstack/cli-cm-export-to-csv": "~1.7.3",
33
- "@contentstack/cli-cm-import": "~1.19.2",
33
+ "@contentstack/cli-cm-import": "~1.19.3",
34
34
  "@contentstack/cli-cm-migrate-rte": "~1.4.20",
35
35
  "@contentstack/cli-cm-seed": "~1.10.0",
36
36
  "@contentstack/cli-command": "~1.3.2",
37
- "@contentstack/cli-config": "~1.8.0",
38
- "@contentstack/cli-launch": "~1.2.3",
39
- "@contentstack/cli-migration": "~1.6.3",
37
+ "@contentstack/cli-config": "~1.9.0",
38
+ "@contentstack/cli-launch": "~1.3.0",
39
+ "@contentstack/cli-migration": "~1.6.4",
40
40
  "@contentstack/cli-utilities": "~1.8.0",
41
41
  "@contentstack/management": "~1.18.3",
42
- "@contentstack/cli-variants": "~1.1.2",
42
+ "@contentstack/cli-variants": "~1.1.3",
43
43
  "@oclif/core": "^3.27.0",
44
44
  "@oclif/plugin-help": "^5",
45
45
  "@oclif/plugin-not-found": "^2.4.3",
46
- "@oclif/plugin-plugins": "^5.4.15",
46
+ "@oclif/plugin-plugins": "^5.4.17",
47
47
  "chalk": "^4.1.2",
48
48
  "debug": "^4.3.7",
49
49
  "figlet": "^1.8.0",
50
50
  "inquirer": "8.2.6",
51
51
  "node-machine-id": "^1.1.12",
52
52
  "open": "^8.4.2",
53
+ "semver": "^7.6.3",
53
54
  "short-uuid": "^4.2.2",
54
55
  "uuid": "^9.0.1",
55
56
  "winston": "^3.17.0"
56
57
  },
57
58
  "devDependencies": {
58
- "@oclif/test": "^4.1.0",
59
+ "@oclif/test": "^4.1.2",
59
60
  "@types/chai": "^4.3.20",
60
61
  "@types/inquirer": "^9.0.7",
61
62
  "@types/mkdirp": "^1.0.2",
62
63
  "@types/mocha": "^8.2.3",
63
64
  "@types/node": "^14.18.63",
65
+ "@types/semver": "^7.5.8",
64
66
  "@types/sinon": "^10.0.20",
65
67
  "chai": "^4.5.0",
66
68
  "eslint": "^8.57.1",
@@ -153,7 +155,8 @@
153
155
  "hooks": {
154
156
  "prerun": [
155
157
  "./lib/hooks/prerun/command-deprecation-check",
156
- "./lib/hooks/prerun/default-rate-limit-check"
158
+ "./lib/hooks/prerun/default-rate-limit-check",
159
+ "./lib/hooks/prerun/latest-version-warning"
157
160
  ],
158
161
  "init": [
159
162
  "./lib/hooks/init/context-init",