Skip to content

Expose codegen CLI from the package exports #4976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
markerikson opened this issue May 8, 2025 · 1 comment · May be fixed by #4977
Open

Expose codegen CLI from the package exports #4976

markerikson opened this issue May 8, 2025 · 1 comment · May be fixed by #4977

Comments

@markerikson
Copy link
Collaborator

@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

maddrag0n added a commit to useorbital/redux-toolkit that referenced this issue May 9, 2025
@maddrag0n maddrag0n linked a pull request May 9, 2025 that will close this issue
maddrag0n added a commit to useorbital/redux-toolkit that referenced this issue May 9, 2025
maddrag0n added a commit to useorbital/redux-toolkit that referenced this issue May 9, 2025
maddrag0n added a commit to useorbital/redux-toolkit that referenced this issue May 9, 2025
maddrag0n added a commit to useorbital/redux-toolkit that referenced this issue May 9, 2025
@maddrag0n
Copy link

workaround until #4977 is merged and released:

const cliPath = require.resolve('@rtk-query/codegen-openapi')
  .split('/')
  .slice(0, -1)
  .join('/')
  + '/bin/cli.mjs';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants