Skip to content

nx release publish is confused by react-native-macos's prepublish script. #2580

@Saadnajmi

Description

@Saadnajmi

Problem

nx release publish (which we currently use to publish to NPM) will call npm publish, which calls, npm pack, which calls prepack, which invokes node scripts/prepack.js. This script does a bunch of stuff (move a README, run codegen) that prints to stdout. nx release tries to parse the stdout of npm publish as JSON, and get's confused by the output of our prepack script.

Output of npm publish

sanajmi@Saads-MacBook-Pro-14 react-native-macos-2 % npm publish ./packages/react-native

> [email protected] prepack
> node ./scripts/prepack.js

[Prepack] Copying README.md
[Codegen] Searching for codegen-enabled libraries in the app.
[Codegen] Found react-native-macos
[Codegen] Processing rncore

Output of yarn nx release publish

> nx run react-native-macos:nx-release-publish

Something unexpected went wrong when processing the yarn publish output
 SyntaxError: Unexpected token P in JSON at position 1
    at JSON.parse (<anonymous>)
    at runExecutor (/mnt/vss/_work/1/s/node_modules/@nx/js/src/executors/release-publish/release-publish.impl.js:286:37)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async promiseToIterator (/mnt/vss/_work/1/s/node_modules/nx/src/command-line/run/run.js:36:11)
    at async getLastValueFromAsyncIterableIterator (/mnt/vss/_work/1/s/node_modules/nx/src/utils/async-iterator.js:15:19)
    at async iteratorToProcessStatusCode (/mnt/vss/_work/1/s/node_modules/nx/src/command-line/run/run.js:39:25)
    at async handleErrors (/mnt/vss/_work/1/s/node_modules/nx/src/utils/handle-errors.js:8:24)
    at async process.<anonymous> (/mnt/vss/_work/1/s/node_modules/nx/bin/run-executor.js:59:28)

Long term solution

Update Yarn to support the --json flag, and maybe suppress output of lifecycle scripts: yarnpkg/berry#6850

Short term solution

Replace our call to nx release publish with yarn npm publish directly (the Yarn V4 version of the command). Not ideal because we will need to do this once for every package we want to publish, in the currect order. But, we only have two packages we publish... so it should be OK.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions