Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .github/scripts/upgrade-deps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import fs from 'node:fs'
import path from 'node:path'

const ROOT = process.cwd()

// ============ GitHub API ============
Comment thread
Brooooooklyn marked this conversation as resolved.
async function getLatestTagCommit(owner, repo) {
const res = await fetch(
`https://api.github.com/repos/${owner}/${repo}/tags`,
{
headers: {
Authorization: `token ${process.env.GITHUB_TOKEN}`,
Accept: 'application/vnd.github.v3+json',
},
}
)
if (!res.ok) {
throw new Error(
`Failed to fetch tags for ${owner}/${repo}: ${res.status} ${res.statusText}`
)
}
const tags = await res.json()
if (!Array.isArray(tags) || !tags.length) {
throw new Error(`No tags found for ${owner}/${repo}`)
}
if (!tags[0]?.commit?.sha) {
throw new Error(
`Invalid tag structure for ${owner}/${repo}: missing commit SHA`
)
}
return tags[0].commit.sha
Comment thread
Brooooooklyn marked this conversation as resolved.
}
Comment thread
Brooooooklyn marked this conversation as resolved.

// ============ npm Registry ============
Comment thread
Brooooooklyn marked this conversation as resolved.
async function getLatestNpmVersion(packageName) {
const res = await fetch(`https://registry.npmjs.org/${packageName}/latest`)
if (!res.ok) {
throw new Error(
`Failed to fetch npm version for ${packageName}: ${res.status} ${res.statusText}`
)
}
const data = await res.json()
if (!data?.version) {
throw new Error(
`Invalid npm response for ${packageName}: missing version field`
)
}
return data.version
}
Comment thread
Brooooooklyn marked this conversation as resolved.
Comment thread
Brooooooklyn marked this conversation as resolved.

// ============ Update .upstream-versions.json ============
Comment thread
Brooooooklyn marked this conversation as resolved.
async function updateUpstreamVersions() {
const filePath = path.join(ROOT, 'packages/tools/.upstream-versions.json')
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'))

// rolldown -> rolldown/rolldown
data.rolldown.hash = await getLatestTagCommit('rolldown', 'rolldown')

// rolldown-vite -> vitejs/vite
data['rolldown-vite'].hash = await getLatestTagCommit('vitejs', 'vite')

fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n')
console.log('Updated .upstream-versions.json')
Comment thread
Brooooooklyn marked this conversation as resolved.
}

// ============ Update pnpm-workspace.yaml ============
Comment thread
Brooooooklyn marked this conversation as resolved.
async function updatePnpmWorkspace(vitestVersion, tsdownVersion) {
const filePath = path.join(ROOT, 'pnpm-workspace.yaml')
let content = fs.readFileSync(filePath, 'utf8')

// Update vitest-dev override (handle pre-release versions like -beta.1, -rc.0)
content = content.replace(
/vitest-dev: 'npm:vitest@\^[\d.]+(-[\w.]+)?'/,
`vitest-dev: 'npm:vitest@^${vitestVersion}'`
)
Comment thread
Brooooooklyn marked this conversation as resolved.

// Update tsdown in catalog (handle pre-release versions)
content = content.replace(
/tsdown: \^[\d.]+(-[\w.]+)?/,
`tsdown: ^${tsdownVersion}`
)

fs.writeFileSync(filePath, content)
console.log('Updated pnpm-workspace.yaml')
}
Comment thread
Brooooooklyn marked this conversation as resolved.

// ============ Update packages/test/package.json ============
Comment thread
Brooooooklyn marked this conversation as resolved.
async function updateTestPackage(vitestVersion) {
const filePath = path.join(ROOT, 'packages/test/package.json')
const pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'))

// Update all @vitest/* devDependencies
for (const dep of Object.keys(pkg.devDependencies)) {
if (dep.startsWith('@vitest/')) {
pkg.devDependencies[dep] = vitestVersion
Comment thread
Brooooooklyn marked this conversation as resolved.
}
Comment thread
Brooooooklyn marked this conversation as resolved.
Comment thread
Brooooooklyn marked this conversation as resolved.
}
Comment thread
Brooooooklyn marked this conversation as resolved.
Comment thread
Brooooooklyn marked this conversation as resolved.

// Update vitest-dev devDependency
if (pkg.devDependencies['vitest-dev']) {
pkg.devDependencies['vitest-dev'] = `^${vitestVersion}`
Comment thread
Brooooooklyn marked this conversation as resolved.
}

// Update @vitest/ui peerDependency if present
if (pkg.peerDependencies?.['@vitest/ui']) {
pkg.peerDependencies['@vitest/ui'] = vitestVersion
Comment thread
Brooooooklyn marked this conversation as resolved.
}

fs.writeFileSync(filePath, JSON.stringify(pkg, null, 2) + '\n')
console.log('Updated packages/test/package.json')
}

// ============ Update packages/core/package.json ============
async function updateCorePackage(devtoolsVersion) {
Comment thread
Brooooooklyn marked this conversation as resolved.
const filePath = path.join(ROOT, 'packages/core/package.json')
const pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'))

// Update @vitejs/devtools in devDependencies
if (pkg.devDependencies?.['@vitejs/devtools']) {
pkg.devDependencies['@vitejs/devtools'] = `^${devtoolsVersion}`
}

fs.writeFileSync(filePath, JSON.stringify(pkg, null, 2) + '\n')
console.log('Updated packages/core/package.json')
}

