@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
File without changes
@@ -0,0 +1,31 @@
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
8
+
9
+ You need to have `make` installed:
10
+
11
+ - Windows: [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install)
12
+ - OS X: [Command Line Tools for Xcode](https://developer.apple.com/download/more/)
13
+ - Linux: refer to your distro-specific docs
14
+
15
+ To install dependencies run:
16
+
17
+ ```sh
18
+ make
19
+ ```
20
+
21
+ ### 2. Run Tests
22
+
23
+ ```sh
24
+ make test
25
+ ```
26
+
27
+ ### 3. Create app zip
28
+
29
+ ```sh
30
+ make bundle
31
+ ```
@@ -0,0 +1,31 @@
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
8
+
9
+ You need to have `make` installed:
10
+
11
+ - Windows: [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install)
12
+ - OS X: [Command Line Tools for Xcode](https://developer.apple.com/download/more/)
13
+ - Linux: refer to your distro-specific docs
14
+
15
+ To install dependencies run:
16
+
17
+ ```sh
18
+ make
19
+ ```
20
+
21
+ ### 2. Run Tests
22
+
23
+ ```sh
24
+ make test
25
+ ```
26
+
27
+ ### 3. Create app zip
28
+
29
+ ```sh
30
+ make bundle
31
+ ```
@@ -0,0 +1,31 @@
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
8
+
9
+ You need to have `make` installed:
10
+
11
+ - Windows: [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install)
12
+ - OS X: [Command Line Tools for Xcode](https://developer.apple.com/download/more/)
13
+ - Linux: refer to your distro-specific docs
14
+
15
+ To install dependencies run:
16
+
17
+ ```sh
18
+ make
19
+ ```
20
+
21
+ ### 2. Run Tests
22
+
23
+ ```sh
24
+ make test
25
+ ```
26
+
27
+ ### 3. Create app zip
28
+
29
+ ```sh
30
+ make bundle
31
+ ```
File without changes
@@ -1,50 +0,0 @@
1
- const dependencies = {
2
- devDependencies: {
3
- 'postcss-loader': '4.1.0',
4
- },
5
- dependencies: {
6
- '@corva/ui': 'latest',
7
- '@material-ui/core': '4.11.2',
8
- '@material-ui/icons': '4.9.1',
9
- '@material-ui/lab': '4.0.0-alpha.57',
10
- '@material-ui/pickers': '3.2.10',
11
- 'classnames': '2.2.6',
12
- 'corva-convert-units': '1.10.17',
13
- 'highcharts': '8.1.2',
14
- 'highcharts-react-official': '2.2.2',
15
- 'lodash': '^4.17.4',
16
- 'mapbox.js': '3.2.1',
17
- 'moment': '2.23.0',
18
- 'moment-timezone': '0.5.23',
19
- 'prop-types': '^15.6.1',
20
- 'react': '17.0.1',
21
- 'react-dom': '17.0.1',
22
- },
23
- };
24
-
25
- const tsDependencies = {
26
- devDependencies: {
27
- '@tsconfig/create-react-app': '1.0.2',
28
- '@types/material-ui': '0.21.9',
29
- '@types/react': '^17.0.22',
30
- '@types/react-dom': '^17.0.9',
31
- '@typescript-eslint/eslint-plugin': '^4.31.2',
32
- '@typescript-eslint/parser': '^4.31.2',
33
- 'ts-loader': '8.2.0',
34
- 'typescript': '^4.4.3',
35
- },
36
- };
37
-
38
- const scripts = {
39
- build: 'webpack --config=./config-overrides.js --mode production',
40
- start: 'webpack-dev-server --config=./config-overrides.js --open --mode development',
41
- zip: 'create-corva-app --zip ui',
42
- lint: 'eslint --cache ./src/',
43
- release: 'create-corva-app --release',
44
- };
45
-
46
- module.exports = {
47
- tsDependencies,
48
- dependencies,
49
- scripts,
50
- };
package/index.js DELETED
@@ -1,386 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- const chalk = require('chalk');
6
- const figlet = require('figlet');
7
- const commander = require('commander');
8
- const fs = require('fs-extra');
9
- const inquirer = require('inquirer');
10
- const os = require('os');
11
- const path = require('path');
12
- const semver = require('semver');
13
-
14
- const uiScripts = require('./scripts/ui');
15
- const { ensureLatestVersion } = require('./scripts/utils/version');
16
- const utils = require('./helpers/utils.js');
17
- const manifestHelpers = require('./helpers/manifest.js');
18
- const versioning = require('./helpers/versioning.js');
19
-
20
- const packageConstants = require('./constants/package.js');
21
- const manifestConstants = require('./constants/manifest.js');
22
-
23
- const packageJson = require('./package.json');
24
- const { clear } = require('console');
25
- const spawn = require('cross-spawn');
26
- const { APP_RUNTIMES, TEMPLATE_TYPES, APP_TYPES } = require('./constants/cli');
27
-
28
- const YARN_EXECUTABLE = 'yarn';
29
-
30
- let packageManager = YARN_EXECUTABLE;
31
- let useTypescript = false;
32
-
33
- const shouldUseYarn = () => packageManager === YARN_EXECUTABLE;
34
- const getLockFileName = (manager) =>
35
- manager === YARN_EXECUTABLE ? 'yarn.lock' : 'package-lock.json';
36
-
37
- let projectName;
38
- let program;
39
-
40
- function startingMessage() {
41
- clear();
42
- console.log(chalk.green(' Welcome to apps generator for:'));
43
- console.log(chalk.cyan(figlet.textSync('CORVA.AI', { horizontalLayout: 'full' })));
44
- }
45
-
46
- function checkNodeVersion() {
47
- process.stdout.write('Checking node version...');
48
-
49
- const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10');
50
- if (unsupportedNodeVersion) {
51
- console.log(
52
- chalk.red(
53
- `\nYou are using Node ${process.version}.\n\n` +
54
- `Please update to Node 10 or higher for a better, fully supported experience.\n`
55
- )
56
- );
57
- // Fall back to latest supported react-scripts on Node 4
58
- return process.exit(1);
59
- }
60
- process.stdout.write(' ✅ \n');
61
- }
62
-
63
- function checkOptions(opts) {
64
- let isValid = true;
65
- const values = {};
66
-
67
- manifestConstants.getManifestMandatoryKeys(opts).forEach((key) => {
68
- if (!opts[key]) {
69
- isValid = false;
70
- }
71
-
72
- values[key] = opts[key];
73
- });
74
-
75
- return {
76
- isValid,
77
- values,
78
- };
79
- }
80
-
81
- async function initialChecks() {
82
- program = new commander.Command('corva-create-app')
83
- .version(packageJson.version)
84
- .argument('[project-directory]', 'project directory to work with')
85
- .usage(`${chalk.green('<project-directory>')} [options]`)
86
- .action((name) => {
87
- projectName = name;
88
- })
89
- .option('-z, --zip <type>', 'zip app source')
90
- .option('--bump-version [string]', 'bump version')
91
- .option('--release', 'release app')
92
- .addOption(
93
- new commander.Option(`-p, --packageManager [string]`, 'package manager to use')
94
- .default(YARN_EXECUTABLE)
95
- .choices(['npm', YARN_EXECUTABLE])
96
- );
97
-
98
- manifestConstants.manifestOptions(projectName).forEach((value) => {
99
- const type = typeof value.default;
100
- const option = new commander.Option(
101
- `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${
102
- (type !== 'undefined' && type) || 'string'
103
- }]`,
104
- value.message
105
- );
106
-
107
- if (value.choices) {
108
- if (typeof value.choices === 'function') {
109
- option.choices(value.choices());
110
- } else {
111
- option.choices(
112
- value.choices.map((choice) => `${typeof choice === 'object' ? choice.value : choice}`)
113
- );
114
- }
115
- }
116
-
117
- if (type === 'number') {
118
- option.argParser(Number);
119
- }
120
-
121
- program.addOption(option);
122
- });
123
-
124
- program.parse(process.argv);
125
-
126
- checkNodeVersion();
127
-
128
- const opts = program.opts();
129
-
130
- packageManager = opts.packageManager || packageManager;
131
- useTypescript = opts.useTypescript || useTypescript;
132
-
133
- if (opts.zip) {
134
- if (opts.zip === APP_RUNTIMES.UI)
135
- return uiScripts.zipAppSource({
136
- bumpVersion: opts.bumpVersion,
137
- });
138
- process.exit(0);
139
- }
140
- if (opts.release) {
141
- return uiScripts.releaseAppZip({ bumpVersion: opts.bumpVersion });
142
- process.exit(0);
143
- }
144
-
145
- startingMessage();
146
-
147
- if (!projectName) {
148
- console.error('Please specify the project directory:');
149
- console.log(` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`);
150
- console.log();
151
- console.log('For example:');
152
- console.log(` ${chalk.cyan(program.name())} ${chalk.green('my-react-app')}`);
153
- console.log();
154
- console.log(`Run ${chalk.cyan(`${program.name()} --help`)} to see all options.`);
155
- process.exit(1);
156
- }
157
-
158
- // NOTE: Default action
159
- await createApp(opts);
160
- }
161
-
162
- async function initPackage(manifest) {
163
- const appType = manifest.application.type;
164
- if (appType === APP_TYPES.UI) {
165
- await ensureLatestVersion();
166
- }
167
-
168
- const root = path.resolve(projectName);
169
-
170
- console.log(`Creating a new Corva app in ${chalk.green(root)}.`);
171
-
172
- fs.mkdirSync(root);
173
-
174
- fs.writeFileSync(path.join(root, 'manifest.json'), JSON.stringify(manifest, null, 2) + os.EOL);
175
-
176
- let runtime = manifest.settings.runtime;
177
-
178
- // Runtimes normally include a version number, like python3.8 or nodejs12.x. We don't want to have a directory or
179
- // config for every possible version at this point, so just consolidate all versions of a runtime into a single
180
- // template directory.
181
- if (appType !== APP_TYPES.UI) {
182
- if (runtime.startsWith(TEMPLATE_TYPES.PYTHON)) {
183
- runtime = TEMPLATE_TYPES.PYTHON;
184
- } else {
185
- runtime = useTypescript ? TEMPLATE_TYPES.NODE_TYPESCRIPT : TEMPLATE_TYPES.NODE;
186
- }
187
- } else {
188
- runtime = useTypescript ? TEMPLATE_TYPES.UI_TS : TEMPLATE_TYPES.UI;
189
- }
190
-
191
- addTemplate(root, appType, runtime);
192
- configureApp(root, appType, runtime, manifest);
193
- installApp(root, appType, runtime);
194
- }
195
-
196
- async function createApp(opts) {
197
- const { isValid, values } = checkOptions(opts);
198
-
199
- if (isValid) {
200
- Object.keys(values).forEach((key) => {
201
- console.log(`${key} : ${values[key]}`);
202
- });
203
-
204
- const manifest = manifestHelpers.fillManifest(values);
205
-
206
- await initPackage(manifest);
207
- } else {
208
- console.log('Please fill your app Metadata');
209
-
210
- inquirer.prompt(manifestConstants.manifestOptions(projectName), opts).then((answers) => {
211
- packageManager = answers.packageManager || packageManager;
212
- useTypescript = answers.useTypescript || useTypescript;
213
-
214
- const manifest = manifestHelpers.fillManifest(answers);
215
-
216
- initPackage(manifest);
217
- });
218
- }
219
-
220
- console.log();
221
- }
222
-
223
- function addTemplate(root, appType, runtime) {
224
- console.log(chalk.green('Copying app template...'));
225
- console.log();
226
-
227
- const templateFolder = path.resolve(__dirname, 'template', appType, runtime);
228
-
229
- utils.copyFolderRecursiveSync(templateFolder, root, runtime);
230
-
231
- const gitignore = path.join(root, 'gitignore');
232
-
233
- if (fs.pathExistsSync(gitignore)) {
234
- // We can't have .gitignore file in our templates.
235
- // It's missing when @corva/create-app is installed.
236
- // That's why we manually rename gitignore to .gitignore after copying template
237
-
238
- fs.renameSync(gitignore, path.join(root, '.gitignore'));
239
- }
240
-
241
- console.log(chalk.green('Done: copying app template!'));
242
- }
243
-
244
- function configureApp(root, appType, runtime, manifest) {
245
- if (appType === APP_TYPES.UI) {
246
- addPackageJSON(root, manifest.application.name);
247
- } else if (runtime.startsWith(TEMPLATE_TYPES.NODE)) {
248
- updatePackageJSON(root, manifest.application.description, appType, runtime);
249
- }
250
-
251
- if (runtime.startsWith(TEMPLATE_TYPES.PYTHON) && appType === APP_TYPES.SCHEDULER) {
252
- patchSchedulerForPython(root, appType, runtime, manifest);
253
- }
254
- }
255
-
256
- function patchSchedulerForPython(root, appType, runtime, manifest) {
257
- const schedulerType = manifest.settings.app.scheduler_type;
258
-
259
- if (schedulerType === manifestConstants.SCHEDULER_TYPE_DATA_TIME.value) {
260
- return;
261
- }
262
-
263
- const templateFolder = path.resolve(__dirname, 'template', appType, runtime);
264
- const originalType = 'ScheduledDataTimeEvent';
265
- const replacementType =
266
- schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value
267
- ? 'ScheduledDepthEvent'
268
- : 'ScheduledNaturalTimeEvent';
269
- const patchedCode = fs
270
- .readFileSync(path.join(templateFolder, 'lambda_function.py'), 'utf-8')
271
- .replace(new RegExp(originalType, 'g'), replacementType);
272
-
273
- fs.writeFileSync(path.join(root, 'lambda_function.py'), patchedCode);
274
- }
275
-
276
- function addPackageJSON(root, appName) {
277
- const devDependencies = {
278
- ...packageConstants.dependencies.devDependencies,
279
- ...(useTypescript && packageConstants.tsDependencies.devDependencies),
280
- };
281
- const packageJson = {
282
- name: appName.replace(/\W/g, ''),
283
- version: '0.0.1',
284
- main: 'src/index.js',
285
- scripts: packageConstants.scripts,
286
- ...packageConstants.dependencies,
287
- devDependencies,
288
- };
289
-
290
- fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) + os.EOL);
291
- }
292
-
293
- function updatePackageJSON(root, description, appType, runtime) {
294
- const templateFolder = path.resolve(__dirname, 'template', appType, runtime);
295
-
296
- let packageJson = JSON.parse(fs.readFileSync(path.join(templateFolder, 'package.json'), 'utf-8'));
297
-
298
- packageJson.name = projectName.replace(/\W/g, '-').toLowerCase();
299
- packageJson.description = description;
300
-
301
- packageJson.scripts.bundle = packageJson.scripts.bundle.replace(
302
- '$LOCKFILE',
303
- getLockFileName(packageManager)
304
- );
305
-
306
- fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) + os.EOL);
307
- }
308
-
309
- function installApp(appPath, appType, runtime) {
310
- switch (runtime) {
311
- case TEMPLATE_TYPES.PYTHON: {
312
- break;
313
- }
314
- default: {
315
- installJsApp(appPath, appType);
316
-
317
- break;
318
- }
319
- }
320
- }
321
-
322
- function installJsApp(appPath, appType) {
323
- const command = packageManager;
324
- const args = ['install'];
325
-
326
- console.log(chalk.yellow(`Installing template dependencies using ${command}...`));
327
- const proc = spawn.sync(command, args, { stdio: ['inherit', 'inherit', 'pipe'], cwd: appPath });
328
-
329
- if (proc.stderr) {
330
- const error = proc.stderr
331
- .toString('utf8')
332
- .split('\n')
333
- // NOTE: filter out warnings caused by @corva/ui peer dependencies
334
- .filter(line => !line.includes('@corva/ui'))
335
- .join('\n');
336
- console.log(error);
337
- }
338
-
339
- if (proc.status !== 0) {
340
- console.error(`\`${command} ${args.join(' ')}\` failed`);
341
- return;
342
- }
343
-
344
- console.log(chalk.green('Successfull project install'));
345
-
346
- let initializedGit = false;
347
- if (versioning.tryGitInit(appPath)) {
348
- initializedGit = true;
349
- console.log();
350
- console.log('Initialized a git repository.');
351
- }
352
-
353
- if (initializedGit && versioning.tryGitCommit(appPath)) {
354
- console.log();
355
- console.log('Created git commit.');
356
- }
357
-
358
- console.log();
359
- console.log(`Success! Created ${projectName} at ${appPath}`);
360
-
361
- if (appType === APP_RUNTIMES.UI) {
362
- console.log('Inside that directory, you can run several commands:');
363
- helpCommands();
364
- }
365
- }
366
-
367
- async function helpCommands() {
368
- const displayedCommand = packageManager;
369
- const useYarn = shouldUseYarn();
370
-
371
- console.log();
372
- console.log(chalk.cyan(` ${displayedCommand} start`));
373
- console.log(' Starts the development server.');
374
- console.log();
375
- console.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}build`));
376
- console.log(' Bundles the app into static files for production.');
377
- console.log();
378
- console.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}zip`));
379
- console.log(' Bundles the app into ZIP file in app root directory');
380
- console.log();
381
- console.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}release`));
382
- console.log(' Uploads the app ZIP to Corva');
383
- console.log();
384
- }
385
-
386
- initialChecks();
@@ -1,7 +0,0 @@
1
- const zipAppSource = require('./zipAppSource');
2
- const releaseAppZip = require('./releaseAppZip');
3
-
4
- module.exports = {
5
- zipAppSource,
6
- releaseAppZip,
7
- };