Nuxt/scripts/bump-edge.ts

37 lines
1.3 KiB
TypeScript
Raw Normal View History

import { execSync } from 'node:child_process'
import { $fetch } from 'ofetch'
import { inc } from 'semver'
2023-04-20 09:40:07 +00:00
import { determineBumpType, loadWorkspace } from './_utils'
async function main () {
const workspace = await loadWorkspace(process.cwd())
const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim().slice(0, 8)
const date = Math.round(Date.now() / (1000 * 60))
const nuxtPkg = workspace.find('nuxt')
const { version: latestNitro } = await $fetch<{ version: string }>('https://registry.npmjs.org/nitropack-edge/latest')
nuxtPkg.data.dependencies.nitropack = `npm:nitropack-edge@^${latestNitro}`
const { version: latestNuxi } = await $fetch<{ version: string }>('https://registry.npmjs.org/nuxi-ng/latest')
nuxtPkg.data.dependencies.nuxi = `npm:nuxi-ng@^${latestNuxi}`
2023-04-20 09:40:07 +00:00
const bumpType = await determineBumpType()
for (const pkg of workspace.packages.filter(p => !p.data.private)) {
2023-03-07 21:36:58 +00:00
const newVersion = inc(pkg.data.version, bumpType || 'patch')
workspace.setVersion(pkg.data.name, `${newVersion}-${date}.${commit}`, {
updateDeps: true
})
const newname = pkg.data.name === 'nuxt' ? 'nuxt3' : (pkg.data.name + '-edge')
workspace.rename(pkg.data.name, newname)
}
await workspace.save()
}
main().catch((err) => {
console.error(err)
process.exit(1)
})