Skip to content

Commit

Permalink
Add GO GraphQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
rawagner committed Jun 17, 2020
1 parent 5b864a7 commit 305ca9b
Show file tree
Hide file tree
Showing 84 changed files with 10,637 additions and 436 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/frontend/npm-debug.log
/frontend/yarn-error.log
/frontend/gui_test_screenshots
/frontend/@types
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FROM openshift/origin-base

COPY --from=build /go/src/github.com/openshift/console/frontend/public/dist /opt/bridge/static
COPY --from=build /go/src/github.com/openshift/console/bin/bridge /opt/bridge/bin/bridge
COPY --from=build /go/src/github.com/openshift/console/pkg/graphql/schema.graphql /pkg/graphql/schema.graphql

LABEL io.k8s.display-name="OpenShift Console" \
io.k8s.description="This is a component of OpenShift Container Platform and provides a web console." \
Expand Down
2 changes: 1 addition & 1 deletion analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -d "$ARTIFACT_DIR" ]; then
cp public/dist/report.html "${ARTIFACT_DIR}"
fi

MAX_BYTES=2621440 # ~2.5 MiB
MAX_BYTES=2726298 # ~2.6 MiB
VENDORS_MAIN_BYTES=$(jq -r '.assets[] | select(.name | match("^vendors~main-chunk.*js$")) | .size' public/dist/stats.json)
DISPLAY_VALUE=$(awk "BEGIN {printf \"%.2f\n\", $VENDORS_MAIN_BYTES/1024/1024}")
echo "Main vendor bundle size: $DISPLAY_VALUE MiB"
Expand Down
1 change: 1 addition & 0 deletions frontend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ public/dist
public/lib
**/node_modules
Godeps
@types
90 changes: 0 additions & 90 deletions frontend/.eslintrc

This file was deleted.

99 changes: 99 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
var fs = require('fs');

module.exports = {
root: true,
env: {
browser: true,
es6: true,
jasmine: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:react/recommended',
'plugin:console/json',
'plugin:console/prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
comment: true,
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2017,
extraFileExtensions: ['.json'],
sourceType: 'module',
tsconfigRootDir: './',
},
plugins: ['react', 'react-hooks', '@typescript-eslint', 'graphql'],
rules: {
camelcase: [
'error',
{ allow: ['UNSAFE_componentWillReceiveProps', 'UNSAFE_componentWillMount'] },
],
'consistent-return': 0,
'consistent-this': [1, 'that'],
curly: [2, 'all'],
'default-case': [2],
'dot-notation': [2],
'no-multiple-empty-lines': [2, { max: 2, maxEOF: 0 }],
eqeqeq: [2, 'allow-null'],
'guard-for-in': 2,
'import/no-unresolved': ['error'],
'import/no-duplicates': ['error'],
'max-nested-callbacks': [1, 4],
'no-alert': 2,
'no-caller': 2,
'no-console': 2,
'no-constant-condition': 2,
'no-debugger': 2,
'no-else-return': ['error'],
'no-global-strict': 0,
'no-irregular-whitespace': ['error'],
'no-prototype-builtins': 0, // Disable with exlint v6 update.
'no-shadow': ['error'],
'no-underscore-dangle': 0,
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: 'React', args: 'after-used' },
],
'@typescript-eslint/no-use-before-define': 2,
'no-var': 2,
'object-shorthand': ['error', 'properties'],
'prefer-const': ['error', { destructuring: 'all' }],
'prefer-template': 2,
radix: 2,
'react/jsx-fragments': 'error',
'react/jsx-no-duplicate-props': 2,
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/no-string-refs': 1,
'react/no-unknown-property': 'error',
'react/prop-types': 0,
'react/self-closing-comp': ['error', { component: true, html: false }],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/display-name': 0,
'react/no-unescaped-entities': 0,
'require-atomic-updates': 0,
'graphql/template-strings': [
'error',
{
env: 'literal',
schemaString: fs.readFileSync('../pkg/graphql/schema.graphql', 'utf-8'),
},
],
},
settings: {
'import/extensions': ['.js', '.jsx'],
'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts', '.tsx'] } },
react: {
version: 'detect',
},
},
globals: {
process: 'readonly',
},
};
5 changes: 4 additions & 1 deletion frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
"[json]": {
"editor.formatOnSave": true
},
"[graphql]": {
"editor.formatOnSave": true
},

"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "json"],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "json", "graphql"],
"eslint.enable": true,
"javascript.validate.enable": false,
"debug.node.autoAttach": "on",
Expand Down
4 changes: 4 additions & 0 deletions frontend/__mocks__/websocket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable */
import { WebSocket } from 'mock-socket';

