Skip to content

Commit

Permalink
Update publish-native script for wasm change (#57472)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Oct 26, 2023
1 parent 4bc549b commit d670c5c
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions scripts/publish-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,60 +74,60 @@ const cwd = process.cwd()
)

// Update name/version of wasm packages and publish
const pkgDirectory = 'packages/next-swc/crates/wasm'
let wasmDir = path.join(cwd, pkgDirectory)
// const pkgDirectory = 'packages/next-swc/crates/wasm'
// let wasmDir = path.join(cwd, pkgDirectory)

await Promise.all(
['web', 'nodejs'].map(async (wasmTarget) => {
await publishSema.acquire()
// await Promise.all(
// ['web', 'nodejs'].map(async (wasmTarget) => {
// await publishSema.acquire()

let wasmPkg = JSON.parse(
await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
)
wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
wasmPkg.version = version
wasmPkg.repository = {
type: 'git',
url: 'https://github.com/vercel/next.js',
directory: pkgDirectory,
}
// let wasmPkg = JSON.parse(
// await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
// )
// wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
// wasmPkg.version = version
// wasmPkg.repository = {
// type: 'git',
// url: 'https://github.com/vercel/next.js',
// directory: pkgDirectory,
// }

await writeFile(
path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
JSON.stringify(wasmPkg, null, 2)
)
// await writeFile(
// path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
// JSON.stringify(wasmPkg, null, 2)
// )

try {
await execa(
`npm`,
[
'publish',
`${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
'--access',
'public',
...(version.includes('canary') ? ['--tag', 'canary'] : []),
],
{ stdio: 'inherit' }
)
} catch (err) {
// don't block publishing other versions on single platform error
console.error(`Failed to publish`, wasmTarget, err)
// try {
// await execa(
// `npm`,
// [
// 'publish',
// `${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
// '--access',
// 'public',
// ...(version.includes('canary') ? ['--tag', 'canary'] : []),
// ],
// { stdio: 'inherit' }
// )
// } catch (err) {
// // don't block publishing other versions on single platform error
// console.error(`Failed to publish`, wasmTarget, err)

if (
err.message &&
err.message.includes(
'You cannot publish over the previously published versions'
)
) {
console.error('Ignoring already published error', wasmTarget)
} else {
// throw err
}
} finally {
publishSema.release()
}
})
)
// if (
// err.message &&
// err.message.includes(
// 'You cannot publish over the previously published versions'
// )
// ) {
// console.error('Ignoring already published error', wasmTarget)
// } else {
// // throw err
// }
// } finally {
// publishSema.release()
// }
// })
// )

// Update optional dependencies versions
let nextPkg = JSON.parse(
Expand Down

0 comments on commit d670c5c

Please sign in to comment.