Skip to content

Commit 4200eda

Browse files
authored
update angular standalone demo based on new tutorial rewrite (#30)
1 parent 64a3a19 commit 4200eda

File tree

91 files changed

+7860
-23573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+7860
-23573
lines changed

standalone-angular-app/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

standalone-angular-app/.eslintrc.base.json

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"root": true,
33
"ignorePatterns": ["**/*"],
4-
"plugins": ["@nrwl/nx"],
4+
"plugins": ["@nx"],
55
"overrides": [
66
{
77
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
88
"rules": {
9-
"@nrwl/nx/enforce-module-boundaries": [
9+
"@nx/enforce-module-boundaries": [
1010
"error",
1111
{
1212
"enforceBuildableLibDependency": true,
@@ -15,6 +15,30 @@
1515
{
1616
"sourceTag": "*",
1717
"onlyDependOnLibsWithTags": ["*"]
18+
},
19+
{
20+
"sourceTag": "type:feature",
21+
"onlyDependOnLibsWithTags": ["type:feature", "type:ui"]
22+
},
23+
{
24+
"sourceTag": "type:ui",
25+
"onlyDependOnLibsWithTags": ["type:ui"]
26+
},
27+
{
28+
"sourceTag": "scope:orders",
29+
"onlyDependOnLibsWithTags": [
30+
"scope:orders",
31+
"scope:products",
32+
"scope:shared"
33+
]
34+
},
35+
{
36+
"sourceTag": "scope:products",
37+
"onlyDependOnLibsWithTags": ["scope:products", "scope:shared"]
38+
},
39+
{
40+
"sourceTag": "scope:shared",
41+
"onlyDependOnLibsWithTags": ["scope:shared"]
1842
}
1943
]
2044
}
@@ -23,12 +47,12 @@
2347
},
2448
{
2549
"files": ["*.ts", "*.tsx"],
26-
"extends": ["plugin:@nrwl/nx/typescript"],
50+
"extends": ["plugin:@nx/typescript"],
2751
"rules": {}
2852
},
2953
{
3054
"files": ["*.js", "*.jsx"],
31-
"extends": ["plugin:@nrwl/nx/javascript"],
55+
"extends": ["plugin:@nx/javascript"],
3256
"rules": {}
3357
},
3458
{

standalone-angular-app/.eslintrc.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
{
55
"files": ["*.ts"],
66
"extends": [
7-
"plugin:@nrwl/nx/angular",
7+
"plugin:@nx/angular",
88
"plugin:@angular-eslint/template/process-inline-templates"
99
],
1010
"rules": {
1111
"@angular-eslint/directive-selector": [
1212
"error",
1313
{
1414
"type": "attribute",
15-
"prefix": "store",
15+
"prefix": "myngapp",
1616
"style": "camelCase"
1717
}
1818
],
1919
"@angular-eslint/component-selector": [
2020
"error",
2121
{
2222
"type": "element",
23-
"prefix": "store",
23+
"prefix": "myngapp",
2424
"style": "kebab-case"
2525
}
2626
]
2727
}
2828
},
2929
{
3030
"files": ["*.html"],
31-
"extends": ["plugin:@nrwl/nx/angular-template"],
31+
"extends": ["plugin:@nx/angular-template"],
3232
"rules": {}
3333
}
3434
],
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Add files here to ignore them from prettier formatting
2-
32
/dist
43
/coverage
4+
.angular

standalone-angular-app/README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
1-
# Tutorial: Standalone Angular Application
1+
# Tutorial: Building Angular Apps with the Nx Standalone Projects Setup
22

33
[![standalone application](https://img.shields.io/static/v1?label=Nx%20setup&message=standalone%20app&color=blue)](https://nx.dev/concepts/integrated-vs-package-based#standalone-applications)
44

5+
56
Source code for the Angular standalone application tutorial on the Nx docs:
67
- Tutorial: https://nx.dev/getting-started/angular-standalone-tutorial
78

89
## What's inside?
910

10-
This example contains a single Angular application that has been generated with the `angular-standlone` preset. It contains a single root-level application and two libraries, `cart` and `ui` that are imported into the app.
11+
This example contains a single Angular application that has been generated with the `angular-standalone` preset.
12+
13+
```
14+
npx create-nx-workspace@latest myngapp --preset=angular-standalone
15+
```
16+
17+
It contains
18+
19+
- a single root-level Angular application (in `src`)
20+
- an e2e project based on Cypress
21+
- two local libraries, `modules/products`, `modules/orders` and `modules/shared/ui` to demo how to modularize a codebase
22+
- uses [Nx module boundary rules](https://nx.dev/core-features/enforce-project-boundaries) to enforce architectural constraints
1123

1224
Follow through the tutorial linked above for more details.
1325

1426
## How to run it
1527

16-
Install all dependencies using `npm install`. You can then run commands Like
28+
Clone it locally, install all dependencies using `npm install`. You can then run commands Like
1729

1830
- `npx nx build` to build the Angular application
1931
- `npx nx serve` to serve the app
2032
- you can use `npx nx graph` to visualize the structure
2133

22-
## Learn more
34+
Alternatively 👇
2335

24-
- [Video: Standalone Applications with Nx](https://youtu.be/qEaVzh-oBBc)
36+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github.com/nrwl/nx-recipes/tree/main/standalone-angular-app?file=README.md)

standalone-angular-app/cart/project.json

-28
This file was deleted.

standalone-angular-app/cart/src/index.ts

-3
This file was deleted.

standalone-angular-app/cart/src/lib/cart.module.ts

-10
This file was deleted.

standalone-angular-app/cart/src/lib/cart/cart.component.html

-1
This file was deleted.

standalone-angular-app/cart/src/lib/cart/cart.component.ts

-8
This file was deleted.

standalone-angular-app/cart/src/test-setup.ts

-1
This file was deleted.

standalone-angular-app/e2e/.eslintrc.json

-11
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,13 @@
22
"extends": ["plugin:cypress/recommended", "../.eslintrc.base.json"],
33
"ignorePatterns": ["!**/*"],
44
"overrides": [
5-
{
6-
"files": ["*.ts", "*.tsx"],
7-
"rules": {}
8-
},
95
{
106
"files": ["*.js", "*.jsx"],
117
"rules": {}
128
},
139
{
1410
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
1511
"rules": {}
16-
},
17-
{
18-
"files": ["src/plugins/index.js"],
19-
"rules": {
20-
"@typescript-eslint/no-var-requires": "off",
21-
"no-undef": "off"
22-
}
2312
}
2413
]
2514
}

standalone-angular-app/e2e/cypress.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineConfig } from 'cypress';
2-
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';
2+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
33

44
export default defineConfig({
55
e2e: nxE2EPreset(__dirname),

standalone-angular-app/e2e/project.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
"projectType": "application",
66
"targets": {
77
"e2e": {
8-
"executor": "@nrwl/cypress:cypress",
8+
"executor": "@nx/cypress:cypress",
99
"options": {
1010
"cypressConfig": "e2e/cypress.config.ts",
11-
"devServerTarget": "store:serve:development",
11+
"devServerTarget": "myngapp:serve:development",
1212
"testingType": "e2e"
1313
},
1414
"configurations": {
1515
"production": {
16-
"devServerTarget": "store:serve:production"
16+
"devServerTarget": "myngapp:serve:production"
17+
},
18+
"ci": {
19+
"devServerTarget": "myngapp:serve-static"
1720
}
1821
}
1922
},
2023
"lint": {
21-
"executor": "@nrwl/linter:eslint",
24+
"executor": "@nx/linter:eslint",
2225
"outputs": ["{options.outputFile}"],
2326
"options": {
2427
"lintFilePatterns": ["e2e/**/*.{js,ts}"]
2528
}
2629
}
2730
},
2831
"tags": [],
29-
"implicitDependencies": ["store"]
32+
"implicitDependencies": ["myngapp"]
3033
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { getGreeting } from '../support/app.po';
22

3-
describe('store', () => {
3+
describe('myngapp', () => {
44
beforeEach(() => cy.visit('/'));
55

66
it('should display welcome message', () => {
77
// Custom command example, see `../support/commands.ts` file
88
cy.login('[email protected]', 'myPassword');
99

1010
// Function helper example, see `../support/app.po.ts` file
11-
getGreeting().contains('Welcome store');
11+
getGreeting().contains('Welcome myngapp');
1212
});
1313
});

standalone-angular-app/e2e/tsconfig.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,5 @@
1212
"noImplicitReturns": true,
1313
"noFallthroughCasesInSwitch": true
1414
},
15-
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"],
16-
"angularCompilerOptions": {
17-
"enableI18nLegacyMessageIdFormat": false,
18-
"strictInjectionParameters": true,
19-
"strictInputAccessModifiers": true,
20-
"strictTemplates": true
21-
}
15+
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"]
2216
}

0 commit comments

Comments
 (0)