// ============ Main ============
async function main() {
console.log('Fetching latest versions...')

const [vitestVersion, tsdownVersion, devtoolsVersion] = await Promise.all([
getLatestNpmVersion('vitest'),
getLatestNpmVersion('tsdown'),
getLatestNpmVersion('@vitejs/devtools'),
])

console.log(`vitest: ${vitestVersion}`)
console.log(`tsdown: ${tsdownVersion}`)
console.log(`@vitejs/devtools: ${devtoolsVersion}`)

await updateUpstreamVersions()
await updatePnpmWorkspace(vitestVersion, tsdownVersion)
await updateTestPackage(vitestVersion)
await updateCorePackage(devtoolsVersion)

console.log('Done!')
}
Comment thread
Brooooooklyn marked this conversation as resolved.

main().catch((err) => {
console.error(err)
process.exit(1)
})
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ jobs:
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: lint
tools: dprint,cargo-shear
tools: cargo-shear
components: clippy rust-docs rustfmt

- run: |
dprint check
cargo shear
cargo fmt --check
# cargo clippy --all-targets --all-features -- -D warnings
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- main
- deps/upstream-update
paths-ignore:
- '**/*.md'
pull_request:
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/upgrade-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Upgrade Upstream Dependencies

on:
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
Comment thread
Brooooooklyn marked this conversation as resolved.
workflow_dispatch: # Manual trigger

permissions: {}

jobs:
upgrade:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/clone

- name: Configure Git for access to vite-task
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
Comment thread
Brooooooklyn marked this conversation as resolved.
Comment thread
Brooooooklyn marked this conversation as resolved.

- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: upgrade-deps

- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4

- name: Rustup Adds Target
run: rustup target add x86_64-unknown-linux-gnu

- name: Rustup Adds Target for rolldown
working-directory: rolldown
run: rustup target add x86_64-unknown-linux-gnu

- name: Upgrade dependencies
id: upgrade
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .github/scripts/upgrade-deps.mjs
Comment thread
Brooooooklyn marked this conversation as resolved.

- name: Sync remote and build
id: build
continue-on-error: true # Create PR even if build fails
Comment thread
Brooooooklyn marked this conversation as resolved.
Comment thread
Brooooooklyn marked this conversation as resolved.
run: |
pnpm install --no-frozen-lockfile
pnpm tool sync-remote
pnpm install --no-frozen-lockfile

Comment thread
Brooooooklyn marked this conversation as resolved.
- name: Build
uses: ./.github/actions/build-upstream
with:
target: x86_64-unknown-linux-gnu
build-rolldown-native: 'true'
Comment thread
Brooooooklyn marked this conversation as resolved.
Comment thread
Brooooooklyn marked this conversation as resolved.

- name: Update lockfile
Comment thread
Brooooooklyn marked this conversation as resolved.
run: |
pnpm install --no-frozen-lockfile
Comment thread
Brooooooklyn marked this conversation as resolved.
pnpm dedupe

- name: Close and delete previous PR
env:
GH_TOKEN: ${{ secrets.AUTO_UPDATE_BRANCH_TOKEN }}
run: |
# Find PR with the deps/upstream-update branch
PR_NUMBER=$(gh pr list --head deps/upstream-update --json number --jq '.[0].number')

if [ -n "$PR_NUMBER" ]; then
echo "Found existing PR #$PR_NUMBER, closing and deleting branch..."
gh pr close "$PR_NUMBER" --delete-branch
else
echo "No existing PR found with branch deps/upstream-update"
fi

Comment thread
Brooooooklyn marked this conversation as resolved.
- name: Create/Update PR
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
with:
base: main
branch: deps/upstream-update
Comment thread
Brooooooklyn marked this conversation as resolved.
title: 'feat(deps): upgrade upstream dependencies'
sign-commits: true
token: ${{ secrets.AUTO_UPDATE_BRANCH_TOKEN }}
branch-token: ${{ secrets.GITHUB_TOKEN }}
body: |
Automated daily upgrade of upstream dependencies:
- rolldown (latest tag)
- rolldown-vite (latest tag)
- vitest (latest npm version)
- tsdown (latest npm version)

Build status: ${{ steps.build.outcome }}
commit-message: 'feat(deps): upgrade upstream dependencies'
32 changes: 0 additions & 32 deletions dprint.json

This file was deleted.

2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ watch *args='':
fmt:
cargo shear --fix
cargo fmt --all
dprint fmt
pnpm fmt

check:
cargo check --workspace --all-features --all-targets --locked
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@
"vitest": "catalog:"
},
"lint-staged": {
"*.@(yml|yaml|md|json|html|toml)": [
"dprint fmt --staged"
],
"*.@(js|ts|tsx)": [
"oxlint -- --fix",
"vite fmt"
"oxlint -- --fix"
],
"*.rs": [
"cargo fmt --"
Expand Down
9 changes: 5 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
},
"./dist/client/*": "./dist/vite/client/*",
"./internal": "./dist/vite/node/internal.js",
"./lib": {
"default": "./dist/tsdown/index.js",
"types": "./dist/tsdown/index-types.d.ts"
},
Comment thread
Brooooooklyn marked this conversation as resolved.
"./module-runner": "./dist/vite/node/module-runner.js",
"./package.json": "./package.json",
"./rolldown": {
Expand Down Expand Up @@ -48,10 +52,6 @@
"default": "./dist/pluginutils/index.js",
"types": "./dist/pluginutils/index.d.ts"
},
"./lib": {
"default": "./dist/tsdown/index.js",
"types": "./dist/tsdown/index-types.d.ts"
},
"./types/*": {
"types": "./dist/vite/types/*"
},
Expand Down Expand Up @@ -166,6 +166,7 @@
"devDependencies": {
"@oxc-node/cli": "catalog:",
"@oxc-node/core": "catalog:",
"@vitejs/devtools": "^0.0.0-alpha.18",
"es-module-lexer": "^1.7.0",
"hookable": "^6.0.1",
"magic-string": "^0.30.21",
Expand Down
Loading
Loading