@corva/create-app 0.44.0-0 → 0.44.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 (43) hide show
  1. package/bin/create-corva-app.cjs +8 -11
  2. package/lib/bump-version.option.js +10 -18
  3. package/lib/constants/manifest.js +29 -10
  4. package/lib/constants/package.js +8 -4
  5. package/lib/flow.js +4 -6
  6. package/lib/flows/lib/api.js +14 -14
  7. package/lib/flows/lib/create-zip-archive.js +10 -4
  8. package/lib/flows/lib/json.js +4 -3
  9. package/lib/flows/lib/notification.js +3 -0
  10. package/lib/flows/steps/attach/add-app-to-stream.js +4 -5
  11. package/lib/flows/steps/attach/get-all-live-assets.js +7 -14
  12. package/lib/flows/steps/attach/index.js +1 -5
  13. package/lib/flows/steps/attach/prepare-data.js +0 -1
  14. package/lib/flows/steps/prepare-load-app-files.js +2 -4
  15. package/lib/flows/steps/release/get-config.js +3 -2
  16. package/lib/flows/steps/release/remove-failed-upload.js +2 -13
  17. package/lib/flows/steps/release/upload-zip-to-corva.js +3 -8
  18. package/lib/flows/steps/release/wait-for-build.js +3 -2
  19. package/lib/flows/steps/rerun/create-task.js +8 -9
  20. package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +8 -12
  21. package/lib/flows/steps/rerun/get-app-version.js +8 -7
  22. package/lib/flows/steps/rerun/prepare-data.js +13 -12
  23. package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +22 -18
  24. package/lib/flows/steps/zip-cleanup.js +2 -2
  25. package/lib/flows/steps/zip-create-archive.js +2 -2
  26. package/lib/flows/steps/zip-file-list-resolve.js +24 -14
  27. package/lib/flows/steps/zip-prepare.js +3 -3
  28. package/lib/flows/steps/zip.js +1 -6
  29. package/lib/helpers/resolve-app-runtime.js +8 -5
  30. package/lib/helpers/utils.js +5 -4
  31. package/lib/helpers/versioning.js +14 -2
  32. package/lib/main.js +59 -73
  33. package/lib/scripts/utils/version.js +2 -0
  34. package/package.json +76 -68
  35. package/templates/javascript/scheduler/.eslintrc.js +1 -0
  36. package/templates/javascript/scheduler/.prettierrc +1 -0
  37. package/templates/javascript/stream/.eslintrc.js +1 -0
  38. package/templates/javascript/stream/.prettierrc +1 -0
  39. package/templates/javascript/task/.eslintrc.js +1 -0
  40. package/templates/javascript/task/.prettierrc +1 -0
  41. package/templates/typescript/scheduler/.prettierrc +1 -0
  42. package/templates/typescript/stream/.prettierrc +1 -0
  43. package/templates/typescript/task/.prettierrc +1 -0
package/lib/main.js CHANGED
@@ -1,44 +1,45 @@
1
+ /* eslint-disable no-undef */
1
2
  import chalk from 'chalk';
2
- import figlet from 'figlet';
3
3
  import { Command, CommanderError, Option } from 'commander';
4
+ import figlet from 'figlet';
4
5
  import fs from 'fs-extra';
5
6
  import inquirer from 'inquirer';
6
7
  import os from 'node:os';
7
8
  import path, { resolve } from 'node:path';
8
9
  import semver from 'semver';
9
10
 
10
- import { ensureLatestVersion, warnIfOutdated, ensureBumpVersion } from './scripts/utils/version.js';
11
- import * as utils from './helpers/utils.js';
12
11
  import * as manifestHelpers from './helpers/manifest.js';
12
+ import * as utils from './helpers/utils.js';
13
13
  import * as versioning from './helpers/versioning.js';
14
+ import { ensureBumpVersion, ensureLatestVersion, warnIfOutdated } from './scripts/utils/version.js';
14
15
 
15
- import { getDefaultsForPackageJson } from './constants/package.js';
16
16
  import * as manifestConstants from './constants/manifest.js';
17
+ import { getDefaultsForPackageJson } from './constants/package.js';
17
18
 
18
- import packageJson from '../package.json' assert { type: 'json' };
19
- import { clear } from 'node:console';
20
19
  import spawn from 'cross-spawn';
