2018-10-17 21:28:25 +00:00
|
|
|
import consola from 'consola'
|
|
|
|
|
|
|
|
import Package from './package.js'
|
|
|
|
|
2019-11-27 19:51:48 +00:00
|
|
|
async function main () {
|
2018-10-17 21:28:25 +00:00
|
|
|
// Read package at current directory
|
|
|
|
const rootPackage = new Package()
|
2018-11-27 15:32:00 +00:00
|
|
|
const workspacePackages = await rootPackage.getWorkspacePackages()
|
2018-10-17 21:28:25 +00:00
|
|
|
|
|
|
|
const watch = process.argv.includes('--watch')
|
|
|
|
|
|
|
|
if (watch) {
|
|
|
|
consola.info('Watch mode')
|
|
|
|
}
|
|
|
|
|
|
|
|
// Universal linkedDependencies based on workspace
|
|
|
|
const linkedDependencies = workspacePackages
|
|
|
|
.map(p => p.pkg.name.replace(p.options.suffix, ''))
|
|
|
|
|
|
|
|
for (const pkg of workspacePackages) {
|
|
|
|
pkg.options.linkedDependencies = (pkg.options.linkedDependencies || [])
|
|
|
|
.concat(linkedDependencies)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 1: Apply suffixes
|
|
|
|
for (const pkg of workspacePackages) {
|
|
|
|
if (pkg.options.suffix && pkg.options.suffix.length) {
|
2020-06-04 08:25:53 +00:00
|
|
|
pkg.suffixAndVersion()
|
2018-11-28 18:44:11 +00:00
|
|
|
await pkg.writePackage()
|
2018-10-17 21:28:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 2: Build packages
|
|
|
|
for (const pkg of workspacePackages) {
|
|
|
|
if (pkg.options.build) {
|
|
|
|
if (watch) {
|
|
|
|
pkg.watch()
|
|
|
|
} else {
|
|
|
|
await pkg.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 3: Link dependencies and Fix packages
|
|
|
|
for (const pkg of workspacePackages) {
|
|
|
|
pkg.syncLinkedDependencies()
|
|
|
|
pkg.autoFix()
|
|
|
|
pkg.writePackage()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch((error) => {
|
|
|
|
consola.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
})
|