Skip to content

Commit

Permalink
feat(core): Update plugin generators so that they are formatted by de…
Browse files Browse the repository at this point in the history
…fault (#28593)
  • Loading branch information
ndcunningham authored Oct 31, 2024
1 parent 178d93d commit c2e3112
Show file tree
Hide file tree
Showing 104 changed files with 1,209 additions and 949 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ describe('AppComponent', () => {
`;
exports[`app --minimal should skip "nx-welcome.component.ts" file and references for non-standalone apps with routing 4`] = `
"<h1>Welcome plain</h1> <router-outlet></router-outlet>
"<h1>Welcome plain</h1>
<router-outlet></router-outlet>
"
`;
Expand Down Expand Up @@ -116,7 +117,7 @@ describe('AppComponent', () => {
`;
exports[`app --minimal should skip "nx-welcome.component.ts" file and references for non-standalone apps without routing 4`] = `
"<h1>Welcome plain</h1>
"<h1>Welcome plain</h1>
"
`;
Expand Down Expand Up @@ -160,7 +161,8 @@ describe('AppComponent', () => {
`;
exports[`app --minimal should skip "nx-welcome.component.ts" file and references for standalone apps with routing 3`] = `
"<h1>Welcome plain</h1> <router-outlet></router-outlet>
"<h1>Welcome plain</h1>
<router-outlet></router-outlet>
"
`;
Expand Down Expand Up @@ -202,7 +204,7 @@ describe('AppComponent', () => {
`;
exports[`app --minimal should skip "nx-welcome.component.ts" file and references for standalone apps without routing 3`] = `
"<h1>Welcome plain</h1>
"<h1>Welcome plain</h1>
"
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>
<%_ if(minimal) { _%>
<h1>Welcome <%= appName %></h1>
<%_ } else { _%>
<<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>>
<%_ } _%>
<%_ if(routing) { _%>
<router-outlet></router-outlet>
<%_ } _%>
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>
<%_ if(minimal) { _%>
<h1>Welcome <%= appName %></h1>
<%_ } else { _%>
<<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>>
<%_ } _%>
<%_ if(routing) { _%>
<router-outlet></router-outlet>
<%_ } _%>
4 changes: 0 additions & 4 deletions packages/angular/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { Tree } from '@nx/devkit';
import {
addDependenciesToPackageJson,
addProjectConfiguration,
ensurePackage,
getPackageManagerCommand,
joinPathFragments,
readNxJson,
readProjectConfiguration,
updateProjectConfiguration,
} from '@nx/devkit';
import { nxVersion } from '../../../utils/versions';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedSchema } from './normalized-schema';
import { addE2eCiTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
import { E2EWebServerDetails } from '@nx/devkit/src/generators/e2e-web-server-info-utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Meta, StoryObj } from '@storybook/angular';
import { <%=componentName%> } from './<%=componentFileName%>';
<% if ( interactionTests ) { %>
<%_ if ( interactionTests ) { _%>
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
<% } %>
<%_ } _%>

const meta: Meta<<%= componentName %>> = {
component: <%= componentName %>,
Expand All @@ -18,7 +18,7 @@ export const Primary: Story = {
},
};

<% if ( interactionTests ) { %>
<%_ if ( interactionTests ) { _%>
export const Heading: Story = {
args: {<% for (let prop of props) { %>
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
Expand All @@ -28,4 +28,4 @@ export const Heading: Story = {
expect(canvas.getByText(/<%=componentNameSimple%> works!/gi)).toBeTruthy();
},
};
<% } %>
<%_ } _%>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
display: block;
}
<% } else { %>\:host
display: block;
display: block
<% }} %>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# <%= libName %>

This library was generated with [Nx](https://nx.dev).
<% if (unitTesting) { %>
<%_ if (unitTesting) { _%>

## Running unit tests

Run `nx test <%= libName %>` to execute the unit tests.
<% } %>
<%_ } _%>
8 changes: 6 additions & 2 deletions packages/angular/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,9 @@ describe('lib', () => {
...nx.configs["flat/angular"],
...nx.configs["flat/angular-template"],
{
files: ["**/*.ts"],
files: [
"**/*.ts"
],
rules: {
"@angular-eslint/directive-selector": [
"error",
Expand All @@ -1239,7 +1241,9 @@ describe('lib', () => {
}
},
{
files: ["**/*.html"],
files: [
"**/*.html"
],
// Override or add rules here
rules: {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
exports[`angularStories generator: applications should generate stories file for inline scam component 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { MyScamComponent } from './my-scam.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
const meta: Meta<MyScamComponent> = {
component: MyScamComponent,
title: 'MyScamComponent',
Expand All @@ -20,7 +18,6 @@ export const Primary: Story = {
},
};
export const Heading: Story = {
args: {
},
Expand All @@ -35,7 +32,6 @@ export const Heading: Story = {
exports[`angularStories generator: applications should generate stories file with interaction tests 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { AppComponent } from './app.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down Expand Up @@ -63,11 +59,9 @@ export const Heading: Story = {
exports[`angularStories generator: applications should ignore a path that has a nested component, but still generate nested component stories 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { ComponentBComponent } from './component-b.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
const meta: Meta<ComponentBComponent> = {
component: ComponentBComponent,
title: 'ComponentBComponent',
Expand All @@ -80,7 +74,6 @@ export const Primary: Story = {
},
};
export const Heading: Story = {
args: {
},
Expand All @@ -95,11 +88,9 @@ export const Heading: Story = {
exports[`angularStories generator: applications should ignore a path when using a routing module 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { ComponentComponent } from './component.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
const meta: Meta<ComponentComponent> = {
component: ComponentComponent,
title: 'ComponentComponent',
Expand All @@ -112,7 +103,6 @@ export const Primary: Story = {
},
};
export const Heading: Story = {
args: {
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
exports[`angularStories generator: libraries Stories for non-empty Angular library should generate stories file for standalone components 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { StandaloneComponent } from './standalone.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down Expand Up @@ -31,7 +30,6 @@ export const Heading: Story = {
exports[`angularStories generator: libraries Stories for non-empty Angular library should generate stories file for standalone components 2`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { SecondaryStandaloneComponent } from './secondary-standalone.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down Expand Up @@ -59,7 +57,6 @@ export const Heading: Story = {
exports[`angularStories generator: libraries Stories for non-empty Angular library should generate stories.ts files 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { TestButtonComponent } from './test-button.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down Expand Up @@ -97,11 +94,9 @@ export const Heading: Story = {
exports[`angularStories generator: libraries Stories for non-empty Angular library should ignore paths 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { TestButtonComponent } from './test-button.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
const meta: Meta<TestButtonComponent> = {
component: TestButtonComponent,
title: 'TestButtonComponent',
Expand All @@ -118,7 +113,6 @@ export const Primary: Story = {
},
};
export const Heading: Story = {
args: {
buttonType: 'button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default config;
exports[`StorybookConfiguration generator should configure storybook with interaction tests and install dependencies 1`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { TestButtonComponent } from './test-button.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down Expand Up @@ -71,7 +70,6 @@ export const Heading: Story = {
exports[`StorybookConfiguration generator should configure storybook with interaction tests and install dependencies 2`] = `
"import type { Meta, StoryObj } from '@storybook/angular';
import { TestOtherComponent } from './test-other.component';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/src/generators/utils/add-jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export async function addJest(
setupFile,
`// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
${contents}`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"**/*.js",
"<%= offsetFromProjectRoot %>cypress.config.ts",
"<%= offsetFromProjectRoot %>**/*.cy.ts",
<% if (jsx) { %> "<%= offsetFromProjectRoot %>**/*.cy.tsx",<% } %>
<%_ if (jsx) { _%> "<%= offsetFromProjectRoot %>**/*.cy.tsx",<%_ } _%>
"<%= offsetFromProjectRoot %>**/*.cy.js",
<% if (jsx) { %>"<%= offsetFromProjectRoot %>**/*.cy.jsx",<% } %>
<%_ if (jsx) { _%>"<%= offsetFromProjectRoot %>**/*.cy.jsx",<%_ } _%>
"<%= offsetFromProjectRoot %>**/*.d.ts"
]
}
Loading

0 comments on commit c2e3112

Please sign in to comment.