@corva/create-app 0.28.0-0 → 0.28.0-3
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 +160 -17
- package/bin/create-corva-app.js +5 -0
- package/lib/app.js +9 -0
- package/lib/bump-version.option.js +29 -0
- package/{constants → lib/constants}/cli.js +1 -0
- package/{constants → lib/constants}/manifest.js +5 -13
- package/lib/constants/messages.js +21 -0
- package/lib/constants/package.js +161 -0
- package/lib/flow.js +46 -0
- package/lib/flows/lib/create-zip-archive.js +77 -0
- package/lib/flows/lib/json.js +28 -0
- package/lib/flows/lib/manifest.js +47 -0
- package/lib/flows/lib/step-error.js +12 -0
- package/lib/flows/prepare.js +8 -0
- package/lib/flows/release.js +18 -0
- package/lib/flows/steps/prepare-load-app-files.js +18 -0
- package/lib/flows/steps/release-get-app-key.js +16 -0
- package/lib/flows/steps/release-get-config.js +30 -0
- package/lib/flows/steps/release-upload-zip-to-corva.js +34 -0
- package/lib/flows/steps/zip-cleanup.js +17 -0
- package/lib/flows/steps/zip-create-archive.js +15 -0
- package/lib/flows/steps/zip-file-list-resolve.js +185 -0
- package/lib/flows/steps/zip-prepare.js +21 -0
- package/lib/flows/steps/zip.js +15 -0
- package/lib/flows/zip-simple.js +8 -0
- package/lib/flows/zip.js +9 -0
- package/{helpers → lib/helpers}/manifest.js +11 -13
- package/lib/helpers/resolve-app-runtime.js +29 -0
- package/{helpers → lib/helpers}/utils.js +17 -17
- package/{helpers → lib/helpers}/versioning.js +0 -0
- package/lib/index.js +502 -0
- package/{scripts → lib/scripts}/utils/version.js +49 -26
- package/package.json +13 -8
- package/{template/scheduler/node → templates/javascript/scheduler}/README.md +0 -0
- package/{template/scheduler/node → templates/javascript/scheduler}/__test__/processor.test.js +0 -0
- package/{template/scheduler/node → templates/javascript/scheduler}/index.js +0 -0
- package/{template/scheduler/node → templates/javascript/scheduler}/src/processor.js +0 -0
- package/{template/stream/node → templates/javascript/stream}/README.md +0 -0
- package/{template/stream/node → templates/javascript/stream}/__test__/processor.test.js +0 -0
- package/{template/stream/node → templates/javascript/stream}/index.js +0 -0
- package/{template/stream/node → templates/javascript/stream}/src/processor.js +0 -0
- package/{template/task/node → templates/javascript/task}/README.md +0 -0
- package/{template/task/node → templates/javascript/task}/__test__/processor.test.js +0 -0
- package/{template/task/node → templates/javascript/task}/index.js +0 -0
- package/{template/task/node → templates/javascript/task}/src/processor.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/.env +0 -0
- package/{template/ui/js → templates/javascript/ui}/.env.sample +0 -0
- package/{template/ui/js → templates/javascript/ui}/.eslintrc +0 -0
- package/{template/ui/js → templates/javascript/ui}/.prettierrc +0 -0
- package/{template/ui/js → templates/javascript/ui}/README.md +0 -0
- package/{template/ui/js → templates/javascript/ui}/config-overrides.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/gitignore +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/App.css +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/App.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/AppSettings.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/assets/logo.svg +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/constants.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/index.js +0 -0
- package/templates/python/scheduler/README.md +31 -0
- package/{template/scheduler/python → templates/python/scheduler}/lambda_function.py +0 -0
- package/{template/scheduler/python → templates/python/scheduler}/test/__init__.py +0 -0
- package/{template/scheduler/python → templates/python/scheduler}/test/app_test.py +0 -0
- package/templates/python/stream/README.md +31 -0
- package/{template/stream/python → templates/python/stream}/lambda_function.py +0 -0
- package/{template/stream/python → templates/python/stream}/test/__init__.py +0 -0
- package/{template/stream/python → templates/python/stream}/test/app_test.py +0 -0
- package/templates/python/task/README.md +31 -0
- package/{template/task/python → templates/python/task}/lambda_function.py +0 -0
- package/{template/task/python → templates/python/task}/test/__init__.py +0 -0
- package/{template/task/python → templates/python/task}/test/app_test.py +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/README.md +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/__test__/processor.spec.ts +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/index.ts +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/lib/processor.ts +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/README.md +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/__test__/processor.spec.ts +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/index.ts +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/lib/processor.ts +0 -0
- package/{template/task/node-ts → templates/typescript/task}/README.md +0 -0
- package/{template/task/node-ts → templates/typescript/task}/__test__/processor.spec.ts +0 -0
- package/{template/task/node-ts → templates/typescript/task}/index.ts +0 -0
- package/{template/task/node-ts → templates/typescript/task}/src/processor.ts +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.env +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.env.sample +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.eslintrc +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.prettierrc +0 -0
- package/{template/ui/ts → templates/typescript/ui}/README.md +0 -0
- package/{template/ui/ts → templates/typescript/ui}/config-overrides.js +0 -0
- package/{template/ui/ts → templates/typescript/ui}/gitignore +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/App.css +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/App.tsx +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/AppSettings.tsx +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/assets/logo.svg +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/constants.ts +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/custom.d.ts +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/index.js +0 -0
- package/{template/ui/ts → templates/typescript/ui}/tsconfig.json +0 -0
- package/constants/package.js +0 -50
- package/index.js +0 -386
- package/scripts/ui/index.js +0 -7
- package/scripts/ui/releaseAppZip.js +0 -91
- package/scripts/ui/zipAppSource.js +0 -103
- package/template/scheduler/node/gitignore +0 -21
- package/template/scheduler/node/package.json +0 -17
- package/template/scheduler/node-ts/gitignore +0 -25
- package/template/scheduler/node-ts/package.json +0 -37
- package/template/scheduler/node-ts/tsconfig.build.json +0 -11
- package/template/scheduler/node-ts/tsconfig.json +0 -34
- package/template/scheduler/python/README.md +0 -19
- package/template/scheduler/python/requirements.txt +0 -2
- package/template/stream/node/gitignore +0 -21
- package/template/stream/node/package.json +0 -17
- package/template/stream/node-ts/gitignore +0 -25
- package/template/stream/node-ts/package.json +0 -37
- package/template/stream/node-ts/tsconfig.build.json +0 -11
- package/template/stream/node-ts/tsconfig.json +0 -34
- package/template/stream/python/README.md +0 -19
- package/template/stream/python/requirements.txt +0 -2
- package/template/task/node/gitignore +0 -21
- package/template/task/node/package.json +0 -17
- package/template/task/node-ts/gitignore +0 -25
- package/template/task/node-ts/package.json +0 -37
- package/template/task/node-ts/tsconfig.build.json +0 -11
- package/template/task/node-ts/tsconfig.json +0 -34
- package/template/task/python/README.md +0 -19
- package/template/task/python/requirements.txt +0 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { APP_TYPES, APP_RUNTIMES, TEMPLATE_TYPES } = require('../../constants/cli');
|
|
2
|
+
|
|
3
|
+
const NODE_RUNTIMES = [APP_RUNTIMES.NODE12, APP_RUNTIMES.NODE14];
|
|
4
|
+
|
|
5
|
+
class Manifest {
|
|
6
|
+
constructor(manifest) {
|
|
7
|
+
this.manifest = manifest;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get runtime() {
|
|
11
|
+
return this.manifest.settings.runtime;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get type() {
|
|
15
|
+
return this.manifest.application.type
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get name() {
|
|
19
|
+
return this.manifest.application.name
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get description() {
|
|
23
|
+
return this.manifest.application.description
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
isNode() {
|
|
27
|
+
return NODE_RUNTIMES.includes(this.manifest.settings.runtime);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
isUi() {
|
|
31
|
+
return this.manifest.application.type === APP_TYPES.UI;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
isJs() {
|
|
35
|
+
return this.isUi() || this.isNode();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
isPython() {
|
|
39
|
+
return this.manifest.settings.runtime === APP_RUNTIMES.PYTHON3;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
isScheduler() {
|
|
43
|
+
return this.manifest.application.type === APP_TYPES.SCHEDULER;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = { Manifest };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { PREPARE_FLOW } = require('./prepare');
|
|
2
|
+
const { GET_APP_KEY_STEP } = require('./steps/release-get-app-key');
|
|
3
|
+
const { GET_RELEASE_CONFIG_STEP } = require('./steps/release-get-config');
|
|
4
|
+
const { UPLOAD_ZIP_TO_CORVA_STEP } = require('./steps/release-upload-zip-to-corva');
|
|
5
|
+
const { ZIP_SIMPLE_FLOW } = require('./zip-simple');
|
|
6
|
+
|
|
7
|
+
const RELEASE_FLOW = {
|
|
8
|
+
name: 'release',
|
|
9
|
+
steps: [
|
|
10
|
+
PREPARE_FLOW,
|
|
11
|
+
GET_RELEASE_CONFIG_STEP,
|
|
12
|
+
GET_APP_KEY_STEP,
|
|
13
|
+
ZIP_SIMPLE_FLOW,
|
|
14
|
+
UPLOAD_ZIP_TO_CORVA_STEP,
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = { RELEASE_FLOW };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { loadJson } = require('../lib/json');
|
|
2
|
+
const { Manifest } = require('../lib/manifest');
|
|
3
|
+
|
|
4
|
+
const LOAD_APP_FILES_STEP = {
|
|
5
|
+
message: "Loading Corva app's files...",
|
|
6
|
+
async fn(context) {
|
|
7
|
+
const manifest =
|
|
8
|
+
context.manifest || new Manifest(await loadJson(context.dirName, 'manifest.json'));
|
|
9
|
+
const pkg =
|
|
10
|
+
context.package || (manifest.isJs() && (await loadJson(context.dirName, 'package.json')));
|
|
11
|
+
|
|
12
|
+
return { pkg, manifest };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
LOAD_APP_FILES_STEP,
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 };
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
const GET_RELEASE_CONFIG_STEP = {
|
|
8
|
+
message: RELEASE.getAuthToken,
|
|
9
|
+
fn: async ({ dirName }) => {
|
|
10
|
+
const env = await fs.readFile(resolve(dirName, '.env')).catch((e) => {
|
|
11
|
+
if (e.code === 'ENOENT') {
|
|
12
|
+
throw new StepError('Mising .env file', { cause: e });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
throw e;
|
|
16
|
+
});
|
|
17
|
+
const { CORVA_API_ENV, AUTH_TOKEN } = dotenv.parse(env);
|
|
18
|
+
|
|
19
|
+
if (!AUTH_TOKEN) {
|
|
20
|
+
throw new StepError(RELEASE.getAuthTokenError);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
CORVA_API_ENV: CORVA_API_ENV || 'production',
|
|
25
|
+
AUTH_TOKEN,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = { GET_RELEASE_CONFIG_STEP };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { RELEASE } = require('../../constants/messages');
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
const FormData = require('form-data');
|
|
4
|
+
const { resolve } = require('path');
|
|
5
|
+
const { createReadStream } = require('fs');
|
|
6
|
+
const { StepError } = require('../lib/step-error');
|
|
7
|
+
const { get } = require('lodash/fp');
|
|
8
|
+
|
|
9
|
+
const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
10
|
+
message: RELEASE.uploadApp,
|
|
11
|
+
fn: async ({ zipFileName, appKey, CORVA_API_ENV, AUTH_TOKEN, dirName }) => {
|
|
12
|
+
const form = new FormData();
|
|
13
|
+
|
|
14
|
+
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'archive.zip');
|
|
15
|
+
|
|
16
|
+
const baseURL = `https://api${
|
|
17
|
+
CORVA_API_ENV === 'production' ? '' : `.${CORVA_API_ENV}`
|
|
18
|
+
}.corva.ai`;
|
|
19
|
+
const uploadURL = `${baseURL}/v2/apps/${appKey}/packages/upload`;
|
|
20
|
+
|
|
21
|
+
await axios
|
|
22
|
+
.post(uploadURL, form, {
|
|
23
|
+
headers: { ...form.getHeaders(), Authorization: `Bearer ${AUTH_TOKEN}` },
|
|
24
|
+
})
|
|
25
|
+
.catch((e) => {
|
|
26
|
+
throw new StepError(
|
|
27
|
+
`${get('response.data.message', e) || ''} \nPOST: ${uploadURL} failed.`,
|
|
28
|
+
{ cause: e }
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = { UPLOAD_ZIP_TO_CORVA_STEP };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { promises: fs } = require('fs');
|
|
2
|
+
const { resolve } = require('path');
|
|
3
|
+
|
|
4
|
+
const debug = require('debug')('cca:flow:zip:cleanup');
|
|
5
|
+
|
|
6
|
+
const CLEANUP_STEP = {
|
|
7
|
+
message: 'Removing temporary files...',
|
|
8
|
+
fn: async ({ itemsToRemove, dirName }) => {
|
|
9
|
+
for (const item of itemsToRemove) {
|
|
10
|
+
debug('Removing %s', item);
|
|
11
|
+
|
|
12
|
+
await fs.unlink(resolve(dirName, item));
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = { CLEANUP_STEP };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { createZipArchive } = require('../lib/create-zip-archive');
|
|
2
|
+
const debug = require('debug')('cca:flow:zip:archive');
|
|
3
|
+
|
|
4
|
+
const CREATE_ARCHIVE_STEP = {
|
|
5
|
+
message: 'Creating archive...',
|
|
6
|
+
fn: async ({ itemsToZip, zipFileName, dirName }) => {
|
|
7
|
+
debug(`Zipping %d items to %s`, itemsToZip.length, zipFileName);
|
|
8
|
+
|
|
9
|
+
const bytes = await createZipArchive(dirName, zipFileName, itemsToZip);
|
|
10
|
+
|
|
11
|
+
debug(`Created %s with %d items (%d bytes)`, zipFileName, itemsToZip.length, bytes);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = { CREATE_ARCHIVE_STEP };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const { set } = require('lodash/fp');
|
|
2
|
+
const { resolve } = require('path');
|
|
3
|
+
const { promises: fs } = require('fs');
|
|
4
|
+
const Glob = require('glob');
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const isGlob = require('is-glob');
|
|
7
|
+
const { promisify } = require('util');
|
|
8
|
+
const { getIncreasedVersion } = require('../../scripts/utils/version');
|
|
9
|
+
const { loadJson } = require('../lib/json');
|
|
10
|
+
const { StepError } = require('../lib/step-error');
|
|
11
|
+
|
|
12
|
+
const glob = promisify(Glob);
|
|
13
|
+
const debug = require('debug')('cca:flow:zip:resolve');
|
|
14
|
+
|
|
15
|
+
const uniqueValues = (array) => Array.from(new Set(array));
|
|
16
|
+
|
|
17
|
+
const FILE_LIST_RESOLVE_STEP = {
|
|
18
|
+
message: 'Resolving files list...',
|
|
19
|
+
fn: async (context) => {
|
|
20
|
+
const { patterns, manifest, dirName } = context;
|
|
21
|
+
const files = await transformPatternsIntoFileNames(dirName, patterns);
|
|
22
|
+
|
|
23
|
+
if (manifest.isUi()) {
|
|
24
|
+
return resolveDataToZipUiApp(files, context);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (manifest.isNode()) {
|
|
28
|
+
return resolveDataForZipNodeJsApp(files, context);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (manifest.isPython()) {
|
|
32
|
+
return resolveDataForZipPythonApp(files, context);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw new Error(`Unsupported runtime: ${manifest.runtime}`);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const transformPatternsIntoFileNames = async (dirName, patterns) => {
|
|
40
|
+
const filesFromPatterns = [];
|
|
41
|
+
|
|
42
|
+
for (const pattern of patterns) {
|
|
43
|
+
if (pattern.includes('node_modules')) {
|
|
44
|
+
debug('Invalid file pattern', pattern);
|
|
45
|
+
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!isGlob(pattern, { strict: false })) {
|
|
50
|
+
filesFromPatterns.push(pattern);
|
|
51
|
+
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const files = await glob(pattern, { cwd: dirName, ignore: '**/node_modules' });
|
|
56
|
+
|
|
57
|
+
filesFromPatterns.push(...files);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return filesFromPatterns;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName }) => {
|
|
64
|
+
const version = await getIncreasedVersion(pkg.version, options);
|
|
65
|
+
const zipFileName = `${pkg.name}-${version}.zip`;
|
|
66
|
+
const itemsToSave = [];
|
|
67
|
+
const shouldUpdateVersion = version !== pkg.version;
|
|
68
|
+
|
|
69
|
+
if (shouldUpdateVersion) {
|
|
70
|
+
pkg.version = version;
|
|
71
|
+
|
|
72
|
+
itemsToSave.push({
|
|
73
|
+
name: 'package.json',
|
|
74
|
+
content: pkg,
|
|
75
|
+
message: chalk(
|
|
76
|
+
`\n${chalk.yellow`NOTE`}: Version of your app was updated to ${version} (package.json), please don't lower it.`
|
|
77
|
+
),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
itemsToSave.push({
|
|
82
|
+
name: 'packageForSource.json',
|
|
83
|
+
content: set(
|
|
84
|
+
'scripts',
|
|
85
|
+
{
|
|
86
|
+
build: 'webpack --config=./config-overrides.js --mode production',
|
|
87
|
+
},
|
|
88
|
+
pkg
|
|
89
|
+
),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const itemsToRemove = ['packageForSource.json'];
|
|
93
|
+
|
|
94
|
+
itemsToZip.push(
|
|
95
|
+
'manifest.json',
|
|
96
|
+
'config-overrides.js',
|
|
97
|
+
'tsconfig.json',
|
|
98
|
+
'.npmrc',
|
|
99
|
+
'yarn.lock',
|
|
100
|
+
{ path: resolve(dirName, 'packageForSource.json'), name: 'package.json' },
|
|
101
|
+
'src'
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
zipFileName,
|
|
106
|
+
itemsToZip,
|
|
107
|
+
itemsToSave,
|
|
108
|
+
itemsToRemove,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirName }) => {
|
|
113
|
+
const version = await getIncreasedVersion(pkg.version, options);
|
|
114
|
+
const zipFileName = `${pkg.name}-${version}.zip`;
|
|
115
|
+
const itemsToSave = [];
|
|
116
|
+
const shouldUpdateVersion = version !== pkg.version;
|
|
117
|
+
|
|
118
|
+
if (shouldUpdateVersion) {
|
|
119
|
+
pkg.version = version;
|
|
120
|
+
|
|
121
|
+
itemsToSave.push({
|
|
122
|
+
name: 'package.json',
|
|
123
|
+
content: pkg,
|
|
124
|
+
message: chalk(
|
|
125
|
+
`\n${chalk.yellow`NOTE`}: Version of your app was updated to ${version} (package.json), please don't lower it.`
|
|
126
|
+
),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const packageDirContent = await fs.readdir(dirName);
|
|
131
|
+
const shouldPushDefaultSrc = !itemsToZip.length;
|
|
132
|
+
|
|
133
|
+
itemsToZip.push('config', 'manifest.json', 'package.json');
|
|
134
|
+
|
|
135
|
+
if (packageDirContent.includes('package-lock.json')) {
|
|
136
|
+
itemsToZip.push('package-lock.json');
|
|
137
|
+
|
|
138
|
+
if (shouldUpdateVersion) {
|
|
139
|
+
itemsToSave.push({
|
|
140
|
+
name: 'package-lock.json',
|
|
141
|
+
content: set('version', version, await loadJson(dirName, 'package-lock.json')),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
} else if (packageDirContent.includes('yarn.lock')) {
|
|
145
|
+
itemsToZip.push('yarn.lock');
|
|
146
|
+
} else {
|
|
147
|
+
throw new StepError(`No lock file found in ${dirName}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (packageDirContent.includes('tsconfig.json')) {
|
|
151
|
+
itemsToZip.push('tsconfig.json', 'tsconfig.build.json');
|
|
152
|
+
|
|
153
|
+
if (shouldPushDefaultSrc) {
|
|
154
|
+
itemsToZip.push('index.ts', ...(await glob('+(src|lib)/**/*.ts', { cwd: dirName })));
|
|
155
|
+
}
|
|
156
|
+
} else if (shouldPushDefaultSrc) {
|
|
157
|
+
itemsToZip.push('index.js', ...(await glob('+(src|lib)/**/*.js', { cwd: dirName })));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
zipFileName,
|
|
162
|
+
itemsToZip: uniqueValues(itemsToZip),
|
|
163
|
+
itemsToSave,
|
|
164
|
+
itemsToRemove: [],
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const resolveDataForZipPythonApp = async (itemsToZip = [], { manifest, dirName }) => {
|
|
169
|
+
const zipFileName = `${manifest.manifest.application.name}.zip`;
|
|
170
|
+
|
|
171
|
+
if (!itemsToZip.length) {
|
|
172
|
+
itemsToZip.push(...(await glob('**/*.py', { cwd: dirName })));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
itemsToZip.push('manifest.json', 'requirements.txt');
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
zipFileName,
|
|
179
|
+
itemsToZip: uniqueValues(itemsToZip),
|
|
180
|
+
itemsToSave: [],
|
|
181
|
+
itemsToRemove: [],
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
module.exports = { FILE_LIST_RESOLVE_STEP };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { saveJson } = require('../lib/json');
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('cca:flow:zip:prepare');
|
|
4
|
+
|
|
5
|
+
const PREPARE_FILES_BEFORE_ZIP_STEP = {
|
|
6
|
+
message: 'Preparing...',
|
|
7
|
+
fn: async ({ itemsToSave, dirName }) => {
|
|
8
|
+
for (const item of itemsToSave) {
|
|
9
|
+
debug(`Updating %s`, item.name);
|
|
10
|
+
await saveJson(dirName, item.name, item.content);
|
|
11
|
+
|
|
12
|
+
if (item.message) {
|
|
13
|
+
process.stdout.write(item.message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
PREPARE_FILES_BEFORE_ZIP_STEP,
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { CLEANUP_STEP } = require('./zip-cleanup');
|
|
2
|
+
const { CREATE_ARCHIVE_STEP } = require('./zip-create-archive');
|
|
3
|
+
const { FILE_LIST_RESOLVE_STEP } = require('./zip-file-list-resolve');
|
|
4
|
+
const { PREPARE_FILES_BEFORE_ZIP_STEP } = require('./zip-prepare');
|
|
5
|
+
|
|
6
|
+
const ZIP_STEPS = [
|
|
7
|
+
FILE_LIST_RESOLVE_STEP,
|
|
8
|
+
PREPARE_FILES_BEFORE_ZIP_STEP,
|
|
9
|
+
CREATE_ARCHIVE_STEP,
|
|
10
|
+
CLEANUP_STEP,
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
ZIP_STEPS,
|
|
15
|
+
};
|
package/lib/flows/zip.js
ADDED
|
@@ -34,11 +34,11 @@ function fillManifest(answers) {
|
|
|
34
34
|
settings: {
|
|
35
35
|
...defaultManifestProperties.settings,
|
|
36
36
|
runtime,
|
|
37
|
-
|
|
37
|
+
app: defaultAppSettings({
|
|
38
38
|
type: answers.appType,
|
|
39
39
|
schedulerType: answers.schedulerType,
|
|
40
40
|
cronString: answers.cronString,
|
|
41
|
-
depthMilestone: answers.depthMilestone
|
|
41
|
+
depthMilestone: answers.depthMilestone,
|
|
42
42
|
}),
|
|
43
43
|
},
|
|
44
44
|
};
|
|
@@ -63,19 +63,17 @@ function defaultAppSettings({ type, schedulerType, cronString, depthMilestone })
|
|
|
63
63
|
return {};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
:
|
|
66
|
+
if (schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value) {
|
|
67
|
+
return {
|
|
68
|
+
scheduler_type: schedulerType,
|
|
69
|
+
depth_milestone: depthMilestone || 1
|
|
70
|
+
}
|
|
71
|
+
}
|
|
70
72
|
|
|
71
73
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
cron_string: cronString,
|
|
76
|
-
depth_milestone: depthMilestone
|
|
77
|
-
},
|
|
78
|
-
};
|
|
74
|
+
scheduler_type: schedulerType,
|
|
75
|
+
cron_string: cronString || '*/5 * * * *',
|
|
76
|
+
}
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
module.exports = {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { APP_TYPES } = require("../constants/cli");
|
|
2
|
+
|
|
3
|
+
const resolveAppRuntime = (opts) => {
|
|
4
|
+
if (opts.appType === APP_TYPES.UI) {
|
|
5
|
+
return {
|
|
6
|
+
language: opts.useTypescript ? "typescript" : "javascript",
|
|
7
|
+
packageManager: opts.packageManager,
|
|
8
|
+
version: process.version.replace(/^v/, ""),
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (opts.runtime.startsWith('node')) {
|
|
13
|
+
const version = /nodejs(\d{2})\.x/.exec(opts.runtime)[1];
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
language: opts.useTypescript ? "typescript" : "javascript",
|
|
17
|
+
packageManager: opts.packageManager,
|
|
18
|
+
version
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
language: "python",
|
|
24
|
+
packageManager: 'pip',
|
|
25
|
+
version: '3.8'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
module.exports = { resolveAppRuntime };
|
|
@@ -13,29 +13,29 @@ function copyFileSync(source, target) {
|
|
|
13
13
|
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function copyFolderRecursiveSync(
|
|
17
|
-
let files = [];
|
|
18
|
-
|
|
16
|
+
function copyFolderRecursiveSync(sourceFolder, targetFolder) {
|
|
19
17
|
//check if folder needs to be created or integrated
|
|
20
|
-
let targetFolder;
|
|
21
|
-
if (path.basename(source) !== excludeFolderName) {
|
|
22
|
-
targetFolder = path.join(target, path.basename(source));
|
|
23
|
-
} else targetFolder = target;
|
|
24
18
|
if (!fs.existsSync(targetFolder)) {
|
|
25
19
|
fs.mkdirSync(targetFolder);
|
|
26
20
|
}
|
|
27
21
|
|
|
22
|
+
if (!fs.lstatSync(sourceFolder).isDirectory()) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
28
26
|
//copy
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
27
|
+
const items = fs.readdirSync(sourceFolder);
|
|
28
|
+
|
|
29
|
+
for (const item of items) {
|
|
30
|
+
const curSource = path.join(sourceFolder, item);
|
|
31
|
+
|
|
32
|
+
if (fs.lstatSync(curSource).isDirectory()) {
|
|
33
|
+
copyFolderRecursiveSync(curSource, path.join(targetFolder, item));
|
|
34
|
+
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
copyFileSync(curSource, targetFolder);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
File without changes
|