@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.
Files changed (126) hide show
  1. package/README.md +160 -17
  2. package/bin/create-corva-app.js +5 -0
  3. package/lib/app.js +9 -0
  4. package/lib/bump-version.option.js +29 -0
  5. package/{constants → lib/constants}/cli.js +1 -0
  6. package/{constants → lib/constants}/manifest.js +5 -13
  7. package/lib/constants/messages.js +21 -0
  8. package/lib/constants/package.js +161 -0
  9. package/lib/flow.js +46 -0
  10. package/lib/flows/lib/create-zip-archive.js +77 -0
  11. package/lib/flows/lib/json.js +28 -0
  12. package/lib/flows/lib/manifest.js +47 -0
  13. package/lib/flows/lib/step-error.js +12 -0
  14. package/lib/flows/prepare.js +8 -0
  15. package/lib/flows/release.js +18 -0
  16. package/lib/flows/steps/prepare-load-app-files.js +18 -0
  17. package/lib/flows/steps/release-get-app-key.js +16 -0
  18. package/lib/flows/steps/release-get-config.js +30 -0
  19. package/lib/flows/steps/release-upload-zip-to-corva.js +34 -0
  20. package/lib/flows/steps/zip-cleanup.js +17 -0
  21. package/lib/flows/steps/zip-create-archive.js +15 -0
  22. package/lib/flows/steps/zip-file-list-resolve.js +185 -0
  23. package/lib/flows/steps/zip-prepare.js +21 -0
  24. package/lib/flows/steps/zip.js +15 -0
  25. package/lib/flows/zip-simple.js +8 -0
  26. package/lib/flows/zip.js +9 -0
  27. package/{helpers → lib/helpers}/manifest.js +11 -13
  28. package/lib/helpers/resolve-app-runtime.js +29 -0
  29. package/{helpers → lib/helpers}/utils.js +17 -17
  30. package/{helpers → lib/helpers}/versioning.js +0 -0
  31. package/lib/index.js +502 -0
  32. package/{scripts → lib/scripts}/utils/version.js +49 -26
  33. package/package.json +13 -8
  34. package/{template/scheduler/node → templates/javascript/scheduler}/README.md +0 -0
  35. package/{template/scheduler/node → templates/javascript/scheduler}/__test__/processor.test.js +0 -0
  36. package/{template/scheduler/node → templates/javascript/scheduler}/index.js +0 -0
  37. package/{template/scheduler/node → templates/javascript/scheduler}/src/processor.js +0 -0
  38. package/{template/stream/node → templates/javascript/stream}/README.md +0 -0
  39. package/{template/stream/node → templates/javascript/stream}/__test__/processor.test.js +0 -0
  40. package/{template/stream/node → templates/javascript/stream}/index.js +0 -0
  41. package/{template/stream/node → templates/javascript/stream}/src/processor.js +0 -0
  42. package/{template/task/node → templates/javascript/task}/README.md +0 -0
  43. package/{template/task/node → templates/javascript/task}/__test__/processor.test.js +0 -0
  44. package/{template/task/node → templates/javascript/task}/index.js +0 -0
  45. package/{template/task/node → templates/javascript/task}/src/processor.js +0 -0
  46. package/{template/ui/js → templates/javascript/ui}/.env +0 -0
  47. package/{template/ui/js → templates/javascript/ui}/.env.sample +0 -0
  48. package/{template/ui/js → templates/javascript/ui}/.eslintrc +0 -0
  49. package/{template/ui/js → templates/javascript/ui}/.prettierrc +0 -0
  50. package/{template/ui/js → templates/javascript/ui}/README.md +0 -0
  51. package/{template/ui/js → templates/javascript/ui}/config-overrides.js +0 -0
  52. package/{template/ui/js → templates/javascript/ui}/gitignore +0 -0
  53. package/{template/ui/js → templates/javascript/ui}/src/App.css +0 -0
  54. package/{template/ui/js → templates/javascript/ui}/src/App.js +0 -0
  55. package/{template/ui/js → templates/javascript/ui}/src/AppSettings.js +0 -0
  56. package/{template/ui/js → templates/javascript/ui}/src/assets/logo.svg +0 -0
  57. package/{template/ui/js → templates/javascript/ui}/src/constants.js +0 -0
  58. package/{template/ui/js → templates/javascript/ui}/src/index.js +0 -0
  59. package/templates/python/scheduler/README.md +31 -0
  60. package/{template/scheduler/python → templates/python/scheduler}/lambda_function.py +0 -0
  61. package/{template/scheduler/python → templates/python/scheduler}/test/__init__.py +0 -0
  62. package/{template/scheduler/python → templates/python/scheduler}/test/app_test.py +0 -0
  63. package/templates/python/stream/README.md +31 -0
  64. package/{template/stream/python → templates/python/stream}/lambda_function.py +0 -0
  65. package/{template/stream/python → templates/python/stream}/test/__init__.py +0 -0
  66. package/{template/stream/python → templates/python/stream}/test/app_test.py +0 -0
  67. package/templates/python/task/README.md +31 -0
  68. package/{template/task/python → templates/python/task}/lambda_function.py +0 -0
  69. package/{template/task/python → templates/python/task}/test/__init__.py +0 -0
  70. package/{template/task/python → templates/python/task}/test/app_test.py +0 -0
  71. package/{template/scheduler/node-ts → templates/typescript/scheduler}/README.md +0 -0
  72. package/{template/scheduler/node-ts → templates/typescript/scheduler}/__test__/processor.spec.ts +0 -0
  73. package/{template/scheduler/node-ts → templates/typescript/scheduler}/index.ts +0 -0
  74. package/{template/scheduler/node-ts → templates/typescript/scheduler}/lib/processor.ts +0 -0
  75. package/{template/stream/node-ts → templates/typescript/stream}/README.md +0 -0
  76. package/{template/stream/node-ts → templates/typescript/stream}/__test__/processor.spec.ts +0 -0
  77. package/{template/stream/node-ts → templates/typescript/stream}/index.ts +0 -0
  78. package/{template/stream/node-ts → templates/typescript/stream}/lib/processor.ts +0 -0
  79. package/{template/task/node-ts → templates/typescript/task}/README.md +0 -0
  80. package/{template/task/node-ts → templates/typescript/task}/__test__/processor.spec.ts +0 -0
  81. package/{template/task/node-ts → templates/typescript/task}/index.ts +0 -0
  82. package/{template/task/node-ts → templates/typescript/task}/src/processor.ts +0 -0
  83. package/{template/ui/ts → templates/typescript/ui}/.env +0 -0
  84. package/{template/ui/ts → templates/typescript/ui}/.env.sample +0 -0
  85. package/{template/ui/ts → templates/typescript/ui}/.eslintrc +0 -0
  86. package/{template/ui/ts → templates/typescript/ui}/.prettierrc +0 -0
  87. package/{template/ui/ts → templates/typescript/ui}/README.md +0 -0
  88. package/{template/ui/ts → templates/typescript/ui}/config-overrides.js +0 -0
  89. package/{template/ui/ts → templates/typescript/ui}/gitignore +0 -0
  90. package/{template/ui/ts → templates/typescript/ui}/src/App.css +0 -0
  91. package/{template/ui/ts → templates/typescript/ui}/src/App.tsx +0 -0
  92. package/{template/ui/ts → templates/typescript/ui}/src/AppSettings.tsx +0 -0
  93. package/{template/ui/ts → templates/typescript/ui}/src/assets/logo.svg +0 -0
  94. package/{template/ui/ts → templates/typescript/ui}/src/constants.ts +0 -0
  95. package/{template/ui/ts → templates/typescript/ui}/src/custom.d.ts +0 -0
  96. package/{template/ui/ts → templates/typescript/ui}/src/index.js +0 -0
  97. package/{template/ui/ts → templates/typescript/ui}/tsconfig.json +0 -0
  98. package/constants/package.js +0 -50
  99. package/index.js +0 -386
  100. package/scripts/ui/index.js +0 -7
  101. package/scripts/ui/releaseAppZip.js +0 -91
  102. package/scripts/ui/zipAppSource.js +0 -103
  103. package/template/scheduler/node/gitignore +0 -21
  104. package/template/scheduler/node/package.json +0 -17
  105. package/template/scheduler/node-ts/gitignore +0 -25
  106. package/template/scheduler/node-ts/package.json +0 -37
  107. package/template/scheduler/node-ts/tsconfig.build.json +0 -11
  108. package/template/scheduler/node-ts/tsconfig.json +0 -34
  109. package/template/scheduler/python/README.md +0 -19
  110. package/template/scheduler/python/requirements.txt +0 -2
  111. package/template/stream/node/gitignore +0 -21
  112. package/template/stream/node/package.json +0 -17
  113. package/template/stream/node-ts/gitignore +0 -25
  114. package/template/stream/node-ts/package.json +0 -37
  115. package/template/stream/node-ts/tsconfig.build.json +0 -11
  116. package/template/stream/node-ts/tsconfig.json +0 -34
  117. package/template/stream/python/README.md +0 -19
  118. package/template/stream/python/requirements.txt +0 -2
  119. package/template/task/node/gitignore +0 -21
  120. package/template/task/node/package.json +0 -17
  121. package/template/task/node-ts/gitignore +0 -25
  122. package/template/task/node-ts/package.json +0 -37
  123. package/template/task/node-ts/tsconfig.build.json +0 -11
  124. package/template/task/node-ts/tsconfig.json +0 -34
  125. package/template/task/python/README.md +0 -19
  126. 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,12 @@