21
- import { runFlow } from './flow.js';
22
- import { ERROR_ICON } from './constants/messages.js';
23
- import { StepError } from './flows/lib/step-error.js';
24
- import { RELEASE_FLOW } from './flows/release.js';
25
- import { RERUN_FLOW } from './flows/rerun.js';
26
- import { ATTACH_FLOW } from './flows/attach.js';
27
- import { ZIP_FLOW } from './flows/zip.js';
20
+ import _ from 'lodash/fp.js';
21
+ import { clear } from 'node:console';
22
+ import { existsSync } from 'node:fs';
23
+ import { fileURLToPath } from 'node:url';
24
+ import packageJson from '../package.json' assert { type: 'json' };
28
25
  import {
29
- bumpVersionOption,
30
26
  apiKeyOption,
31
- envOption,
32
- silentOption,
33
27
  appVersion,
28
+ bumpVersionOption,
29
+ envOption,
34
30
  originalCwdOption,
31
+ silentOption,
35
32
  } from './bump-version.option.js';
33
+ import { ERROR_ICON } from './constants/messages.js';
34
+ import { runFlow } from './flow.js';
35
+ import { ATTACH_FLOW } from './flows/attach.js';
36
36
  import { Manifest } from './flows/lib/manifest.js';
37
- import { IS_WINDOWS, resolveAppRuntime } from './helpers/resolve-app-runtime.js';
38
- import { existsSync } from 'node:fs';
39
- import { fileURLToPath } from 'node:url';
37
+ import { StepError } from './flows/lib/step-error.js';
38
+ import { RELEASE_FLOW } from './flows/release.js';
39
+ import { RERUN_FLOW } from './flows/rerun.js';
40
+ import { ZIP_FLOW } from './flows/zip.js';
40
41
  import { logger } from './helpers/logger.js';
41
- import _ from 'lodash/fp.js';
42
+ import { IS_WINDOWS, resolveAppRuntime } from './helpers/resolve-app-runtime.js';
42
43
 
43
44
  const __filename = fileURLToPath(import.meta.url);
44
45
  const __dirname = path.dirname(__filename);
@@ -58,7 +59,7 @@ const silencer =
58
59
  }
59
60
  };
60
61
 
61
- const getRealWorkingDir = (relativePath, options) => resolve(options.originalCwd, relativePath)
62
+ const getRealWorkingDir = (relativePath, options) => resolve(options.originalCwd, relativePath);
62
63
 
63
64
  function startingMessage() {
64
65
  clear();
@@ -70,16 +71,19 @@ function checkNodeVersion() {
70
71
  logger.write('Checking node version...');
71
72
 
72
73
  const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16');
74
+
73
75
  if (unsupportedNodeVersion) {
74
76
  logger.log(
75
77
  chalk.red(
76
78
  `\nYou are using Node ${process.version}.\n\n` +
77
- `Please update to Node 16 or higher for a better, fully supported experience.\n`
78
- )
79
+ `Please update to Node 16 or higher for a better, fully supported experience.\n`,
80
+ ),
79
81
  );
82
+
80
83
  // Fall back to latest supported react-scripts on Node 4
81
84
  return process.exit(1);
82
85
  }
86
+
83
87
  logger.write(' ✅ \n');
84
88
  }
85
89
 
@@ -101,10 +105,10 @@ function checkOptions(opts) {
101
105
  };
102
106
  }
103
107
 
108
+ // eslint-disable-next-line no-unused-vars
104
109
  const printDeprecationNotice = (param) =>
105
110
  console.warn(
106
- chalk.bgYellowBright`DEPRECATED OPTION: ${param}` +
107
- ` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`
111
+ chalk.bgYellowBright`DEPRECATED OPTION: ${param}` + ` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`,
108
112
  );
109
113
 
