Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update docs example dependencies to version 8 #30385

Closed
wants to merge 9 commits into from
Closed
3 changes: 3 additions & 0 deletions aio/content/examples/.gitignore
Expand Up @@ -23,6 +23,9 @@
**/bs-config.e2e.json
**/bs-config.json
**/package.json
**/tsconfig.json
**/tsconfig.app.json
**/tsconfig.spec.json
**/tslint.json
**/karma-test-shim.js
**/browser-test-shim.js
Expand Down
2 changes: 1 addition & 1 deletion aio/content/examples/bootstrapping/e2e/src/app.e2e-spec.ts
Expand Up @@ -9,6 +9,6 @@ describe('feature-modules App', () => {

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
expect(page.getTitleText()).toEqual('app works!');
});
});
3 changes: 0 additions & 3 deletions aio/content/examples/elements/example-config.json
@@ -1,3 +0,0 @@
{
"projectType": "elements"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Expand Up @@ -9,7 +9,7 @@ describe('feature-modules App', () => {

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
expect(page.getTitleText()).toEqual('app works!');
});
});

Expand Down
Expand Up @@ -15,7 +15,7 @@ describe('providers App', () => {

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Lazy loading feature modules');
expect(page.getTitleText()).toEqual('Lazy loading feature modules');
});

