@corva/create-app 0.0.0-73c49372 → 0.0.0-9a3cf8e
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 +7 -0
- package/bin/create-corva-app.cjs +4 -9
- package/lib/commands/build-release.js +60 -0
- package/lib/commands/release.js +6 -0
- package/lib/constants/cli.js +13 -3
- package/lib/constants/manifest.js +1 -0
- package/lib/constants/package.js +18 -6
- package/lib/flows/build-release.js +31 -0
- package/lib/flows/lib/api.js +6 -12
- package/lib/flows/lib/manifest.js +1 -1
- package/lib/flows/release.js +2 -1
- package/lib/flows/steps/build.js +25 -0
- package/lib/flows/steps/release/get-config.js +2 -2
- package/lib/flows/steps/release/prepare-data.js +14 -5
- package/lib/flows/steps/release/upload-zip-to-corva.js +80 -2
- package/lib/flows/steps/resolve-built-files-for-zip.js +35 -0
- package/lib/flows/steps/zip-file-list-resolve.js +45 -25
- package/lib/helpers/cli-version.js +38 -2
- package/lib/helpers/manifest.js +9 -1
- package/lib/helpers/resolve-app-runtime.js +3 -3
- package/lib/main.js +2 -0
- package/package.json +1 -104
- package/template_extensions/corva/.eslintrc +32 -0
- package/template_extensions/corva/.github/workflows/develop.yml +2 -0
- package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +1 -1
- package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +1 -1
- package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +1 -1
- package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +1 -1
- package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +1 -1
- package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +1 -1
- package/templates/stream_depth/javascript/__tests__/processor.spec.js +1 -1
- package/templates/stream_depth/typescript/__tests__/processor.spec.ts +1 -1
- package/templates/stream_time/javascript/__tests__/processor.spec.js +1 -1
- package/templates/stream_time/typescript/__tests__/processor.spec.ts +1 -1
- package/templates/task/javascript/__tests__/processor.spec.js +1 -1
- package/templates/task/typescript/__tests__/processor.spec.ts +1 -1
- package/templates/ui/javascript/config/jest/setupTests.js +19 -0
- package/templates/ui/javascript/src/App.completion.js +30 -31
- package/templates/ui/javascript/src/App.css +0 -13
- package/templates/ui/javascript/src/App.drilling.js +31 -36
- package/templates/ui/javascript/src/__tests__/App.test.js +27 -2
- package/templates/ui/typescript/config/jest/setupTests.js +19 -0
- package/templates/ui/typescript/src/App.completion.tsx +32 -42
- package/templates/ui/typescript/src/App.css +0 -13
- package/templates/ui/typescript/src/App.drilling.tsx +32 -41
- package/templates/ui/typescript/src/AppSettings.tsx +2 -12
- package/templates/ui/typescript/src/__mocks__/mockData.ts +194 -0
- package/templates/ui/typescript/src/__tests__/App.test.tsx +80 -6
- package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +14 -3
- package/templates/ui/typescript/src/types.ts +618 -0
- package/templates/ui/typescript/tsconfig.json +0 -1
- package/templates/ui/typescript/src/__mocks__/mockAppProps.ts +0 -590
- package/templates/ui/typescript/src/__mocks__/mockAppSettingsProps.ts +0 -290
package/README.md
CHANGED
|
@@ -182,6 +182,7 @@ Options:
|
|
|
182
182
|
--silent [boolean] Only log result of the operation (default: false)
|
|
183
183
|
--remove-on-success App package (.zip) will not be deleted after upload (default: true)
|
|
184
184
|
--remove-existing [boolean] If package.json version is already taken - remove the previously published package and upload a new one (default: false)
|
|
185
|
+
--author [string] Author name for the audit
|
|
185
186
|
```
|
|
186
187
|
|
|
187
188
|
### Examples
|
|
@@ -209,3 +210,9 @@ create-corva-app release test-app --bump-version=patch
|
|
|
209
210
|
```sh
|
|
210
211
|
create-corva-app release test-app --bump-version=4.2.0
|
|
211
212
|
```
|
|
213
|
+
|
|
214
|
+
#### Make a release with author option(by default it will use your GitHub username)
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
create-corva-app release test-app --author=MyName
|
|
218
|
+
```
|
package/bin/create-corva-app.cjs
CHANGED
|
@@ -7,18 +7,13 @@ const originalCwd = process.cwd();
|
|
|
7
7
|
|
|
8
8
|
process.chdir(__dirname);
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
.slice(2)
|
|
12
|
-
|
|
13
|
-
.concat(['--original-cwd', originalCwd])
|
|
14
|
-
// leave spaces in place for arguments
|
|
15
|
-
.map((a) => (a.includes(' ') ? `"${a}"` : a));
|
|
16
|
-
|
|
17
|
-
const args = ['--no-warnings', '--experimental-json-modules', 'cca.js'].concat(preparedOriginalArgs);
|
|
10
|
+
const args = ['--no-warnings', '--experimental-json-modules', 'cca.js']
|
|
11
|
+
.concat(process.argv.slice(2))
|
|
12
|
+
.concat(['--original-cwd', originalCwd]);
|
|
18
13
|
|
|
19
14
|
const { signal, status, error } = spawnSync(cmd, args, {
|
|
20
15
|
stdio: 'inherit',
|
|
21
|
-
shell:
|
|
16
|
+
shell: false,
|
|
22
17
|
});
|
|
23
18
|
|
|
24
19
|
if (signal) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { bumpVersionOption } from '../options/bump-version.js';
|
|
3
|
+
import { silentOption } from '../options/silent.js';
|
|
4
|
+
import { envOption } from '../options/env.js';
|
|
5
|
+
import { apiKeyOption } from '../options/api-key.js';
|
|
6
|
+
import { appKeyOption } from '../options/app-key.js';
|
|
7
|
+
import { originalCwdOption } from '../options/original-cwd.js';
|
|
8
|
+
import { ensureBumpVersion } from '../helpers/cli-version.js';
|
|
9
|
+
import { runFlow } from '../flow.js';
|
|
10
|
+
import { getRealWorkingDir } from '../helpers/commands.js';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { ERROR_ICON } from '../constants/messages.js';
|
|
13
|
+
import { BUILD_RELEASE_PAAS_FLOW } from '../flows/build-release.js';
|
|
14
|
+
|
|
15
|
+
export const buildReleasePaasCommand = new Command('build-release')
|
|
16
|
+
.description("Build & release app to environments that don't have a packager")
|
|
17
|
+
.argument('<project-directory>', 'Project directory to work with')
|
|
18
|
+
.argument(
|
|
19
|
+
'[environment-api-url]',
|
|
20
|
+
'(Optional) API URL for environment to upload to. You have to have the correct auth token for the given environment',
|
|
21
|
+
)
|
|
22
|
+
.addOption(bumpVersionOption)
|
|
23
|
+
.addOption(silentOption)
|
|
24
|
+
.addOption(envOption)
|
|
25
|
+
.addOption(apiKeyOption)
|
|
26
|
+
.addOption(appKeyOption)
|
|
27
|
+
.addOption(originalCwdOption)
|
|
28
|
+
.addOption(new Option('--notes [string]', 'Add custom notes to published app'))
|
|
29
|
+
.addOption(new Option('--label [string]', 'Put a label on the release').choices(['DEV', 'BETA', 'PROD']))
|
|
30
|
+
.addOption(new Option('--remove-on-fail [boolean]', 'Remove release if it fails during deployment').default(false))
|
|
31
|
+
.addOption(
|
|
32
|
+
new Option('--remove-on-success [boolean]', 'App package (.zip) will not be deleted after upload').default(true),
|
|
33
|
+
)
|
|
34
|
+
.addOption(
|
|
35
|
+
new Option(
|
|
36
|
+
'--remove-existing [boolean]',
|
|
37
|
+
'If package version is already taken - remove the previously published package and upload a new one',
|
|
38
|
+
).default(false),
|
|
39
|
+
)
|
|
40
|
+
.addOption(new Option('--author [string]', 'Author name for the audit'))
|
|
41
|
+
.action(async (dirName, envApiUrl, options) => {
|
|
42
|
+
// if author is present in CLI, save it to process.env
|
|
43
|
+
if (options.author) {
|
|
44
|
+
process.env.githubUsername = options.author;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
48
|
+
|
|
49
|
+
await runFlow(BUILD_RELEASE_PAAS_FLOW, {
|
|
50
|
+
dirName: getRealWorkingDir(dirName, options),
|
|
51
|
+
patterns: [],
|
|
52
|
+
envApiUrl,
|
|
53
|
+
options,
|
|
54
|
+
});
|
|
55
|
+
})
|
|
56
|
+
.showHelpAfterError()
|
|
57
|
+
.showSuggestionAfterError(true)
|
|
58
|
+
.configureOutput({
|
|
59
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
60
|
+
});
|
package/lib/commands/release.js
CHANGED
|
@@ -36,7 +36,13 @@ export const releaseCommand = new Command('release')
|
|
|
36
36
|
).default(false),
|
|
37
37
|
)
|
|
38
38
|
// .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
|
|
39
|
+
.addOption(new Option('--author [string]', 'Author name for the audit'))
|
|
39
40
|
.action(async (dirName, patterns, options) => {
|
|
41
|
+
// if author is present in CLI, save it to process.env
|
|
42
|
+
if (options.author) {
|
|
43
|
+
process.env.githubUsername = options.author;
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
41
47
|
|
|
42
48
|
await runFlow(RELEASE_FLOW, {
|
package/lib/constants/cli.js
CHANGED
|
@@ -2,10 +2,16 @@ export const APP_RUNTIMES = {
|
|
|
2
2
|
UI: 'ui',
|
|
3
3
|
// NODE12: 'nodejs12.x',
|
|
4
4
|
// NODE14: 'nodejs14.x',
|
|
5
|
-
NODE16: 'nodejs16.x',
|
|
5
|
+
// NODE16: 'nodejs16.x',
|
|
6
6
|
NODE18: 'nodejs18.x',
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
NODE20: 'nodejs20.x',
|
|
8
|
+
NODE22: 'nodejs22.x',
|
|
9
|
+
// PYTHON3_8: 'python3.8',
|
|
10
|
+
// PYTHON3_9: 'python3.9',
|
|
11
|
+
// PYTHON3_10: 'python3.10',
|
|
12
|
+
PYTHON3_11: 'python3.11',
|
|
13
|
+
PYTHON3_12: 'python3.12',
|
|
14
|
+
PYTHON3_13: 'python3.13',
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
export const TEMPLATE_TYPES = {
|
|
@@ -22,3 +28,7 @@ export const APP_TYPES = {
|
|
|
22
28
|
STREAM: 'stream',
|
|
23
29
|
TASK: 'task',
|
|
24
30
|
};
|
|
31
|
+
|
|
32
|
+
export const APP_EXTENSIONS = {
|
|
33
|
+
CORVA: 'corva',
|
|
34
|
+
};
|
package/lib/constants/package.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import { APP_EXTENSIONS } from './cli.js';
|
|
2
3
|
|
|
3
4
|
const uiDependencies = {
|
|
4
5
|
'@corva/ui': 'latest',
|
|
@@ -37,8 +38,11 @@ const jsUiDevDependencies = {
|
|
|
37
38
|
const tsUiDevDependencies = {
|
|
38
39
|
...jsUiDevDependencies,
|
|
39
40
|
'@tsconfig/create-react-app': '1.0.2',
|
|
41
|
+
'@types/lodash': '4.17.5',
|
|
40
42
|
'@types/material-ui': '0.21.9',
|
|
41
|
-
'@types/
|
|
43
|
+
'@types/minimatch': '3.0.5',
|
|
44
|
+
'@types/mime': '3.0.1',
|
|
45
|
+
'@types/node': '18.19.47',
|
|
42
46
|
'@types/react': '^17.0.22',
|
|
43
47
|
'@types/react-dom': '^17.0.9',
|
|
44
48
|
'@types/jest': '^27.0.1',
|
|
@@ -52,11 +56,15 @@ const corvaUiExtension = {
|
|
|
52
56
|
scripts: {
|
|
53
57
|
prepare: 'husky install',
|
|
54
58
|
},
|
|
59
|
+
dependencies: {
|
|
60
|
+
'@tanstack/react-query': '4.35.3',
|
|
61
|
+
},
|
|
55
62
|
devDependencies: {
|
|
56
63
|
'@commitlint/cli': '^17.0.0',
|
|
57
64
|
'@commitlint/config-conventional': '^17.0.0',
|
|
58
65
|
'husky': '^8.0.0',
|
|
59
66
|
'lint-staged': '^13.0.0',
|
|
67
|
+
'@tanstack/eslint-plugin-query': '4.34.1',
|
|
60
68
|
},
|
|
61
69
|
};
|
|
62
70
|
|
|
@@ -67,7 +75,7 @@ function applyUiExtension(packageJson, extensionNames) {
|
|
|
67
75
|
|
|
68
76
|
const extensions = extensionNames
|
|
69
77
|
.map((extensionName) => {
|
|
70
|
-
if (extensionName ===
|
|
78
|
+
if (extensionName === APP_EXTENSIONS.CORVA) {
|
|
71
79
|
return corvaUiExtension;
|
|
72
80
|
}
|
|
73
81
|
|
|
@@ -135,6 +143,10 @@ const uiPackage = {
|
|
|
135
143
|
const tsUiPackage = {
|
|
136
144
|
...uiPackage,
|
|
137
145
|
devDependencies: tsUiDevDependencies,
|
|
146
|
+
// todo: temporary solution, ref https://github.com/oppia/oppia/issues/22283#issuecomment-2756641371
|
|
147
|
+
resolutions: {
|
|
148
|
+
'@types/babel__traverse': '7.20.6',
|
|
149
|
+
},
|
|
138
150
|
};
|
|
139
151
|
|
|
140
152
|
const nodeNpmScripts = {
|
|
@@ -151,17 +163,17 @@ const nodeDependencies = {
|
|
|
151
163
|
|
|
152
164
|
const nodeDevDependencies = {
|
|
153
165
|
'@corva/eslint-config-node': '^5.1.1',
|
|
154
|
-
'jest': '^
|
|
166
|
+
'jest': '^29.7.0',
|
|
155
167
|
'dotenv': '^16.0.3',
|
|
156
168
|
'eslint': '^8.2.0',
|
|
157
169
|
'prettier': '^2.0.0',
|
|
158
|
-
'typescript': '^
|
|
170
|
+
'typescript': '^5.5.4',
|
|
159
171
|
};
|
|
160
172
|
|
|
161
173
|
const nodeTsDevDependencies = {
|
|
162
174
|
...nodeDevDependencies,
|
|
163
|
-
'@types/jest': '^
|
|
164
|
-
'ts-jest': '^
|
|
175
|
+
'@types/jest': '^29.5.12',
|
|
176
|
+
'ts-jest': '^29.2.4',
|
|
165
177
|
};
|
|
166
178
|
|
|
167
179
|
const nodeYarnScripts = {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PREPARE_FLOW } from './prepare.js';
|
|
2
|
+
import { SETUP_API_CLIENT_STEP } from './steps/release/get-config.js';
|
|
3
|
+
import { RELEASE_PREPARE_DATA_STEP } from './steps/release/prepare-data.js';
|
|
4
|
+
import { PREPARE_FILES_BEFORE_ZIP_STEP } from './steps/zip-prepare.js';
|
|
5
|
+
import { CREATE_ARCHIVE_STEP } from './steps/zip-create-archive.js';
|
|
6
|
+
import { CLEANUP_STEP } from './steps/zip-cleanup.js';
|
|
7
|
+
import { UPLOAD_ZIP_TO_CORVA_STEP } from './steps/release/upload-zip-to-corva.js';
|
|
8
|
+
import { PUBLISH_PACKAGE_STEP } from './steps/release/publish.js';
|
|
9
|
+
import { ADD_LABEL_STEP } from './steps/release/add-label.js';
|
|
10
|
+
import { ADD_NOTES_STEP } from './steps/release/add-notes.js';
|
|
11
|
+
import { BUILD_STEP } from './steps/build.js';
|
|
12
|
+
import { RESOLVE_BUILT_FILES_FOR_ZIP_STEP } from './steps/resolve-built-files-for-zip.js';
|
|
13
|
+
|
|
14
|
+
export const BUILD_RELEASE_PAAS_FLOW = {
|
|
15
|
+
name: 'build-release-paas',
|
|
16
|
+
steps: [
|
|
17
|
+
PREPARE_FLOW,
|
|
18
|
+
SETUP_API_CLIENT_STEP,
|
|
19
|
+
RELEASE_PREPARE_DATA_STEP,
|
|
20
|
+
BUILD_STEP,
|
|
21
|
+
RESOLVE_BUILT_FILES_FOR_ZIP_STEP,
|
|
22
|
+
PREPARE_FILES_BEFORE_ZIP_STEP,
|
|
23
|
+
CREATE_ARCHIVE_STEP,
|
|
24
|
+
CLEANUP_STEP,
|
|
25
|
+
// eslint-disable-next-line new-cap
|
|
26
|
+
UPLOAD_ZIP_TO_CORVA_STEP({ prebuilt: true }),
|
|
27
|
+
PUBLISH_PACKAGE_STEP,
|
|
28
|
+
ADD_LABEL_STEP,
|
|
29
|
+
ADD_NOTES_STEP,
|
|
30
|
+
],
|
|
31
|
+
};
|
package/lib/flows/lib/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import debugFn from 'debug';
|
|
2
2
|
import got from 'got';
|
|
3
3
|
import { StepError } from './step-error.js';
|
|
4
|
-
import {
|
|
4
|
+
import { DELETE_CACHE_BEHAVIOR, OVERRIDE_CACHE_BEHAVIOR } from './../../constants/cache.js';
|
|
5
5
|
|
|
6
6
|
const debug = debugFn('cca:api');
|
|
7
7
|
|
|
@@ -15,8 +15,8 @@ export class Api {
|
|
|
15
15
|
*/
|
|
16
16
|
#api;
|
|
17
17
|
|
|
18
|
-
constructor(envName, apiKey, authToken = null) {
|
|
19
|
-
const prefixUrl = `https://api${envName === 'production' ? '' : `.${envName}`}.corva.ai`;
|
|
18
|
+
constructor(envName, apiKey, authToken = null, { envApiUrl } = {}) {
|
|
19
|
+
const prefixUrl = envApiUrl || `https://api${envName === 'production' ? '' : `.${envName}`}.corva.ai`;
|
|
20
20
|
|
|
21
21
|
this.#api = got.extend({
|
|
22
22
|
prefixUrl,
|
|
@@ -42,21 +42,15 @@ export class Api {
|
|
|
42
42
|
* @returns {object}
|
|
43
43
|
*/
|
|
44
44
|
async getAppByKey(appKey) {
|
|
45
|
-
const { data } = await this.#api
|
|
46
|
-
.get('v2/apps', {
|
|
47
|
-
searchParams: { per_page: 2, search: appKey },
|
|
48
|
-
})
|
|
49
|
-
.json();
|
|
45
|
+
const { data } = await this.#api.get(`v2/apps/${appKey}`).json();
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!app) {
|
|
47
|
+
if (!data) {
|
|
54
48
|
throw new StepError(
|
|
55
49
|
`App with key - ${appKey}, does not exist.\nThe key search is case-sensitive. You might need to update the app key in your app to exactly match the key.`,
|
|
56
50
|
);
|
|
57
51
|
}
|
|
58
52
|
|
|
59
|
-
return
|
|
53
|
+
return data;
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
/**
|
|
@@ -11,7 +11,7 @@ const SCHEDULER_MAPPING = [SCHEDULER_TYPE_DATA_TIME, SCHEDULER_TYPE_DEPTH, SCHED
|
|
|
11
11
|
{},
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
-
const NODE_RUNTIMES = [APP_RUNTIMES.
|
|
14
|
+
const NODE_RUNTIMES = [APP_RUNTIMES.NODE18, APP_RUNTIMES.NODE20, APP_RUNTIMES.NODE22];
|
|
15
15
|
|
|
16
16
|
export class Manifest {
|
|
17
17
|
constructor(manifest) {
|
package/lib/flows/release.js
CHANGED
|
@@ -16,7 +16,8 @@ export const RELEASE_FLOW = {
|
|
|
16
16
|
SETUP_API_CLIENT_STEP,
|
|
17
17
|
RELEASE_PREPARE_DATA_STEP,
|
|
18
18
|
ZIP_SIMPLE_FLOW,
|
|
19
|
-
|
|
19
|
+
// eslint-disable-next-line new-cap
|
|
20
|
+
UPLOAD_ZIP_TO_CORVA_STEP(),
|
|
20
21
|
WAIT_FOR_BUILD_FINISH_STEP,
|
|
21
22
|
REMOVE_FAILED_UPLOAD_STEP,
|
|
22
23
|
PUBLISH_PACKAGE_STEP,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StepError } from '../lib/step-error.js';
|
|
2
|
+
import util from 'util';
|
|
3
|
+
import ChildProcess from 'child_process';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
const exec = util.promisify(ChildProcess.exec);
|
|
7
|
+
|
|
8
|
+
export const BUILD_STEP = {
|
|
9
|
+
message: 'Building...',
|
|
10
|
+
fn: async ({ dirName }) => {
|
|
11
|
+
const currentCWD = process.cwd();
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
process.chdir(dirName);
|
|
15
|
+
|
|
16
|
+
const command = fs.existsSync('./yarn.lock') ? 'yarn' : 'npm';
|
|
17
|
+
|
|
18
|
+
await exec(`${command} webpack --config=./config-overrides.js --mode production`);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw new StepError(`Application build failed! ${e.stderr || e.message || 'Unknown error'}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
process.chdir(currentCWD);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -18,7 +18,7 @@ async function getVarsFromDotEnv({ dirName }) {
|
|
|
18
18
|
|
|
19
19
|
export const SETUP_API_CLIENT_STEP = {
|
|
20
20
|
message: RELEASE.getAuthToken,
|
|
21
|
-
fn: async ({ dirName, options: { apiKey, env } }) => {
|
|
21
|
+
fn: async ({ dirName, envApiUrl, options: { apiKey, env } }) => {
|
|
22
22
|
const parsedEnv = await getVarsFromDotEnv({ dirName });
|
|
23
23
|
|
|
24
24
|
const CORVA_API_ENV = env || parsedEnv.CORVA_API_ENV || process.env.CORVA_API_ENV || 'production';
|
|
@@ -29,7 +29,7 @@ export const SETUP_API_CLIENT_STEP = {
|
|
|
29
29
|
throw new StepError(RELEASE.getAuthTokenError);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const api = new Api(CORVA_API_ENV, API_KEY, AUTH_TOKEN);
|
|
32
|
+
const api = new Api(CORVA_API_ENV, API_KEY, AUTH_TOKEN, { envApiUrl });
|
|
33
33
|
const notification = new Notification(CORVA_API_ENV);
|
|
34
34
|
|
|
35
35
|
return {
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
1
3
|
export const RELEASE_PREPARE_DATA_STEP = {
|
|
2
4
|
message: 'Preparing data...',
|
|
3
5
|
async fn({ api, manifest, options }) {
|
|
4
6
|
const appKey = options.appKey || manifest.manifest.application.key;
|
|
5
|
-
const app = await api.getAppByKey(appKey);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
try {
|
|
9
|
+
const app = await api.getAppByKey(appKey);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
appId: app.id,
|
|
13
|
+
appKey,
|
|
14
|
+
};
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.log(chalk.bold.red(`\n${e.message}`));
|
|
17
|
+
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
11
20
|
},
|
|
12
21
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs';
|
|
3
4
|
import { createReadStream } from 'node:fs';
|
|
4
5
|
import { resolve } from 'node:path';
|
|
5
6
|
import { RELEASE } from '../../../constants/messages.js';
|
|
6
7
|
import { StepError } from '../../lib/step-error.js';
|
|
7
8
|
import { logger } from '../../../helpers/logger.js';
|
|
9
|
+
import { execSync } from 'node:child_process';
|
|
8
10
|
|
|
9
11
|
async function deleteAppPackage({ api, appId, appPkgVersion }) {
|
|
10
12
|
const appPackages = await api.getAppPackages(appId);
|
|
@@ -23,7 +25,71 @@ async function deleteAppPackage({ api, appId, appPkgVersion }) {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
function getRealAuthorFromGithubEvent() {
|
|
29
|
+
if (!process.env.GITHUB_EVENT_PATH) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'));
|
|
35
|
+
|
|
36
|
+
// For push-event
|
|
37
|
+
if (event?.pusher?.name) {
|
|
38
|
+
return event.pusher.name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// For PR event
|
|
42
|
+
if (event?.pull_request?.user?.login) {
|
|
43
|
+
return event.pull_request.user.login;
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// Catch error in case json file is invalid or absent
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getGithubUsernameActor() {
|
|
54
|
+
// If option passed --author – we firstly take it
|
|
55
|
+
if (process.env.githubUsername) {
|
|
56
|
+
return process.env.githubUsername;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// If no --author passed, try use GITHUB_ACTOR
|
|
60
|
+
const actor = process.env.GITHUB_ACTOR;
|
|
61
|
+
|
|
62
|
+
if (actor && actor !== 'github-actions[bot]') {
|
|
63
|
+
return actor;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If actor == github-actions[bot], let's try to get a real user
|
|
67
|
+
const realAuthor = getRealAuthorFromGithubEvent();
|
|
68
|
+
|
|
69
|
+
if (realAuthor) {
|
|
70
|
+
return realAuthor;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getGitConfigUsername() {
|
|
77
|
+
try {
|
|
78
|
+
let username = execSync('git config user.name').toString().trim();
|
|
79
|
+
|
|
80
|
+
if (!username) {
|
|
81
|
+
username = execSync('git config --global user.name').toString().trim();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return username || null;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
logger.log('Unable to fetch git config username:', error.message);
|
|
87
|
+
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const UPLOAD_ZIP_TO_CORVA_STEP = (uploadPackagesParams) => ({
|
|
27
93
|
message: RELEASE.uploadApp,
|
|
28
94
|
/**
|
|
29
95
|
*
|
|
@@ -36,6 +102,18 @@ export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
|
36
102
|
|
|
37
103
|
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'package.zip');
|
|
38
104
|
|
|
105
|
+
if (uploadPackagesParams?.prebuilt) {
|
|
106
|
+
form.append('prebuilt', 'true');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let githubUsername = getGithubUsernameActor();
|
|
110
|
+
|
|
111
|
+
if (!githubUsername) {
|
|
112
|
+
githubUsername = getGitConfigUsername();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
form.append('github_username', githubUsername);
|
|
116
|
+
|
|
39
117
|
const { id: packageId, isDeletedDueToLimit } = await api.uploadPackages(appKey, form);
|
|
40
118
|
|
|
41
119
|
if (isDeletedDueToLimit) {
|
|
@@ -59,4 +137,4 @@ export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
|
59
137
|
throw error;
|
|
60
138
|
}
|
|
61
139
|
},
|
|
62
|
-
};
|
|
140
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { prepareUiAppFilesForZip, transformPatternsIntoFileNames } from './zip-file-list-resolve.js';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { StepError } from '../lib/step-error.js';
|
|
4
|
+
|
|
5
|
+
export const RESOLVE_BUILT_FILES_FOR_ZIP_STEP = {
|
|
6
|
+
message: 'Resolving files list...',
|
|
7
|
+
fn: async (context) => {
|
|
8
|
+
const { manifest, dirName } = context;
|
|
9
|
+
const files = [];
|
|
10
|
+
|
|
11
|
+
if (manifest.isUi()) {
|
|
12
|
+
const data = await prepareUiAppFilesForZip(files, context);
|
|
13
|
+
|
|
14
|
+
const regex = new RegExp(`^dist${path.sep}`);
|
|
15
|
+
|
|
16
|
+
// Manifest is already accounted for (with possible changes) in prepareUiAppFilesForZip
|
|
17
|
+
const builtFiles = (await transformPatternsIntoFileNames(dirName, ['dist/**/*'], ['dist/manifest.json'])).map(
|
|
18
|
+
(filename) => ({
|
|
19
|
+
// Source file path
|
|
20
|
+
path: path.resolve(dirName, filename),
|
|
21
|
+
// Target file path
|
|
22
|
+
name: filename.replace(regex, ''),
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
data.itemsToZip.push('yarn.lock', ...builtFiles);
|
|
27
|
+
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new StepError(
|
|
32
|
+
`Unsupported runtime: ${manifest.runtime}. Currently, this command supports the following app types: "ui"`,
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -9,11 +9,10 @@ import { getIncreasedVersion } from '../../helpers/cli-version.js';
|
|
|
9
9
|
import { generateRandomString } from '../../helpers/utils.js';
|
|
10
10
|
import { loadJson } from '../lib/json.js';
|
|
11
11
|
import { StepError } from '../lib/step-error.js';
|
|
12
|
+
import debugFn from 'debug';
|
|
12
13
|
|
|
13
14
|
const glob = promisify(Glob);
|
|
14
15
|
|
|
15
|
-
import debugFn from 'debug';
|
|
16
|
-
|
|
17
16
|
const debug = debugFn('cca:flow:zip:resolve');
|
|
18
17
|
|
|
19
18
|
const uniqueValues = (array) => Array.from(new Set(array));
|
|
@@ -40,7 +39,7 @@ export const FILE_LIST_RESOLVE_STEP = {
|
|
|
40
39
|
},
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
const transformPatternsIntoFileNames = async (dirName, patterns, ignoredFiles = []) => {
|
|
42
|
+
export const transformPatternsIntoFileNames = async (dirName, patterns, ignoredFiles = []) => {
|
|
44
43
|
const filesFromPatterns = [];
|
|
45
44
|
|
|
46
45
|
for (const pattern of patterns) {
|
|
@@ -68,14 +67,7 @@ const transformPatternsIntoFileNames = async (dirName, patterns, ignoredFiles =
|
|
|
68
67
|
return filesFromPatterns;
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* @param {string[]} itemsToZip
|
|
74
|
-
* @param {object} param1
|
|
75
|
-
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, manifest, appKey }) => {
|
|
70
|
+
export const prepareUiAppFilesForZip = async (itemsToZip, { options, pkg, dirName, manifest, appKey }) => {
|
|
79
71
|
const version = await getIncreasedVersion(pkg.version, options);
|
|
80
72
|
const randomSuffix = generateRandomString(); // Random suffix is needed to not cause a conflict when we call 2 parallel commands at the same time.
|
|
81
73
|
const zipFileName = `${manifest.unix_name}-${version}-${randomSuffix}.zip`;
|
|
@@ -109,20 +101,6 @@ const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, m
|
|
|
109
101
|
|
|
110
102
|
const itemsToRemove = [tmpPackageForSourceName];
|
|
111
103
|
|
|
112
|
-
itemsToZip.push(
|
|
113
|
-
'manifest.json',
|
|
114
|
-
'config-overrides.js',
|
|
115
|
-
'tsconfig.json',
|
|
116
|
-
'.npmrc',
|
|
117
|
-
'.nvmrc',
|
|
118
|
-
'yarn.lock',
|
|
119
|
-
{
|
|
120
|
-
path: resolve(dirName, tmpPackageForSourceName),
|
|
121
|
-
name: 'package.json',
|
|
122
|
-
},
|
|
123
|
-
...(await transformPatternsIntoFileNames(dirName, ['src/**/*'], options.ignoredFiles)),
|
|
124
|
-
);
|
|
125
|
-
|
|
126
104
|
if (options.appKey) {
|
|
127
105
|
/**
|
|
128
106
|
* Both manifest.json appKey in zip and the provided
|
|
@@ -143,8 +121,50 @@ const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, m
|
|
|
143
121
|
path: resolve(dirName, tmpManifestForSourceName),
|
|
144
122
|
name: 'manifest.json',
|
|
145
123
|
});
|
|
124
|
+
} else {
|
|
125
|
+
itemsToZip.push('manifest.json');
|
|
146
126
|
}
|
|
147
127
|
|
|
128
|
+
return {
|
|
129
|
+
zipFileName,
|
|
130
|
+
itemsToZip: [
|
|
131
|
+
...itemsToZip,
|
|
132
|
+
{
|
|
133
|
+
path: resolve(dirName, tmpPackageForSourceName),
|
|
134
|
+
name: 'package.json',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
itemsToSave,
|
|
138
|
+
itemsToRemove,
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param {string[]} itemsToZipBase
|
|
145
|
+
* @param {object} param1
|
|
146
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
147
|
+
* @returns
|
|
148
|
+
*/
|
|
149
|
+
const resolveDataToZipUiApp = async (itemsToZipBase = [], { options, pkg, dirName, manifest, appKey }) => {
|
|
150
|
+
const { zipFileName, itemsToZip, itemsToSave, itemsToRemove } = await prepareUiAppFilesForZip(itemsToZipBase, {
|
|
151
|
+
options,
|
|
152
|
+
pkg,
|
|
153
|
+
dirName,
|
|
154
|
+
manifest,
|
|
155
|
+
appKey,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
itemsToZip.push(
|
|
159
|
+
'config-overrides.js',
|
|
160
|
+
'tsconfig.json',
|
|
161
|
+
'.npmrc',
|
|
162
|
+
'.nvmrc',
|
|
163
|
+
'yarn.lock',
|
|
164
|
+
...(await transformPatternsIntoFileNames(dirName, ['src/**/*'], options.ignoredFiles)),
|
|
165
|
+
...(await transformPatternsIntoFileNames(dirName, ['config/**/*'], options.ignoredFiles)),
|
|
166
|
+
);
|
|
167
|
+
|
|
148
168
|
return {
|
|
149
169
|
zipFileName,
|
|
150
170
|
itemsToZip,
|