global.WebSocket = WebSocket;
15 changes: 15 additions & 0 deletions frontend/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schema: ../pkg/graphql/schema.graphql
documents: ./**/*.(gql|graphql)
generates:
'@types/gql/schema.ts':
plugins:
- typescript
- typescript-operations
config:
dedupeOperationSuffix: true
namingConvention: keep
operationResultSuffix: Type
skipTypename: true
'@types/gql/queries.d.ts':
plugins:
- typescript-graphql-files-modules
2 changes: 1 addition & 1 deletion frontend/integration-tests/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"node": true,
"es6": true
},
"extends": ["../.eslintrc"],
"extends": ["../.eslintrc.js"],
"globals": {},
"rules": {
"no-console": ["error", { "allow": ["warn", "error", "log", "info"] }]
Expand Down
36 changes: 27 additions & 9 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
],
"scripts": {
"clean": "rm -rf ./public/dist",
"dev": "yarn clean && NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack-dev-server",
"dev-once": "yarn clean && NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=development",
"build": "yarn clean && NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production",
"dev": "yarn clean && yarn gql-generate && NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack-dev-server",
"dev-once": "yarn clean && yarn gql-generate && NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=development",
"build": "yarn clean && yarn gql-generate && NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production",
"check-cycles": "CHECK_CYCLES=true yarn dev-once",
"coverage": "jest --coverage .",
"eslint": "eslint --ext .js,.jsx,.ts,.tsx,.json --color",
"eslint": "eslint --ext .js,.jsx,.ts,.tsx,.json,.gql,.graphql --color",
"lint": "NODE_OPTIONS=--max-old-space-size=4096 yarn eslint .",
"test": "jest",
"debug-test": "node --inspect-brk node_modules/.bin/jest --runInBand",
Expand All @@ -28,15 +28,18 @@
"test-suite": "ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"debug-test-suite": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' node -r ts-node/register --inspect-brk ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"analyze": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production --profile --json | awk '{if(NR>2)print}' > public/dist/stats.json && ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack-bundle-analyzer --mode static -r public/dist/report.html public/dist/stats.json",
"prettier-all": "prettier --write '**/*.{js,jsx,ts,tsx,json}'"
"prettier-all": "prettier --write '**/*.{js,jsx,ts,tsx,json}'",
"gql-generate": "graphql-codegen"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json"
"json",
"gql",
"graphql"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
Expand All @@ -46,7 +49,8 @@
"^react-dnd-html5-backend$": "react-dnd-html5-backend/dist/cjs"
},
"transform": {
".(ts|tsx|js|jsx)": "./node_modules/ts-jest/preprocessor.js"
".(ts|tsx|js|jsx)": "./node_modules/ts-jest/preprocessor.js",
".(gql|graphql)$": "jest-transform-graphql"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!(lodash-es|@console|@novnc|@spice-project)/.*)"
Expand All @@ -58,6 +62,7 @@
"./__mocks__/matchMedia.js",
"./__mocks__/serverFlags.js",
"./__mocks__/mutationObserver.js",
"./__mocks__/websocket.js",
"./before-tests.js"
],
"coverageDirectory": "__coverage__",
Expand All @@ -77,21 +82,25 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.9.0",
"@patternfly/patternfly": "2.71.5",
"@patternfly/react-catalog-view-extension": "1.4.58",
"@patternfly/react-charts": "5.3.19",
"@patternfly/react-core": "3.153.13",
"@patternfly/react-table": "2.28.39",
"@patternfly/react-tokens": "2.8.13",
"@patternfly/react-topology": "2.14.58",
"@patternfly/react-virtualized-extension": "1.4.59",
"@patternfly/react-catalog-view-extension": "1.4.58",
"abort-controller": "3.0.0",
"apollo-cache-inmemory": "^1.6.5",
"apollo-client": "^2.6.8",
"apollo-link-ws": "^1.0.20",
"classnames": "2.x",
"core-js": "2.x",
"d3": "^5.9.2",
"file-saver": "1.3.x",
"focus-trap-react": "^6.0.0",
"formik": "2.0.3",
"fuzzysearch": "1.0.x",
"graphql": "^14.0.0",
"history": "4.x",
"immutable": "3.x",
"js-base64": "^2.5.1",
Expand Down Expand Up @@ -131,6 +140,7 @@
"screenfull": "4.x",
"semver": "^6.0.0",
"showdown": "1.8.x",
"subscriptions-transport-ws": "^0.9.16",
"text-encoding": "0.x",
"typesafe-actions": "^4.2.1",
"url-polyfill": "^1.1.5",
Expand All @@ -142,6 +152,10 @@
"yup": "^0.27.0"
},
"devDependencies": {
"@graphql-codegen/cli": "^1.15.1",
"@graphql-codegen/typescript": "^1.15.1",
"@graphql-codegen/typescript-graphql-files-modules": "^1.15.1",
"@graphql-codegen/typescript-operations": "^1.15.1",
"@types/classnames": "^2.2.7",
"@types/enzyme": "3.10.x",
"@types/glob": "7.x",
Expand Down Expand Up @@ -170,21 +184,25 @@
"css-loader": "0.28.x",
"enzyme": "3.10.x",
"enzyme-adapter-react-16": "1.15.2",
"eslint-plugin-graphql": "^4.0.0",
"file-loader": "1.x",
"find-up": "4.x",
"fork-ts-checker-webpack-plugin": "0.x",
"geckodriver": "1.x",
"glob": "7.x",
"glslify-loader": "1.x",
"graphql-tag": "^2.10.3",
"html-webpack-plugin": "3.x",
"husky": "^4.2.5",
"jasmine-console-reporter": "2.x",
"jasmine-core": "2.x",
"jasmine-reporters": "2.x",
"jest": "21.x",
"jest-cli": "21.x",
"jest-transform-graphql": "^2.1.0",
"lint-staged": "^10.2.2",
"mini-css-extract-plugin": "0.4.x",
"mock-socket": "^9.0.3",
"moment": "2.22.x",
"monaco-editor-core": "0.14.0",
"monaco-editor-webpack-plugin": "^1.7.0",
Expand Down Expand Up @@ -221,6 +239,6 @@
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx,json}": "eslint --color --fix"
"*.{js,jsx,ts,tsx,json,gql,graphql}": "eslint --color --fix"
}
}
Loading

0 comments on commit 305ca9b

Please sign in to comment.