@govtechsg/oobee 0.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.dockerignore +22 -0
  2. package/.github/pull_request_template.md +11 -0
  3. package/.github/workflows/docker-test.yml +54 -0
  4. package/.github/workflows/image.yml +107 -0
  5. package/.github/workflows/publish.yml +18 -0
  6. package/.idea/modules.xml +8 -0
  7. package/.idea/purple-a11y.iml +9 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/.prettierrc.json +12 -0
  10. package/.vscode/extensions.json +5 -0
  11. package/.vscode/settings.json +10 -0
  12. package/CODE_OF_CONDUCT.md +128 -0
  13. package/DETAILS.md +163 -0
  14. package/Dockerfile +60 -0
  15. package/INSTALLATION.md +146 -0
  16. package/INTEGRATION.md +785 -0
  17. package/LICENSE +22 -0
  18. package/README.md +587 -0
  19. package/SECURITY.md +5 -0
  20. package/__mocks__/mock-report.html +1431 -0
  21. package/__mocks__/mockFunctions.ts +32 -0
  22. package/__mocks__/mockIssues.ts +64 -0
  23. package/__mocks__/mock_all_issues/000000001.json +64 -0
  24. package/__mocks__/mock_all_issues/000000002.json +53 -0
  25. package/__mocks__/mock_all_issues/fake-file.txt +0 -0
  26. package/__tests__/logs.test.ts +25 -0
  27. package/__tests__/mergeAxeResults.test.ts +278 -0
  28. package/__tests__/utils.test.ts +118 -0
  29. package/a11y-scan-results.zip +0 -0
  30. package/eslint.config.js +53 -0
  31. package/exclusions.txt +2 -0
  32. package/gitlab-pipeline-template.yml +54 -0
  33. package/jest.config.js +1 -0
  34. package/package.json +96 -0
  35. package/scripts/copyFiles.js +44 -0
  36. package/scripts/install_oobee_dependencies.cmd +13 -0
  37. package/scripts/install_oobee_dependencies.command +101 -0
  38. package/scripts/install_oobee_dependencies.ps1 +110 -0
  39. package/scripts/oobee_shell.cmd +13 -0
  40. package/scripts/oobee_shell.command +11 -0
  41. package/scripts/oobee_shell.sh +55 -0
  42. package/scripts/oobee_shell_ps.ps1 +54 -0
  43. package/src/cli.ts +401 -0
  44. package/src/combine.ts +240 -0
  45. package/src/constants/__tests__/common.test.ts +44 -0
  46. package/src/constants/cliFunctions.ts +305 -0
  47. package/src/constants/common.ts +1840 -0
  48. package/src/constants/constants.ts +443 -0
  49. package/src/constants/errorMeta.json +319 -0
  50. package/src/constants/itemTypeDescription.ts +11 -0
  51. package/src/constants/oobeeAi.ts +141 -0
  52. package/src/constants/questions.ts +181 -0
  53. package/src/constants/sampleData.ts +187 -0
  54. package/src/crawlers/__tests__/commonCrawlerFunc.test.ts +51 -0
  55. package/src/crawlers/commonCrawlerFunc.ts +656 -0
  56. package/src/crawlers/crawlDomain.ts +877 -0
  57. package/src/crawlers/crawlIntelligentSitemap.ts +156 -0
  58. package/src/crawlers/crawlLocalFile.ts +193 -0
  59. package/src/crawlers/crawlSitemap.ts +356 -0
  60. package/src/crawlers/custom/extractAndGradeText.ts +57 -0
  61. package/src/crawlers/custom/flagUnlabelledClickableElements.ts +964 -0
  62. package/src/crawlers/custom/utils.ts +486 -0
  63. package/src/crawlers/customAxeFunctions.ts +82 -0
  64. package/src/crawlers/pdfScanFunc.ts +468 -0
  65. package/src/crawlers/runCustom.ts +117 -0
  66. package/src/index.ts +173 -0
  67. package/src/logs.ts +66 -0
  68. package/src/mergeAxeResults.ts +964 -0
  69. package/src/npmIndex.ts +284 -0
  70. package/src/screenshotFunc/htmlScreenshotFunc.ts +411 -0
  71. package/src/screenshotFunc/pdfScreenshotFunc.ts +762 -0
  72. package/src/static/ejs/partials/components/categorySelector.ejs +4 -0
  73. package/src/static/ejs/partials/components/categorySelectorDropdown.ejs +57 -0
  74. package/src/static/ejs/partials/components/pagesScannedModal.ejs +70 -0
  75. package/src/static/ejs/partials/components/reportSearch.ejs +47 -0
  76. package/src/static/ejs/partials/components/ruleOffcanvas.ejs +105 -0
  77. package/src/static/ejs/partials/components/scanAbout.ejs +263 -0
  78. package/src/static/ejs/partials/components/screenshotLightbox.ejs +13 -0
  79. package/src/static/ejs/partials/components/summaryScanAbout.ejs +141 -0
  80. package/src/static/ejs/partials/components/summaryScanResults.ejs +16 -0
  81. package/src/static/ejs/partials/components/summaryTable.ejs +20 -0
  82. package/src/static/ejs/partials/components/summaryWcagCompliance.ejs +94 -0
  83. package/src/static/ejs/partials/components/topFive.ejs +6 -0
  84. package/src/static/ejs/partials/components/wcagCompliance.ejs +70 -0
  85. package/src/static/ejs/partials/footer.ejs +21 -0
  86. package/src/static/ejs/partials/header.ejs +230 -0
  87. package/src/static/ejs/partials/main.ejs +40 -0
  88. package/src/static/ejs/partials/scripts/bootstrap.ejs +8 -0
  89. package/src/static/ejs/partials/scripts/categorySelectorDropdownScript.ejs +190 -0
  90. package/src/static/ejs/partials/scripts/categorySummary.ejs +141 -0
  91. package/src/static/ejs/partials/scripts/highlightjs.ejs +335 -0
  92. package/src/static/ejs/partials/scripts/popper.ejs +7 -0
  93. package/src/static/ejs/partials/scripts/reportSearch.ejs +248 -0
  94. package/src/static/ejs/partials/scripts/ruleOffcanvas.ejs +801 -0
  95. package/src/static/ejs/partials/scripts/screenshotLightbox.ejs +71 -0
  96. package/src/static/ejs/partials/scripts/summaryScanResults.ejs +14 -0
  97. package/src/static/ejs/partials/scripts/summaryTable.ejs +78 -0
  98. package/src/static/ejs/partials/scripts/utils.ejs +441 -0
  99. package/src/static/ejs/partials/styles/bootstrap.ejs +12375 -0
  100. package/src/static/ejs/partials/styles/highlightjs.ejs +54 -0
  101. package/src/static/ejs/partials/styles/styles.ejs +1843 -0
  102. package/src/static/ejs/partials/styles/summaryBootstrap.ejs +12458 -0
  103. package/src/static/ejs/partials/summaryHeader.ejs +70 -0
  104. package/src/static/ejs/partials/summaryMain.ejs +75 -0
  105. package/src/static/ejs/report.ejs +420 -0
  106. package/src/static/ejs/summary.ejs +47 -0
  107. package/src/static/mustache/.prettierrc +4 -0
  108. package/src/static/mustache/Attention Deficit.mustache +11 -0
  109. package/src/static/mustache/Blind.mustache +11 -0
  110. package/src/static/mustache/Cognitive.mustache +7 -0
  111. package/src/static/mustache/Colorblindness.mustache +20 -0
  112. package/src/static/mustache/Deaf.mustache +12 -0
  113. package/src/static/mustache/Deafblind.mustache +7 -0
  114. package/src/static/mustache/Dyslexia.mustache +14 -0
  115. package/src/static/mustache/Low Vision.mustache +7 -0
  116. package/src/static/mustache/Mobility.mustache +15 -0
  117. package/src/static/mustache/Sighted Keyboard Users.mustache +42 -0
  118. package/src/static/mustache/report.mustache +1709 -0
  119. package/src/types/print-message.d.ts +28 -0
  120. package/src/types/types.ts +46 -0
  121. package/src/types/xpath-to-css.d.ts +3 -0
  122. package/src/utils.ts +332 -0
  123. package/tsconfig.json +15 -0
