Skip to content

Commit a390ab1

Browse files
authored
Update dependencies (#154)
* Update module dependencies * Update non-eslint root dependencies * Update eslint dependencies * Fix failing jest tests * Update upload-preview.js
1 parent 20bde3b commit a390ab1

File tree

12 files changed

+4145
-2992
lines changed

12 files changed

+4145
-2992
lines changed

.github/upload-preview.js

Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,98 @@
11
const fs = require('fs');
22
const path = require('path');
3-
const { Octokit } = require('@octokit/rest');
4-
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
53
const surge = require('surge');
64
const publishFn = surge().publish();
75

8-
// From github actions
9-
const ghrepo = process.env.GITHUB_REPOSITORY || '';
6+
(async () => {
7+
const { Octokit } = await import('@octokit/rest');
8+
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
109

11-
const owner = process.env.CIRCLE_PROJECT_USERNAME || ghrepo.split('/')[0]; // patternfly
12-
const repo = process.env.CIRCLE_PROJECT_REPONAME || ghrepo.split('/')[1];
13-
const prnum = process.env.CIRCLE_PR_NUMBER || process.env.GH_PR_NUM;
14-
const prbranch = process.env.CIRCLE_BRANCH || process.env.GITHUB_REF.split('/').pop();
10+
// From github actions
11+
const ghrepo = process.env.GITHUB_REPOSITORY || '';
1512

16-
const uploadFolder = process.argv[2];
17-
if (!uploadFolder) {
18-
console.log('Usage: upload-preview uploadFolder');
19-
process.exit(1);
20-
}
13+
const owner = process.env.CIRCLE_PROJECT_USERNAME || ghrepo.split('/')[0]; // patternfly
14+
const repo = process.env.CIRCLE_PROJECT_REPONAME || ghrepo.split('/')[1];
15+
const prnum = process.env.CIRCLE_PR_NUMBER || process.env.GH_PR_NUM;
16+
const prbranch = process.env.CIRCLE_BRANCH || process.env.GITHUB_REF.split('/').pop();
2117

22-
const uploadFolderName = path.basename(uploadFolder);
23-
let uploadURL = `${repo}-${prnum ? `pr-component-groups-${prnum}` : prbranch}`.replace(/[\/|\.]/g, '-');
18+
const uploadFolder = process.argv[2];
19+
if (!uploadFolder) {
20+
console.log('Usage: upload-preview uploadFolder');
21+
process.exit(1);
22+
}
2423

25-
switch(uploadFolderName) {
26-
case 'coverage':
27-
uploadURL += '-a11y.surge.sh';
28-
break;
29-
case 'public':
30-
if (!prnum && prbranch === 'main') {
31-
uploadURL = 'https://pf-extensions.surge.sh/';
32-
}
33-
else {
24+
const uploadFolderName = path.basename(uploadFolder);
25+
let uploadURL = `${repo}-${prnum ? `pr-component-groups-${prnum}` : prbranch}`.replace(/[\/|\.]/g, '-');
26+
27+
switch(uploadFolderName) {
28+
case 'coverage':
29+
uploadURL += '-a11y.surge.sh';
30+
break;
31+
case 'public':
32+
if (!prnum && prbranch === 'main') {
33+
uploadURL = 'https://pf-extensions.surge.sh/';
34+
} else {
35+
uploadURL += '.surge.sh';
36+
}
37+
break;
38+
default:
39+
uploadURL += `-${uploadFolderName}`;
3440
uploadURL += '.surge.sh';
35-
}
36-
break;
37-
default:
38-
uploadURL += `-${uploadFolderName}`;
39-
uploadURL += '.surge.sh';
40-
break;
41-
}
41+
break;
42+
}
4243

43-
publishFn({
44-
project: uploadFolder,
45-
p: uploadFolder,
46-
domain: uploadURL,
47-
d: uploadURL,
48-
e: 'https://surge.surge.sh',
49-
endpoint: 'https://surge.surge.sh'
50-
});
44+
publishFn({
45+
project: uploadFolder,
46+
p: uploadFolder,
47+
domain: uploadURL,
48+
d: uploadURL,
49+
e: 'https://surge.surge.sh',
50+
endpoint: 'https://surge.surge.sh'
51+
});
5152

52-
function tryAddComment(comment, commentBody) {
53-
if (!commentBody.includes(comment)) {
54-
return comment;
53+
function tryAddComment(comment, commentBody) {
54+
if (!commentBody.includes(comment)) {
55+
return comment;
56+
}
57+
return '';
5558
}
56-
return '';
57-
}
5859

59-
if (prnum) {
60-
octokit.issues.listComments({
61-
owner,
62-
repo,
63-
issue_number: prnum
64-
})
65-
.then(res => res.data)
66-
.then(comments => {
67-
let commentBody = '';
68-
const existingComment = comments.find(comment => comment.user.login === 'patternfly-build');
69-
if (existingComment) {
70-
commentBody += existingComment.body.trim();
71-
commentBody += '\n\n';
72-
}
60+
if (prnum) {
61+
const comments = await octokit.issues.listComments({
62+
owner,
63+
repo,
64+
issue_number: prnum
65+
}).then(res => res.data);
7366

74-
if (uploadFolderName === 'public') {
75-
commentBody += tryAddComment(`Preview: https://${uploadURL}`, commentBody);
76-
}
77-
else if (uploadFolderName === 'coverage') {
78-
commentBody += tryAddComment(`A11y report: https://${uploadURL}`, commentBody);
79-
}
67+
let commentBody = '';
68+
const existingComment = comments.find(comment => comment.user.login === 'patternfly-build');
69+
if (existingComment) {
70+
commentBody += existingComment.body.trim();
71+
commentBody += '\n\n';
72+
}
8073

81-
if (existingComment) {
82-
octokit.issues.updateComment({
83-
owner,
84-
repo,
85-
comment_id: existingComment.id,
86-
body: commentBody
87-
}).then(() => console.log('Updated comment!'));
88-
} else {
89-
octokit.issues.createComment({
90-
owner,
91-
repo,
92-
issue_number: prnum,
93-
body: commentBody
94-
}).then(() => console.log('Created comment!'));
95-
}
96-
});
97-
}
74+
if (uploadFolderName === 'public') {
75+
commentBody += tryAddComment(`Preview: https://${uploadURL}`, commentBody);
76+
} else if (uploadFolderName === 'coverage') {
77+
commentBody += tryAddComment(`A11y report: https://${uploadURL}`, commentBody);
78+
}
79+
80+
if (existingComment) {
81+
await octokit.issues.updateComment({
82+
owner,
83+
repo,
84+
comment_id: existingComment.id,
85+
body: commentBody
86+
});
87+
console.log('Updated comment!');
88+
} else {
89+
await octokit.issues.createComment({
90+
owner,
91+
repo,
92+
issue_number: prnum,
93+
body: commentBody
94+
});
95+
console.log('Created comment!');
96+
}
97+
}
98+
})();

config/setupTests.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,3 @@
1-
/* eslint-disable no-unused-vars */
21
import 'whatwg-fetch';
32
import 'babel-polyfill';
43
import '@testing-library/jest-dom';
5-
6-
global.SVGPathElement = function () {};
7-
8-
global.MutationObserver = class {
9-
constructor(callback) {}
10-
disconnect() {}
11-
observe(element, initObject) {}
12-
};
13-
14-
global.window.insights = {
15-
...(window.insights || {}),
16-
chrome: {
17-
...((window.insights && window.insights.chrome) || {}),
18-
auth: {
19-
...((window.insights && window.insights.chrome && window.insights.chrome) || {}),
20-
getUser: () =>
21-
new Promise((res) =>
22-
res({
23-
identity: {
24-
// eslint-disable-next-line camelcase
25-
account_number: '0',
26-
type: 'User',
27-
user: {
28-
// eslint-disable-next-line camelcase
29-
is_org_admin: true,
30-
},
31-
},
32-
})
33-
),
34-
},
35-
getUserPermissions: () => new Promise((res) => res([])),
36-
isBeta: () => false,
37-
},
38-
};
39-
jest.mock('react', () => ({
40-
...jest.requireActual('react'),
41-
useLayoutEffect: jest.requireActual('react').useEffect,
42-
}));
43-
Element.prototype.scrollTo = () => {};

cypress/component/ErrorBoundary.cy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ErrorBoundary from '../../packages/module/dist/dynamic/ErrorBoundary';
33

44
describe('ErrorBoundary', () => {
55
it('renders the ErrorBoundary ', () => {
6-
cy.mount(<ErrorBoundary headerTitle="My app header" errorTitle="Something wrong happened"/>)
7-
cy.get('div h1').should('have.text', 'Something wrong happened');
6+
cy.mount(<ErrorBoundary headerTitle="My app header" errorTitle="Something wrong happened"><div data-ouia-component-id="test">Test</div></ErrorBoundary>)
7+
cy.get('[data-ouia-component-id="test"]').should('have.text', 'Test');
88
});
99
})

fed-mini-modules.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
const fse = require('fs-extra');
2-
const glob = require('glob');
2+
const { globSync } = require('glob');
33
const path = require('path');
44

55
const root = process.cwd();
66

7-
const sourceFiles = glob
8-
.sync(`${root}/src/*/`)
7+
const sourceFiles = globSync(`${root}/src/*/`)
98
.map((name) => name.replace(/\/$/, ''));
109

11-
const indexTypings = glob.sync(`${root}/src/index.d.ts`);
10+
const indexTypings = globSync(`${root}/src/index.d.ts`);
1211

1312
async function copyTypings(files, dest) {
1413
const cmds = [];
@@ -21,7 +20,7 @@ async function copyTypings(files, dest) {
2120

2221
async function createPackage(file) {
2322
const fileName = file.split('/').pop();
24-
const esmSource = glob.sync(`${root}/esm/${fileName}/**/index.js`)[0];
23+
const esmSource = globSync(`${root}/esm/${fileName}/**/index.js`)[0];
2524
/**
2625
* Prevent creating package.json for directories with no JS files (like CSS directories)
2726
*/
@@ -36,7 +35,7 @@ async function createPackage(file) {
3635
main: 'index.js',
3736
module: esmRelative,
3837
};
39-
const typings = glob.sync(`${root}/src/${fileName}/*.d.ts`);
38+
const typings = globSync(`${root}/src/${fileName}/*.d.ts`);
4039
const cmds = [];
4140
content.typings = 'index.d.ts';
4241
cmds.push(copyTypings(typings, `${root}/${fileName}`));
@@ -56,6 +55,7 @@ async function run(files) {
5655
copyTypings(indexTypings, root);
5756
}
5857
} catch (error) {
58+
// eslint-disable-next-line no-console
5959
console.error(error);
6060
process.exit(1);
6161
}

0 commit comments

Comments
 (0)