@corva/create-app 0.48.0-1 → 0.48.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.
package/README.md CHANGED
@@ -44,23 +44,25 @@ Arguments:
44
44
  project-directory project directory to work with (default: "Current working dir")
45
45
 
46
46
  Options:
47
- --appKey [string] Enter the App Key (default: "app.key-goes-here")
48
- --appName [string] Enter the App Name
49
- --appType [string] Choose the App Type (choices: "ui", "scheduler", "stream", "task", default: "ui")
50
- --category [string] Enter category (default: "")
47
+ --developerName [string] Enter the Developer Name (default: "O&G Company")
48
+ --developerIdentifier [string] Enter the Developer Identifier (default: "oandgc")
49
+ --appType Choose the App Type (choices: "ui", "scheduler", "stream", "task")
50
+ --schedulerType Choose the scheduler type (choices: "1", "2", "4")
51
51
  --cronString [string] Provide CRON string for the scheduler (default: "*/5 * * * *")
52
52
  --depthMilestone [number] Provide depth milestone for the scheduler (default: 1)
53
+ --logType Choose the log type (choices: "time", "depth")
54
+ --appName [string] Enter the App Name (default: "Corva Dev Center App")
53
55
  --description [string] Enter description (default: "This is the description of my app. You can do great things with it!")
54
- --developerIdentifier [string] Enter the Developer Identifier (default: "oandgc")
55
- --developerName [string] Enter the Developer Name (default: "O&G Company")
56
- --runtime [string] Choose runtime (choices: "ui", "nodejs16.x", "python3.8", "python3.9")
57
- --schedulerType [number] Choose the scheduler type (choices: "1", "2", "4", default: 1)
58
- --segments [string] Choose segments (choices: "drilling", "completion")
59
56
  --summary [string] Enter summary (default: "More information about this app goes here")
57
+ --category [string] Enter category (default: "")
60
58
  --website [string] Enter website (default: "https://www.oandgexample.com/my-app/")
61
- -p, --packageManager [string] Please select the desired package manager (choices: "yarn", "npm", default: "yarn")
59
+ --segments Choose segments (choices: "drilling", "completion")
60
+ --runtime Choose runtime (choices: "ui", "nodejs16.x", "python3.8", "python3.9")
61
+ -p, --packageManager Please select the desired package manager (choices: "yarn", "npm")
62
62
  -t, --useTypescript [boolean] Would you like to use TypesScript? (default: false)
63
63
  --silent [boolean] Only log result of the operation (default: false)