@@ -0,0 +1,53 @@
1
+ // @ts-check
2
+ import globals from 'globals';
3
+ import eslint from '@eslint/js';
4
+ import tseslint from 'typescript-eslint';
5
+ import * as pluginImport from 'eslint-plugin-import';
6
+ import pluginPrettier from 'eslint-plugin-prettier';
7
+ import { FlatCompat } from '@eslint/eslintrc';
8
+
9
+ const compat = new FlatCompat();
10
+
11
+ export default tseslint.config(
12
+ eslint.configs.recommended,
13
+ ...tseslint.configs.recommended,
14
+ {
15
+ ignores: [
16
+ 'dist/',
17
+ '__mocks__/',
18
+ '__tests__/',
19
+ '**/test.js',
20
+ 'src/constants/__tests__/',
21
+ 'src/crawlers/__tests__/',
22
+ ],
23
+ },
24
+ ...compat.extends('airbnb-base', 'plugin:prettier/recommended'),
25
+ {
26
+ languageOptions: {
27
+ globals: {
28
+ ...globals.node,
29
+ ...globals.browser,
30
+ },
31
+ ecmaVersion: 'latest',
32
+ sourceType: 'module',
33
+ },
34
+ plugins: {
35
+ pluginImport,
36
+ pluginPrettier,
37
+ },
38
+ settings: {
39
+ 'import/resolver': {
40
+ node: {
41
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
42
+ },
43
+ },
44
+ },
45
+ rules: {
46
+ 'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
47
+ // disabling import/no-unresolved as typescript already checks this
48
+ // https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
49
+ 'import/no-unresolved': 'off',
50
+ 'lines-between-class-members': 'off',
51
+ },
52
+ },
53
+ );
package/exclusions.txt ADDED
@@ -0,0 +1,2 @@
1
+ \.*login.singpass.gov.sg\.*
2
+ \.*auth.singpass.gov.sg\.*
@@ -0,0 +1,54 @@
1
+ variables:
2
+ # DOCKER_IMAGE: <GitLab URL>/<username>/<project name>:latest
3
+ DOCKER_IMAGE: <GitLab URL>/<username>/<project name>:latest
4
+ # OOBEE_SCAN_URL: https://www.example.com
5
+ OOBEE_SCAN_URL: 'https://example.com'
6
+ # OOBEE_SCAN_TYPE: [choices: "sitemap", "website", "intelligent"]
7
+ OOBEE_SCAN_TYPE: 'website'
8
+ # OOBEE_SCAN_DEVICE: "Desktop"
9
+ # A full list of devices is available at https://github.com/GovTechSG/oobee#mobile-device-options
10
+ OOBEE_SCAN_DEVICE: 'Desktop'
11
+ # OOBEE_SCAN_MAX_NUM_PAGES: 100
12
+ OOBEE_SCAN_MAX_NUM_PAGES: 200
13
+ # OOBEE_MAX_CONCURRENT_PAGES: 25
14
+ # If scan encounters blocked pages / error 403, reduce to 1
15
+ OOBEE_MAX_CONCURRENT_PAGES: 1
16
+ # Speed up tests by excluding screenshots
17
+ # OOBEE_INCLUDE_SCREENSHOTS: [choices: "screenshots", "none"]
18
+ OOBEE_INCLUDE_SCREENSHOTS: 'none'
19
+ # Safe Mode to prevent unexpected dynamic page behaviours
20
+ # OOBEE_SCAN_SAFE_MODE: [choices: "yes", "no"]
21
+ OOBEE_SCAN_SAFE_MODE: 'yes'
22
+ # OOBEE_SCAN_ARTIFACT_NAME: "oobee-scan-results.zip"
23
+ OOBEE_SCAN_ARTIFACT_NAME: 'oobee-scan-results.zip'
24
+ # OOBEE_SCAN_NAME_EMAIL: "John Doe:john@domain.com"
25
+ OOBEE_SCAN_NAME_EMAIL: ''
26
+
27
+ oobee-scan:
28
+ stage: test
29
+ tags:
30
+ # - some tag
31
+ image:
32
+ name: $DOCKER_IMAGE
33
+ entrypoint: ['/bin/bash', '-lc']
34
+ script:
35
+ # Start in the app dir
36
+ - cd /app
37
+ # Run accessibility scan
38
+ - OOBEE_VERBOSE=true npm run build && npm run cli -- -b chromium -c "$OOBEE_SCAN_TYPE" -d "$OOBEE_SCAN_DEVICE" -o "$CI_PROJECT_DIR/$OOBEE_SCAN_ARTIFACT_NAME" -u "$OOBEE_SCAN_URL" -p "$OOBEE_SCAN_MAX_NUM_PAGES" -a "$OOBEE_INCLUDE_SCREENSHOTS" -f "$OOBEE_SCAN_SAFE_MODE" -k "$OOBEE_SCAN_NAME_EMAIL" || true
39
+ # Move the results directory to artifacts
40
+ - results_directory=$(find results -mindepth 1 -maxdepth 1 -type d -print -quit) # Get the first directory within ./results
41
+ - if [ -n "$results_directory" ]; then mv "$results_directory" "$CI_PROJECT_DIR/artifacts"; fi # Move the directory to ./artifacts
42
+ artifacts:
43
+ paths:
44
+ # Stores the report CSV, HTML, summary PDF only to save storage space
45
+ - artifacts/report.csv
46
+ - artifacts/report.html
47
+ - artifacts/scanDetails.csv
48
+ - artifacts/summary.pdf
49
+ # Include screenhots folder
50
+ # - artifacts/elemScreenshots/
51
+ # Stores the reports folder so it can be accessed through Browse
52
+ # - artifacts/
53
+ # Uploads the results as zipped file
54
+ # - $OOBEE_SCAN_ARTIFACT_NAME
package/jest.config.js ADDED
@@ -0,0 +1 @@
1
+ export default { transform: {} };
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@govtechsg/oobee",
3
+ "main": "dist/npmIndex.js",
4
+ "version": "0.10.20",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "@json2csv/node": "^7.0.3",
8
+ "@napi-rs/canvas": "^0.1.53",
9
+ "axe-core": "^4.10.2",
10
+ "axios": "^1.7.4",
11
+ "cheerio": "^1.0.0-rc.12",
12
+ "crawlee": "^3.11.1",
13
+ "ejs": "^3.1.9",
14
+ "file-type": "^19.5.0",
15
+ "fs-extra": "^11.2.0",
16
+ "glob": "^10.3.10",
17
+ "https": "^1.0.0",
18
+ "inquirer": "^9.2.12",
19
+ "jsdom": "^21.1.2",
20
+ "lodash": "^4.17.21",
21
+ "mime-types": "^2.1.35",
22
+ "minimatch": "^9.0.3",
23
+ "pdfjs-dist": "github:veraPDF/pdfjs-dist#v2.14.305-taggedPdf-0.1.11",
24
+ "playwright": "1.46.1",
25
+ "prettier": "^3.1.0",
26
+ "print-message": "^3.0.1",
27
+ "safe-regex": "^2.1.1",
28
+ "text-readability": "^1.1.0",
29
+ "typescript": "^5.4.5",
30
+ "url": "^0.11.3",
31
+ "uuid": "^11.0.3",
32
+ "validator": "^13.11.0",
33
+ "which": "^4.0.0",
34
+ "winston": "^3.11.0",
35
+ "xml2js": "^0.6.2",
36
+ "xpath-to-css": "^1.2.0",
37
+ "yargs": "^17.7.2"
38
+ },
39
+ "devDependencies": {
40
+ "@eslint/eslintrc": "^3.0.2",
41
+ "@eslint/js": "^9.6.0",
42
+ "@types/eslint__js": "^8.42.3",
43
+ "@types/fs-extra": "^11.0.4",
44
+ "@types/inquirer": "^9.0.7",
45
+ "@types/lodash": "^4.17.7",
46
+ "@types/safe-regex": "^1.1.6",
47
+ "@types/validator": "^13.11.10",
48
+ "@types/which": "^3.0.4",
49
+ "@types/xml2js": "^0.4.14",
50
+ "eslint": "^8.57.0",
51
+ "eslint-config-airbnb-base": "^15.0.0",
52
+ "eslint-config-prettier": "^8.6.0",
53
+ "eslint-plugin-import": "^2.27.4",
54
+ "eslint-plugin-prettier": "^5.0.0",
55
+ "globals": "^15.2.0",
56
+ "jest": "^29.7.0",
57
+ "typescript-eslint": "^8.3.0"
58
+ },
59
+ "overrides": {
60
+ "node-fetch": "^2.3.0",
61
+ "json5": "^2.2.3",
62
+ "ansi-regex": "^5.0.1",
63
+ "tough-cookie": "^5.0.0-rc.2",
64
+ "micromatch": "github:micromatch/micromatch.git#4.0.7"
65
+ },
66
+ "optionalDependencies": {
67
+ "@napi-rs/canvas-darwin-arm64": "^0.1.53",
68
+ "@napi-rs/canvas-darwin-x64": "^0.1.53",
69
+ "@napi-rs/canvas-linux-arm64-gnu": "0.1.53",
70
+ "@napi-rs/canvas-linux-arm64-musl": "0.1.53",
71
+ "@napi-rs/canvas-linux-x64-gnu": "0.1.53",
72
+ "@napi-rs/canvas-linux-x64-musl": "0.1.53",
73
+ "@napi-rs/canvas-win32-x64-msvc": "0.1.53"
74
+ },
75
+ "scripts": {
76
+ "build": "npm run copyfiles && tsc",
77
+ "build:watch": "npm run build -- --watch",
78
+ "copyfiles": "node ./scripts/copyFiles.js src/static/ejs dist/static && node ./scripts/copyFiles.js src/constants/errorMeta.json dist/constants && node ./scripts/copyFiles.js exclusions.txt dist",
79
+ "start": "node --max-old-space-size=10000 dist/index.js",
80
+ "cli": "node --max-old-space-size=10000 dist/cli.js",
81
+ "test": "node --experimental-vm-modules ./node_modules/.bin/jest",
82
+ "lint": "eslint . --report-unused-disable-directives --max-warnings 0",
83
+ "lint:fix": "eslint . --fix --report-unused-disable-directives --max-warnings 0"
84
+ },
85
+ "author": "",
86
+ "license": "MIT",
87
+ "description": "Oobee is a customisable, automated accessibility testing tool that allows software development teams to assess whether their products are user-friendly to persons with disabilities (PWDs).",
88
+ "repository": {
89
+ "type": "git",
90
+ "url": "git+https://github.com/GovTechSG/oobee.git"
91
+ },
92
+ "bugs": {
93
+ "url": "https://github.com/GovTechSG/oobee/issues"
94
+ },
95
+ "homepage": "https://github.com/GovTechSG/oobee#readme"
96
+ }
@@ -0,0 +1,44 @@
1
+ /* eslint-disable no-console */
2
+ import { exec } from 'child_process';
3
+ import os from 'os';
4
+
5
+ const sourceDir = process.argv[2];
6
+ const destDir = process.argv[3];
7
+
8
+ if (!sourceDir || !destDir) {
9
+ console.error('Usage: node copyFiles.js <sourceDir> <destDir>');
10
+ process.exit(1);
11
+ }
12
+
13
+ const platform = os.platform();
14
+
15
+ if (platform === 'win32') {
16
+ // Windows
17
+ exec(
18
+ `powershell -Command "(New-Item -Path '${destDir}' -ItemType 'directory' -Force); (Copy-item -Path '${sourceDir}' -Destination '${destDir}' -Recurse -Force)"`,
19
+ (error, stdout, stderr) => {
20
+ if (error) {
21
+ console.error(`Error: ${error.message}`);
22
+ return;
23
+ }
24
+ if (stderr) {
25
+ console.error(`Stderr: ${stderr}`);
26
+ return;
27
+ }
28
+ console.log(`Output: ${stdout}`);
29
+ },
30
+ );
31
+ } else {
32
+ // Other operating systems (Linux, macOS, etc.)
33
+ exec(`mkdir -p "${destDir}" && cp -vr "${sourceDir}" "${destDir}"`, (error, stdout, stderr) => {
34
+ if (error) {
35
+ console.error(`Error: ${error.message}`);
36
+ return;
37
+ }
38
+ if (stderr) {
39
+ console.error(`Stderr: ${stderr}`);
40
+ return;
41
+ }
42
+ console.log(`Output: ${stdout}`);
43
+ });
44
+ }
@@ -0,0 +1,13 @@
1
+ @echo OFF
2
+ if [%1]==[] goto usage
3
+
4
+ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass "& ""%~dp0oobee_shell_ps.ps1""" %*
5
+ exit /B 1
6
+
7
+ :usage
8
+ echo oobee Shell - Created By younglim - NO WARRANTY PROVIDED
9
+ echo ================================================================
10
+ echo
11
+
12
+ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NoExit -ExecutionPolicy Bypass "& ""%~dp0install_oobee_dependencies.ps1"""
13
+ Footer
@@ -0,0 +1,101 @@
1
+ #!/bin/bash
2
+
3
+ NODE_VERSION="20.10.0"
4
+
5
+ # Get current shell command
6
+ SHELL_COMMAND=$(ps -o comm= -p $$)
7
+ SHELL_NAME="${SHELL_COMMAND#-}"
8
+
9
+ cd "$(dirname "${BASH_SOURCE[0]}")"
10
+ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+
12
+ CURR_FOLDERNAME="$(basename "$PWD")"
13
+ if [ "$CURR_FOLDERNAME" = "scripts" ]; then
14
+ cd ..
15
+ CURR_FOLDERNAME="$(basename "$PWD")"
16
+ fi
17
+
18
+ if ! [ -f nodejs-mac-arm64/bin/node ]; then
19
+ echo "Downloading NodeJS LTS (ARM64)"
20
+ curl -o ./nodejs-mac-arm64.tar.gz --create-dirs https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-darwin-arm64.tar.gz
21
+ mkdir nodejs-mac-arm64
22
+ tar -xzf nodejs-mac-arm64.tar.gz -C nodejs-mac-arm64 --strip-components=1 && rm ./nodejs-mac-arm64.tar.gz
23
+ rm nodejs-mac-arm64.tar.gz
24
+ fi
25
+
26
+ if ! [ -f nodejs-mac-x64/bin/node ]; then
27
+ echo "Downloading NodeJS LTS (x64)"
28
+ curl -o ./nodejs-mac-x64.tar.gz --create-dirs https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-darwin-x64.tar.gz
29
+ mkdir nodejs-mac-x64
30
+ tar -xzf nodejs-mac-x64.tar.gz -C nodejs-mac-x64 --strip-components=1 && rm ./nodejs-mac-x64.tar.gz
31
+ rm node-*-darwin-x64.tar.gz
32
+ fi
33
+
34
+ export CORRETTO_BASEDIR="$HOME/Library/Application Support/Oobee"
35
+ mkdir -p "$CORRETTO_BASEDIR"
36
+
37
+ echo "INFO: Set path to Corretto-11 JDK"
38
+ export JAVA_HOME="$CORRETTO_BASEDIR/amazon-corretto-11.jdk.x64/Contents/Home"
39
+ export PATH="$JAVA_HOME/bin:$PATH"
40
+
41
+ if ! [ -f jre/bin/java ]; then
42
+ cd "$CORRETTO_BASEDIR"
43
+ if ! [ -f amazon-corretto-11.jdk.x64/Contents/Home/bin/java ]; then
44
+ echo "Downloading Corretto (x64)"
45
+ curl -L -o ./corretto-11.tar.gz "https://corretto.aws/downloads/latest/amazon-corretto-11-x64-macos-jdk.tar.gz"
46
+ tar -zxf ./corretto-11.tar.gz
47
+ rm -f ./corretto-11.tar.gz
48
+ mv amazon-corretto-11.jdk amazon-corretto-11.jdk.x64
49
+ else
50
+ echo "Found Corretto (x64)"
51
+ fi
52
+
53
+ echo "INFO: Build JRE SE"
54
+ cd "$__dir"
55
+ jlink --output jre --add-modules java.se
56
+
57
+ fi
58
+
59
+ if ! [ -f verapdf/verapdf ]; then
60
+ echo "Downloading VeraPDF"
61
+ if [ -d "./verapdf" ]; then rm -Rf ./verapdf; fi
62
+ if [ -d "./verapdf-installer" ]; then rm -Rf ./verapdf-installer; fi
63
+ curl -L -o ./verapdf-installer.zip https://github.com/GovTechSG/oobee/releases/download/cache/verapdf-installer.zip
64
+ unzip -j ./verapdf-installer.zip -d ./verapdf-installer
65
+ ./verapdf-installer/verapdf-install "${__dir}/verapdf-auto-install-macos.xml"
66
+ cp -r /tmp/verapdf .
67
+ rm -rf ./verapdf-installer.zip ./verapdf-installer /tmp/verapdf
68
+
69
+ fi
70
+
71
+ if [ -d "/Applications/Cloudflare WARP.app" ]; then
72
+ curl -sSLJ -o "/tmp/Cloudflare_CA.pem" "https://developers.cloudflare.com/cloudflare-one/static/documentation/connections/Cloudflare_CA.pem"
73
+ export NODE_EXTRA_CA_CERTS="/tmp/Cloudflare_CA.pem"
74
+ fi
75
+
76
+ source "${__dir}/oobee_shell.sh"
77
+
78
+ if ! [ -f package.json ] && [ -d oobee ]; then
79
+ cd oobee
80
+ fi
81
+
82
+ if [ -d "node_modules" ]; then
83
+ echo "Deleting node_modules before installation"
84
+ rm -rf node_modules
85
+ fi
86
+
87
+ echo "Installing Node dependencies to $PWD"
88
+ npm install --force --omit=dev
89
+
90
+ # Add additional canvas dependency in x64 mode
91
+ if [ "$(uname -m)" = "arm64" ] && /usr/bin/pgrep oahd >/dev/null 2>&1; then
92
+ if [ -f package.json ]; then
93
+ export PATH="$(dirname "$PWD")/nodejs-mac-x64/bin:$PATH"
94
+ else
95
+ export PATH="$PWD/nodejs-mac-x64/bin:$PATH"
96
+ fi
97
+ arch -x86_64 npm install @napi-rs/canvas-darwin-x64@0.1.53 --force --omit=dev
98
+ fi
99
+
100
+ echo "Build TypeScript"
101
+ npm run build || true
@@ -0,0 +1,110 @@
1
+ # If currently within script, go one directory up
2
+ if ((Split-Path -Path $pwd -Leaf) -eq "scripts") {
3
+ cd ..
4
+ }
5
+
6
+ $ProgressPreferences = 'SilentlyContinue'
7
+ $ErrorActionPreference = 'Stop'
8
+
9
+ # Install NodeJS binaries
10
+ if (-Not (Test-Path nodejs-win\node.exe)) {
11
+ Write-Output "Downloading Node"
12
+ Invoke-WebRequest -o ./nodejs-win.zip "https://nodejs.org/dist/v20.10.0/node-v20.10.0-win-x64.zip"
13
+
14
+ Write-Output "Unzip Node"
15
+ Expand-Archive .\nodejs-win.zip -DestinationPath .
16
+ Rename-Item node-v20.10.0-win-x64 -NewName nodejs-win
17
+ Remove-Item -Force .\nodejs-win.zip
18
+ }
19
+
20
+ # Install Coretto-11
21
+ if (-Not (Test-Path jre\bin\java.exe)) {
22
+ if (-Not (Test-Path jdk\bin\java.exe)) {
23
+ Write-Output "Downloading Corretto-11"
24
+ Invoke-WebRequest -o ./corretto-11.zip "https://corretto.aws/downloads/latest/amazon-corretto-11-x64-windows-jdk.zip"
25
+
26
+ Write-Output "Unzip Corretto-11"
27
+ Expand-Archive .\corretto-11.zip -DestinationPath .
28
+ Get-ChildItem ./jdk* -Directory | Rename-Item -NewName jdk
29
+ Remove-Item -Force .\corretto-11.zip
30
+ }
31
+
32
+ Write-Output "Set path to JDK"
33
+ $env:JAVA_HOME = "$PWD\jdk"
34
+ $env:Path = "$env:JAVA_HOME\bin;$env:Path"
35
+
36
+ Write-Output "Build JRE SE"
37
+ Start-Process jlink -ArgumentList "--output jre --add-modules java.se" -Wait -NoNewWindow
38
+ }
39
+
40
+ # Install VeraPDF
41
+ if (-Not (Test-Path verapdf\verapdf.bat)) {
42
+ Write-Output "INFO: Downloading VeraPDF"
43
+ Invoke-WebRequest -o .\verapdf-installer.zip "https://github.com/GovTechSG/oobee/releases/download/cache/verapdf-installer.zip"
44
+ Expand-Archive .\verapdf-installer.zip -DestinationPath .
45
+ Get-ChildItem ./verapdf-greenfield-* -Directory | Rename-Item -NewName verapdf-installer
46
+
47
+ Write-Output "INFO: Set path to JRE for this session"
48
+ $env:JAVA_HOME = "$PWD\jre"
49
+ $env:Path = "$env:JAVA_HOME\bin;$env:Path"
50
+
51
+ Write-Output "INFO: Installing VeraPDF"
52
+ .\verapdf-installer\verapdf-install "$PWD\verapdf-auto-install-windows.xml"
53
+ Move-Item -Path C:\Windows\Temp\verapdf -Destination verapdf
54
+ Remove-Item -Force -Path .\verapdf-installer.zip
55
+ Remove-Item -Force -Path .\verapdf-installer -recurse
56
+ }
57
+
58
+ # Check if the jdk directory exists and remove
59
+ if (Test-Path -Path .\jdk -PathType Container) {
60
+ # Remove the directory forcefully
61
+ Remove-Item -Path .\jdk -Recurse -Force
62
+ }
63
+
64
+ # Install Node dependencies
65
+ if (Test-Path oobee) {
66
+ Write-Output "Installing node dependencies"
67
+ & ".\oobee_shell_ps.ps1" "cd oobee;npm install --force --omit=dev;cd .."
68
+
69
+ # Omit installing Playwright browsers as it is not reuqired
70
+ # Write-Output "Install Playwright browsers"
71
+ # & ".\oobee_shell_ps.ps1" "npx playwright install chromium"
72
+
73
+ try {
74
+ Write-Output "Building Typescript"
75
+ & ".\oobee_shell_ps.ps1" "cd oobee;npm run build"
76
+ } catch {
77
+ Write-Output "Build with some errors but continuing. $_.Exception.Message"
78
+ }
79
+
80
+ if (Test-Path oobee\.git) {
81
+ Write-Output "Unhide .git folder"
82
+ attrib -s -h oobee\.git
83
+ }
84
+
85
+ } else {
86
+ Write-Output "Trying to search for package.json instead"
87
+
88
+ if (Test-Path package.json) {
89
+ Write-Output "Installing node dependencies"
90
+ & ".\oobee_shell_ps.ps1" "npm install --force --omit=dev"
91
+
92
+ Write-Output "Install Playwright browsers"
93
+ & "npx playwright install chromium"
94
+
95
+ if (Test-Path .git) {
96
+ Write-Output "Unhide .git folder"
97
+ attrib -s -h .git
98
+ }
99
+
100
+ try {
101
+ Write-Output "Building Typescript"
102
+ npm run build
103
+ } catch {
104
+ Write-Output "Build with some errors but continuing"
105
+ }
106
+
107
+ } else {
108
+ Write-Output "Could not find oobee"
109
+ }
110
+ }
@@ -0,0 +1,13 @@
1
+ @echo OFF
2
+
3
+ if [%1]==[] goto usage
4
+
5
+ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass "& ""%~dp0oobee_shell_ps.ps1""" %*
6
+ exit /B 1
7
+
8
+ :usage
9
+ echo oobee Shell - Created By younglim - NO WARRANTY PROVIDED
10
+ echo ================================================================
11
+ echo\
12
+
13
+ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NoExit -ExecutionPolicy Bypass "& ""%~dp0oobee_shell_ps.ps1"""
@@ -0,0 +1,11 @@
1
+ #!/bin/zsh
2
+ cd "$(dirname "${BASH_SOURCE[0]}")"
3
+
4
+ # Get current shell command
5
+ SHELL_COMMAND=$(ps -o comm= -p $$)
6
+ SHELL_NAME="${SHELL_COMMAND#-}"
7
+ CURR_FOLDERNAME="$(dirname "$0")"
8
+
9
+ cd "$CURR_FOLDERNAME"
10
+
11
+ $SHELL_NAME "$CURR_FOLDERNAME/oobee_shell.sh" $SHELL_NAME
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+
3
+ echo "oobee Shell - Created By younglim - NO WARRANTY PROVIDED"
4
+ echo "================================================================"
5
+ echo ""
6
+
7
+ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ ORIGINAL_DIR="$PWD"
9
+
10
+ CURR_FOLDERNAME="$(basename "$PWD")"
11
+
12
+ if [ "$CURR_FOLDERNAME" = "scripts" ]; then
13
+ cd ..
14
+ CURR_FOLDERNAME="$(basename "$PWD")"
15
+ fi
16
+
17
+ # Get current shell command
18
+ SHELL_COMMAND=$(ps -o comm= -p $$)
19
+ SHELL_NAME="${SHELL_COMMAND#-}"
20
+
21
+ if [[ $(uname -m) == 'arm64' ]]; then
22
+ echo "INFO: Setting path to node arm64 for this session"
23
+ export PATH_TO_NODE="$PWD/nodejs-mac-arm64/bin"
24
+
25
+ else
26
+ echo "INFO: Setting path to node x64 for this session"
27
+ export PATH_TO_NODE="$PWD/nodejs-mac-x64/bin"
28
+ fi
29
+
30
+
31
+ export PATH="$PATH_TO_NODE:$PATH"
32
+
33
+ echo "INFO: Set path to node_modules for this session"
34
+ if find ./oobee -name "node_modules" -maxdepth 1 -type l -ls &> /dev/null; then
35
+ export PATH="$PWD/oobee/node_modules/.bin:$PATH"
36
+ else
37
+ export PATH="$PWD/node_modules/.bin:$PATH"
38
+ fi
39
+
40
+ echo "INFO: Set path to Java JRE"
41
+ export JAVA_HOME="$PWD/jre"
42
+ export PATH="$JAVA_HOME/bin:$PATH"
43
+
44
+ echo "INFO: Set path to VeraPDF"
45
+ export PATH="$PWD/verapdf:$PATH"
46
+
47
+ echo "INFO: Set path to Playwright cache for this session"
48
+ export PLAYWRIGHT_BROWSERS_PATH="$PWD/ms-playwright"
49
+ export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true"
50
+
51
+ echo "INFO: Removing com.apple.quarantine attributes for required binaries to run"
52
+ xattr -rd com.apple.quarantine . &>/dev/null
53
+
54
+ cd "$ORIGINAL_DIR"
55
+ $@
@@ -0,0 +1,54 @@
1
+ # If currently within script, go one directory up
2
+ if ((Split-Path -Path $pwd -Leaf) -eq "scripts") {
3
+ cd ..
4
+ }
5
+
6
+ # Set current path
7
+ $current_path = (Get-Item -Path ".\" -Verbose).FullName
8
+
9
+ echo "INFO: Stored current working directory at $current_path"
10
+
11
+ # INFO: Set path to oobee
12
+ # $path_to_oobee = split-path -parent $MyInvocation.MyCommand.Definition
13
+ $path_to_oobee = "$PSScriptRoot"
14
+
15
+ echo "INFO: Set path to node for this session"
16
+ $env:Path = "$path_to_oobee\nodejs-win;$env:Path";
17
+
18
+ echo "INFO: Set path to node_modules for this session"
19
+ $env:Path = "$path_to_oobee\node_modules\.bin;./node_modules/.bin;$env:Path";
20
+
21
+ echo "INFO: Set path to Playwright cache for this session"
22
+ $env:PLAYWRIGHT_BROWSERS_PATH = "$path_to_oobee\ms-playwright"
23
+ $env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "true"
24
+
25
+ echo "INFO: Set path to JRE for this session"
26
+ $env:JAVA_HOME = "$path_to_oobee\jre"
27
+ $env:Path = "$env:JAVA_HOME\bin;$env:Path"
28
+
29
+ echo "INFO: Set path to VeraPDF for this session"
30
+ $env:Path = "$path_to_oobee\verapdf;$env:Path"
31
+
32
+ if (Test-Path oobee) {
33
+ echo "INFO: Set path to oobee for this session"
34
+ $env:Path = "$path_to_oobee\oobee;$env:Path"
35
+ } else {
36
+ if (Test-Path package.json) {
37
+ echo "INFO: Set path to oobee for this session"
38
+ $env:Path = "$path_to_oobee;$env:Path"
39
+ } else {
40
+ Write-Output "Could not find oobee"
41
+ }
42
+ }
43
+
44
+ echo ""
45
+ $allArgs = $PsBoundParameters.Values + $args + ""
46
+
47
+ if ($allArgs)
48
+ {
49
+ echo "Running: $allArgs"
50
+ iex "& $allArgs"
51
+ } else
52
+ {
53
+ echo ""
54
+ }