hypermod-community icon indicating copy to clipboard operation
hypermod-community copied to clipboard

pnpm workspace support

Open danieldelcore opened this issue 2 years ago • 0 comments

Originally submitted to Discord: https://discord.com/channels/1062245324732768347/1062248060702437376/1086273854072172544

I'm trying to run codeshift in a monorepo following this guide: https://www.codeshiftcommunity.com/docs/monorepos, but when I get the the Development step: https://www.codeshiftcommunity.com/docs/monorepos/#development the CLI does not find any codemods, in the docs it says that it will leverage the workspace (we are using pnpm workspaces), but when I run the command there are no codemods in the list. if I create a codeshift.config.js in the root of the dir and I add the transform which is in one of my packages, then it works. am I doing something wrong? here is an example of the codeshift.config.js which i'm required to add at the root dir

module.exports = {
  maintainers: [],
  targets: [],
  description: 'Codemods for compat',

  transforms: {
    '1.0.0': require.resolve('./packages/compat/codemods/1.0.0/transform'),
  },

  presets: {},
};

For the docs, my understanding is that it should be able to read this already from my packages dir, for example ./packages/compat/codeshift.config.js ?

to note, we are using type:"module" in our packages, so my configs are .cjs instead. (I also tried without the cjs and type:"modules" but it's still the same issue)

I found the entry point for workspaces: https://github.com/CodeshiftCommunity/CodeshiftCommunity/blob/main/packages/cli/src/main.ts#L51C4-L87 but this means it's not always valid, for example in pnpm you define workspaces with the pnpm-workspace.yaml (https://pnpm.io/pnpm-workspace_yaml), defining it in packages does fix the issue.

danieldelcore avatar Mar 23 '23 09:03 danieldelcore