64
+ --no-dependencies-install Skip installing dependencies
65
+ --no-git-init Skip initializing git repository
64
66
  ```
65
67
 
66
68
  ### Examples
@@ -34,7 +34,11 @@ export const defaultManifest = {
34
34
 
35
35
  export const defaultUIAppManifest = {
36
36
  application: {
37
- ui: { initial_size: { w: 4, h: 10 } },
37
+ ui: {
38
+ initial_size: { w: 4, h: 10 },
39
+ multi_rig: false,
40
+ full_screen_report: false,
41
+ },
38
42
  },
39
43
  settings: {
40
44
  entrypoint: {
@@ -240,4 +244,12 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
240
244
  message: 'Only log result of the operation',
241
245
  default: false,
242
246
  },
247
+ {
248
+ name: 'no-dependencies-install',
249
+ message: 'Skip installing dependencies',
250
+ },
251
+ {
252
+ name: 'no-git-init',
253
+ message: 'Skip initializing git repository',
254
+ },
243
255
  ];
@@ -71,7 +71,7 @@ const tsUiPackage = {
71
71
  const nodeNpmScripts = {
72
72
  'bundle': 'create-corva-app zip .',
73
73
  'test': 'npm audit --production && npm run unit',
74
- 'unit': 'jest --setupFiles dotenv/config',
74
+ 'unit': 'jest',
75
75
  'lint': 'eslint --ext .js,.ts .',
76
76
  'lint:fix': 'eslint --ext .js,.ts --fix .',
77
77
  };
@@ -121,6 +121,9 @@ const nodeNpmPackage = {
121
121
  dependencies: nodeDependencies,
122
122
  devDependencies: nodeDevDependencies,
123
123
  scripts: nodeNpmScripts,
124
+ jest: {
125
+ setupFiles: ['dotenv/config'],
126
+ },
124
127
  };
125
128
 
126
129
  const nodeYarnPackage = {
@@ -135,6 +138,7 @@ const nodeTsNpmPackage = {
135
138
  jest: {
136
139
  preset: 'ts-jest',
137
140
  testEnvironment: 'node',
141
+ ...nodeNpmPackage.jest,
138
142
  },
139
143
  };
140
144
 
@@ -23,7 +23,7 @@ export function isInGitRepository(appPath) {
23
23
 
24
24
  export function tryGitInit(appPath) {
25
25
  try {
26
- if (isInGitRepository()) {
26
+ if (isInGitRepository(appPath)) {
27
27
  debug('is in git repository');
28
28
 
29
29
  return false;
@@ -50,7 +50,6 @@ export function tryGitCommit(appPath) {
50
50
  stdio: 'ignore',
51
51
  cwd: appPath,
52
52
  });
53
- logger.log('Added first git commit');
54
53
 
55
54
  return true;
56
55
  } catch (e) {
package/lib/main.js CHANGED
@@ -130,10 +130,11 @@ export async function run() {
130
130
 
131
131
  manifestConstants.manifestOptions().forEach((value) => {
132
132
  const type = typeof value.default;
133
- const option = new Option(
134
- `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${(type !== 'undefined' && type) || 'string'}]`,
135
- value.message,
136
- );
133
+ const cliType = type === 'undefined' ? (value.choices ? ' [string]' : '') : ` [${type}]`;
134
+ const alias = value.alias ? `-${value.alias}, ` : '';
135
+ const optionString = `${alias}--${value.name}${cliType}`;
136
+
137
+ const option = new Option(optionString, value.message);
137
138
 
138
139
  if (value.choices) {
139
140
  if (typeof value.choices === 'function') {
@@ -377,7 +378,15 @@ async function initPackage(projectName, opts) {
377
378
 
378
379
  await addTemplate(root, manifest, runtime);
379
380
  await configureApp(root, manifest, runtime);
380
- await installApp(root, manifest, runtime);
381
+
382
+ opts.dependenciesInstall && (await installDependencies(root, manifest, runtime));
383
+
384
+ opts.gitInit && (await initVersioning(root, manifest, runtime));
385
+
386
+ logger.log();
387
+ logger.log(`Success! Created ${chalk.green(manifest.name)} at ${chalk.yellow(root)}`);
388
+
389
+ helpCommands(manifest, runtime);
381
390
 
382
391
  logger.log();
383
392
  }
@@ -538,68 +547,78 @@ function addPackageJSON(root, manifest, runtime) {
538
547
  }
539
548
 
540
549
  /**
541
- *
542
550
  * @param {string} root
543
551
  * @param {import('./flows/lib/manifest').Manifest} manifest
552
+ * @param {import('./helpers/resolve-app-runtime.js').Runtime} runtime
553
+ * @returns {Promise<void>}
554
+ * @throws {Error}
555
+ * @throws {import('child_process').ExecException}
556
+ * @throws {import('child_process').SpawnSyncReturns<Buffer>}
544
557
  */
545
- async function installApp(root, manifest, runtime) {
558
+ async function installDependencies(root, manifest, runtime) {
546
559
  const command = manifest.isJs() ? runtime.packageManager : 'make';
547
560
 
548
- if (!IS_WINDOWS || manifest.isJs()) {
549
- const args = ['install'];
550
- const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root };
551
-
552
- if (process.env.CI && command === 'yarn') {
553
- args.push('--cache-folder=".yarn-cache"');
554
- }
561
+ if (IS_WINDOWS && !manifest.isJs()) {
562
+ logger.log();
563
+ logger.log(`⚠️ ${chalk.yellow('Please install project dependencies manually')}`);
555
564
 
556
- logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
557
-
558
- const proc =
559
- manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
560
- ? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
561
- shell: true,
562
- ...opts,
563
- })
564
- : spawn.sync(command, args, opts);
565
-
566
- if (proc.stderr) {
567
- const error = proc.stderr
568
- .toString('utf8')
569
- .split('\n')
570
- // NOTE: filter out warnings caused by @corva/ui peer dependencies
571
- .filter((line) => !line.includes('@corva/ui'))
572
- .join('\n');
573
-
574
- console.log(error);
575
- }
565
+ return;
566
+ }
576
567
 
577
- if (proc.status !== 0) {
578
- console.error(`\`${command} ${args.join(' ')}\` failed`);
568
+ const args = ['install'];
569
+ const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root };
579
570
 
580
- return;
581
- }
571
+ if (process.env.CI && command === 'yarn') {
572
+ args.push('--cache-folder=".yarn-cache"');
573
+ }
582
574
 
583
- logger.log(chalk.green('Successfull project install'));
584
- } else {
585
- logger.log();
586
- logger.log(`⚠️ ${chalk.yellow('Please install project dependencies manually')}`);
575
+ logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
576
+
577
+ const proc =
578
+ manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
579
+ ? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
580
+ shell: true,
581
+ ...opts,
582
+ })
583
+ : spawn.sync(command, args, opts);
584
+
585
+ if (proc.stderr) {
586
+ const error = proc.stderr
587
+ .toString('utf8')
588
+ .split('\n')
589
+ // NOTE: filter out warnings caused by @corva/ui peer dependencies
590
+ .filter((line) => !line.includes('@corva/ui'))
591
+ .join('\n');
592
+
593
+ console.log(error);
587
594
  }
588
595
 
589
- if (versioning.tryGitInit(root)) {
590
- logger.log();
591
- logger.log('Initialized a git repository.');
596
+ if (proc.status !== 0) {
597
+ console.error(`\`${command} ${args.join(' ')}\` failed`);
592
598
 
593
- if (versioning.tryGitCommit(root)) {
594
- logger.log();
595
- logger.log('Created git commit.');
596
- }
599
+ return;
597
600
  }
598
601
 
602
+ logger.log(chalk.green('Successfull project install'));
603
+ }
604
+
605
+ /**
606
+ *
607
+ * @param {string} root
608
+ */
609
+ async function initVersioning(root) {
599
610
  logger.log();
600
- logger.log(`Success! Created ${chalk.green(manifest.name)} at ${chalk.yellow(root)}`);
601
611
 
602
- helpCommands(manifest, runtime);
612
+ if (!versioning.tryGitInit(root)) {
613
+ logger.log('Already in a git repository. Skipping git initialization.');
614
+
615
+ return;
616
+ }
617
+
618
+ if (versioning.tryGitCommit(root)) {
619
+ logger.log();
620
+ logger.log('Created git commit');
621
+ }
603
622
  }
604
623
 
605
624
  async function helpCommands(manifest, { packageManager: displayedCommand }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.48.0-1",
3
+ "version": "0.48.0-3",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [