From c23cbc67f687843273822faf8312444c9592ff5b Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 10 Feb 2023 18:17:36 +0100 Subject: [PATCH 01/20] begin --- website/index.html | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 website/index.html diff --git a/website/index.html b/website/index.html new file mode 100644 index 00000000..cc300f78 --- /dev/null +++ b/website/index.html @@ -0,0 +1,51 @@ + + + + + + graphql-http + + + + + + + + +
+

graphql-http

+ +
+
+ +
+ +
+
+ +
+
+
+ + + + From f1766a9230efff95cffd37552cc9e71f72bace9c Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 10 Feb 2023 18:28:19 +0100 Subject: [PATCH 02/20] website improvements --- website/index.html | 49 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/website/index.html b/website/index.html index cc300f78..1bd43a26 100644 --- a/website/index.html +++ b/website/index.html @@ -6,11 +6,27 @@ graphql-http @@ -22,17 +38,32 @@
-

graphql-http

+

graphql-http

-
- +
+ + Check for + GraphQL over HTTP spec + compliance + +
+ +
+ +
+ Please make sure that CORS allows this origin on your + server. +

- -
-
- -
+
+ +
+
@@ -41,8 +72,8 @@

graphql-http

const url = params.get('url'); if (url) { document.getElementById('url').setAttribute('value', url); - graphqlHttpAudits.auditServer({ url }).then((results) => { + // TODO: render results console.log(results); }); } From 6112bd09d44680eb510ab44e9d2737e5d7da311c Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 13:02:27 +0100 Subject: [PATCH 03/20] improvements --- website/index.html | 48 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/website/index.html b/website/index.html index 1bd43a26..bc465fba 100644 --- a/website/index.html +++ b/website/index.html @@ -3,6 +3,7 @@ + graphql-http @@ -40,8 +59,8 @@

graphql-http

-
-
+ +
Check for graphql-http
+ +
From 6fb73b1a0fc5f0b705e886b91ea31f5c25cf3356 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 13:58:31 +0100 Subject: [PATCH 04/20] display audit report --- website/index.html | 56 +++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/website/index.html b/website/index.html index bc465fba..a1a08858 100644 --- a/website/index.html +++ b/website/index.html @@ -18,15 +18,14 @@ Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; } - fieldset { - padding: 1em; - } + input { padding: 0.5em; font-size: 1em; width: 100%; } button { + cursor: pointer; font-size: 1em; } @@ -34,25 +33,34 @@ max-width: 512px; margin: 0 auto; } + fieldset { + padding: 1em; + } - #result { + #report { max-width: 1024px; - margin: 50px auto; - padding: 1em; + margin: 2em auto; + padding: 2em; border: 1px solid grey; } - #result.auditing { + #report.hidden { + display: none; + } + #report.auditing { color: grey; background-color: lightgrey; text-align: center; } + pre { + border: 1px solid grey; + padding: 1em; + } + summary { + cursor: pointer; + } - @@ -85,7 +93,7 @@

graphql-http

-
+ From 81f85c68733c3659dcaea10891fbbe154ec0c022 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 14:05:35 +0100 Subject: [PATCH 05/20] error handling --- website/index.html | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/website/index.html b/website/index.html index a1a08858..85b6f8a9 100644 --- a/website/index.html +++ b/website/index.html @@ -51,9 +51,14 @@ background-color: lightgrey; text-align: center; } + #report.error { + color: red; + border-color: red; + } pre { border: 1px solid grey; padding: 1em; + white-space: pre-wrap; } summary { cursor: pointer; @@ -111,20 +116,19 @@

graphql-http

