Skip to content

Expose codegen CLI from the package exports #4976

Open
@markerikson

Description

@markerikson

@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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions