Nuxt/scripts/bump-edge.ts

41 lines
1.2 KiB
TypeScript
Raw Normal View History

import { execSync } from 'node:child_process'
import { inc } from 'semver'
import { consola } from 'consola'
2023-04-20 09:40:07 +00:00
import { determineBumpType, loadWorkspace } from './_utils'
const nightlyPackages = {
nitropack: 'nitropack-nightly',
h3: 'h3-nightly',
nuxi: 'nuxi-nightly',
}
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))
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,
})
for (const [name, nightlyName] of Object.entries(nightlyPackages)) {
2023-08-11 15:14:49 +00:00
if (pkg.data.dependencies && name in pkg.data.dependencies) {
pkg.data.dependencies[name] = `npm:${nightlyName}@latest`
}
}
const newname = pkg.data.name + '-nightly'
workspace.rename(pkg.data.name, newname)
}
await workspace.save()
}
main().catch((err) => {
consola.error(err)
process.exit(1)
})