describe('Customers list', function() {
Expand Down
2 changes: 1 addition & 1 deletion aio/content/examples/providers/e2e/src/app.e2e-spec.ts
Expand Up @@ -23,7 +23,7 @@ describe('providers App', () => {

it('should display header that says Users list', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Users list');
expect(page.getTitleText()).toEqual('Users list');
});


Expand Down
Expand Up @@ -11,7 +11,7 @@ describe('sw-example App', () => {

it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to Service Workers!');
expect(page.getTitleText()).toEqual('Welcome to Service Workers!');
});

it('should display the Angular logo', () => {
Expand Down
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
Expand All @@ -11,6 +11,6 @@
"**/*.spec.ts"
],
"angularCompilerOptions": {
"entryModule": "app/app.server.module#AppServerModule"
"entryModule": "src/app/app.server.module#AppServerModule"
}
}
38 changes: 26 additions & 12 deletions aio/tools/examples/README.md
Expand Up @@ -17,21 +17,23 @@ As mentioned, many of the documentation pages contain snippets extracted from re
To achieve that, all those applications needs to contain a basic boilerplate. E.g. a `node_modules`
folder, `package.json` with scripts, etc.

No one wants to maintain the boilerplate on each example, so the goal of this tool is to provide a
set of boilerplates that works in all the examples.
No one wants to maintain the boilerplate on each example, so the goal of this tool is to provide a set of files that works across all the examples.

### Boilerplate files

Inside `/aio/tools/examples/shared/boilerplate` you will find a set of folders representing each
boilerplate.
Inside `/aio/tools/examples/shared/boilerplate` you will find a set of folders representing each project type.

Currently you will find the next boilerplates:
Currently you will find the next project types:


* CLI - For CLI based examples. This is the default one, to be used in the majority of the examples.
* cli - For CLI based examples. This is the default one, to be used in the majority of the examples.
* getting-started - CLI-based with its own set of styles.
* i18n - CLI-based with additional scripts for internationalization.
* ivy - CLI-based with additional configuration for running the examples with the Ivy renderer and ngstc compiler.
* schematics - CLI-based with additional scripts for building schematics.
* service-worker - CLI-based with additional packages and configuration for service workers.
* systemjs - Currently in deprecation, only used in a few examples.
* i18n - Based on the CLI one, features a few scripts for i18n.
* universal - Based on the cli with a extra server for universal.
* testing - CLI-based with additional styles for jasmine testing.
* universal - CLI-based with an extra server target.

There is also a `common` folder that contains files used in all different examples.

Expand All @@ -41,11 +43,14 @@ Each example is identified by an **example-config.json** configuration file in i
This configuration file indicates what type of boilerplate this example needs. E.g.

```json
{ projectType: 'universal' }
{
"projectType": "cli",
"useCommonBoilerplate": true
}
```

If the file is empty then the default type of cli is assumed.
When the boilerplate tooling runs, it will copy into the example folder all of the appropriate boilerplate files.
When the boilerplate tooling runs, it will copy into the example folder all of the appropriate files based on the project type.

### A node_modules to share

Expand Down Expand Up @@ -89,4 +94,13 @@ that name.
It also has an optional `--setup` flag to run the `example-boilerplate.js` script and install
the latest `webdriver`.

It will create a `/aio/protractor-results-txt` file when it finishes running tests.
It will create a `/aio/protractor-results.txt` file when it finishes running tests.

### Updating example dependencies

With every major release, we update the examples to be on the latest version. The following steps to update are:

* In the `shared/package.json` file, bump all the `@angular/*`, `@angular-devkit/*`, `rxjs`, `typescript`, and `zone.js` package versions to the version that corresponds with the [framework version](../../../package.json).
* In the `shared` folder, run `yarn` to update the dependencies for the shared `node_modules` and the `yarn.lock` file.
* In the `boilerplate` folder, go through each sub-folder and update the `package.json` dependencies if one is present.
* Follow the [update guide](./shared/boilerplate/UPDATING_CLI.md) to update the common files used in the examples based on project type.
10 changes: 4 additions & 6 deletions aio/tools/examples/example-boilerplate.js
Expand Up @@ -13,9 +13,9 @@ const EXAMPLES_BASE_PATH = path.resolve(__dirname, '../../content/examples');
const BOILERPLATE_PATHS = {
cli: [
'src/environments/environment.prod.ts', 'src/environments/environment.ts',
'src/assets/.gitkeep', 'src/browserslist', 'src/favicon.ico', 'src/karma.conf.js',
'src/polyfills.ts', 'src/test.ts', 'src/tsconfig.app.json', 'src/tsconfig.spec.json',
'src/tslint.json', 'e2e/src/app.po.ts', 'e2e/protractor.conf.js', 'e2e/tsconfig.e2e.json',
'src/assets/.gitkeep', 'browserslist', 'src/favicon.ico', 'karma.conf.js',
'src/polyfills.ts', 'src/test.ts', 'tsconfig.app.json', 'tsconfig.spec.json',
'tslint.json', 'e2e/src/app.po.ts', 'e2e/protractor.conf.js', 'e2e/tsconfig.json',
'.editorconfig', 'angular.json', 'package.json', 'tsconfig.json', 'tslint.json'
],
systemjs: [
Expand All @@ -29,8 +29,6 @@ const BOILERPLATE_PATHS = {
// This maps the CLI files that exists in a parent folder
const cliRelativePath = BOILERPLATE_PATHS.cli.map(file => `../cli/${file}`);

BOILERPLATE_PATHS.elements = [...cliRelativePath, 'tsconfig.json'];

BOILERPLATE_PATHS.i18n = [...cliRelativePath, 'angular.json', 'package.json'];

BOILERPLATE_PATHS['service-worker'] = [...cliRelativePath, 'angular.json', 'package.json'];
Expand All @@ -51,7 +49,7 @@ BOILERPLATE_PATHS['getting-started'] = [

BOILERPLATE_PATHS.ivy = {
systemjs: ['rollup-config.js', 'tsconfig-aot.json'],
cli: ['src/tsconfig.app.json']
cli: ['tsconfig.app.json']
};

BOILERPLATE_PATHS.schematics = [
Expand Down
5 changes: 0 additions & 5 deletions aio/tools/examples/run-example-e2e.js
Expand Up @@ -26,11 +26,6 @@ const IGNORED_EXAMPLES = [
const fixmeIvyExamples = [
// fixmeIvy('unknown') app fails at runtime due to missing external service (goog is undefined)
'i18n',
// Needs a Angular CLI synced with the Ivy loadChildren: string support after
// https://github.com/angular/angular/pull/28685
'lazy-loading-ngmodules',
'router',
'ngmodules',
];

if (argv.ivy) {
Expand Down
2 changes: 2 additions & 0 deletions aio/tools/examples/shared/boilerplate/.gitignore
@@ -0,0 +1,2 @@
**/yarn.lock
**/package-lock.json
86 changes: 40 additions & 46 deletions aio/tools/examples/shared/boilerplate/UPDATING_CLI.md
@@ -1,56 +1,50 @@
# How to update the CLI boilerplate
# How to update the CLI project

The boilerplate is updated by hand so you normally update it every minor version unless there is a major bug to fix.
The Angular CLI default setup is updated using `ng update`. Any necessary file changes will be done automatically through migration schematics.

## Getting a new boilerplate

The first thing would be updating the CLI globally
In the `cli` folder, update the Angular CLI depedencies to the latest version:

```
npm i -g @angular/cli
ng update @angular/cli --next
```

Then create a new dummy project in a temporary folder outside angular
Then update the Angular Framework dependencies to the latest version:

```
ng new dummy
ng update @angular/core --next
```

Now you have a fresh application to get our new boilerplate files.

## Updating files

From `dummy` you can replace the following files into `aio/tools/examples/shared/boilerplate/cli`:

* .editorconfig
* angular.json
* package.json
* tsconfig.json
* tslint.json
* e2e/src/app.po.ts
* e2e/protractor.conf.js
* e2e/tsconfig.e2e.json
* src/environments/environment.prod.ts
* src/environments/environment.ts
* src/browserslist
* src/favicon.ico
* src/karma.conf.js
* src/polyfills.js
* src/styles.css
* src/test.ts
* src/tsconfig.app.json
* src/tsconfig.spec.json
* src/tslint.json
* src/typings.d.ts

### angular.json

Update the `project > name` to `angular.io-example`.

### package.json

Update the `name` to `angular.io-example`.

### src/tsconfig.app.json

This file is small enough and there are a few new excludes, update by hand.
Commit any changes to the `cli` folder to the repository.

## Updating other CLI-based projects

Along with the boilerplate files for the `cli` folder, the other cli-based projects need to be updated also. Each cli-based project has slightly modified files specific to the project type. Make sure any necessary changes to these projects are made also to be in alignment with the `cli` project files.

The specific changes to each project type are listed below:

* i18n
- angular.json
- Includes additional configurations for `build`, `serve`, and `e2e` for different locales
- package.json
- Includes custom scripts for building and serving different locales
* ivy
- cli/tsconfig.app.json
- Includes an `angularCompilerOptions` object with `enableIvy` set to `true`
* schematics
- angular.json
- Includes a `my-lib` project that contains a library with example schematics
* service-worker
- angular.json
- Has `serviceWorker` set to `true` in the `production` build target
- package.json
- Includes `@angular/service-worker` in `dependencies`
* testing
- angular.json
- Includes `src/test.css` in the `styles` for the `test` target
* universal
- angular.json
- Includes a `server` target in the `build` architect runners
- package.json
- Includes custom scripts for building the `server`
- Includes additional `dependencies` on `@nguniversal/common`, `@nguniversal/express-engine`, and `@nguniversal/module-map-ngfactory-loader`
- Includes `devDependencies` on `@angular/platform-server`, and `ts-loader`
2 changes: 1 addition & 1 deletion aio/tools/examples/shared/boilerplate/cli/.editorconfig
@@ -1,4 +1,4 @@
# Editor configuration, see http://editorconfig.org
# Editor configuration, see https://editorconfig.org
brandonroberts marked this conversation as resolved.
Show resolved Hide resolved
root = true

[*]
Expand Down
7 changes: 7 additions & 0 deletions aio/tools/examples/shared/boilerplate/cli/.gitignore
Expand Up @@ -4,10 +4,16 @@
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
Expand All @@ -23,6 +29,7 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
Expand Down