110
114
  export async function run() {
@@ -127,19 +131,15 @@ export async function run() {
127
131
  manifestConstants.manifestOptions().forEach((value) => {
128
132
  const type = typeof value.default;
129
133
  const option = new Option(
130
- `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${
131
- (type !== 'undefined' && type) || 'string'
132
- }]`,
133
- value.message
134
+ `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${(type !== 'undefined' && type) || 'string'}]`,
135
+ value.message,
134
136
  );
135
137
 
136
138
  if (value.choices) {
137
139
  if (typeof value.choices === 'function') {
138
140
  option.choices(value.choices());
139
141
  } else {
140
- option.choices(
141
- value.choices.map((choice) => `${typeof choice === 'object' ? choice.value : choice}`)
142
- );
142
+ option.choices(value.choices.map((choice) => `${typeof choice === 'object' ? choice.value : choice}`));
143
143
  }
144
144
  }
145
145
 
@@ -180,10 +180,14 @@ export async function run() {
180
180
  silencer(async (dirName, patterns, options) => {
181
181
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
182
182
 
183
- console.log(getRealWorkingDir(dirName, options), options)
183
+ console.log(getRealWorkingDir(dirName, options), options);
184
184
 
185
- return runFlow(ZIP_FLOW, { dirName: getRealWorkingDir(dirName, options), patterns, options }).then(_.get('zipFileName'));
186
- })
185
+ return runFlow(ZIP_FLOW, {
186
+ dirName: getRealWorkingDir(dirName, options),
187
+ patterns,
188
+ options,
189
+ }).then(_.get('zipFileName'));
190
+ }),
187
191
  );
188
192
 
189
193
  program
@@ -198,26 +202,20 @@ export async function run() {
198
202
  .addOption(apiKeyOption)
199
203
  .addOption(originalCwdOption)
200
204
  .addOption(new Option('--notes [string]', 'Add custom notes to published app'))
205
+ .addOption(new Option('--label [string]', 'Put a label on the release').choices(['BETA', 'PROD']))
206
+ .addOption(new Option('--remove-on-fail [boolean]', 'Remove release if it fails during deployment').default(false))
201
207
  .addOption(
202
- new Option('--label [string]', 'Put a label on the release').choices(['BETA', 'PROD'])
203
- )
204
- .addOption(
205
- new Option(
206
- '--remove-on-fail [boolean]',
207
- 'Remove release if it fails during deployment'
208
- ).default(false)
209
- )
210
- .addOption(
211
- new Option(
212
- '--remove-on-success [boolean]',
213
- 'App package (.zip) will not be deleted after upload'
214
- ).default(true)
208
+ new Option('--remove-on-success [boolean]', 'App package (.zip) will not be deleted after upload').default(true),
215
209
  )
216
210
  // .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
217
211
  .action(async (dirName, patterns, options) => {
218
212
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
219
213
 
220
- await runFlow(RELEASE_FLOW, { dirName: getRealWorkingDir(dirName, options), patterns, options });
214
+ await runFlow(RELEASE_FLOW, {
215
+ dirName: getRealWorkingDir(dirName, options),
216
+ patterns,
217
+ options,
218
+ });
221
219
  });
222
220
 
223
221
  program
@@ -285,16 +283,12 @@ const handleCommanderError = (e) => {
285
283
  const commandName = program.args[0] || program._defaultCommandName;
286
284
 
287
285
  console.error('Please specify the project directory:');
288
- logger.log(
289
- ` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`
290
- );
286
+ logger.log(` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`);
291
287
  logger.log();
292
288
  logger.log('For example:');
293
289
  logger.log(` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('my-react-app')}`);
294
290
  logger.log();
295
- logger.log(
296
- `Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`
297
- );
291
+ logger.log(`Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`);
298
292
  } else {
299
293
  console.error('❌', e.message);
300
294
  }
@@ -339,8 +333,8 @@ async function initPackage(projectName, opts) {
339
333
  if (!(await runtime.isRuntimeAvailable())) {
340
334
  throw new Error(
341
335
  `Runtime "${opts.runtime}" is not available locally. Please proceed to ${chalk.green(
342
- getEnvManagementLink(manifest)
343
- )} to install it locally.`
336
+ getEnvManagementLink(manifest),
337
+ )} to install it locally.`,
344
338
  );
345
339
  }
346
340
 
@@ -355,6 +349,7 @@ async function initPackage(projectName, opts) {
355
349
  if (fs.existsSync(root)) {
356
350
  throw new Error(`Directory already exists: ${root}`);
357
351
  }
352
+
358
353
  await fs.mkdir(root);
359
354
  await fs.writeJSON(path.join(root, 'manifest.json'), manifest.manifest, writejsonOptions);
360
355
 
@@ -393,13 +388,7 @@ async function addTemplate(root, manifest, runtime) {
393
388
  logger.log(chalk.green('Copying app template...'));
394
389
  logger.log();
395
390
 
396
- const templateFolder = path.resolve(
397
- __dirname,
398
- '..',
399
- 'templates',
400
- runtime.language,
401
- manifest.type
402
- );
391
+ const templateFolder = path.resolve(__dirname, '..', 'templates', runtime.language, manifest.type);
403
392
 
404
393
  utils.copyFolderRecursiveSync(templateFolder, root);
405
394
 
@@ -462,7 +451,7 @@ const addTsConfigs = (root, manifest, runtime) => {
462
451
  inlineSourceMap: true,
463
452
  },
464
453
  },
465
- writejsonOptions
454
+ writejsonOptions,
466
455
  ),
467
456
  fs.writeJson(
468
457
  path.resolve(root, 'tsconfig.build.json'),
@@ -471,7 +460,7 @@ const addTsConfigs = (root, manifest, runtime) => {
471
460
  include: ['lib/**/*.ts', 'index.ts'],
472
461
  exclude: ['node_modules', '**/*.spec.ts'],
473
462
  },
474
- writejsonOptions
463
+ writejsonOptions,
475
464
  ),
476
465
  ]);
477
466
  };
@@ -483,13 +472,7 @@ function patchSchedulerForPython(root, manifest, runtime) {
483
472
  return;
484
473
  }
485
474
 
486
- const templateFolder = path.resolve(
487
- __dirname,
488
- '..',
489
- 'templates',
490
- runtime.language,
491
- manifest.type
492
- );
475
+ const templateFolder = path.resolve(__dirname, '..', 'templates', runtime.language, manifest.type);
493
476
  const originalType = 'ScheduledDataTimeEvent';
494
477
  const replacementType =
495
478
  schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value
@@ -544,6 +527,7 @@ async function installApp(root, manifest, runtime) {
544
527
  }
545
528
 
546
529
  logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
530
+
547
531
  const proc =
548
532
  manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
549
533
  ? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
@@ -559,11 +543,13 @@ async function installApp(root, manifest, runtime) {
559
543
  // NOTE: filter out warnings caused by @corva/ui peer dependencies
560
544
  .filter((line) => !line.includes('@corva/ui'))
561
545
  .join('\n');
546
+
562
547
  console.log(error);
563
548
  }
564
549
 
565
550
  if (proc.status !== 0) {
566
551
  console.error(`\`${command} ${args.join(' ')}\` failed`);
552
+
567
553
  return;
568
554
  }
569
555
 
@@ -5,6 +5,7 @@ import inquirer from 'inquirer';
5
5
 
6
6
  import packageJson from '../../../package.json' assert { type: 'json' };
7
7
  import { logger } from '../../helpers/logger.js';
8
+
8
9
  const npm = new NpmApi();
9
10
 
10
11
  const error = chalk.bold.red;
@@ -21,6 +22,7 @@ export async function ensureLatestVersion() {
21
22
  const latestVersion = await getLatestVersion();
22
23
 
23
24
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
25
+
24
26
  if (isCurrentVersionOutdated) {
25
27
  console.log(error(asterisks));
26
28
  console.log(error`
package/package.json CHANGED
@@ -1,71 +1,79 @@
1
1
  {
2
- "name": "@corva/create-app",
3
- "version": "0.44.0-0",
4
- "private": false,
5
- "description": "Create an app to use it in CORVA.AI",
6
- "keywords": [
7
- "react"
8
- ],
9
- "bugs": {
10
- "url": "https://github.com/facebook/create-react-app/issues"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/corva-ai/create-corva-app",
15
- "directory": "@corva/create-app"
16
- },
17
- "license": "MIT",
18
- "type": "module",
19
- "bin": {
20
- "create-corva-app": "./bin/create-corva-app.cjs"
21
- },
22
- "files": [
23
- "bin/**/*.cjs",
24
- "bin/**/*.js",
25
- "lib/**/*.js",
26
- "templates",
27
- "common"
28
- ],
29
- "scripts": {
30
- "lint": "prettier . --write",
31
- "build": "echo \"build is not configured for package \\\"×\\\", skipping.\"",
32
- "get-changelog": "conventional-changelog -r 2 -p angular",
33
- "release": "git add -A && standard-version -a",
34
- "release-rc": "npm run release -- --prerelease"
35
- },
36
- "dependencies": {
37
- "archiver": "^5.3.0",
38
- "chalk": "4.1.0",
39
- "commander": "^9.1.0",
40
- "cross-spawn": "^7.0.3",
41
- "debug": "^4.3.4",
42
- "dotenv": "^16.0.0",
43
- "figlet": "^1.5.0",
44
- "form-data": "^4.0.0",
45
- "fs-extra": "9.0.1",
46
- "glob": "^8.0.1",
47
- "got": "^12.5.1",
48
- "inquirer": "^8.2.3",
49
- "is-glob": "^4.0.3",
50
- "lodash": "^4.17.21",
51
- "npm-api": "^1.0.0",
52
- "semver": "7.3.2",
53
- "terminal-link": "^3.0.0"
54
- },
55
- "devDependencies": {
56
- "@corva/eslint-config-browser": "^0.0.4",
57
- "@corva/eslint-config-node": "^4.2.0",
58
- "@types/cross-spawn": "^6.0.2",
59
- "conventional-changelog-cli": "^2.1.0",
60
- "prettier": "^2.4.1",
61
- "standard-version": "^9.0.0"
62
- },
63
- "engines": {
64
- "node": ">=16"
65
- },
66
- "standard-version": {
67
- "skip": {
68
- "tag": true
69
- }
2
+ "name": "@corva/create-app",
3
+ "version": "0.44.0-2",
4
+ "private": false,
5
+ "description": "Create an app to use it in CORVA.AI",
6
+ "keywords": [
7
+ "react"
8
+ ],
9
+ "bugs": {
10
+ "url": "https://github.com/facebook/create-react-app/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/corva-ai/create-corva-app",
15
+ "directory": "@corva/create-app"
16
+ },
17
+ "license": "MIT",
18
+ "type": "module",
19
+ "bin": {
20
+ "create-corva-app": "./bin/create-corva-app.cjs"
21
+ },
22
+ "files": [
23
+ "bin/**/*.cjs",
24
+ "bin/**/*.js",
25
+ "lib/**/*.js",
26
+ "templates",
27
+ "common"
28
+ ],
29
+ "scripts": {
30
+ "build": "echo \"build is not configured for package \\\"×\\\", skipping.\"",
31
+ "get-changelog": "conventional-changelog -r 2 -p angular",
32
+ "lint": "eslint .",
33
+ "lint:fix": "eslint . --fix",
34
+ "release": "git add -A && standard-version -a",
35
+ "release-rc": "npm run release -- --prerelease"
36
+ },
37
+ "lint-staged": {
38
+ "*.{js,json}": "npm run lint:fix"
39
+ },
40
+ "dependencies": {
41
+ "archiver": "^5.3.0",
42
+ "chalk": "4.1.0",
43
+ "commander": "^9.1.0",
44
+ "cross-spawn": "^7.0.3",
45
+ "debug": "^4.3.4",
46
+ "dotenv": "^16.0.0",
47
+ "figlet": "^1.5.0",
48
+ "form-data": "^4.0.0",
49
+ "fs-extra": "9.0.1",
50
+ "glob": "^8.0.1",
51
+ "got": "^12.5.1",
52
+ "inquirer": "^8.2.3",
53
+ "is-glob": "^4.0.3",
54
+ "lodash": "^4.17.21",
55
+ "npm-api": "^1.0.0",
56
+ "semver": "7.3.2",
57
+ "terminal-link": "^3.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "@babel/eslint-parser": "^7.19.1",
61
+ "@babel/plugin-syntax-import-assertions": "^7.20.0",
62
+ "@commitlint/cli": "^17.3.0",
63
+ "@commitlint/config-conventional": "^17.3.0",
64
+ "@corva/eslint-config-browser": "^0.0.4",
65
+ "@corva/eslint-config-node": "^5.0.0",
66
+ "@types/cross-spawn": "^6.0.2",
67
+ "conventional-changelog-cli": "^2.1.0",
68
+ "husky": "^8.0.2",
69
+ "standard-version": "^9.0.0"
70
+ },
71
+ "engines": {
72
+ "node": ">=16"
73
+ },
74
+ "standard-version": {
75
+ "skip": {
76
+ "tag": true
70
77
  }
78
+ }
71
79
  }
@@ -0,0 +1 @@
1
+ module.exports = { extends: '@corva/eslint-config-node' };
@@ -0,0 +1 @@
1
+ "@corva/eslint-config-node/prettier"
@@ -0,0 +1 @@
1
+ module.exports = { extends: '@corva/eslint-config-node' };
@@ -0,0 +1 @@
1
+ "@corva/eslint-config-node/prettier"
@@ -0,0 +1 @@
1
+ module.exports = { extends: '@corva/eslint-config-node' };
@@ -0,0 +1 @@
1
+ "@corva/eslint-config-node/prettier"
@@ -0,0 +1 @@
1
+ "@corva/eslint-config-node/prettier"
@@ -0,0 +1 @@
1
+ "@corva/eslint-config-node/prettier"
@@ -0,0 +1 @@
1
+ "@corva/eslint-config-node/prettier"