diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a8c39665..d4138bbd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ on: env: # be sure to also update these in other workflows DENO_DIR: deno_dir - DENO_VERSION: "1.32.1" + DENO_VERSION: "1.40.3" jobs: build: @@ -30,7 +30,7 @@ jobs: restore-keys: ci- - name: Setup Deno - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: ${{ env.DENO_VERSION }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eafdb10d1..51ac1d44a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: env: # be sure to also update these in other workflows DENO_DIR: deno_dir - DENO_VERSION: "1.32.1" + DENO_VERSION: "1.40.3" jobs: lint: @@ -31,7 +31,7 @@ jobs: restore-keys: ci- - name: Setup Deno - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: ${{ env.DENO_VERSION }} @@ -56,7 +56,7 @@ jobs: restore-keys: ci- - name: Setup Deno - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: ${{ env.DENO_VERSION }} @@ -81,7 +81,7 @@ jobs: restore-keys: ci- - name: Setup Deno - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: ${{ env.DENO_VERSION }} @@ -114,7 +114,7 @@ jobs: restore-keys: ci- - name: Setup Deno - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: ${{ env.DENO_VERSION }} diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 2a9b2a949..bca551b0f 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -7,7 +7,7 @@ on: env: # be sure to also update these in other workflows DENO_DIR: deno_dir - DENO_VERSION: "1.32.1" + DENO_VERSION: "1.40.3" permissions: {} jobs: @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: Setup Deno - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba with: deno-version: ${{ env.DENO_VERSION }} diff --git a/deno.json b/deno.json index 09eea3f19..f88a3433c 100644 --- a/deno.json +++ b/deno.json @@ -10,12 +10,12 @@ }, "importMap": "importmap.json", "tasks": { - "dev": "deno run --unstable --allow-env --allow-run --allow-read --allow-write --allow-net scripts/dev.js", - "lint": "deno run --allow-env --allow-read --allow-write --allow-run=git scripts/lint.js", - "check": "deno run --unstable --allow-env --allow-run --allow-read --allow-write --allow-net scripts/check.js", - "test": "deno run --unstable --allow-run --allow-read --allow-write --allow-env --allow-net scripts/test.js", - "build-engine": "deno run --unstable --allow-read --allow-write --allow-net --allow-env scripts/buildEngine.js", - "build-studio": "deno run --unstable -A scripts/buildStudio.js", + "dev": "deno run --allow-env --allow-run --allow-read --allow-write --allow-net scripts/dev.js", + "lint": "deno run --allow-env --allow-read --allow-write --allow-sys --allow-run=git scripts/lint.js", + "check": "deno run --allow-env --allow-run --allow-read --allow-write --allow-net scripts/check.js", + "test": "deno run --allow-run --allow-read --allow-write --allow-env --allow-net scripts/test.js", + "build-engine": "deno run --allow-read --allow-write --allow-net --allow-env scripts/buildEngine.js", + "build-studio": "deno run -A scripts/buildStudio.js", "build-npm-package": "deno run --allow-read --allow-write scripts/buildNpmPackage.js" } } diff --git a/scripts/buildStudio.js b/scripts/buildStudio.js index c132b481e..1099548c4 100755 --- a/scripts/buildStudio.js +++ b/scripts/buildStudio.js @@ -112,17 +112,21 @@ function rebaseCssUrl({ * @param {string} cmd */ async function runCmd(cmd) { - const p = Deno.run({ - cmd: cmd.split(" "), + const splitCmd = cmd.split(" "); + if (splitCmd.length <= 0) { + throw new Error("Invalid command: " + cmd); + } + const [exec, ...args] = splitCmd; + const command = new Deno.Command(exec, { + args, stdout: "piped", }); - const status = await p.status(); - if (!status.success) { - throw new Error(`Running "${cmd}" exited with status code ${status.code}`); + const output = await command.output(); + if (!output.success) { + throw new Error(`Running "${cmd}" exited with status code ${output.code}`); } - const outputBuffer = await p.output(); + const outputBuffer = output.stdout; let outputStr = new TextDecoder().decode(outputBuffer); - p.close(); outputStr = outputStr.trim(); if (!outputStr) { throw new Error(`Running "${cmd}" resulted in an empty string`); diff --git a/scripts/check.js b/scripts/check.js index c2001fd0a..0ae049928 100644 --- a/scripts/check.js +++ b/scripts/check.js @@ -2,16 +2,18 @@ import {dev} from "./dev.js"; await dev({ needsTypes: true, + needsTypesSync: true, needsDependencies: true, }); -const proc = Deno.run({ - // Also update the version in ./scripts/dev.js - cmd: ["deno", "run", "--allow-env", "--allow-read", "npm:typescript@5.0.2/tsc", "--noEmit", "-p", "./jsconfig.json"], +const command = new Deno.Command(Deno.execPath(), { + args: ["run", "--allow-env", "--allow-read", "npm:typescript@5.0.2/tsc", "--noEmit", "-p", "./jsconfig.json"], + stdout: "inherit", + stderr: "inherit", }); -const status = await proc.status(); -if (!status.success) { +const output = await command.output(); +if (!output.success) { Deno.exit(1); } else { console.log("No type errors!"); diff --git a/scripts/dev.js b/scripts/dev.js index 88777297e..79852b278 100755 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -36,48 +36,62 @@ export async function dev({ if (needsTypes) { const {generateTypes} = await import("https://deno.land/x/deno_tsc_helper@v0.5.0/mod.js"); - const promise = generateTypes({ - outputDir: ".denoTypes", - unstable: true, - importMap: "importmap.json", - include: [ - "scripts", - "test/shared/", - "test/unit/", - "test/e2e/shared/", - "test/e2e/studio/shared/", - "test/e2e/studio/src/", - "studio/devSocket", - ], - excludeUrls: [ - "rollup-plugin-cleanup", - "https://deno.land/x/dev@v0.2.0/mod.js", // Temporary workaround for https://github.com/denoland/deno/issues/17210 - "npm:rollup-plugin-resolve-url-objects@0.0.4", - "npm:eslint-plugin-jsdoc@39.8.0", - "npm:jszip@3.5.0", + const cwd = Deno.cwd(); - // The StudioDiscovery references some types from the main Renda repository, - // but some of these files have css import assertions, causing deno vendor to fail - "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/util.js", - "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/TypedMessenger/TypedMessenger.js", - "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/discoveryMethods/WebRtcDiscoveryMethod.js", - "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/DiscoveryManager.js", - ], - extraTypeRoots: { + const promise = (async () => { + await generateTypes({ + outputDir: ".denoTypes", + importMap: "importmap.json", + include: [ + "scripts", + "test/shared/", + "test/unit/", + "test/e2e/shared/", + "test/e2e/studio/shared/", + "test/e2e/studio/src/", + "studio/devSocket", + ], + excludeUrls: [ + "rollup-plugin-cleanup", + "https://deno.land/x/dev@v0.2.0/mod.js", // Temporary workaround for https://github.com/denoland/deno/issues/17210 + "npm:rollup-plugin-resolve-url-objects@0.0.4", + "npm:eslint-plugin-jsdoc@39.8.0", + "npm:jszip@3.5.0", + + // The StudioDiscovery references some types from the main Renda repository, + // but some of these files have css import assertions, causing deno vendor to fail + "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/util.js", + "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/TypedMessenger/TypedMessenger.js", + "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/discoveryMethods/WebRtcDiscoveryMethod.js", + "https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/DiscoveryManager.js", + ], + extraTypeRoots: { // We prefix webgpu with aa to ensure it is placed above deno-types. // The Deno types include webgpu types but they are outdated. - "aa-webgpu": "https://cdn.jsdelivr.net/npm/@webgpu/types@0.1.21/dist/index.d.ts", - "wicg-file-system-access": "https://cdn.jsdelivr.net/npm/@types/wicg-file-system-access@2020.9.5/index.d.ts", - "strict-map": "https://deno.land/x/strictly@v0.0.1/src/map.d.ts", - "strict-set": "https://deno.land/x/strictly@v0.0.1/src/set.d.ts", - }, - exactTypeModules: { - eslint: "https://cdn.jsdelivr.net/npm/@types/eslint@8.4.6/index.d.ts", - estree: "https://cdn.jsdelivr.net/npm/@types/estree@1.0.0/index.d.ts", - "npm:postcss-url@10.1.3": "https://cdn.jsdelivr.net/npm/@types/postcss-url@10.0.0/index.d.ts", - }, - logLevel: suppressTypesLogging ? "WARNING" : "DEBUG", - }); + "aa-webgpu": "https://cdn.jsdelivr.net/npm/@webgpu/types@0.1.21/dist/index.d.ts", + "wicg-file-system-access": "https://cdn.jsdelivr.net/npm/@types/wicg-file-system-access@2020.9.5/index.d.ts", + "strict-map": "https://deno.land/x/strictly@v0.0.1/src/map.d.ts", + "strict-set": "https://deno.land/x/strictly@v0.0.1/src/set.d.ts", + }, + exactTypeModules: { + eslint: "https://cdn.jsdelivr.net/npm/@types/eslint@8.4.6/index.d.ts", + estree: "https://cdn.jsdelivr.net/npm/@types/estree@1.0.0/index.d.ts", + "npm:postcss-url@10.1.3": "https://cdn.jsdelivr.net/npm/@types/postcss-url@10.0.0/index.d.ts", + }, + logLevel: suppressTypesLogging ? "WARNING" : "DEBUG", + }); + + // Some of Deno's webgpu types clash with ours + const pathMod = await import("std/path/mod.ts"); + const denoTypesPath = pathMod.resolve(cwd, ".denoTypes/@types/deno-types/index.d.ts"); + const denoTypes = await Deno.readTextFile(denoTypesPath); + const canvasConfigurationStart = denoTypes.indexOf("declare interface GPUCanvasConfiguration"); + if (canvasConfigurationStart > 0) { + const canvasConfigurationEnd = denoTypes.indexOf("}", canvasConfigurationStart) + 1; + const newDenoTypes = denoTypes.slice(0, canvasConfigurationStart) + denoTypes.slice(canvasConfigurationEnd); + await Deno.writeTextFile(denoTypesPath, newDenoTypes); + } + })(); // eslint-disable-next-line no-constant-condition if (false) { diff --git a/scripts/lint.js b/scripts/lint.js index 84d3a6803..f34ebb271 100755 --- a/scripts/lint.js +++ b/scripts/lint.js @@ -74,15 +74,15 @@ if (useIo) { if (Deno.args.includes("--all")) { lintFilesStr = "**/*.js"; } else { - const proc = Deno.run({ - cmd: ["git", "status", "-z"], + const command = new Deno.Command("git", { + args: ["status", "-z"], stdout: "piped", }); - const status = await proc.status(); - if (!status.success) { + const output = await command.output(); + if (!output.success) { throw new Error("Failed to determine which files were changed, run with --all to lint all files in the repository."); } - const result = await proc.output(); + const result = output.stdout; let files = []; let i = 0; diff --git a/scripts/test.js b/scripts/test.js index 261ea68a8..58a4f010e 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -53,7 +53,7 @@ const testCommands = []; // Unit tests if (needsUnitTests) { - const denoTestArgs = ["deno", "test", "--no-check", "--allow-env", "--allow-read", "--allow-net", "--parallel"]; + const denoTestArgs = [Deno.execPath(), "test", "--no-check", "--allow-env", "--allow-read", "--allow-net", "--parallel"]; if (needsCoverage) { denoTestArgs.push("--allow-write"); } @@ -74,19 +74,19 @@ if (needsUnitTests) { // E2e tests if (needsE2eTests) { - const cmd = ["deno", "run", "--allow-env", "--allow-read", "--allow-write", "--allow-run", "--allow-net"]; + const cmd = [Deno.execPath(), "run", "--allow-env", "--allow-read", "--allow-write", "--allow-run", "--allow-net"]; if (inspect) cmd.push("--inspect-brk"); cmd.push("test/e2e/shared/e2eTestRunner.js", ...Deno.args); testCommands.push(cmd); } -let lastTestStatus; for (const cmd of testCommands) { console.log(`Running: ${cmd.join(" ")}`); - const testProcess = Deno.run({cmd}); - lastTestStatus = await testProcess.status(); - if (!lastTestStatus.success) { - Deno.exit(lastTestStatus.code); + const [exec, ...args] = cmd; + const testCommand = new Deno.Command(exec, {args, stdout: "inherit", stderr: "inherit"}); + const testOutput = await testCommand.output(); + if (!testOutput.success) { + Deno.exit(testOutput.code); } } @@ -103,31 +103,37 @@ if (needsCoverage) { } if (coverageMapExists) { console.log("Applying fake-imports coverage map."); - const p = Deno.run({ - cmd: ["deno", "run", "--allow-read", "--no-check", "--allow-write", "https://deno.land/x/fake_imports@v0.8.1/applyCoverageMap.js", FAKE_IMPORTS_COVERAGE_DIR, DENO_COVERAGE_DIR], + const cmd = new Deno.Command(Deno.execPath(), { + args: ["run", "--allow-read", "--no-check", "--allow-write", "https://deno.land/x/fake_imports@v0.8.1/applyCoverageMap.js", FAKE_IMPORTS_COVERAGE_DIR, DENO_COVERAGE_DIR], + stdout: "inherit", + stderr: "inherit", }); - await p.status(); + const output = await cmd.output(); + if (!output.success) { + throw new Error(`Applying fake-imports coverage map failed with status ${output.code}`); + } } console.log("Generating cov.lcov..."); const includeRegex = `^file://${Deno.cwd()}/(src|studio/src|studio/devSocket/src)`; - const coverageProcess = Deno.run({ - cmd: ["deno", "coverage", DENO_COVERAGE_DIR, "--lcov", `--include=${includeRegex}`], + const coverageProcess = new Deno.Command(Deno.execPath(), { + args: ["coverage", DENO_COVERAGE_DIR, "--lcov", `--include=${includeRegex}`], stdout: "piped", }); - const lcov = await coverageProcess.output(); - const coverageStatus = await coverageProcess.status(); - if (!coverageStatus.success) { - Deno.exit(coverageStatus.code); + const coverageOutput = await coverageProcess.output(); + if (!coverageOutput.success) { + Deno.exit(coverageOutput.code); } - await Deno.writeFile(".coverage/cov.lcov", lcov); + await Deno.writeFile(".coverage/cov.lcov", coverageOutput.stdout); if (needsHtmlCoverageReport) { console.log("Generating HTML coverage report..."); - let genHtmlProcess = null; + let genHtmlCommand = null; try { - genHtmlProcess = Deno.run({ - cmd: ["genhtml", "-o", ".coverage/html", ".coverage/cov.lcov"], + genHtmlCommand = new Deno.Command("genhtml", { + args: ["-o", ".coverage/html", ".coverage/cov.lcov"], + stdout: "inherit", + stderr: "inherit", }); } catch { console.error("%cERROR%c Failed to generate html report, is lcov not installed?", "color: red", ""); @@ -140,10 +146,10 @@ if (needsCoverage) { console.log(`Try installing it with: %c${installCmd}`, "color: black; background-color: grey"); } } - if (genHtmlProcess) { - const genHtmlStatus = await genHtmlProcess.status(); - if (!genHtmlStatus.success) { - Deno.exit(genHtmlStatus.code); + if (genHtmlCommand) { + const genHtmlOutput = await genHtmlCommand.output(); + if (!genHtmlOutput.success) { + Deno.exit(genHtmlOutput.code); } } } diff --git a/test/unit/studio/src/misc/ServiceWorkerManager.test.js b/test/unit/studio/src/misc/ServiceWorkerManager.test.js index a48a27fa2..157a82b43 100644 --- a/test/unit/studio/src/misc/ServiceWorkerManager.test.js +++ b/test/unit/studio/src/misc/ServiceWorkerManager.test.js @@ -20,7 +20,7 @@ const SERVICE_WORKER_CLIENT_ID = "service worker client id"; * @property {(now: number) => void} setPreformanceNow Sets the return value for `preformance.now()` * @property {(pending: boolean) => void} setUpdatePromisePending * @property {() => Promise} waitForMicrotasks - * @property {import("std/testing/mock.ts").Stub} reloadSpy + * @property {import("std/testing/mock.ts").Stub} reloadSpy * @property {import("std/testing/mock.ts").Spy} registerClientSpy * @property {import("std/testing/mock.ts").Spy} unregisterClientSpy * @property {import("std/testing/mock.ts").Spy>} skipWaitingSpy