@corva/create-app 0.94.0-1 → 0.94.0-rc.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/lib/helpers/cli-version.js +19 -2
- package/package.json +1 -1
|
@@ -4,9 +4,10 @@ import semver from 'semver';
|
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import * as url from 'url';
|
|
7
|
+
import fs from 'fs-extra';
|
|
7
8
|
|
|
8
9
|
import { logger } from './logger.js';
|
|
9
|
-
import
|
|
10
|
+
import { StepError } from '../flows/lib/step-error.js';
|
|
10
11
|
|
|
11
12
|
const npm = new NpmApi();
|
|
12
13
|
|
|
@@ -17,7 +18,23 @@ const asterisks = '*************************************************************
|
|
|
17
18
|
|
|
18
19
|
const getCurrentVersion = async () =>
|
|
19
20
|
(await fs.readJSON(join(url.fileURLToPath(new URL('.', import.meta.url)), '../../package.json'))).version;
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
const getLatestVersion = async () => {
|
|
23
|
+
try {
|
|
24
|
+
return await npm.repo('@corva/create-app').prop('version');
|
|
25
|
+
} catch (caughtError) {
|
|
26
|
+
if (caughtError.name === 'FetchError') {
|
|
27
|
+
throw new StepError(`The request to check the latest available version has failed due to the network error. Details:
|
|
28
|
+
|
|
29
|
+
${caughtError}
|
|
30
|
+
|
|
31
|
+
Please check your internet connection and that the above request is not blocked in your network
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw caughtError;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
21
38
|
|
|
22
39
|
// NOTE: Stop process and show error if version is outdated
|
|
23
40
|
export async function ensureLatestVersion() {
|