tldraw/scripts/publish-canary.ts
Dan Groshev e6e4e7f6cb
[dx] use Biome instead of Prettier, part 2 (#2731)
Biome seems to be MUCH faster than Prettier. Unfortunately, it
introduces some formatting changes around the ternary operator, so we
have to update files in the repo. To make revert easier if we need it,
the change is split into two PRs. This PR introduces a Biome CI check
and reformats all files accordingly.

## Change Type
- [x] `minor` — New feature
2024-02-05 17:54:02 +00:00

39 lines
1.1 KiB
TypeScript

import { exec } from './lib/exec'
import { nicelog } from './lib/nicelog'
import { getLatestVersion, publish, setAllVersions } from './lib/publishing'
async function main() {
const sha = (await exec('git', ['rev-parse', 'HEAD'])).trim().slice(0, 12)
async function setCanaryVersions(bump: 'major' | 'minor' | 'patch') {
const latestVersion = getLatestVersion()
const nextVersion = latestVersion.prerelease.length
? // if the package is in prerelease mode, we want to release a canary for the current version rather than bumping
latestVersion
: latestVersion?.inc(bump)
const versionString = `${nextVersion.major}.${nextVersion.minor}.${nextVersion.patch}-canary.${sha}`
setAllVersions(versionString)
}
// module was called directly
const bumpType = (await exec('npx', ['auto', 'version'])).trim() as
| 'major'
| 'minor'
| 'patch'
| ''
nicelog('bumpType', bumpType)
if (bumpType === '') {
nicelog('nothing to do')
} else if (['major', 'minor', 'patch'].includes(bumpType)) {
nicelog('setting canary versions')
setCanaryVersions(bumpType)
publish()
} else {
throw new Error('Invalid bump type provided')
}
}
main()