@corva/create-app 0.11.0-0 → 0.12.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 (60) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +57 -0
  3. package/constants/manifest.js +91 -49
  4. package/constants/package.js +23 -24
  5. package/helpers/manifest.js +25 -12
  6. package/helpers/utils.js +2 -2
  7. package/helpers/versioning.js +14 -14
  8. package/index.js +158 -164
  9. package/package.json +62 -58
  10. package/scripts/ui/index.js +2 -2
  11. package/scripts/ui/zipAppSource.js +31 -41
  12. package/scripts/utils/version.js +9 -22
  13. package/template/scheduler/node/__test__/processor.test.js +12 -12
  14. package/template/scheduler/node/gitignore +21 -0
  15. package/template/scheduler/node/index.js +5 -6
  16. package/template/scheduler/node/package.json +3 -3
  17. package/template/scheduler/node/src/processor.js +9 -13
  18. package/template/scheduler/node-ts/README.md +25 -0
  19. package/template/scheduler/node-ts/__test__/processor.spec.ts +20 -0
  20. package/template/scheduler/node-ts/gitignore +25 -0
  21. package/template/scheduler/node-ts/index.ts +8 -0
  22. package/template/scheduler/node-ts/lib/processor.ts +13 -0
  23. package/template/scheduler/node-ts/package.json +37 -0
  24. package/template/scheduler/node-ts/tsconfig.build.json +11 -0
  25. package/template/scheduler/node-ts/tsconfig.json +33 -0
  26. package/template/stream/node/README.md +1 -1
  27. package/template/stream/node/__test__/processor.test.js +37 -40
  28. package/template/stream/node/gitignore +21 -0
  29. package/template/stream/node/index.js +5 -6
  30. package/template/stream/node/package.json +3 -3
  31. package/template/stream/node/src/processor.js +11 -14
  32. package/template/stream/node-ts/README.md +25 -0
  33. package/template/stream/node-ts/__test__/processor.spec.ts +43 -0
  34. package/template/stream/node-ts/gitignore +25 -0
  35. package/template/stream/node-ts/index.ts +8 -0
  36. package/template/stream/node-ts/lib/processor.ts +16 -0
  37. package/template/stream/node-ts/package.json +37 -0
  38. package/template/stream/node-ts/tsconfig.build.json +11 -0
  39. package/template/stream/node-ts/tsconfig.json +33 -0
  40. package/template/task/node/README.md +1 -1
  41. package/template/task/node/__test__/processor.test.js +18 -0
  42. package/template/task/node/gitignore +21 -0
  43. package/template/task/node/index.js +7 -8
  44. package/template/task/node/package.json +3 -3
  45. package/template/task/node/src/processor.js +9 -14
  46. package/template/task/node-ts/README.md +25 -0
  47. package/template/task/node-ts/__test__/processor.spec.ts +27 -0
  48. package/template/task/node-ts/gitignore +25 -0
  49. package/template/task/node-ts/index.ts +8 -0
  50. package/template/task/node-ts/package.json +37 -0
  51. package/template/task/node-ts/src/processor.ts +13 -0
  52. package/template/task/node-ts/tsconfig.build.json +11 -0
  53. package/template/task/node-ts/tsconfig.json +33 -0
  54. package/template/ui/README.md +1 -1
  55. package/template/ui/gitignore +1 -0
  56. package/template/ui/src/App.js +2 -1
  57. package/template/ui/src/AppSettings.js +1 -1
  58. package/template/ui/src/constants.js +1 -1
  59. package/template/ui/src/index.js +2 -2
  60. package/helpers/metadata.js +0 -29
