diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2947030..4e544ca6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,12 @@ jobs: run: pnpm coverage - name: 🧪 Test grammar package run: pnpm test:grammar + - name: ↕️ Setup cors free proxy for cloning + run: | + git clone https://github.com/wmhilton/cors-buster + cd cors-buster + npm install + PORT=8000 npm start & - name: 📨 Setup playwright run: | npx playwright install diff --git a/pkg/browser/package.json b/pkg/browser/package.json index 0bf1a6c3..3faee0a4 100644 --- a/pkg/browser/package.json +++ b/pkg/browser/package.json @@ -3,11 +3,13 @@ "dependencies": { "@slangroom/core": "workspace:*", "@slangroom/deps": "workspace:*", + "@slangroom/git": "workspace:*", "@slangroom/helpers": "workspace:*", "@slangroom/http": "workspace:*", "@slangroom/json-schema": "workspace:*", "@slangroom/pocketbase": "workspace:*", - "@slangroom/qrcode": "workspace:*" + "@slangroom/qrcode": "workspace:*", + "buffer": "^6.0.3" }, "version": "1.40.0", "repository": "https://github.com/dyne/slangroom", @@ -40,10 +42,13 @@ "devDependencies": { "@playwright/test": "^1.40.1", "@types/node": "^20.10.4", - "esbuild": "^0.21.4" + "@types/path-browserify": "^1.0.3", + "@zenfs/core": "^0.16.4", + "esbuild": "^0.21.4", + "path-browserify": "^1.0.1" }, "scripts": { - "build": "pnpm exec esbuild --bundle src/index.ts --outfile=build/slangroom.js --target=es2016 --external:fs --external:path --external:crypto && cp build/slangroom.js public" + "build": "pnpm exec esbuild --bundle src/index.ts --outfile=build/slangroom.js --target=ESNext --external:crypto --alias:fs=@zenfs/core --alias:path=path-browserify && cp build/slangroom.js public" }, "engines": { "node": "^18.20.0 || ^20.10.0 || ^22" diff --git a/pkg/browser/public/index.html b/pkg/browser/public/index.html index 60f545f4..e71490ac 100644 --- a/pkg/browser/public/index.html +++ b/pkg/browser/public/index.html @@ -14,6 +14,7 @@

Test http