1
+ class StepError extends Error {
2
+ cause;
3
+ name;
4
+
5
+ constructor(message, { cause } = {}) {
6
+ super(message);
7
+ this.name = 'StepError';
8
+ this.cause = cause;
9
+ }
10
+ }
11
+
12
+ module.exports = { StepError };
@@ -0,0 +1,8 @@
1
+ const { LOAD_APP_FILES_STEP } = require('./steps/prepare-load-app-files');
2
+
3
+ const PREPARE_FLOW = {
4
+ name: 'prepare',
5
+ steps: [LOAD_APP_FILES_STEP],
6
+ };
7
+
8
+ module.exports = { PREPARE_FLOW };
@@ -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
+ };
@@ -0,0 +1,8 @@
1
+ const { ZIP_STEPS } = require('./steps/zip');
2
+
3
+ const ZIP_SIMPLE_FLOW = {
4
+ name: 'zip (simple)',
5
+ steps: ZIP_STEPS,
6
+ };
7
+
8
+ module.exports = { ZIP_SIMPLE_FLOW };
@@ -0,0 +1,9 @@
1
+ const { PREPARE_FLOW } = require('./prepare');
2
+ const { ZIP_STEPS } = require('./steps/zip');
3
+
4
+ const ZIP_FLOW = {
5
+ name: 'zip',
6
+ steps: [PREPARE_FLOW, ...ZIP_STEPS],
7
+ };
8
+
9
+ module.exports = { ZIP_FLOW };
@@ -34,11 +34,11 @@ function fillManifest(answers) {
34
34
  settings: {
35
35
  ...defaultManifestProperties.settings,
36
36
  runtime,
37
- ...defaultAppSettings({
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
- const schedulerAppSettings =
67
- schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value
68
- ? manifestConstants.defaultDepthSchedulerSettings
69
- : manifestConstants.defaultTimeSchedulerSettings;
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
- app: {
73
- ...schedulerAppSettings,
74
- scheduler_type: schedulerType,
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(source, target, excludeFolderName) {
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
- if (fs.lstatSync(source).isDirectory()) {
30
- files = fs.readdirSync(source);
31
- files.forEach(function (file) {
32
- const curSource = path.join(source, file);
33
- if (fs.lstatSync(curSource).isDirectory()) {
34
- copyFolderRecursiveSync(curSource, targetFolder, excludeFolderName);
35
- } else {
36
- copyFileSync(curSource, targetFolder);
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