Skip to content

Commit

Permalink
chore(setup): add build command
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Jun 30, 2020
1 parent b02702b commit 7165331
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function getCommitEnvVar(name: string): string {
}

async function main() {
const buildOnly = process.argv[2] === '--build'

if (process.env.BUILDKITE_TAG && !process.env.RELEASE_PROMOTE_DEV) {
throw new Error(`When providing BUILDKITE_TAG, you also need to provide the env var RELEASE_PROMOTE_DEV, which
has to point to the dev version you want to promote, for example 2.1.0-dev.123`)
Expand All @@ -39,24 +41,43 @@ has to point to the dev version you want to promote, for example 2.1.0-dev.123`)
})
}

debug(`Installing dependencies, building packages`)

const rawPackages = await getPackages()
const packages = getPackageDependencies(rawPackages)
const publishOrder = getPublishOrder(packages)

console.log(publishOrder)
if (!buildOnly) {
debug(`Installing dependencies`)

await run(
'.',
`pnpm i --no-prefer-frozen-lockfile -r --ignore-scripts`,
).catch((e) => {})
}

debug(`Building packages`)

await run(
'.',
`pnpm i --no-prefer-frozen-lockfile -r --ignore-scripts`,
).catch((e) => {})
for (const batch of publishOrder) {
await pMap(batch, async (pkgName) => {
const pkg = packages[pkgName]
const pkgDir = path.dirname(pkg.path)
await run(pkgDir, 'pnpm run build')
})
await pMap(
batch,
async (pkgName) => {
const pkg = packages[pkgName]
const pkgDir = path.dirname(pkg.path)
const runPromise = run(pkgDir, 'pnpm run build')

// we want to build all in build-only to see all errors at once
if (buildOnly) {
runPromise.catch(console.error)
}

await runPromise
},
{ concurrency: 1 },
)
}

if (buildOnly) {
return
}

// this should not be necessary, it's an pnpm bug
Expand Down

0 comments on commit 7165331

Please sign in to comment.