Skip to content

Commit a5e080f

Browse files
SNPRC Scheduler project updates (#858)
* Factor out unnecessary and unsupported packages * Update all other packages to latest versions (including react, redux and react-dnd) * Update webpack build to use standard @labkey/build * Update entrypoint and production/dev server entry points * Many refactors associated with package updates including bootstrap and react-data-grid updates * Refactor all grids using react-bootstrap-table to instead use react-data-grid * Start conversion of JS and JSX files to TS and TSX * Update jest tests to new libraries and webpack
1 parent b351621 commit a5e080f

71 files changed

Lines changed: 14963 additions & 10843 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ snprc_ehr/.editorconfig
3333
snprc_ehr/resources/referenceStudy/LoadTaqmanData
3434
snprc_ehr/resources/referenceStudy/datasetImport/LoadTaqmanData
3535
snprc_scheduler/.gradle
36+
snprc_scheduler/resources/views/gen
37+
snprc_scheduler/resources/web/gen
3638
snprc_ehr/resources/credits
3739
*/resources/credits/dependencies.txt
3840
*/resources/credits/jars.txt

snprc_scheduler/.babelrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

snprc_scheduler/eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import config from '@labkey/eslint-config';
2+
export default config;

snprc_scheduler/jest.config.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@ module.exports = {
33
LABKEY: {},
44
},
55
moduleFileExtensions: [
6+
"ts",
7+
"tsx",
68
"jsx",
79
"js",
810
],
9-
setupFilesAfterEnv: [
10-
"<rootDir>/src/client/tests/setupTests.js"
11-
],
1211
testEnvironment: "jsdom",
1312
testPathIgnorePatterns: [
1413
"node_modules",
1514
],
16-
testRegex: "(\\.(test|spec))\\.(js|jsx)$",
17-
testResultsProcessor: "jest-teamcity-reporter"
15+
testRegex: "(\\.(test|spec))\\.(js|jsx|ts|tsx)$",
16+
testResultsProcessor: "jest-teamcity-reporter",
17+
transform: {
18+
"^.+\\.(js|jsx|ts|tsx)$": [
19+
'ts-jest',
20+
{
21+
tsconfig: 'node_modules/@labkey/build/webpack/tsconfig.test.json',
22+
},
23+
],
24+
}
1825
};

snprc_scheduler/lint.diff.mjs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { execa } from 'execa';
2+
3+
const fileExtensions = ['.tsx', '.ts']; // linted file types
4+
5+
// This is the difference from where the top of the git repo is and where this script is run from. Will
6+
// need to be updated for other repos.
7+
const repoPath = '';
8+
9+
// Default path to the directory to be checked for changes
10+
let lintPath = 'src/';
11+
12+
// Default lint target (--fix changes to lint-fix)
13+
let npmTarget = 'lint';
14+
15+
let currentBranch = false;
16+
17+
// Parameters all optional.
18+
// --fix: this will perform eslint --fix instead of regular eslint
19+
// --currentBranch: this will perform eslint on the files that have been changed in this branch compared
20+
// to the master branch. Can be run with our without --fix. Will ignore any file paths passed in.
21+
// File path: if wanting to do a lint-diff on a specific directory or file otherwise defaults to src/
22+
if (process.argv.length > 2) {
23+
for (let i=2; i<process.argv.length; i++) {
24+
switch(process.argv[i]) {
25+
case '--fix':
26+
npmTarget = 'lint-fix';
27+
break;
28+
case '--currentBranch':
29+
currentBranch = true;
30+
break;
31+
default:
32+
lintPath = process.argv[i];
33+
}
34+
}
35+
}
36+
37+
(async () => {
38+
let files;
39+
let stdout; // This is the supported way to pipe stdout to a local variable
40+
if (currentBranch) {
41+
// Get name of the current branch
42+
({ stdout } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD']));
43+
if (!stdout) {
44+
console.error('Error finding git branch name');
45+
} else {
46+
console.log('Checking for updated files in branch: ', stdout);
47+
}
48+
49+
const branch = stdout;
50+
51+
// Diff current branch against develop to get changed file names
52+
({stdout} = await execa('git', ['diff', 'develop...' + branch, '--name-only', '--diff-filter=AM', '--relative']));
53+
if (!stdout) {
54+
console.log('No changed files in branch ' + branch);
55+
}
56+
57+
files = stdout;
58+
} else {
59+
// Diff uncommitted changes against committed to
60+
({stdout} = await execa('git', ['diff', '--name-only', '--diff-filter=AM', '--relative', lintPath]));
61+
if (!stdout) {
62+
console.log('No changed files at ' + lintPath);
63+
}
64+
65+
files = stdout;
66+
}
67+
68+
if (files) {
69+
let filtered = stdout.split('\n');
70+
71+
// Filter by file extension and file path
72+
filtered = filtered.filter(file => {
73+
file = file.trim();
74+
const correctPath = file.startsWith(repoPath + 'src/');
75+
const correctExt = fileExtensions.findIndex(ext => (file.endsWith(ext))) !== -1;
76+
return correctPath && correctExt
77+
});
78+
79+
if (filtered.length < 1) {
80+
console.log('No changed files match the file extension.')
81+
}
82+
else {
83+
// Remove file path relative to git repo
84+
filtered = filtered.map(file => {
85+
return file.substring(repoPath.length);
86+
});
87+
88+
console.log('Linting files:\n', filtered);
89+
90+
// File paths need parens to resolve correctly
91+
const param = "\"" + filtered.join("\" \"") + "\"";
92+
93+
try {
94+
await execa('npm', ['run', npmTarget, param], {shell: true}).stdout.pipe(process.stdout);
95+
}
96+
catch (error) {
97+
console.error("Lint error: ", error);
98+
}
99+
}
100+
}
101+
})();

0 commit comments

Comments
 (0)