2022-04-15 15:19:05 +00:00
|
|
|
import { execSync } from 'node:child_process'
|
2022-08-31 19:17:42 +00:00
|
|
|
import { inc } from 'semver'
|
2023-09-19 21:26:15 +00:00
|
|
|
import { consola } from 'consola'
|
2023-04-20 09:40:07 +00:00
|
|
|
import { determineBumpType, loadWorkspace } from './_utils'
|
2021-07-01 12:58:27 +00:00
|
|
|
|
2023-08-11 13:11:51 +00:00
|
|
|
const nightlyPackages = {
|
2023-10-19 13:31:17 +00:00
|
|
|
nitropack: 'nitropack-nightly',
|
2023-08-11 13:11:51 +00:00
|
|
|
h3: 'h3-nightly',
|
2023-10-12 14:17:38 +00:00
|
|
|
nuxi: 'nuxi-nightly'
|
2023-08-11 13:11:51 +00:00
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
|
2023-04-20 09:40:07 +00:00
|
|
|
const bumpType = await determineBumpType()
|
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
|
|
|
|
})
|
2023-08-11 13:11:51 +00:00
|
|
|
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) {
|
2023-08-11 13:11:51 +00:00
|
|
|
pkg.data.dependencies[name] = `npm:${nightlyName}@latest`
|
|
|
|
}
|
|
|
|
}
|
2023-10-12 14:17:38 +00:00
|
|
|
const newname = pkg.data.name + '-nightly'
|
2022-04-20 08:52:39 +00:00
|
|
|
workspace.rename(pkg.data.name, newname)
|
2021-07-01 12:58:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await workspace.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch((err) => {
|
2023-09-19 21:26:15 +00:00
|
|
|
consola.error(err)
|
2021-07-01 12:58:27 +00:00
|
|
|
process.exit(1)
|
|
|
|
})
|