@corva/create-app 0.102.0-0 → 0.102.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.
@@ -36,11 +36,23 @@ Please check your internet connection and that the above request is not blocked
36
36
  }
37
37
  };
38
38
 
39
+ // Utility function to check if a version is a regular semver without prerelease identifiers
40
+ const isRegularVersion = (version) => {
41
+ return semver.prerelease(version) === null;
42
+ };
43
+
39
44
  // NOTE: Stop process and show error if version is outdated
40
45
  export async function ensureLatestVersion() {
41
46
  const currentVersion = await getCurrentVersion();
42
47
  const latestVersion = await getLatestVersion();
43
48
 
49
+ // Skip version check if current version is a prerelease (dev or next)
50
+ if (!isRegularVersion(currentVersion)) {
51
+ logger.write('Skipping version check for prerelease version.\n');
52
+
53
+ return;
54
+ }
55
+
44
56
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
45
57
 
46
58
  if (isCurrentVersionOutdated) {
@@ -65,6 +77,13 @@ export async function warnIfOutdated() {
65
77
  const currentVersion = await getCurrentVersion();
66
78
  const latestVersion = await getLatestVersion();
67
79
 
80
+ // Skip version check if current version is a prerelease (dev or next)
81
+ if (!isRegularVersion(currentVersion)) {
82
+ logger.write(' ⚠️ Skipping version check for prerelease version.\n');
83
+
84
+ return;
85
+ }
86
+
68
87
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
69
88
 
70
89
  if (isCurrentVersionOutdated) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.102.0-0",
3
+ "version": "0.102.0-3",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [
@@ -9,3 +9,22 @@ import '@testing-library/jest-dom/extend-expect';
9
9
 
10
10
  // Set UTC timezone for tests to not use the environment timezone
11
11
  process.env.TZ = 'UTC';
12
+
13
+ // Mock ResizeObserver & MutationObserver
14
+ class FakeObserver {
15
+ observe() {}
16
+ unobserve() {}
17
+ disconnect() {}
18
+ }
19
+
20
+ global.ResizeObserver = FakeObserver;
21
+ global.MutationObserver = FakeObserver;
22
+
23
+ // Suppressing "Could not parse CSS stylesheet" from JSDOM
24
+ const originalConsoleError = global.console.error;
25
+ global.console.error = (message, ...optionalParams) => {
26
+ if (message.includes('Could not parse CSS stylesheet')) {
27
+ return;
28
+ }
29
+ originalConsoleError(message, ...optionalParams);
30
+ };
@@ -1,4 +1,5 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
4
5
  import logo from './assets/logo.svg';
@@ -8,54 +9,52 @@ import styles from './App.css';
8
9
  /**
9
10
  * @param {Object} props
10
11
  * @param {boolean} props.isExampleCheckboxChecked
11
- * @param {Object} props.appHeaderProps
12
12
  * @param {Object} props.fracFleet
13
13
  * @param {Object} props.well
14
14
  * @param {Object[]} props.wells
15
15
  * @returns
16
16
  */
17
17
  function App({
18
- appHeaderProps,
19
18
  isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
20
19
  fracFleet,
21
20
  well,
22
21
  wells,
23
22
  }) {
23
+ const { appKey } = useAppCommons();
24
24
  // NOTE: On general type dashboard app receives wells array
25
25
  // on asset type dashboard app receives well object
26
26
  const wellsList = wells || [well];
27
27
 
28
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{' '}
29
+ <AppContainer header={<AppHeader />} testId={appKey}>
30
+ <div>
31
+ <img src={logo} alt="logo" className={styles.logo} />
32
+ <p>
33
+ Edit <code>src/App.js</code> and save to reload.
34
+ <br />
35
+ <br />
36
+ </p>
37
+ <p>
38
+ Frac Fleet: <span data-testid="fracFleet">{fracFleet?.name || 'No Frac Fleet'}</span>
39
+ <br />
40
+ Wells: <span data-testid="wellsList">{wellsList.map(well => well.name).join(', ')}</span>
41
+ </p>
42
+ <a
43
+ className="App-link"
44
+ href="https://reactjs.org"
45
+ target="_blank"
46
+ rel="noopener noreferrer"
47
+ >
48
+ Learn React
49
+ </a>
50
+ </div>
51
+ <div>
52
+ Settings &quot;Example&quot; checkbox is{' '}
53
+ <span data-testid="exampleCheckboxChecked">
55
54
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
56
- </div>
55
+ </span>
57
56
  </div>
58
- </div>
57
+ </AppContainer>
59
58
  );
60
59
  }
61
60
 
@@ -1,20 +1,3 @@
1
- .container {
2
- display: flex;
3
- flex-direction: column;
4
- height: 100%;
5
- padding: 12px 12px 30px 12px;
6
- }
7
-
8
- .content {
9
- display: flex;
10
- flex-direction: column;
11
- text-align: center;
12
- align-items: center;
13
- justify-content: center;
14
- flex-grow: 1;
15
- overflow: auto;
16
- }
17
-
18
1
  @keyframes App-logo-spin {
19
2
  from {
20
3
  transform: rotate(0deg);
@@ -1,4 +1,5 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
4
5
  import logo from './assets/logo.svg';
@@ -7,49 +8,43 @@ import styles from './App.css';
7
8
 
8
9
  /**
9
10
  * @param {Object} props
10
- * @param {Object} props.appHeaderProps
11
11
  * @param {boolean} props.isExampleCheckboxChecked
12
12
  * @param {Object} props.rig
13
13
  * @param {Object} props.well
14
14
  * @returns
15
15
  */
16
- function App({
17
- appHeaderProps,
18
- isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
19
- rig,
20
- well,
21
- }) {
16
+ function App({ isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked, rig, well }) {
17
+ const { appKey } = useAppCommons();
22
18
  return (
23
- <div className={styles.container}>
24
- <AppHeader {...appHeaderProps} />
25
- <div className={styles.content}>
26
- <div>
27
- <img src={logo} alt="logo" className={styles.logo} />
28
- <p>
29
- Edit <code>src/App.js</code> and save to reload.
30
- <br />
31
- <br />
32
- </p>
33
- <p>
34
- Rig: {rig.name}
35
- <br />
36
- Well: {well.name}
37
- </p>
38
- <a
39
- className="App-link"
40
- href="https://reactjs.org"
41
- target="_blank"
42
- rel="noopener noreferrer"
43
- >
44
- Learn React
45
- </a>
46
- </div>
47
- <div>
48
- Settings &quot;Example&quot; checkbox is{' '}
19
+ <AppContainer header={<AppHeader />} testId={appKey}>
20
+ <div>
21
+ <img src={logo} alt="logo" className={styles.logo} />
22
+ <p>
23
+ Edit <code>src/App.js</code> and save to reload.
24
+ <br />
25
+ <br />
26
+ </p>
27
+ <p>
28
+ Rig: <span data-testid="rig">{rig.name}</span>
29
+ <br />
30
+ Well: <span data-testid="well">{well.name}</span>
31
+ </p>
32
+ <a
33
+ className="App-link"
34
+ href="https://reactjs.org"
35
+ target="_blank"
36
+ rel="noopener noreferrer"
37
+ >
38
+ Learn React
39
+ </a>
40
+ </div>
41
+ <div>
42
+ Settings &quot;Example&quot; checkbox is{' '}
43
+ <span data-testid="exampleCheckboxState">
49
44
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
50
- </div>
45
+ </span>
51
46
  </div>
52
- </div>
47
+ </AppContainer>
53
48
  );
54
49
  }
55
50
 
@@ -1,11 +1,24 @@
1
1
  import { render, screen } from '@testing-library/react';
2
+ import { AppTestWrapper } from '@corva/ui/testing';
2
3
 
3
4
  import App from '../App';
4
5
  import { mockAppProps } from '../__mocks__/mockAppProps';
5
6
 
6
7
  describe('<App />', () => {
7
8
  it('should show correct layout', () => {
8
- render(<App {...mockAppProps} />);
9
+ render(
10
+ <AppTestWrapper
11
+ app={mockAppProps.app}
12
+ appId={123}
13
+ maximized={false}
14
+ appSettings={mockAppProps.app.settings}
15
+ onSettingChange={() => {
16
+ /* noop */
17
+ }}
18
+ >
19
+ <App {...mockAppProps} />
20
+ </AppTestWrapper>
21
+ );
9
22
 
10
23
  screen.getByText(/checked/i);
11
24
  });
@@ -14,7 +27,19 @@ describe('<App />', () => {
14
27
  const propsWithoutSettings = mockAppProps;
15
28
  delete propsWithoutSettings.isExampleCheckboxChecked;
16
29
 
17
- render(<App {...propsWithoutSettings} />);
30
+ render(
31
+ <AppTestWrapper
32
+ app={mockAppProps.app}
33
+ appId={123}
34
+ maximized={false}
35
+ appSettings={mockAppProps.app.settings}
36
+ onSettingChange={() => {
37
+ /* noop */
38
+ }}
39
+ >
40
+ <App {...propsWithoutSettings} />
41
+ </AppTestWrapper>
42
+ );
18
43
 
19
44
  screen.getByText(/unchecked/i);
20
45
  });
@@ -9,3 +9,22 @@ import '@testing-library/jest-dom/extend-expect';
9
9
 
10
10
  // Set UTC timezone for tests to not use the environment timezone
11
11
  process.env.TZ = 'UTC';
12
+
13
+ // Mock ResizeObserver & MutationObserver
14
+ class FakeObserver {
15
+ observe() {}
16
+ unobserve() {}
17
+ disconnect() {}
18
+ }
19
+
20
+ global.ResizeObserver = FakeObserver;
21
+ global.MutationObserver = FakeObserver;
22
+
23
+ // Suppressing "Could not parse CSS stylesheet" from JSDOM
24
+ const originalConsoleError = global.console.error;
25
+ global.console.error = (message, ...optionalParams) => {
26
+ if (message.includes('Could not parse CSS stylesheet')) {
27
+ return;
28
+ }
29
+ originalConsoleError(message, ...optionalParams);
30
+ };
@@ -1,4 +1,5 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
4
5
  import logo from './assets/logo.svg';
@@ -6,10 +7,6 @@ import logo from './assets/logo.svg';
6
7
  import styles from './App.css';
7
8
 
8
9
  type AppProps = {
9
- appHeaderProps: {
10
- [key: string]: any;
11
- app: any;
12
- };
13
10
  isExampleCheckboxChecked?: boolean;
14
11
  fracFleet?: { name: string };
15
12
  well?: { name: string };
@@ -17,47 +14,46 @@ type AppProps = {
17
14
  };
18
15
 
19
16
  function App({
20
- appHeaderProps,
21
17
  isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
22
18
  fracFleet,
23
19
  well,
24
20
  wells,
25
21
  }: AppProps): JSX.Element {
22
+ const { appKey } = useAppCommons();
26
23
  // NOTE: On general type dashboard app receives wells array
27
24
  // on asset type dashboard app receives well object
28
25
  const wellsList = wells || [well];
29
26
 
30
27
  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{' '}
28
+ <AppContainer header={<AppHeader />} testId={appKey}>
29
+ <div>
30
+ <img src={logo} alt="logo" className={styles.logo} />
31
+ <p>
32
+ Edit <code>src/App.js</code> and save to reload.
33
+ <br />
34
+ <br />
35
+ </p>
36
+ <p>
37
+ Frac Fleet: <span data-testid="fracFleet">{fracFleet?.name || 'No Frac Fleet'}</span>
38
+ <br />
39
+ Wells: <span data-testid="wellsList">{wellsList.map(well => well.name).join(', ')}</span>
40
+ </p>
41
+ <a
42
+ className="App-link"
43
+ href="https://reactjs.org"
44
+ target="_blank"
45
+ rel="noopener noreferrer"
46
+ >
47
+ Learn React
48
+ </a>
49
+ </div>
50
+ <div>
51
+ Settings &quot;Example&quot; checkbox is{' '}
52
+ <span data-testid="exampleCheckboxState">
57
53
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
58
- </div>
54
+ </span>
59
55
  </div>
60
- </div>
56
+ </AppContainer>
61
57
  );
62
58
  }
63
59
 
@@ -1,20 +1,3 @@
1
- .container {
2
- display: flex;
3
- flex-direction: column;
4
- height: 100%;
5
- padding: 12px 12px 30px 12px;
6
- }
7
-
8
- .content {
9
- display: flex;
10
- flex-direction: column;
11
- text-align: center;
12
- align-items: center;
13
- justify-content: center;
14
- flex-grow: 1;
15
- overflow: auto;
16
- }
17
-
18
1
  @keyframes App-logo-spin {
19
2
  from {
20
3
  transform: rotate(0deg);
@@ -1,4 +1,5 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
4
5
  import logo from './assets/logo.svg';
@@ -6,52 +7,47 @@ import logo from './assets/logo.svg';
6
7
  import styles from './App.css';
7
8
 
8
9
  type AppProps = {
9
- appHeaderProps: {
10
- [key: string]: any;
11
- app: any;
12
- };
13
10
  isExampleCheckboxChecked?: boolean;
14
11
  rig: { name: string };
15
12
  well: { name: string };
16
13
  };
17
14
 
18
15
  function App({
19
- appHeaderProps,
20
16
  isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
21
17
  rig,
22
18
  well,
23
19
  }: AppProps): JSX.Element {
20
+ const { appKey } = useAppCommons();
24
21
  return (
25
- <div className={styles.container}>
26
- <AppHeader {...appHeaderProps} />
27
- <div className={styles.content}>
28
- <div>
29
- <img src={logo} alt="logo" className={styles.logo} />
30
- <p>
31
- Edit <code>src/App.js</code> and save to reload.
32
- <br />
33
- <br />
34
- </p>
35
- <p>
36
- Rig: {rig.name}
37
- <br />
38
- Well: {well.name}
39
- </p>
40
- <a
41
- className="App-link"
42
- href="https://reactjs.org"
43
- target="_blank"
44
- rel="noopener noreferrer"
45
- >
46
- Learn React
47
- </a>
48
- </div>
49
- <div>
50
- Settings &quot;Example&quot; checkbox is{' '}
22
+ <AppContainer header={<AppHeader />} testId={appKey}>
23
+ <div>
24
+ <img src={logo} alt="logo" className={styles.logo} />
25
+ <p>
26
+ Edit <code>src/App.js</code> and save to reload.
27
+ <br />
28
+ <br />
29
+ </p>
30
+ <p>
31
+ Rig: <span data-testid="rig">{rig.name}</span>
32
+ <br />
33
+ Well: <span data-testid="well">{well.name}</span>
34
+ </p>
35
+ <a
36
+ className="App-link"
37
+ href="https://reactjs.org"
38
+ target="_blank"
39
+ rel="noopener noreferrer"
40
+ >
41
+ Learn React
42
+ </a>
43
+ </div>
44
+ <div>
45
+ Settings &quot;Example&quot; checkbox is{' '}
46
+ <span data-testid="exampleCheckboxState">
51
47
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
52
- </div>
48
+ </span>
53
49
  </div>
54
- </div>
50
+ </AppContainer>
55
51
  );
56
52
  }
57
53
 
@@ -1,11 +1,24 @@
1
1
  import { render, screen } from '@testing-library/react';
2
+ import { AppTestWrapper } from '@corva/ui/testing';
2
3
 
3
4
  import App from '../App';
4
5
  import { mockAppProps } from '../__mocks__/mockAppProps';
5
6
 
6
7
  describe('<App />', () => {
7
8
  it('should show correct layout', () => {
8
- render(<App {...mockAppProps} />);
9
+ render(
10
+ <AppTestWrapper
11
+ app={mockAppProps.app}
12
+ appId={123}
13
+ maximized={false}
14
+ appSettings={mockAppProps.app.settings}
15
+ onSettingChange={() => {
16
+ /* noop */
17
+ }}
18
+ >
19
+ <App {...mockAppProps} />
20
+ </AppTestWrapper>
21
+ );
9
22
 
10
23
  screen.getByText(/checked/i);
11
24
  });
@@ -14,7 +27,19 @@ describe('<App />', () => {
14
27
  const propsWithoutSettings = mockAppProps;
15
28
  delete propsWithoutSettings.isExampleCheckboxChecked;
16
29
 
17
- render(<App {...propsWithoutSettings} />);
30
+ render(
31
+ <AppTestWrapper
32
+ app={mockAppProps.app}
33
+ appId={123}
34
+ maximized={false}
35
+ appSettings={mockAppProps.app.settings}
36
+ onSettingChange={() => {
37
+ /* noop */
38
+ }}
39
+ >
40
+ <App {...propsWithoutSettings} />
41
+ </AppTestWrapper>
42
+ );
18
43
 
19
44
  screen.getByText(/unchecked/i);
20
45
  });