Skip to content
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

[Bug]: Issues while using some of the codemod with different version of recast installed #22902

Open
100terres opened this issue Jun 2, 2023 · 0 comments

Comments

@100terres
Copy link

100terres commented Jun 2, 2023

Describe the bug

Hi thank you for all the work you are doing!

I've face an issue while doing some codemod (to migrate to v7).

Here's the bug I faced when running npx storybook@latest migrate csf-2-to-3:

 Transformation error (The expression evaluated to a falsy value:    assert_1.default.ok(lines instanceof linesModule.Lines) )
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert_1.default.ok(lines instanceof linesModule.Lines)

This happens when there are multiple version of recast installed. benjamn/recast#645 (comment)

Here's what I had installed:

$ npm ls recast
REDACTED
├─┬ @storybook/addon-docs@7.0.18
│ └─┬ @storybook/csf-tools@7.0.18
│   └── recast@0.23.1 deduped
├─┬ @types/jscodeshift@0.11.6
│ └── recast@0.20.5
├─┬ apollo@2.34.0
│ └─┬ apollo-codegen-core@0.40.9
│   └── recast@0.21.5
├─┬ jscodeshift@0.15.0 invalid: "^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0" from node_modules/jscodeshift-add-imports
│ └── recast@0.23.1
└─┬ storybook@7.0.18
  └─┬ @storybook/cli@7.0.18
    ├─┬ @storybook/codemod@7.0.18
    │ ├─┬ jscodeshift@0.14.0
    │ │ └── recast@0.21.5
    │ └── recast@0.23.1 deduped
    └─┬ jscodeshift@0.14.0
      └── recast@0.21.5

I was able to fix the issue by ensuring that there's only one version of recast installed on my porject:

// package.json
{
  // ...
  "overrides": {
    "recast": "0.23.1"
  }
}

With the override here's what I now have:

$ npm ls recast
REDACTED
├─┬ @storybook/addon-docs@7.0.18
│ └─┬ @storybook/csf-tools@7.0.18
│   └── recast@0.23.1 deduped
├─┬ @types/jscodeshift@0.11.6
│ └── recast@0.23.1
├─┬ apollo@2.34.0
│ └─┬ apollo-codegen-core@0.40.9
│   └── recast@0.23.1 deduped
├─┬ jscodeshift@0.15.0 invalid: "^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0" from node_modules/jscodeshift-add-imports
│ └── recast@0.23.1 deduped
└─┬ storybook@7.0.18
  └─┬ @storybook/cli@7.0.18
    ├─┬ @storybook/codemod@7.0.18
    │ ├─┬ jscodeshift@0.14.0
    │ │ └── recast@0.23.1 deduped
    │ └── recast@0.23.1 deduped
    └─┬ jscodeshift@0.14.0
      └── recast@0.23.1 deduped

Now I'm able to run:

npx storybook@latest migrate csf-2-to-3

I think one fix would be to ensure that all storybook module are using the same version of recast.

To Reproduce

No response

System

No response

Additional context

No response

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

No branches or pull requests

2 participants