@corva/create-app 0.126.1 → 0.127.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/commands/create.js
CHANGED
|
@@ -358,7 +358,12 @@ function addPackageJSON(root, manifest, runtime, opts) {
|
|
|
358
358
|
},
|
|
359
359
|
scripts,
|
|
360
360
|
dependencies,
|
|
361
|
-
|
|
361
|
+
// the app's scripts run the CLI that generated it, from its own node_modules, so a global
|
|
362
|
+
// install of another version cannot change what `yarn zip` or `yarn release` do
|
|
363
|
+
devDependencies: {
|
|
364
|
+
'@corva/create-app': fs.readJSONSync(join(__dirname, '../../package.json')).version,
|
|
365
|
+
...devDependencies,
|
|
366
|
+
},
|
|
362
367
|
...rest,
|
|
363
368
|
};
|
|
364
369
|
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import { glob } from 'glob';
|
|
3
3
|
import isGlob from 'is-glob';
|
|
4
4
|
import _ from 'lodash/fp.js';
|
|
5
5
|
import { promises as fs } from 'node:fs';
|
|
6
6
|
import { resolve } from 'node:path';
|
|
7
|
-
import { promisify } from 'node:util';
|
|
8
7
|
import { getIncreasedVersion } from '../../helpers/cli-version.js';
|
|
9
8
|
import { generateRandomString } from '../../helpers/utils.js';
|
|
10
9
|
import { loadJson } from '../lib/json.js';
|
|
11
10
|
import { StepError } from '../lib/step-error.js';
|
|
12
11
|
|
|
13
|
-
const glob = promisify(Glob);
|
|
14
|
-
|
|
15
12
|
import debugFn from 'debug';
|
|
16
13
|
|
|
17
14
|
const debug = debugFn('cca:flow:zip:resolve');
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import NpmApi from 'npm-api';
|
|
2
1
|
import chalk from 'chalk';
|
|
3
2
|
import semver from 'semver';
|
|
4
3
|
import inquirer from 'inquirer';
|
|
@@ -9,8 +8,6 @@ import fs from 'fs-extra';
|
|
|
9
8
|
import { logger } from './logger.js';
|
|
10
9
|
import { StepError } from '../flows/lib/step-error.js';
|
|
11
10
|
|
|
12
|
-
const npm = new NpmApi();
|
|
13
|
-
|
|
14
11
|
const error = chalk.bold.red;
|
|
15
12
|
const warning = chalk.hex('#FFA500'); // Orange
|
|
16
13
|
const code = chalk.cyan;
|
|
@@ -19,20 +16,32 @@ const asterisks = '*************************************************************
|
|
|
19
16
|
const getCurrentVersion = async () =>
|
|
20
17
|
(await fs.readJSON(join(url.fileURLToPath(new URL('.', import.meta.url)), '../../package.json'))).version;
|
|
21
18
|
|
|
19
|
+
// An app that lists @corva/create-app owns the version its scripts run, so there is nothing for the
|
|
20
|
+
// user to update globally; the nag belongs to a global install only.
|
|
21
|
+
const isCliPinnedByApp = async (appDirectory) => {
|
|
22
|
+
const packageJsonPath = join(appDirectory, 'package.json');
|
|
23
|
+
|
|
24
|
+
if (!(await fs.pathExists(packageJsonPath))) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { dependencies = {}, devDependencies = {} } = await fs.readJSON(packageJsonPath);
|
|
29
|
+
|
|
30
|
+
return Boolean(dependencies['@corva/create-app'] || devDependencies['@corva/create-app']);
|
|
31
|
+
};
|
|
32
|
+
|
|
22
33
|
const getLatestVersion = async () => {
|
|
23
34
|
try {
|
|
24
|
-
|
|
35
|
+
const response = await fetch('https://registry.npmjs.org/@corva/create-app/latest');
|
|
36
|
+
|
|
37
|
+
return (await response.json()).version;
|
|
25
38
|
} catch (caughtError) {
|
|
26
|
-
|
|
27
|
-
throw new StepError(`The request to check the latest available version has failed due to the network error. Details:
|
|
39
|
+
throw new StepError(`The request to check the latest available version has failed due to the network error. Details:
|
|
28
40
|
|
|
29
41
|
${caughtError}
|
|
30
42
|
|
|
31
43
|
Please check your internet connection and that the above request is not blocked in your network
|
|
32
44
|
`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
throw caughtError;
|
|
36
45
|
}
|
|
37
46
|
};
|
|
38
47
|
|
|
@@ -71,7 +80,11 @@ export async function ensureLatestVersion() {
|
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
// NOTE: Show user-friendly warning if version is outdated
|
|
74
|
-
export async function warnIfOutdated() {
|
|
83
|
+
export async function warnIfOutdated(appDirectory = process.cwd()) {
|
|
84
|
+
if (await isCliPinnedByApp(appDirectory)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
logger.write('Checking for updates...\n');
|
|
76
89
|
|
|
77
90
|
const currentVersion = await getCurrentVersion();
|
package/lib/main.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import chalk from 'chalk';
|
|
2
4
|
import { Command } from 'commander';
|
|
3
5
|
import semver from 'semver';
|
|
@@ -35,10 +37,13 @@ function checkNodeVersion() {
|
|
|
35
37
|
|
|
36
38
|
export async function run() {
|
|
37
39
|
const program = new Command('create-corva-app')
|
|
38
|
-
.hook('preAction', async () => {
|
|
40
|
+
.hook('preAction', async (_, actionCommand) => {
|
|
39
41
|
checkNodeVersion();
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
const [projectDirectory = '.'] = actionCommand.args;
|
|
44
|
+
const { originalCwd = process.cwd() } = actionCommand.opts();
|
|
45
|
+
|
|
46
|
+
await warnIfOutdated(resolve(originalCwd, projectDirectory));
|
|
42
47
|
})
|
|
43
48
|
.addCommand(createCommand, { isDefault: true })
|
|
44
49
|
.addCommand(zipCommand)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corva/create-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.127.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create an app to use it in CORVA.AI",
|
|
6
6
|
"keywords": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"lodash": "4.18.1"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"archiver": "^
|
|
48
|
+
"archiver": "^7.0.1",
|
|
49
49
|
"chalk": "^4.1.0",
|
|
50
50
|
"commander": "^9.1.0",
|
|
51
51
|
"cross-spawn": "^7.0.3",
|
|
@@ -54,12 +54,11 @@
|
|
|
54
54
|
"figlet": "^1.5.0",
|
|
55
55
|
"form-data": "^4.0.4",
|
|
56
56
|
"fs-extra": "^9.0.1",
|
|
57
|
-
"glob": "^
|
|
57
|
+
"glob": "^13.0.6",
|
|
58
58
|
"got": "^12.5.1",
|
|
59
59
|
"inquirer": "^8.2.3",
|
|
60
60
|
"is-glob": "^4.0.3",
|
|
61
61
|
"lodash": "^4.18.1",
|
|
62
|
-
"npm-api": "^1.0.0",
|
|
63
62
|
"semver": "^7.3.2",
|
|
64
63
|
"terminal-link": "^3.0.0"
|
|
65
64
|
},
|