@corva/create-app 0.27.0-rc.0 → 0.28.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.
Files changed (128) 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 +4 -12
  7. package/lib/constants/messages.js +21 -0
  8. package/{constants → lib/constants}/package.js +2 -2
  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 +31 -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/{helpers → lib/helpers}/utils.js +0 -0
  29. package/{helpers → lib/helpers}/versioning.js +0 -0
  30. package/{index.js → lib/index.js} +165 -52
  31. package/{scripts → lib/scripts}/utils/version.js +49 -26
  32. package/package.json +13 -8
  33. package/{template → templates}/scheduler/node/README.md +0 -0
  34. package/{template → templates}/scheduler/node/__test__/processor.test.js +0 -0
  35. package/{template → templates}/scheduler/node/gitignore +0 -0
  36. package/{template → templates}/scheduler/node/index.js +0 -0
  37. package/{template → templates}/scheduler/node/package.json +1 -1
  38. package/{template → templates}/scheduler/node/src/processor.js +0 -0
  39. package/{template → templates}/scheduler/node-ts/README.md +0 -0
  40. package/{template → templates}/scheduler/node-ts/__test__/processor.spec.ts +0 -0
  41. package/{template → templates}/scheduler/node-ts/gitignore +0 -0
  42. package/{template → templates}/scheduler/node-ts/index.ts +0 -0
  43. package/templates/scheduler/node-ts/lib/processor.js +16 -0
  44. package/templates/scheduler/node-ts/lib/processor.js.map +1 -0
  45. package/{template → templates}/scheduler/node-ts/lib/processor.ts +0 -0
  46. package/{template → templates}/scheduler/node-ts/package.json +1 -1
  47. package/{template → templates}/scheduler/node-ts/tsconfig.build.json +0 -0
  48. package/{template → templates}/scheduler/node-ts/tsconfig.json +0 -0
  49. package/templates/scheduler/python/Makefile +15 -0
  50. package/templates/scheduler/python/README.md +31 -0
  51. package/{template → templates}/scheduler/python/lambda_function.py +0 -0
  52. package/{template → templates}/scheduler/python/requirements.txt +0 -0
  53. package/{template → templates}/scheduler/python/test/__init__.py +0 -0
  54. package/{template → templates}/scheduler/python/test/app_test.py +0 -0
  55. package/{template → templates}/stream/node/README.md +0 -0
  56. package/{template → templates}/stream/node/__test__/processor.test.js +0 -0
  57. package/{template → templates}/stream/node/gitignore +0 -0
  58. package/{template → templates}/stream/node/index.js +0 -0
  59. package/{template → templates}/stream/node/package.json +1 -1
  60. package/{template → templates}/stream/node/src/processor.js +0 -0
  61. package/{template → templates}/stream/node-ts/README.md +0 -0
  62. package/{template → templates}/stream/node-ts/__test__/processor.spec.ts +0 -0
  63. package/{template → templates}/stream/node-ts/gitignore +0 -0
  64. package/{template → templates}/stream/node-ts/index.ts +0 -0
  65. package/{template → templates}/stream/node-ts/lib/processor.ts +0 -0
  66. package/{template → templates}/stream/node-ts/package.json +1 -1
  67. package/{template → templates}/stream/node-ts/tsconfig.build.json +0 -0
  68. package/{template → templates}/stream/node-ts/tsconfig.json +0 -0
  69. package/templates/stream/python/Makefile +15 -0
  70. package/templates/stream/python/README.md +31 -0
  71. package/{template → templates}/stream/python/lambda_function.py +0 -0
  72. package/{template → templates}/stream/python/requirements.txt +0 -0
  73. package/{template → templates}/stream/python/test/__init__.py +0 -0
  74. package/{template → templates}/stream/python/test/app_test.py +0 -0
  75. package/{template → templates}/task/node/README.md +0 -0
  76. package/{template → templates}/task/node/__test__/processor.test.js +0 -0
  77. package/{template → templates}/task/node/gitignore +0 -0
  78. package/{template → templates}/task/node/index.js +0 -0
  79. package/{template → templates}/task/node/package.json +1 -1
  80. package/{template → templates}/task/node/src/processor.js +0 -0
  81. package/{template → templates}/task/node-ts/README.md +0 -0
  82. package/{template → templates}/task/node-ts/__test__/processor.spec.ts +0 -0
  83. package/{template → templates}/task/node-ts/gitignore +0 -0
  84. package/{template → templates}/task/node-ts/index.ts +0 -0
  85. package/{template → templates}/task/node-ts/package.json +1 -1
  86. package/{template → templates}/task/node-ts/src/processor.ts +0 -0
  87. package/{template → templates}/task/node-ts/tsconfig.build.json +0 -0
  88. package/{template → templates}/task/node-ts/tsconfig.json +0 -0
  89. package/templates/task/python/Makefile +15 -0
  90. package/templates/task/python/README.md +31 -0
  91. package/{template → templates}/task/python/lambda_function.py +0 -0
  92. package/{template → templates}/task/python/requirements.txt +0 -0
  93. package/{template → templates}/task/python/test/__init__.py +0 -0
  94. package/{template → templates}/task/python/test/app_test.py +0 -0
  95. package/{template → templates}/ui/js/.env +0 -0
  96. package/{template → templates}/ui/js/.env.sample +0 -0
  97. package/{template → templates}/ui/js/.eslintrc +0 -0
  98. package/{template → templates}/ui/js/.prettierrc +0 -0
  99. package/{template → templates}/ui/js/README.md +0 -0
  100. package/{template → templates}/ui/js/config-overrides.js +0 -0
  101. package/{template → templates}/ui/js/gitignore +0 -0
  102. package/{template → templates}/ui/js/src/App.css +0 -0
  103. package/{template → templates}/ui/js/src/App.js +0 -0
  104. package/{template → templates}/ui/js/src/AppSettings.js +0 -0
  105. package/{template → templates}/ui/js/src/assets/logo.svg +0 -0
  106. package/{template → templates}/ui/js/src/constants.js +0 -0
  107. package/{template → templates}/ui/js/src/index.js +0 -0
  108. package/{template → templates}/ui/ts/.env +0 -0
  109. package/{template → templates}/ui/ts/.env.sample +0 -0
  110. package/{template → templates}/ui/ts/.eslintrc +0 -0
  111. package/{template → templates}/ui/ts/.prettierrc +0 -0
  112. package/{template → templates}/ui/ts/README.md +0 -0
  113. package/{template → templates}/ui/ts/config-overrides.js +0 -0
  114. package/{template → templates}/ui/ts/gitignore +0 -0
  115. package/{template → templates}/ui/ts/src/App.css +0 -0
  116. package/{template → templates}/ui/ts/src/App.tsx +0 -0
  117. package/{template → templates}/ui/ts/src/AppSettings.tsx +0 -0
  118. package/{template → templates}/ui/ts/src/assets/logo.svg +0 -0
  119. package/{template → templates}/ui/ts/src/constants.ts +0 -0
  120. package/{template → templates}/ui/ts/src/custom.d.ts +0 -0
  121. package/{template → templates}/ui/ts/src/index.js +0 -0
  122. package/{template → templates}/ui/ts/tsconfig.json +0 -0
  123. package/scripts/ui/index.js +0 -7
  124. package/scripts/ui/releaseAppZip.js +0 -91
  125. package/scripts/ui/zipAppSource.js +0 -103
  126. package/template/scheduler/python/README.md +0 -19
  127. package/template/stream/python/README.md +0 -19
  128. package/template/task/python/README.md +0 -19
