@corva/create-app 0.40.0-1 → 0.41.0-2
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/README.md +18 -19
- package/bin/cca.js +5 -0
- package/bin/create-corva-app.cjs +14 -0
- package/lib/bump-version.option.js +17 -8
- package/lib/constants/cli.js +5 -11
- package/lib/constants/manifest.js +10 -22
- package/lib/constants/messages.js +4 -10
- package/lib/constants/package.js +6 -8
- package/lib/flow.js +12 -10
- package/lib/flows/lib/api.js +153 -84
- package/lib/flows/lib/create-zip-archive.js +7 -7
- package/lib/flows/lib/json.js +8 -8
- package/lib/flows/lib/manifest.js +5 -7
- package/lib/flows/lib/step-error.js +1 -3
- package/lib/flows/lib/waitForMs.js +3 -0
- package/lib/flows/prepare.js +2 -4
- package/lib/flows/release.js +18 -10
- package/lib/flows/rerun.js +5 -7
- package/lib/flows/steps/prepare-load-app-files.js +3 -7
- package/lib/flows/steps/release/add-label.js +11 -0
- package/lib/flows/steps/release/add-notes.js +10 -0
- package/lib/flows/steps/release/get-config.js +37 -0
- package/lib/flows/steps/release/prepare-data.js +10 -0
- package/lib/flows/steps/release/publish.js +9 -0
- package/lib/flows/steps/release/remove-failed-upload.js +20 -0
- package/lib/flows/steps/release/upload-zip-to-corva.js +25 -0
- package/lib/flows/steps/release/wait-for-build.js +29 -0
- package/lib/flows/steps/rerun-create-task.js +22 -15
- package/lib/flows/steps/rerun-prepare-data.js +150 -127
- package/lib/flows/steps/rerun.js +3 -7
- package/lib/flows/steps/zip-cleanup.js +6 -6
- package/lib/flows/steps/zip-create-archive.js +5 -5
- package/lib/flows/steps/zip-file-list-resolve.js +34 -29
- package/lib/flows/steps/zip-prepare.js +6 -8
- package/lib/flows/steps/zip.js +5 -9
- package/lib/flows/zip-simple.js +2 -4
- package/lib/flows/zip.js +3 -5
- package/lib/helpers/logger.js +13 -5
- package/lib/helpers/manifest.js +6 -10
- package/lib/helpers/resolve-app-runtime.js +47 -45
- package/lib/helpers/utils.js +4 -9
- package/lib/helpers/versioning.js +6 -12
- package/lib/{index.js → main.js} +80 -89
- package/lib/scripts/utils/version.js +10 -12
- package/package.json +5 -3
- package/bin/create-corva-app.js +0 -5
- package/lib/app.js +0 -9
- package/lib/flows/steps/release-get-app-key.js +0 -16
- package/lib/flows/steps/release-get-config.js +0 -37
- package/lib/flows/steps/release-upload-zip-to-corva.js +0 -25
package/lib/helpers/manifest.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { APP_RUNTIMES, APP_TYPES, TEMPLATE_TYPES } from '../constants/cli.js';
|
|
2
|
+
import * as manifestConstants from '../constants/manifest.js';
|
|
3
3
|
|
|
4
|
-
function fillManifest(answers) {
|
|
4
|
+
export function fillManifest(answers) {
|
|
5
5
|
const runtime = answers.runtime || APP_RUNTIMES.UI;
|
|
6
6
|
|
|
7
7
|
const defaultManifestProperties = _defaultManifestProperties({
|
|
@@ -66,16 +66,12 @@ function defaultAppSettings({ type, schedulerType, cronString, depthMilestone })
|
|
|
66
66
|
if (schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value) {
|
|
67
67
|
return {
|
|
68
68
|
scheduler_type: schedulerType,
|
|
69
|
-
depth_milestone: depthMilestone || 1
|
|
70
|
-
}
|
|
69
|
+
depth_milestone: depthMilestone || 1,
|
|
70
|
+
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return {
|
|
74
74
|
scheduler_type: schedulerType,
|
|
75
75
|
cron_string: cronString || '*/5 * * * *',
|
|
76
|
-
}
|
|
76
|
+
};
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
module.exports = {
|
|
80
|
-
fillManifest,
|
|
81
|
-
};
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { spawn } = require("child_process");
|
|
4
|
-
const { promises: fs } = require("fs");
|
|
5
|
-
const semver = require("semver");
|
|
6
|
-
const os = require("os");
|
|
1
|
+
import { APP_TYPES } from '../constants/cli.js';
|
|
2
|
+
import Debug from 'debug';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
|
|
4
|
+
const debug = Debug('cca:resolve-app-runtime');
|
|
5
|
+
import { spawn } from 'child_process';
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import semver from 'semver';
|
|
8
|
+
import os from 'os';
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
const checkCliVersion = async (command, version, stdErr = false) =>
|
|
11
|
+
new Promise((resolve, reject) => {
|
|
12
|
+
const child = spawn(command, ['--version']);
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
data = buffer;
|
|
15
|
-
});
|
|
14
|
+
let data;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
child.stderr.once('data', (buffer) => {
|
|
17
|
+
data = buffer;
|
|
18
|
+
});
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
debug(data.toString());
|
|
20
|
+
child.stdout.once('data', (buffer) => {
|
|
21
|
+
data = buffer;
|
|
22
|
+
});
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
child.once('close', (code) => {
|
|
25
|
+
if (code !== 0) {
|
|
26
|
+
debug(`Command ${command} exited with code ${code}`);
|
|
27
|
+
debug(data.toString());
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
return reject(false);
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
debug(`%s version output: %s`, command, data.toString());
|
|
33
|
+
|
|
34
|
+
resolve(semver.satisfies(semver.coerce(data.toString('utf-8')), version));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
34
37
|
|
|
35
|
-
const checkNodeVersion = version => async () => {
|
|
38
|
+
const checkNodeVersion = (version) => async () => {
|
|
36
39
|
try {
|
|
37
40
|
await fs.access(`${os.homedir()}/.nvm/nvm.sh`);
|
|
38
41
|
|
|
@@ -43,41 +46,40 @@ const checkNodeVersion = version => async () => {
|
|
|
43
46
|
debug(e);
|
|
44
47
|
debug('nvm is not installed, checking node version');
|
|
45
48
|
|
|
46
|
-
return checkCliVersion(
|
|
49
|
+
return checkCliVersion('node', version);
|
|
47
50
|
}
|
|
48
|
-
}
|
|
51
|
+
};
|
|
49
52
|
|
|
50
|
-
const resolveAppRuntime = (opts) => {
|
|
53
|
+
export const resolveAppRuntime = (opts) => {
|
|
51
54
|
if (opts.appType === APP_TYPES.UI) {
|
|
52
|
-
const version =
|
|
55
|
+
const version = '16';
|
|
53
56
|
|
|
54
57
|
return {
|
|
55
|
-
language: opts.useTypescript ?
|
|
58
|
+
language: opts.useTypescript ? 'typescript' : 'javascript',
|
|
56
59
|
isRuntimeAvailable: checkNodeVersion(version),
|
|
57
60
|
packageManager: opts.packageManager,
|
|
58
|
-
version
|
|
59
|
-
}
|
|
61
|
+
version,
|
|
62
|
+
};
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
if (opts.runtime.startsWith(
|
|
65
|
+
if (opts.runtime.startsWith('node')) {
|
|
63
66
|
const version = /nodejs(\d{2})\.x/.exec(opts.runtime)[1];
|
|
64
67
|
|
|
65
68
|
return {
|
|
66
|
-
language: opts.useTypescript ?
|
|
69
|
+
language: opts.useTypescript ? 'typescript' : 'javascript',
|
|
67
70
|
isRuntimeAvailable: checkNodeVersion(version),
|
|
68
71
|
packageManager: opts.packageManager,
|
|
69
|
-
version
|
|
70
|
-
}
|
|
72
|
+
version,
|
|
73
|
+
};
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
const version = /python(\d\.\d)/.exec(opts.runtime)[1]
|
|
76
|
+
const version = /python(\d\.\d)/.exec(opts.runtime)[1];
|
|
74
77
|
|
|
75
78
|
return {
|
|
76
|
-
language:
|
|
77
|
-
isRuntimeAvailable: async () =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
language: 'python',
|
|
80
|
+
isRuntimeAvailable: async () =>
|
|
81
|
+
(await checkCliVersion('python3', version)) || (await checkCliVersion('python', version)),
|
|
82
|
+
packageManager: 'pip',
|
|
83
|
+
version,
|
|
84
|
+
};
|
|
81
85
|
};
|
|
82
|
-
|
|
83
|
-
module.exports = { resolveAppRuntime };
|
package/lib/helpers/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
3
|
|
|
4
|
-
function copyFileSync(source, target) {
|
|
4
|
+
export function copyFileSync(source, target) {
|
|
5
5
|
let targetFile = target;
|
|
6
6
|
//if target is a directory a new file with the same name will be created
|
|
7
7
|
if (fs.existsSync(target)) {
|
|
@@ -13,7 +13,7 @@ function copyFileSync(source, target) {
|
|
|
13
13
|
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function copyFolderRecursiveSync(sourceFolder, targetFolder) {
|
|
16
|
+
export function copyFolderRecursiveSync(sourceFolder, targetFolder) {
|
|
17
17
|
//check if folder needs to be created or integrated
|
|
18
18
|
if (!fs.existsSync(targetFolder)) {
|
|
19
19
|
fs.mkdirSync(targetFolder);
|
|
@@ -38,8 +38,3 @@ function copyFolderRecursiveSync(sourceFolder, targetFolder) {
|
|
|
38
38
|
copyFileSync(curSource, targetFolder);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
module.exports = {
|
|
43
|
-
copyFileSync,
|
|
44
|
-
copyFolderRecursiveSync,
|
|
45
|
-
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
3
|
|
|
4
|
-
function isInGitRepository(appPath) {
|
|
4
|
+
export function isInGitRepository(appPath) {
|
|
5
5
|
try {
|
|
6
6
|
execSync('git rev-parse --is-inside-work-tree', {
|
|
7
7
|
stdio: 'ignore',
|
|
@@ -13,7 +13,7 @@ function isInGitRepository(appPath) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function tryGitInit(appPath) {
|
|
16
|
+
export function tryGitInit(appPath) {
|
|
17
17
|
try {
|
|
18
18
|
if (isInGitRepository()) {
|
|
19
19
|
return false;
|
|
@@ -29,7 +29,7 @@ function tryGitInit(appPath) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function tryGitCommit(appPath) {
|
|
32
|
+
export function tryGitCommit(appPath) {
|
|
33
33
|
try {
|
|
34
34
|
execSync('git add -A', { stdio: 'ignore', cwd: appPath });
|
|
35
35
|
execSync('git commit -m "chore: initialize project using @corva/create-app"', {
|
|
@@ -56,7 +56,7 @@ function tryGitCommit(appPath) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function shouldUseYarn(appPath) {
|
|
59
|
+
export function shouldUseYarn(appPath) {
|
|
60
60
|
try {
|
|
61
61
|
execSync('yarnpkg --version', { stdio: 'ignore', cwd: appPath });
|
|
62
62
|
return true;
|
|
@@ -64,9 +64,3 @@ function shouldUseYarn(appPath) {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
module.exports = {
|
|
69
|
-
isInGitRepository,
|
|
70
|
-
tryGitInit,
|
|
71
|
-
tryGitCommit,
|
|
72
|
-
};
|
package/lib/{index.js → main.js}
RENAMED
|
@@ -1,48 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const semver = require('semver');
|
|
13
|
-
|
|
14
|
-
const {
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import figlet from 'figlet';
|
|
3
|
+
import { Command, CommanderError, Option } from 'commander';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import semver from 'semver';
|
|
9
|
+
|
|
10
|
+
import {
|
|
15
11
|
ensureLatestVersion,
|
|
16
12
|
warnIfOutdated,
|
|
17
13
|
ensureBumpVersion,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
} from './scripts/utils/version.js';
|
|
15
|
+
import * as utils from './helpers/utils.js';
|
|
16
|
+
import * as manifestHelpers from './helpers/manifest.js';
|
|
17
|
+
import * as versioning from './helpers/versioning.js';
|
|
18
|
+
|
|
19
|
+
import { getDefaultsForPackageJson } from './constants/package.js';
|
|
20
|
+
import * as manifestConstants from './constants/manifest.js';
|
|
21
|
+
|
|
22
|
+
import packageJson from '../package.json' assert { type: 'json' };
|
|
23
|
+
import { clear } from 'node:console';
|
|
24
|
+
import spawn from 'cross-spawn';
|
|
25
|
+
import { runFlow } from './flow.js';
|
|
26
|
+
import { ERROR_ICON } from './constants/messages.js';
|
|
27
|
+
import { StepError } from './flows/lib/step-error.js';
|
|
28
|
+
import { RELEASE_FLOW } from './flows/release.js';
|
|
29
|
+
import { RERUN_FLOW } from './flows/rerun.js';
|
|
30
|
+
import { ZIP_FLOW } from './flows/zip.js';
|
|
31
|
+
import { bumpVersionOptionDeprecated, bumpVersionOption, apiKeyOption, envOption, silentOption } from './bump-version.option.js';
|
|
32
|
+
import { Manifest } from './flows/lib/manifest.js';
|
|
33
|
+
import { resolveAppRuntime } from './helpers/resolve-app-runtime.js';
|
|
34
|
+
import { existsSync } from 'node:fs';
|
|
35
|
+
import { fileURLToPath } from 'node:url';
|
|
36
|
+
import { logger } from './helpers/logger.js';
|
|
37
|
+
import _ from 'lodash/fp.js';
|
|
38
|
+
|
|
39
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
40
|
+
const __dirname = path.dirname(__filename);
|
|
40
41
|
|
|
41
42
|
const writejsonOptions = {
|
|
42
43
|
spaces: 2,
|
|
43
44
|
EOL: os.EOL,
|
|
44
45
|
};
|
|
45
46
|
|
|
47
|
+
const silencer = handler => async (...args) => {
|
|
48
|
+
const result = await handler(...args);
|
|
49
|
+
|
|
50
|
+
if (args[args.length - 2].silent && result) {
|
|
51
|
+
console.log(result);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
function startingMessage() {
|
|
47
56
|
clear();
|
|
48
57
|
console.log(chalk.green(' Welcome to apps generator for:'));
|
|
@@ -90,7 +99,7 @@ const printDeprecationNotice = (param) =>
|
|
|
90
99
|
` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`
|
|
91
100
|
);
|
|
92
101
|
|
|
93
|
-
async function
|
|
102
|
+
export async function run() {
|
|
94
103
|
const program = new Command()
|
|
95
104
|
.hook('preAction', async () => {
|
|
96
105
|
checkNodeVersion();
|
|
@@ -111,7 +120,7 @@ async function initialChecks() {
|
|
|
111
120
|
const option = new Option(
|
|
112
121
|
`${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${(type !== 'undefined' && type) || 'string'
|
|
113
122
|
}]`,
|
|
114
|
-
value.message
|
|
123
|
+
value.message,
|
|
115
124
|
);
|
|
116
125
|
|
|
117
126
|
if (value.choices) {
|
|
@@ -137,37 +146,12 @@ async function initialChecks() {
|
|
|
137
146
|
|
|
138
147
|
createCommand
|
|
139
148
|
.version(packageJson.version)
|
|
140
|
-
.addOption(
|
|
141
|
-
new Option(
|
|
142
|
-
'-z, --zip [string]',
|
|
143
|
-
chalk.bgYellow`DEPRECATED` + ` Use ${chalk.cyan`zip`} command instead`
|
|
144
|
-
)
|
|
145
|
-
)
|
|
146
|
-
.addOption(
|
|
147
|
-
new Option(
|
|
148
|
-
'--release',
|
|
149
|
-
chalk.bgYellow`DEPRECATED` + ` Use ${chalk.cyan`release`} command instead`
|
|
150
|
-
)
|
|
151
|
-
)
|
|
152
|
-
.addOption(bumpVersionOptionDeprecated);
|
|
153
149
|
|
|
154
150
|
createCommand.action(async (dirName, options) => {
|
|
155
151
|
if (options.zip || options.release) {
|
|
156
152
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
if (options.zip) {
|
|
160
|
-
printDeprecationNotice('zip');
|
|
161
|
-
|
|
162
|
-
return runFlow(ZIP_FLOW, { dirName, patterns: [], options });
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (options.release) {
|
|
166
|
-
printDeprecationNotice('release');
|
|
167
|
-
|
|
168
|
-
return runFlow(RELEASE_FLOW, { dirName, patterns: [], options });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
155
|
startingMessage();
|
|
172
156
|
|
|
173
157
|
// NOTE: Default action
|
|
@@ -181,16 +165,12 @@ async function initialChecks() {
|
|
|
181
165
|
.argument('[patterns...]', 'Additional patterns to zip', [])
|
|
182
166
|
.addOption(bumpVersionOption)
|
|
183
167
|
.addOption(new Option('--ignored-files [ignoredFiles...]', 'Patterns to skip zip', []))
|
|
184
|
-
.addOption(
|
|
185
|
-
.action(async (dirName, patterns, options) => {
|
|
168
|
+
.addOption(silentOption)
|
|
169
|
+
.action(silencer(async (dirName, patterns, options) => {
|
|
186
170
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
187
171
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return runFlow(ZIP_FLOW, { dirName, patterns, options });
|
|
193
|
-
});
|
|
172
|
+
return runFlow(ZIP_FLOW, { dirName, patterns, options }).then(_.get('zipFileName'))
|
|
173
|
+
}));
|
|
194
174
|
|
|
195
175
|
program
|
|
196
176
|
.command('release')
|
|
@@ -198,25 +178,30 @@ async function initialChecks() {
|
|
|
198
178
|
.argument('<project-directory>', 'Project directory to work with')
|
|
199
179
|
.argument('[patterns...]', 'Additional patterns to zip', [])
|
|
200
180
|
.addOption(bumpVersionOption)
|
|
201
|
-
.addOption(new Option('--ignored-files [
|
|
202
|
-
.addOption(
|
|
181
|
+
.addOption(new Option('--ignored-files [string...]', 'Patterns to skip zip').default([]))
|
|
182
|
+
.addOption(silentOption)
|
|
183
|
+
.addOption(envOption)
|
|
184
|
+
.addOption(apiKeyOption)
|
|
185
|
+
.addOption(new Option('--notes [string]', 'Add custom notes to published app'))
|
|
186
|
+
.addOption(new Option('--label [string]', 'Put a label on the release').choices(['BETA', 'PROD']))
|
|
187
|
+
.addOption(new Option('--remove-on-fail [boolean]', 'Remove release if it fails during deployment').default(false))
|
|
188
|
+
// .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
|
|
203
189
|
.action(async (dirName, patterns, options) => {
|
|
204
190
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
205
191
|
|
|
206
|
-
|
|
207
|
-
console.log(dirName);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return runFlow(RELEASE_FLOW, { dirName, patterns, options });
|
|
192
|
+
await runFlow(RELEASE_FLOW, { dirName, patterns, options });
|
|
211
193
|
});
|
|
212
194
|
|
|
213
195
|
program
|
|
214
196
|
.command('rerun')
|
|
215
197
|
.description('Rerun app')
|
|
216
198
|
.argument('<project-directory>', 'Project directory to work with')
|
|
199
|
+
.addOption(apiKeyOption)
|
|
200
|
+
.addOption(envOption)
|
|
201
|
+
.addOption(silentOption)
|
|
217
202
|
.addOption(new Option('--assets [assets...]', 'Assets ids list', []))
|
|
218
|
-
.action(async (dirName,
|
|
219
|
-
|
|
203
|
+
.action(async (dirName, options) => {
|
|
204
|
+
await runFlow(RERUN_FLOW, { dirName, options });
|
|
220
205
|
});
|
|
221
206
|
|
|
222
207
|
try {
|
|
@@ -289,7 +274,7 @@ async function initPackage(projectName, opts) {
|
|
|
289
274
|
const manifest = new Manifest(manifestHelpers.fillManifest(opts));
|
|
290
275
|
const runtime = resolveAppRuntime(opts);
|
|
291
276
|
|
|
292
|
-
if (!await runtime.isRuntimeAvailable()) {
|
|
277
|
+
if (!(await runtime.isRuntimeAvailable())) {
|
|
293
278
|
throw new Error(`Runtime "${opts.runtime}" is not available locally`);
|
|
294
279
|
}
|
|
295
280
|
|
|
@@ -391,7 +376,7 @@ async function configureApp(root, manifest, runtime) {
|
|
|
391
376
|
|
|
392
377
|
const addNvmRc = async (root, manifest, runtime) => {
|
|
393
378
|
await fs.outputFile(path.join(root, '.nvmrc'), `${runtime.version}\n`);
|
|
394
|
-
}
|
|
379
|
+
};
|
|
395
380
|
|
|
396
381
|
const addTsConfigs = (root, manifest, runtime) => {
|
|
397
382
|
if (runtime.language !== 'typescript') {
|
|
@@ -466,7 +451,7 @@ function addPackageJSON(root, manifest, runtime) {
|
|
|
466
451
|
scripts: defaults.scripts,
|
|
467
452
|
dependencies: defaults.dependencies,
|
|
468
453
|
devDependencies: defaults.devDependencies,
|
|
469
|
-
...(defaults.jest && { jest: defaults.jest })
|
|
454
|
+
...(defaults.jest && { jest: defaults.jest }),
|
|
470
455
|
};
|
|
471
456
|
|
|
472
457
|
return fs.writeJSON(path.join(root, 'package.json'), packageJson, writejsonOptions);
|
|
@@ -480,12 +465,20 @@ function addPackageJSON(root, manifest, runtime) {
|
|
|
480
465
|
async function installApp(root, manifest, runtime) {
|
|
481
466
|
const command = manifest.isJs() ? runtime.packageManager : 'make';
|
|
482
467
|
const args = ['install'];
|
|
483
|
-
const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root }
|
|
468
|
+
const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root };
|
|
469
|
+
|
|
470
|
+
if (process.env.CI && command === 'yarn') {
|
|
471
|
+
args.push('--cache-folder=".yarn-cache"');
|
|
472
|
+
}
|
|
484
473
|
|
|
485
474
|
logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
|
|
486
|
-
const proc =
|
|
487
|
-
|
|
488
|
-
|
|
475
|
+
const proc =
|
|
476
|
+
manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
|
|
477
|
+
? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
|
|
478
|
+
shell: true,
|
|
479
|
+
...opts,
|
|
480
|
+
})
|
|
481
|
+
: spawn.sync(command, args, opts);
|
|
489
482
|
|
|
490
483
|
if (proc.stderr) {
|
|
491
484
|
const error = proc.stderr
|
|
@@ -542,5 +535,3 @@ async function helpCommands(manifest, { packageManager: displayedCommand }) {
|
|
|
542
535
|
logger.log(' Uploads the app ZIP to Corva');
|
|
543
536
|
logger.log();
|
|
544
537
|
}
|
|
545
|
-
|
|
546
|
-
initialChecks();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import NpmApi from 'npm-api';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import packageJson from '../../../package.json' assert { type: 'json' };
|
|
7
|
+
import { logger } from '../../helpers/logger.js';
|
|
8
8
|
const npm = new NpmApi();
|
|
9
9
|
|
|
10
10
|
const error = chalk.bold.red;
|
|
@@ -16,7 +16,7 @@ const getCurrentVersion = () => packageJson.version;
|
|
|
16
16
|
const getLatestVersion = async () => npm.repo('@corva/create-app').prop('version');
|
|
17
17
|
|
|
18
18
|
// NOTE: Stop process and show error if version is outdated
|
|
19
|
-
async function ensureLatestVersion() {
|
|
19
|
+
export async function ensureLatestVersion() {
|
|
20
20
|
const currentVersion = getCurrentVersion();
|
|
21
21
|
const latestVersion = await getLatestVersion();
|
|
22
22
|
|
|
@@ -37,7 +37,7 @@ async function ensureLatestVersion() {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// NOTE: Show user-friendly warning if version is outdated
|
|
40
|
-
async function warnIfOutdated() {
|
|
40
|
+
export async function warnIfOutdated() {
|
|
41
41
|
logger.write('Checking for updates...\n');
|
|
42
42
|
|
|
43
43
|
const currentVersion = getCurrentVersion();
|
|
@@ -64,7 +64,7 @@ const PROMPT_MESSAGE = `Bumping package version:
|
|
|
64
64
|
${chalk.bold` Please select one of the options below:`}
|
|
65
65
|
`;
|
|
66
66
|
|
|
67
|
-
const ensureBumpVersion = async (bumpVersion) => {
|
|
67
|
+
export const ensureBumpVersion = async (bumpVersion) => {
|
|
68
68
|
if (bumpVersion) {
|
|
69
69
|
return bumpVersion;
|
|
70
70
|
}
|
|
@@ -96,7 +96,7 @@ const ensureBumpVersion = async (bumpVersion) => {
|
|
|
96
96
|
return option === 'custom' ? custom : option;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersion }) {
|
|
99
|
+
export async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersion }) {
|
|
100
100
|
if (releaseTypeOrNewVersion === 'skip') {
|
|
101
101
|
return version;
|
|
102
102
|
}
|
|
@@ -107,5 +107,3 @@ async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersi
|
|
|
107
107
|
|
|
108
108
|
return semver.inc(version, releaseTypeOrNewVersion);
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
module.exports = { ensureLatestVersion, warnIfOutdated, getIncreasedVersion, ensureBumpVersion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corva/create-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0-2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create app to use it in CORVA.AI",
|
|
6
6
|
"keywords": [
|
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
"directory": "@corva/create-app"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
18
19
|
"bin": {
|
|
19
|
-
"create-corva-app": "./bin/create-corva-app.
|
|
20
|
+
"create-corva-app": "./bin/create-corva-app.cjs"
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
23
|
+
"bin/**/*.cjs",
|
|
22
24
|
"bin/**/*.js",
|
|
23
25
|
"lib/**/*.js",
|
|
24
26
|
"templates",
|
|
@@ -33,7 +35,6 @@
|
|
|
33
35
|
},
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"archiver": "^5.3.0",
|
|
36
|
-
"axios": "^0.25.0",
|
|
37
38
|
"chalk": "4.1.0",
|
|
38
39
|
"commander": "^9.1.0",
|
|
39
40
|
"cross-spawn": "7.0.3",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"form-data": "^4.0.0",
|
|
44
45
|
"fs-extra": "9.0.1",
|
|
45
46
|
"glob": "^8.0.1",
|
|
47
|
+
"got": "^12.5.1",
|
|
46
48
|
"inquirer": "^8.2.3",
|
|
47
49
|
"is-glob": "^4.0.3",
|
|
48
50
|
"lodash": "^4.17.21",
|
package/bin/create-corva-app.js
DELETED
package/lib/app.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const { RELEASE } = require('../../constants/messages');
|
|
2
|
-
|
|
3
|
-
const GET_APP_KEY_STEP = {
|
|
4
|
-
message: RELEASE.getAppKey,
|
|
5
|
-
fn: ({ manifest }) => {
|
|
6
|
-
const appKey = manifest.manifest.application.key;
|
|
7
|
-
|
|
8
|
-
if (!appKey) {
|
|
9
|
-
throw new Error(RELEASE.getAppKeyError);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return { appKey };
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = { GET_APP_KEY_STEP };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const { RELEASE } = require('../../constants/messages');
|
|
2
|
-
const { promises: fs } = require('fs');
|
|
3
|
-
const dotenv = require('dotenv');
|
|
4
|
-
const { resolve } = require('path');
|
|
5
|
-
const { StepError } = require('../lib/step-error');
|
|
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
|
-
|
|
16
|
-
const GET_RELEASE_CONFIG_STEP = {
|
|
17
|
-
message: RELEASE.getAuthToken,
|
|
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;
|
|
24
|
-
|
|
25
|
-
if (!AUTH_TOKEN && !API_KEY) {
|
|
26
|
-
throw new StepError(RELEASE.getAuthTokenError);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
CORVA_API_ENV: CORVA_API_ENV || 'production',
|
|
31
|
-
AUTH_TOKEN,
|
|
32
|
-
API_KEY,
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
module.exports = { GET_RELEASE_CONFIG_STEP };
|