chore: esm compatible scripts
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
import fse from 'fs-extra'
|
import fse from 'fs-extra'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
const packagesDir = path.resolve(__dirname, '../../packages')
|
const packagesDir = path.resolve(__dirname, '../../packages')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { ExecSyncOptions } from 'child_process'
|
import type { ExecSyncOptions } from 'child_process'
|
||||||
|
import { execSync } from 'child_process'
|
||||||
|
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import { execSync } from 'child_process'
|
|
||||||
import execa from 'execa'
|
import execa from 'execa'
|
||||||
import fse from 'fs-extra'
|
import fse from 'fs-extra'
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
@@ -12,6 +12,7 @@ import simpleGit from 'simple-git'
|
|||||||
|
|
||||||
import { getPackageDetails } from './lib/getPackageDetails'
|
import { getPackageDetails } from './lib/getPackageDetails'
|
||||||
import { updateChangelog } from './utils/updateChangelog'
|
import { updateChangelog } from './utils/updateChangelog'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
// Update this list with any packages to publish
|
// Update this list with any packages to publish
|
||||||
const packageWhitelist = [
|
const packageWhitelist = [
|
||||||
@@ -20,14 +21,20 @@ const packageWhitelist = [
|
|||||||
'ui',
|
'ui',
|
||||||
'next',
|
'next',
|
||||||
'graphql',
|
'graphql',
|
||||||
|
|
||||||
'db-mongodb',
|
'db-mongodb',
|
||||||
|
'db-postgres',
|
||||||
'richtext-slate',
|
'richtext-slate',
|
||||||
|
'richtext-lexical',
|
||||||
|
'plugin-cloud',
|
||||||
|
'plugin-cloud-storage',
|
||||||
|
'plugin-seo',
|
||||||
]
|
]
|
||||||
|
|
||||||
const rootPath = path.resolve(__dirname, '..')
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
const cwd = path.resolve(__dirname, '..')
|
||||||
|
|
||||||
const git = simpleGit(rootPath)
|
const git = simpleGit(cwd)
|
||||||
|
|
||||||
const execOpts: ExecSyncOptions = { stdio: 'inherit' }
|
const execOpts: ExecSyncOptions = { stdio: 'inherit' }
|
||||||
const args = minimist(process.argv.slice(2))
|
const args = minimist(process.argv.slice(2))
|
||||||
@@ -120,16 +127,12 @@ async function main() {
|
|||||||
|
|
||||||
// Prebuild all packages
|
// Prebuild all packages
|
||||||
header(`\n🔨 Prebuilding all packages...`)
|
header(`\n🔨 Prebuilding all packages...`)
|
||||||
await execa('pnpm', ['install'], {
|
|
||||||
cwd: rootPath,
|
|
||||||
stdio: 'inherit',
|
|
||||||
})
|
|
||||||
|
|
||||||
const buildResult = await execa('pnpm', ['build:core', '--output-logs=errors-only'], {
|
const execaOpts: execa.Options = { ...execOpts, stdio: 'inherit' }
|
||||||
cwd: rootPath,
|
|
||||||
// stdio: ['ignore', 'ignore', 'pipe'],
|
await execa('pnpm', ['install'], execaOpts)
|
||||||
stdio: 'inherit',
|
|
||||||
})
|
const buildResult = await execa('pnpm', ['build:core', '--output-logs=errors-only'], execaOpts)
|
||||||
// const buildResult = execSync('pnpm build:all', execOpts)
|
// const buildResult = execSync('pnpm build:all', execOpts)
|
||||||
if (buildResult.exitCode !== 0) {
|
if (buildResult.exitCode !== 0) {
|
||||||
console.error(chalk.bold.red('Build failed'))
|
console.error(chalk.bold.red('Build failed'))
|
||||||
@@ -137,10 +140,22 @@ async function main() {
|
|||||||
abort('Build failed')
|
abort('Build failed')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const buildPluginsResult = await execa(
|
||||||
|
'pnpm',
|
||||||
|
['build:plugins', '--output-logs=errors-only'],
|
||||||
|
execaOpts,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (buildPluginsResult.exitCode !== 0) {
|
||||||
|
console.error(chalk.bold.red('Build failed'))
|
||||||
|
console.log(buildPluginsResult.stderr)
|
||||||
|
abort('Build failed')
|
||||||
|
}
|
||||||
|
|
||||||
// Update changelog
|
// Update changelog
|
||||||
if (changelog) {
|
if (changelog) {
|
||||||
header(`${logPrefix}📝 Updating changelog...`)
|
header(`${logPrefix}📝 Updating changelog...`)
|
||||||
await updateChangelog({ newVersion: nextReleaseVersion, dryRun })
|
await updateChangelog({ dryRun, newVersion: nextReleaseVersion })
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.bold.yellow('📝 Skipping changelog update'))
|
console.log(chalk.bold.yellow('📝 Skipping changelog update'))
|
||||||
}
|
}
|
||||||
@@ -191,7 +206,7 @@ async function main() {
|
|||||||
cmdArgs.push('--otp', otp)
|
cmdArgs.push('--otp', otp)
|
||||||
}
|
}
|
||||||
const { exitCode } = await execa('pnpm', cmdArgs, {
|
const { exitCode } = await execa('pnpm', cmdArgs, {
|
||||||
cwd: rootPath,
|
cwd,
|
||||||
stdio: ['ignore', 'ignore', 'pipe'],
|
stdio: ['ignore', 'ignore', 'pipe'],
|
||||||
// stdio: 'inherit',
|
// stdio: 'inherit',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ import addStream from 'add-stream'
|
|||||||
import conventionalChangelog from 'conventional-changelog'
|
import conventionalChangelog from 'conventional-changelog'
|
||||||
import { default as getConventionalPreset } from 'conventional-changelog-conventionalcommits'
|
import { default as getConventionalPreset } from 'conventional-changelog-conventionalcommits'
|
||||||
import { once } from 'events'
|
import { once } from 'events'
|
||||||
import fse, { createReadStream, createWriteStream } from 'fs-extra'
|
import fse from 'fs-extra'
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
import simpleGit from 'simple-git'
|
import simpleGit from 'simple-git'
|
||||||
import tempfile from 'tempfile'
|
import tempfile from 'tempfile'
|
||||||
|
|
||||||
|
const { createReadStream, createWriteStream } = fse
|
||||||
|
|
||||||
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
|
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
|
||||||
const git = simpleGit()
|
const git = simpleGit()
|
||||||
|
|
||||||
@@ -105,8 +107,9 @@ export const updateChangelog = async ({ newVersion, dryRun }: Args) => {
|
|||||||
await once(emitter, 'finish')
|
await once(emitter, 'finish')
|
||||||
}
|
}
|
||||||
|
|
||||||
// If file is executed directly, run the function
|
// module import workaround for ejs
|
||||||
if (require.main === module) {
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
|
// This module is being run directly
|
||||||
const { newVersion } = minimist(process.argv.slice(2))
|
const { newVersion } = minimist(process.argv.slice(2))
|
||||||
updateChangelog({ dryRun: true, newVersion })
|
updateChangelog({ dryRun: true, newVersion })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user