@@ -1,91 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const axios = require('axios');
4
- const FormData = require('form-data');
5
- const chalk = require('chalk');
6
- const dotenv = require('dotenv');
7
- const get = require('lodash').get;
8
- const zipAppSource = require('./zipAppSource');
9
-
10
- const SUCCESS_ICON = ' ✅ \n';
11
- const ERROR_ICON = ' ❌ \n';
12
-
13
- const CONSOLE_MESSAGES = {
14
- createZip: 'Creating zip archive...\n',
15
- createZipError: 'Could not create zip archive.',
16
- createZipSuccess: `Zip archive has been created ${SUCCESS_ICON}`,
17
- getAuthToken: 'Reading auth token...',
18
- getAuthTokenError: `Could not find auth token. Please run ${chalk.cyan(
19
- 'yarn start'
20
- )} and login to Corva`,
21
- getAppKey: 'Reading app key...',
22
- getAppKeyError: "Could not find app key. Please make sure it's defined in manifest.json",
23
- uploadApp: 'Uploading app...',
24
- };
25
-
26
- function handleError(e, message) {
27
- process.stdout.write(ERROR_ICON);
28
- message && console.log(chalk.red(message));
29
- console.error(chalk.red(e));
30
- process.exit(1);
31
- }
32
-
33
- async function releaseAppZip({ bumpVersion }) {
34
- const dirname = process.cwd();
35
-
36
- // Read auth token
37
- let authToken;
38
- let corvaAPIEnv = 'production';
39
- try {
40
- process.stdout.write(CONSOLE_MESSAGES.getAuthToken);
41
- const env = await fs.promises.readFile(path.resolve(dirname, './.env'));
42
- const config = dotenv.parse(env);
43
- authToken = config.AUTH_TOKEN;
44
- if (!authToken) throw new Error('No auth token.');
45
- if (config.CORVA_API_ENV) corvaAPIEnv = config.CORVA_API_ENV;
46
- process.stdout.write(SUCCESS_ICON);
47
- } catch (e) {
48
- handleError(e, CONSOLE_MESSAGES.getAuthTokenError);
49
- }
50
-
51
- // Read app key
52
- let appKey;
53
- try {
54
- process.stdout.write(CONSOLE_MESSAGES.getAppKey);
55
- const manifest = JSON.parse(
56
- await fs.promises.readFile(path.resolve(dirname, './manifest.json'))
57
- );
58
- appKey = manifest.application.key;
59
- if (!appKey) throw new Error('No app key.');
60
- process.stdout.write(SUCCESS_ICON);
61
- } catch (e) {
62
- handleError(e, CONSOLE_MESSAGES.getAppKeyError);
63
- }
64
-
65
- // Zip archive
66
- let zipPath;
67
- try {
68
- process.stdout.write(CONSOLE_MESSAGES.createZip);
69
- zipPath = await zipAppSource({ silent: true, bumpVersion });
70
- process.stdout.write(CONSOLE_MESSAGES.createZipSuccess);
71
- } catch (e) {
72
- handleError(e, CONSOLE_MESSAGES.createZipError);
73
- }
74
-
75
- let uploadURL;
76
- try {
77
- process.stdout.write(CONSOLE_MESSAGES.uploadApp);
78
- const form = new FormData();
79
- form.append('package', fs.createReadStream(zipPath), 'archive.zip');
80
- const baseURL = `https://api${corvaAPIEnv === 'production' ? '' : `.${corvaAPIEnv}`}.corva.ai`;
81
- uploadURL = `${baseURL}/v2/apps/${appKey}/packages/upload`;
82
- await axios.post(uploadURL, form, {
83
- headers: { ...form.getHeaders(), Authorization: `Bearer ${authToken}` },
84
- });
85
- process.stdout.write(SUCCESS_ICON);
86
- } catch (e) {
87
- handleError(e, `${get(e, 'response.data.message', '')} \nPOST: ${uploadURL} failed.`);
88
- }
89
- }
90
-
91
- module.exports = releaseAppZip;
@@ -1,103 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const archiver = require('archiver');
4
- const os = require('os');
5
- const chalk = require('chalk');
6
- const noop = require('lodash').noop;
7
-
8
- const { warnIfOutdated, getIncreasedVersion } = require('../utils/version');
9
-
10
- async function compressAppToZip({ silent = false, bumpVersion } = {}) {
11
- const log = silent ? noop : console.log;
12
- await warnIfOutdated();
13
-
14
- // Left only build script for package json;
15
- const dirname = process.cwd();
16
- const packageJsonContent = fs.readFileSync(path.resolve(dirname, 'package.json'), 'utf-8');
17
- const packageJson = JSON.parse(packageJsonContent);
18
- const updatedVersion = await getIncreasedVersion(packageJson.version, { bumpVersion });
19
-
20
- const updatedPackage = {
21
- ...packageJson,
22
- version: updatedVersion,
23
- scripts: {
24
- build: 'webpack --config=./config-overrides.js --mode production',
25
- },
26
- };
27
-
28
- const zipFileName = `${packageJson.name}-${updatedVersion}.zip`;
29
- const zipPath = path.resolve(path.resolve(dirname, zipFileName));
30
-
31
- var archive = archiver.create('zip', {});
32
- var output = fs.createWriteStream(zipPath);
33
-
34
- // pipe archive data to the file
35
- archive.pipe(output);
36
-
37
- output.on('close', function() {
38
- log(`Created ${zipPath.replace(dirname + '/', '')}, ${archive.pointer()} bytes written\n`);
39
-
40
- // clean up temp package.json file
41
- try {
42
- fs.unlinkSync(path.resolve(dirname, 'packageForSource.json'));
43
- // deleteFolderRecursive(path.resolve(dirname, 'src'));
44
- } catch (err) {
45
- console.error(err);
46
- }
47
- });
48
-
49
- output.on('end', function() {
50
- log('Data has been drained');
51
- });
52
-
53
- archive.on('warning', function(err) {
54
- if (err.code === 'ENOENT') {
55
- log(err.message);
56
- } else {
57
- throw err;
58
- }
59
- });
60
-
61
- archive.on('error', function(err) {
62
- throw err;
63
- });
64
-
65
- fs.writeFileSync(
66
- path.resolve(dirname, 'package.json'),
67
- JSON.stringify({ ...packageJson, version: updatedVersion }, null, 2) + os.EOL
68
- );
69
-
70
- log(
71
- chalk(
72
- `NOTE: Version of your app was updated to ${updatedVersion} (package.json), please don't lower it.`
73
- )
74
- );
75
-
76
- fs.writeFileSync(
77
- path.resolve(dirname, 'packageForSource.json'),
78
- JSON.stringify(updatedPackage, null, 2) + os.EOL
79
- );
80
-
81
- archive.file(path.resolve(dirname, 'packageForSource.json'), {
82
- name: 'package.json',
83
- });
84
-
85
- ['manifest.json', 'config-overrides.js', 'tsconfig.json', '.npmrc', 'yarn.lock'].forEach(
86
- (name) => {
87
- const file = path.resolve(dirname, name);
88
-
89
- // not all app templates have the tsconfig, archive will raise an error with missing files, have to filter-out that
90
- if (!fs.existsSync(file)) return;
91
-
92
- archive.file(file, { name });
93
- }
94
- );
95
-
96
- archive.directory(path.resolve(dirname, 'src'), 'src');
97
-
98
- await archive.finalize();
99
- log(zipPath);
100
- return zipPath;
101
- }
102
-
103
- module.exports = compressAppToZip;
@@ -1,19 +0,0 @@
1
- # Dev Center Python Polling Scheduler Data App
2
-
3
- ## Getting started
4
-
5
- [Python SDK Documentation](https://corva-ai.github.io/python-sdk)
6
-
7
- ### 1. Install Dependencies
8
-
9
- ```
10
- python -m venv venv
11
- source venv/bin/activate
12
- pip install -r requirements.txt
13
- ```
14
-
15
- ### 2. Run Tests
16
-
17
- ```
18
- pytest
19
- ```
@@ -1,19 +0,0 @@
1
- # Dev Center Python Real-Time Stream Data App
2
-
3
- ## Getting started
4
-
5
- [Python SDK Documentation](https://corva-ai.github.io/python-sdk)
6
-
7
- ### 1. Install Dependencies
8
-
9
- ```
10
- python -m venv venv
11
- source venv/bin/activate
12
- pip install -r requirements.txt
13
- ```
14
-
15
- ### 2. Run Tests
16
-
17
- ```
18
- pytest
19
- ```
@@ -1,19 +0,0 @@
1
- # Dev Center Python Task Data App
2
-
3
- ## Getting started
4
-
5
- [Python SDK Documentation](https://corva-ai.github.io/python-sdk)
6
-
7
- ### 1. Install Dependencies
8
-
9
- ```
10
- python -m venv venv
11
- source venv/bin/activate
12
- pip install -r requirements.txt
13
- ```
14
-
15
- ### 2. Run Tests
16
-
17
- ```
18
- pytest
19
- ```