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