Skip to content

Commit

Permalink
feat(core): add migration to add lint target
Browse files Browse the repository at this point in the history
Add a migration that updates existing projects with the new lint target.
  • Loading branch information
Ben Callaghan committed May 19, 2021
1 parent d320ce8 commit e391744
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/core/migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"generators": {
"add-lint-target": {
"version": "0.7.0",
"description": "Adds lint target to all existing dotnet projects",
"cli": "nx",
"implementation": "./src/migrations/add-lint-target/add-lint-target"
}
}
}
5 changes: 4 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
},
"bugs": {
"url": "https://github.com/nx-dotnet/nx-dotnet/issues/new?assignees=&labels=bug%2C+needs-triage&template=bug_report.md&title=%5BBUG%5D+"
},
"nx-migrate": {
"migrations": "./migrations.json"
}
}
}
11 changes: 11 additions & 0 deletions packages/core/src/migrations/add-lint-target/add-lint-target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Tree, updateProjectConfiguration } from '@nrwl/devkit';
import { getNxDotnetProjects } from '@nx-dotnet/utils';
import { GetLintExecutorConfiguration } from '../../models';

export default function update(host: Tree) {
const projects = getNxDotnetProjects(host);
for (const [name, project] of projects) {
project.targets.lint ??= GetLintExecutorConfiguration();
updateProjectConfiguration(host, name, project);
}
}
7 changes: 6 additions & 1 deletion workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@
},
"LICENSE",
"CHANGELOG.md",
"README.md"
"README.md",
{
"input": "./packages/core",
"glob": "migrations.json",
"output": "."
}
]
}
}
Expand Down

0 comments on commit e391744

Please sign in to comment.