The VS Code of video editing, built for agents.
TypeScript
Enhance Windows support and update dependencies
konstantin-paulus46cef22b266a
diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.ymlnew file mode 100644index 00000000..143bc5e4--- /dev/null+++ b/.github/workflows/build-windows.yml@@ -0,0 +1,37 @@+name: Build Windows++# An unsigned Windows installer on demand, for testing the Windows build+# before it is part of the release (see apps/desktop/WINDOWS.md). Signing+# and publishing join the Release workflow in a later stage.++on:+ workflow_dispatch:++jobs:+ make-windows:+ runs-on: windows-latest+ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-node@v4+ with:+ node-version: 20+ cache: npm++ - run: npm ci++ - name: Provide client env for web build+ shell: bash+ run: cp apps/web/.env.example apps/web/.env++ - name: Build and make the installer+ shell: bash+ env:+ SKIP_SIGN: "1"+ run: npm run make --workspace=@diffusionstudio/desktop++ - uses: actions/upload-artifact@v4+ with:+ name: diffusion-studio-windows-${{ runner.arch }}+ path: apps/desktop/out/make/squirrel.windows/**+ if-no-files-found: errordiff --git a/apps/cli/package.json b/apps/cli/package.jsonindex 540f6eb1..ae79f7e6 100644--- a/apps/cli/package.json+++ b/apps/cli/package.json@@ -7,7 +7,7 @@"dapi": "./dist/index.js"},"scripts": {- "build": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.js && chmod +x dist/index.js",+ "build": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.js && node -e \"process.platform !== 'win32' && require('node:fs').chmodSync('dist/index.js', 0o755)\"","check": "tsc --noEmit","symlink:remove": "rm -f /opt/homebrew/bin/dapi","symlink:create": "npm run build && ln -sf \"$PWD/dist/index.js\" /opt/homebrew/bin/dapi"diff --git a/apps/desktop/WINDOWS.md b/apps/desktop/WINDOWS.mdindex 3f498b6a..73ee170c 100644--- a/apps/desktop/WINDOWS.md+++ b/apps/desktop/WINDOWS.md@@ -72,6 +72,12 @@ Goal: a `Diffusion Studio Setup.exe` built by CI (unsigned) that installs,launches, opens a project, and exports a video. Nothing about CLI, MCP, orchrome yet.+Status: implemented on macOS, not yet run on Windows. Every task below is+in place; `.github/workflows/build-windows.yml` (workflow_dispatch) is the+next step, followed by the acceptance checks on a Windows machine. Squirrel's+`iconUrl` points at `assets/icon.ico` on `main`, so Add/Remove Programs+shows the icon only once this lands there.+Tasks:1. **npm scripts that survive `cmd.exe`.**diff --git a/apps/desktop/assets/icon.ico b/apps/desktop/assets/icon.iconew file mode 100644index 00000000..ed38b1f9Binary files /dev/null and b/apps/desktop/assets/icon.ico differdiff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.tsindex 924a5049..881ad49f 100644--- a/apps/desktop/forge.config.ts+++ b/apps/desktop/forge.config.ts@@ -4,6 +4,7 @@import type { ForgeConfig } from '@electron-forge/shared-types';import { MakerDMG } from '@electron-forge/maker-dmg';+import { MakerSquirrel } from '@electron-forge/maker-squirrel';import { MakerZIP } from '@electron-forge/maker-zip';import { PublisherGithub } from '@electron-forge/publisher-github';import { readFileSync } from 'node:fs';@@ -18,6 +19,11 @@ const config: ForgeConfig = {appCategoryType: 'public.app-category.video',appVersion: version,icon: './assets/icon',+ win32metadata: {+ CompanyName: 'Diffusion Studio',+ ProductName: 'Diffusion Studio',+ FileDescription: 'Diffusion Studio',+ },protocols: [{ name: 'Diffusion Studio', schemes: ['diffusion'] }],prune: false,ignore: (path) =>@@ -42,6 +48,16 @@ const config: ForgeConfig = {},makers: [new MakerZIP({}, ['darwin']),+ new MakerSquirrel({+ name: 'DiffusionStudio',+ authors: 'Diffusion Studio',+ exe: 'Diffusion Studio.exe',+ setupExe: `Diffusion-Studio-${process.arch}-Setup.exe`,+ setupIcon: './assets/icon.ico',+ // Shown by Add/Remove Programs; Squirrel only takes a URL.+ iconUrl: 'https://raw.githubusercontent.com/diffusionstudio/editor/main/apps/desktop/assets/icon.ico',+ noMsi: true,+ }),new MakerDMG({name: `Diffusion-Studio-${process.arch}`,icon: './assets/icon.icns',diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 09f75dd7..194c19b6 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -24,11 +24,13 @@"publish": "npm run build && npm run build:web && npm run stage:cli && npm run stage:runtime && npm run stage:docs && electron-forge publish","make:icns": "sh scripts/make-icns.sh","test": "vitest run",- "build:agent-host": "esbuild ../../packages/agent-chat/src/bin.ts --bundle --platform=node --format=esm --target=node20 --external:electron '--external:@anthropic-ai/claude-agent-sdk-*' --banner:js=\"import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);\" --outfile=dist/agent-host.mjs"+ "build:agent-host": "esbuild ../../packages/agent-chat/src/bin.ts --bundle --platform=node --format=esm --target=node20 --external:electron \"--external:@anthropic-ai/claude-agent-sdk-*\" --banner:js=\"import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);\" --outfile=dist/agent-host.mjs",+ "make:ico": "sh scripts/make-ico.sh"},"devDependencies": {"@electron-forge/cli": "^7.11.1","@electron-forge/maker-dmg": "^7.11.1",+ "@electron-forge/maker-squirrel": "^7.11.2","@electron-forge/maker-zip": "^7.11.1","@electron-forge/publisher-github": "^7.11.1","@types/babel__core": "^7.20.5",@@ -40,6 +42,7 @@"dependencies": {"@babel/core": "^7.29.7","@babel/preset-typescript": "^7.27.1",+ "@diffusionstudio/agent-chat": "*","@diffusionstudio/dapi": "*","@diffusionstudio/jsx": "*","@modelcontextprotocol/sdk": "^1.30.0",@@ -48,7 +51,6 @@"nanoid": "^6.0.1","ts-morph": "^28.0.0","update-electron-app": "^3.0.0",- "yaml": "^2.9.0",- "@diffusionstudio/agent-chat": "*"+ "yaml": "^2.9.0"}}diff --git a/apps/desktop/scripts/make-ico.sh b/apps/desktop/scripts/make-ico.shnew file mode 100755index 00000000..7749a965--- /dev/null+++ b/apps/desktop/scripts/make-ico.sh@@ -0,0 +1,10 @@+#!/bin/sh+# Regenerates assets/icon.ico from assets/icon.png (1024x1024), the sizes+# Windows uses for the taskbar, Explorer, and the installer.+# Replace assets/icon.png and run: npm run make:ico+# Needs ImageMagick 7 (brew install imagemagick).+set -e+cd "$(dirname "$0")/.."++magick assets/icon.png -define icon:auto-resize=256,128,64,48,32,16 assets/icon.ico+echo "wrote assets/icon.ico"diff --git a/apps/desktop/scripts/stage-runtime.mjs b/apps/desktop/scripts/stage-runtime.mjsindex 04723b9f..e2fa96ad 100644--- a/apps/desktop/scripts/stage-runtime.mjs+++ b/apps/desktop/scripts/stage-runtime.mjs@@ -19,6 +19,7 @@ import { createRequire } from "node:module";import { existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, closeSync, rmSync, writeFileSync } from "node:fs";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";+import { npm } from "../../../scripts/lib/npm.mjs";const desktopDir = join(dirname(fileURLToPath(import.meta.url)), "..");const stageDir = join(desktopDir, "runtime");@@ -44,10 +45,7 @@ writeFileSync(JSON.stringify({ name: "desktop-runtime", private: true, dependencies }, null, 2),);-execFileSync("npm", ["install", "--omit=dev", "--no-audit", "--no-fund", "--no-package-lock"], {- cwd: stageDir,- stdio: "inherit",-});+npm(["install", "--omit=dev", "--no-audit", "--no-fund", "--no-package-lock"], { cwd: stageDir });// Mach-O files inside Resources are not reached by the app-bundle signing// pass, and notarization rejects unsigned executables; sign them here.diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex 5c380d62..c59ebf0b 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -17,6 +17,7 @@ import { applyMcp, healMcpRegistrations, mcpStatus } from "./mcp-install";import { enableHeadless } from "./headless";import { trackInstall } from "./analytics";import { setupAppMenu } from "./menu";+import { handleSquirrelEvent } from "./squirrel";import { mainBridge } from "./main-manager";import { MAIN_CHANNELS } from "./main-channels";import {@@ -55,6 +56,11 @@ const AUTH_PROTOCOL = "diffusion";const MACOS_CORNER_RADIUS = 18;const MACOS_BACKDROP = { blur: 80, red: 0.07, green: 0.07, blue: 0.07, alpha: 0.9 };+// A Squirrel.Windows install/update/uninstall launch: housekeeping only, the+// app quits on its own. Decided first so nothing below starts a service or+// checks for updates on a launch that is about to end.+const squirrelLaunch = handleSquirrelEvent();+app.setName("Diffusion Studio");app.commandLine.appendSwitch("enable-blink-features", "CanvasDrawElement");app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer");@@ -85,7 +91,7 @@ function applyBackdrop() {setNativeBackdrop(mainWindow.getNativeWindowHandle(), blur, red, green, blue, alpha);}-if (app.isPackaged && !process.argv.includes("--hidden")) {+if (app.isPackaged && !squirrelLaunch && !process.argv.includes("--hidden")) {updateElectronApp({ repo: "diffusionstudio/editor" });}@@ -261,7 +267,9 @@ if (process.defaultApp && process.argv.length >= 2) {app.setAsDefaultProtocolClient(AUTH_PROTOCOL);}-if (app.requestSingleInstanceLock()) {+if (squirrelLaunch) {+ // Update.exe is at work; handleSquirrelEvent quits the app when it is done.+} else if (app.requestSingleInstanceLock()) {app.on("second-instance", (_event, argv) => {const url = findProtocolUrl(argv);if (url) deliverDeepLink(url);diff --git a/apps/desktop/src/squirrel.test.ts b/apps/desktop/src/squirrel.test.tsnew file mode 100644index 00000000..8e33dbf8--- /dev/null+++ b/apps/desktop/src/squirrel.test.ts@@ -0,0 +1,34 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++// Which launches are Squirrel housekeeping: only the four event flags, only+// on Windows, and only as the first argument, where Squirrel puts them. A+// deep link or `--hidden` in that position is a real launch.++import { describe, expect, it, vi } from "vitest";++vi.mock("electron", () => ({ app: { quit: () => {} } }));++const { squirrelEvent } = await import("./squirrel");++const exe = "C:\\Users\\me\\AppData\\Local\\DiffusionStudio\\app-1.0.0\\Diffusion Studio.exe";++describe("squirrelEvent", () => {+ it("recognises each event flag on Windows", () => {+ for (const flag of ["--squirrel-install", "--squirrel-updated", "--squirrel-uninstall", "--squirrel-obsolete"]) {+ expect(squirrelEvent([exe, flag, "1.0.0"], "win32")).toBe(flag);+ }+ });++ it("treats the first run and ordinary launches as launches", () => {+ expect(squirrelEvent([exe, "--squirrel-firstrun"], "win32")).toBeNull();+ expect(squirrelEvent([exe], "win32")).toBeNull();+ expect(squirrelEvent([exe, "--hidden"], "win32")).toBeNull();+ expect(squirrelEvent([exe, "diffusion://auth?x=1"], "win32")).toBeNull();+ });++ it("is never an event off Windows", () => {+ expect(squirrelEvent(["/Applications/Diffusion Studio.app/Contents/MacOS/Diffusion Studio", "--squirrel-install"], "darwin")).toBeNull();+ });+});diff --git a/apps/desktop/src/squirrel.ts b/apps/desktop/src/squirrel.tsnew file mode 100644index 00000000..75811b9c--- /dev/null+++ b/apps/desktop/src/squirrel.ts@@ -0,0 +1,63 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++// Squirrel.Windows starts the app once for each install, update, and+// uninstall, with a `--squirrel-*` flag as the only argument, and expects it+// to do its housekeeping and exit. That is the moment the Start Menu+// shortcut is created and removed (through Squirrel's own Update.exe, one+// folder up from the versioned app folder), and — from later stages — where+// the `dapi` shim and the agents' MCP entries get written and cleaned up.+// `--squirrel-firstrun` is the ordinary first launch and is not an event.++import { app } from "electron";+import { spawn } from "node:child_process";+import { basename, resolve } from "node:path";++const EVENTS = new Set(["--squirrel-install", "--squirrel-updated", "--squirrel-uninstall", "--squirrel-obsolete"]);++/** The `--squirrel-*` event this launch is, or null when it is a real launch. */+export function squirrelEvent(argv: string[] = process.argv, platform: string = process.platform): string | null {+ if (platform !== "win32") return null;+ const flag = argv[1];+ return flag && EVENTS.has(flag) ? flag : null;+}++/** Runs Update.exe with `args` and quits once it is done. Quits at once if it cannot be started. */+function updateExe(args: string[]): void {+ const exe = resolve(process.execPath, "..", "..", "Update.exe");+ let child;+ try {+ child = spawn(exe, args, { detached: true, stdio: "ignore", windowsHide: true });+ } catch {+ app.quit();+ return;+ }+ child.on("error", () => app.quit());+ child.on("close", () => app.quit());+}++/**+ * Handles a Squirrel event launch. Returns true when this launch was one —+ * the caller must then not open a window or start any service; the app+ * quits by itself once the housekeeping is done.+ */+export function handleSquirrelEvent(): boolean {+ const event = squirrelEvent();+ if (!event) return false;++ const target = basename(process.execPath);+ switch (event) {+ case "--squirrel-install":+ case "--squirrel-updated":+ updateExe(["--createShortcut", target]);+ break;+ case "--squirrel-uninstall":+ updateExe(["--removeShortcut", target]);+ break;+ default:+ // --squirrel-obsolete: the version being replaced gets a last word; we have none.+ app.quit();+ }+ return true;+}diff --git a/package-lock.json b/package-lock.jsonindex 5cbad698..caab5a2f 100644--- a/package-lock.json+++ b/package-lock.json@@ -57,6 +57,7 @@"devDependencies": {"@electron-forge/cli": "^7.11.1","@electron-forge/maker-dmg": "^7.11.1",+ "@electron-forge/maker-squirrel": "^7.11.2","@electron-forge/maker-zip": "^7.11.1","@electron-forge/publisher-github": "^7.11.1","@types/babel__core": "^7.20.5",@@ -973,6 +974,24 @@"electron-installer-dmg": "^5.0.1"}},+ "node_modules/@electron-forge/maker-squirrel": {+ "version": "7.11.2",+ "resolved": "https://registry.npmjs.org/@electron-forge/maker-squirrel/-/maker-squirrel-7.11.2.tgz",+ "integrity": "sha512-4CILo57ZDEQH1mJxjhYCSXuv+WaU7oPq67KqiTLEUOEzmiPg9u9/z7FXE34H/Tn5aKWN3dy+ngAETzv6iERCGg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@electron-forge/maker-base": "7.11.2",+ "@electron-forge/shared-types": "7.11.2",+ "fs-extra": "^10.0.0"+ },+ "engines": {+ "node": ">= 16.4.0"+ },+ "optionalDependencies": {+ "electron-winstaller": "^5.3.0"+ }+ },"node_modules/@electron-forge/maker-zip": {"version": "7.11.2","resolved": "https://registry.npmjs.org/@electron-forge/maker-zip/-/maker-zip-7.11.2.tgz",@@ -6867,6 +6886,67 @@"integrity": "sha512-TaxwufTFDufvPEoXdhwVrA3UdFWBeWGkYoJ1K8ldF1xe6gKfth6iRNS5lTQ5JPNOHdGQm8PT1QYKUqFLCiUefQ==","license": "ISC"},+ "node_modules/electron-winstaller": {+ "version": "5.4.4",+ "resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-5.4.4.tgz",+ "integrity": "sha512-j9ETcBGJaXxAY/b6UBpR7LZfjdU4BAO+yvr4ifqHEdyuc3UNCy91PDGkWKY5UQ4coHNYfnwFggrqD6QPeFGAlg==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@electron/asar": "^3.2.1",+ "debug": "^4.1.1",+ "fs-extra": "^7.0.1",+ "lodash": "^4.17.21",+ "semver": "^7.6.3",+ "temp": "^0.9.0"+ },+ "engines": {+ "node": ">=8.0.0"+ },+ "optionalDependencies": {+ "@electron/windows-sign": "^1.1.2"+ }+ },+ "node_modules/electron-winstaller/node_modules/fs-extra": {+ "version": "7.0.1",+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",+ "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "graceful-fs": "^4.1.2",+ "jsonfile": "^4.0.0",+ "universalify": "^0.1.0"+ },+ "engines": {+ "node": ">=6 <7 || >=8"+ }+ },+ "node_modules/electron-winstaller/node_modules/jsonfile": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",+ "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "optionalDependencies": {+ "graceful-fs": "^4.1.6"+ }+ },+ "node_modules/electron-winstaller/node_modules/universalify": {+ "version": "0.1.2",+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",+ "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "engines": {+ "node": ">= 4.0.0"+ }+ },"node_modules/electron/node_modules/@electron/get": {"version": "5.0.0","resolved": "https://registry.npmjs.org/@electron/get/-/get-5.0.0.tgz",@@ -9570,6 +9650,14 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/lodash": {+ "version": "4.18.1",+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",+ "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",+ "dev": true,+ "license": "MIT",+ "optional": true+ },"node_modules/lodash.get": {"version": "4.4.2","resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",@@ -12552,6 +12640,50 @@"node": ">=8"}},+ "node_modules/temp": {+ "version": "0.9.4",+ "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz",+ "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "mkdirp": "^0.5.1",+ "rimraf": "~2.6.2"+ },+ "engines": {+ "node": ">=6.0.0"+ }+ },+ "node_modules/temp/node_modules/mkdirp": {+ "version": "0.5.6",+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",+ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "minimist": "^1.2.6"+ },+ "bin": {+ "mkdirp": "bin/cmd.js"+ }+ },+ "node_modules/temp/node_modules/rimraf": {+ "version": "2.6.3",+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",+ "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",+ "deprecated": "Rimraf versions prior to v4 are no longer supported",+ "dev": true,+ "license": "ISC",+ "optional": true,+ "dependencies": {+ "glob": "^7.1.3"+ },+ "bin": {+ "rimraf": "bin.js"+ }+ },"node_modules/terser": {"version": "5.48.0","resolved": "https://registry.npmjs.org/terser/-/terser-5.48.0.tgz",diff --git a/scripts/dev-desktop.mjs b/scripts/dev-desktop.mjsindex a5cf8262..d09a86ee 100644--- a/scripts/dev-desktop.mjs+++ b/scripts/dev-desktop.mjs@@ -14,6 +14,7 @@ import { spawn, execFileSync } from "node:child_process";import { get } from "node:http";import { join } from "node:path";import { fileURLToPath } from "node:url";+import { npm } from "./lib/npm.mjs";const ROOT = fileURLToPath(new URL("..", import.meta.url));const BIN = join(ROOT, "node_modules", ".bin");@@ -135,7 +136,7 @@ async function reclaimPort(port) {// 1. Build the CLI (blocking) so `dapi` and the app agree on the latest code.console.log("[dev:desktop] building CLI…");-execFileSync("npm", ["run", "build", "--workspace=@diffusionstudio/cli"], { stdio: "inherit" });+npm(["run", "build", "--workspace=@diffusionstudio/cli"]);// 2. Start the web dev server, on a port that is free.await reclaimPort(DEV_PORT);@@ -151,6 +152,6 @@ try {shutdown(1);}console.log("[dev:desktop] building desktop app…");-execFileSync("npm", ["run", "build", "--workspace=@diffusionstudio/desktop"], { stdio: "inherit" });+npm(["run", "build", "--workspace=@diffusionstudio/desktop"]);console.log("[dev:desktop] starting desktop app…");run("desktop", "electron-forge", ["start"], join(ROOT, "apps", "desktop"));diff --git a/scripts/lib/npm.mjs b/scripts/lib/npm.mjsnew file mode 100644index 00000000..6dc1c9cb--- /dev/null+++ b/scripts/lib/npm.mjs@@ -0,0 +1,23 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++// Runs npm from a script, on every platform. On Windows `npm` is a `.cmd`+// shim, which `execFileSync` cannot start without a shell; on POSIX it is a+// plain executable and a shell would only get in the way of the arguments.++import { execFileSync } from "node:child_process";++const WINDOWS = process.platform === "win32";++/**+ * `npm <args>`, blocking, with output inherited. `options` are passed to+ * `execFileSync` (`cwd`, `env`, `stdio`).+ */+export function npm(args, options = {}) {+ return execFileSync(WINDOWS ? "npm.cmd" : "npm", args, {+ stdio: "inherit",+ ...options,+ shell: WINDOWS,+ });+}diff --git a/scripts/release.mjs b/scripts/release.mjsindex f4e473d2..a8bf4f67 100644--- a/scripts/release.mjs+++ b/scripts/release.mjs@@ -11,6 +11,7 @@ import { execFileSync } from "node:child_process";import { readFileSync, writeFileSync } from "node:fs";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";+import { npm } from "./lib/npm.mjs";const root = join(dirname(fileURLToPath(import.meta.url)), "..");const PKGS = [@@ -62,10 +63,7 @@ for (const rel of PKGS) {writeFileSync(path, JSON.stringify(pkg, null, 2) + "\n");}-execFileSync("npm", ["install", "--package-lock-only", "--no-audit", "--no-fund"], {- cwd: root,- stdio: "inherit",-});+npm(["install", "--package-lock-only", "--no-audit", "--no-fund"], { cwd: root });git("add", ...PKGS, "package-lock.json");git("commit", "-m", tag);