Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): cache --outputFile (#6852)
- Loading branch information
1 parent
387af0c
commit a7f8950
Showing
21 changed files
with
190 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ Object { | |
"apps/e2e-app-1/**/*.{js,ts}", | ||
], | ||
}, | ||
"outputs": Array [ | ||
"{options.outputFile}", | ||
], | ||
}, | ||
}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/linter/src/migrations/update-12-9-0/add-outputs.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
addProjectConfiguration, | ||
readProjectConfiguration, | ||
TargetConfiguration, | ||
Tree, | ||
} from '@nrwl/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import addOutputs from './add-outputs'; | ||
|
||
describe('addOutputs', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
|
||
const lintWithoutOutputs: TargetConfiguration = { | ||
executor: '@nrwl/linter:eslint', | ||
options: {}, | ||
}; | ||
const lintWithOutputs: TargetConfiguration = { | ||
executor: '@nrwl/linter:eslint', | ||
outputs: ['dist'], | ||
options: {}, | ||
}; | ||
const notLint: TargetConfiguration = { | ||
executor: '@nrwl/node:build', | ||
options: {}, | ||
}; | ||
|
||
addProjectConfiguration(tree, 'proj', { | ||
root: 'proj', | ||
targets: { | ||
lintWithoutOutputs, | ||
lintWithOutputs, | ||
notLint, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should add outputs to targets that do not have outputs', async () => { | ||
await addOutputs(tree); | ||
|
||
expect(readProjectConfiguration(tree, 'proj')).toMatchInlineSnapshot(` | ||
Object { | ||
"root": "proj", | ||
"targets": Object { | ||
"lintWithOutputs": Object { | ||
"executor": "@nrwl/linter:eslint", | ||
"options": Object {}, | ||
"outputs": Array [ | ||
"dist", | ||
], | ||
}, | ||
"lintWithoutOutputs": Object { | ||
"executor": "@nrwl/linter:eslint", | ||
"options": Object {}, | ||
"outputs": Array [ | ||
"{options.outputFile}", | ||
], | ||
}, | ||
"notLint": Object { | ||
"executor": "@nrwl/node:build", | ||
"options": Object {}, | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/linter/src/migrations/update-12-9-0/add-outputs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
formatFiles, | ||
getProjects, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
|
||
export default async function addOutputs(tree: Tree) { | ||
for (const [projectName, project] of getProjects(tree)) { | ||
if (!project.targets) { | ||
continue; | ||
} | ||
|
||
for (const target of Object.values(project.targets)) { | ||
if (target.executor !== '@nrwl/linter:eslint' || target.outputs) { | ||
continue; | ||
} | ||
|
||
target.outputs = ['{options.outputFile}']; | ||
|
||
updateProjectConfiguration(tree, projectName, project); | ||
} | ||
} | ||
|
||
await formatFiles(tree); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,9 @@ Object { | |
"libs/my-lib/**/*.ts", | ||
], | ||
}, | ||
"outputs": Array [ | ||
"{options.outputFile}", | ||
], | ||
} | ||
`; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.