Skip to content

Commit

Permalink
Demo Website (#263)
Browse files Browse the repository at this point in the history
* TeaVM related changes. Allows salvation to be compiled to JS instead of having to run a server

* Add main class needed for TeaVM

* fix indentation

* expose functions on window so they're individually callable

* Can't use named capturing groups. Seems like it doesn't work when it's transpiled

* output a string for the JS to consume

* use integers for matching since teavm doesn't support strings

* checkstyle fixes

* update readme and specify a filename for the js output

* remove comments

* abstract regex out to its own variable

* function renaming

* add js test and ci job

* don't run the build for java8

* applying comment suggestions

* fix ci command

* rearrange ci job so java build doesn't need to happen twice

* add demo site to be published via GH pages

* specify working directory

* update readme stating that the js file needs to be manually copied.
  • Loading branch information
rosstroha authored Jul 17, 2024
1 parent 2c4d7c9 commit cf6fc9d
Show file tree
Hide file tree
Showing 29 changed files with 14,347 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@ jobs:
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
mvn test -B
- run: node --test
docs-lint:
if: |
!cancelled() && !failure()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
working-directory: ./docs
run: npm install
- name: Lint
working-directory: ./docs
run: npm run lint

26 changes: 26 additions & 0 deletions .github/workflows/demo-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and Deploy Demo Site
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Install and Build 🔧
run: |
npm install
npm run build
deploy:
if: |
!cancelled() && !failure()
needs: build
steps:
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs/public
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ cert.pem
*.classpath
*.project
*.settings

dist
.vscode
docs/public
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ To reduce the overhead of running this library, it will now automatically be tra

The transpiled code will be placed in `target/javascript` as `salvation-v${project.version}.min.js`.

If you experience errors relating to TeaVM transpiling, check the [supported TeaVM classes](https://teavm.org/jcl-report/recent/jcl.html).
If you experience errors relating to TeaVM transpiling, check the [supported TeaVM classes](https://teavm.org/jcl-report/recent/jcl.html).

### Using the JavaScript

Expand Down
6 changes: 6 additions & 0 deletions docs/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
logs
deployment
static
public
159 changes: 159 additions & 0 deletions docs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
'use strict';
const { defineConfig } = require('eslint-define-config');

module.exports = defineConfig({
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
],
env: {
browser: true,
es2021: true,
node: true,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
reportUnusedDisableDirectives: true,
root: true,
rules: {
'array-element-newline': ['error', 'consistent'],
'arrow-body-style': 'error',
'array-bracket-spacing': ['error', 'never'],
'arrow-parens': ['error', 'as-needed'],
'brace-style': ['error', '1tbs'],
'camelcase': 'error',
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': ['error', { before: false, after: true }],
'comma-style': ['error', 'last'],
'computed-property-spacing': ['error', 'never'],
'consistent-return': 'error',
'curly': ['error', 'multi-line'],
'dot-notation': 'error',
'eol-last': 'error',
'eqeqeq': ['error', 'smart'],
'func-call-spacing': 'error',
'guard-for-in': 'error',
'indent': [
'error',
2,
{
SwitchCase: 1,
VariableDeclarator: {
var: 2,
let: 2,
const: 3,
},
},
],
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true,
},
],
'keyword-spacing': 'error',
'max-statements-per-line': 'error',
'no-alert': 'error',
'no-caller': 'error',
'no-else-return': 'error',
'no-empty': [
'error',
{
allowEmptyCatch: true,
},
],
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-floating-decimal': 'error',
'no-implied-eval': 'error',
'no-inner-declarations': ['error', 'both'],
'no-lonely-if': 'error',
'no-loop-func': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': [
'error',
{
max: 2,
},
],
'no-param-reassign': 'warn',

'no-return-assign': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-shadow': ['error', { builtinGlobals: true }],
'no-trailing-spaces': 'error',
'no-undefined': 'error',
'no-unused-expressions': 'error',
'no-unused-vars': ['error', { vars: 'all', args: 'after-used' }],
'no-use-before-define': ['error', 'nofunc'],
'no-useless-call': 'error',
'no-var': 'error',
'no-with': 'error',
'object-curly-spacing': ['error', 'always'],
'object-property-newline': [
'error',
{
allowAllPropertiesOnSameLine: true,
},
],
'object-shorthand': ['error', 'always'],
'prefer-arrow-callback': ['error'],
'quotes': ['error', 'single', { avoidEscape: true }],
'semi': ['error', 'always'],
'semi-spacing': [
'error',
{
before: false,
after: true,
},
],
'space-before-blocks': 'error',
'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }],
'space-in-parens': 'error',
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': [
'warn',
'always',
{
block: {
markers: ['!'],
exceptions: ['*'],
},
line: {
markers: ['/'],
},
},
],
'wrap-iife': ['error', 'inside'],
'yoda': ['error', 'never'],
},
settings: {
react: {
version: 'detect',
},
},
overrides: [
{
files: ['*.js', '*.jsx'],
},
{
files: [
'webpack.config.js',
'.eslintrc.js',
],
env: {
node: true,
},
},
],
});
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Installation
```sh
npm install
```

## Development Build
```sh
npm run dev
```

## Production Build
```sh
npm run build
```

# Note on salvation.min.js

This comes from [Salvation](https://github.com/shapesecurity/salvation). It is automatically generated at compile time using [TeaVM](https://teavm.org/docs/intro/getting-started.html). And needs to be manually copied to `docs/static/`.

To update the version of Salvation used in this demo website, follow the instructions provided in the README located at the root of this repo. Copy the generated file to `docs/static/`, then rename it to `salvation.min.js`.
22 changes: 22 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
presets: [
'@babel/preset-env',
['@babel/preset-react', {
runtime: 'automatic',
development: process.env.NODE_ENV === 'development',
}],
],
targets: {
browsers: '> 0.5%, last 10 versions',
},
plugins: [
'@babel/plugin-transform-runtime',
[
'@babel/plugin-transform-react-jsx',
{
runtime: 'automatic',
importSource: 'preact',
},
],
],
};
Loading

0 comments on commit cf6fc9d

Please sign in to comment.