diff --git a/.eslintignore b/.eslintignore index 8f24d4ab..1268706e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,9 @@ -packages/*/** -prototypes/*/** artifacts reports +.nyc_output +coverage +dist +styleguide +build +lib/app +node_modules \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index 2d9d8311..3acd62ef 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,10 @@ { "extends": "joyent-portal", "rules": { - "jsx-a11y/href-no-hash": 0, + "no-console": 1, "new-cap": 0, - "no-console": 0 + "jsx-a11y/href-no-hash": 0, + "no-negated-condition": 1, + "camelcase": 1 } } diff --git a/bundle/.yarnclean b/bundle/.yarnclean new file mode 100644 index 00000000..e69de29b diff --git a/bundle/package.json b/bundle/package.json index f256074f..35767072 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -9,24 +9,21 @@ "build:lib": "echo 0", "build:bundle": "echo 0", "prepublish": "echo 0", - "lint": "echo 0", - "lint:ci": "echo 0", "test": "echo 0", "test:ci": "echo 0" }, "dependencies": { "apr-main": "^4.0.3", - "brule": "^3.1.0", - "cloudapi-gql": "^7.1.4", + "cloudapi-gql": "^8.0.0", "execa": "^0.10.0", - "h2o2": "^8.0.1", - "hapi": "^17.3.1", - "hapi-triton-auth": "^2.0.1", - "hapi-webconsole-nav": "^1.2.0", - "inert": "^5.1.0", + "graphi": "^5.7.0", + "h2o2": "^8.1.2", + "hapi": "^17.4.0", + "hapi-triton-auth": "^3.0.0", + "hapi-webconsole-nav": "^2.1.0", "my-joy-images": "*", "my-joy-instances": "*", "my-joy-navigation": "*", - "rollover": "^1.0.0" + "tsg-graphql": "^1.0.0" } } diff --git a/bundle/src/images.js b/bundle/src/images.js index ee1d313e..e6cea0e7 100644 --- a/bundle/src/images.js +++ b/bundle/src/images.js @@ -1,5 +1,8 @@ +require('../.env.js'); + const Main = require('apr-main'); const CloudApiGql = require('cloudapi-gql'); +const Graphi = require('graphi'); const Url = require('url'); const Server = require('./server'); @@ -28,6 +31,17 @@ Main(async () => { }); await server.register([ + { + plugin: Graphi, + options: { + graphqlPath: '/graphql', + graphiqlPath: '/graphiql', + authStrategy: 'sso' + }, + routes: { + prefix: `/${PREFIX}` + } + }, { plugin: CloudApiGql, options: { diff --git a/bundle/src/instances.js b/bundle/src/instances.js index 3fbcb4ee..26a3f45a 100644 --- a/bundle/src/instances.js +++ b/bundle/src/instances.js @@ -1,5 +1,8 @@ +require('../.env.js'); + const Main = require('apr-main'); const CloudApiGql = require('cloudapi-gql'); +const Graphi = require('graphi'); const Url = require('url'); const Server = require('./server'); @@ -28,6 +31,17 @@ Main(async () => { }); await server.register([ + { + plugin: Graphi, + options: { + graphqlPath: '/graphql', + graphiqlPath: '/graphiql', + authStrategy: 'sso' + }, + routes: { + prefix: `/${PREFIX}` + } + }, { plugin: CloudApiGql, options: { diff --git a/bundle/src/navigation.js b/bundle/src/navigation.js index 94f7eee1..859b9d2a 100644 --- a/bundle/src/navigation.js +++ b/bundle/src/navigation.js @@ -1,5 +1,8 @@ +require('../.env.js'); + const Main = require('apr-main'); const Nav = require('hapi-webconsole-nav'); +const Graphi = require('graphi'); const Url = require('url'); const Server = require('./server'); @@ -33,6 +36,17 @@ Main(async () => { }); await server.register([ + { + plugin: Graphi, + options: { + graphqlPath: '/graphql', + graphiqlPath: '/graphiql', + authStrategy: 'sso' + }, + routes: { + prefix: `/${PREFIX}` + } + }, { plugin: Nav, options: { diff --git a/bundle/src/server.js b/bundle/src/server.js index 6378cae1..6be55cfb 100644 --- a/bundle/src/server.js +++ b/bundle/src/server.js @@ -1,6 +1,7 @@ +require('../.env.js'); + const Hapi = require('hapi'); const Sso = require('hapi-triton-auth'); -const Url = require('url'); const { COOKIE_PASSWORD, @@ -8,12 +9,10 @@ const { SDC_KEY_PATH, SDC_ACCOUNT, SDC_KEY_ID, - SDC_URL, - DC_NAME + SDC_URL } = process.env; module.exports = async ({ PORT, BASE_URL }) => { - const dcName = DC_NAME || Url.parse(SDC_URL).host.split('.')[0]; const keyPath = SDC_KEY_PATH; const keyId = `/${SDC_ACCOUNT}/keys/${SDC_KEY_ID}`; const apiBaseUrl = SDC_URL; @@ -50,6 +49,7 @@ module.exports = async ({ PORT, BASE_URL }) => { server.events.on('log', (event, tags) => { if (tags.error) { + // eslint-disable-next-line no-console console.log(event); } }); @@ -58,6 +58,7 @@ module.exports = async ({ PORT, BASE_URL }) => { const { tags } = event; if (tags.includes('error') && event.data && event.data.errors) { event.data.errors.forEach(error => { + // eslint-disable-next-line no-console console.log(error); }); } diff --git a/bundle/src/service-groups.js b/bundle/src/service-groups.js new file mode 100644 index 00000000..f9819cbb --- /dev/null +++ b/bundle/src/service-groups.js @@ -0,0 +1,74 @@ +require('../.env.js'); + +const Main = require('apr-main'); +const CloudApiGql = require('cloudapi-gql'); +const Tsg = require('tsg-graphql'); +const Graphi = require('graphi'); +const Url = require('url'); + +const Server = require('./server'); + +const { + PORT = 4004, + BASE_URL = `http://0.0.0.0:${PORT}`, + PREFIX = 'service-groups', + DC_NAME, + TSG_URL = 'http://0.0.0.0:3000', + SDC_URL, + SDC_KEY_PATH, + SDC_ACCOUNT, + SDC_KEY_ID +} = process.env; + +const dcName = DC_NAME || Url.parse(SDC_URL).host.split('.')[0]; +const keyPath = SDC_KEY_PATH; +const keyId = `/${SDC_ACCOUNT}/keys/${SDC_KEY_ID}`; + +Main(async () => { + const server = await Server({ + PORT, + BASE_URL + }); + + await server.register([ + { + plugin: Graphi, + options: { + graphqlPath: '/graphql', + graphiqlPath: '/graphiql', + authStrategy: 'sso' + }, + routes: { + prefix: `/${PREFIX}` + } + }, + { + plugin: Tsg, + options: { + authStrategy: 'sso', + keyPath, + keyId, + apiBaseUrl: TSG_URL, + dcName + }, + routes: { + prefix: `/${PREFIX}` + } + }, + { + plugin: CloudApiGql, + options: { + authStrategy: 'sso', + keyPath, + keyId, + apiBaseUrl: SDC_URL, + dcName + }, + routes: { + prefix: `/${PREFIX}` + } + } + ]); + + await server.start(); +}); diff --git a/bundle/src/templates.js b/bundle/src/templates.js new file mode 100644 index 00000000..2bd6a8a3 --- /dev/null +++ b/bundle/src/templates.js @@ -0,0 +1,74 @@ +require('../.env.js'); + +const Main = require('apr-main'); +const CloudApiGql = require('cloudapi-gql'); +const Tsg = require('tsg-graphql'); +const Graphi = require('graphi'); +const Url = require('url'); + +const Server = require('./server'); + +const { + PORT = 4005, + BASE_URL = `http://0.0.0.0:${PORT}`, + PREFIX = 'templates', + DC_NAME, + TSG_URL = 'http://0.0.0.0:3000', + SDC_URL, + SDC_KEY_PATH, + SDC_ACCOUNT, + SDC_KEY_ID +} = process.env; + +const dcName = DC_NAME || Url.parse(SDC_URL).host.split('.')[0]; +const keyPath = SDC_KEY_PATH; +const keyId = `/${SDC_ACCOUNT}/keys/${SDC_KEY_ID}`; + +Main(async () => { + const server = await Server({ + PORT, + BASE_URL + }); + + await server.register([ + { + plugin: Graphi, + options: { + graphqlPath: '/graphql', + graphiqlPath: '/graphiql', + authStrategy: 'sso' + }, + routes: { + prefix: `/${PREFIX}` + } + }, + { + plugin: Tsg, + options: { + authStrategy: 'sso', + keyPath, + keyId, + apiBaseUrl: TSG_URL, + dcName + }, + routes: { + prefix: `/${PREFIX}` + } + }, + { + plugin: CloudApiGql, + options: { + authStrategy: 'sso', + keyPath, + keyId, + apiBaseUrl: SDC_URL, + dcName + }, + routes: { + prefix: `/${PREFIX}` + } + } + ]); + + await server.start(); +}); diff --git a/commitlint.config.js b/commitlint.config.js index da6b1b5f..3aff4a4f 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -4,7 +4,16 @@ module.exports = { 'scope-enum': [ 2, 'always', - ['ui-toolkit', 'icons', 'instances', 'navigation', 'bundle', 'images'] + [ + 'ui-toolkit', + 'icons', + 'instances', + 'navigation', + 'bundle', + 'images', + 'sg', + 'templates' + ] ] } }; diff --git a/consoles/my-joy-images/.eslintrc b/consoles/my-joy-images/.eslintrc deleted file mode 100644 index 435e02c4..00000000 --- a/consoles/my-joy-images/.eslintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "joyent-portal", - "rules": { - "no-console": 0, - "new-cap": 0, - "camelcase": 1, - "jsx-a11y/href-no-hash": 0, - "no-negated-condition": 0 - } -} diff --git a/consoles/my-joy-images/lib/index.js b/consoles/my-joy-images/lib/index.js index 75c7af75..7e3e9199 100644 --- a/consoles/my-joy-images/lib/index.js +++ b/consoles/my-joy-images/lib/index.js @@ -16,6 +16,7 @@ exports.register = async server => { if (NODE_ENV === 'production') { throw err; } else { + // eslint-disable-next-line no-console console.error(err); } } diff --git a/consoles/my-joy-images/package.json b/consoles/my-joy-images/package.json index ccd520ad..6e085671 100644 --- a/consoles/my-joy-images/package.json +++ b/consoles/my-joy-images/package.json @@ -11,8 +11,6 @@ "build:lib": "echo 0", "build:bundle": "NAMESPACE=images NODE_ENV=production redrun -p build:frontend build:ssr", "prepublish": "NODE_ENV=production redrun build:bundle", - "lint": "redrun lint:ci -- --fix", - "lint:ci": "NODE_ENV=test eslint . --ext .js --ext .md", "test": "echo 0", "test:ci": "echo 0", "build:frontend": "joyent-react-scripts build", @@ -38,6 +36,7 @@ "inert": "^5.1.0", "joyent-logo-assets": "^1.1.0", "joyent-react-styled-flexboxgrid": "^2.2.3", + "joyent-ui-resource-widgets": "^1.0.0", "joyent-ui-toolkit": "^6.0.0", "lodash.assign": "^4.2.0", "lodash.find": "^4.6.0", diff --git a/consoles/my-joy-images/src/components/create-image/details.js b/consoles/my-joy-images/src/components/create-image/details.js index 48bd15a9..e7d1870c 100644 --- a/consoles/my-joy-images/src/components/create-image/details.js +++ b/consoles/my-joy-images/src/components/create-image/details.js @@ -6,7 +6,6 @@ import remcalc from 'remcalc'; import { Row, Col } from 'joyent-react-styled-flexboxgrid'; import { - Divider, FormGroup, FormLabel, Input, @@ -22,15 +21,14 @@ export default ({ placeholderName, randomizing, onRandomize }) => ( Image name - + - - +