@corva/create-app 0.72.0-1 → 0.72.0-rc.0

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.
@@ -17,7 +17,7 @@ import { ensureBumpVersion, ensureLatestVersion } from '../helpers/cli-version.j
17
17
  import { logger } from '../helpers/logger.js';
18
18
  import { IS_WINDOWS, resolveAppRuntime } from '../helpers/resolve-app-runtime.js';
19
19
  import { tryGitCommit, tryGitInit } from '../helpers/versioning.js';
20
- import { copyFolderRecursiveSync, putVariablesInEnvFile } from '../helpers/utils.js';
20
+ import { addUiAppFile, copyFolderRecursiveSync, getExcludedFiles, putVariablesInEnvFile } from '../helpers/utils.js';
21
21
  import { getDefaultsForPackageJson } from '../constants/package.js';
22
22
  import { getRealWorkingDir } from '../helpers/commands.js';
23
23
  import { Manifest } from '../flows/lib/manifest.js';
@@ -201,7 +201,9 @@ async function addTemplate(root, manifest, runtime, opts) {
201
201
 
202
202
  const templateFolder = join(cliRoot, 'templates', manifest.templateName, runtime.language);
203
203
 
204
- copyFolderRecursiveSync(templateFolder, root);
204
+ const excludeFiles = getExcludedFiles(manifest);
205
+
206
+ copyFolderRecursiveSync(templateFolder, root, excludeFiles);
205
207
 
206
208
  if (manifest.isNode()) {
207
209
  copyFolderRecursiveSync(join(cliRoot, 'common', 'node'), root);
@@ -244,6 +246,10 @@ async function addTemplate(root, manifest, runtime, opts) {
244
246
  logger.log(chalk.red('Error: applying app extensions!'));
245
247
  logger.log(e);
246
248
  }
249
+
250
+ if (manifest.isUi()) {
251
+ addUiAppFile(templateFolder, root, runtime, manifest, opts);
252
+ }
247
253
  }
248
254
 
249
255
  /**
@@ -246,6 +246,7 @@ export class Api {
246
246
  return {
247
247
  id: data.id,
248
248
  status: data.attributes.status,
249
+ isDeletedDueToLimit: data.attributes.deleted_due_to_limit,
249
250
  };
250
251
  } catch (e) {
251
252
  throw new StepError(`${JSON.parse(e.response.body).message || ''} \nPOST: ${uploadURL} failed.`, { cause: e });
@@ -1,8 +1,10 @@
1
1
  import FormData from 'form-data';
2
+ import chalk from 'chalk';
2
3
  import { createReadStream } from 'node:fs';
3
4
  import { resolve } from 'node:path';
4
5
  import { RELEASE } from '../../../constants/messages.js';
5
6
  import { StepError } from '../../lib/step-error.js';
7
+ import { logger } from '../../../helpers/logger.js';
6
8
 
7
9
  async function deleteAppPackage({ api, appId, appPkgVersion }) {
8
10
  const appPackages = await api.getAppPackages(appId);
@@ -34,7 +36,13 @@ export const UPLOAD_ZIP_TO_CORVA_STEP = {
34
36
 
35
37
  form.append('package', createReadStream(resolve(dirName, zipFileName)), 'package.zip');
36
38
 
37
- const { id: packageId } = await api.uploadPackages(appKey, form);
39
+ const { id: packageId, isDeletedDueToLimit } = await api.uploadPackages(appKey, form);
40
+
41
+ if (isDeletedDueToLimit) {
42
+ logger.write(
43
+ `\n${chalk.yellow`NOTE`}: Version number limit reached. The oldest version without label was deleted.`,
44
+ );
45
+ }
38
46
 
39
47
  return { packageId };
40
48
  }
@@ -1,5 +1,29 @@
1
1
  import path, { join } from 'node:path';
2
2
  import fs from 'fs-extra';
3
+ import chalk from 'chalk';
4
+ import { logger } from './logger.js';
5
+
6
+ export const addUiAppFile = (templateFolder, root, runtime, manifest, opts) => {
7
+ try {
8
+ logger.log(chalk.green('adding app file'));
9
+
10
+ const fileExtension = runtime.language === 'typescript' ? 'tsx' : 'js';
11
+ const segment = opts.segments === 'completion' ? 'completion' : 'drilling';
12
+ const appFilePath = join(templateFolder, 'src', `App.${segment}.${fileExtension}`);
13
+
14
+ copyFileSync(appFilePath, join(root, 'src', `App.${fileExtension}`));
15
+ logger.log(chalk.green('Done: adding app file!'));
16
+ } catch (e) {
17
+ logger.log(chalk.red('Error: adding app file!'));
18
+ logger.log(e);
19
+ }
20
+ };
21
+
22
+ export const getExcludedFiles = (manifest) => {
23
+ if (manifest.isUi()) return ['App.drilling.js', 'App.completion.js', 'App.drilling.tsx', 'App.completion.tsx'];
24
+
25
+ return [];
26
+ };
3
27
 
4
28
  export function copyFileSync(source, target) {
5
29
  let targetFile = target;
@@ -18,7 +42,7 @@ export function copyFileSync(source, target) {
18
42
  fs.chmodSync(targetFile, targetMode);
19
43
  }
20
44
 
21
- export function copyFolderRecursiveSync(sourceFolder, targetFolder) {
45
+ export function copyFolderRecursiveSync(sourceFolder, targetFolder, excludeFiles = []) {
22
46
  // check if folder needs to be created or integrated
23
47
  if (!fs.existsSync(targetFolder)) {
24
48
  fs.mkdirSync(targetFolder);
@@ -32,10 +56,12 @@ export function copyFolderRecursiveSync(sourceFolder, targetFolder) {
32
56
  const items = fs.readdirSync(sourceFolder);
33
57
 
34
58
  for (const item of items) {
59
+ if (excludeFiles.includes(item)) continue; // Skip the files in the exclude list
60
+
35
61
  const curSource = path.join(sourceFolder, item);
36
62
 
37
63
  if (fs.lstatSync(curSource).isDirectory()) {
38
- copyFolderRecursiveSync(curSource, path.join(targetFolder, item));
64
+ copyFolderRecursiveSync(curSource, path.join(targetFolder, item), excludeFiles);
39
65
 
40
66
  continue;
41
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.72.0-1",
3
+ "version": "0.72.0-rc.0",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [
@@ -4,7 +4,7 @@ const { merge } = require('webpack-merge');
4
4
  module.exports = (env, argv) => {
5
5
  return merge(
6
6
  getWebpackConfig(env, argv),
7
- // NOTE: Custom webpack 4 plugins and module rules can be provided here
7
+ // NOTE: Custom webpack 5 plugins and module rules can be provided here
8
8
  {}
9
9
  );
10
10
  };
@@ -0,0 +1,64 @@
1
+ import { AppHeader } from '@corva/ui/components';
2
+
3
+ import { DEFAULT_SETTINGS } from './constants';
4
+ import logo from './assets/logo.svg';
5
+
6
+ import styles from './App.css';
7
+
8
+ /**
9
+ * @param {Object} props
10
+ * @param {boolean} props.isExampleCheckboxChecked
11
+ * @param {Object} props.appHeaderProps
12
+ * @param {Object} props.fracFleet
13
+ * @param {Object} props.well
14
+ * @param {Object[]} props.wells
15
+ * @returns
16
+ */
17
+ function App({
18
+ appHeaderProps,
19
+ isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
20
+ fracFleet,
21
+ well,
22
+ wells,
23
+ }) {
24
+ // NOTE: On general type dashboard app receives wells array
25
+ // on asset type dashboard app receives well object
26
+ const wellsList = wells || [well];
27
+
28
+ return (
29
+ <div className={styles.container}>
30
+ <AppHeader {...appHeaderProps} />
31
+ <div className={styles.content}>
32
+ <div>
33
+ <img src={logo} alt="logo" className={styles.logo} />
34
+ <p>
35
+ Edit <code>src/App.js</code> and save to reload.
36
+ <br />
37
+ <br />
38
+ </p>
39
+ <p>
40
+ Frac Fleet: {fracFleet?.name || 'No Frac Fleet'}
41
+ <br />
42
+ Wells: {wellsList.map(well => well.name).join(', ')}
43
+ </p>
44
+ <a
45
+ className="App-link"
46
+ href="https://reactjs.org"
47
+ target="_blank"
48
+ rel="noopener noreferrer"
49
+ >
50
+ Learn React
51
+ </a>
52
+ </div>
53
+ <div>
54
+ Settings &quot;Example&quot; checkbox is{' '}
55
+ {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
56
+ </div>
57
+ </div>
58
+ </div>
59
+ );
60
+ }
61
+
62
+ // Important: Do not change root component default export (App.js). Use it as container
63
+ // for your App. It's required to make build and zip scripts work as expected;
64
+ export default App;
@@ -7,13 +7,17 @@ import styles from './App.css';
7
7
 
8
8
  /**
9
9
  * @param {Object} props
10
- * @param {boolean} props.isExampleCheckboxChecked
11
10
  * @param {Object} props.appHeaderProps
11
+ * @param {boolean} props.isExampleCheckboxChecked
12
+ * @param {Object} props.rig
13
+ * @param {Object} props.well
12
14
  * @returns
13
15
  */
14
16
  function App({
15
- isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
16
17
  appHeaderProps,
18
+ isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
19
+ rig,
20
+ well,
17
21
  }) {
18
22
  return (
19
23
  <div className={styles.container}>
@@ -26,6 +30,11 @@ function App({
26
30
  <br />
27
31
  <br />
28
32
  </p>
33
+ <p>
34
+ Rig: {rig.name}
35
+ <br />
36
+ Well: {well.name}
37
+ </p>
29
38
  <a
30
39
  className="App-link"
31
40
  href="https://reactjs.org"
@@ -577,4 +577,14 @@ export const mockAppProps = {
577
577
  type: 'general',
578
578
  pdfReportMode: false,
579
579
  },
580
+ // Completion segment app props
581
+ fracFleet: {
582
+ current_pad_id: 101,
583
+ id: 1002,
584
+ name: 'Magic Frac Fleet',
585
+ },
586
+ wells: [
587
+ { id: 1, name: 'Well 1' },
588
+ { id: 2, name: 'Well 2' },
589
+ ],
580
590
  };
@@ -4,7 +4,7 @@ const { merge } = require('webpack-merge');
4
4
  module.exports = (env, argv) => {
5
5
  return merge(
6
6
  getWebpackConfig(env, argv),
7
- // NOTE: Custom webpack 4 plugins and module rules can be provided here
7
+ // NOTE: Custom webpack 5 plugins and module rules can be provided here
8
8
  {}
9
9
  );
10
10
  };
@@ -0,0 +1,66 @@
1
+ import { AppHeader } from '@corva/ui/components';
2
+
3
+ import { DEFAULT_SETTINGS } from './constants';
4
+ import logo from './assets/logo.svg';
5
+
6
+ import styles from './App.css';
7
+
8
+ type AppProps = {
9
+ appHeaderProps: {
10
+ [key: string]: any;
11
+ app: any;
12
+ };
13
+ isExampleCheckboxChecked?: boolean;
14
+ fracFleet?: { name: string };
15
+ well?: { name: string };
16
+ wells?: { name: string }[];
17
+ };
18
+
19
+ function App({
20
+ appHeaderProps,
21
+ isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
22
+ fracFleet,
23
+ well,
24
+ wells,
25
+ }: AppProps): JSX.Element {
26
+ // NOTE: On general type dashboard app receives wells array
27
+ // on asset type dashboard app receives well object
28
+ const wellsList = wells || [well];
29
+
30
+ return (
31
+ <div className={styles.container}>
32
+ <AppHeader {...appHeaderProps} />
33
+ <div className={styles.content}>
34
+ <div>
35
+ <img src={logo} alt="logo" className={styles.logo} />
36
+ <p>
37
+ Edit <code>src/App.js</code> and save to reload.
38
+ <br />
39
+ <br />
40
+ </p>
41
+ <p>
42
+ Frac Fleet: {fracFleet?.name || 'No Frac Fleet'}
43
+ <br />
44
+ Wells: {wellsList.map(well => well.name).join(', ')}
45
+ </p>
46
+ <a
47
+ className="App-link"
48
+ href="https://reactjs.org"
49
+ target="_blank"
50
+ rel="noopener noreferrer"
51
+ >
52
+ Learn React
53
+ </a>
54
+ </div>
55
+ <div>
56
+ Settings &quot;Example&quot; checkbox is{' '}
57
+ {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
58
+ </div>
59
+ </div>
60
+ </div>
61
+ );
62
+ }
63
+
64
+ // Important: Do not change root component default export (App.js). Use it as container
65
+ // for your App. It's required to make build and zip scripts work as expected;
66
+ export default App;
@@ -6,16 +6,20 @@ import logo from './assets/logo.svg';
6
6
  import styles from './App.css';
7
7
 
8
8
  type AppProps = {
9
- isExampleCheckboxChecked?: boolean;
10
9
  appHeaderProps: {
11
10
  [key: string]: any;
12
11
  app: any;
13
12
  };
13
+ isExampleCheckboxChecked?: boolean;
14
+ rig: { name: string };
15
+ well: { name: string };
14
16
  };
15
17
 
16
18
  function App({
17
- isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
18
19
  appHeaderProps,
20
+ isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
21
+ rig,
22
+ well,
19
23
  }: AppProps): JSX.Element {
20
24
  return (
21
25
  <div className={styles.container}>
@@ -28,6 +32,11 @@ function App({
28
32
  <br />
29
33
  <br />
30
34
  </p>
35
+ <p>
36
+ Rig: {rig.name}
37
+ <br />
38
+ Well: {well.name}
39
+ </p>
31
40
  <a
32
41
  className="App-link"
33
42
  href="https://reactjs.org"
@@ -577,4 +577,14 @@ export const mockAppProps = {
577
577
  type: 'general',
578
578
  pdfReportMode: false,
579
579
  },
580
+ // Completion segment app props
581
+ fracFleet: {
582
+ current_pad_id: 101,
583
+ id: 1002,
584
+ name: 'Magic Frac Fleet',
585
+ },
586
+ wells: [
587
+ { id: 1, name: 'Well 1' },
588
+ { id: 2, name: 'Well 2' },
589
+ ],
580
590
  };