/
update-package-to-tsc.ts
42 lines (34 loc) · 1012 Bytes
/
update-package-to-tsc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
addDependenciesToPackageJson,
formatFiles,
getProjects,
Tree,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { nxVersion } from '@nrwl/workspace/src/utils/versions';
export default async function update(host: Tree) {
const projects = getProjects(host);
let installNeeded = false;
for (const [name, config] of projects.entries()) {
if (config?.targets?.build?.executor !== '@nrwl/node:package') continue;
config.targets.build.executor = '@nrwl/js:tsc';
const transformers = config.targets.build.options?.tsPlugins;
if (transformers) {
delete config.targets.build.options.tsPlugins;
config.targets.build.options.transformers = transformers;
}
installNeeded = true;
updateProjectConfiguration(host, name, config);
}
const task = installNeeded
? addDependenciesToPackageJson(
host,
{},
{
'@nrwl/js': nxVersion,
}
)
: undefined;
await formatFiles(host);
return task;
}