Skip to content

Commit fb8f3dd

Browse files
committed
feat(init): Initialize the data view extension
1 parent 8bae9f1 commit fb8f3dd

Some content is hidden

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

59 files changed

+25622
-2
lines changed
47.9 MB
Binary file not shown.
261 KB
Binary file not shown.

.eslintignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Javascript builds
2+
node_modules
3+
dist
4+
tsc_out
5+
.out
6+
.changelog
7+
.DS_Store
8+
coverage
9+
.cache
10+
.tmp
11+
.eslintcache
12+
generated
13+
__tests__
14+
15+
# package managers
16+
lerna-debug.log
17+
18+
# IDEs and editors
19+
.idea
20+
.project
21+
.classpath
22+
.c9
23+
*.launch
24+
.settings
25+
*.sublime-workspace
26+
.history
27+
.vscode
28+
.yo-rc.json
29+
30+
# IDE - VSCode
31+
.vscode
32+
# For vim
33+
*.swp
34+
35+
public

.eslintrc-md.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"plugins": [
3+
"markdown",
4+
"react"
5+
],
6+
"parserOptions": {
7+
"ecmaVersion": 9,
8+
"sourceType": "module",
9+
"ecmaFeatures": {
10+
"jsx": true
11+
}
12+
},
13+
"settings": {
14+
"react": {
15+
"version": "16.4.0"
16+
}
17+
},
18+
"rules": {
19+
"eol-last": 2,
20+
"spaced-comment": 2,
21+
"no-unused-vars": 0,
22+
"no-this-before-super": 2,
23+
"react/jsx-uses-react": "error",
24+
"react/jsx-uses-vars": "error",
25+
"react/no-unknown-property": 2,
26+
"react/jsx-no-undef": 2
27+
}
28+
}

.eslintrc.json

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es6": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:react/recommended",
10+
"plugin:react-hooks/recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"prettier"
13+
],
14+
"overrides": [
15+
{
16+
"files": ["**/patternfly-docs/pages/*"],
17+
"rules": {
18+
"arrow-body-style": "off"
19+
}
20+
}
21+
],
22+
"parserOptions": {
23+
"ecmaVersion": "latest",
24+
"sourceType": "module",
25+
"ecmaFeatures": {
26+
"jsx": true
27+
}
28+
},
29+
"settings": {
30+
"react": {
31+
"version": "detect"
32+
}
33+
},
34+
"plugins": ["react", "react-hooks", "@typescript-eslint"],
35+
"rules": {
36+
"@typescript-eslint/adjacent-overload-signatures": "error",
37+
"@typescript-eslint/array-type": "error",
38+
"@typescript-eslint/consistent-type-assertions": "error",
39+
"@typescript-eslint/consistent-type-definitions": "error",
40+
"@typescript-eslint/no-misused-new": "error",
41+
"@typescript-eslint/no-namespace": "error",
42+
"@typescript-eslint/no-unused-vars": [
43+
"error",
44+
{
45+
"argsIgnorePattern": "^_"
46+
}
47+
],
48+
"@typescript-eslint/prefer-for-of": "error",
49+
"@typescript-eslint/prefer-function-type": "error",
50+
"@typescript-eslint/prefer-namespace-keyword": "error",
51+
"@typescript-eslint/unified-signatures": "error",
52+
"@typescript-eslint/no-var-requires": "off",
53+
"arrow-body-style": "error",
54+
"array-bracket-spacing": ["error", "always"],
55+
"camelcase": [
56+
"error",
57+
{
58+
"ignoreDestructuring": true
59+
}
60+
],
61+
"constructor-super": "error",
62+
"curly": "error",
63+
"dot-notation": "error",
64+
"eqeqeq": ["error", "smart"],
65+
"guard-for-in": "error",
66+
"indent": ["error", 2],
67+
"max-classes-per-file": ["error", 1],
68+
"no-nested-ternary": "error",
69+
"no-bitwise": "error",
70+
"no-caller": "error",
71+
"no-cond-assign": "error",
72+
"no-console": "error",
73+
"no-debugger": "error",
74+
"no-empty": "error",
75+
"no-eval": "error",
76+
"no-new-wrappers": "error",
77+
"no-undef-init": "error",
78+
"no-unsafe-finally": "error",
79+
"no-unused-expressions": [
80+
"error",
81+
{
82+
"allowTernary": true,
83+
"allowShortCircuit": true
84+
}
85+
],
86+
"no-unused-labels": "error",
87+
"no-var": "error",
88+
"object-shorthand": "error",
89+
"object-curly-spacing": ["error", "always"],
90+
"one-var": ["error", "never"],
91+
"prefer-const": "error",
92+
"radix": ["error", "as-needed"],
93+
"react/prop-types": 0,
94+
"react/display-name": 0,
95+
"react-hooks/exhaustive-deps": "warn",
96+
"react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }],
97+
"spaced-comment": "error",
98+
"use-isnan": "error"
99+
}
100+
}

.github/upload-preview.js

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { Octokit } = require('@octokit/rest');
4+
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
5+
const surge = require('surge');
6+
const publishFn = surge().publish();
7+
8+
// From github actions
9+
const ghrepo = process.env.GITHUB_REPOSITORY || '';
10+
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();
15+
16+
const uploadFolder = process.argv[2];
17+
if (!uploadFolder) {
18+
console.log('Usage: upload-preview uploadFolder');
19+
process.exit(1);
20+
}
21+
22+
const uploadFolderName = path.basename(uploadFolder);
23+
let uploadURL = `${repo}-${prnum ? `pr-data-view-${prnum}` : prbranch}`.replace(/[\/|\.]/g, '-');
24+
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 {
34+
uploadURL += '.surge.sh';
35+
}
36+
break;
37+
default:
38+
uploadURL += `-${uploadFolderName}`;
39+
uploadURL += '.surge.sh';
40+
break;
41+
}
42+
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+
});
51+
52+
function tryAddComment(comment, commentBody) {
53+
if (!commentBody.includes(comment)) {
54+
return comment;
55+
}
56+
return '';
57+
}
58+
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+
}
73+
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+
}
80+
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+
}

0 commit comments

Comments
 (0)