@corva/create-app 0.21.0 → 0.23.0-1
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/CHANGELOG.md +5 -19
- package/constants/package.js +1 -0
- package/index.js +13 -9
- package/package.json +4 -1
- package/scripts/ui/index.js +2 -0
- package/scripts/ui/releaseAppZip.js +90 -0
- package/scripts/ui/zipAppSource.js +25 -27
- package/template/ui/ts/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,27 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [0.
|
|
5
|
+
## [0.23.0-1](https://github.com/corva-ai/create-corva-app/compare/v0.23.0-0...v0.23.0-1) (2022-02-17)
|
|
6
6
|
|
|
7
|
-
## [0.21.0-rc.0](https://github.com/corva-ai/create-corva-app/compare/v0.20.0-rc.1...v0.21.0-rc.0) (2022-02-01)
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
### Bug Fixes
|
|
13
|
-
|
|
14
|
-
* **dc-2955:** get back -t option ([b6ffc5f](https://github.com/corva-ai/create-corva-app/commit/b6ffc5f38e818d038bf8c7346fa7183a18d97fa6))
|
|
15
|
-
|
|
16
|
-
## [0.21.0-1](https://github.com/corva-ai/create-corva-app/compare/v0.19.0...v0.21.0-1) (2022-01-21)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Bug Fixes
|
|
8
|
+
### Features
|
|
20
9
|
|
|
21
|
-
* **
|
|
10
|
+
* **DC-2291:** add release script to FE dc apps ([fe1bda2](https://github.com/corva-ai/create-corva-app/commit/fe1bda29aa2b68d6912894353d731e73aadeb47b))
|
|
22
11
|
|
|
23
|
-
## [0.
|
|
12
|
+
## [0.23.0-0](https://github.com/corva-ai/create-corva-app/compare/v0.22.0-0...v0.23.0-0) (2022-02-15)
|
|
24
13
|
|
|
25
|
-
## [0.
|
|
14
|
+
## [0.22.0-0](https://github.com/corva-ai/create-corva-app/compare/v0.21.0-2...v0.22.0-0) (2022-02-01)
|
|
26
15
|
|
|
27
16
|
## [0.21.0-2](https://github.com/corva-ai/create-corva-app/compare/v0.21.0-1...v0.21.0-2) (2022-01-25)
|
|
28
17
|
|
|
@@ -249,9 +238,6 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
249
238
|
## [0.6.0-0](https://github.com/facebook/create-react-app/compare/v0.5.0-0...v0.6.0-0) (2021-06-16)
|
|
250
239
|
|
|
251
240
|
## [0.5.0-0](https://github.com/facebook/create-react-app/compare/v0.2.29...v0.5.0-0) (2021-06-02)
|
|
252
|
-
## [0.4.0](https://github.com/facebook/create-react-app/compare/v0.4.0-rc.0...v0.4.0) (2021-06-16)
|
|
253
|
-
|
|
254
|
-
## [0.4.0-rc.0](https://github.com/facebook/create-react-app/compare/v0.2.29...v0.4.0-rc.0) (2021-06-02)
|
|
255
241
|
|
|
256
242
|
### [0.4.3](https://github.com/facebook/create-react-app/compare/v0.4.0...v0.4.3) (2021-05-26)
|
|
257
243
|
|
package/constants/package.js
CHANGED
package/index.js
CHANGED
|
@@ -34,29 +34,31 @@ const shouldUseYarn = () => packageManager === YARN_EXECUTABLE;
|
|
|
34
34
|
const getLockFileName = (manager) =>
|
|
35
35
|
manager === YARN_EXECUTABLE ? 'yarn.lock' : 'package-lock.json';
|
|
36
36
|
|
|
37
|
-
clear();
|
|
38
37
|
|
|
39
38
|
let projectName;
|
|
40
39
|
let program;
|
|
41
40
|
|
|
42
41
|
function startingMessage() {
|
|
42
|
+
clear();
|
|
43
43
|
console.log(chalk.green(' Welcome to apps generator for:'));
|
|
44
44
|
console.log(chalk.cyan(figlet.textSync('CORVA.AI', { horizontalLayout: 'full' })));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function checkNodeVersion() {
|
|
48
|
-
|
|
48
|
+
process.stdout.write('Checking node version...');
|
|
49
|
+
|
|
49
50
|
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10');
|
|
50
51
|
if (unsupportedNodeVersion) {
|
|
51
52
|
console.log(
|
|
52
53
|
chalk.red(
|
|
53
|
-
|
|
54
|
+
`\nYou are using Node ${process.version}.\n\n` +
|
|
54
55
|
`Please update to Node 10 or higher for a better, fully supported experience.\n`
|
|
55
56
|
)
|
|
56
57
|
);
|
|
57
58
|
// Fall back to latest supported react-scripts on Node 4
|
|
58
59
|
return process.exit(1);
|
|
59
60
|
}
|
|
61
|
+
process.stdout.write(' ✅ \n');
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
function checkOptions(opts) {
|
|
@@ -78,8 +80,6 @@ function checkOptions(opts) {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
async function initialChecks() {
|
|
81
|
-
startingMessage();
|
|
82
|
-
|
|
83
83
|
program = new commander.Command('corva-create-app')
|
|
84
84
|
.version(packageJson.version)
|
|
85
85
|
.argument('[project-directory]', 'project directory to work with')
|
|
@@ -88,6 +88,7 @@ async function initialChecks() {
|
|
|
88
88
|
projectName = name;
|
|
89
89
|
})
|
|
90
90
|
.option('-z, --zip <type>', 'zip app source')
|
|
91
|
+
.option('--release <type>', 'release app')
|
|
91
92
|
.addOption(
|
|
92
93
|
new commander.Option(`-p, --packageManager [string]`, 'package manager to use')
|
|
93
94
|
.default(YARN_EXECUTABLE)
|
|
@@ -125,12 +126,15 @@ async function initialChecks() {
|
|
|
125
126
|
useTypescript = opts.useTypescript || useTypescript;
|
|
126
127
|
|
|
127
128
|
if (opts.zip) {
|
|
128
|
-
if (opts.zip === APP_RUNTIMES.UI)
|
|
129
|
-
return uiScripts.zipAppSource(shouldUseYarn());
|
|
130
|
-
}
|
|
131
|
-
|
|
129
|
+
if (opts.zip === APP_RUNTIMES.UI) return uiScripts.zipAppSource();
|
|
132
130
|
process.exit(0);
|
|
133
131
|
}
|
|
132
|
+
if (opts.release) {
|
|
133
|
+
if (opts.release === APP_RUNTIMES.UI) return uiScripts.releaseAppZip();
|
|
134
|
+
process.exit(0);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
startingMessage();
|
|
134
138
|
|
|
135
139
|
if (!projectName) {
|
|
136
140
|
console.error('Please specify the project directory:');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corva/create-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0-1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create app to use it in CORVA.AI",
|
|
6
6
|
"keywords": [
|
|
@@ -33,12 +33,15 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"archiver": "^5.3.0",
|
|
36
|
+
"axios": "^0.25.0",
|
|
36
37
|
"chalk": "4.1.0",
|
|
37
38
|
"commander": "^8.2.0",
|
|
38
39
|
"conventional-changelog-cli": "^2.1.0",
|
|
39
40
|
"cross-spawn": "7.0.3",
|
|
41
|
+
"dotenv": "^16.0.0",
|
|
40
42
|
"envinfo": "7.5.1",
|
|
41
43
|
"figlet": "^1.5.0",
|
|
44
|
+
"form-data": "^4.0.0",
|
|
42
45
|
"fs-extra": "9.0.1",
|
|
43
46
|
"hyperquest": "2.1.3",
|
|
44
47
|
"inquirer": "7.3.2",
|
package/scripts/ui/index.js
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const FormData = require('form-data');
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const dotenv = require('dotenv');
|
|
7
|
+
const get = require('lodash').get;
|
|
8
|
+
const zipAppSource = require('./zipAppSource');
|
|
9
|
+
|
|
10
|
+
const SUCCESS_ICON = ' ✅ \n';
|
|
11
|
+
const ERROR_ICON = ' ❌ \n';
|
|
12
|
+
|
|
13
|
+
const CONSOLE_MESSAGES = {
|
|
14
|
+
createZip: 'Creating zip archive...',
|
|
15
|
+
createZipError: 'Could not create zip archive.',
|
|
16
|
+
getAuthToken: 'Reading auth token...',
|
|
17
|
+
getAuthTokenError: `Could not find auth token. Please run ${chalk.cyan(
|
|
18
|
+
'yarn start'
|
|
19
|
+
)} and login to Corva`,
|
|
20
|
+
getAppKey: 'Reading app key...',
|
|
21
|
+
getAppKeyError: "Could not find app key. Please make sure it's defined in manifest.json",
|
|
22
|
+
uploadApp: 'Uploading app...',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function handleError(e, message) {
|
|
26
|
+
process.stdout.write(ERROR_ICON);
|
|
27
|
+
message && console.log(chalk.red(message));
|
|
28
|
+
console.error(chalk.red(e));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function releaseAppZip() {
|
|
33
|
+
const dirname = process.cwd();
|
|
34
|
+
|
|
35
|
+
// Read auth token
|
|
36
|
+
let authToken;
|
|
37
|
+
let corvaAPIEnv = 'production';
|
|
38
|
+
try {
|
|
39
|
+
process.stdout.write(CONSOLE_MESSAGES.getAuthToken);
|
|
40
|
+
const env = await fs.promises.readFile(path.resolve(dirname, './.env'));
|
|
41
|
+
const config = dotenv.parse(env);
|
|
42
|
+
authToken = config.AUTH_TOKEN;
|
|
43
|
+
if (!authToken) throw new Error('No auth token.');
|
|
44
|
+
if (config.CORVA_API_ENV) corvaAPIEnv = config.CORVA_API_ENV;
|
|
45
|
+
process.stdout.write(SUCCESS_ICON);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
handleError(e, CONSOLE_MESSAGES.getAuthTokenError);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Read app key
|
|
51
|
+
let appKey;
|
|
52
|
+
try {
|
|
53
|
+
process.stdout.write(CONSOLE_MESSAGES.getAppKey);
|
|
54
|
+
const manifest = JSON.parse(
|
|
55
|
+
await fs.promises.readFile(path.resolve(dirname, './manifest.json'))
|
|
56
|
+
);
|
|
57
|
+
appKey = manifest.application.key;
|
|
58
|
+
if (!appKey) throw new Error('No app key.');
|
|
59
|
+
process.stdout.write(SUCCESS_ICON);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
handleError(e, CONSOLE_MESSAGES.getAppKeyError);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Zip archive
|
|
65
|
+
let zipPath;
|
|
66
|
+
try {
|
|
67
|
+
process.stdout.write(CONSOLE_MESSAGES.createZip);
|
|
68
|
+
zipPath = await zipAppSource({ silent: true });
|
|
69
|
+
process.stdout.write(SUCCESS_ICON);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
handleError(e, CONSOLE_MESSAGES.createZipError);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let uploadURL;
|
|
75
|
+
try {
|
|
76
|
+
process.stdout.write(CONSOLE_MESSAGES.uploadApp);
|
|
77
|
+
const form = new FormData();
|
|
78
|
+
form.append('package', fs.createReadStream(zipPath), 'archive.zip');
|
|
79
|
+
const baseURL = `https://api${corvaAPIEnv === 'production' ? '' : `.${corvaAPIEnv}`}.corva.ai`;
|
|
80
|
+
uploadURL = `${baseURL}/v2/apps/${appKey}/packages/upload`;
|
|
81
|
+
await axios.post(uploadURL, form, {
|
|
82
|
+
headers: { ...form.getHeaders(), Authorization: `Bearer ${authToken}` },
|
|
83
|
+
});
|
|
84
|
+
process.stdout.write(SUCCESS_ICON);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
handleError(e, `${get(e, 'response.data.message', '')} \nPOST: ${uploadURL} failed.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = releaseAppZip;
|
|
@@ -4,17 +4,18 @@ const archiver = require('archiver');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
6
|
const semverInc = require('semver/functions/inc');
|
|
7
|
+
const noop = require('lodash').noop;
|
|
7
8
|
|
|
8
9
|
const { warnIfOutdated } = require('../utils/version');
|
|
9
10
|
|
|
10
|
-
async function compressAppToZip(
|
|
11
|
+
async function compressAppToZip({ silent = false }={}) {
|
|
12
|
+
const log = silent ? noop : console.log;
|
|
11
13
|
warnIfOutdated();
|
|
12
14
|
|
|
13
15
|
const dirname = process.cwd();
|
|
14
16
|
|
|
15
17
|
// Left only build script for package json;
|
|
16
18
|
const packageJsonContent = fs.readFileSync(path.resolve(dirname, 'package.json'), 'utf-8');
|
|
17
|
-
|
|
18
19
|
const packageJson = JSON.parse(packageJsonContent);
|
|
19
20
|
|
|
20
21
|
const updatedVersion = semverInc(packageJson.version, 'patch');
|
|
@@ -27,7 +28,8 @@ async function compressAppToZip(useYarn) {
|
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const
|
|
31
|
+
const zipFileName = `${packageJson.name}-${updatedVersion}.zip`;
|
|
32
|
+
const zipPath = path.resolve(path.resolve(dirname, zipFileName));
|
|
31
33
|
|
|
32
34
|
var archive = archiver.create('zip', {});
|
|
33
35
|
var output = fs.createWriteStream(zipPath);
|
|
@@ -35,8 +37,8 @@ async function compressAppToZip(useYarn) {
|
|
|
35
37
|
// pipe archive data to the file
|
|
36
38
|
archive.pipe(output);
|
|
37
39
|
|
|
38
|
-
output.on('close', function
|
|
39
|
-
|
|
40
|
+
output.on('close', function() {
|
|
41
|
+
log(`Created ${zipPath.replace(dirname + '/', '')}, ${archive.pointer()} bytes written\n`);
|
|
40
42
|
|
|
41
43
|
// clean up temp package.json file
|
|
42
44
|
try {
|
|
@@ -47,19 +49,19 @@ async function compressAppToZip(useYarn) {
|
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
|
|
50
|
-
output.on('end', function
|
|
51
|
-
|
|
52
|
+
output.on('end', function() {
|
|
53
|
+
log('Data has been drained');
|
|
52
54
|
});
|
|
53
55
|
|
|
54
|
-
archive.on('warning', function
|
|
56
|
+
archive.on('warning', function(err) {
|
|
55
57
|
if (err.code === 'ENOENT') {
|
|
56
|
-
|
|
58
|
+
log(err.message);
|
|
57
59
|
} else {
|
|
58
60
|
throw err;
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
|
|
62
|
-
archive.on('error', function
|
|
64
|
+
archive.on('error', function(err) {
|
|
63
65
|
throw err;
|
|
64
66
|
});
|
|
65
67
|
|
|
@@ -68,7 +70,7 @@ async function compressAppToZip(useYarn) {
|
|
|
68
70
|
JSON.stringify({ ...packageJson, version: updatedVersion }, null, 2) + os.EOL
|
|
69
71
|
);
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
log(
|
|
72
74
|
chalk(`
|
|
73
75
|
NOTE: Version of your app was updated to ${updatedVersion} (package.json), please don't lower it.
|
|
74
76
|
`)
|
|
@@ -83,26 +85,22 @@ async function compressAppToZip(useYarn) {
|
|
|
83
85
|
name: 'package.json',
|
|
84
86
|
});
|
|
85
87
|
|
|
86
|
-
[
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'tsconfig.json',
|
|
90
|
-
'.npmrc',
|
|
91
|
-
useYarn ? 'yarn.lock' : 'package-lock.json',
|
|
92
|
-
].forEach((name) => {
|
|
93
|
-
const file = path.resolve(dirname, name);
|
|
94
|
-
|
|
95
|
-
// not all app templates have the tsconfig, archive will raise an error with missing files, have to filter-out that
|
|
96
|
-
if (!fs.existsSync(file)) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
88
|
+
['manifest.json', 'config-overrides.js', 'tsconfig.json', '.npmrc', 'yarn.lock'].forEach(
|
|
89
|
+
(name) => {
|
|
90
|
+
const file = path.resolve(dirname, name);
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
// not all app templates have the tsconfig, archive will raise an error with missing files, have to filter-out that
|
|
93
|
+
if (!fs.existsSync(file)) return;
|
|
94
|
+
|
|
95
|
+
archive.file(file, { name });
|
|
96
|
+
}
|
|
97
|
+
);
|
|
102
98
|
|
|
103
99
|
archive.directory(path.resolve(dirname, 'src'), 'src');
|
|
104
100
|
|
|
105
|
-
archive.finalize();
|
|
101
|
+
await archive.finalize();
|
|
102
|
+
log(zipPath);
|
|
103
|
+
return zipPath;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
module.exports = compressAppToZip;
|