Skip to content

Commit

Permalink
adding www boilerplate in preperation of migrating the kernel syllabus
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkernel committed Jun 1, 2022
1 parent 1542c0a commit 012c693
Show file tree
Hide file tree
Showing 33 changed files with 1,313 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/www/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
REACT_APP_DEPLOY_TARGET="STAGING"
REACT_APP_AUTH_ENDPOINT_DEV="http://localhost:3001/auth/rpc"
REACT_APP_AUTH_ENDPOINT_STAGING="https://staging.services.kernel.community/auth/rpc"
REACT_APP_AUTH_URL_DEV="http://localhost:3003/auth"
REACT_APP_AUTH_URL_STAGING="https://staging.wallet.kernel.community/auth"
REACT_APP_STORAGE_ENDPOINT_DEV="http://localhost:3001/storage/rpc"
REACT_APP_STORAGE_ENDPOINT_STAGING="https://staging.services.kernel.community/storage/rpc"
6 changes: 6 additions & 0 deletions packages/www/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
REACT_APP_AUTH_ENDPOINT_PROD="https://services.kernel.community/auth/rpc"
REACT_APP_AUTH_URL_PROD="https://wallet.kernel.community/auth"
REACT_APP_STORAGE_ENDPOINT_PROD="https://services.kernel.community/storage/rpc"
REACT_APP_AUTH_ENDPOINT_STAGING="https://staging.services.kernel.community/auth/rpc"
REACT_APP_AUTH_URL_STAGING="https://staging.wallet.kernel.community/auth"
REACT_APP_STORAGE_ENDPOINT_STAGING="https://staging.services.kernel.community/storage/rpc"
22 changes: 22 additions & 0 deletions packages/www/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const path = require('path')
const { getLoader, loaderByName } = require('@craco/craco')
const absolutePath = path.join(__dirname, '../common')
module.exports = {
webpack: {
alias: {},
plugins: [],
configure: (webpackConfig, { env, paths }) => {
const { isFound, match } = getLoader(
webpackConfig,
loaderByName('babel-loader')
)
if (isFound) {
const include = Array.isArray(match.loader.include)
? match.loader.include
: [match.loader.include]
match.loader.include = include.concat[absolutePath]
}
return webpackConfig
}
}
}
17 changes: 17 additions & 0 deletions packages/www/dist/.gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Node.js dependencies:
node_modules/
42 changes: 42 additions & 0 deletions packages/www/dist/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) Kernel

runtime: nodejs16
instance_class: F1
automatic_scaling:
max_instances: 1

handlers:
- url: /static/(.+)
static_files: build/static/\1
upload: build/static/(.*)

- url: /(manifest.json)
static_files: build/\1
upload: build/(.*)

- url: /(asset-manifest.json)
static_files: build/\1
upload: build/(.*)

- url: /(robots.txt)
static_files: build/\1
upload: build/(.*)

- url: /(icon-192x192.png)
static_files: build/\1
upload: build/(.*)

- url: /(icon-512x512.png)
static_files: build/\1
upload: build/(.*)

- url: /health
secure: always
redirect_http_response_code: 301
script: auto

- url: /(.*)
secure: always
redirect_http_response_code: 301
static_files: build/index.html
upload: build/index.html
6 changes: 6 additions & 0 deletions packages/www/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
83 changes: 83 additions & 0 deletions packages/www/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"name": "@kernel/www",
"version": "0.1.0",
"homepage": "https://www.kernel.community",
"private": true,
"workspaces": {
"nohoist": [
"@mdx-js/mdx/**",
"**/@mdx-js/mdx",
"**/@mdx-js/mdx/**",
"micromark-extension-mdxjs",
"micromark-extension-mdxjs/**",
"**/micromark-extension-mdxjs",
"**/micromark-extension-mdxjs/**"
]
},
"dependencies": {
"@craco/craco": "^6.4.3",
"@fortawesome/fontawesome-free": "^6.1.0",
"@kernel/common": "^0.0.1",
"@mdx-js/mdx": "^2.1.1",
"@mdx-js/react": "^2.1.1",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"ethers": "5.6.8",
"mdx-embed": "^1.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"remark-breaks": "^3.0.2",
"remark-emoji": "^3.0.2",
"remark-gfm": "^3.0.1",
"sass": "^1.50.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "craco start",
"build": "BUILD_PATH='./dist/build' craco build",
"upgrade": "yarn upgrade",
"test": "craco test",
"lint": "npx standard",
"format": "npx standard --fix",
"deploy:staging": "gcloud app deploy dist/app.yaml --project kernel-www-staging",
"eject": "craco eject"
},
"standard": {
"ignore": [
"dist/*"
],
"env": [
"jest",
"es6",
"browser"
]
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.0",
"autoprefixer": "^10.4.4",
"postcss": "^8.4.12",
"standard": "^17.0.0",
"tailwindcss": "^3.0.23"
}
}
6 changes: 6 additions & 0 deletions packages/www/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
}
Binary file added packages/www/public/favicon.ico
Binary file not shown.
Binary file added packages/www/public/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/www/public/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions packages/www/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Kernel" />
<link rel="apple-touch-icon" sizes="192x192" href="%PUBLIC_URL%/icon-192x192.png" />
<link rel="apple-touch-icon" sizes="512x512" href="%PUBLIC_URL%/icon-512x512.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Kernel Community</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
20 changes: 20 additions & 0 deletions packages/www/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"short_name": "Wallet",
"name": "Kernel Wallet",
"icons": [
{
"src": "icon-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "icon-512x512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions packages/www/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
18 changes: 18 additions & 0 deletions packages/www/src/App.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"appTitle": "Kernel Community",
"logoUrl": "/icon-192x192.png",
"homeUrl": "/browse",
"minRole": 1000,
"navbar": {
"links": [
{
"url": "/browse",
"title": "Browse"
},
{
"url": "/create",
"title": "Create"
}
]
}
}
38 changes: 38 additions & 0 deletions packages/www/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
40 changes: 40 additions & 0 deletions packages/www/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) Kernel
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import React, { Suspense, lazy } from 'react'
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom'
import { ServicesProvider, Loading } from '@kernel/common'

import 'App.css'

const Login = lazy(() => import('views/Login'))
const Create = lazy(() => import('views/Create'))
const Edit = lazy(() => import('views/Edit'))
const Browse = lazy(() => import('views/Browse'))
const View = lazy(() => import('views/View'))

const App = () => {
return (
<BrowserRouter basename={process.env.PUBLIC_URL}>
<ServicesProvider>
<Suspense fallback={<Loading />}>
<Routes>
<Route path='/' element={<Login />} />
<Route path='/browse' element={<Browse />} />
<Route path='/create' element={<Create />} />
<Route path='/edit/' element={<Navigate to='/browse' />} />
<Route path='/edit/:module' element={<Edit />} />
<Route path='/view/:module' element={<View />} />
</Routes>
</Suspense>
</ServicesProvider>
</BrowserRouter>
)
}

export default App
6 changes: 6 additions & 0 deletions packages/www/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { render } from '@testing-library/react'
import App from './App'

it('renders without crashing', () => {
render(<App />)
})
Binary file added packages/www/src/assets/images/admin_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/www/src/assets/images/kernel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 012c693

Please sign in to comment.