graphqlHttpAudits .auditServer({ url }) - .then((results) => { + .then((results) => graphqlHttpAudits .renderAuditResultsToHTML(results) - .then((html) => { - reportDiv.innerHTML = html; - }) - .catch((err) => { - console.error('Problem while rendering the report', err); - // TODO: report render error - }); - }) + .then((html) => (reportDiv.innerHTML = html)), + ) .catch((err) => { - console.error('Problem while running server audits', err); - // TODO: report audit error + console.error('Problem while auditing server', err); + reportDiv.classList.add('error'); + reportDiv.innerHTML = `
${
+              err instanceof Error
+                ? err.message + '\n\n' + err.stack
+                : JSON.stringify(err, null, ' ')
+            }
`; }) .finally(() => { urlInput.removeAttribute('disabled'); From 5df91b1286c0f4fad5ff730b4415e3c2f5e86caa Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 14:08:28 +0100 Subject: [PATCH 06/20] break word in pre --- website/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/website/index.html b/website/index.html index 85b6f8a9..8318baa8 100644 --- a/website/index.html +++ b/website/index.html @@ -59,6 +59,7 @@ border: 1px solid grey; padding: 1em; white-space: pre-wrap; + word-wrap: break-word; } summary { cursor: pointer; From 326be5feea0aa4b75ee89f346f1e5f7dddb8850a Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 14:08:34 +0100 Subject: [PATCH 07/20] autofocus input url --- website/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/index.html b/website/index.html index 8318baa8..208b23cf 100644 --- a/website/index.html +++ b/website/index.html @@ -85,7 +85,7 @@

graphql-http


- +
Please make sure that CORS allows this origin on your From 5c98f821b4e72e036c02cf4544f4ea618f08331c Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 14:20:32 +0100 Subject: [PATCH 08/20] footer and niceties --- website/index.html | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/website/index.html b/website/index.html index 208b23cf..5300c62d 100644 --- a/website/index.html +++ b/website/index.html @@ -5,6 +5,10 @@ graphql-http + @@ -71,7 +79,15 @@
-

graphql-http

+

+ graphql-http +

+

+ Simple, pluggable, zero-dependency, GraphQL over HTTP spec compliant + server, client and audit suite. +

+ +
@@ -88,8 +104,11 @@

graphql-http


Please make sure that CORS allows this origin on your - server.Please make sure that + CORS + allows this origin on your server.

@@ -99,7 +118,23 @@

graphql-http

+
+ + + + ${closeMark}`, + ), + ); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/website/index.html b/website/index.html index b20f803d..a00d5b74 100644 --- a/website/index.html +++ b/website/index.html @@ -85,6 +85,10 @@ + From 39eafe56bdc37a3f481332f28d7385f881e5d478 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 22:09:15 +0100 Subject: [PATCH 17/20] website ci --- .github/workflows/website.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 00000000..f3c0c72d --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,39 @@ +name: Website + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + branches: + - main + +jobs: + update-audits: + name: Update audits + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: yarn + - name: Install + run: yarn install --immutable + - name: Build + run: yarn build:umd + - name: Inject + run: node scripts/inject-audits-website.mjs + - name: Diff + run: git diff --minimal + - name: Commit + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + [ -z "$(git status --porcelain)" ] \ + && echo "::notice::Audits didn't change." \ + || (git add . && git commit -m "chore(website): update audits [skip ci]" && git push) From 598503aa021eb9dbd96bcdb2a228bf4b217ecaf4 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 22:33:58 +0100 Subject: [PATCH 18/20] deploy through gh actions --- .github/workflows/website.yml | 47 +++++++++++++++++++++++------------ website/index.html | 5 +--- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index f3c0c72d..1d5642f5 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -3,15 +3,12 @@ name: Website on: push: branches: - - main - pull_request: - types: [opened, synchronize, reopened] - branches: - - main + # TODO: replace with "main" once ready + - website jobs: - update-audits: - name: Update audits + inject-audits: + name: Inject audits runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: @@ -28,12 +25,30 @@ jobs: run: yarn build:umd - name: Inject run: node scripts/inject-audits-website.mjs - - name: Diff - run: git diff --minimal - - name: Commit - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - [ -z "$(git status --porcelain)" ] \ - && echo "::notice::Audits didn't change." \ - || (git add . && git commit -m "chore(website): update audits [skip ci]" && git push) + - name: Upload + uses: actions/upload-pages-artifact@v1 + with: + path: website + + deploy: + name: Deploy + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + needs: [inject-audits] + permissions: + pages: write + id-token: write + concurrency: + group: website-deploy + cancel-in-progress: true + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up pages + uses: actions/configure-pages@v3 + - name: Deploy + id: deployment + uses: actions/deploy-pages@v1 diff --git a/website/index.html b/website/index.html index a00d5b74..88ec5053 100644 --- a/website/index.html +++ b/website/index.html @@ -85,10 +85,7 @@ - + From de8a0e1a157487add5c2ba1295b1f17f8b6f1ee6 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 22:36:42 +0100 Subject: [PATCH 19/20] descriptive name --- .github/workflows/website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 1d5642f5..eaad93d7 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -25,7 +25,7 @@ jobs: run: yarn build:umd - name: Inject run: node scripts/inject-audits-website.mjs - - name: Upload + - name: Upload website uses: actions/upload-pages-artifact@v1 with: path: website From ab087c384914eaaed742d6c5d5ce74fb37cc8abd Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 12 Feb 2023 22:39:58 +0100 Subject: [PATCH 20/20] deploy from main --- .github/workflows/website.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index eaad93d7..52865912 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -3,8 +3,7 @@ name: Website on: push: branches: - # TODO: replace with "main" once ready - - website + - main jobs: inject-audits: