(
{ tree, format, configFilename, isEsm }: WriteContext,
resolved: ScopedPluginResult[],
targetDir: string,
tool: MonorepoTool,
)
| 118 | } |
| 119 | |
| 120 | async function writeMonorepoConfigs( |
| 121 | { tree, format, configFilename, isEsm }: WriteContext, |
| 122 | resolved: ScopedPluginResult[], |
| 123 | targetDir: string, |
| 124 | tool: MonorepoTool, |
| 125 | ): Promise<void> { |
| 126 | const projectResults = resolved |
| 127 | .filter(r => r.scope === 'project') |
| 128 | .map(r => r.result); |
| 129 | |
| 130 | const rootResults = resolved |
| 131 | .filter(r => r.scope === 'root') |
| 132 | .map(r => r.result); |
| 133 | |
| 134 | const presetFilename = resolveFilename('code-pushup.preset', format, isEsm); |
| 135 | await tree.write( |
| 136 | presetFilename, |
| 137 | generatePresetSource(projectResults, format), |
| 138 | ); |
| 139 | |
| 140 | if (rootResults.length > 0) { |
| 141 | await tree.write(configFilename, generateConfigSource(rootResults, format)); |
| 142 | } |
| 143 | |
| 144 | const projects = await listProjects(targetDir, tool); |
| 145 | await Promise.all( |
| 146 | projects.map(async project => { |
| 147 | const importPath = computeRelativePresetImport( |
| 148 | project.relativeDir, |
| 149 | presetFilename, |
| 150 | ); |
| 151 | await tree.write( |
| 152 | toUnixPath(path.join(project.relativeDir, configFilename)), |
| 153 | generateProjectSource(project.name, importPath), |
| 154 | ); |
| 155 | await addCodePushUpCommand(tree, project, tool); |
| 156 | }), |
| 157 | ); |
| 158 | } |
| 159 | |
| 160 | async function finalize(tree: Tree, dryRun?: boolean): Promise<void> { |
| 161 | logger.newline(); |
no test coverage detected