@corva/create-app 0.35.0-1 → 0.36.0-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.
- package/lib/bump-version.option.js +1 -0
- package/lib/constants/package.js +13 -0
- package/lib/flows/lib/manifest.js +5 -0
- package/lib/flows/steps/zip-file-list-resolve.js +26 -5
- package/lib/index.js +2 -1
- package/package.json +1 -1
- package/templates/javascript/ui/src/__tests__/TestExample.test.js +31 -0
- package/templates/javascript/ui/src/setupTests.js +2 -0
- package/templates/typescript/ui/src/AppSettings.tsx +12 -12
- package/templates/typescript/ui/src/__tests__/TestExample.test.tsx +31 -0
- package/templates/typescript/ui/src/custom.d.ts +1 -1
- package/templates/typescript/ui/src/setupTests.ts +2 -0
package/lib/constants/package.js
CHANGED
|
@@ -18,6 +18,12 @@ const uiDependencies = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const jsUiDevDependencies = {
|
|
21
|
+
'@testing-library/jest-dom': '^5.16.4',
|
|
22
|
+
'@testing-library/react': '12.1.5',
|
|
23
|
+
'@testing-library/react-hooks': '^8.0.1',
|
|
24
|
+
'@testing-library/user-event': '^14.3.0',
|
|
25
|
+
'react-scripts': '4.0.3',
|
|
26
|
+
'eslint': '7.32.0',
|
|
21
27
|
'postcss-loader': '4.1.0',
|
|
22
28
|
};
|
|
23
29
|
|
|
@@ -26,6 +32,7 @@ const tsUiDevDependencies = {
|
|
|
26
32
|
'@tsconfig/create-react-app': '1.0.2',
|
|
27
33
|
'@types/material-ui': '0.21.9',
|
|
28
34
|
'@types/react': '^17.0.22',
|
|
35
|
+
'@types/jest': '26.0.24',
|
|
29
36
|
'@types/react-dom': '^17.0.9',
|
|
30
37
|
'@typescript-eslint/eslint-plugin': '^4.31.2',
|
|
31
38
|
'@typescript-eslint/parser': '^4.31.2',
|
|
@@ -39,6 +46,7 @@ const uiScripts = {
|
|
|
39
46
|
zip: 'create-corva-app zip .',
|
|
40
47
|
lint: 'eslint --cache ./src/',
|
|
41
48
|
release: 'create-corva-app release .',
|
|
49
|
+
test: 'react-scripts test',
|
|
42
50
|
};
|
|
43
51
|
|
|
44
52
|
const uiPackage = {
|
|
@@ -47,6 +55,11 @@ const uiPackage = {
|
|
|
47
55
|
scripts: uiScripts,
|
|
48
56
|
dependencies: uiDependencies,
|
|
49
57
|
devDependencies: jsUiDevDependencies,
|
|
58
|
+
// TODO: This is a temporary workaround. Should be removed once
|
|
59
|
+
// this ticket is resolved: https://corvaqa.atlassian.net/browse/DC-3982
|
|
60
|
+
jest: {
|
|
61
|
+
transformIgnorePatterns: ['/node_modules/(?!@babel/runtime|@corva/ui)', '\\.pnp\\.[^\\/]+$'],
|
|
62
|
+
},
|
|
50
63
|
};
|
|
51
64
|
|
|
52
65
|
const tsUiPackage = {
|
|
@@ -19,6 +19,11 @@ class Manifest {
|
|
|
19
19
|
return this.manifest.application.name
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
get unix_name() {
|
|
23
|
+
// todo: npm scopes?
|
|
24
|
+
return this.manifest.application.key.replace(/\W+/gi, '_').toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
get description() {
|
|
23
28
|
return this.manifest.application.description
|
|
24
29
|
}
|
|
@@ -64,9 +64,16 @@ const transformPatternsIntoFileNames = async (dirName, patterns, ignoredFiles =
|
|
|
64
64
|
return filesFromPatterns;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param {string[]} itemsToZip
|
|
70
|
+
* @param {object} param1
|
|
71
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, manifest }) => {
|
|
68
75
|
const version = await getIncreasedVersion(pkg.version, options);
|
|
69
|
-
const zipFileName = `${
|
|
76
|
+
const zipFileName = `${manifest.unix_name}-${version}.zip`;
|
|
70
77
|
const itemsToSave = [];
|
|
71
78
|
const shouldUpdateVersion = version !== pkg.version;
|
|
72
79
|
|
|
@@ -114,9 +121,16 @@ const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName })
|
|
|
114
121
|
};
|
|
115
122
|
};
|
|
116
123
|
|
|
117
|
-
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @param {string[]} itemsToZip
|
|
127
|
+
* @param {object} param1
|
|
128
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirName, manifest }) => {
|
|
118
132
|
const version = await getIncreasedVersion(pkg.version, options);
|
|
119
|
-
const zipFileName = `${
|
|
133
|
+
const zipFileName = `${manifest.unix_name}-${version}.zip`;
|
|
120
134
|
const itemsToSave = [];
|
|
121
135
|
const shouldUpdateVersion = version !== pkg.version;
|
|
122
136
|
|
|
@@ -176,8 +190,15 @@ const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirNa
|
|
|
176
190
|
};
|
|
177
191
|
};
|
|
178
192
|
|
|
193
|
+
/**
|
|
194
|
+
*
|
|
195
|
+
* @param {string[]} itemsToZip
|
|
196
|
+
* @param {object} param1
|
|
197
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
179
200
|
const resolveDataForZipPythonApp = async (itemsToZip = [], { manifest, dirName, options }) => {
|
|
180
|
-
const zipFileName = `${manifest.
|
|
201
|
+
const zipFileName = `${manifest.unix_name}.zip`;
|
|
181
202
|
|
|
182
203
|
if (!itemsToZip.length) {
|
|
183
204
|
itemsToZip.push(...(await glob('**/*.py', { cwd: dirName, ignore: [...(options.ignoredFiles || []), 'venv/**/*'] })));
|
package/lib/index.js
CHANGED
|
@@ -431,7 +431,7 @@ function addPackageJSON(root, manifest, runtime) {
|
|
|
431
431
|
const defaults = getDefaultsForPackageJson(manifest, runtime);
|
|
432
432
|
|
|
433
433
|
const packageJson = {
|
|
434
|
-
name: manifest.
|
|
434
|
+
name: manifest.unix_name,
|
|
435
435
|
version: defaults.version,
|
|
436
436
|
description: manifest.description || defaults.description,
|
|
437
437
|
engines: {
|
|
@@ -441,6 +441,7 @@ function addPackageJSON(root, manifest, runtime) {
|
|
|
441
441
|
scripts: defaults.scripts,
|
|
442
442
|
dependencies: defaults.dependencies,
|
|
443
443
|
devDependencies: defaults.devDependencies,
|
|
444
|
+
...(defaults.jest && {jest: defaults.jest})
|
|
444
445
|
};
|
|
445
446
|
|
|
446
447
|
return fs.writeJSON(path.join(root, 'package.json'), packageJson, writejsonOptions);
|
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { Button } from '@corva/ui/components';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
6
|
+
const Toggle = () => {
|
|
7
|
+
const [isOn, setIsOn] = useState(false);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{isOn ? 'ON' : 'OFF'}
|
|
12
|
+
<Button onClick={() => setIsOn(value => !value)}>toggle</Button>
|
|
13
|
+
</>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe('<Toggle />', () => {
|
|
18
|
+
it('should be OFF by default', () => {
|
|
19
|
+
render(<Toggle />);
|
|
20
|
+
|
|
21
|
+
expect(screen.getByText('OFF')).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should switch to ON after a single press', async () => {
|
|
25
|
+
render(<Toggle />);
|
|
26
|
+
|
|
27
|
+
userEvent.click(screen.getByText('toggle'));
|
|
28
|
+
|
|
29
|
+
await waitFor(() => screen.getByText('ON'));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -2,6 +2,18 @@ import { Checkbox, FormControlLabel } from '@material-ui/core';
|
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_SETTINGS } from './constants';
|
|
4
4
|
|
|
5
|
+
/* Types */
|
|
6
|
+
interface AppSettingsProps {
|
|
7
|
+
app: { [key: string]: any };
|
|
8
|
+
appData: { [key: string]: any };
|
|
9
|
+
company: { [key: string]: any };
|
|
10
|
+
onSettingChange: (key: string, value: any) => void;
|
|
11
|
+
settings: {
|
|
12
|
+
isExampleCheckboxChecked: boolean;
|
|
13
|
+
};
|
|
14
|
+
user: { [key: string]: any };
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
const AppSettings = (props: AppSettingsProps): JSX.Element => {
|
|
6
18
|
const { settings: apiSettings, onSettingChange } = props;
|
|
7
19
|
const settings = { ...DEFAULT_SETTINGS, ...apiSettings };
|
|
@@ -25,18 +37,6 @@ AppSettings.defaultProps = {
|
|
|
25
37
|
company: {},
|
|
26
38
|
};
|
|
27
39
|
|
|
28
|
-
/* Types */
|
|
29
|
-
interface AppSettingsProps {
|
|
30
|
-
app: { [key: string]: any };
|
|
31
|
-
appData: { [key: string]: any };
|
|
32
|
-
company: { [key: string]: any };
|
|
33
|
-
onSettingChange: (key: string, value: any) => void;
|
|
34
|
-
settings: {
|
|
35
|
-
isExampleCheckboxChecked: boolean;
|
|
36
|
-
};
|
|
37
|
-
user: { [key: string]: any };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
40
|
// Important: Do not change root component default export (AppSettings.js). Use it as container
|
|
41
41
|
// for your App Settings. It's required to make build and zip scripts work as expected;
|
|
42
42
|
export default AppSettings;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { Button } from '@corva/ui/components';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
6
|
+
const Toggle = () => {
|
|
7
|
+
const [isOn, setIsOn] = useState<boolean>(false);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{isOn ? 'ON' : 'OFF'}
|
|
12
|
+
<Button onClick={() => setIsOn(value => !value)}>toggle</Button>
|
|
13
|
+
</>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe('<Toggle />', () => {
|
|
18
|
+
it('should be OFF by default', () => {
|
|
19
|
+
render(<Toggle />);
|
|
20
|
+
|
|
21
|
+
expect(screen.getByText('OFF')).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should switch to ON after a single press', async () => {
|
|
25
|
+
render(<Toggle />);
|
|
26
|
+
|
|
27
|
+
userEvent.click(screen.getByText('toggle'));
|
|
28
|
+
|
|
29
|
+
await waitFor(() => screen.getByText('ON'));
|
|
30
|
+
});
|
|
31
|
+
});
|