Skip to content

Commit

Permalink
fix(angular): prevent nested calls to formatFiles in generators (#15946)
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Mar 29, 2023
1 parent 8fd5bcf commit d20bf77
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 11 deletions.
7 changes: 6 additions & 1 deletion packages/angular/src/generators/add-linting/add-linting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
formatFiles,
GeneratorCallback,
joinPathFragments,
runTasksInSerial,
Expand Down Expand Up @@ -41,10 +42,14 @@ export async function addLintingGenerator(
);

if (!options.skipPackageJson) {
const installTask = await addAngularEsLintDependencies(tree);
const installTask = addAngularEsLintDependencies(tree);
tasks.push(installTask);
}

if (!options.skipFormat) {
await formatFiles(tree);
}

return runTasksInSerial(...tasks);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
directory: options.directory,
project: options.name,
linter: options.linter,
skipFormat: options.skipFormat,
standaloneConfig: options.standaloneConfig,
skipPackageJson: options.skipPackageJson,
skipFormat: true,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
setParserOptionsProject: options.setParserOptionsProject,
skipPackageJson: options.skipPackageJson,
unitTestRunner: options.unitTestRunner,
skipFormat: true,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
supportTsx: false,
skipSerializers: false,
skipPackageJson: options.skipPackageJson,
skipFormat: true,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function conversionGenerator(
* does and remove the config again if it doesn't, so that it is most efficient.
*/
setParserOptionsProject: true,
skipFormat: options.skipFormat,
skipFormat: true,
});
},
});
Expand Down Expand Up @@ -105,7 +105,7 @@ export async function conversionGenerator(
* step of this parent generator, if applicable
*/
removeTSLintIfNoMoreTSLintTargets: false,
skipFormat: options.skipFormat,
skipFormat: true,
});
} catch {
logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export function cleanupEsLintPackages(tree: Tree): void {
export async function createWorkspaceFiles(tree: Tree): Promise<void> {
updateVsCodeRecommendedExtensions(tree);

await jsInitGenerator(tree, {});
await jsInitGenerator(tree, { skipFormat: true });

generateFiles(tree, joinPathFragments(__dirname, '../files/root'), '.', {
tmpl: '',
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/generators/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export async function remote(tree: Tree, options: Schema) {
standalone: options.standalone ?? false,
routing: true,
port,
skipFormat: true,
});

const skipE2E =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export async function scamDirectiveGenerator(tree: Tree, rawOptions: Schema) {
skipImport: true,
export: false,
standalone: false,
skipFormat: true,
});

const pipeFileInfo = getDirectiveFileInfo(tree, options);
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/generators/scam-pipe/scam-pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export async function scamPipeGenerator(tree: Tree, rawOptions: Schema) {
skipImport: true,
export: false,
standalone: false,
skipFormat: true,
});

const pipeFileInfo = getPipeFileInfo(tree, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export function updateHostAppRoutes(tree: Tree, options: Schema) {
tree.write(
joinPathFragments(sourceRoot, 'app/app.component.html'),
`<ul class="remote-menu">
<li><a routerLink='/'>Home</a></li>
${remoteRoutes}
<li><a routerLink='/'>Home</a></li>${remoteRoutes}
</ul>
<router-outlet></router-outlet>
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export async function generateStories(
options.configureCypress && options.generateCypressSpecs,
cypressProject: e2eProjectName,
ignorePaths: options.ignorePaths,
skipFormat: true,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export async function generateStorybookConfiguration(
configureTestRunner: options.configureTestRunner,
storybook7Configuration: options.storybook7Configuration,
configureStaticServe: options.configureStaticServe,
skipFormat: true,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
updateJson,
} from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
import applicationGenerator from '../../generators/application/application';
import libraryGenerator from '../../generators/library/library';
import {
generateTestApplication,
generateTestLibrary,
} from '../../generators/utils/testing';
import { updateTestingTsconfigForJest } from './update-testing-tsconfig';

let projectGraph: ProjectGraph;
Expand Down Expand Up @@ -68,7 +70,7 @@ describe('Jest+Ng - 15.9.0 - tsconfig updates', () => {
});

async function setup(tree: Tree, name: string) {
await applicationGenerator(tree, {
await generateTestApplication(tree, {
name,
skipPackageJson: true,
});
Expand All @@ -79,7 +81,7 @@ async function setup(tree: Tree, name: string) {
return json;
});

await libraryGenerator(tree, {
await generateTestLibrary(tree, {
name: `${name}-lib`,
});

Expand Down

0 comments on commit d20bf77

Please sign in to comment.