Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(website): add initial website #1117

Merged
merged 40 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2f19731
add initial setup
jonaslagoni Jan 30, 2023
9ad1b62
wip
jonaslagoni Jan 31, 2023
854e477
wip
jonaslagoni Feb 1, 2023
ded6659
Merge branch 'master' into feature/add_modelina_website
jonaslagoni Feb 3, 2023
c83a535
wip
jonaslagoni Feb 3, 2023
5eff0b9
finished frontpage
jonaslagoni Feb 4, 2023
1d2760e
fixed playground
jonaslagoni Feb 4, 2023
f4fece5
fixed playground
jonaslagoni Feb 4, 2023
40ae0ec
fixed all linting problems
jonaslagoni Feb 4, 2023
a20ae3b
added netlify build
jonaslagoni Feb 5, 2023
142a485
added missing dependency
jonaslagoni Feb 5, 2023
ede61c5
fixed some typing issues
jonaslagoni Feb 5, 2023
4f6c277
exclude website from regular build
jonaslagoni Feb 5, 2023
dff0015
switched socket io out with regular REST
jonaslagoni Feb 5, 2023
5b2834e
Removed unused socket io files
jonaslagoni Feb 5, 2023
88d4616
updated netlify config
jonaslagoni Feb 5, 2023
94869b1
removed old netlify.toml
jonaslagoni Feb 5, 2023
e4e53bc
add edge function
jonaslagoni Feb 5, 2023
b893c8f
exclude netlify function from being build
jonaslagoni Feb 5, 2023
6d086f5
switched to netlify functions
jonaslagoni Feb 5, 2023
4d10fd5
changed function location
jonaslagoni Feb 5, 2023
0de666b
added docs
jonaslagoni Feb 5, 2023
bec95df
fixed path for api call in netlify
jonaslagoni Feb 5, 2023
71f2a01
update environment variable
jonaslagoni Feb 5, 2023
0aae773
Update environment variables
jonaslagoni Feb 5, 2023
0212426
fixed netlify.toml
jonaslagoni Feb 5, 2023
6588e51
stringify return body
jonaslagoni Feb 5, 2023
30529be
changed modelina page
jonaslagoni Feb 5, 2023
276b58e
Fixed workflows
jonaslagoni Feb 5, 2023
126f553
fixed pr testing workflow for website
jonaslagoni Feb 5, 2023
af1c70f
fixed linting
jonaslagoni Feb 5, 2023
42bbaf2
fixed query loading
jonaslagoni Feb 5, 2023
a9b7431
small changes
jonaslagoni Feb 5, 2023
f7363f6
Merge branch 'master' into feature/add_modelina_website
jonaslagoni Feb 13, 2023
2dcfcd6
Merge branch 'master' into feature/add_modelina_website
jonaslagoni Mar 9, 2023
2a04f7a
fixed build errors
jonaslagoni Mar 10, 2023
318a8cd
update netlify
jonaslagoni Mar 10, 2023
a7c03a2
update badge
jonaslagoni Mar 10, 2023
44913cc
fixed frontpage
jonaslagoni Mar 10, 2023
f2450a2
Merge branch 'master' into feature/add_modelina_website
jonaslagoni Mar 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ src/generators/template
test/generators/template
examples/integrate-with-react
src/processors/TemplateInputProcessor.ts
test/processors/TemplateInputProcessor.spec.ts
test/processors/TemplateInputProcessor.spec.ts
modelina-website
26 changes: 26 additions & 0 deletions .github/workflows/lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ci": {
"assert": {
"assertions": {
"categories:accessibility": [
"error",
{
"minScore": 0.70
}
]
}
},
"collect": {
"settings": {
"skipAudits": [
"robots-txt",
"canonical",
"tap-targets",
"is-crawlable",
"works-offline",
"offline-start-url"
]
}
}
}
}
17 changes: 17 additions & 0 deletions .github/workflows/website-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

name: Deploy to Netlify
on:
issues:
types: [opened, deleted, closed, reopened, labeled, unlabeled]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Trigger deploy on Netlify
run: |
curl -X POST "https://api.netlify.com/api/v1/sites/$NETLIFY_SITE_ID/builds" -H "Authorization: Bearer $NETLIFY_AUTH_TOKEN"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
108 changes: 108 additions & 0 deletions .github/workflows/website-pr-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Test website

on:
pull_request_target:
paths:
- 'modelina-website'
- 'netlify.toml'
branches:
- master
types: [opened, reopened, synchronize, ready_for_review]

jobs:
lighthouse-ci:
name: Lighthouse CI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: Modelina Core Install dependencies
id: first-installation-core
run: npm install --loglevel verbose
continue-on-error: true

- if: steps.first-installation-core.outputs.status == 'failure'
name: Modelina Core Clear NPM cache and install deps again
run: |
npm cache clean --force
npm install --loglevel verbose

- name: Build Modelina
run: npm run build:prod

- name: Modelina Website Install dependencies
id: first-installation-website
run: cd modelina-website && npm install --loglevel verbose
continue-on-error: true

