Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@
"lodash": "4.18.1"
},
"overrides": {
"@types/react": "16.14.69",
"@types/react-dom": "16.9.25",
"lodash": "4.18.1"
"@types/react": "^16.14.69",
"@types/react-dom": "^16.9.25",
"lodash": "^4.18.1"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
6 changes: 3 additions & 3 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"release": "node --loader=ts-node/esm ./release.mts"
},
"dependencies": {
"@changesets/read": "^0.5.7",
"@changesets/read": "^0.6.7",
"ts-node": "^10.9.1",
"typescript": "^4.8.3",
"zx": "^7.0.8"
"typescript": "^4.9.5",
"zx": "^8.8.5"
}
}
32 changes: 15 additions & 17 deletions scripts/release.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
* Publish snapshot releases as a tarball to github releases
*/
import 'zx/globals'
import _readChangesets from '@changesets/read'
// See https://github.com/changesets/changesets/issues/622
const readChangesets =
_readChangesets.default as (typeof import('@changesets/read/dist/declarations/src/index.js'))['default']
import readChangesets from '@changesets/read'

// These paths are relative to the git root
const ASSETS_DIR = './assets'
Expand Down Expand Up @@ -131,15 +128,19 @@ async function maybeConsumeVersions() {
* Checks if a release already exists under the given git tag.
*/
async function checkIfReleaseExists(gitTag: string): Promise<boolean> {
return await $`gh release view ${gitTag}`
.then((p) => {
debug(p.stdout)
return true
})
.catch((p: ProcessOutput) => {
try {
const processOutput = await $`gh release view ${gitTag}`
debug(processOutput.stdout)
return true
} catch(err: unknown) {
if (err && typeof err === "object" && "stderr" in err) {
const p = err as ProcessOutput
debug(p.stderr)
return false
})
} else {
console.error("Unknown error occurred while checking if release exists.", err)
}
return false
}
}

async function pkgToTarball(packDir: string) {
Expand All @@ -149,18 +150,15 @@ async function pkgToTarball(packDir: string) {
const packOutput = await $`npm pack --pack-destination ${packDir} --json`
const packInfos: NpmPack[] = JSON.parse(packOutput.stdout)
const [packInfo] = packInfos
// The actual file name that `npm pack` creates has @ and / symbols replaced
// The actual file name that `yarn pack` creates has @ and / symbols replaced
const filename = packInfo.filename.replace('@', '').replace('/', '-')
const gitTag = `v${packInfo.version}`

return { gitTag, filename }
}

async function setup() {
// Set zx verbosity based on DEBUG env var
if (!process.env.DEBUG) {
$.verbose = false
}
$.verbose = !!process.env.DEBUG // Set zx verbosity based on DEBUG env var
await runAtGitRoot()
await checkExternalScriptDependencies()
}
Expand Down
Loading
Loading