Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
167 lines
5.6 KiB
JavaScript
167 lines
5.6 KiB
JavaScript
// @ts-check
|
|
const execa = require('execa')
|
|
const fs = require('node:fs/promises')
|
|
const os = require('node:os')
|
|
const path = require('node:path')
|
|
|
|
async function main() {
|
|
const [
|
|
githubHeadSha,
|
|
tarballDirectory = path.join(os.tmpdir(), 'vercel-nextjs-preview-tarballs'),
|
|
] = process.argv.slice(2)
|
|
const repoRoot = path.resolve(__dirname, '..')
|
|
|
|
await fs.mkdir(tarballDirectory, { recursive: true })
|
|
|
|
// The preview version is set in packages/next/package.json by
|
|
// scripts/set-preview-version.js before the build step.
|
|
const nextPackageJson = JSON.parse(
|
|
await fs.readFile(path.join(repoRoot, 'packages/next/package.json'), 'utf8')
|
|
)
|
|
const version = nextPackageJson.version
|
|
console.info(`Designated version: ${version}`)
|
|
|
|
const nativePackagesDir = path.join(repoRoot, 'crates/next-napi-bindings/npm')
|
|
const platforms = (await fs.readdir(nativePackagesDir)).filter(
|
|
(name) => !name.startsWith('.')
|
|
)
|
|
|
|
console.info(`Creating tarballs for next-swc packages`)
|
|
const nextSwcPackageNames = new Set()
|
|
await Promise.all(
|
|
platforms.map(async (platform) => {
|
|
const binaryName = `next-swc.${platform}.node`
|
|
try {
|
|
await fs.cp(
|
|
path.join(repoRoot, 'packages/next-swc/native', binaryName),
|
|
path.join(nativePackagesDir, platform, binaryName)
|
|
)
|
|
} catch (error) {
|
|
if (error.code === 'ENOENT') {
|
|
console.warn(
|
|
`Skipping next-swc platform '${platform}' tarball creation because ${binaryName} was never built.`
|
|
)
|
|
return
|
|
}
|
|
throw error
|
|
}
|
|
const manifest = JSON.parse(
|
|
await fs.readFile(
|
|
path.join(nativePackagesDir, platform, 'package.json'),
|
|
'utf8'
|
|
)
|
|
)
|
|
manifest.version = version
|
|
await fs.writeFile(
|
|
path.join(nativePackagesDir, platform, 'package.json'),
|
|
JSON.stringify(manifest, null, 2) + '\n'
|
|
)
|
|
// By encoding the package name in the directory, vercel-packages can later extract the package name of a tarball from its path when `tarballDirectory` is zipped.
|
|
const packDestination = path.join(tarballDirectory, manifest.name)
|
|
await fs.mkdir(packDestination, { recursive: true })
|
|
const { stdout } = await execa(
|
|
'npm',
|
|
['pack', '--pack-destination', packDestination],
|
|
{
|
|
cwd: path.join(nativePackagesDir, platform),
|
|
}
|
|
)
|
|
// tarball name is printed as the last line of npm-pack
|
|
const tarballName = stdout.trim().split('\n').pop()
|
|
console.info(`Created tarball ${path.join(packDestination, tarballName)}`)
|
|
|
|
nextSwcPackageNames.add(manifest.name)
|
|
})
|
|
)
|
|
|
|
const lernaListJson = await execa('pnpm', [
|
|
'--silent',
|
|
'lerna',
|
|
'list',
|
|
'--json',
|
|
])
|
|
const packages = JSON.parse(lernaListJson.stdout)
|
|
const packagesByVersion = new Map()
|
|
// vercel-packages finds GH artifacts via the head SHA because that's the only
|
|
// API GitHub offers.
|
|
for (const packageInfo of packages) {
|
|
packagesByVersion.set(
|
|
packageInfo.name,
|
|
`https://vercel-packages.vercel.app/next/commits/${githubHeadSha}/${packageInfo.name}`
|
|
)
|
|
}
|
|
for (const nextSwcPackageName of nextSwcPackageNames) {
|
|
packagesByVersion.set(
|
|
nextSwcPackageName,
|
|
`https://vercel-packages.vercel.app/next/commits/${githubHeadSha}/${nextSwcPackageName}`
|
|
)
|
|
}
|
|
|
|
console.info(`Creating tarballs for regular packages`)
|
|
for (const packageInfo of packages) {
|
|
if (packageInfo.private) {
|
|
continue
|
|
}
|
|
|
|
const packageJsonPath = path.join(packageInfo.location, 'package.json')
|
|
const packageJson = await fs.readFile(packageJsonPath, 'utf8')
|
|
const manifest = JSON.parse(packageJson)
|
|
|
|
manifest.version = version
|
|
|
|
if (packageInfo.name === 'next') {
|
|
manifest.optionalDependencies ??= {}
|
|
for (const nextSwcPackageName of nextSwcPackageNames) {
|
|
manifest.optionalDependencies[nextSwcPackageName] =
|
|
packagesByVersion.get(nextSwcPackageName)
|
|
}
|
|
}
|
|
|
|
// ensure it depends on packages from this release.
|
|
for (const [dependencyName, version] of packagesByVersion) {
|
|
if (manifest.dependencies?.[dependencyName] !== undefined) {
|
|
manifest.dependencies[dependencyName] = version
|
|
}
|
|
if (manifest.devDependencies?.[dependencyName] !== undefined) {
|
|
manifest.devDependencies[dependencyName] = version
|
|
}
|
|
if (manifest.peerDependencies?.[dependencyName] !== undefined) {
|
|
manifest.peerDependencies[dependencyName] = version
|
|
}
|
|
if (manifest.optionalDependencies?.[dependencyName] !== undefined) {
|
|
manifest.optionalDependencies[dependencyName] = version
|
|
}
|
|
}
|
|
|
|
await fs.writeFile(
|
|
packageJsonPath,
|
|
JSON.stringify(manifest, null, 2) +
|
|
// newline will be added by Prettier
|
|
'\n'
|
|
)
|
|
|
|
// By encoding the package name in the directory, vercel-packages can later extract the package name of a tarball from its path when `tarballDirectory` is zipped.
|
|
const packDestination = path.join(tarballDirectory, manifest.name)
|
|
await fs.mkdir(packDestination, { recursive: true })
|
|
const { stdout } = await execa(
|
|
'npm',
|
|
['pack', '--pack-destination', packDestination],
|
|
{
|
|
cwd: packageInfo.location,
|
|
}
|
|
)
|
|
// tarball name is printed as the last line of npm-pack
|
|
const tarballName = stdout.trim().split('\n').pop()
|
|
console.info(`Created tarball ${path.join(packDestination, tarballName)}`)
|
|
}
|
|
|
|
console.info(
|
|
`When this job is completed, a Next.js preview build will be available under ${packagesByVersion.get('next')}`
|
|
)
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|