Trouble getting codemod to run on my project
samselikoff opened this issue · 16 comments
I tried to run this codemod on one of EmberMap's templates and I'm having trouble getting it to work. It's strange because I just used this on a different project the other day.
Here's the command I ran:
npx ember-angle-brackets-codemod http://localhost:4200 ./app/pods/about/template.hbs
And the template seems pretty standard:
View template
The codemod runs then says that there was 1 unmodified file. There were some errors.
View terminal output
npx ember-angle-brackets-codemod http://localhost:4200 ./app/pods/about/template.hbs Downloading Chromium r686378 - 110.2 Mb [====================] 100% 0.0s
error evaluating `@fortawesome/free-brands-svg-icons`: Cannot read property 'proto' of undefined
error evaluating `@fortawesome/free-solid-svg-icons`: Cannot read property 'proto' of undefined
error evaluating `@fortawesome/pro-regular-svg-icons`: Cannot read property 'proto' of undefined
error evaluating `ember-cli-mirage/db-collection`: Cannot set property default of #<Object> which has only a getter
error evaluating `ember-composable-helpers/-private/closure-action`: Cannot read property 'proto' of null
error evaluating `ember-map/components/code-snippet`: Could not find module `highlight.js` imported from `(require)`
error evaluating `ember-map/ember-focus-method/tests/app.lint-test`: QUnit is not defined
error evaluating `ember-map/pods/components/md-text/component`: Could not find module `ember-remarkable/components/md-text` imported from `ember-map/pods/components/md-text/
component`
error evaluating `ember-map/styles/tailwind`: module is not defined
error evaluating `ember-map/tests/mirage/mirage.lint-test`: QUnit is not defined
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
All done.
Results:
0 errors
1 unmodified
0 skipped
0 ok
Time elapsed: 9.506seconds
Would appreciate any tips on how to go about debugging this!
@samselikoff if I remember you use pods for EmberMap. The codemod does not support pods layout.
My apologies that this is not in the readme. I will update it.
Oh wow that’s surprising. Even if I point at a specific file? Does it have to do with the resolver?
Is there a manual way to run it on a pods app?
@samselikoff Just throwing it from the top of my head, will this help
find ./app/pods -name "*.hbs" | xargs npx ember-angle-brackets-codemod http://localhost:4200
I haven't tried it.
The thing is I originally ran this
npx ember-angle-brackets-codemod http://localhost:4200 ./app/pods/about/template.hbs
so I already pointed to an individual file, so I don't think that's it. Think it's something else in the code.
There is also the issue with telemetry. Some of the logic works only with non-pod structures to determine helpers and components. The good news however is I am working on reducing the need to rely on telemetry and file paths to more of a “type of invocation” to figure out what is component/helper.
In regards to single file, it should work, but again the telemetry will likely block you.
Oh wow that’s surprising. Even if I point at a specific file? Does it have to do with the resolver?
Is there a manual way to run it on a pods app?
@samselikoff In order to use it with pods you'll have to use 1.4.12 version
You can install it locally like:
npm install --save https://github.com/ember-codemods/ember-angle-brackets-codemod/archive/v1.4.12.tar.gz
After that you can run it like:
npx ember-angle-brackets-codemod angle-brackets ./app/pods/about/template.hbs
And if you set config file correctly you'll be able to update some folder with templates at once
I ran into the problem as well, after Installing 1.4.12 I combined everything above into the following command, which worked for me:
yarn add https://github.com/ember-codemods/ember-angle-brackets-codemod/archive/v1.4.12.tar.gz
and
find ./app/pods -name "*.hbs" | xargs npx ember-angle-brackets-codemod angle-brackets
.
Edit: I needed to remove the codemod from package.json afterwards, as running the server failed with an error: The "id" argument must be of type string. Received type undefined
I'm just curious, b/c I see both of the above examples mention ./app/pods
, does that mean this codemod won't work only if you are using podModulePrefix, or will it not work are using pods at all (i.e. usePods: true
).
I believe that the codemod cannot infer anything from telemetry when pods structure is in use.
Thank you.
So if #287 lands podModulePrefix
users should be able to run:
npx ember-angle-brackets-codemod --no-telemetry ./app/pods/**/*.hbs
or non podModulePrefix
users like myself should be able to run:
npx ember-angle-brackets-codemod --no-telemetry ./app/**/*.hbs
right?
Yes, I think that is correct.
@rwjblue is there anything fundamentally preventing this codemod from being used with pods with telemetry or is it just a matter of someone putting in the work?
@runspired I know I'm not @rwjblue 😂 but the transform "should work" now since we infer as much as possible without using telemetry. I believe you can use the --no-telemetry
on pods to get this to work. There are some caveats. Some helpers may need to be put in a skip config if it is too ambiguous to determine if they are a component. Additionally there is some limitation on converting some block parameters ( @Turbo87 has better detection code in ember-template-lint
) that would be awesome to port here.
I ran this on a 700+ file codebase with minimal interaction. I hope this helps.
npx ember-angle-brackets-codemod --no-telemetry ./app/pods/**/*.hbs
thanks, @tomwayson! worked for my app with pods structure like a charm 👍
For those who land on this issue, I wrote a codemod to un-pod Ember projects. Feel free to give it a try.