Closed Serg-Mois closed 3 years ago
I think this can be improved :+1:
I usually end up writing a workspace-generator
.
Question though, some workspaces have @nrwl/angular
projects as well as @nrwl/nest
projects which have a different generator: @nrwl/nest:convert-tslint-to-eslint
.
If we introduced nx g @nrwl/angular:convert-tslint-to-eslint --all
, do you think it makes sense to only migrate Angular projects? And similarly @nrwl/nest:convert-tslint-eslint --all
, would only migrate nest projects? We would need some sort of heuristic to determine projects associated with Angular/Nest. All this also goes for Cypress as well :sweat_smile:
cc @JamesHenry What do you think?
I thought @JamesHenry initially fixed this here? https://github.com/nrwl/nx/pull/4943 or did I misunderstand this original issue? https://github.com/nrwl/nx/issues/4320. I have to agree that running this command for tons of projects is not ideal
@FrozenPandaz, @JamesHenry and I had discussion not long ago about converging the convert-tslint-to-eslint
logic and decision was to leave it as is, due to fine differences and better readability.
We can use project graph
's dependencies to distinguish whether given project is nest
, angular
or cypress
(most likely marked with e2e
already. Question is do we want to have a global --all
or per type?
Maybe if you provide --all
you have to provide the framework too? That way the CLI tool isn't stuck with that responsibility?
It will still have to know whether given project has certain framework so we wouldn't save much. And the responsibility wouldn't be in the CLI, but @nrwl/workspace
project.
Yes our original resolution on this was that any bulk usage would live in userland (for the reasons already cited above).
We would have to write quite a bit of code to inspect everyone's workspaces and figure out what converter to use, whereas you would already have a big headstart in terms of knowledge of your own very specific workspace.
If you only have Angular projects, here is a real example that a user submitted for converting all Angular projects using a bash one-liner: https://github.com/nrwl/nx/issues/4320#issuecomment-810162696
for project in $(cat angular.json | npx json projects | npx json -M -a key); do ng generate @nrwl/angular:convert-tslint-to-eslint --project=$project --no-interactive; done
You could adapt this to run on only nest or cypress projects for example (although note cypress projects which are linked to Angular apps are handled automatically by the Angular converter so that may not be necessary in the common case).
I think you can honestly get pretty far with minimal scripting with knowledge of your specific workspace. Generalising the solution to work on all possible workspaces, however, is far more work as was noted and that is why there is no --all
.
If you need more sophisticated logic and would prefer not to hack it together in bash, this is a great use-case for a workspace generator as Jason already noted above.
You can find the workspace generator guide here: https://nx.dev/l/a/generators/workspace-generators
And you would simply import the relevant Nrwl converter generators and use them. E.g. the libraryGenerator
is used as an example in the linked guide:
import { Tree, formatFiles, installPackagesTask } from '@nrwl/devkit';
import { libraryGenerator } from '@nrwl/workspace';
export default async function (tree: Tree, schema: any) {
await libraryGenerator(tree, { name: schema.name });
await formatFiles(tree);
return () => {
installPackagesTask(tree);
};
}
Hope that helps, if you run into specific difficulties with any of the above advice feel free to ask any questions
You would replace that with one or more conversion generators depending on whether or not you want to convert Angular, Nest and Cypress or some more granular mixture.
Hi @Serg-Mois, just a gentle ping.
Was answer from @JamesHenry enough to resolve your issue or do you have a followup on this?
@meeroslav It's not my issue, It's just a suggestion. Of course, I created a simple node.js script that reads angular.json and runs commands for all projects separately.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Description
In @nrwl/angular:convert-tslint-to-eslint we have to specify the project that we want to migrate. But nx repo may consist of thousands of small projects in 'libs' folder. How to migrate all projects/modules in the repo to eslint?