package/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [0.12.0-2](https://github.com/corva-ai/create-corva-app/compare/v0.12.0-1...v0.12.0-2) (2021-09-21)
6
+
7
+
8
+ ### Features
9
+
10
+ * add typescript app templates ([f256b39](https://github.com/corva-ai/create-corva-app/commit/f256b3970b4a2f426c6f87ddd10fe5c957757658))
11
+ * **DC-2167:** updated node templates to use latest sdk ([#118](https://corvaqa.atlassian.net/browse/118)) ([c9dc93a](https://github.com/corva-ai/create-corva-app/commit/c9dc93a07a48b06f4c0831bcd95aca4fd5b5504c))
12
+
13
+ ## [0.12.0-1](https://github.com/corva-ai/create-corva-app/compare/v0.12.0-0...v0.12.0-1) (2021-09-20)
14
+
15
+
16
+ ### Features
17
+
18
+ * **DC-2204:** Add .env file to gitignore ([cb598d6](https://github.com/corva-ai/create-corva-app/commit/cb598d654dcd78f20ce93c6dcf7bf4282cad47c9))
19
+
20
+ ## [0.12.0-0](https://github.com/corva-ai/create-corva-app/compare/v0.11.0-0...v0.12.0-0) (2021-09-14)
21
+
22
+
23
+ ### Features
24
+
25
+ * **DC-2132:** add scheduler type to manifest template ([#112](https://corvaqa.atlassian.net/browse/112)) ([4955186](https://github.com/corva-ai/create-corva-app/commit/4955186a4d2e5ee8c0d5a3e44ecd54752d561de3))
26
+
5
27
  ## [0.11.0-0](https://github.com/corva-ai/create-corva-app/compare/v0.10.0-0...v0.11.0-0) (2021-08-31)
6
28
 
7
29
  ## [0.10.0-0](https://github.com/corva-ai/create-corva-app/compare/v0.9.0-0...v0.10.0-0) (2021-08-18)
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @corva/create-app
2
+
3
+ Apps generator for [corva.ai](https://corva.ai).
4
+
5
+ ## Prerequisites
6
+
7
+ - NodeJs 12+ (https://nodejs.org/en/download/)
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm i -g @corva/create-app
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ `corva-create-app` provides a user-friendly CLI wizard to create an app.
18
+
19
+ ```sh
20
+ Usage: corva-create-app <project-directory> [options]
21
+
22
+ Arguments:
23
+ project-directory project directory to work with
24
+
25
+ Options:
26
+ -V, --version output the version number
27
+ -z, --zip <type> zip app source
28
+ -t, --useTypescript use typescript or javascript (default: false)
29
+ -p, --packageManager <value> package manager to use (choices: "npm", "yarn", default: "yarn")
30
+ --appType [value]
31
+ --appKey [value]
32
+ --appName [value]
33
+ --category [value]
34
+ --segments [value]
35
+ --runtime [value]
36
+ -h, --help display help for command
37
+ ```
38
+
39
+ ## Examples
40
+
41
+ ### Create a UI application
42
+
43
+ ```sh
44
+ create-corva-app test --appName "Test" --segments "drilling" --category "wellDesign" --appKey "some-company.test.ui" --appType "ui" --runtime "ui"
45
+ ```
46
+
47
+ ### Create a NodeJs TypeScript application
48
+
49
+ ```sh
50
+ create-corva-app test --appName "Test" --segments "drilling" --category "wellDesign" --appKey "some-company.test.scheduler" --appType "scheduler" --runtime "nodejs12.x" -t
51
+ ```
52
+
53
+ ### Create a Python application
54
+
55
+ ```sh
56
+ create-corva-app test --appName "Test" --segments "drilling" --category "analytics" --appKey "some-company.test.stream" --appType "stream" --runtime "python3.8"
57
+ ```
@@ -1,30 +1,29 @@
1
1
  const defaultManifest = {
2
2
  format: 1,
3
3
  license: {
4
- type: "MIT",
5
- url: "https://www.oandgexample.com/license/",
4
+ type: 'MIT',
5
+ url: 'https://www.oandgexample.com/license/',
6
6
  },
7
7
  developer: {
8
- name: "O&G Company",
9
- identifier: "oandgc",
8
+ name: 'O&G Company',
9
+ identifier: 'oandgc',
10
10
  authors: [],
11
11
  },
12
12
  application: {
13
- type: "ui",
14
- key: "app.key-goes-here",
15
- visibility: "private",
16
- name: "Name of My App",
17
- description:
18
- "This is the description of my app. You can do great things with it!",
19
- summary: "More information about this app goes here",
20
- category: "",
21
- website: "https://www.oandgexample.com/my-app/",
22
- segments: ["drilling", "completion"],
13
+ type: 'ui',
14
+ key: 'app.key-goes-here',
15
+ visibility: 'private',
16
+ name: 'Name of My App',
17
+ description: 'This is the description of my app. You can do great things with it!',
18
+ summary: 'More information about this app goes here',
19
+ category: '',
20
+ website: 'https://www.oandgexample.com/my-app/',
21
+ segments: ['drilling', 'completion'],
23
22
  },
24
23
  settings: {
25
24
  entrypoint: {
26
- file: "index.js",
27
- function: "handler",
25
+ file: 'index.js',
26
+ function: 'handler',
28
27
  },
29
28
  environment: {},
30
29
  },
@@ -37,8 +36,8 @@ const defaultUIAppManifest = {
37
36
  },
38
37
  settings: {
39
38
  entrypoint: {
40
- file: "src/index.js",
41
- function: "handler",
39
+ file: 'src/index.js',
40
+ function: 'handler',
42
41
  },
43
42
  environment: {},
44
43
  },
@@ -47,8 +46,8 @@ const defaultUIAppManifest = {
47
46
  const defaultDataAppNodeManifest = {
48
47
  settings: {
49
48
  entrypoint: {
50
- file: "index.js",
51
- function: "handler",
49
+ file: 'index.js',
50
+ function: 'handler',
52
51
  },
53
52
  timeout: 120,
54
53
  memory: 128,
@@ -59,8 +58,8 @@ const defaultDataAppNodeManifest = {
59
58
  const defaultDataAppPythonManifest = {
60
59
  settings: {
61
60
  entrypoint: {
62
- file: "lambda_function",
63
- function: "lambda_handler",
61
+ file: 'lambda_function',
62
+ function: 'lambda_handler',
64
63
  },
65
64
  timeout: 120,
66
65
  memory: 128,
@@ -68,43 +67,86 @@ const defaultDataAppPythonManifest = {
68
67
  },
69
68
  };
70
69
 
71
- const defaultSchedulerAppSettings = {
72
- app: {
73
- cron_string: "*/5 * * * *",
74
- },
70
+ const defaultTimeSchedulerSettings = {
71
+ scheduler_type: 'data_time',
72
+ cron_string: '*/5 * * * *',
75
73
  };
76
74
 
77
- const MANIFEST_MANDATORY_KEYS = [
78
- 'appType',
79
- 'appKey',
80
- 'appName',
81
- 'category',
82
- 'segments',
83
- 'runtime'
84
- ];
75
+ const defaultDepthSchedulerSettings = {
76
+ scheduler_type: 'data_depth',
77
+ depth_milestone: 1,
78
+ };
85
79
 
86
- const manifestOptions = {
87
- developerName: "O&G Company",
88
- developerIdentifier: "oandgc",
80
+ const MANIFEST_MANDATORY_KEYS = ['appType', 'appKey', 'appName', 'category', 'segments', 'runtime'];
89
81
 
90
- appType: ["ui", "scheduler", "stream", "task"],
91
- appKey: "app.key-goes-here",
92
- appName: "Name of My App",
93
- description:
94
- "This is the description of my app. You can do great things with it!",
95
- summary: "More information about this app goes here",
96
- category: "",
97
- website: "https://www.oandgexample.com/my-app/",
98
- segments: ["drilling", "completion"],
99
- runtime: ["ui", "python3.8", "nodejs12.x"]
100
- };
82
+ const manifestOptions = (projectName) => [
83
+ { name: 'developerName', message: 'Enter the Developer Name', default: 'O&G Company' },
84
+ { name: 'developerIdentifier', message: 'Enter the Developer Identifier', default: 'oandgc' },
85
+ {
86
+ type: 'rawlist',
87
+ name: 'appType',
88
+ message: 'Choose the App Type',
89
+ default: 'ui',
90
+ choices: ['ui', 'scheduler', 'stream', 'task'],
91
+ },
92
+ { name: 'appKey', message: 'Enter the App Key', default: 'app.key-goes-here' },
93
+ { name: 'appName', message: 'Enter the App Name', default: projectName },
94
+ {
95
+ name: 'description',
96
+ message: 'Enter description',
97
+ default: 'This is the description of my app. You can do great things with it!',
98
+ },
99
+ {
100
+ name: 'summary',
101
+ message: 'Enter summary',
102
+ default: 'More information about this app goes here',
103
+ },
104
+ { name: 'category', message: 'Enter category', default: '' },
105
+ { name: 'website', message: 'Enter website', default: 'https://www.oandgexample.com/my-app/' },
106
+ {
107
+ type: 'rawlist',
108
+ name: 'segments',
109
+ message: 'Choose segments',
110
+ choices: ['drilling', 'completion'],
111
+ },
112
+ {
113
+ type: 'rawlist',
114
+ name: 'runtime',
115
+ message: 'Choose runtime',
116
+ choices: ['python3.8', 'nodejs12.x'],
117
+ when: (answers) => answers.appType !== 'ui',
118
+ },
119
+ {
120
+ type: 'rawlist',
121
+ name: 'packageManager',
122
+ message: 'Please select the desired package manager',
123
+ default: 'yarn',
124
+ choices: ['yarn', 'npm'],
125
+ when: (answers) => !answers.runtime || !answers.runtime.startsWith('python'),
126
+ },
127
+ {
128
+ type: 'confirm',
129
+ name: 'useTypescript',
130
+ message: 'Would you like to use TypesScript?',
131
+ default: false,
132
+ when: (answers) => answers.runtime && answers.runtime.startsWith('nodejs'),
133
+ },
134
+ {
135
+ type: 'rawlist',
136
+ name: 'schedulerType',
137
+ message: 'Choose schedulerType',
138
+ choices: ['data_time', 'data_depth', 'natural_time'],
139
+ when: (answers) => answers.appType === 'scheduler',
140
+ },
141
+ ];
101
142
 
102
143
  module.exports = {
103
144
  defaultManifest,
104
145
  defaultUIAppManifest,
105
146
  defaultDataAppNodeManifest,
106
147
  defaultDataAppPythonManifest,
107
- defaultSchedulerAppSettings,
148
+ defaultTimeSchedulerSettings,
149
+ defaultDepthSchedulerSettings,
108
150
  manifestOptions,
109
151
  MANIFEST_MANDATORY_KEYS,
110
152
  };
@@ -1,36 +1,35 @@
1
1
  const dependencies = {
2
2
  devDependencies: {
3
- "postcss-loader": "4.1.0"
3
+ 'postcss-loader': '4.1.0',
4
4
  },
5
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
- }
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
23
  };
24
24
 
25
25
  const scripts = {
26
- build: "webpack --config=./config-overrides.js --mode production",
27
- start:
28
- "webpack-dev-server --config=./config-overrides.js --open --mode development",
29
- zip: "create-corva-app --zip ui",
30
- lint: "eslint --cache ./src/"
26
+ build: 'webpack --config=./config-overrides.js --mode production',
27
+ start: 'webpack-dev-server --config=./config-overrides.js --open --mode development',
28
+ zip: 'create-corva-app --zip ui',
29
+ lint: 'eslint --cache ./src/',
31
30
  };
32
31
 
33
32
  module.exports = {
34
33
  dependencies,
35
- scripts
34
+ scripts,
36
35
  };
@@ -1,9 +1,12 @@
1
- const manifestConstants = require("../constants/manifest.js");
1
+ const manifestConstants = require('../constants/manifest.js');
2
2
 
3
3
  function fillManifest(answers) {
4
+ const runtime = answers.runtime || 'ui';
5
+
4
6
  const defaultManifestProperties = _defaultManifestProperties({
5
7
  type: answers.appType,
6
- runtime: answers.runtime
8
+ // fallback to UI
9
+ runtime,
7
10
  });
8
11
 
9
12
  const manifest = {
@@ -13,7 +16,7 @@ function fillManifest(answers) {
13
16
  ...manifestConstants.defaultManifest.developer,
14
17
  ...defaultManifestProperties.developer,
15
18
  name: answers.developerName,
16
- identifier: answers.developerIdentifier
19
+ identifier: answers.developerIdentifier,
17
20
  },
18
21
  application: {
19
22
  ...manifestConstants.defaultManifest.application,
@@ -25,13 +28,13 @@ function fillManifest(answers) {
25
28
  summary: answers.summary,
26
29
  category: answers.category,
27
30
  website: answers.website,
28
- segments: [answers.segments]
31
+ segments: [answers.segments],
29
32
  },
30
33
  settings: {
31
34
  ...defaultManifestProperties.settings,
32
- runtime: answers.runtime,
33
- ...defaultAppSettings({ type: answers.appType }),
34
- }
35
+ runtime,
36
+ ...defaultAppSettings({ type: answers.appType, schedulerType: answers.schedulerType }),
37
+ },
35
38
  };
36
39
 
37
40
  return manifest;
@@ -49,14 +52,24 @@ function _defaultManifestProperties({ type, runtime }) {
49
52
  return manifestConstants.defaultDataAppNodeManifest;
50
53
  }
51
54
 
52
- function defaultAppSettings({ type }) {
53
- if (type === 'scheduler') {
54
- return manifestConstants.defaultSchedulerAppSettings;
55
+ function defaultAppSettings({ type, schedulerType }) {
56
+ if (!schedulerType) {
57
+ return {};
55
58
  }
56
59
 
57
- return {};
60
+ const schedulerAppSettings =
61
+ schedulerType == 'data_depth'
62
+ ? manifestConstants.defaultDepthSchedulerSettings
63
+ : manifestConstants.defaultTimeSchedulerSettings;
64
+
65
+ return {
66
+ app: {
67
+ ...schedulerAppSettings,
68
+ scheduler_type: schedulerType || 'data_time',
69
+ },
70
+ };
58
71
  }
59
72
 
60
73
  module.exports = {
61
- fillManifest
74
+ fillManifest,
62
75
  };
package/helpers/utils.js CHANGED
@@ -1,5 +1,5 @@
1
- const path = require("path");
2
- const fs = require("fs-extra");
1
+ const path = require('path');
2
+ const fs = require('fs-extra');
3
3
 
4
4
  function copyFileSync(source, target) {
5
5
  let targetFile = target;
@@ -1,9 +1,9 @@
1
- const execSync = require("child_process").execSync;
1
+ const execSync = require('child_process').execSync;
2
2
 
3
3
  function isInGitRepository(appPath) {
4
4
  try {
5
- execSync("git rev-parse --is-inside-work-tree", {
6
- stdio: "ignore",
5
+ execSync('git rev-parse --is-inside-work-tree', {
6
+ stdio: 'ignore',
7
7
  cwd: appPath,
8
8
  });
9
9
  return true;
@@ -17,25 +17,25 @@ function tryGitInit(appPath) {
17
17
  if (isInGitRepository()) {
18
18
  return false;
19
19
  }
20
- execSync("git --version", { stdio: "ignore", cwd: appPath });
20
+ execSync('git --version', { stdio: 'ignore', cwd: appPath });
21
21
 
22
- execSync("git init", { stdio: "ignore", cwd: appPath });
23
- console.log("Initialized git repo in app");
22
+ execSync('git init', { stdio: 'ignore', cwd: appPath });
23
+ console.log('Initialized git repo in app');
24
24
  return true;
25
25
  } catch (e) {
26
- console.warn("Git repo not initialized", e);
26
+ console.warn('Git repo not initialized', e);
27
27
  return false;
28
28
  }
29
29
  }
30
30
 
31
31
  function tryGitCommit(appPath) {
32
32
  try {
33
- execSync("git add -A", { stdio: "ignore", cwd: appPath });
33
+ execSync('git add -A', { stdio: 'ignore', cwd: appPath });
34
34
  execSync('git commit -m "Initialize project using Create React App"', {
35
- stdio: "ignore",
35
+ stdio: 'ignore',
36
36
  cwd: appPath,
37
37
  });
38
- console.log("Added first git commit");
38
+ console.log('Added first git commit');
39
39
  return true;
40
40
  } catch (e) {
41
41
  // We couldn't commit in already initialized git repo,
@@ -43,11 +43,11 @@ function tryGitCommit(appPath) {
43
43
  // In the future, we might supply our own committer
44
44
  // like Ember CLI does, but for now, let's just
45
45
  // remove the Git files to avoid a half-done state.
46
- console.warn("Git commit not created", e);
47
- console.warn("Removing .git directory...");
46
+ console.warn('Git commit not created', e);
47
+ console.warn('Removing .git directory...');
48
48
  try {
49
49
  // unlinkSync() doesn't work on directories.
50
- fs.removeSync(path.join(appPath, ".git"));
50
+ fs.removeSync(path.join(appPath, '.git'));
51
51
  } catch (removeErr) {
52
52
  // Ignore.
53
53
  }
@@ -57,7 +57,7 @@ function tryGitCommit(appPath) {
57
57
 
58
58
  function shouldUseYarn(appPath) {
59
59
  try {
60
- execSync("yarnpkg --version", { stdio: "ignore", cwd: appPath });
60
+ execSync('yarnpkg --version', { stdio: 'ignore', cwd: appPath });
61
61
  return true;
62
62
  } catch (e) {
63
63
  return false;