@contentstack/cli 1.31.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
|
@@ -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
|
+
}
|
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.32.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bin": {
|
|
7
7
|
"csdx": "./bin/run.js"
|
|
@@ -30,7 +30,7 @@
|
|
|
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.
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
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.
|
|
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",
|
|
@@ -50,6 +50,7 @@
|
|
|
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"
|
|
@@ -61,6 +62,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",
|