@corva/create-app 0.39.0-0 → 0.39.0-0-test-commit-a2b3fe7
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.
|
@@ -8,7 +8,7 @@ const RELEASE = {
|
|
|
8
8
|
createZipError: 'Could not create zip archive.',
|
|
9
9
|
createZipSuccess: `Zip archive has been created ${SUCCESS_ICON}`,
|
|
10
10
|
getAuthToken: 'Reading auth token...',
|
|
11
|
-
getAuthTokenError: `Could not find auth token.
|
|
11
|
+
getAuthTokenError: `Could not find auth token or CORVA_API_KEY in .env file.\nFor UI app please run ${chalk.cyan`yarn start`} and login to Corva to fetch it or set CORVA_API_KEY in your .env file`,
|
|
12
12
|
getAppKey: 'Reading app key...',
|
|
13
13
|
getAppKeyError: "Could not find app key. Please make sure it's defined in manifest.json",
|
|
14
14
|
uploadApp: 'Uploading app...',
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
const { RELEASE } = require('../../constants/messages');
|
|
2
2
|
const { promises: fs } = require('fs');
|
|
3
|
-
const dotenv = require('dotenv');
|
|
4
3
|
const { resolve } = require('path');
|
|
5
4
|
const { StepError } = require('../lib/step-error');
|
|
6
5
|
|
|
7
6
|
const GET_RELEASE_CONFIG_STEP = {
|
|
8
7
|
message: RELEASE.getAuthToken,
|
|
9
8
|
fn: async ({ dirName }) => {
|
|
10
|
-
const
|
|
11
|
-
if (e.code === 'ENOENT') {
|
|
12
|
-
throw new StepError('Mising .env file', { cause: e });
|
|
13
|
-
}
|
|
9
|
+
const { CORVA_API_ENV, AUTH_TOKEN, CORVA_API_KEY } = process.env;
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
const { CORVA_API_ENV, AUTH_TOKEN } = dotenv.parse(env);
|
|
18
|
-
|
|
19
|
-
if (!AUTH_TOKEN) {
|
|
11
|
+
if (!AUTH_TOKEN && !CORVA_API_KEY) {
|
|
20
12
|
throw new StepError(RELEASE.getAuthTokenError);
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
return {
|
|
24
16
|
CORVA_API_ENV: CORVA_API_ENV || 'production',
|
|
25
17
|
AUTH_TOKEN,
|
|
18
|
+
CORVA_API_KEY,
|
|
26
19
|
};
|
|
27
20
|
},
|
|
28
21
|
};
|
|
@@ -8,7 +8,7 @@ const { get } = require('lodash/fp');
|
|
|
8
8
|
|
|
9
9
|
const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
10
10
|
message: RELEASE.uploadApp,
|
|
11
|
-
fn: async ({ zipFileName, appKey, CORVA_API_ENV, AUTH_TOKEN, dirName }) => {
|
|
11
|
+
fn: async ({ zipFileName, appKey, CORVA_API_ENV, AUTH_TOKEN, CORVA_API_KEY, dirName }) => {
|
|
12
12
|
const form = new FormData();
|
|
13
13
|
|
|
14
14
|
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'archive.zip');
|
|
@@ -20,7 +20,10 @@ const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
|
20
20
|
|
|
21
21
|
await axios
|
|
22
22
|
.post(uploadURL, form, {
|
|
23
|
-
headers: {
|
|
23
|
+
headers: {
|
|
24
|
+
...form.getHeaders(),
|
|
25
|
+
Authorization: AUTH_TOKEN ? `Bearer ${AUTH_TOKEN}` : `API ${CORVA_API_KEY}`,
|
|
26
|
+
},
|
|
24
27
|
})
|
|
25
28
|
.catch((e) => {
|
|
26
29
|
throw new StepError(
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const inquirer = require('inquirer');
|
|
|
10
10
|
const os = require('os');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const semver = require('semver');
|
|
13
|
+
require('dotenv').config();
|
|
13
14
|
|
|
14
15
|
const {
|
|
15
16
|
ensureLatestVersion,
|
|
@@ -55,7 +56,7 @@ function checkNodeVersion() {
|
|
|
55
56
|
console.log(
|
|
56
57
|
chalk.red(
|
|
57
58
|
`\nYou are using Node ${process.version}.\n\n` +
|
|
58
|
-
|
|
59
|
+
`Please update to Node 16 or higher for a better, fully supported experience.\n`
|
|
59
60
|
)
|
|
60
61
|
);
|
|
61
62
|
// Fall back to latest supported react-scripts on Node 4
|
|
@@ -85,7 +86,7 @@ function checkOptions(opts) {
|
|
|
85
86
|
const printDeprecationNotice = (param) =>
|
|
86
87
|
console.warn(
|
|
87
88
|
chalk.bgYellowBright`DEPRECATED OPTION: ${param}` +
|
|
88
|
-
|
|
89
|
+
` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`
|
|
89
90
|
);
|
|
90
91
|
|
|
91
92
|
async function initialChecks() {
|
|
@@ -107,7 +108,8 @@ async function initialChecks() {
|
|
|
107
108
|
manifestConstants.manifestOptions().forEach((value) => {
|
|
108
109
|
const type = typeof value.default;
|
|
109
110
|
const option = new Option(
|
|
110
|
-
`${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${
|
|
111
|
+
`${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${
|
|
112
|
+
(type !== 'undefined' && type) || 'string'
|
|
111
113
|
}]`,
|
|
112
114
|
value.message
|
|
113
115
|
);
|
|
@@ -268,7 +270,7 @@ async function initPackage(projectName, opts) {
|
|
|
268
270
|
const manifest = new Manifest(manifestHelpers.fillManifest(opts));
|
|
269
271
|
const runtime = resolveAppRuntime(opts);
|
|
270
272
|
|
|
271
|
-
if (!await runtime.isRuntimeAvailable()) {
|
|
273
|
+
if (!(await runtime.isRuntimeAvailable())) {
|
|
272
274
|
throw new Error(`Runtime "${opts.runtime}" is not available locally`);
|
|
273
275
|
}
|
|
274
276
|
|
|
@@ -370,7 +372,7 @@ async function configureApp(root, manifest, runtime) {
|
|
|
370
372
|
|
|
371
373
|
const addNvmRc = async (root, manifest, runtime) => {
|
|
372
374
|
await fs.outputFile(path.join(root, '.nvmrc'), `${runtime.version}\n`);
|
|
373
|
-
}
|
|
375
|
+
};
|
|
374
376
|
|
|
375
377
|
const addTsConfigs = (root, manifest, runtime) => {
|
|
376
378
|
if (runtime.language !== 'typescript') {
|
|
@@ -445,7 +447,7 @@ function addPackageJSON(root, manifest, runtime) {
|
|
|
445
447
|
scripts: defaults.scripts,
|
|
446
448
|
dependencies: defaults.dependencies,
|
|
447
449
|
devDependencies: defaults.devDependencies,
|
|
448
|
-
...(defaults.jest && { jest: defaults.jest })
|
|
450
|
+
...(defaults.jest && { jest: defaults.jest }),
|
|
449
451
|
};
|
|
450
452
|
|
|
451
453
|
return fs.writeJSON(path.join(root, 'package.json'), packageJson, writejsonOptions);
|
|
@@ -459,12 +461,16 @@ function addPackageJSON(root, manifest, runtime) {
|
|
|
459
461
|
async function installApp(root, manifest, runtime) {
|
|
460
462
|
const command = manifest.isJs() ? runtime.packageManager : 'make';
|
|
461
463
|
const args = ['install'];
|
|
462
|
-
const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root }
|
|
464
|
+
const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root };
|
|
463
465
|
|
|
464
466
|
console.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
|
|
465
|
-
const proc =
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
const proc =
|
|
468
|
+
manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
|
|
469
|
+
? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
|
|
470
|
+
shell: true,
|
|
471
|
+
...opts,
|
|
472
|
+
})
|
|
473
|
+
: spawn.sync(command, args, opts);
|
|
468
474
|
|
|
469
475
|
if (proc.stderr) {
|
|
470
476
|
const error = proc.stderr
|