+
diff --git a/pkg/browser/src/index.ts b/pkg/browser/src/index.ts index 51986419..caf90152 100644 --- a/pkg/browser/src/index.ts +++ b/pkg/browser/src/index.ts @@ -4,6 +4,7 @@ import { Slangroom, version as coreVersion } from '@slangroom/core'; import { qrcode, version as qrcodeVersion } from '@slangroom/qrcode'; +import { git, version as gitVersion } from '@slangroom/git'; import { http, version as httpVersion } from '@slangroom/http'; import { pocketbase, version as pocketbaseVersion } from '@slangroom/pocketbase'; import { helpers, version as helpersVersion } from '@slangroom/helpers'; @@ -11,9 +12,16 @@ import { JSONSchema, version as jsonSchemaVersion } from '@slangroom/json-schema import { zenroomVersion } from '@slangroom/deps/zenroom'; import packageJson from '@slangroom/browser/package.json' with { type: 'json' }; +// web dependencies +import { Buffer } from 'buffer'; + export const version = packageJson.version; const plugins_dict = { + git: { + plugin: git, + version: gitVersion + }, http: { plugin: http, version: httpVersion @@ -51,4 +59,6 @@ const slangroom = new Slangroom(plugins); // eslint-disable-next-line @typescript-eslint/no-explicit-any (window as any).slangroom = slangroom; // instead of casting window to any, you can extend the Window interface: https://stackoverflow.com/a/43513740/5433572 +window.Buffer = Buffer; + console.log(welcome_message); diff --git a/pkg/browser/tests/example.spec.ts b/pkg/browser/tests/example.spec.ts index f121edd9..351d2ce3 100644 --- a/pkg/browser/tests/example.spec.ts +++ b/pkg/browser/tests/example.spec.ts @@ -5,6 +5,9 @@ import { test, expect } from '@playwright/test'; test('check results of slangroom', async ({ page }) => { + // set timeout + test.setTimeout(30000); + await page.goto('http://localhost:8080/'); // Expects page to have a heading with the name of Installation. @@ -22,4 +25,9 @@ test('check results of slangroom', async ({ page }) => { await expect(page.locator('#test-pocketbase-2')).toContainText( "{\"output\":{\"name\":\"test organization\"}}" ); + + await expect(page.locator('#test-git')).toContainText( + "{\"checked\":\"true\"}", + { timeout: 20000 } + ); }); diff --git a/pkg/git/src/plugin.ts b/pkg/git/src/plugin.ts index 174713ed..a5b9f603 100644 --- a/pkg/git/src/plugin.ts +++ b/pkg/git/src/plugin.ts @@ -5,9 +5,9 @@ import { Plugin } from '@slangroom/core'; import gitpkg from 'isomorphic-git'; // TODO: why does this require index.js? -import http from 'isomorphic-git/http/node/index.js'; -import * as fs from 'node:fs/promises'; -import * as path from 'node:path'; +import http from 'isomorphic-git/http/web/index.js'; +import { promises as fs } from 'fs'; +import path from 'path'; // read the version from the package.json import packageJson from '@slangroom/git/package.json' with { type: 'json' }; @@ -24,6 +24,7 @@ export class GitError extends Error { * @internal */ export const sandboxDir = () => { + if (typeof process === 'undefined') return '.'; // TODO: sanitize sandboxDir return process.env['FILES_DIR']; }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 89056ac4..02f173cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -228,6 +228,9 @@ importers: '@slangroom/deps': specifier: workspace:* version: link:../deps + '@slangroom/git': + specifier: workspace:* + version: link:../git '@slangroom/helpers': specifier: workspace:* version: link:../helpers @@ -243,6 +246,9 @@ importers: '@slangroom/qrcode': specifier: workspace:* version: link:../qrcode + buffer: + specifier: ^6.0.3 + version: 6.0.3 devDependencies: '@playwright/test': specifier: ^1.40.1 @@ -250,9 +256,18 @@ importers: '@types/node': specifier: ^20.10.4 version: 20.10.4 + '@types/path-browserify': + specifier: ^1.0.3 + version: 1.0.3 + '@zenfs/core': + specifier: ^0.16.4 + version: 0.16.4 esbuild: specifier: ^0.21.4 version: 0.21.4 + path-browserify: + specifier: ^1.0.1 + version: 1.0.1 pkg/core: dependencies: @@ -1574,12 +1589,24 @@ packages: '@types/node@20.11.30': resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} + '@types/node@20.16.1': + resolution: {integrity: sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==} + '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} + '@types/object-path@0.11.4': + resolution: {integrity: sha512-4tgJ1Z3elF/tOMpA8JLVuR9spt9Ynsf7+JjqsQ2IqtiPJtcLoHoXcT6qU4E10cPFqyXX5HDm9QwIzZhBSkLxsw==} + + '@types/path-browserify@1.0.3': + resolution: {integrity: sha512-ZmHivEbNCBtAfcrFeBCiTjdIc2dey0l7oCGNGpSuRTy8jP6UVND7oUowlvDujBy8r2Hoa8bfFUOCiPWfmtkfxw==} + '@types/qrcode@1.5.5': resolution: {integrity: sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==} + '@types/readable-stream@4.0.15': + resolution: {integrity: sha512-oAZ3kw+kJFkEqyh7xORZOku1YAKvsFTogRY8kVl4vHpEKiDkfnSA/My8haRE7fvmix5Zyy+1pwzOi7yycGLBJw==} + '@types/semver@7.5.8': resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} @@ -1761,6 +1788,15 @@ packages: '@vueuse/shared@10.9.0': resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==} + '@wessberg/stringutil@1.0.19': + resolution: {integrity: sha512-9AZHVXWlpN8Cn9k5BC/O0Dzb9E9xfEMXzYrNunwvkUTvuK7xgQPVRZpLo+jWCOZ5r8oBa8NIrHuPEu1hzbb6bg==} + engines: {node: '>=8.0.0'} + + '@zenfs/core@0.16.4': + resolution: {integrity: sha512-QYT0tB3iHWo6q4KlSTl1zr2LWLgayNOHGPw5x+s926weH3Nrnw2Npe2gfLK05UFvXhhTynee8DgYGjFhgqBUmg==} + engines: {node: '>= 16'} + hasBin: true + JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true @@ -1781,6 +1817,10 @@ packages: zod: optional: true + abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + acorn-import-attributes@1.9.2: resolution: {integrity: sha512-O+nfJwNolEA771IYJaiLWK1UAwjNsQmZbTRqqwBYxCgVQTmpFEMvBw6LOIQV0Me339L5UMVYFyRohGnGlQDdIQ==} peerDependencies: @@ -2019,6 +2059,9 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + builtins@5.0.1: resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} @@ -2600,9 +2643,17 @@ packages: ethereum-cryptography@2.1.2: resolution: {integrity: sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==} + event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + eventemitter3@5.0.1: resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} + events@3.3.0: + resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} + engines: {node: '>=0.8.x'} + execa@5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -4023,6 +4074,9 @@ packages: parse5@6.0.1: resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} @@ -4159,6 +4213,10 @@ packages: process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + promise-all-reject-late@1.0.1: resolution: {integrity: sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==} @@ -4248,6 +4306,10 @@ packages: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} + readable-stream@4.5.2: + resolution: {integrity: sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -4835,6 +4897,9 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + unicode-emoji-modifier-base@1.0.0: resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==} engines: {node: '>=4'} @@ -4884,6 +4949,9 @@ packages: util@0.12.5: resolution: {integrity: sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==} + utilium@0.4.4: + resolution: {integrity: sha512-TjhvLLoSi3WmzAR1QMFwGykW31cEOzbVoPqqopY6UYcm+5MfsF0ep3+DuJmAnOlU/zglGDwR96j0hjiHfwP4og==} + uuid@8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true @@ -6407,12 +6475,25 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/node@20.16.1': + dependencies: + undici-types: 6.19.8 + '@types/normalize-package-data@2.4.4': {} + '@types/object-path@0.11.4': {} + + '@types/path-browserify@1.0.3': {} + '@types/qrcode@1.5.5': dependencies: '@types/node': 20.11.30 + '@types/readable-stream@4.0.15': + dependencies: + '@types/node': 20.16.1 + safe-buffer: 5.1.2 + '@types/semver@7.5.8': {} '@types/validator@13.11.9': {} @@ -6645,6 +6726,18 @@ snapshots: - '@vue/composition-api' - vue + '@wessberg/stringutil@1.0.19': {} + + '@zenfs/core@0.16.4': + dependencies: + '@types/node': 20.16.1 + '@types/readable-stream': 4.0.15 + buffer: 6.0.3 + eventemitter3: 5.0.1 + minimatch: 9.0.3 + readable-stream: 4.5.2 + utilium: 0.4.4 + JSONStream@1.3.5: dependencies: jsonparse: 1.3.1 @@ -6660,6 +6753,10 @@ snapshots: optionalDependencies: zod: 3.22.4 + abort-controller@3.0.0: + dependencies: + event-target-shim: 5.0.1 + acorn-import-attributes@1.9.2(acorn@8.11.3): dependencies: acorn: 8.11.3 @@ -6929,6 +7026,11 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + buffer@6.0.3: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + builtins@5.0.1: dependencies: semver: 7.6.0 @@ -7587,8 +7689,12 @@ snapshots: '@scure/bip32': 1.3.1 '@scure/bip39': 1.2.1 + event-target-shim@5.0.1: {} + eventemitter3@5.0.1: {} + events@3.3.0: {} + execa@5.1.1: dependencies: cross-spawn: 7.0.3 @@ -9040,6 +9146,8 @@ snapshots: parse5@6.0.1: {} + path-browserify@1.0.1: {} + path-exists@3.0.0: {} path-exists@4.0.0: {} @@ -9146,6 +9254,8 @@ snapshots: process-nextick-args@2.0.1: {} + process@0.11.10: {} + promise-all-reject-late@1.0.1: {} promise-call-limit@3.0.1: {} @@ -9249,6 +9359,14 @@ snapshots: string_decoder: 1.3.0 util-deprecate: 1.0.2 + readable-stream@4.5.2: + dependencies: + abort-controller: 3.0.0 + buffer: 6.0.3 + events: 3.3.0 + process: 0.11.10 + string_decoder: 1.3.0 + readdirp@3.6.0: dependencies: picomatch: 2.3.1 @@ -9858,6 +9976,8 @@ snapshots: undici-types@5.26.5: {} + undici-types@6.19.8: {} + unicode-emoji-modifier-base@1.0.0: {} unicorn-magic@0.1.0: {} @@ -9906,6 +10026,10 @@ snapshots: is-typed-array: 1.1.12 which-typed-array: 1.1.13 + utilium@0.4.4: + dependencies: + eventemitter3: 5.0.1 + uuid@8.3.2: {} uuid@9.0.1: {}