- if: steps.first-installation-website.outputs.status == 'failure'
name: Modelina Website Clear NPM cache and install deps again
run: |
cd modelina-website && npm cache clean --force
cd modelina-website && npm install --loglevel verbose

- name: Lint Modelina website
run: cd modelina-website && npm run lint

- name: Build Modelina website
run: cd modelina-website && npm run build

- name: Await Netlify Preview
uses: jakepartusch/wait-for-netlify-action@v1
id: netlify
with:
site_name: modelina
max_timeout: 600

- name: Lighthouse Audit
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@9.3.0
with:
urls: |
https://deploy-preview-$PR_NUMBER--modelina.netlify.app/
configPath: ./.github/workflows/lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true
env:
PR_NUMBER: ${{ github.event.pull_request.number}}

- name: Lighthouse Score Report
id: lighthouse_score_report
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
const links = ${{ steps.lighthouse_audit.outputs.links }}
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
const comment = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
- name: LightHouse Statistic Comment
id: lighthouse_statistic_comment
uses: marocchino/sticky-pull-request-comment@v2.2.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.lighthouse_score_report.outputs.comment }}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib
node_modules
modelina-website
1 change: 1 addition & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Disable specific duplicate code since it would introduce more complexity to reduce it.
sonar.cpd.exclusions=src/generators/**/*.ts
sonar.exclusions=modelina-website/next.config.js
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![AsyncAPI Modelina](./docs/img/readme-banner.png)](https://www.asyncapi.com/tools/modelina)
[![AsyncAPI Modelina](./docs/img/readme-banner.png)](https://www.modelina.org)
[![blackbox pipeline status](<https://img.shields.io/github/actions/workflow/status/asyncapi/modelina/blackbox-testing.yml?label=blackbox%20testing>)](https://github.com/asyncapi/modelina/actions/workflows/blackbox-testing.yml?query=branch%3Amaster++)
[![Coverage Status](https://coveralls.io/repos/github/asyncapi/modelina/badge.svg?branch=master)](https://coveralls.io/github/asyncapi/modelina?branch=master)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
Expand All @@ -7,7 +7,8 @@
[![License](https://img.shields.io/github/license/asyncapi/modelina)](https://github.com/asyncapi/modelina/blob/master/LICENSE)
[![last commit](https://img.shields.io/github/last-commit/asyncapi/modelina)](https://github.com/asyncapi/modelina/commits/master)
[![Discussions](https://img.shields.io/github/discussions/asyncapi/modelina)](https://github.com/asyncapi/modelina/discussions)
[![Playground](https://img.shields.io/website?label=playground&url=https%3A%2F%2Fwww.asyncapi.com%2Ftools%2Fmodelina)](https://www.asyncapi.com/tools/modelina) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![Website](https://img.shields.io/website?label=website&url=https%3A%2F%2Fwww.modelina.org)](https://www.modelina.org)
[![Playground](https://img.shields.io/website?label=playground&url=https%3A%2F%2Fwww.modelina.org%2Fplayground)](https://www.modelina.org/playground) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-43-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Expand Down
1 change: 1 addition & 0 deletions modelina-website/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_PATH=/api
2 changes: 2 additions & 0 deletions modelina-website/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.next
12 changes: 12 additions & 0 deletions modelina-website/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": [
"../.eslintrc",
"next"
],
"rules": {
"@typescript-eslint/no-empty-interface": "off",
"no-console": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
3 changes: 3 additions & 0 deletions modelina-website/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
37 changes: 37 additions & 0 deletions modelina-website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local
!.env.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
19 changes: 19 additions & 0 deletions modelina-website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Modelina Website

This website is a `Next` + TypeScript website.

The website is being deployed to Netlify along side serverless functions.

## How to run it
It uses the local version of Modelina, which means that before you run the website, make sure you build Modelina through `npm run build:modelina`.

## Playground

Here is a quick overview of where some of the functions for rendering the playground work:

- `/src/helpers/GeneratorCode` contains all the functions for creating the generator code, shown instead of the options.
- `/src/pages/api/functions` contain all the individual generators that when the frontend calls the API `/api/generate` will perform the code generation with Modelina.
- `src/components/playground/PlaygroundOptions.tsx` is the main component that renders the options based on which output is selected.
- `src/components/playground/options` contain all the individual react components for showing the output options.
- `src/components/playground/Playground.tsx` is the main playground component, and is the one rendered by the playground page.
- `src/components/playground/GeneratedModels.tsx` is the playground component responsible for rendering the generated models.
18 changes: 18 additions & 0 deletions modelina-website/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const isGithubActions = process.env.GITHUB_ACTIONS || false;

let assetPrefix = '/';
let basePath = '';

if (isGithubActions) {
const repo = process.env.GITHUB_REPOSITORY.replace(/.*?\//, '');
assetPrefix = `/${repo}/`;
basePath = `/${repo}`;
}

/** @type {import('next').NextConfig} */
const nextConfig = {
assetPrefix: assetPrefix,
basePath: basePath
}

module.exports = nextConfig
Loading