redux-toolkit
redux-toolkit copied to clipboard
Expose codegen CLI from the package exports
@markerikson we are calling the cli programmatically like this
const cliPath = require.resolve('@rtk-query/codegen-openapi/lib/bin/cli'); const runReduxCodegen = async (specUrl: string | undefined, configPath: string, outputPath: string): Promise<void> => ( new Promise((resolve, reject) => { exec( `tsx ${cliPath} ${configPath}`, { env: { ...process.env, SPEC_URL: specUrl, STORE_ROOT_PATH: outputPath, }, }, (error, stdout, stderr) => { if (error) { console.error(`exec error: ${error}`); reject(new Error(`Execution failed with error: ${stderr || 'Unknown error'}`)); } else { console.log(stdout); if (stderr) { reject(new Error(`Execution produced errors: ${stderr}`)); } else { resolve(); } } }, ); }) );when upgrading from 1.2.0 to 2.0.0, the error message is that /lib/bin/cli is not in exports of the package
nodeLinker is pnp
Originally posted by @maddrag0n in #4974
workaround until https://github.com/reduxjs/redux-toolkit/pull/4977 is merged and released:
const cliPath = require.resolve('@rtk-query/codegen-openapi')
.split('/')
.slice(0, -1)
.join('/')
+ '/bin/cli.mjs';