From f703b2bd799e969bd703078ecb0bfffe4f6c136b Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 14:55:09 +0800 Subject: [PATCH 01/15] Update Dockerfile for TypeScript --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5e8c5692..2b21f5a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,9 @@ RUN npm ci --omit=dev # Install Playwright browsers RUN npx playwright install chromium webkit +# Compile TypeScript +RUN npm run build + # Add non-privileged user RUN addgroup -S purple && adduser -S -G purple purple RUN chown -R purple:purple ./ From 39dff552637a533aa335c0ab86b573e8ce75cbe6 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 15:15:56 +0800 Subject: [PATCH 02/15] Update Dockerfile not to omit devDependencies --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2b21f5a7..91555e50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,7 @@ ENV PLAYWRIGHT_BROWSERS_PATH="/opt/ms-playwright" ENV PATH="/opt/verapdf:${PATH}" # Install dependencies -RUN npm ci --omit=dev +RUN npm install # Install Playwright browsers RUN npx playwright install chromium webkit From 47c055a91ffe8e49941465ba34456b52ce944589 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 15:23:29 +0800 Subject: [PATCH 03/15] Print folder contents --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 91555e50..0a1e5d7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,9 @@ RUN npm install # Install Playwright browsers RUN npx playwright install chromium webkit +# Temp: Print folder contents +RUN ls -al + # Compile TypeScript RUN npm run build From e0d9655b4e1b64d6df13fb6bb15c917d8f5565f0 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 15:37:44 +0800 Subject: [PATCH 04/15] Move TypeScript command to last step --- Dockerfile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a1e5d7c..f391fa42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,17 +41,11 @@ ENV PLAYWRIGHT_BROWSERS_PATH="/opt/ms-playwright" ENV PATH="/opt/verapdf:${PATH}" # Install dependencies -RUN npm install +RUN npm ci --omit=dev # Install Playwright browsers RUN npx playwright install chromium webkit -# Temp: Print folder contents -RUN ls -al - -# Compile TypeScript -RUN npm run build - # Add non-privileged user RUN addgroup -S purple && adduser -S -G purple purple RUN chown -R purple:purple ./ @@ -61,3 +55,6 @@ USER purple # Copy application and support files COPY . . + +# Compile TypeScript +RUN npm run build From b91e62a1e7db9fd12e09d17f9a1e50625cab1093 Mon Sep 17 00:00:00 2001 From: younglim Date: Tue, 4 Jun 2024 15:41:52 +0800 Subject: [PATCH 05/15] Move TypeScript as deps --- package-lock.json | 5 ++--- package.json | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 259c290d..a29e0d42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "prettier": "^3.1.0", "print-message": "^3.0.1", "safe-regex": "^2.1.1", + "typescript": "^5.4.5", "validator": "^13.11.0", "which": "^4.0.0", "winston": "^3.11.0", @@ -43,8 +44,7 @@ "eslint-plugin-import": "^2.27.4", "eslint-plugin-prettier": "^5.0.0", "globals": "^15.2.0", - "jest": "^29.3.1", - "typescript": "^5.4.5" + "jest": "^29.3.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -8864,7 +8864,6 @@ "version": "5.4.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 803940be..13c17119 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "prettier": "^3.1.0", "print-message": "^3.0.1", "safe-regex": "^2.1.1", + "typescript": "^5.4.5", "validator": "^13.11.0", "which": "^4.0.0", "winston": "^3.11.0", @@ -41,8 +42,7 @@ "eslint-plugin-import": "^2.27.4", "eslint-plugin-prettier": "^5.0.0", "globals": "^15.2.0", - "jest": "^29.3.1", - "typescript": "^5.4.5" + "jest": "^29.3.1" }, "overrides": { "node-fetch": "^2.3.0", From a55b878d944b9c33ec9bf486587ae591bf007802 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 15:47:37 +0800 Subject: [PATCH 06/15] Force exit code 0 temporarily --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f391fa42..0e2b8706 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,4 +57,4 @@ USER purple COPY . . # Compile TypeScript -RUN npm run build +RUN npm run build || true # true exits with code 0 - temp workaround until errors are resolved From fce90c6282eed816e919c5b83feb62171c4f03b6 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 15:53:12 +0800 Subject: [PATCH 07/15] Update docker-test.yml to run npm cli --- .github/workflows/docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index f7b07933..0cdc8782 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -26,7 +26,7 @@ jobs: - name: Run Node CLI command inside the Docker container run: | # Execute a webisite crawl - docker exec purple-hats-container node cli -u "${{ vars.A11Y_SCAN_URL }}" -c 2 -p "${{ vars.A11Y_SCAN_MAX_NUM_PAGES }}" -t "${{ vars.A11Y_SCAN_MAX_CONCURRENCY }}" -k "${{ github.actor }}:${{ github.actor }}@users.noreply.github.com" -b chromium || true + docker exec purple-hats-container npm run cli -- -u "${{ vars.A11Y_SCAN_URL }}" -c 2 -p "${{ vars.A11Y_SCAN_MAX_NUM_PAGES }}" -t "${{ vars.A11Y_SCAN_MAX_CONCURRENCY }}" -k "${{ github.actor }}:${{ github.actor }}@users.noreply.github.com" -b chromium || true - name: Print errors run: | From 088635f5aaa3c7117f6d6ca361a47be144568c97 Mon Sep 17 00:00:00 2001 From: younglim Date: Tue, 4 Jun 2024 16:31:09 +0800 Subject: [PATCH 08/15] Rename setup scripts --- {src/scripts => scripts}/a11y_shell.cmd | 0 {src/scripts => scripts}/a11y_shell.command | 0 {src/scripts => scripts}/a11y_shell.sh | 0 {src/scripts => scripts}/a11y_shell_ps.ps1 | 0 {src/scripts => scripts}/install_purple_dependencies.cmd | 0 {src/scripts => scripts}/install_purple_dependencies.command | 0 {src/scripts => scripts}/install_purple_dependencies.ps1 | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {src/scripts => scripts}/a11y_shell.cmd (100%) rename {src/scripts => scripts}/a11y_shell.command (100%) rename {src/scripts => scripts}/a11y_shell.sh (100%) rename {src/scripts => scripts}/a11y_shell_ps.ps1 (100%) rename {src/scripts => scripts}/install_purple_dependencies.cmd (100%) rename {src/scripts => scripts}/install_purple_dependencies.command (100%) rename {src/scripts => scripts}/install_purple_dependencies.ps1 (100%) diff --git a/src/scripts/a11y_shell.cmd b/scripts/a11y_shell.cmd similarity index 100% rename from src/scripts/a11y_shell.cmd rename to scripts/a11y_shell.cmd diff --git a/src/scripts/a11y_shell.command b/scripts/a11y_shell.command similarity index 100% rename from src/scripts/a11y_shell.command rename to scripts/a11y_shell.command diff --git a/src/scripts/a11y_shell.sh b/scripts/a11y_shell.sh similarity index 100% rename from src/scripts/a11y_shell.sh rename to scripts/a11y_shell.sh diff --git a/src/scripts/a11y_shell_ps.ps1 b/scripts/a11y_shell_ps.ps1 similarity index 100% rename from src/scripts/a11y_shell_ps.ps1 rename to scripts/a11y_shell_ps.ps1 diff --git a/src/scripts/install_purple_dependencies.cmd b/scripts/install_purple_dependencies.cmd similarity index 100% rename from src/scripts/install_purple_dependencies.cmd rename to scripts/install_purple_dependencies.cmd diff --git a/src/scripts/install_purple_dependencies.command b/scripts/install_purple_dependencies.command similarity index 100% rename from src/scripts/install_purple_dependencies.command rename to scripts/install_purple_dependencies.command diff --git a/src/scripts/install_purple_dependencies.ps1 b/scripts/install_purple_dependencies.ps1 similarity index 100% rename from src/scripts/install_purple_dependencies.ps1 rename to scripts/install_purple_dependencies.ps1 From ccdf09ecf97edc107197709583d5ae3f5e023795 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 16:37:15 +0800 Subject: [PATCH 09/15] Update run command --- .github/workflows/docker-test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 0cdc8782..54b3df7b 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -16,27 +16,27 @@ jobs: - name: Build and run Docker container run: | - # Build your Docker image (replace 'purple-hats' and 'Dockerfile' with your image name and Dockerfile path) - docker build -t purple-hats . + # Build your Docker image (replace 'purple-a11y' and 'Dockerfile' with your image name and Dockerfile path) + docker build -t purple-a11y . # Run the Docker container (adjust any options as needed) - docker run -dit --name purple-hats-container purple-hats + docker run -dit --name purple-a11y-container purple-a11y # Ensure the Docker container is running before running the next step continue-on-error: true - name: Run Node CLI command inside the Docker container run: | # Execute a webisite crawl - docker exec purple-hats-container npm run cli -- -u "${{ vars.A11Y_SCAN_URL }}" -c 2 -p "${{ vars.A11Y_SCAN_MAX_NUM_PAGES }}" -t "${{ vars.A11Y_SCAN_MAX_CONCURRENCY }}" -k "${{ github.actor }}:${{ github.actor }}@users.noreply.github.com" -b chromium || true + docker exec purple-a11y-container npm run cli -- -u "${{ vars.A11Y_SCAN_URL }}" -c 2 -p "${{ vars.A11Y_SCAN_MAX_NUM_PAGES }}" -t "${{ vars.A11Y_SCAN_MAX_CONCURRENCY }}" -k "${{ github.actor }}:${{ github.actor }}@users.noreply.github.com" -b chromium || true - name: Print errors run: | - docker exec purple-hats-container cat errors.txt || true + docker exec purple-a11y-container cat errors.txt || true - name: Print logs run: | - docker exec purple-hats-container cat logs/*/*.txt || true + docker exec purple-a11y-container cat logs/*/*.txt || true - name: Copy Results from Docker Container - run: docker cp purple-hats-container:/app/results ./results + run: docker cp purple-a11y-container:/app/results ./results - name: Zip Results run: zip -r results.zip ./results @@ -50,5 +50,5 @@ jobs: - name: Cleanup Docker container run: | # Stop and remove the Docker container - docker stop purple-hats-container - docker rm purple-hats-container + docker stop purple-a11y-container + docker rm purple-a11y-container From 8ae8ccb81820fcc12125dcd0682f26a69161f5a2 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 16:39:43 +0800 Subject: [PATCH 10/15] Build TypeScript --- scripts/install_purple_dependencies.command | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install_purple_dependencies.command b/scripts/install_purple_dependencies.command index d4ec36a5..31671bca 100755 --- a/scripts/install_purple_dependencies.command +++ b/scripts/install_purple_dependencies.command @@ -86,3 +86,6 @@ fi echo "Installing Node dependencies to $PWD" npm ci + +echo "Build TypeScript" +npm run build From 4e1d006a77ae6a1c5c204b8ab887f463cfca3b8c Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 16:42:00 +0800 Subject: [PATCH 11/15] Exit with code 0 --- scripts/install_purple_dependencies.command | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_purple_dependencies.command b/scripts/install_purple_dependencies.command index 31671bca..1ded7372 100755 --- a/scripts/install_purple_dependencies.command +++ b/scripts/install_purple_dependencies.command @@ -88,4 +88,4 @@ echo "Installing Node dependencies to $PWD" npm ci echo "Build TypeScript" -npm run build +npm run build || true From 19b77ff14166d823e7f27d6793881ce2337d3ec2 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 20:08:15 +0800 Subject: [PATCH 12/15] Update with npm build --- scripts/install_purple_dependencies.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/install_purple_dependencies.ps1 b/scripts/install_purple_dependencies.ps1 index 579b3e15..15214d1d 100644 --- a/scripts/install_purple_dependencies.ps1 +++ b/scripts/install_purple_dependencies.ps1 @@ -84,11 +84,18 @@ if (Test-Path purple-a11y) { Write-Output "Install Playwright browsers" & "npx playwright install chromium" - + if (Test-Path .git) { Write-Output "Unhide .git folder" attrib -s -h .git } + + try { + Write-Output "Building Typescript" + npm run build + } catch { + Write-Output "Build with some errors but continuing" + } } else { Write-Output "Could not find purple-a11y" From 8cb2c1e447abedbc372dc1eaacb9c559a28416fd Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 20:27:07 +0800 Subject: [PATCH 13/15] Restore verapdf-auto-install-macos.xml --- scripts/verapdf-auto-install-macos.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scripts/verapdf-auto-install-macos.xml diff --git a/scripts/verapdf-auto-install-macos.xml b/scripts/verapdf-auto-install-macos.xml new file mode 100644 index 00000000..41dc97db --- /dev/null +++ b/scripts/verapdf-auto-install-macos.xml @@ -0,0 +1,16 @@ + + + + + /tmp/verapdf + + + + + + + + + + + From 902341f2b27dd837b36f7dd0535adffa70e25610 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 20:27:59 +0800 Subject: [PATCH 14/15] Restore verapdf-auto-install-windows.xml --- scripts/verapdf-auto-install-windows.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scripts/verapdf-auto-install-windows.xml diff --git a/scripts/verapdf-auto-install-windows.xml b/scripts/verapdf-auto-install-windows.xml new file mode 100644 index 00000000..e0aebeab --- /dev/null +++ b/scripts/verapdf-auto-install-windows.xml @@ -0,0 +1,16 @@ + + + + + C:\Windows\Temp\verapdf + + + + + + + + + + + From aaa06974447fd8130a814df258df5408d756c6e8 Mon Sep 17 00:00:00 2001 From: Zui Young Date: Tue, 4 Jun 2024 20:56:49 +0800 Subject: [PATCH 15/15] Update npm run build --- scripts/install_purple_dependencies.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/install_purple_dependencies.ps1 b/scripts/install_purple_dependencies.ps1 index 15214d1d..40c22115 100644 --- a/scripts/install_purple_dependencies.ps1 +++ b/scripts/install_purple_dependencies.ps1 @@ -70,6 +70,12 @@ if (Test-Path purple-a11y) { # Write-Output "Install Playwright browsers" # & ".\a11y_shell_ps.ps1" "npx playwright install chromium" + try { + Write-Output "Building Typescript" + & ".\a11y_shell_ps.ps1" "cd purple-a11y;npm run build" + } catch { + Write-Output "Build with some errors but continuing" + } if (Test-Path purple-a11y\.git) { Write-Output "Unhide .git folder" attrib -s -h purple-a11y\.git