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-04-07 16:02:47 +00:00
|
|
|
import { determineSemverChange, getGitDiff, loadChangelogConfig, parseCommits } from 'changelogen'
|
2023-03-02 16:57:55 +00:00
|
|
|
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())
|
|
|
|
|
2023-03-06 22:20:07 +00:00
|
|
|
const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim().slice(0, 8)
|
2021-07-01 12:58:27 +00:00
|
|
|
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())
|
|
|
|
|
2023-03-03 10:45:47 +00:00
|
|
|
const latestTag = execaSync('git', ['describe', '--tags', '--abbrev=0']).stdout
|
2023-03-02 16:57:55 +00:00
|
|
|
|
|
|
|
const commits = await getGitDiff(latestTag)
|
2023-03-07 21:36:58 +00:00
|
|
|
let bumpType = determineSemverChange(parseCommits(commits, config), config)
|
|
|
|
if (bumpType === 'major') { bumpType = 'minor' } // 🙈
|
2023-03-02 16:57:55 +00:00
|
|
|
|
2021-07-01 12:58:27 +00:00
|
|
|
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')
|
2023-03-28 15:53:00 +00:00
|
|
|
workspace.setVersion(pkg.data.name, `${newVersion}-${date}.${commit}`, {
|
|
|
|
updateDeps: true
|
|
|
|
})
|
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)
|
|
|
|
})
|