diff --git a/.dockerignore b/.dockerignore index 9b69ad55..948d5f92 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,10 @@ +data/webpack.json +public +static/js +resources/ node_modules .git dist -*/target +crate/target +crate/pkg .cache diff --git a/.gitignore b/.gitignore index 79e92252..f2008e57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +data/webpack.json +public +static/js +resources/ dist/ .cache diff --git a/Dockerfile b/Dockerfile index 2ba356b6..24643ee2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,11 @@ FROM node # Install zopfli for a better gzip and sponge from moreutils RUN apt-get update && apt-get install -y moreutils zopfli && rm -rf /var/lib/apt/lists/* +RUN curl -O -L https://github.com/gohugoio/hugo/releases/download/v0.68.3/hugo_extended_0.68.3_Linux-64bit.deb && \ + dpkg -i hugo_extended_0.68.3_Linux-64bit.deb + # Install rust -RUN set -eux; curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +RUN set -eux; curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y && \ . ~/.cargo/env && \ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s @@ -25,13 +28,9 @@ COPY . . # modify the source as else parcel will derive the same hash when only the # /crate directory has been modified. RUN set -eux; . ~/.cargo/env && \ - ./assets/build-wasm.sh && \ - ./assets/asset-pipeline.sh rl_wasm_bg.wasm src/worker.ts && \ - ./assets/asset-pipeline.sh sample.replay src/components/LoadSample.tsx && \ npm run build && \ - rm dist/rl_wasm_bg.wasm dist/sample.replay && \ - zopfli dist/*.js dist/*.wasm dist/*.css dist/*.html dist/*.png + find public -iname "*.js" -o -iname "*.wasm" -o -iname "*.html" -o -iname "*.png" -o -iname "*.replay" | xargs zopfli FROM nginx:stable-alpine -COPY --from=0 /usr/src/rl-web/dist /usr/share/nginx/html -COPY assets/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=0 /usr/src/rl-web/public /usr/share/nginx/html +COPY dev/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/README.md b/README.md index a28b3988..dc79aacb 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ feature rich analysis of replays, see [calculated.gg](https://calculated.gg/) ## Screenshot -![Screenshot of web page](assets/rl-web-screenshot.png?raw=true) +![Screenshot of web page](dev/rl-web-screenshot.png?raw=true) ## Goals diff --git a/assets/asset-pipeline.sh b/assets/asset-pipeline.sh deleted file mode 100755 index f667e0de..00000000 --- a/assets/asset-pipeline.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -eu - -# Poor man's asset pipeline -FILE="$1" -FILE_EXT="${FILE##*.}" -FILE_NAME="${FILE%.*}" -SHA=$(sha1sum < "dist/$FILE" | cut -d' ' -f1) -NEW_FILE="$FILE_NAME-$SHA.$FILE_EXT" -mv "dist/$FILE" "dist/$NEW_FILE" -sed -i -e "s/$FILE/$NEW_FILE/g" "$2" diff --git a/assets/build-wasm.sh b/assets/build-wasm.sh deleted file mode 100755 index d52c2a28..00000000 --- a/assets/build-wasm.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -eu - -pushd crate -wasm-pack build --target web $@ -popd - -mkdir -p dist -cp crate/pkg/rl_wasm_bg.wasm dist/. -cp assets/3d07e.replay dist/sample.replay - -# Parcel doesn't support the experimental import feature -sed -i -e '/import.meta.url.replace/d' crate/pkg/rl_wasm.js diff --git a/src/styles.css b/assets/styles.scss similarity index 95% rename from src/styles.css rename to assets/styles.scss index 3830c6e4..b013b7ba 100644 --- a/src/styles.css +++ b/assets/styles.scss @@ -1,6 +1,6 @@ -@import url(sanitize.css); -@import url(sanitize.css/typography.css); -@import url(sanitize.css/forms.css); +@import "sanitize.css/sanitize"; +@import "sanitize.css/typography"; +@import "sanitize.css/forms"; :root { --rlBlue: #00179e; diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8b3d9bf6..80c6a3f2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,20 +7,22 @@ steps: displayName: Install rust - script: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh displayName: Install wasm-pack + - script: | + curl -O -L https://github.com/gohugoio/hugo/releases/download/v0.68.3/hugo_extended_0.68.3_Linux-64bit.deb + sudo dpkg -i hugo_extended_0.68.3_Linux-64bit.deb + displayName: Install hugo - script: npm ci displayName: Npm Install - - script: './assets/build-wasm.sh' - displayName: Build rust crate + - script: npm run build + displayName: Build app - script: 'wasm-pack test --node' workingDirectory: './crate' displayName: Test rust crate - - script: npm run type-check - displayName: Typescript check - script: npm run unit displayName: Unit Tests - script: npm test displayName: e2e tests - script: docker build . displayName: build docker image - - script: ./assets/wasm-size-check.sh + - script: ./dev/wasm-size-check.sh displayName: test wasm bundle size diff --git a/config.toml b/config.toml new file mode 100644 index 00000000..8a56ed33 --- /dev/null +++ b/config.toml @@ -0,0 +1 @@ +disableKinds = ["taxonomy", "taxonomyTerm", "RSS", "sitemap"] diff --git a/crate/tests/test.rs b/crate/tests/test.rs index d8529511..6b4c7248 100644 --- a/crate/tests/test.rs +++ b/crate/tests/test.rs @@ -1,7 +1,7 @@ use rl_wasm::*; use wasm_bindgen_test::*; -const REPLAY: &'static [u8] = include_bytes!("../../assets/3d07e.replay"); +const REPLAY: &'static [u8] = include_bytes!("../../dev/sample.replay"); #[wasm_bindgen_test] fn test_parse_header() { diff --git a/cypress/fixtures/3d07e.replay b/cypress/fixtures/3d07e.replay deleted file mode 120000 index 28cfce12..00000000 --- a/cypress/fixtures/3d07e.replay +++ /dev/null @@ -1 +0,0 @@ -../../assets/3d07e.replay \ No newline at end of file diff --git a/cypress/fixtures/no-stats.replay b/cypress/fixtures/no-stats.replay index da4aeaa6..4d96670b 120000 --- a/cypress/fixtures/no-stats.replay +++ b/cypress/fixtures/no-stats.replay @@ -1 +1 @@ -../../assets/no-stats.replay \ No newline at end of file +../../dev/no-stats.replay \ No newline at end of file diff --git a/cypress/fixtures/sample.replay b/cypress/fixtures/sample.replay new file mode 120000 index 00000000..03c694f8 --- /dev/null +++ b/cypress/fixtures/sample.replay @@ -0,0 +1 @@ +../../dev/sample.replay \ No newline at end of file diff --git a/cypress/integration/app_spec.js b/cypress/integration/app_spec.js index 12d4c46c..3832bfea 100644 --- a/cypress/integration/app_spec.js +++ b/cypress/integration/app_spec.js @@ -1,13 +1,13 @@ describe('RL web tests', function() { it('replay 3d07e', function() { - cy.visit("http://localhost:1234"); + cy.visit("http://localhost:1313"); cy.contains("Rocket League Replay Parser"); - cy.uploadFile("input[type=file]", '3d07e.replay'); + cy.uploadFile("input[type=file]", 'sample.replay'); cy.get('p.description').contains('On 12/8/2016, comagoosie, TheGoldenGarp, TrUeLiFe98 vs. Grim Reefer, Doomsayer2050, PUT YOUR WEIGHT ON IT in a 3v3 soccar match'); }) it('replay with no stats', function() { - cy.visit("http://localhost:1234"); + cy.visit("http://localhost:1313"); cy.contains("Rocket League Replay Parser"); cy.uploadFile("input[type=file]", 'no-stats.replay'); cy.get('p.error').contains('Replay successfully parsed but no stats extracted'); diff --git a/assets/nginx.conf b/dev/nginx.conf similarity index 100% rename from assets/nginx.conf rename to dev/nginx.conf diff --git a/assets/no-stats.replay b/dev/no-stats.replay similarity index 100% rename from assets/no-stats.replay rename to dev/no-stats.replay diff --git a/assets/rl-web-screenshot.png b/dev/rl-web-screenshot.png similarity index 100% rename from assets/rl-web-screenshot.png rename to dev/rl-web-screenshot.png diff --git a/assets/3d07e.replay b/dev/sample.replay similarity index 100% rename from assets/3d07e.replay rename to dev/sample.replay diff --git a/assets/wasm-size-check.sh b/dev/wasm-size-check.sh similarity index 68% rename from assets/wasm-size-check.sh rename to dev/wasm-size-check.sh index dc05ca53..04f4ec99 100755 --- a/assets/wasm-size-check.sh +++ b/dev/wasm-size-check.sh @@ -1,5 +1,5 @@ #!/bin/bash -bytes=$(docker run --rm -i "$(docker build -q .)" find /usr/share/nginx/html -iname rl_wasm_bg-*.wasm -exec wc -c {} \; | cut -d " " -f1) +bytes=$(docker run --rm -i "$(docker build -q .)" find /usr/share/nginx/html -iname *.wasm -exec wc -c {} \; | cut -d " " -f1) [[ $bytes -lt 1000 ]] && echo "wasm generated incorrectly" && exit 1 echo "done" diff --git a/src/index.html b/layouts/index.html similarity index 66% rename from src/index.html rename to layouts/index.html index 3863db7e..e7703ec3 100644 --- a/src/index.html +++ b/layouts/index.html @@ -5,11 +5,12 @@ - - - - - + {{ $opts := (dict "outputStyle" "compressed" "includePaths" (slice "node_modules")) }} + {{ $style := resources.Get "styles.scss" | toCSS $opts | fingerprint }} + + + + Rocket League Replay Parser @@ -35,6 +36,6 @@

Rocket League Replay Parser