2022-04-15 15:19:05 +00:00
|
|
|
import { execSync } from 'node:child_process'
|
2022-11-15 14:33:43 +00:00
|
|
|
import { $fetch } from 'ofetch'
|
2022-08-31 19:17:42 +00:00
|
|
|
import { inc } from 'semver'
|
2023-03-02 16:57:55 +00:00
|
|
|
import { getGitDiff, determineSemverChange, loadChangelogConfig, parseCommits } from 'changelogen'
|
|
|
|
import { execaSync } from 'execa'
|
2022-10-17 10:10:05 +00:00
|
|
|
import { loadWorkspace } from './_utils'
|
2021-07-01 12:58:27 +00:00
|
|
|
|
|
|
|
async function main () {
|
|
|
|
const workspace = await loadWorkspace(process.cwd())
|
|
|
|
|
|
|
|
const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim()
|
|
|
|
const date = Math.round(Date.now() / (1000 * 60))
|
|
|
|
|
2022-08-30 08:40:09 +00:00
|
|
|
const nuxtPkg = workspace.find('nuxt')
|
|
|
|
const nitroInfo = await $fetch('https://registry.npmjs.org/nitropack-edge')
|
|
|
|
const latestNitro = nitroInfo['dist-tags'].latest
|
|
|
|
nuxtPkg.data.dependencies.nitropack = `npm:nitropack-edge@^${latestNitro}`
|
|
|
|
|
2023-03-02 16:57:55 +00:00
|
|
|
const config = await loadChangelogConfig(process.cwd())
|
|
|
|
|
|
|
|
const latestTag = execaSync('git', ['describe', '--tags', '--abbrev=0']).stdout
|
|
|
|
|
|
|
|
const commits = await getGitDiff(latestTag)
|
|
|
|
const bumpType = determineSemverChange(parseCommits(commits, config), config)
|
|
|
|
|
2021-07-01 12:58:27 +00:00
|
|
|
for (const pkg of workspace.packages.filter(p => !p.data.private)) {
|
2023-03-02 16:57:55 +00:00
|
|
|
const newVersion = inc(pkg.data.version, bumpType || 'prerelease')
|
2022-08-31 19:17:42 +00:00
|
|
|
workspace.setVersion(pkg.data.name, `${newVersion}-${date}.${commit}`)
|
2022-04-20 08:52:39 +00:00
|
|
|
const newname = pkg.data.name === 'nuxt' ? 'nuxt3' : (pkg.data.name + '-edge')
|
|
|
|
workspace.rename(pkg.data.name, newname)
|
2021-07-01 12:58:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await workspace.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch((err) => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|