Migrate to oxfmt (#618)

* Migrate to oxfmt

* Enable import sorting

* trailingComma always
This commit is contained in:
Bjorn Lu
2026-05-15 11:48:55 +00:00
committed by GitHub
parent 03ba888eb8
commit 6c80731937
18 changed files with 324 additions and 110 deletions
+7
View File
@@ -0,0 +1,7 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 80,
"sortImports": {
"newlinesBetween": false
}
}
@@ -1,6 +1,4 @@
{ {
"$schema": "https://unpkg.com/@changesets/config@1.3.0/schema.json", "$schema": "https://unpkg.com/@changesets/config@1.3.0/schema.json",
"ignore": [ "ignore": ["changesets-dev-ignored-package-pkg-a"]
"changesets-dev-ignored-package-pkg-a"
]
} }
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"private": true,
"name": "ignored-package", "name": "ignored-package",
"version": "1.0.0", "version": "1.0.0",
"private": true,
"workspaces": [ "workspaces": [
"packages/*" "packages/*"
] ]
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"private": true,
"name": "simple-project", "name": "simple-project",
"version": "1.0.0", "version": "1.0.0",
"private": true,
"workspaces": [ "workspaces": [
"packages/*" "packages/*"
] ]
+25 -30
View File
@@ -1,41 +1,21 @@
{ {
"name": "@changesets/action", "name": "@changesets/action",
"version": "1.8.0", "version": "1.8.0",
"main": "dist/index.js",
"type": "module",
"license": "MIT", "license": "MIT",
"devDependencies": { "type": "module",
"@changesets/changelog-github": "^0.5.1", "main": "dist/index.js",
"@changesets/cli": "^2.29.3",
"@changesets/types": "^6.1.0",
"@changesets/write": "^0.4.0",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@types/node": "^24.12.2",
"@types/semver": "^7.5.0",
"builtin-modules": "^5.0.0",
"esbuild": "^0.25.4",
"fixturez": "^1.1.0",
"prettier": "^2.0.5",
"rollup": "^4.40.2",
"typescript": "^5.8.3",
"vitest": "^4.1.5"
},
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",
"test": "vitest", "test": "vitest",
"test:watch": "pnpm test --watch", "test:watch": "pnpm test --watch",
"typecheck": "tsc", "typecheck": "tsc",
"format": "oxfmt --check",
"format:fix": "oxfmt",
"changeset": "changeset", "changeset": "changeset",
"bump": "node --experimental-strip-types ./scripts/bump.ts", "bump": "node --experimental-strip-types ./scripts/bump.ts",
"release": "node --experimental-strip-types ./scripts/release.ts", "release": "node --experimental-strip-types ./scripts/release.ts",
"release:pr": "node --experimental-strip-types ./scripts/release-pr.ts" "release:pr": "node --experimental-strip-types ./scripts/release-pr.ts"
}, },
"engines": {
"node": ">= 24"
},
"dependencies": { "dependencies": {
"@actions/core": "^3.0.1", "@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0", "@actions/exec": "^3.0.0",
@@ -53,12 +33,27 @@
"semver": "^7.5.3", "semver": "^7.5.3",
"unified": "^8.3.2" "unified": "^8.3.2"
}, },
"pnpm": { "devDependencies": {
"overrides": { "@changesets/changelog-github": "^0.5.1",
"trim": "^0.0.3", "@changesets/cli": "^2.29.3",
"y18n": "^4.0.1" "@changesets/types": "^6.1.0",
} "@changesets/write": "^0.4.0",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@types/node": "^24.12.2",
"@types/semver": "^7.5.0",
"builtin-modules": "^5.0.0",
"esbuild": "^0.25.4",
"fixturez": "^1.1.0",
"oxfmt": "^0.48.0",
"rollup": "^4.40.2",
"typescript": "^5.8.3",
"vitest": "^4.1.5"
},
"engines": {
"node": ">=24"
}, },
"prettier": {},
"packageManager": "pnpm@11.1.1+sha512.d1fdf5f73c617b64fa1a56a81c3c8dfe0e966e33a6010aa256b517ae77be21d93e05affc0de1a83b0e4f29d569f68b446ae8f068cd7247c0bb3df0fb4d7bdf9a" "packageManager": "pnpm@11.1.1+sha512.d1fdf5f73c617b64fa1a56a81c3c8dfe0e966e33a6010aa256b517ae77be21d93e05affc0de1a83b0e4f29d569f68b446ae8f068cd7247c0bb3df0fb4d7bdf9a"
} }
+217 -3
View File
@@ -94,9 +94,9 @@ importers:
fixturez: fixturez:
specifier: ^1.1.0 specifier: ^1.1.0
version: 1.1.0 version: 1.1.0
prettier: oxfmt:
specifier: ^2.0.5 specifier: ^0.48.0
version: 2.8.8 version: 0.48.0
rollup: rollup:
specifier: ^4.40.2 specifier: ^4.40.2
version: 4.60.2 version: 4.60.2
@@ -598,6 +598,128 @@ packages:
'@octokit/types@16.0.0': '@octokit/types@16.0.0':
resolution: {integrity: sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==} resolution: {integrity: sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==}
'@oxfmt/binding-android-arm-eabi@0.48.0':
resolution: {integrity: sha512-uwqk+/KhQvBIpULD8SMM/zAafMRC/+DV/xsEQjkkIsJ/kLmEI/2bxonVowcYTiXqqZ/a0FEW8DPkZY3VvwELDA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [android]
'@oxfmt/binding-android-arm64@0.48.0':
resolution: {integrity: sha512-VUCiKuXK5+McVssgHEJdrcGK7hRJzrRb36zm9/jwzMholyYt4BgXhw5Nm1V1DX6Ce717Zi/1jk432b/tgmQgtQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
'@oxfmt/binding-darwin-arm64@0.48.0':
resolution: {integrity: sha512-IkKp8rnIyQLW6Jt+6jragCbUVYSayk55lapiprLjIVvt4NczLyO/nwX2GgefLQ5iaBdfS8UEAFgCs/pLO6Cl0w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
'@oxfmt/binding-darwin-x64@0.48.0':
resolution: {integrity: sha512-+aFuhsGIuvnoOjXyKVHMhPKJZR1kQkAl8QyrKoMlA7yJsSTC3N0Asl53La8TChSHhW8epToQ/Q0nvLmEmfNmLg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
'@oxfmt/binding-freebsd-x64@0.48.0':
resolution: {integrity: sha512-fbqzQL8FjI9gGnktI7RIo0dksDziTAYBy7xlI7jU7eID5fxLF/25fS4Xj6GydD8Y5oWHL83U4NK160QaOAxtyg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
'@oxfmt/binding-linux-arm-gnueabihf@0.48.0':
resolution: {integrity: sha512-hn4i0zhAyTiB3ZHjQfYUZkDvrbVkohw1S7pySWxWUoZ87HnkDoTFThj7QTxk40hNPOTUP0vHbPRNamFIv1HBJQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@oxfmt/binding-linux-arm-musleabihf@0.48.0':
resolution: {integrity: sha512-R4WBD9qF3QM9hqgdAa+fBGXmquTvDUujrPQ36t2Sjk8RPOSKGHDeN7l/khr10hqbQaOq9KCgPHG9ubNET/X/RQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@oxfmt/binding-linux-arm64-gnu@0.48.0':
resolution: {integrity: sha512-5bVdwSwlm1M8wbYCorLOxWxUBw/8tBvHYyQNIfwWVPwOJaj5vg1APSGJQVpwJfV5VNE9PSrR91UKEpoNwHhqUA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-arm64-musl@0.48.0':
resolution: {integrity: sha512-vCS3Fk7gFslTqE1lUE2IlroyVV7u/9SmMA/uBqDoshuck2psGWcjW0ePyPZI3rM3+qtf2pDaMVIKMHozraifuw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [musl]
'@oxfmt/binding-linux-ppc64-gnu@0.48.0':
resolution: {integrity: sha512-gKtfFfueUClXDumyoHUbymqRf7prHejOOyzJK0eIJn93GF9JBdFHdo60TM1ZBHxkEwZvjuOgHmKtneKbEOc/Eg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-riscv64-gnu@0.48.0':
resolution: {integrity: sha512-SYt0UhOvZD/UwZz9sXq6J2uAw8o24f5VZpLB2DH01f6MevshmlgakQlZe2lwek2sZJkd07eLu7mZa0g7yeiw7Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-riscv64-musl@0.48.0':
resolution: {integrity: sha512-JLbrwck2AopG4ud/XklZO5N+qxGC7cS7ROvXZVNfx0MCLDDL2kGOLvzuWORkVjnjAM0CMAfIMU2zNBtQbM+4dw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@oxfmt/binding-linux-s390x-gnu@0.48.0':
resolution: {integrity: sha512-mdxt5L8OQLxkQH+JVpdC/lknZNe0lX4hlO3d8+xvw2wToo+iDrid9tiGOd5bmHfUVd5wVhrUry0qlu5vq66NkQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-x64-gnu@0.48.0':
resolution: {integrity: sha512-oEz1BQwMrV7OMEFx/3VPDU3n9TM0AnxpktDYXjEg5i6nTX87wo18wSfBvkl4tzAICdKtoAQAdBIl7Y7hsPlx5w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-x64-musl@0.48.0':
resolution: {integrity: sha512-g2SKTTurP5mWjd8Ecait0erYqmltL4IqW1EwttM25BxM6NiTt4ubobJYMR1uox1V2QgG4UfHH10CGRvWlUixjw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [musl]
'@oxfmt/binding-openharmony-arm64@0.48.0':
resolution: {integrity: sha512-CIg24VgheEpvolHL2gQuax5qcQ602bRMHrJ9g8XsQr3iVj9aSPgopigBKuMqrXsupwkrU+RQCn5cG8PgFntR6w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
'@oxfmt/binding-win32-arm64-msvc@0.48.0':
resolution: {integrity: sha512-zeaWkcxcEULwkGF3I/HgEvcDPN8buYDrxibBUa/IFh5Vmwyge+KpLO+hEwSovW349H0O/C0Z2kaFmEzEDm00/Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
'@oxfmt/binding-win32-ia32-msvc@0.48.0':
resolution: {integrity: sha512-yiEKnIAGvx5CyZQOlMaNlZkAbwT7/Quk0j3WLt+PR5hK+qYjPTRRJYDfD77wCBPLvEYAG41v4KG3iL0H+uxoxg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ia32]
os: [win32]
'@oxfmt/binding-win32-x64-msvc@0.48.0':
resolution: {integrity: sha512-GSD2+7t2UoVMV2NgxXypa4bKewflPMAjYnF0Xw9/ht82ZfafAHhb8STwrEd7wlH2PFogt5zw3WVCxYJaHUdbeQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
'@rollup/plugin-commonjs@28.0.9': '@rollup/plugin-commonjs@28.0.9':
resolution: {integrity: sha512-PIR4/OHZ79romx0BVVll/PkwWpJ7e5lsqFa3gFfcrFPWwLXLV39JVUzQV9RKjWerE7B845Hqjj9VYlQeieZ2dA==} resolution: {integrity: sha512-PIR4/OHZ79romx0BVVll/PkwWpJ7e5lsqFa3gFfcrFPWwLXLV39JVUzQV9RKjWerE7B845Hqjj9VYlQeieZ2dA==}
engines: {node: '>=16.0.0 || 14 >= 14.17'} engines: {node: '>=16.0.0 || 14 >= 14.17'}
@@ -1521,6 +1643,11 @@ packages:
outdent@0.5.0: outdent@0.5.0:
resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==}
oxfmt@0.48.0:
resolution: {integrity: sha512-AVaLh+7XeGx+R1zfFV+f6VV61nT2MWVJXVUDhbTm5LBWGyNt64xAyh3NYYyjeY2WykNt9AvqSQLPHcbWquYF9g==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
p-filter@2.1.0: p-filter@2.1.0:
resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==}
engines: {node: '>=8'} engines: {node: '>=8'}
@@ -1796,6 +1923,10 @@ packages:
resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==} resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==}
engines: {node: '>=12.0.0'} engines: {node: '>=12.0.0'}
tinypool@2.1.0:
resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==}
engines: {node: ^20.0.0 || >=22.0.0}
tinyrainbow@3.1.0: tinyrainbow@3.1.0:
resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==} resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
@@ -2455,6 +2586,63 @@ snapshots:
dependencies: dependencies:
'@octokit/openapi-types': 27.0.0 '@octokit/openapi-types': 27.0.0
'@oxfmt/binding-android-arm-eabi@0.48.0':
optional: true
'@oxfmt/binding-android-arm64@0.48.0':
optional: true
'@oxfmt/binding-darwin-arm64@0.48.0':
optional: true
'@oxfmt/binding-darwin-x64@0.48.0':
optional: true
'@oxfmt/binding-freebsd-x64@0.48.0':
optional: true
'@oxfmt/binding-linux-arm-gnueabihf@0.48.0':
optional: true
'@oxfmt/binding-linux-arm-musleabihf@0.48.0':
optional: true
'@oxfmt/binding-linux-arm64-gnu@0.48.0':
optional: true
'@oxfmt/binding-linux-arm64-musl@0.48.0':
optional: true
'@oxfmt/binding-linux-ppc64-gnu@0.48.0':
optional: true
'@oxfmt/binding-linux-riscv64-gnu@0.48.0':
optional: true
'@oxfmt/binding-linux-riscv64-musl@0.48.0':
optional: true
'@oxfmt/binding-linux-s390x-gnu@0.48.0':
optional: true
'@oxfmt/binding-linux-x64-gnu@0.48.0':
optional: true
'@oxfmt/binding-linux-x64-musl@0.48.0':
optional: true
'@oxfmt/binding-openharmony-arm64@0.48.0':
optional: true
'@oxfmt/binding-win32-arm64-msvc@0.48.0':
optional: true
'@oxfmt/binding-win32-ia32-msvc@0.48.0':
optional: true
'@oxfmt/binding-win32-x64-msvc@0.48.0':
optional: true
'@rollup/plugin-commonjs@28.0.9(rollup@4.60.2)': '@rollup/plugin-commonjs@28.0.9(rollup@4.60.2)':
dependencies: dependencies:
'@rollup/pluginutils': 5.3.0(rollup@4.60.2) '@rollup/pluginutils': 5.3.0(rollup@4.60.2)
@@ -3253,6 +3441,30 @@ snapshots:
outdent@0.5.0: {} outdent@0.5.0: {}
oxfmt@0.48.0:
dependencies:
tinypool: 2.1.0
optionalDependencies:
'@oxfmt/binding-android-arm-eabi': 0.48.0
'@oxfmt/binding-android-arm64': 0.48.0
'@oxfmt/binding-darwin-arm64': 0.48.0
'@oxfmt/binding-darwin-x64': 0.48.0
'@oxfmt/binding-freebsd-x64': 0.48.0
'@oxfmt/binding-linux-arm-gnueabihf': 0.48.0
'@oxfmt/binding-linux-arm-musleabihf': 0.48.0
'@oxfmt/binding-linux-arm64-gnu': 0.48.0
'@oxfmt/binding-linux-arm64-musl': 0.48.0
'@oxfmt/binding-linux-ppc64-gnu': 0.48.0
'@oxfmt/binding-linux-riscv64-gnu': 0.48.0
'@oxfmt/binding-linux-riscv64-musl': 0.48.0
'@oxfmt/binding-linux-s390x-gnu': 0.48.0
'@oxfmt/binding-linux-x64-gnu': 0.48.0
'@oxfmt/binding-linux-x64-musl': 0.48.0
'@oxfmt/binding-openharmony-arm64': 0.48.0
'@oxfmt/binding-win32-arm64-msvc': 0.48.0
'@oxfmt/binding-win32-ia32-msvc': 0.48.0
'@oxfmt/binding-win32-x64-msvc': 0.48.0
p-filter@2.1.0: p-filter@2.1.0:
dependencies: dependencies:
p-map: 2.1.0 p-map: 2.1.0
@@ -3577,6 +3789,8 @@ snapshots:
fdir: 6.5.0(picomatch@4.0.4) fdir: 6.5.0(picomatch@4.0.4)
picomatch: 4.0.4 picomatch: 4.0.4
tinypool@2.1.0: {}
tinyrainbow@3.1.0: {} tinyrainbow@3.1.0: {}
to-buffer@1.2.2: to-buffer@1.2.2:
+3 -3
View File
@@ -1,10 +1,10 @@
import { defineConfig } from "rollup";
import commonjs from "@rollup/plugin-commonjs"; import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve"; import nodeResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser"; import terser from "@rollup/plugin-terser";
import json from "@rollup/plugin-json";
import { transform } from "esbuild";
import builtinModulesList from "builtin-modules"; import builtinModulesList from "builtin-modules";
import { transform } from "esbuild";
import { defineConfig } from "rollup";
const builtinModules = new Set(builtinModulesList); const builtinModules = new Set(builtinModulesList);
+2 -2
View File
@@ -1,6 +1,6 @@
import { exec } from "@actions/exec";
import fs from "node:fs"; import fs from "node:fs";
import path from "node:path"; import path from "node:path";
import { exec } from "@actions/exec";
import pkgJson from "../package.json" with { type: "json" }; import pkgJson from "../package.json" with { type: "json" };
process.chdir(path.join(import.meta.dirname, "..")); process.chdir(path.join(import.meta.dirname, ".."));
@@ -13,6 +13,6 @@ const readmePath = path.join(import.meta.dirname, "..", "README.md");
const content = fs.readFileSync(readmePath, "utf8"); const content = fs.readFileSync(readmePath, "utf8");
const updatedContent = content.replace( const updatedContent = content.replace(
/changesets\/action@[^\s]+/g, /changesets\/action@[^\s]+/g,
`changesets/action@${releaseLine}` `changesets/action@${releaseLine}`,
); );
fs.writeFileSync(readmePath, updatedContent); fs.writeFileSync(readmePath, updatedContent);
+1 -2
View File
@@ -1,6 +1,5 @@
import { exec } from "@actions/exec";
import path from "node:path"; import path from "node:path";
import { exec } from "@actions/exec";
import pkgJson from "../package.json" with { type: "json" }; import pkgJson from "../package.json" with { type: "json" };
const tag = `v${pkgJson.version}`; const tag = `v${pkgJson.version}`;
+3 -4
View File
@@ -1,6 +1,5 @@
import { exec, getExecOutput } from "@actions/exec";
import path from "node:path"; import path from "node:path";
import { exec, getExecOutput } from "@actions/exec";
import pkgJson from "../package.json" with { type: "json" }; import pkgJson from "../package.json" with { type: "json" };
const tag = `v${pkgJson.version}`; const tag = `v${pkgJson.version}`;
@@ -14,11 +13,11 @@ process.chdir(path.join(import.meta.dirname, ".."));
["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`], ["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`],
{ {
ignoreReturnCode: true, ignoreReturnCode: true,
} },
); );
if (exitCode === 0) { if (exitCode === 0) {
console.log( console.log(
`Action is not being published because version ${tag} is already published` `Action is not being published because version ${tag} is already published`,
); );
return; return;
} }
+3 -3
View File
@@ -14,7 +14,7 @@ const push = async (branch: string, options: GitOptions) => {
const switchToMaybeExistingBranch = async ( const switchToMaybeExistingBranch = async (
branch: string, branch: string,
options: GitOptions options: GitOptions,
) => { ) => {
let { stderr } = await getExecOutput("git", ["checkout", branch], { let { stderr } = await getExecOutput("git", ["checkout", branch], {
ignoreReturnCode: true, ignoreReturnCode: true,
@@ -41,7 +41,7 @@ const checkIfClean = async (options: GitOptions): Promise<boolean> => {
const { stdout } = await getExecOutput( const { stdout } = await getExecOutput(
"git", "git",
["status", "--porcelain"], ["status", "--porcelain"],
options options,
); );
return !stdout.length; return !stdout.length;
}; };
@@ -71,7 +71,7 @@ export class Git {
], ],
{ {
cwd: this.cwd, cwd: this.cwd,
} },
); );
} }
+13 -13
View File
@@ -1,6 +1,6 @@
import * as core from "@actions/core";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import path from "node:path"; import path from "node:path";
import * as core from "@actions/core";
import { Git } from "./git.ts"; import { Git } from "./git.ts";
import { setupOctokit } from "./octokit.ts"; import { setupOctokit } from "./octokit.ts";
import readChangesetState from "./readChangesetState.ts"; import readChangesetState from "./readChangesetState.ts";
@@ -48,7 +48,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
core.info("setting GitHub credentials"); core.info("setting GitHub credentials");
await fs.writeFile( await fs.writeFile(
`${process.env.HOME}/.netrc`, `${process.env.HOME}/.netrc`,
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`,
); );
let { changesets } = await readChangesetState(cwd); let { changesets } = await readChangesetState(cwd);
@@ -56,7 +56,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
let publishScript = core.getInput("publish"); let publishScript = core.getInput("publish");
let hasChangesets = changesets.length !== 0; let hasChangesets = changesets.length !== 0;
const hasNonEmptyChangesets = changesets.some( const hasNonEmptyChangesets = changesets.some(
(changeset) => changeset.releases.length > 0 (changeset) => changeset.releases.length > 0,
); );
let hasPublishScript = !!publishScript; let hasPublishScript = !!publishScript;
@@ -67,12 +67,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
switch (true) { switch (true) {
case !hasChangesets && !hasPublishScript: case !hasChangesets && !hasPublishScript:
core.info( core.info(
"No changesets present or were removed by merging release PR. Not publishing because no publish script found." "No changesets present or were removed by merging release PR. Not publishing because no publish script found.",
); );
return; return;
case !hasChangesets && hasPublishScript: { case !hasChangesets && hasPublishScript: {
core.info( core.info(
"No changesets found. Attempting to publish any unpublished packages to npm" "No changesets found. Attempting to publish any unpublished packages to npm",
); );
if (process.env.NPM_TOKEN) { if (process.env.NPM_TOKEN) {
@@ -87,24 +87,24 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
}); });
if (authLine) { if (authLine) {
core.info( core.info(
"Found existing auth token for the npm registry in the user .npmrc file" "Found existing auth token for the npm registry in the user .npmrc file",
); );
} else { } else {
core.info( core.info(
"Didn't find existing auth token for the npm registry in the user .npmrc file, creating one" "Didn't find existing auth token for the npm registry in the user .npmrc file, creating one",
); );
await fs.appendFile( await fs.appendFile(
userNpmrcPath, userNpmrcPath,
`\n//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n` `\n//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n`,
); );
} }
} else { } else {
core.info( core.info(
"No user .npmrc file found, creating one with NPM_TOKEN used as auth token" "No user .npmrc file found, creating one with NPM_TOKEN used as auth token",
); );
await fs.writeFile( await fs.writeFile(
userNpmrcPath, userNpmrcPath,
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n` `//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n`,
); );
} }
} else if ( } else if (
@@ -112,11 +112,11 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
process.env.ACTIONS_ID_TOKEN_REQUEST_URL process.env.ACTIONS_ID_TOKEN_REQUEST_URL
) { ) {
core.info( core.info(
"No NPM_TOKEN found, but OIDC is available - using npm trusted publishing" "No NPM_TOKEN found, but OIDC is available - using npm trusted publishing",
); );
} else { } else {
core.info( core.info(
"No NPM_TOKEN or OIDC available - assuming npm is already authenticated" "No NPM_TOKEN or OIDC available - assuming npm is already authenticated",
); );
} }
@@ -133,7 +133,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
core.setOutput("published", "true"); core.setOutput("published", "true");
core.setOutput( core.setOutput(
"publishedPackages", "publishedPackages",
JSON.stringify(result.publishedPackages) JSON.stringify(result.publishedPackages),
); );
} }
return; return;
+4 -4
View File
@@ -9,7 +9,7 @@ export const setupOctokit = (githubToken: string) => {
throttle: { throttle: {
onRateLimit: (retryAfter, options: any, octokit, retryCount) => { onRateLimit: (retryAfter, options: any, octokit, retryCount) => {
core.warning( core.warning(
`Request quota exhausted for request ${options.method} ${options.url}` `Request quota exhausted for request ${options.method} ${options.url}`,
); );
if (retryCount <= 2) { if (retryCount <= 2) {
@@ -21,10 +21,10 @@ export const setupOctokit = (githubToken: string) => {
retryAfter, retryAfter,
options: any, options: any,
octokit, octokit,
retryCount retryCount,
) => { ) => {
core.warning( core.warning(
`SecondaryRateLimit detected for request ${options.method} ${options.url}` `SecondaryRateLimit detected for request ${options.method} ${options.url}`,
); );
if (retryCount <= 2) { if (retryCount <= 2) {
@@ -34,7 +34,7 @@ export const setupOctokit = (githubToken: string) => {
}, },
}, },
}, },
throttling throttling,
); );
}; };
+2 -2
View File
@@ -1,6 +1,6 @@
import type { PreState, NewChangeset } from "@changesets/types";
import { readPreState } from "@changesets/pre"; import { readPreState } from "@changesets/pre";
import readChangesets from "@changesets/read"; import readChangesets from "@changesets/read";
import type { PreState, NewChangeset } from "@changesets/types";
export type ChangesetState = { export type ChangesetState = {
preState: PreState | undefined; preState: PreState | undefined;
@@ -8,7 +8,7 @@ export type ChangesetState = {
}; };
export default async function readChangesetState( export default async function readChangesetState(
cwd: string = process.cwd() cwd: string = process.cwd(),
): Promise<ChangesetState> { ): Promise<ChangesetState> {
let preState = await readPreState(cwd); let preState = await readPreState(cwd);
let changesets = await readChangesets(cwd); let changesets = await readChangesets(cwd);
+13 -13
View File
@@ -1,8 +1,8 @@
import fs from "node:fs/promises";
import path from "node:path";
import type { Changeset } from "@changesets/types"; import type { Changeset } from "@changesets/types";
import writeChangeset from "@changesets/write"; import writeChangeset from "@changesets/write";
import fixturez from "fixturez"; import fixturez from "fixturez";
import fs from "node:fs/promises";
import path from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest"; import { beforeEach, describe, expect, it, vi } from "vitest";
import { Git } from "./git.ts"; import { Git } from "./git.ts";
import { setupOctokit } from "./octokit.ts"; import { setupOctokit } from "./octokit.ts";
@@ -41,7 +41,7 @@ let f = fixturez(import.meta.dirname);
const linkNodeModules = async (cwd: string) => { const linkNodeModules = async (cwd: string) => {
await fs.symlink( await fs.symlink(
path.join(import.meta.dirname, "..", "node_modules"), path.join(import.meta.dirname, "..", "node_modules"),
path.join(cwd, "node_modules") path.join(cwd, "node_modules"),
); );
}; };
const writeChangesets = (changesets: Changeset[], cwd: string) => { const writeChangesets = (changesets: Changeset[], cwd: string) => {
@@ -79,7 +79,7 @@ describe("version", () => {
summary: "Awesome feature", summary: "Awesome feature",
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -114,7 +114,7 @@ describe("version", () => {
summary: "Awesome feature", summary: "Awesome feature",
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -150,7 +150,7 @@ describe("version", () => {
summary: "Awesome feature", summary: "Awesome feature",
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -185,7 +185,7 @@ describe("version", () => {
summary: "Awesome feature", summary: "Awesome feature",
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -240,7 +240,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
`, `,
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -253,7 +253,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot(); expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot();
expect(mockedGithubMethods.pulls.create.mock.calls[0][0].body).toMatch( expect(mockedGithubMethods.pulls.create.mock.calls[0][0].body).toMatch(
/The changelog information of each package has been omitted from this message/ /The changelog information of each package has been omitted from this message/,
); );
}); });
@@ -299,7 +299,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
`, `,
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -312,7 +312,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot(); expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot();
expect(mockedGithubMethods.pulls.create.mock.calls[0][0].body).toMatch( expect(mockedGithubMethods.pulls.create.mock.calls[0][0].body).toMatch(
/All release information have been omitted from this message, as the content exceeds the size limit/ /All release information have been omitted from this message, as the content exceeds the size limit/,
); );
}); });
@@ -336,7 +336,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
summary: "Awesome feature", summary: "Awesome feature",
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
@@ -370,7 +370,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
summary: "Awesome feature", summary: "Awesome feature",
}, },
], ],
cwd cwd,
); );
await runVersion({ await runVersion({
+19 -17
View File
@@ -1,11 +1,11 @@
import fs from "node:fs/promises";
import { createRequire } from "node:module";
import path from "node:path";
import * as core from "@actions/core"; import * as core from "@actions/core";
import { exec, getExecOutput } from "@actions/exec"; import { exec, getExecOutput } from "@actions/exec";
import * as github from "@actions/github"; import * as github from "@actions/github";
import type { PreState } from "@changesets/types"; import type { PreState } from "@changesets/types";
import { type Package, getPackages } from "@manypkg/get-packages"; import { type Package, getPackages } from "@manypkg/get-packages";
import fs from "node:fs/promises";
import { createRequire } from "node:module";
import path from "node:path";
import semverLt from "semver/functions/lt.js"; import semverLt from "semver/functions/lt.js";
import { Git } from "./git.ts"; import { Git } from "./git.ts";
import type { Octokit } from "./octokit.ts"; import type { Octokit } from "./octokit.ts";
@@ -28,7 +28,7 @@ const MAX_CHARACTERS_PER_MESSAGE = 60000;
const createRelease = async ( const createRelease = async (
octokit: Octokit, octokit: Octokit,
{ pkg, tagName }: { pkg: Package; tagName: string } { pkg, tagName }: { pkg: Package; tagName: string },
) => { ) => {
let changelog; let changelog;
try { try {
@@ -45,7 +45,7 @@ const createRelease = async (
// we can find a changelog but not the entry for this version // we can find a changelog but not the entry for this version
// if this is true, something has probably gone wrong // if this is true, something has probably gone wrong
throw new Error( throw new Error(
`Could not find changelog entry for ${pkg.packageJson.name}@${pkg.packageJson.version}` `Could not find changelog entry for ${pkg.packageJson.name}@${pkg.packageJson.version}`,
); );
} }
@@ -91,7 +91,7 @@ export async function runPublish({
let changesetPublishOutput = await getExecOutput( let changesetPublishOutput = await getExecOutput(
publishCommand, publishCommand,
publishArgs, publishArgs,
{ cwd, env: { ...process.env, GITHUB_TOKEN: githubToken } } { cwd, env: { ...process.env, GITHUB_TOKEN: githubToken } },
); );
let { packages, tool } = await getPackages(cwd); let { packages, tool } = await getPackages(cwd);
@@ -111,7 +111,7 @@ export async function runPublish({
if (pkg === undefined) { if (pkg === undefined) {
throw new Error( throw new Error(
`Package "${pkgName}" not found.` + `Package "${pkgName}" not found.` +
"This is probably a bug in the action, please open an issue" "This is probably a bug in the action, please open an issue",
); );
} }
releasedPackages.push(pkg); releasedPackages.push(pkg);
@@ -123,14 +123,14 @@ export async function runPublish({
const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`; const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`;
await git.pushTag(tagName); await git.pushTag(tagName);
await createRelease(octokit, { pkg, tagName }); await createRelease(octokit, { pkg, tagName });
}) }),
); );
} }
} else { } else {
if (packages.length === 0) { if (packages.length === 0) {
throw new Error( throw new Error(
`No package found.` + `No package found.` +
"This is probably a bug in the action, please open an issue" "This is probably a bug in the action, please open an issue",
); );
} }
let pkg = packages[0]; let pkg = packages[0];
@@ -166,14 +166,16 @@ export async function runPublish({
const requireChangesetsCliPkgJson = (cwd: string) => { const requireChangesetsCliPkgJson = (cwd: string) => {
try { try {
return require(require.resolve("@changesets/cli/package.json", { return require(
require.resolve("@changesets/cli/package.json", {
paths: [cwd], paths: [cwd],
})); }),
);
} catch (err) { } catch (err) {
if (isErrorWithCode(err, "MODULE_NOT_FOUND")) { if (isErrorWithCode(err, "MODULE_NOT_FOUND")) {
throw new Error( throw new Error(
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`, `Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`,
{ cause: err } { cause: err },
); );
} }
throw err; throw err;
@@ -309,7 +311,7 @@ export async function runVersion({
{ {
cwd, cwd,
env, env,
} },
); );
} }
@@ -318,7 +320,7 @@ export async function runVersion({
changedPackages.map(async (pkg) => { changedPackages.map(async (pkg) => {
let changelogContents = await fs.readFile( let changelogContents = await fs.readFile(
path.join(pkg.dir, "CHANGELOG.md"), path.join(pkg.dir, "CHANGELOG.md"),
"utf8" "utf8",
); );
let entry = getChangelogEntry(changelogContents, pkg.packageJson.version); let entry = getChangelogEntry(changelogContents, pkg.packageJson.version);
@@ -328,7 +330,7 @@ export async function runVersion({
content: entry.content, content: entry.content,
header: `## ${pkg.packageJson.name}@${pkg.packageJson.version}`, header: `## ${pkg.packageJson.name}@${pkg.packageJson.version}`,
}; };
}) }),
); );
const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`; const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`;
@@ -353,8 +355,8 @@ export async function runVersion({
`Existing pull requests: ${JSON.stringify( `Existing pull requests: ${JSON.stringify(
existingPullRequests.data, existingPullRequests.data,
null, null,
2 2,
)}` )}`,
); );
await git.pushChanges({ branch: versionBranch, message: finalCommitMessage }); await git.pushChanges({ branch: versionBranch, message: finalCommitMessage });
+7 -7
View File
@@ -1,11 +1,11 @@
import unified from "unified";
import remarkParse from "remark-parse";
import remarkStringify from "remark-stringify";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import { getPackages, type Package } from "@manypkg/get-packages";
import type { Root } from "mdast"; import type { Root } from "mdast";
// @ts-ignore // @ts-ignore
import mdastToString from "mdast-util-to-string"; import mdastToString from "mdast-util-to-string";
import { getPackages, type Package } from "@manypkg/get-packages"; import remarkParse from "remark-parse";
import remarkStringify from "remark-stringify";
import unified from "unified";
export const BumpLevels = { export const BumpLevels = {
dep: 0, dep: 0,
@@ -21,7 +21,7 @@ export async function getVersionsByDirectory(cwd: string) {
export async function getChangedPackages( export async function getChangedPackages(
cwd: string, cwd: string,
previousVersions: Map<string, string> previousVersions: Map<string, string>,
) { ) {
let { packages } = await getPackages(cwd); let { packages } = await getPackages(cwd);
let changedPackages = new Set<Package>(); let changedPackages = new Set<Package>();
@@ -87,7 +87,7 @@ export function getChangelogEntry(changelog: string, version: string) {
export function sortTheThings( export function sortTheThings(
a: { private: boolean; highestLevel: number }, a: { private: boolean; highestLevel: number },
b: { private: boolean; highestLevel: number } b: { private: boolean; highestLevel: number },
) { ) {
if (a.private === b.private) { if (a.private === b.private) {
return b.highestLevel - a.highestLevel; return b.highestLevel - a.highestLevel;
@@ -110,6 +110,6 @@ export function isErrorWithCode(err: unknown, code: string) {
export function fileExists(filePath: string) { export function fileExists(filePath: string) {
return fs.access(filePath, fs.constants.F_OK).then( return fs.access(filePath, fs.constants.F_OK).then(
() => true, () => true,
() => false () => false,
); );
} }
+1 -1
View File
@@ -7,7 +7,7 @@ type Opts = {
declare module "fixturez" { declare module "fixturez" {
export default function ( export default function (
cwd: string, cwd: string,
opts?: Opts opts?: Opts,
): { ): {
find: (a: string) => string; find: (a: string) => string;
temp: () => string; temp: () => string;