Compare commits

...

426 Commits

Author SHA1 Message Date
Alex Rickabaugh 31acfa11bb release: cut the v13.3.10 release (#46141)
PR Close #46141
2022-05-25 13:33:43 -07:00
mgechev a12372a66d docs: update the Angular roadmap as of May 2022 (#46117)
* Update project completion status
* Update project description based on state
* Add new projects to the future section

PR Close #46117
2022-05-25 11:23:54 -07:00
dario-piotrowicz 4a7e724238 refactor(compiler-cli): fix "for to" typo in code comment (#46113)
fix the typo/extra for in a code comment saying
"this is used for to determine" so that it only says
"this is used to determine"

PR Close #46113
2022-05-24 10:52:18 -07:00
dario-piotrowicz 355e6b3521 docs: replace wrong hyphen with # in aio cheatsheet (#46125)
replace the hyphen symbol wrongly used in the aio cheatsheet
doc to create a template variable with the proper # symbol

PR Close #46125
2022-05-24 10:49:53 -07:00
Roopesh Chinnakampalli f936946dc0 docs: corrected the misspelled word (#46126)
innovation -> invocation
PR Close #46126
2022-05-24 10:47:47 -07:00
Aristeidis Bampakos fa7c9dc67a docs: align lightbox elements together (#46107)
Align lightbox `div` elements so that the image appears inside the lightbox correctly.

PR Close #46107
2022-05-24 10:45:53 -07:00
dario-piotrowicz 123782bfb6 docs: move all bazel testing info to a single location (#46084)
instead of presenting the same (or similar information) in both the
DEVELOPER.md and the BAZEL.md files, more all the information in the
BAZEL file and refer to that section in the DEVELOPER file

PR Close #46084
2022-05-23 13:59:06 -07:00
A. J. Javier 2009238d35 docs: fix angularfire2 hyperlink (#46046)
PR Close #46046
2022-05-23 13:52:13 -07:00
dario-piotrowicz 429822bc9f feat(docs-infra): add group role and label for aio-notification (#45770)
add a role and an aria-label to the aio-notification component so that
it can be handled better by assistive technologies

resolves #44345

PR Close #45770
2022-05-23 13:48:30 -07:00
dario-piotrowicz c58e925f4e docs: make structural directives guide generic (#44895)
tweak the current structural directives guide (currently mainly targeted
at the creation of custom structural directives) so that is more generic
and a point of reference for structural directives in general

this also includes the re-addition of the one-per-element section
removed in PR #40015

resolves #44786

PR Close #44895
2022-05-23 13:44:42 -07:00
Aristeidis Bampakos 4275504571 docs: remove broken code from TOH tutorial (#46105)
At the end of Part 2 of the Tour or Heroes tutorial, there is a code sample that is broken. It looks like it was added by mistake because it is not related to the summary.
PR Close #46105
2022-05-23 13:31:24 -07:00
Tom Raithel a0676d6a2c docs: fix division by zero in progress events example (#46077)
If the `event.total` is undefined, this line would have generated a `NaN` due to division by zero. I suppose, that a `0` would be more suitable for this case.

PR Close #46077
2022-05-23 13:27:47 -07:00
Paul Gschwendtner 8f68f53b67 build: fix unbound variable error in build artifact script (#46076)
We recently had a couple of issues with the shallowing of snapshot
git repositories. In an attempt to fix this, parts of the publish
script of the COMP repo have been used, but variables have not been
updated properly.

This commit fixes an unbound variable, avoiding errors when snapshots
are published for a new branch (e.g. when we branch-off).

PR Close #46076
2022-05-23 13:26:33 -07:00
Nathan Nontell c6d0d8c856 docs(docs-infra): update createComponent description to fix incorrect method name and invalid use of html escaping (#46074)
PR Close #46074
2022-05-23 13:21:46 -07:00
Jerome Kruse 1199cfa551 docs: update service-worker-config to more clearly describe behavior (#45909)
Fixes #45280

PR Close #45909
2022-05-23 13:17:52 -07:00
Thomas Mair f6c265deba fix(docs-infra): add member name to search index without ignore list (#46060)
Previously classs, interface and enum members where filtered with the default word ignore list. This lead to  poor search results if a search for a member on the ignore list was performed.

PR Close #46060
2022-05-23 09:56:09 -07:00
J Rob Gant 8eb5b3c5c2 docs: Remove outdated note (#46022)
Component.styles can now use SCSS or LESS preprocessors.

PR Close #46022
2022-05-23 09:53:41 -07:00
Joey Perrott 1d02c09010 build: update saucelabs key (#46089)
Update the saucelabs key for the newly generated key

PR Close #46089
2022-05-21 20:21:42 +00:00
Joey Perrott 239edda790 build: update saucelabs key (#46088)
Update the saucelabs key for the newly generated key

PR Close #46088
2022-05-21 20:11:04 +00:00
Jessica Janiuk f708479e2e release: cut the v13.3.9 release (#46042) 2022-05-18 11:42:28 -07:00
George Kalpakas f901bd2458 docs: explicitly specify a version in the CLI install command (#46020)
Update the CLI install command in the CLI overview page to explicitly
specify a version. This ensures that the version installed is
appropriate for the version of the docs (e.g. installing CLI v12.x when
following the v12 docs) and it consistent with the `setup-local` guide.

PR Close #46020
2022-05-17 18:28:31 +00:00
George Kalpakas c3659dd46a fix(docs-infra): correctly style the CLI version in code snippet (#46020)
Some CLI versions (such as `@next`) are not parsed (and thus not
formatted) correctly in code snippets. Fix this by explicitly adding an
appropriate CSS class to the `<aio-angular-dist-tag>` elements to let
PrettyPrint know how to style this token.

PR Close #46020
2022-05-17 18:28:31 +00:00
Bob Watson d7de3c54cd docs: remove Narco from hero list in code, text, and images (#46008)
Fixes issue #45769

Removes the malevolent comic book character, "Narco," from the list of heroes. This change removes the reference from the code, text and screenshots used in the documentation and makes other minor edits as necessary.

PR Close #46008
2022-05-17 17:47:04 +00:00
4javier db15a0882e docs(devtools): add firefox extension references (#45985)
add a link to recent deployed firefox extension and use less specific terminology
PR Close #45985
2022-05-16 18:04:51 +00:00
mariu c85bff173a docs: add transparency to Ecosystem image (#45993)
PR Close #45993
2022-05-16 09:37:35 -07:00
George Kalpakas e539f532cd test(docs-infra): ensure examples are split correctly across shards (#46005)
Previously, the examples were split across shards based on the order in
which `globby()` returned them. This was based on the assumption that
`globby()`/the OS would list files in a deterministic order. However, it
turns out that examples can be listed in different orders between
executions, leading in them not being split correctly across shards on
CI (which further means that some examples may be tested multiple times
and others may not be tested at all).
You can see an example [here][1], where the `getting-started` example is
tested in both the 4th and 5th shards.

This commit fixes this by explicitly sorting the examples based on their
path.

[1]: https://circleci.com/gh/angular/angular/1165448

PR Close #46005
2022-05-16 09:35:44 -07:00
celinetunc 57adaded2a docs: add selin tunc to contributors (#45989)
PR Close #45989
2022-05-13 15:05:01 -07:00
Pavan Kumar Jadda c224adaa21 docs: adds ngx-cookie-service library to resources list (#45955)
PR Close #45955
2022-05-13 20:08:10 +00:00
Evan Lee 9a31c22cdd docs: remove Angular 11 from support table (#45980)
PR Close #45980
2022-05-13 11:18:50 -07:00
Joey Perrott dfc4852d6c build: manually unshallow the repo for builds publishing, use absolute paths (#45979)
Use the absolute path for the artifacts directory, as well as encapsulate the clone
vs init logic to prevent it from changing directories.

Manually remove the shallow marker so that git does not recognize this as a shallow repo.

PR Close #45979
2022-05-13 09:07:50 -07:00
Jessica Janiuk 986e80e9db release: cut the v13.3.8 release (#45976) 2022-05-12 15:05:49 -07:00
Joey Perrott c9c24d170b build: use clone instead of init for creating the builds commit changes (#45975)
Rather than using git init to create an empty repo and then shallow fetch the
repo for a specific branch, we shallow clone the repository itself for the branch.
This prevents us from running into the issue of Github denying the push because it
comes from a shallow branch which does not map back to the repository.

PR Close #45975
2022-05-12 20:31:45 +00:00
Joey Perrott 90e6987ee3 build: set the default branch of the ephemeral repo for publishing build artifacts to main (#45974)
It looks like because the primary branch for our ephemeral repos doesn't match the build repos
we are pushing to it causes errors around shallow clones.  This attempts to prevent this.

PR Close #45974
2022-05-12 19:39:37 +00:00
Andrew Scott b4eb9ed884 fix(language-service): Prevent TSServer from removing templates from project (#45965)
As part of the `updateProjectIfDirty` process and inside `updateNonInferredProjectFiles`
TS Server will remove the template files that we added as roots in
`readResource`.
https://sourcegraph.com/github.com/microsoft/TypeScript@c300fea3250abd7f75920d95a58d9e742ac730ee/-/blob/src/server/editorServices.ts?L2363

The external files are added to the list here so ensuring that the
templates are included in the `getExternalFiles` will prevent this from
happening
https://sourcegraph.com/github.com/microsoft/TypeScript@c300fea3250abd7f75920d95a58d9e742ac730ee/-/blob/src/server/editorServices.ts?L2395:18

PR Close #45965
2022-05-12 09:25:20 -07:00
George Kalpakas e223649dc5 fix(docs-infra): do not detect a running job as failed (#45948)
Previously, the preview server would incorrectly identify a running
`aio_preview` CI job as failed and therefore skip creating a preview.
This happened because it only checked whether the job's status is
`success`, failing to account for the fact that the job would have a
`running` status.
(This bug was accidentally introduced in #45934.)

This commit avoids the problem by getting rid of the job status check
altogether. This check does not offer any benefit, since the CI job will
always be in a `running` state (i.e. neither successfully completed nor
failed).

PR Close #45948
2022-05-12 09:02:04 -07:00
Andrew Kushnir 72c11f33b5 release: cut the v13.3.7 release 2022-05-11 10:17:13 -07:00
Ted.chang 3626464f00 docs: add NGX-YOUI website to resources list (#45810)
PR Close #45810
2022-05-10 16:03:37 -07:00
Andrew Scott 5ca3bcf4f8 fix(language-service): Add resource files as roots to their associated projects (#45601)
When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes https://github.com/angular/vscode-ng-language-service/issues/1623
fixes https://github.com/angular/vscode-ng-language-service/issues/876

PR Close #45601
2022-05-10 09:36:28 -07:00
mgechev 66c400c032 docs: add the change detection guide to the navigation and pullapprove (#45880)
PR Close #45880
2022-05-09 13:56:36 -07:00
mgechev 5e858c7b2a docs: add a guide on using OnPush change detection strategy (#45880)
Explain how to use OnPush change detection strategy and what are the
different edge cases. Looks into several different scenarios and covers
the behavior of OnPush for each one of them.

PR Close #45880
2022-05-09 13:56:36 -07:00
mgechev af009c3789 docs: add a guide on optimizing slow computations (#45880)
Add a guide that explains:
- How we can slow the change detection down
- How to discover slow computations with Angular DevTools
- Explain how to fix slow computations

PR Close #45880
2022-05-09 13:56:36 -07:00
mgechev 87e661d16c docs: add guide on how to run code outside of NgZone (#45880)
Explain the relationship between Angular and Zone.js. Covers how to
discover code that triggers change detection more often than we have to
run it and explain how to run code outside the Angular zone.

PR Close #45880
2022-05-09 13:56:36 -07:00
mgechev 683895c27f docs: add general change detection overview (#45880)
Add a few paragraphs with introduction to how change detection works
referencing a video for further details.

PR Close #45880
2022-05-09 13:56:36 -07:00
JoostK 73bbee2c0d perf(core): allow checkNoChanges mode to be tree-shaken in production (#45936)
This commit guards all logic that exists for the `checkNoChanges` mode
with `ngDevMode` checks such that the logic can be tree-shaken.

PR Close #45936
2022-05-09 13:24:41 -07:00
Andrew Kushnir 02b99f60f0 ci: enable the aio_preview CircleCI job (#45935)
This reverts commit dbc0dababa, since the fix has landed in https://github.com/angular/angular/commit/c4340970c7a6419eee28804c9b82254dbcf59315.

PR Close #45935
2022-05-09 12:33:34 -07:00
JayMartMedia 40b3cf4682 docs: remove unnecesarry backslash from pipes documentation (#45916)
There was an extra backslash in the description of the pipe character. This could be misleading as people could think that the backslash is a pipe character.

PR Close #45916
2022-05-09 12:08:04 -07:00
JayMartMedia 0ec3263ddf docs: fix bold text in start-data (#45916)
PR Close #45916
2022-05-09 12:08:04 -07:00
Andrew Kushnir c8ed9bc001 ci: update NgBot to sync internal and external configs (#45915)
There was a difference in the set of paths between check/sync scripts internally and externally.
This commit aligns both configurations.

PR Close #45915
2022-05-09 11:55:38 -07:00
Thomas Mair a3ca0f1e11 refactor(docs-infra): remove unnecessary types for stemmer dependency (#45831)
NOTE:
Since version 2.0.0 stemmer includes its own typings (see https://github.com/words/stemmer/commit/cd6fd9a0319bd7f44dc09ed40614fa807fe28535)

PR Close #45831
2022-05-09 11:54:56 -07:00
George Kalpakas 0e87cd9a81 fix(docs-infra): handle CircleCI API v2 responses in preview server (#45934)
In PR #45349 we switched to using version 2 of the CircleCI API. It
turns out that this version of the API (in addition to different URLs)
also returns different info from some endpoints, which we have failed to
account for.

More specifically, the v2 API response for a job does not contain info
that we need in [BuildRetriever][1].

As an example, see the API responses for an `aio_preview` run:
- [API v1.1][2]
- [API v2][3]

This commit updates the code to handle API v2 responses. In addition,
since the info we need is not present in the job info (as it was with
the previous version of the API), we now also retrieve the pipeline
info.

NOTE:
This issue did not manifest earlier, because the preview server code on
the VM was not updated to the latest version (that tried to use API v2)
due to a different error. This error was fixed with PR #45895, which
allowed the preview server to be updated on the VM and uncovered the API
v2 incompatibility.

[1]: https://github.com/angular/angular/blob/baa3e18812127e7266580f4cd202a4cb3204cbcb/aio/aio-builds-setup/dockerbuild/scripts-js/lib/preview-server/build-retriever.ts#L39-L45
[2]: https://circleci.com/api/v1.1/project/github/angular/angular/1163816
[3]: https://circleci.com/api/v2/project/gh/angular/angular/job/1163816

Fixes #45931

PR Close #45934
2022-05-09 11:54:10 -07:00
dario-piotrowicz 5056cfe839 docs(docs-infra): clarify toh-2 error message (#45878)
the second step of the tour of heroes refers to a runtime error which
generally isn't presented to new users since it gets caught by the
TypeScript compiler's strict mode, clarify such detail so not to confuse
readers

resolves #45759

PR Close #45878
2022-05-09 11:23:27 -07:00
George Kalpakas d4d7bf231a docs: fix code snippets in TOH (part 5) "Final code review" section (#45830)
Fixes #45736

PR Close #45830
2022-05-09 11:18:20 -07:00
George Kalpakas e3d7d5c68a docs: fix ellipsis in code-snippet in creating-libraries guide (#45820)
When hard-coding content in a `<code-example>` tag inside an `.md` file,
the content is treated as HTML by the Markdown processor and thus any
characters with special meaning in HTML have to be encoded (or replaced
with HTML entities).

However, the content that is embedded into `<code-example>` tags via
docregions is treated as text (since it is not parsed by the Markdown
processor) and thus should not have encoded characters or HTML entities.

PR Close #45820
2022-05-09 11:08:48 -07:00
Andrew Kushnir 31c4879da1 ci: disable aio_preview CircleCI job temporarily (#45932)
This commit disables the `aio_preview` CircleCI job temporarily, since it's failing after switching to CircleCI API v2. It will be enabled back once the code is updated. More info can be found here: https://github.com/angular/angular/issues/45931

PR Close #45932
2022-05-09 11:06:53 -07:00
ᚷᛁᛟᚱᚷᛁ ᛒᚨᛚᚨᚲᚻᚨᛞᛉᛖ 6644165e13 docs: remove redundant word (#45910)
PR Close #45910
2022-05-06 09:52:20 -07:00
Paul Gschwendtner 1f0ea14098 ci: update github robot config to reflect update in syncing (#45907)
The `ng_module` Starlark code is not used internally, just
`ngc-wrapped`.

PR Close #45907
2022-05-06 09:51:48 -07:00
dario-piotrowicz f9f1f92c0f docs(docs-infra): improve clarity of toh-pt2 li>button code (#45858)
in the tour of heros part 2 guide the addition of a button with spans is
slighly unclear, so update the code to make things more clear

resolves #45760

PR Close #45858
2022-05-05 16:58:45 -07:00
Andrew Kushnir 60ea078ce9 ci: update the list of excluded paths in NgBot config (#45901)
This commit aligns the NgBot config that is used to determine whether a presubmit is needed with its internal version.

PR Close #45901
2022-05-05 15:45:49 -07:00
George Kalpakas c9899637b0 build(docs-infra): remove unused Docker artifacts when updating the preview server (#45895)
Update the `update-preview-server.sh` script that is used to update the
PR preview server to also remove unused Docker images and containers
after the update. This avoids having unused Docker artifacts grow
uncontrolled and fill up the VM disk drive.

PR Close #45895
2022-05-05 14:49:14 -07:00
George Kalpakas d735ba7577 test(docs-infra): update preview server serify-setup tests to match implementation (#45895)
Update the mocks used in the `verify-setup` tests of the PR preview
server to account for changes made in PR #45349. These tests run to
verify that a newly built docker container works as expected before
deploying it to the preview server, so having them fail prevents the
preview server from updating automatically.

NOTE:
These tests are currently not run on CI due to complications with
running Docker inside Docker.

PR Close #45895
2022-05-05 14:49:14 -07:00
Will 保哥 719199c678 docs: fix a markdown syntax error in aio/content/marketing/analytics.md (#45898)
PR Close #45898
2022-05-05 11:50:58 -07:00
Paul Gschwendtner 09280257a2 build: clean up references to old master branch (#45890)
Cleans up all references to the `master` branch we renamed to
`main` across Angular.

PR Close #45890
2022-05-05 10:53:13 -07:00
Dylan Hunn e3b657e73a release: cut the v13.3.6 release (#45873)
PR Close #45873
2022-05-04 12:58:55 -07:00
Andrew Kushnir f9e0da6cf2 ci: decrease the number of required public-api and size-tracking reviews (#45855)
This commit updates the PullApprove config to decrease the number of required reviews from `public-api` and `size-tracking` group members.

PR Close #45855
2022-05-03 15:48:28 -07:00
George Kalpakas 8007946e6c docs(service-worker): fix alert closing tag (#45797)
This also allows correctly parsing other tags further below (such as
the `@reviewed` tag at the end).

PR Close #45797
2022-05-03 09:27:38 -07:00
Andrew Scott c00786ac3a fix(dev-infra): Fix pullapprove by commenting out the empty availability (#45846)
Fixes invalid yml caused by https://github.com/angular/angular/commit/509cab9972dc9ee3366649324e0b19ec9277d7f8

PR Close #45846
2022-05-02 16:33:44 -07:00
Pawel Kozlowski e7cd87d237 ci: mark pkozlowski as availabe for PR reviews (#45842)
Change pullapprove configuration to re-include pkozlowski

PR Close #45842
2022-05-02 15:35:36 -07:00
Ryan Day e59ed8ca14 build(bazel): change ngc-wrapped to use new bazelOpts.devmode (#45804)
bazelOpts.es5Mode is being removed and replaced with devmode. Adding a
check for either will allow a smooth migration.

PR Close #45804
2022-05-02 13:10:07 -07:00
dario-piotrowicz 26c7b5ec0c docs(docs-infra): improve clarity of toh-pt2 click code snippet (#45829)
make clearer that the click code snippet present in the tour of heroes
part 2 guide is not complete but adding ellipsis at the end of the
snippet and also by slightly tweaking the text introducing the snippet

resolves #45758

PR Close #45829
2022-05-02 11:42:12 -07:00
dario-piotrowicz ab011b7f84 fix(docs-infra): fix wrong heading structure in aio resources page (#45822)
in the aio resources page there is a main h1 heading and then the next
headings used are h3 and h4, thus h2 is being skipped, change such
headings so that there is no heading skipping (which is a bad practice
and can result to confusing experiences from screen reader users)

PR Close #45822
2022-05-02 09:20:38 -07:00
Paul Gschwendtner 839392523e build: updates to account for github primary branch rename
This is the commit accounting for the Github primary branch
rename when we actually perform the update.

We have three change phases: Prepare, Direct, Cleanup. This commit
is for the `direct` phase.
2022-04-28 17:24:46 +00:00
Andrew Scott 8cfb53df01 release: cut the v13.3.5 release (#45780) 2022-04-27 11:23:40 -07:00
dario-piotrowicz 73fda73d32 docs: empty alt of aio home decorative images (#45740)
in the aio home page the sections' decorative images provide an alt
texts, which shouldn't actually be present
(see: https://www.w3.org/WAI/tutorials/images/decorative/), empty such
alt text for a better user experience

PR Close #45740
2022-04-27 09:06:13 -07:00
dario-piotrowicz bed3362fe7 docs: use proper sections in aio home (#45740)
convert the `div` groups in the aio home page
to proper `section`s with a valid heading/title

PR Close #45740
2022-04-27 09:06:13 -07:00
dario-piotrowicz b838b4c60a docs: make sure aio home has a non-ignored h1 (#45740)
currently the aio home page presents a single h1 which is ignored by
assistive technologies since it has its display set none, so replace it
with a new h1 containing the main text of the page instead

PR Close #45740
2022-04-27 09:06:12 -07:00
dario-piotrowicz c5a6cff4af fix(docs-infra): fix alert child margin issue (#45761)
replace the generic `*` selector used in the alert styling with
`p` (which is what gets generated from the markdown) as the styling adds
margins which are not always wanted

PR Close #45761
2022-04-27 09:04:31 -07:00
Renovate Bot 3a645c6bfc build: update actions/checkout action to v3.0.2 (#45764)
PR Close #45764
2022-04-26 10:11:43 -07:00
Joey Perrott 63398e0eb4 fix(bazel): add this_is_bazel marker (#45728)
Add marker for noting that this check confirms we are running in a bazel environment.

PR Close #45728
2022-04-22 12:46:24 -07:00
George Kalpakas 81611dbc9d fix(docs-infra): fix placement of "Edit source" button on errors and diagnostics pages (#45634)
This commit aligns the layout of errors and extended diagnostics pages
more closely with other docs pages to ensure that the "Edit source"
button is displayed correctly even when the heading is too long to fit
on a single line. For error pages, in particular, this ensures that the
button is not obscured by the error video.

**Before:**
![error-pages before][1]

**After:**
![error-pages after][2]

[1]: https://user-images.githubusercontent.com/8604205/163408291-7aebd029-891c-4045-8fa2-a8e2b2b06dab.png
[2]: https://user-images.githubusercontent.com/8604205/163408296-40e6df8e-aadc-4a82-978a-ab4d902b6f6e.png

PR Close #45634
2022-04-21 11:07:27 -07:00
Andrew Kushnir 6f50fd9435 fix(docs-infra): include tslib into SystemJS config in upgrade-module example app (#45706)
This commit updates the SystemJS for one of the example apps (the `upgrade-module` one) to include a resolution rule for the `tslib`. This is needed in case `tslib` is referenced from the framework code (for example in case of downleveling of some operators). This makes it consistent with other example app configs.

PR Close #45706
2022-04-21 11:05:39 -07:00
Dylan Hunn 2ea541f4f8 release: cut the v13.3.4 release (#45702)
PR Close #45702
2022-04-20 14:31:12 -07:00
Andrew Kushnir dd7eeb6929 fix(docs-infra): avoid internal symbols from being referenced during auto-linking (#45689)
This commit adds extra logic to avoid internal and privately exported symbols from being referenced during auto-linking. Currently such symbols can be used for linking, thus resulting in a non-existing link and causing the linking process to fail.

PR Close #45689
2022-04-20 09:11:22 -07:00
Paul Gschwendtner 1d204fcf2c Revert "test(common): Fix flaky Location test (#45683)" (#45691)
This reverts commit 254d6cea9a.

This test has only been introduced in the next branch with
https://github.com/angular/angular/pull/44901. The cherry-pick
of the flaky test fix does not work in the patch branch due to
some other missing changes and the test did not exist in 13.3.x
anyway.

PR Close #45691
2022-04-20 08:58:46 -07:00
Paul Gschwendtner 7619c16697 build: preparation for primary branch rename in the Angular repos (#45691)
Preparation for the framework repo as outlined our planning
document.

PR Close #45691
2022-04-20 08:58:46 -07:00
Mangalraj 52a564df94 docs: Update aio/content/guide/setup-local.md (#45644)
Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>
PR Close #45644
2022-04-19 20:20:40 -07:00
Mangalraj bb7b51bbc6 docs: correct the example command to install angular (#45644)
PR Close #45644
2022-04-19 20:20:40 -07:00
Andrew Scott 254d6cea9a test(common): Fix flaky Location test (#45683)
This test has proven to be flaky. This commit greatly simplifies the
test and moves it to a more appropriate location (pun intended).

PR Close #45683
2022-04-19 20:17:56 -07:00
Saurabh Kamble 1e8fe84c05 Fix typo (#45680)
PR Close #45680
2022-04-19 09:26:14 -07:00
George Kalpakas 22ef5e0e60 docs(common): fix links to locales in i18n guides (#45661)
In PR #42230, the locale file generation process was modified so that
generated locale files are no longer checked into the repository. Update
a few links in the docs that pointed to the previously checked in files
to point to other places where the files exist.

PR Close #45661
2022-04-19 09:17:34 -07:00
Jeremy Elbourn c4e1d45418 build: don't assign jelbourn to most review categories (#45668)
Configure pullapprove to not automatically assign jelbourn to most review categories.

PR Close #45668
2022-04-19 09:15:40 -07:00
Louis Gombert d5a522a40a docs: update decorators proposal stage and link in glossary (#45669)
PR Close #45669
2022-04-19 09:14:37 -07:00
Andrew Kushnir ed832b4dd7 test: reset counters before running a styling test (#45670)
This commit updates one of the styling tests to reset perf counters, making it order-independent and non-flaky (previously the test got random failures depending on whether there are other tests invoked before).

PR Close #45670
2022-04-19 09:14:10 -07:00
Marko Kaznovac ebf98c4695 docs: use language agnostic mdn urls (#45666)
PR Close #45666
2022-04-18 14:10:17 -07:00
Marko Kaznovac ac8c896fff docs: fix mdn links (#45666)
PR Close #45666
2022-04-18 14:10:17 -07:00
dario-piotrowicz 37b3ac7f69 fix(docs-infra): implement focus trap for aio search results (#45654)
currently if a user tries to navigate via keyboard, once the are
presented with search results, the search results panel remains
present and can potentially hide most of the content on the page,
in such case keyboard navigation will be severly hindered and
the only option for the user would be to go back to the seach input
text and clear its value, fix such inconvenience by looping the
focus in the header area close to the search results and the
results panel itself

note: an alternative implementation using the cdkTrapFocus has been
attempted in PR #45194, such alternative implementation presented a
number of (minor) drawbacks (including the increase main bundle size
due to the inclusion of the A11yModule), so it was agreed to proceed
with the manual implementation present in these changes instead.

PR Close #45654
2022-04-18 09:57:53 -07:00
dario-piotrowicz b5820b6fa4 fix(docs-infra): fix aio search-results issue with toolbar and notification (#45579) (#45654)
use border-top-width instead of padding-top as the strategy for moving
the search-results panel down, this fixes the issue of the panel going
behind the toolbar (which causes either overlapping text in the home
page or the results scrollbar to be hidden behind the toolbar in other
pages)

PR Close #45579

PR Close #45654
2022-04-18 09:57:53 -07:00
dario-piotrowicz 26fe7642fe fix(docs-infra): amend notification close button aria-label (#45579) (#45654)
move the aria-label used inside the close-button to the button itself
(since otherwise the button's aria-label overrides the childs)

PR Close #45579

PR Close #45654
2022-04-18 09:57:53 -07:00
dario-piotrowicz 1564771b3a feat(docs-infra): add close button to search-results aio panel (#45579) (#45654)
add a close button to the search-results aio panel so that the user can
conveniently close it via keyboard

this complements the focus trap implemented in PR #44989
(more here: https://github.com/angular/angular/pull/44989#issuecomment-1037287678)

PR Close #45579

PR Close #45654
2022-04-18 09:57:53 -07:00
Andrew Kushnir 989ba8fb65 ci: add more reviewers to the docs-packaging-and-releasing group (#45652)
Currently that group has just 2 reviewers, but we often update the files that belong to that group during the deprecation period. Adding more people would allow to balance the reviews better.

PR Close #45652
2022-04-18 09:24:59 -07:00
Kristiyan Kostadinov 9317f513d5 fix(core): better error message when directive extends a component (#45658)
We throw an error when a directive is trying to extend a component, but we don't actually say which class is responsible which can be difficult to track down. These changes add the two class names to the error message.

PR Close #45658
2022-04-18 09:24:24 -07:00
ivanwonder d68333e508 fix(language-service): two-way binding completion should not remove the trailing quote (#45582)
We allow the path to contain both the `t.BoundAttribute` and `t.BoundEvent` for two-way
bindings but do not want the path to contain both the `t.BoundAttribute` with its
children when the position is in the value span because we would then logically create a path
that also contains the `PropertyWrite` from the `t.BoundEvent`. This early return condition
ensures we target just `t.BoundAttribute` for this case and exclude `t.BoundEvent` children.

Fixes https://github.com/angular/vscode-ng-language-service/issues/1626

PR Close #45582
2022-04-15 13:53:49 -07:00
Andrew Kushnir 4766817f02 fix(core): improve multiple components match error (#45645)
This commit improves the error message that is thrown at runtime when multiple components match the same element. Now the error message contains names of classes that represent those components.

PR Close #45645
2022-04-15 13:52:20 -07:00
Andrew Kushnir 575cafc163 test(core): add a test for multiple named interpolations with the same name (#45651)
The test from this commit verifies that i18n logic can handle multiple named interpolations with the same name.

PR Close #45651
2022-04-15 13:51:56 -07:00
Ilya Marchik acbd2e9339 docs: fix typo (#45637)
Replace wrong mention of 'heroService.delete()' with 'heroService.deleteHero()' because 'heroService.delete()' doesn't exist and 'heroService.deleteHero()' should be mentioned instead

Resolves #45636

PR Close #45637
2022-04-14 16:30:05 -07:00
Andrew Kushnir a1c741846d docs: move old changelog entries to a separate file (#45639)
This commit moves all release notes for everything before v11.0.0 to a separate file, so that the changelog can be rendered correctly via GitHub UI.

Closes #45635.

PR Close #45639
2022-04-14 15:01:49 -07:00
George Kalpakas 8d09451d89 docs(core): fix typo in View Encapsulation code example (#45629)
Fix closing tag name to match opening one (`</hero-detail>` -->
`<hero-details>`).

PR Close #45629
2022-04-14 15:00:06 -07:00
Andrew Kushnir ec115a31b8 refactor(core): avoid referencing PlatformRef in bootstrap code (#45519)
This commit updates an existing bootstrap logic to avoid referencing the `PlatformRef` instance to keep track of the platform status. Instead, we use platform injector, so that the `PlatformRef`can be tree-shaken away in the bootstrap logic for Standalone Components.

The motivation for this change is that retaining the `PlatformRef` class also retains NgModule-based bootstrap code, which would not be needed in case of Standalone Components.

PR Close #45519
2022-04-13 15:34:48 -07:00
Jessica Janiuk cbfe6284a2 release: cut the v13.3.3 release (#45614) 2022-04-13 11:27:48 -07:00
Kristiyan Kostadinov e50fd9ee87 fix(compiler): avoid errors with extremely long instruction chains (#45574)
Our logic for generating code from an AST uses recursion which limits the number of expressions we can nest before we reach the call stack limit. These changes add a limit in order to avoid errors in some cases where the chains become extremely long.

Fixes #45564.

PR Close #45574
2022-04-13 16:18:56 +00:00
4javier 5fe59706fd docs: fix grammar (#45455)
PR Close #45455
2022-04-12 23:55:33 +00:00
4javier cfb54c6a7b docs: fix to comply with new codeblock guidelines (#45455)
PR Close #45455
2022-04-12 23:55:33 +00:00
4javier 14268012ad docs: modified as per dylhunn suggestions (#45455)
https://github.com/angular/angular/pull/45455#pullrequestreview-925369970
PR Close #45455
2022-04-12 23:55:32 +00:00
4javier db7201fd84 docs: update template reference variables (#45455)
- Specify `NgForm` gets applied by default on `<form>` elements before the long example using it
- Move the strange (and questioned in a commented line) snippet about undefined ref vars in a standalone paragraph and clarify its meanings (adding the part about directive just because there was something similar already there)
- Extend and modify `*ngFor` example, since in the original that was misleading to think reference variable couldn't be used inside a loop
- Remove two lines stating that with `*ngIf` and `*ngFor` the framework cannot know if a template is ever instantiated (can't see how this relate with the page)
- Add an explanation of assignment of default `$implicit` value to undefined input variables
- Modify template example for template input variable to be a complete ngForOf loop instead of the original poor intelligible truncated one
- Replace last generic statements about variable namespaces with a more pragmatic and explanatory one concerning the resolution in case of homonymy

PR Close #45455
2022-04-12 23:55:32 +00:00
Andrew Kushnir fc145d024b refactor(core): make ComponentFactoryResolver lazily instantiated in ApplicationRef (#45507)
This commit removes the `ComponentFactoryResolver` as a constructor argument of the `ApplicationRef` class. This makes it lazily instantiated + simplifies further refactoring in a context of Standalone Components.

PR Close #45507
2022-04-12 22:29:17 +00:00
Andrew Kushnir 44b9d89917 refactor(core): make platform core providers tree-shakable (#45506)
This commit refactors the set of hardcoded platform core providers into tree-shakable providers.
In addition to making them tree-shakable, this would also avoid the need to rely on the platform creation logic in an upcoming bootstrap logic for Standalone Components.

PR Close #45506
2022-04-12 22:28:24 +00:00
Jason Hendee ae1db7a88d docs: make tutorial instructions consistent (#45372)
When starting this tutorial, it's not clear to the user whether they should add routing right away, Etc. The other tutorials within the routing section do a better job of this.

Also.. the suggested name of this sample app clashes with that of a previous tutorial, forcing the user to either delete the previous tutorial files, choose a different name for this tutorial's app, or place this app in a different parent directory.
 Conflicts:
	aio/content/guide/router-tutorial-toh.md

PR Close #45372
2022-04-12 22:27:38 +00:00
Dylan Hunn 5c9fe8de29 build: only allow renovate to run on Monday nights (#45605)
By running renovate once a week, we can consolidate all the updates into a single weekly PR, before each Wednesday release. That will significantly reduce the burden on caretakers, and make patch ports less onerous.

PR Close #45605
2022-04-12 22:26:49 +00:00
Virginia Dooley c49d23269c docs: new Pipes custom data doc (#45505)
PR Close #45505
2022-04-12 21:29:07 +00:00
Virginia Dooley 24212cd7ef docs: pipes custom data transform (#45505)
PR Close #45505
2022-04-12 21:29:07 +00:00
4javier d5b7c9610d docs: fix path typo (#45604)
PR Close #45604
2022-04-12 21:27:49 +00:00
4javier ddd822fdc5 docs: fix final code review section codetabs path (#45604)
Fix paths for codetabs in final review section messed up by this commit https://github.com/angular/angular/commit/42289f25c69ec7a36d2e3ef424d32f77bc7cd19a
They were all pointing to `heroes-search.component`
PR Close #45604
2022-04-12 21:27:49 +00:00
Michael-Doner d31f4de575 docs: add powershell execution policies note (#45576)
Fixes #44598

PR Close #45576
2022-04-12 21:13:59 +00:00
George Kalpakas 5900f0e133 docs(docs-infra): add missing period in aio/README.md (#45584)
PR Close #45584
2022-04-12 18:40:46 +00:00
Joe Martin (Crowdstaffing) 61894570f1 docs: improve markdown (#45590)
improve markdown for documentation. Duplicate of #45325 that targets 13.3.x.

PR Close #45590
2022-04-11 22:35:01 +00:00
Renovate Bot 09c5c18c7d build: update dependency google-closure-compiler to v20220405 (#45568)
PR Close #45568
2022-04-11 16:26:26 +00:00
Michal Materowski f09d16600b build: fix typo in package.json file comment (#45569)
Change comment in scripts section of package.json

PR Close #45569
2022-04-11 16:14:16 +00:00
George Kalpakas 1b2c67d9fd test(docs-infra): fix e2e test for {@example} dgeni tags (#45551) (#45563)
Previously, the `guide/compoent-style` page was used in e2e tests to
verify the behavior of `{@example}` dgeni tags. However, this guide has
been updated and no longer contains an `{@example}` tag.

This commit switches to using a different page (`api/common/NgIf`) that
does currently contain an `{@example}` tag.

(NOTE: This will also fix the [CI failures][1] in #45501.)

[1]: https://circleci.com/gh/angular/angular/1145424

PR Close #45551

PR Close #45563
2022-04-08 15:55:25 +00:00
George Kalpakas 2144b997fa fix(docs-infra): add shell to the list of code-example languages recognized as cli commands (#45551) (#45563)
Previously, only `language="sh"` and `language="bash"` would be
recognized (and formatted) as cli commands in `<code-example>`.

This commit adds `shell` to the list of languages recognized as cli
commands.

(NOTE: This will fix the [CI failures][1] in #45325.)

[1]: https://circleci.com/gh/angular/angular/1145559

PR Close #45551

PR Close #45563
2022-04-08 15:55:24 +00:00
Cédric Exbrayat 208d81921d refactor(core): validate property (#45528)
Simplifies and documents the `validateProperty` function (in a similar fashion that #45492 simplified `validateElementIsKnown`).

PR Close #45528
2022-04-07 22:03:13 +00:00
George Kalpakas 18f98e671b docs: remove out-of-order <h3> elements from footer (#45510)
The footer uses `h3` elements out of order, which causes a "Heading
elements are not in a sequentially-descending order" a11y error.
Replace the `h3` elements with `div` to improve a11y.

Fixes #44338

PR Close #45510
2022-04-07 21:01:58 +00:00
Hossein Mousavi dbd6e75b37 docs(forms): remove the incorrect set value from previous commit (#45533)
in the validators documentation, the value for the formControl for both required and requiredTrue validators is an empty string. This is OK for required since it gives us an error. But I think if we set the value of formControl responsible for requiredTrue to something other than an empty string (e.g.: 'some value'), it would demonstrate the difference between required and requiredTrue better.

PR Close #45533
2022-04-07 21:00:26 +00:00
Hossein Mousavi 6a5ee688df docs(forms): add value to formControl for better demonstration of requiredTrue validator (#45533)
in the validators documentation, the value for the formControl for both required and requiredTrue validators is an empty string. This is OK for required since it gives us an error. But I think if we set the value of formControl responsible for requiredTrue to something other than an empty string (e.g.: 'some value'), it would demonstrate the difference between required and requiredTrue better.

PR Close #45533
2022-04-07 21:00:26 +00:00
Andrew Kushnir fb5e16e018 release: cut the v13.3.2 release (#45548) 2022-04-06 08:47:13 -07:00
Andrew Kushnir 05121c0381 test(animations): update test to use an object instead of a Map (#45531)
The code in the patch branch is slightly different from the master branch: the master branch contains some changes where Map are used instead of objects in animations. As a result, one of the tests is failing in patch, since it expects Maps, but receives objects.

PR Close #45531
2022-04-05 10:31:48 -07:00
Christoph Guttandin a92bceda54 test(animations): add test for buildAnimationAst() function (#31107)
This commit adds a test for the buildAnimationAst() function.

PR Close #31107
2022-04-05 08:41:40 -07:00
Christoph Guttandin b46b25c562 fix(animations): handle structured AnimateTimings (#31107)
This commit makes sure structured AnimateTimings are not procesed any further when building the AST.

Fixes: #22752

PR Close #31107
2022-04-05 08:41:40 -07:00
Renovate Bot fc86fe5dad build: update dependency entities to v4 (#45509)
PR Close #45509
2022-04-04 14:54:17 -07:00
Cédric Exbrayat 9fcc1b7758 refactor(core): validate element is known in JIT mode (#45492)
Renames, simplifies and documents the function in charge of validating if an element is known in JIT mode.

PR Close #45492
2022-04-04 09:34:42 -07:00
Alan Agius ca7a143376 fix(docs-infra): update Angular packages to latest minor version (#45502)
This is needed because Angular CLI 13.3 contains fixes that are needed for Stackblitz Node 16 to compile Sass. We also added `copyfiles` in `aio/tools/examples/shared/package.json` as `yarn sync-deps` was failing due to the missing dependency.

PR Close #45502
2022-04-04 09:23:55 -07:00
piyush132000 5db99cae22 docs: add animations to readme file (#45488)
Updated readme file for adding animations topic in advance topics of Angular

PR Close #45488
2022-04-04 09:17:50 -07:00
mgechev a3d9c82ca4 docs: change roadmap updated date (#45500)
PR Close #45500
2022-04-01 13:33:08 -07:00
mgechev c21b68dcb8 docs: add details about ssr efforts (#45500)
PR Close #45500
2022-04-01 13:33:08 -07:00
Dylan Hunn 9c9a52540c release: cut the v13.3.1 release (#45485)
PR Close #45485
2022-03-30 14:21:53 -07:00
JoostK 7f53c0f4ac fix(compiler-cli): handle inline type-check blocks in nullish coalescing extended check (#45478)
This commit fixes an inconsistency where a type check location for an inline
type check block would be interpreted to occur in a type-checking shim instead.
This resulted in a missing template mapping, causing a crash due to an unsafe
non-null assertion operator.

In the prior commit the `TcbLocation` has been extended with an `isShimFile`
field that is now being used to look for the template mapping in the correct
location. Additionally, the non-null assertion operator is refactored such
that a missing template mapping will now ignore the warning instead of crashing
the compiler.

Fixes #45413

PR Close #45478
2022-03-30 11:34:41 -07:00
JoostK 3f55567111 refactor(compiler-cli): track whether a TcbPosition corresponds with a shim file (#45478)
Extends `TcbPosition` with a field that indicates whether the `tcbPath` is a
type-checking shim file, or an original source file with an inline type check
block.

This field is used in an upcoming commit that fixes an inconsistency with how
inline type check blocks are incorrectly interpreted as a type-checking shim
file instead.

PR Close #45478
2022-03-30 11:34:41 -07:00
JoostK fa90c74a73 refactor(compiler-cli): rename ShimLocation to TcbLocation (#45478)
Inline type check blocks (TCBs) are emitted into the original source file, but
node positions would still be represented as a `ShimLocation` with a `shimPath`
corresponding with the type-checking shim file. This results in inconsistencies,
as the `positionInShimFile` field of `ShimLocation` would not correspond with
the `shimPath` of that `ShimLocation`.

This commit is a precursor to letting `ShimLocation` also represent the correct
location for inline type check blocks, by renaming the interface to
`TcbLocation`. A followup commit addresses the actual inconsistency.

PR Close #45478
2022-03-30 11:34:41 -07:00
JoostK 09f8883826 test: update size golden to account for backport conflict (#45480)
The backport in #45473 introduced a change in payload sizes that is not met on
the 13.3.x branch, this commit corrects this issue.

PR Close #45480
2022-03-30 11:34:10 -07:00
AlirezaEbrahimkhani 7ab7734582 docs: add Angular university website to resources list (#45437)
PR Close #45437
2022-03-29 17:13:09 -07:00
Willian Corrêa 5061c4d41d Update aio/content/marketing/resources.json (#45076)
Co-authored-by: Alan Agius <alan.agius4@gmail.com>
PR Close #45076
2022-03-29 17:11:55 -07:00
Willian Corrêa 3b22121c38 docs: add Rangle's Angular Training book (#45076)
PR Close #45076
2022-03-29 17:11:55 -07:00
Andrew Kushnir 9c03b6371a docs: adding a missing close tag in AIO template (#45474)
Commit 6e45777f01 introduced a change where 1 closing tag was accidentally removed. This commit adds that tag back.

PR Close #45474
2022-03-29 16:46:24 -07:00
Dylan Hunn 6e45777f01 docs: patch port of #45376 (#45473)
PR Close #45473
2022-03-29 15:36:17 -07:00
Paul Gschwendtner 70006daac4 test: update aio payload size golden to reflect Angular update (#45469)
Updates the AIO payload size goldens to reflect the Angular update
affecting both the `aio` and `aio_local` build (due to CLI devkit
changes affecting both goldens, and the Angular update also affecting
the non-local `aio` build / job).

Patch-port of 6e1fce529a

Aside from AIO, the forms integration test size golden also
needs to be updated. A zonejs change caused the 500 bytes limit
to be exceeded. The change landed in `master` without exceeding,
but exceeded in the `13.3.x` branch (unrelated to the Angular
update). Manually confirmed by diffing the bundles that this change
is the culprit.

https://github.com/angular/angular/commit/c08705899f538bd2d26475c94c2832631c16977b

PR Close #45469
2022-03-29 13:13:08 -07:00
Paul Gschwendtner 63539489da test: update api goldens to reflect api-golden bazel rule change (#45469)
The API golden Bazel rule has changed in the shared dev-infra code. Instead
of putting golden API reports into the golden folder as per their original
location in the NPM package, golden reports are now stored based on the
package exports. This makes it more obvious how entry-points are consumable

As part of this change, since the API golden rule now consutls the NPM package
`exports` field, the `localize/tools` entry-point golden file is now generated.

Previously it wasn't generated due to it not having a secondary entry-point
`package.json` file. Such package json files should not be needed anymore
and will be gone in future APF versions.

PR Close #45469
2022-03-29 13:13:08 -07:00
Renovate Bot f7c9ac16ea build: update angular (#45469)
PR Close #45469
2022-03-29 13:13:08 -07:00
dario-piotrowicz 7bbf009216 fix(docs-infra): update a11y min-scores (#45209)
update (decrease) the value of some of the accessibility MIN_SCORES_PER_PAGE
after recent changes

PR Close #45209
2022-03-29 09:23:14 -07:00
dario-piotrowicz 0b96c37986 fix(docs-infra): assign different aria labels to main aio navs (#45209)
assign different aria labels to the primary nav and the one used for
guides and docs, so that impaired users can more easily distinguish the
two

PR Close #45209
2022-03-29 09:23:14 -07:00
dario-piotrowicz 9a82067c03 fix(docs-infra): remove redundant main roles (#45209)
remove redundant main role as pages should always have a
single element with a main role (also remove the role assigne
to the main tag as that is implied)

PR Close #45209
2022-03-29 09:23:14 -07:00
dario-piotrowicz 14cabb00d2 fix(docs-infra): wrap the main aio mat-toolbar in a header (#45209)
wrap the main aio mat-toolbar in a header element to provide better
accessibility

resolves #16938 (the first point)

PR Close #45209
2022-03-29 09:23:14 -07:00
dario-piotrowicz a1d9ce80f6 fix(docs-infra): remove navigation role to aio-top-menu ul (#45209)
currently the navigation ul used in aio-top-menu has a role of
navigation, but listitems should be owned by list parents
(see more: https://www.w3.org/TR/wai-aria-1.1/#listitem)
so wrap the ul in a nav and remove the role="navigation" from the
ul element to fix such issue

resolves #44562
resolves #16938 (the second point)

PR Close #45209
2022-03-29 09:23:14 -07:00
Andrew Kushnir 52e036a193 docs: add image directive to public roadmap (#45448)
PR Close #45448
2022-03-28 10:30:26 -07:00
JiaLiPassion c08705899f fix(zone.js): should ignore multiple resolve call (#45283)
Close #44913

The following case is not handled correctly by `zone.js`.
```
const delayedPromise = new Promise((resolve) => {
  setTimeout(resolve, 1, 'timeout');
});

new Promise((resolve) => {
  resolve(delayedPromise);
  resolve('second call');
}).then(console.log);
```

It should output `timeout`, since the promise is resolved by the
1st resolve, the `second call` should be ignored.

So this is a bug that the original implementation not ensure the
`resolve` is only called once.

PR Close #45283
2022-03-25 17:31:04 -07:00
Paul Gschwendtner 0c28997739 build: disable payload size uploading within bazel (#45446)
Uploading payload size is unreliable from within Bazel. This is
because tests might not run for every commit, tests might have
been cached from a pull request RBE-build (causing payload uploading
to be skipped most of the time as every change comes from a PR)

We should disable the uploading as this is a fundamental problem
(good thing to note now) that we can solve with better payload
size tracking that we want to establish as part of dev-infra.

PR Close #45446
2022-03-25 16:50:10 -07:00
arturovt 0dd532bcd6 fix(zone.js): swallow the error when the element callback is not patchable (#45400)
The `patchCallbacks` is used for patching the `document.registerElement` and
`customElements.define`. We explicitly wrap the patching code into try-catch since
callbacks may be already patched by other web components frameworks (e.g. LWC), and they
make those properties non-writable. This means that patching callback will throw an error
`cannot assign to read-only property`. See this code as an example:
https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186
We don't want to stop the application rendering if we couldn't patch some
callback, e.g. `attributeChangedCallback`.

PR Close #42546

PR Close #45400
2022-03-25 16:31:10 -07:00
Paul Gschwendtner 8d7fd91a67 ci: make payload size tracking script work with CircleCI and Bazel limitation (#45444)
For quite some time now, since we started to use Bazel for integration tests, we
relied on some size tracking logic that did not actually fully work under Bazel.

It was thought that all the necessary CI push/PR information is available to the
Bazel test, but that was not the case. This was now fixed with the recent Rules NodeJS
v5 update where I made sure the `env.sh` variables are actually available before we
write them to the temporary file for the Bazel-access.

This now will unveil an issue because payload size goldens would start being based
on their branch name. e.g. the golden key in `13.3.x` should not be `master` but
`13.3.x`. This makes more sense than `master` as key, but makes things more
cumbersome and ideally we would not store the branch name at all (this is a larger
change though -- not worth now since we might refactor this anyway). For now we will
update the size tracking logic to always use `master` as golden key (like it worked
in the past year(s))

With the environment fix we now (again) start uploading payload size results to Firebase.
This did not work by accident either. The uploading logic is reliant on the CircleCI
commit range which is not working/reliable in upstream branches. This commit
removes this reliance on `COMMIT_RANGE` since it's not strictly necessary and
currently breaking renovate PRs. We can re-enable this when we have a solution with
CircleCI, or a workaround/resolution logic provided in e.g. `ng-dev ci determine-commit-range`.

PR Close #45444
2022-03-25 14:25:04 -07:00
Paul Gschwendtner 88dbeda931 build: shorten partial compilation test case target names for windows (#45443)
Shortens the partial compilation test case target names as the paths/
manifest paths in Bazel became too large, exceeding some Windows path
length limits.

Relevant context/resources:
* https://angular-team.slack.com/archives/C02PARQNMC1/p1648137933069659 (internal)
* https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd
* https://github.com/bazelbuild/rules_nodejs/pull/3215/files#r782271592

PR Close #45443
2022-03-25 13:45:08 -07:00
Paul Gschwendtner a15c7e8f98 ci: improve stability of windows bazel CI job (#45443)
Improves stability of the Windows Bazel CI job by
installing Bazelisk globally.

Also makes the environment helpers more convenient by
evaluating the variable assignments directly, simplifying
some Bash logic.

PR Close #45443
2022-03-25 13:45:08 -07:00
Paul Gschwendtner 5ab0ca53b6 ci: dedupe top-level yarn install in circleci config (#45443)
Dedupes the Yarn run steps, avoiding the need to manually keep
this step in sync (e.g. with the timeout -- which is currently missing
for the windows job)

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner c24ea4b4f5 test: refactor compiler-cli compliance test to work on windows (#45443)
Recent changes in `rules_nodejs` caused the test case copy file actions
to be transitioned into the `exec` configuration, resulting in much larger
file paths. These paths break on Windows with the shell argument limit, and
with the path limit, causing errors like:

```
ERROR: C:/users/circleci/ng/packages/compiler-cli/test/compliance/test_cases/BUILD.bazel:9:12: Copying file packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_if_directive_def.js failed: (Exit 1): cmd.exe failed: error executing command
  cd /d C:/users/circleci/_bazel_circleci/u4uoan2j/execroot/angular
  SET PATH=C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;C:\Windows;C:\Windows\System32;C:\Windows\System32\WindowsPowerShell\v1.0
    SET RUNFILES_MANIFEST_ONLY=1
  cmd.exe /C bazel-out\x64_windows-opt-exec-2B5CBBC6\bin\packages\compiler-cli\test\compliance\test_cases\test_cases--1973427149-cmd.bat
The system cannot find the path specified
```

https://app.circleci.com/pipelines/github/angular/angular/44038/workflows/4b530cb2-f232-4e1d-b35a-e6e085151d08/jobs/1140017

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner c3b3b73e56 ci: make windows circleci job more robust and use git bash (#45443)
It is totally fine, and expected to use Git Bash for running Bazel
on Windows. In fact this is the most common setup for Bazel on Windows
and it's unrealistic to run without it.

This allows us to remove the old/legacy Powershell setup from CI
which is also quite flaky sometimes and does not reproduce how
Bazel is used on windows-users dev machines.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner b73d5aebe0 ci: temporarily disable components-repo-unit-tests job for Bazel NodeJS v5 update (#45443)
The Angular components repository can only start using Bazel Rules NodeJS v5
when `@angular/bazel` is published with support for it. To work around this
cycle we temporarily disable the unit tests job until we migrated the COMP
repo as well.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 3f5e685ca9 refactor: remove unused variables in starlark code to satisfy buildifier (#45443)
We updated buildifier and a few warnings became errors now. This commit
cleans up the failing unused variable instances, making the linter happy.

Additionally for the API extractor BUILD file, the package defaults
need to move to satisfy buildifier.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 69e4c9813e build: migrate more usages from @bazel/typescript to @bazel/concatjs (#45443)
As mentioned in previous commits (check them for more details), `@bazel/typescript`
no longer contains `ts_library`-specific code, so we no longer need that dependency.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 1eaaa5d1cc refactor(bazel): update api-extractor to account for @bazel/typescript change (#45443)
`@bazel/typescript` code moved to `@bazel/concatjs` for the tsc-wrapped code.

Note that this code is likely going to be removed anyway soon when we
move dts bundling from `ng_module` to `ng_package`.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 97e3b00e5b build: add temporary patch to make tsec compatible with rules_nodejs v5 (#45443)
Adds a temporary patch to make `tsec` compatible with `rules_nodejs` v5
until https://github.com/google/tsec/pull/25 is available/released.

PR Close #45443
2022-03-25 13:45:07 -07:00
Paul Gschwendtner 1a149bb50d refactor(bazel): update ngc-wrapped to account for tsc-wrapped move to @bazel/concatjs (#45443)
Previously `tsc-wrapped` which is the foundation for `ngc-wrapped`, resided
in `@bazel/typescript`. It has been moved to `@bazel/concatjs` in rules_nodejs
so we need to account for that as part of our rules_nodejs v5 update.

PR Close #45443
2022-03-25 13:45:07 -07:00
Renovate Bot 29d4b78ada build: update bazel (#45443)
Update `@bazel` packages to the latest 5.x version.

Some of the changes here are modeled after
angular/dev-infra@40c0ac8559.

Co-Authored-By: George Kalpakas <kalpakas.g@gmail.com>

PR Close #45443
2022-03-25 13:45:06 -07:00
Renovate Bot 2e79d09d85 build: update angular to 5a82e60 (#45443)
Update the `@angular/dev-infra-private` package to the latest commit.

PR Close #45443
2022-03-25 13:45:06 -07:00
arturovt dbd6be829f fix(zone.js): read Symbol.species safely (#45369)
We must read `Symbol.species` safely because `this` may be anything. For instance, `this`
may be an object without a prototype (created through `Object.create(null)`); thus
`this.constructor` will be undefined. One of the use cases is SystemJS creating
prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty
object and copies promise properties into that object (within the `getOrCreateLoad`
function). The zone.js then checks if the resolved value has the `then` method and invokes
it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read
properties of undefined (reading 'Symbol(Symbol.species)')`.

PR Close #45369
2022-03-24 18:56:37 -07:00
khai f869b9146a docs: update for 2022 angular events (#45386)
PR Close #45386
2022-03-24 14:29:50 -07:00
George Kalpakas 1a05e2dc48 build(docs-infra): upgrade cli command docs sources to 15ff62d4d (#45348)
Updating [angular#13.3.x](https://github.com/angular/angular/tree/13.3.x) from
[cli-builds#13.3.x](https://github.com/angular/cli-builds/tree/13.3.x).

##
Relevant changes in
[commit range](https://github.com/angular/cli-builds/compare/0f51d5c70...15ff62d4d):

**Modified**
- help/build.json
- help/generate.json
- help/serve.json
- help/test.json

PR Close #45348
2022-03-24 14:24:09 -07:00
mgechev aa29fc7b5c docs: update the public roadmap (#45415)
Change status of existing projects and add new projects we're working
on.

PR Close #45415
2022-03-24 11:29:30 -07:00
George Kalpakas b481eab39d fix(docs-infra): update (and unpin) dependency versions for preview server (#45390)
Update the `Dockerfile` used to create the preview server to use the
latest stable version of Debian (`bullseye`) and also update package
versions to latest versions.

Also, unpin the versions of installed packages (except for Node.js
related ones) as pinning proved problematic due to many packages
removing old versions from the official repositories.

NOTE:
This change will allow the preview server to be updated on the VM and
take advantage of recent fixes, such as #45349. Currently, the update
fails with the error:
```
E: Version '7.64.0-4+deb10u1' for 'curl' was not found
The command '/bin/sh -c apt-get update -y && apt-get install -y curl=7.64.0-4+deb10u1' returned a non-zero code: 100
```

PR Close #45390
2022-03-24 10:53:59 -07:00
arturovt 2b0da62937 fix(zone.js): check if process is defined when patching the GlobalErrors.install (#45392)
Jasmine checks internally if `process` and `process.on` is defined. Otherwise,
it installs the browser rejection handler through the `global.addEventListener`.
This code may be run in the browser environment where `process` is not defined, and
this will lead to a runtime exception since Webpack 5 removed automatic Node.js polyfills.

PR Close #42260

PR Close #45392
2022-03-24 10:52:35 -07:00
Paul Gschwendtner 960e42b2ac fix(bazel): ng module compilation workers are subject to linker race-conditions (#45393)
The Bazel NodeJS rules provide two ways of accessing node modules:

* A linker which creates a `node_modules` directory in the execroot/or in the runfiles.
* A patched module resolution where no node modules directory necessarily needs to exist.

The first is the default in `rules_nodejs` and the second is technically the most idiomatic
resolution mechanism in Bazel (as it matches with a runfile resolution library).

The linker is prone to race conditions in persistent workers, or non-sandbox environments (like
windows). This is because the linker for all workers will operate on a shared `execroot` directory
and the same `node_modules` directory is modified all the time / potentially conflicting with other
linker processes from other concurrently-running workers.

We rely on the patched module resolution anyway, but just need to disable the unused linker to avoid
issues like the following:

```
---8<---8<--- Start of log, file at /private/var/tmp/_bazel_splaktar/280f06d55552a0d01f89f0955b5acd78/bazel-workers/worker-8-TypeScriptCompile.log ---8<---8<---
[link_node_modules.js] An error has been reported: [Error: ENOENT: no such file or directory, unlink 'node_modules'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'unlink',
  path: 'node_modules'
} Error: ENOENT: no such file or directory, unlink 'node_modules'
---8<---8<--- End of log ---8<---8<---
INFO: Elapsed time: 12.796s, Critical Path: 5.39s
INFO: 645 processes: 477 internal, 12 darwin-sandbox, 156 worker.
```

PR Close #45393
2022-03-24 10:52:13 -07:00
Mike cc90fd55b2 docs(router): Fix typo on segments (#45411)
PR Close #45411
2022-03-24 10:49:36 -07:00
Joey Perrott 1734d1e07e fix(docs-infra): prevent framing of AIO with X-Frame-Options (#45419)
Prevent the docs site from being place in an iframe.

PR Close #45419
2022-03-23 12:20:49 -07:00
Ben Brook ee20410a98 docs(docs-infra): fix TypeScript casing (#45307)
PR Close #45307
2022-03-21 16:57:12 -07:00
Paul Gschwendtner 4321e4cdec build: update to bazel v5 for new runfiles API used in dev-infra (#45407)
https://blog.bazel.build/2022/01/19/bazel-5.0.html#starlark-build-language

PR Close #45407
2022-03-21 16:55:37 -07:00
JoostK 3714305f84 fix(compiler): scope css rules within @layer blocks (#45396)
This commit starts scoping CSS rules nested within `@layer` blocks.

Fixes #45389

PR Close #45396
2022-03-21 14:51:46 -07:00
Joey Perrott e5300d6d75 build(docs-infra): move to circleci v2 api for aio-builds (#45349)
Move to the CircleCI v2 api as the authentication fails for downloading artifacts using the v1 methods.

CircleCI v2 api now requires authentication to occur view the headers instead of being done in a
query parameter, all of the CircleCI interactions are now performed through one fetchFromCircleCi method
which ensures the token is provided in the headers as expected.

PR Close #45349
2022-03-17 14:03:27 -07:00
Andrew Scott 3700323e1c docs: changelog for v13.3.0 release (#45367)
PR Close #45367
2022-03-16 12:54:47 -07:00
Andrew Scott 1398acd90c docs: Revert changelog changes from "release: cut the v13.3.0 release (#45365)" (#45367)
This reverts commit CHANGELOG changes from f00f8c4863.

PR Close #45367
2022-03-16 12:54:47 -07:00
Andrew Scott f00f8c4863 release: cut the v13.3.0 release (#45365) 2022-03-16 12:07:42 -07:00
why520crazy 3148ab93a9 docs: add ngx-gantt to "EXPLORE ANGULAR RESOURCES" page (#45351)
PR Close #45351
2022-03-15 16:29:24 -07:00
Amer Yousuf 7ff4c0bf39 fix(forms): improve error message for invalid value accessors (#45192)
improve error message for invalid value accessors when accessor is not provided as array

PR Close #45192
2022-03-15 13:26:04 -07:00
Lee Cooper 2d51587f36 fix(docs-infra): fix tour of heroes global styles (#45329)
fix button styles in src/styles.css that are missing from code snippets

PR Close #45329
2022-03-15 13:24:53 -07:00
alirezaghey bb9b33053c docs: fix small English typo (#45340)
PR Close #45340
2022-03-14 13:10:20 -07:00
Andrew Scott 7eddf582a1 docs: Fix typo in issue template (#45327)
PR Close #45327
2022-03-14 09:31:02 -07:00
Paul Gschwendtner 2a437616bb ci: update payload size goldens to reflect zone.js update (#45298)
ZoneJS has been updated as part of the lock file refresh by Renovate. The
polyfills bundle reduced in size by around 4k which is due to some code
simplication in ZoneJS being finally released. This is the commit responsible
for the major reduction (also mentioning the reduction):

https://github.com/angular/angular/commit/0f298a13dbd141e5440d1388b124d03384641efe

PR Close #45298
2022-03-14 09:29:12 -07:00
Renovate Bot 956b022254 build: lock file maintenance (#45298)
Refreshes the lock file through Renovate.

PR Close #45298
2022-03-14 09:29:12 -07:00
Jessica Janiuk b839aeb2c1 refactor(core): Switch over to new closure LOCALE vs getLocale() (#45302)
This is a change requested via an LSC due to a deprecation.

PR Close #45302
2022-03-10 12:48:30 -08:00
Andrew Scott 0f8e748b07 release: cut the v13.3.0-rc.0 release (#45321) 2022-03-10 11:14:48 -08:00
Kristiyan Kostadinov 895c5417e3 Set up 13.3.0 release for TypeScript 4.6 support (#45319)
* feat(core): support TypeScript 4.6 (#45190)

Adds support for TypeScript 4.6.

PR Close #45190

* build: update version to 13.3.0

Bumps up the version to 13.3.0-next.0 so the tooling can pick it up.
2022-03-10 10:33:21 -08:00
Andrew Scott 6336b8e5b3 refactor(router): Make a few adjustments to createUrlTree for clarity (#45306)
* `tree` function now accepts the old root rather than the old
  `UrlTree`. The `urlTree` argument was only used to get the `root`.
  This change makes it more clear what that pararmeter is used for and
  what's actually being used
* Move the `oldRoot` (previously `urlTree`) to be the first argument of `tree`.
  This change now mirrors the argument order for `replaceSegment` and
  can be read from left to right more easily "in this root,
  replace this old segment group with this new segment group".
* Extract `newRoot` to a variable. This just makes it more clear what's
  going on at the end rather than combining a bunch of operations into
  one.

These changes are being made so that hopefully a future refactor can be
done which does not rely on the `urlTree` argument at all in the
`createUrlTree` function. These refactorings will make it easier to see
1:1 functionlity in these various places.

PR Close #45306
2022-03-09 13:52:38 -08:00
Alistair Kane 10de52887b docs: update <div> to <p> in lifecycle-hooks.md (#45063)
Changes <div> to <p> in description to match the elements in the screenshot.

Update lifecycle-hooks.md

Changes <div> to <p> in description to match the elements in the screenshot.

PR Close #45063
2022-03-09 13:52:16 -08:00
Andrew Kushnir 6f1c941dfe release: cut the v13.2.6 release (#45299) 2022-03-09 08:53:23 -08:00
Andrew Scott 9bce9ce89e fix(language-service): Prioritize Angular-specific completions over DOM completions (#45293)
When authoring Angular templates, developers are likely to be most interested in
the current Directive/Component inputs and outputs, then potential
attributes which would match other directives to the element,
and lastly the plethora of DOM events and attributes.

This change ensures that Angular-specific information appears above DOM
information by prepending the first printable ASCII characters to the
sort text.

Fixes https://github.com/angular/vscode-ng-language-service/issues/1537

PR Close #45293
2022-03-08 14:48:38 -08:00
Andrew Scott 8227eb914e refactor(migrations): update isReferenceToImport to not use valueDeclaration (#45292)
valueDeclaration is only set when the Symbol type is a `Value`:

* [setValueDeclaration](https://sourcegraph.com/github.com/microsoft/TypeScript@d8b21a8d6cef772fea5cf2a507b651c5d38194bd/-/blob/src/compiler/binder.ts?L321-322)
* [Value union](https://sourcegraph.com/github.com/microsoft/TypeScript@d8b21a8d6cef772fea5cf2a507b651c5d38194bd/-/blob/src/compiler/types.ts?L4849:9#tab=references)

This won't be the case if the symbol is an interface (notice that `Interface` is not in the union for `Value` above).

For this reason, we can't rely on the `valueDeclaration` property of the symbol.
Instead, it's more reliable to just compare the first items in the `declarations` list.

PR Close #45292
2022-03-08 13:13:26 -08:00
Renovate Bot 23003f817f build: update actions/checkout action to v3 (#45248)
PR Close #45248
2022-03-08 10:28:32 -08:00
Mladen Jakovljević d98ce5ed4f fix(docs-infra): remove anchor tags from heritage docs (#45287)
Remove anchor tags from heritage docs and let `autoLinkCode` insert them properly.

PR Close #45287
2022-03-08 10:26:50 -08:00
Luca cff1c5622f fix(service-worker): file system hash in batch of 500 elements (#45262)
Add file system concurrency hash test

Fixes #45133
PR Close #45262
2022-03-08 10:23:39 -08:00
Andrew Scott 6efa366e2c fix(compiler): compute correct offsets when interpolations have HTML entities (#44811)
When parsing interpolations, the input string is _decoded_ from what was
in the orginal template. This means that we cannot soley rely on the input
string to compute source spans because it does not necessarily reflect
the exact content of the original template. Specifically, when there is
an HTML entity (i.e. `&nbsp;`), this will show up in its decoded form
when processing the interpolation (' '). We need to compute offsets
using the original _encoded_ string.

Note that this problem only surfaces in the splitting of interpolations.
The spans to this point have already been tracked accurately. For
example, given the template `&nbsp;<div></div>`, the source span for the
`div` is already correctly determined to be 6. Only when we encounter
interpolations with many parts do we run into situations where we need
to compute new spans for the individual parts of the interpolation.

PR Close #44811
2022-03-08 10:23:08 -08:00
Srikanth Kolli ad9d98146e docs: Change tag name to TD from TR in context of colspan usage (#45257)
PR Close #45257
2022-03-07 15:41:37 -08:00
nanda18 8390e12bdd docs: update flush description to include microtasks (#45237)
PR Close #45237
2022-03-07 15:41:08 -08:00
Renovate Bot 43bbaf810d build: update dependency google-closure-compiler to v20220301 (#45260)
PR Close #45260
2022-03-07 14:30:47 -08:00
Renovate Bot 6842bf0515 build: update dependency magic-string to v0.26.1 (#45247)
PR Close #45247
2022-03-07 14:29:46 -08:00
Kristiyan Kostadinov f261fa7c08 test(compiler): fix deprecation warning (#45285)
Jasmine logs a warning when there's a `describe` with no tests. These changes fix one such case in the compiler that happens when the tests are run against Windows.

PR Close #45285
2022-03-07 11:36:48 -08:00
JiaLiPassion d29883adff ci: components CI test should use local zone.js build (#45277)
CI components test install the angular package from the local
version, but still use the zone.js from npm, so this commit let
components also install zone.js from local too.

PR Close #45277
2022-03-07 11:35:00 -08:00
Andrew Scott de67c9fd01 refactor(router): Use helper function to throw NoMatch (#45244)
This update matches the other locations where noMatch is thrown.

PR Close #45244
2022-03-04 15:24:14 -08:00
Joey Perrott 9a8ef7cc28 build: patch snapshot issue in dev-infra selecting the latest version tag (#45269)
Local patch ahead of landing of https://github.com/angular/dev-infra/pull/449

PR Close #45269
2022-03-04 15:23:40 -08:00
Anner Visser 4e1d825d83 docs: change link for devtools to angular repo (#45207)
PR Close #45207
2022-03-03 12:28:25 -08:00
Aristeidis Bampakos 356c521195 docs: add Greek localization for Angular Docs (#45152)
PR Close #45152
2022-03-03 12:27:53 -08:00
JiaLiPassion 9a7eba2352 fix(zone.js): defineProperties should also set symbol props (#45098)
Close #44095

Fix `defineProperties` patch not set `symbol` props issue.

Co-authored-by: varomodt<varomodt@users.noreply.github.com>
Co-authored-by: AndrewKushnir<AndrewKushnir@users.noreply.github.com>

PR Close #45098
2022-03-03 12:22:05 -08:00
Andrew Scott e16dab82a1 refactor(router): Remove special logic for hybrid apps (#45240)
This commit removes special (undocumented) logic in the Router code that is
meant to prevent duplicate navigations that result from location syncs in
AngularJS/Angular hybrid applications.

The duplicate navigations can occur when both the Router and the AngularJS sync
code detect a location change via a popstate/hashchange event. When this
happens, the Angular Router schedules a navigation to sync itself with
the browser, but the hybrid listener may also schedule an additional
navigation. There are a few reasons this logic should not be included in
the Router:

* This special logic is not tree shakeable so it introduces a bundle
  size cost for all applications, most of which don't need it.
* There have been many updates to the routing pipeline to tolerate
  duplicate navigations. That is, duplicate navigations can happen and
  routing should still complete successfully.
    * https://github.com/angular/angular/commit/0e8548f667e5fdefa3ac7cdf1ba47e3e17011ffc
    * https://github.com/angular/angular/commit/9e039ca68bfae5328f3fc1f16fabd7673c466a25
* The logic is really in the wrong place: The hybrid sync code should be
  the location to handle this. If duplicate navigations are meant to be
  avoided, the hybrid sync code should have handling to _not_ trigger
  duplicate navs.
* This logic _also_ used to exist because the mock location
  helper used for test incorrectly triggered popstate events during
  router navigations. In order to avoid unexpected behavior in tests, this
  logic needed to be added. This incorrect mocking may also have been
  put in place because the upgrade module _would_ see a location change
  event and trigger a duplicate navigation.  The location mock has since been updated to
  match real browser behavior so this is no longer necessary. The
  upgrade module has also been updated to not trigger duplicate
  navigations.  The following commits are related to this:
    * https://github.com/angular/angular/commit/202a1a56314af4ddb99c476f974536a10e390319
    * https://github.com/angular/angular/commit/c6a93001eb74374b0fbc6aea1286fe1183d21382

Side note: The `setTimeout` in the location change listener is used to
ensure the ordering of duplicate navigations was consistent. You can see
that the logic being removed here expects the imperative navigation to precede the
popstate/hashchange. With the removal of this code, the `setTimeout` no
longer serves a purpose. However, it has been found that tests can rely
on this behavior (incorrectly) because they expect the navigation to be
complete but in reality, it hasn't even started because the test has not
flushed the timeout. Removing the timeout would be a breaking change as
a result.

PR Close #45240
2022-03-03 09:14:39 -08:00
Paul Gschwendtner 913bbba42b ci: update aio payload size golden to reflect Angular update (#45239)
Similar to 63e9cc7cba, but for the
patch branch where the `aio` job increased in total by ~100b.

New total: 718427 bytes
Before total: 718357 bytes

PR Close #45239
2022-03-03 09:14:08 -08:00
Joey Perrott c7e5cb0371 build: update .pullapprove.yml (#45061) (#45239)
Remove errant extra space in fw-compiler glob matcher.

PR Close #45061

PR Close #45239
2022-03-03 09:14:08 -08:00
Paul Gschwendtner aa616db24f build: update tooling to use new entry-point for dev-infra exports (#45239)
Previously, dev-infra only bundled the CLI with all its dependencies, while
we still also kept all bundled dependencies in the `dependencies`. This basically
meant that the CLI bundling did not provide any value at all.

We fixed this upstream and now dependencies are still bundled, but no longer
also declared as `dependencies`. We also stopped shipping deep JS files, only
shipping the bundles now.

As part of this deep file removal, we introduced a runtime entry-point for
exports/types. This one will also benefit from the bundling and it will be
predictable what symbols dev-infra consumer projects rely on (allowing us to
also have an API guard or something in the future).

PR Close #45239
2022-03-03 09:14:08 -08:00
Renovate Bot de9290096c build: update angular (#45239)
Updates Angular through Renovate. Patch port.

PR Close #45239
2022-03-03 09:14:08 -08:00
Kristiyan Kostadinov 2c7d96afcb build: add retry logic to postinstall script (#45252)
Several people on the team (myself included) have had issues where the `webdriver-manager` step of the `postinstall` script fails on the first run, but work correctly on the second one.

These changes attempt to simplify the workflow by retrying the script up to 3 times before giving up.

PR Close #45252
2022-03-03 09:13:26 -08:00
Jessica Janiuk 8bf3b53a1d release: cut the v13.2.5 release (#45241) 2022-03-02 10:18:07 -08:00
Andrew Kushnir 56ca7d385b perf(common): make NgLocalization token tree-shakable (#45118) (#45226)
This commit updates the `NgLocalization` token to become tree-shakable (vs using a direct reference to that token in the `providers` section of the `CommonModule`). The `NgLocalization` token is used for apps that use i18n and for other apps it would be excluded from the bundle.

PR Close #45118

PR Close #45226
2022-03-02 01:02:54 +00:00
Theodore Brown e8fd452bd2 fix(core): remove individual commands for updating gold files (#45198)
The documented command for updating the forms gold files was outdated
and didn't work. Since this command list can easily become outdated,
remove the individual commands in favor of the simpler global scripts.

PR Close #45198
2022-03-01 19:16:53 +00:00
Andrew Kushnir 71ff12c1cc perf(core): make LOCALE_ID and other tokens from ApplicationModule tree-shakable (#45102) (#45222)
The `ApplicationModule` module has a number of tokens declared as non-tree-shakable providers. This commit updates them to make tree-shakable.

PR Close #45102

PR Close #45222
2022-03-01 18:38:18 +00:00
Andrew Kushnir 82d772857c perf(core): make Compiler, ApplicationRef and ApplicationInitStatus tree-shakable (#45102) (#45222)
The `Compiler`, `ApplicationRef` and `ApplicationInitStatus` classes are registered as non-tree-shakable providers in the `ApplicationModule`. This commit converts them to the tree-shakable providers instead.

PR Close #45102

PR Close #45222
2022-03-01 18:38:17 +00:00
Andrew Kushnir 2bebaa99cf refactor(core): drop unused SCHEDULER provider (#45102) (#45222)
The `SCHEDULER` provider was used previously when both ViewEngine and Ivy code was present. After some prior refactoring, all references to the `SCHEDULER` token were removed, but the token itself remains present in the `ApplicationModule`, which makes it non-tree-shakable.

This commit removes the `SCHEDULER` token as unused.

PR Close #45102

PR Close #45222
2022-03-01 18:38:17 +00:00
dario-piotrowicz 8907fbbfed docs: improve structure of http example (#44986)
improve the http aio example by:
 - adding a background color to the messages section so that it
   can be distinguished from the others
 - avoid using `hr` elements to divide the various sections, use
   css instead (so that the divisions can also be omitted when
   the sections are not being shown)
 - fix the erroneous presence of an input text element inside a button
   (see: https://github.com/angular/angular/pull/44557#discussion_r787239658)

PR Close #44986
2022-02-28 19:31:25 +00:00
Guillaume Bonnet 84b4ad812b docs(docs-infra): fix the stackblitz on page i18n-example (#45097)
The previous configuration didn't allow to serve in any language.

Fixes #45066

PR Close #45097
2022-02-28 17:25:41 +00:00
Paul Gschwendtner 76c6dca93f ci: instruct renovate to not update/override merge ready PRs (#45204)
Sometimes Renovate proposes an update and we need to add some
manual fixups, like updating a size golden. For this we push to
same upstream branch.

Renovate will update the PR though when another new revision/version
becomes available, overriding the fixup and discarding it.

This happened quite often now and causes significantly more
work required by the dev-infra time..

PR Close #45204
2022-02-25 22:10:55 +00:00
Paul Gschwendtner 85546594a5 ci: fix stamping for builds performed in CI (#45147)
Fixes the stamping for snapshot builds and the artifact deployment job.
Currently the stamped versions will have the `.with-local-changes` version
suffix given that we add a file to the Git repo that is just
needed for the CircleCI cache key computation.

PR Close #45147
2022-02-25 19:14:05 +00:00
JoostK 55b8c4f701 ci: allow Babel to be updated by Renovate (#45203)
Automatic updating of Babel was disabled because there were build failures
when using the latest version of Babel, but these have been resolved in
#44931. This commit removes Babel packages from Renovate's ignored list
to allow automatic updates again.

PR Close #45203
2022-02-25 19:13:23 +00:00
JoostK 1e6f700b7d refactor(localize): update version of Babel (#45203)
The `@angular/localize` package depends on a version of Babel that is two years
old, so this commit updates to the latest version.

Some changes were made to the linker and compliance tests to account for slight
changes in source maps, along with a few code updates because of changes to
the typings of Babel.

PR Close #45203
2022-02-25 19:13:23 +00:00
Andrew Scott 01fde59dd9 refactor(router): Refactor errors in applyRedirects to use common throwError function (#45170)
The implementation of `throwError` in `rxjs` is identical to what is
done manually in the Router code.

PR Close #45170
2022-02-24 23:50:01 +00:00
Andrew Scott a4debf14e3 refactor(router): Update match result to be more explicit (#45170)
The `lastChild` property in the match result is only used to compute the
remaining segments (i.e. the ones which were not consumed). The updated
type here makes it easier to use and more clear.

PR Close #45170
2022-02-24 23:50:01 +00:00
dario-piotrowicz c6e64aa8ad docs: fix style guide example app included as routing (#45148)
in the aio example apps page the style guide for documentation
contributions is included in the Routing section instead of being
in its own section, add a documentation section and include the example
in that one

PR Close #45148
2022-02-24 22:57:54 +00:00
Charles Lyding 7379d75782 ci: add permissions to current github action workflows (#45177)
The currently recommended best practice for Github action workflows is to set top-level permissions to read only. And if the job uses the automatic `GITHUB_TOKEN`, fine-grained permissions for each job based on the job's requirements should also be added.
All existing workflows in the repository now have top-level read only permission blocks.
Only the `scorecard` workflow currently requires additional job level permissions and the minimum set of permissions were already present for the job.

PR Close #45177
2022-02-24 21:39:38 +00:00
Jessica Janiuk 21a51fb6a4 test(animations): Fix flaky animations e2e test (#45196)
This adds a 300ms wait to the animations tests to ensure they are fully done animating before asserting.

PR Close #45196
2022-02-24 13:15:33 -08:00
dario-piotrowicz b39db80f91 test(animations): add route animation delay to pages tests (#45144)
PR #44550 introduced an animation for pages/tabs transitions in the
animations example application, after such change intermittent e2e
failures started to occur (see for example: #45083), add a delay to
account for such animation to all the animations pages/tabs e2e tests so
to fix the flakyness caused by the animation

PR Close #45144
2022-02-24 18:41:56 +00:00
Martin Sikora 3b86dda068 refactor(http): change <script>'s ownerDocument in jsonp teardown (#36807)
handler

Cancel pending json handler by adopting its <script> element into
another document
(https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block)
This way the browser will prevent the script from being parsed and executed.

Fixes #34818

PR Close #36807
2022-02-24 17:24:34 +00:00
Martin Sikora 64da1daa78 fix(common): canceled JSONP requests won't throw console error with missing callback function (#36807)
This commit fixes a use-case where unsubscribing from a JSONP request will result in "Uncaught ReferenceError: ng_jsonp_callback_xy is not defined"
thrown into console. Unsubscribing won't remove its associated callback function because the requested script will finish
loading anyway and will try to call the handler.

PR Close #34818

PR Close #36807
2022-02-24 17:24:34 +00:00
JoostK d388522745 fix(localize): avoid imports into compiler-cli package (#45180)
The compiler-cli's declaration files are not necessarily compatible with web
environments that use `@angular/localize`, and would inadvertently include
`typescript` declaration files in any compilation unit that uses
`@angular/localize` (which increases parsing time and memory usage during
builds) using a default import that only type-checks when
`allowSyntheticDefaultImports` is enabled.

Fixes #45179

PR Close #45180
2022-02-24 17:12:10 +00:00
dario-piotrowicz 4f1870362e docs: remove activatedRouteData backward accesses in aio guides (#45140)
developers should not access the router-outlet directive in their
template before defining a template variable for it, such
implementation is present in a couple of aio guides, fix such guides
so that they show the more correct way of accessing the outlet's data

resolves #36173

PR Close #45140
2022-02-24 00:55:19 +00:00
ivanwonder 6c906a5bb9 fix(compiler-cli): Support resolve animation name from the DTS (#45169)
Before this, the compiler resolves the value in the DTS as dynamic.
If the `trigger` is imported from `@angular/animations`, this PR will
use FFR to simulate the actual implementation in JS and extracts the
animation name.

PR Close #45169
2022-02-24 00:54:33 +00:00
dario-piotrowicz 6c61d20476 fix(animations): allow animations with unsupported CSS properties (#45185)
currently animations with unsupported CSS properties cause a hard error
and the crash of the animation itself, instead of this behaviour just
ignore such properties and provide a warning for the developer in
the console (only in dev mode)

this change also introduces a general way to present warnings
in the animations code

resolves #23195

PR Close #45185
2022-02-24 00:53:50 +00:00
Andrew Scott e914da145b release: cut the v13.2.4 release (#45181) 2022-02-23 12:35:31 -08:00
Alan Cohen 6550c59df5 docs: fix test description to match code example (#45101)
PR Close #45101
2022-02-23 08:58:41 -08:00
Daniele Maltese 032276253f fix(docs-infra): removed duplicated style in aio examples (#45157)
Removed duplicated style in aio example scss files.

PR Close #45157
2022-02-22 15:35:17 -08:00
Renovate Bot d607d0b93c build: update ossf/scorecard-action commit hash to 3662744 (#45162)
PR Close #45162
2022-02-22 12:48:12 -08:00
Paul Gschwendtner c02e4d72bc ci: update SHA for components-repo-unit-tests job to fix flakiness (#45166)
This commit attemps to fix the flakiness that shows up sometimes
in the `components-repo-unit-tests` job. See:

https://app.circleci.com/pipelines/github/angular/angular/43024/workflows/fa9bc546-179a-4215-a7f1-db123efa0fa4/jobs/1126909

We updated Firefox/Chromium in dev-infra, hoping to fix this non-reproducable
flakiness (also checked memory/CPU consumption in the test). So far it looks like
the update helped in the COMP repo so we should try it here as well.

PR Close #45166
2022-02-22 10:20:32 -08:00
Renovate Bot 4d2ef0f5df build: update scorecard action dependencies to 040feef (#45135)
PR Close #45135
2022-02-18 13:57:04 -08:00
JoostK 1a4b489692 perf(animations): improve algorithm to balance animation namespaces (#45113)
The prior approach would consider all existing namespaces from back to front
to find the one that's the closest ancestor for a given host element. An
expensive `contains` operation was used which needed to traverse all the
way up the document root _for each existing namespace_. This commit implements
an optimization where the closest namespace is found by traversing up from
the host element, avoiding repeated DOM traversal.

Closes #45055

PR Close #45113
2022-02-18 13:44:44 -08:00
Andrew Kushnir cbd23ee0de perf(core): make IterableDiffers and KeyValueDiffers tree-shakable (#45094) (#45115)
This commit removed references to the `IterableDiffers` and `KeyValueDiffers` classes from the `ApplicationModule`, which effectively make them tree-shakable. Both classes have `prov` static field with the right setup, so they'll be properly initialized when referenced.

PR Close #45094

PR Close #45115
2022-02-18 13:43:05 -08:00
manuelkroiss 5d08390584 docs: replace deprecated SwUpdate#available/activated with new API (#44858)
Since `SwUpdate#available` and `SwUpdate#activated` are deprecated, the new way should be included in the docs instead of the deprecated one.

docs: added missing imports

added imports for VersionReadyEvent, filter, and map

docs: updated service-worker-communications.md

rewrite of SwUpdate service to describe the new versionUpdates property

docs: Apply suggestions from code review

Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>

docs: added events

added VERSION_DETECTED and VERSION_INSTALLATION_FAILED

docs: Apply suggestions from code review

Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>

PR Close #44858
2022-02-18 13:40:35 -08:00
dario-piotrowicz 9b1d3d2fce fix(docs-infra): make hamburger menu non focusable when not visible (#45067)
the header hamburger menu gets removed from the page by moving it
outside the screen, it can however still be accessed via keyboard
navigation, add a visibility hidden to the element to prevent such
behavior

PR Close #45067
2022-02-18 13:36:11 -08:00
dario-piotrowicz f71eb58036 docs(animations): remove query call in animations example (#45126)
the query call used for the transition between the Home and About tabs
doesn't work as intented since it doesn't find any matching element,
remove such quering since it is not needed

PR Close #45126
2022-02-18 13:35:23 -08:00
David Wolf f7a2dd88aa docs(forms): remove type duplicate from button in reactive-forms example (#45124)
PR Close #45124
2022-02-18 13:35:00 -08:00
AlirezaEbrahimkhani 031e23b06a docs: solve the problem with Dynamic Component guide example (#45123)
solve ExpressionChangedAfterItHasBeenChecked error by changing the angular lifecycle hook ngAfterViewInit to ngOnInit

resolves angular#44925

PR Close #45123
2022-02-18 13:33:16 -08:00
Alan Cohen 5b0980f050 docs: fix test examples to use withContext (#45100)
PR Close #45100
2022-02-18 13:32:45 -08:00
Alex Rickabaugh 54d09a6bc0 release: cut the v13.2.3 release (#45116)
PR Close #45116
2022-02-16 15:50:24 -08:00
Renovate Bot 782f678236 build: update scorecard action dependencies to c4e058a (#45036)
PR Close #45036
2022-02-16 13:52:24 -08:00
JiaLiPassion 62cec95981 test(zone.js): add integration test for zone.js Mocha patch (#45047)
Add integration test for `Mocha` patch from `zone.js` to verify the
issue #42384 is fixed

PR Close #45047
2022-02-16 13:51:52 -08:00
JiaLiPassion 2ec696a50f fix(zone.js): patch global instead of Mocha object (#45047)
Close #42834

In the new version fo Mocha, all global test functions are from `global`
object instead of `Mocha` object. Adn the current `zone.js` Mocha
patch's logic looks like this.

```
global.describe = Mocha.describe = function() {
  return originalMochaDescribe.apply(this, arguments);
}
```

and `originalMochaDescribe` is the unpathced Mocha implementation
looks like this

```
function describe() {
  return context.describe(...);
}
```

And the `context` will finally delegate to `global.describe()`,
so the current `zone.js` patch causes infinite loop.

This commit will not patch function of `Mocha` object any longer.

PR Close #45047
2022-02-16 13:51:52 -08:00
Aristeidis Bampakos 119fbddb83 docs: clarify install of build schematics deps (#45104)
PR Close #45104
2022-02-16 13:44:47 -08:00
Yousaf Nawaz e8e09d3455 docs: fix typos (#45103)
correct word 'questionaire' to 'questionnaire' in Building dynamic forms guide

PR Close #45103
2022-02-16 13:42:45 -08:00
AlirezaEbrahimkhani d7c20c8886 docs: fix case types guide (#45095)
fix case types guide text for more detailed guidance

PR Close #45095
2022-02-16 13:36:08 -08:00
AlirezaEbrahimkhani 3e1fad406a docs: remove duplicate link (#45095)
The link to complete schema, is exactly the same as the one above

PR Close #45095
2022-02-16 13:36:08 -08:00
zuckjet aeeb1b55d3 docs(localize): fix angular.json syntax error about i18n (#45048)
In chapter internationlization at section "Deploy multiple locales" the
syntax for angular.json is wrong.

Close #45032

PR Close #45048
2022-02-15 12:31:12 -08:00
AlirezaEbrahimkhani 331383b39b docs: fix grammatical error (#45092)
'an' is replaced with 'a' for the adjective 'straightforward'

resolves angular#45075

PR Close #45092
2022-02-15 12:29:59 -08:00
Jessica Janiuk 0050b01b62 perf(animations): made errors in the animations package tree shakeable (#45079)
This moves all the error strings into exported functions that can be tree shaken away.

PR Close #45079
2022-02-14 16:13:36 -08:00
Jessica Janiuk e632fd1f0f test(animations): Fix e2e intermittent failures (#45083)
This addresses a problem with animations e2e tests that were failing intermittently due to a missing timeout value

PR Close #45083
2022-02-14 15:45:41 -08:00
mgechev 128038e486 docs: extend the LTS for ngUpgrade with a year (#45078)
PR Close #45078
2022-02-14 14:06:59 -08:00
dario-piotrowicz 42c8533f42 docs(animations): clarify information about query with :leave (#45059)
add information to the query api docs clarifying that elements with
a trigger can be queried via `:leave` when their parent is leaving

this exception is potentially something to be changed (see #45058)
but for the time being the docs can be updated to make the users
aware of such behavior

PR Close #45059
2022-02-14 14:05:22 -08:00
Mina Hosseini Moghadam 2cc8fb0a08 docs: change dependencies to devDependencies in document (#45053)
after installing @angular/localize package, it will be placed in devDependencies object
PR Close #45053
2022-02-14 14:03:45 -08:00
Patrick Cameron 4013db6fd2 fix(docs-infra): fix broken link in Glossary (#45068)
Fix broken link in Glossary document

PR Close #45068
2022-02-14 12:51:30 -08:00
Dario Piotrowicz 95ee74a66c docs(animations): improve aio animations guides info around :enter/:leave (#44550)
improve the aio animations guide information around elements entering and
leaving, this includes, querying them, their transitions and also improvements
to the animations guide live examples

PR Close #44550
2022-02-14 09:16:30 -08:00
markostanimirovic a782be62e9 refactor(docs-infra): replace deprecated toPromise usages (#45045)
This commit replaces deprecated `Observable.toPromise` usages
with `lastValueFrom`.

PR Close #45045
2022-02-11 14:34:28 -08:00
markostanimirovic dc4115d7ed refactor(docs-infra): replace deprecated subscribe usages (#45046)
This commit replaces deprecated `Observable.subscribe` usages.

PR Close #45046
2022-02-11 14:33:46 -08:00
Renovate Bot d8a18717da build: update angular (#45040)
Update Angular packages to latest versions.

PR Close #45040
2022-02-10 09:16:14 -08:00
Srdjan Milic dd177e2c18 refactor(http): deprecated symbol used (#44985)
Support for passing an error value to "throwError" method will be removed in v8 of rxjs. More info at https://rxjs.dev/api/index/function/throwError#throwerror

PR Close #44985
2022-02-09 11:46:32 -08:00
dario-piotrowicz 0b8208690c docs: improve try-it-now card focus area (#45002)
the focus/interactable area for the try-it-now card is wider than
necessary, reduce such width to the appropriate size

PR Close #45002
2022-02-09 10:23:08 -08:00
Renovate Bot 7af1f0a265 build: update scorecard action dependencies to 7f9dca2 (#45026)
PR Close #45026
2022-02-09 10:21:47 -08:00
Renovate Bot d0b88a6810 build: update angular (#44981) (#45027)
Updates Angular

PR Close #44981

PR Close #45027
2022-02-09 10:18:09 -08:00
Renovate Bot fd860e3ef7 build: lock file maintenance (#45027)
Lock file maintenance, patch port #44993.

PR Close #45027
2022-02-09 10:18:09 -08:00
Renovate Bot a01ae487d7 build: update dependency google-closure-compiler to v20220202 (#45013)
PR Close #45013
2022-02-08 11:16:08 -08:00
Renovate Bot 3769de2caa build: update scorecard action dependencies to 230611d (#45012)
PR Close #45012
2022-02-08 11:15:36 -08:00
Amer Yousuf 835b326759 docs(forms): improve email validator directive docs (#45014)
PR Close #45014
2022-02-08 09:57:58 -08:00
Andrew Kushnir 92cf9fbebe fix(core): ViewContainerRef.createComponent should consult module injector when custom one is provided (#44966)
Before Ivy, it was only possible to call the `ViewContainerRef.createComponent` function with the ComponentFactory as the first argument. An instance of a `ComponentFactory` resolved via `ComponentFactoryResolver` contained a reference to an `NgModule` where the component is declared. As a result, the component maintained a DI connection with the module injector tree (by retrieving an instance of `NgModuleRef` internally), even when the custom injector was provided (we try to find a token in a custom injector first and consult module injector after that).

With Ivy, we expanded the `ViewContainerRef.createComponent` function API to support direct references to the Component classes without going through the factory resolution step. As a result, there was no connection to the NgModule that declares the component. Thus, if you provide a custom injector, this is the only injector that is taken into account.

This commit updates the logic for the factory-less case to try retrieving an instance of an `NgModuleRef` using the DI tree which `ViewContainerRef` belongs to. The `NgModuleRef` instance is then used to get a hold of a module injector tree. This brings the factory-less and factory-based logic to more consistent state.

Closes #44897.

PR Close #44966
2022-02-08 09:57:21 -08:00
Kristiyan Kostadinov 09f0254bdd perf(compiler): chain element start/end instructions (#44994)
In templates with several levels of nested nodes, it's common for several `elementStart`/`elementEnd` instructions to show up in a row which can be optimized away.

These changes add chaining support for `elementStart`, `elementEnd`, `elementContainerStart` and `elementContainerEnd` to shave off some bytes when possible.

PR Close #44994
2022-02-08 09:56:51 -08:00
Kristiyan Kostadinov 7b9490ad64 refactor(compiler): rework instruction generation logic for improved flexibility (#44994)
Previously the logic for generating chained instructions was somewhat rigid, because we had to collect all of the calls ahead of time and then call one of the chained instruction helpers. This doesn't work for something like `elementStart`, because we have to descend into other elements that could add to the chain.

These changes refactor the code so that we collect the list of instructions in a flat array and we do the chaining only once at the end when we have the entire instruction set for the code block.

The new approach has the advantage of being (almost) entirely configuration-based via the `CHAINABLE_INSTRUCTIONS` array and being more flexible in allowing us to chain instructions that span across elements.

PR Close #44994
2022-02-08 09:56:50 -08:00
Esteban Gehring f0e82c8af4 docs(common): mark lifecycle methods as nodoc (#45017)
PR Close #45017
2022-02-08 09:56:29 -08:00
Dylan Hunn 7a47add255 release: cut the v13.2.2 release (#45018)
PR Close #45018
2022-02-08 09:39:47 -08:00
Alan Cohen 7bc4dbd7ff docs: fix command to clear cache on Windows (#44988)
PR Close #44988
2022-02-07 21:18:03 -08:00
Andrew Kushnir d40ac2056e refactor(core): drop all .ngfactory and .ngsummary imports (#44957)
This commit updates various places in the repo (mostly tests/examples) to drop all `.ngfactory` and `.ngsummary` imports as they are no longer needed in Ivy.

PR Close #44957
2022-02-07 15:31:49 -08:00
Shai Reznik 1368f58b49 docs: add Cost-Effective Angular Testing (#44969)
to resources
PR Close #44969
2022-02-07 13:17:35 -08:00
Kristiyan Kostadinov b75e90f809 fix(forms): incorrectly keeping track of ngModel with ngFor inside a form (#40459)
When an `NgModel` is created within a `form`, it receives an `NgControl` based on its `name`, but
the control doesn't get swapped out if the name changes. This can lead to problems if the `NgModel`
is part of an `ngFor`, because the name can change based on its position in the list and a new
control can be defined with the same name, leading us to having multiple directives pointing to
the same control. For example, if we start off with a list like :

```
[0, 1, 2]; -> [NgModel(0), NgModel(1), NgModel(2)]
```

Then we remove the second item:

```
[0, 2]; -> [NgModel(0), NgModel(2)]
```

And finally, if we decide to add an item to the end of the list, we'll already have a control for
index 2, causing the list to look like:

```
[0, 2, 3]; -> [NgModel(0), NgModel(2), NgModel(2)]
```

These changes fix the issue by removing the old control when the `name` of the directive changes.

Fixes #38465.
Fixes #37920.

PR Close #40459
2022-02-07 13:16:10 -08:00
iRealNirmal 3919ee37cf refactor(forms): update PatternValidator to inherit AbstractValidatorDirective (#44887)
This commit updates the `PatternValidator` class to inherit `AbstractValidatorDirective` to make it conistent with other validators.

Closes angular#42267

PR Close #44887
2022-02-07 12:07:35 -08:00
JoostK 37af6abb49 fix(compiler): allow banana-in-a-box bindings to end with non-null assertion (#37809)
For two-way-bindings that use the banana-in-a-box syntax, the compiler
synthesizes an event assignment expression from the primary expression.
It is valid for the primary expression to be terminated by the non-null
operator, however naive string substitution is used for the synthesized
expression, such that the `!` would immediately precede the `=` token,
resulting in the valid `!=` operator token. The expression would still
parse correctly but it doesn't implement the proper semantics, resulting
in incorrect runtime behavior.

Changing the expression substitution to force a space between the
primary expression and the assignment avoids this mistake, but it
uncovers a new issue. The grammar does not allow for the LHS of an
assignment to be the non-null operator, so the synthesized expression
would fail to parse. To alleviate this, the synthesized expression is
parsed with a special parser flag to allow for this syntax.

Fixes #36551

PR Close #37809
2022-02-07 10:46:53 -08:00
Alan Agius 604a67f0a1 ci: group all scorecard action dependencies (#44998)
With this change we group all the scorecard action dependencies so that Renovate opens a single PR.

PR Close #44998
2022-02-07 09:46:29 -08:00
dario-piotrowicz baf0c7a11a docs(docs-infra): fix cosidered typo (#44987)
fix the "cosidered" typo (which should be "considered")

PR Close #44987
2022-02-07 09:45:22 -08:00
Renovate Bot cd97d8793f build: update all non-major dependencies (#44974)
Patch port of #44963

PR Close #44974
2022-02-04 11:55:23 -08:00
Ramzan 3fae6637e7 perf(http): remove IE special status handling (#44354)
revert the condition as dev only

PR Close #44354
2022-02-04 11:45:16 -08:00
Andrew Kushnir 30d1c34384 refactor(core): cleanup DebugNode and DebugElement implementations (#44270)
This commit updates `DebugNode` and `DebugElement` implementaitons to cleanup ViewEngine removal artifacts. There is no need for a separate interface and implementation class, so we can combine them now. This comment also gets rid of `R3` suffixes (denoting Ivy) in helper methods.

PR Close #44270
2022-02-04 10:43:43 -08:00
Jayson Acosta 1384013a00 docs: correct typo (#44793)
Service worker card contains typo 'us' when it should be 'use.'
PR Close #44793
2022-02-04 10:42:26 -08:00
zuckjet 9327e97500 refactor(dev-infra): convert nullish coalescing operator to plain javascript (#44968)
low version nodejs doesn't support nullish coalescing operator very well

PR Close #44968
2022-02-04 10:40:44 -08:00
Joey Perrott 59a6ec4396 build: exclude devtools scope from generated changelogs (#44964)
The devtools scoped commits are not included in the repository's CHANGELOG.md
file as these commits are not references areas which are included in the
primary released artifacts.

PR Close #44964
2022-02-03 15:19:26 -08:00
Olivier Capuozzo 1b216297f4 docs: update input-output-diagram.svg (#39900)
"deleteRequest" is the *event* (not target) and "crossOffItem" is the *handler* of the event (not "source").

PR Close #39900
2022-02-03 14:51:00 -08:00
Joey Perrott a89805c3ae build: setup OpenSSF Scorecard (#44960)
Set up OpenSSF Scorecard to begin tracking security metrics within the repo.

PR Close #44960
2022-02-03 14:50:23 -08:00
jhonyeduardo f092badb9c docs: add po-ui to UI Components resources (#43689)
PR Close #43689
2022-02-03 12:45:40 -08:00
dario-piotrowicz d27015a43c refactor(docs-infra): add types to all the aio examples buttons (#44557)
add types to all the buttons in the angular.io examples to encourage
the best practice of always including a type per button (regardless
to whether it is in a form or now)

PR Close #44557
2022-02-03 12:44:48 -08:00
dario-piotrowicz b9aee9070c refactor(docs-infra): remove outdated comments regarding CustomEvent (#44557)
remove the comments present in aio examples saying that for older
browsers such as IE CustomEvent could be necessary (as the the Event
constructor could be not available)

such comments are no longer necessary/relevant since the Event constructor
is available for all the supported browsers

PR Close #44557
2022-02-03 12:44:48 -08:00
Dario Piotrowicz 5fdd8ae3ba refactor(docs-infra): fix template eslint issues in aio examples (#44557)
the aio examples have various eslint issues regarding template rules, those
are currently turned off and TODO comments have been added to them in the
examples eslintrc, fix such issues and remove the respective TODO comments

this also includes examples refactoring to use buttons for better accessibility,
this change tries to make the smallest amound of changes to the examples' behaviors
and designs/UI

PR Close #44557
2022-02-03 12:44:48 -08:00
TANMAY SRIVASTAVA b2f474c4c9 docs: describe your change... (#42899)
in the last Lines ViewEncapsulationComponent should be EmulatedEncapsulationComponent as there is no such  ViewEncapsulationComponent  exists in this example where as 
ShadowDomEncapsulationComponent  contains NoEncapsulationComponent and EmulatedEncapsulationComponent
PR Close #42899
2022-02-03 12:41:36 -08:00
dario-piotrowicz 38b042b6d0 docs: improve punctuation in animation sequence summary (#44567)
slightly improve the punctuation in the animation sequence summary present
in the complex animation sequences guide

PR Close #44567
2022-02-03 12:40:53 -08:00
Dario Piotrowicz 48262bcb70 docs(animations): add section about animating reordering list items (#44567)
add a section regarding reordering list items in the complex animation
sequences guide to help developers rememeber to use a `TrackByFunction`
whenever they are animating `*ngFor` list items which change their
ordering

as suggested here: https://github.com/angular/angular/issues/42750#issuecomment-979127165

relates to issue #28040 and #42750

PR Close #44567
2022-02-03 12:40:53 -08:00
Andrew Scott fb3c0b2605 docs: remove item from changelog that does not work (#44961)
After trying this feature, it turns out the approach does not work and we
will be reverting the commits. Note that the feature _never_ worked so it's
not a breaking change.

PR Close #44961
2022-02-03 12:40:01 -08:00
Daniel Díaz fecd4f8eab docs: remove duplicate closing tags in View Encapsulation file (#44958)
PR Close #44958
2022-02-03 08:54:00 -08:00
Doug Parker 9cce12cbf5 refactor(compiler): add @suppress {msgDescriptions} if no description is present on an i18n message (#44787)
Refs http://b/214103351.

This happens if a user writes `<span i18n>Message</span>`. This is accepted as an internationalized message, but without a description. JSCompiler will throw an error in this situation because descriptions are generally required. Now, the Angular compiler will generate a suppression annotation so JSCompiler allows the syntax. This will ease an internal migration to JSCompiler-based i18n.

PR Close #44787
2022-02-02 15:33:45 -08:00
Andrew Scott b9aab0c87b fix(upgrade): Do not trigger duplicate navigation events from Angular Router (#43441)
This code mimics behavior that Google Analytics has been using to
prevent duplicate navigations. They set up their own `HybridRoutingService`
location sync to avoid duplicate navigations that came from the Angular
router. This would happen because the Angular router would trigger a
navigation, which would then get picked up by the `$locationShim`, which
would trigger a `$locationChangeStart`, which would then be picked up by
the `setUpLocationSync` watcher here, which would again trigger a
navigation in the Angular Router.

All of this can be prevented by checking if the `navigationId` exists on
the history state object. This property is added by the Angular router
during navigations.

fixes #21610

PR Close #43441
2022-02-02 19:51:20 +00:00
Andrew Scott 123f42c744 test(upgrade): update router upgrade tests to use fewer mocks (#43441)
This updates the router upgrade tests to use less mocked behavior. The
test upgrade location module is copied from the one that's used in the
common package. This update to the tests verifies more real behavior of
the upgrade module.

PR Close #43441
2022-02-02 19:51:20 +00:00
mgechev 64adfc9150 docs: remove banner after survey expiration (#44949)
The survey is now over. We can remove the banner.

PR Close #44949
2022-02-02 19:50:20 +00:00
Jessica Janiuk 7924a2e497 release: cut the v13.2.1 release (#44948) 2022-02-02 10:42:38 -08:00
George Kalpakas 98a1da9382 build(docs-infra): upgrade cli command docs sources to 0f51d5c70 (#44943)
Updating [angular#13.2.x](https://github.com/angular/angular/tree/13.2.x) from
[cli-builds#13.2.x](https://github.com/angular/cli-builds/tree/13.2.x).

##
Relevant changes in
[commit range](https://github.com/angular/cli-builds/compare/9ac3df5d1...0f51d5c70):

**Modified**
- help/test.json

PR Close #44943
2022-02-02 17:07:59 +00:00
mgechev 165aa4f164 docs: update the survey expiration date (#44938)
Extend with a few more days since the survey is still open.

PR Close #44938
2022-02-02 01:56:40 +00:00
JoostK 4a5ad1793f fix(compiler-cli): ensure casing of logical paths is preserved (#44798)
The logical filesystem would store a cached result based on the canonical path,
where the cached value contains the physical path that was originally provided.
This meant that other physical paths with an identical canonical path would use
a cached result derived from another physical path.

This inconsistency is not known to result in actual issues but is primarily
being made as a performance improvement, as using the provided physical paths
as cache key avoids the need to canonicalize the path if its result is already
cached.

PR Close #44798
2022-02-02 00:04:38 +00:00
JoostK d65a42b183 refactor(compiler-cli): use relative imports into dts files as fallback in type-check files (#44798)
The generated imports should normally use module specifiers that are valid for
use in production code, where arbitrary relative imports into e.g. node_modules
are not allowed. For template type-checking code it is however acceptable to
use relative imports, as such files are never emitted to JS code. It is
desirable to allow a filesystem relative import as fallback if an import would
otherwise fail to be generated, as doing so allows fewer situations from
needing an inline type constructor.

PR Close #44798
2022-02-02 00:04:37 +00:00
JoostK dee108b67c refactor(compiler): remove ViewEngine identifiers (#44676)
This commit removes the leftover `Identifiers` class that was used in the
ViewEngine compiler. The remaining usages of the `inlineInterpolate` and
`interpolate` instructions were refactored to make use of an
`InterpolationExpression` output expression to capture the argument list of an
interpolation expression. An attempt was made to refactor this further by
converting to the desired interpolation instruction immediately, but some
downstream consumers are designed in a way where the argument list itself is
needed, e.g. as other arguments need to be prepended/appended.

PR Close #44676
2022-02-02 00:04:14 +00:00
Andrew Scott 5a75721835 build: fix test for useUnknownInCatch (#44935)
CI ran before the change to the tsconfig file

PR Close #44935
2022-02-01 23:40:17 +00:00
markostanimirovic ec49796807 docs(router): provide better typing for resolver example (#44932)
PR Close #44932
2022-02-01 22:06:29 +00:00
JoostK b4e4617807 fix(common): include query parameters for open HTTP requests in verify (#44917)
When `HttpTestingController.verify` is used to verify that there are not open,
unexpected requests it would throw an error with the method and URL of all pending
requests, excluding the query parameters. This is confusing, as e.g. `expectOne`
matches a URL including its query parameters and `expectOne` does include the
query parameters when it reports when no request could be matched.

This commit changes the error that is reported by `verify` to include the query
parameters.

Closes #19974

PR Close #44917
2022-02-01 21:41:43 +00:00
Renovate Bot 812c1ba971 build: update all non-major dependencies (#44930)
PR Close #44930
2022-02-01 21:30:10 +00:00
David Shevitz 1cc1588c29 docs: fix incorrect title and tooltip in navigation (#44710)
Fixes #44589

In the navigation pane, the title and tooltip for the page,
Preparing component for translation, are incorrect. This PR
fixes this issue.

PR Close #44710
2022-02-01 19:17:40 +00:00
Alan b6d2212ce5 docs: correct the demo code of NgZone.run (#44733)
`NgZone.run` needs to be within the async closure, not around its registration, refer to: https://github.com/angular/angular/issues/44714
PR Close #44733
2022-02-01 19:16:16 +00:00
Andrew Scott a432ad65c7 build: Update 13.2.x for useUnknownInCatch (#44929)
36b16e667a enabled `useUnknownInCatchVariables`
but broke the build becaue the migration does not exist on the main
branch.

PR Close #44929
2022-02-01 19:15:06 +00:00
Arjen 96b3b774c3 docs: explain how ngsw.json is generated (#44823)
Update aio/content/guide/service-worker-devops.md

ngsw.json is the manifest file which is generated at build time ( based on ngsw-config.json ). This explains this a bit clearer.
At first, I thought that it was a wrongly named filename. Not is it explicitly described.

Co-Authored-By: George Kalpakas <kalpakas.g@gmail.com>

PR Close #44823
2022-02-01 18:26:42 +00:00
Doug Parker 365962948a refactor(compiler-cli): remove leftover _extendedTemplateDiagnostics flag (#44920)
This flag is currently a no-op because extended diagnostics are enabled in production.

PR Close #44920
2022-02-01 18:24:10 +00:00
Daniel Díaz 577d97f757 docs: add colon before introducing the list of items (#44751)
PR Close #44751
2022-02-01 18:20:47 +00:00
Andrew Scott 36b16e667a build: enable useUnknownInCatchVariables (#44679)
This unblocks the internal migration to turn the option on in g3.

PR Close #44679
2022-02-01 18:17:29 +00:00
Andrew Kushnir 2916ac9e1a refactor(core): the RuntimeError class should support more compact syntax (#44783)
This commit refactors the `RuntimeError` class to support a short version of providing error messages:
```
throw new RuntimeError(
  RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
  ngDevMode && 'Injector has already been destroyed.');
```
In prod mode, the second argument becomes `false` andn this commit extends the typings to support that.

This commit also contains a couple places were the `RuntimeError` class is used to demostrate the compact form.

PR Close #44783
2022-02-01 00:15:56 +00:00
Andrew Kushnir 4644886aaf perf(animations): remove no longer needed CssKeyframes classes (#44903) (#44919)
This commit removes CSS keyframes-based code that was used to support animations in old browsers. With IE11 deprecation, all supported browsers have native WebAnimations support, so the old code can be removed. This results in ~7KB decrease of the animations package bundle size, since most of the code was non-tree-shakable.

Closes #44520.

PR Close #44919
2022-01-31 22:46:00 +00:00
JoostK f5ce6cfa1e refactor(compiler-cli): remove unused canonical-path dependency (#44918)
This package is no longer used within `compiler-cli` so is being removed as a dependency.

PR Close #44918
2022-01-31 21:39:54 +00:00
Andrew Scott 7ec482d9c2 fix(core): Add back support for namespace URIs in createElement of dom renderer (#44914)
Support for namespace URIs rather than short namespace names was added in
https://github.com/angular/angular/commit/2b9cc8503d48173492c29f5a271b61126104fbdb to
support how Ivy passed around the namespace URI rather than short name at the time.
As a side-effect, this meant that namespace URIs were supported by the
default dom renderer as part of the public API (likely unintentionally).

It did not, however extend the support to other parts of the system (setAttribute, setAttribute,
and the ServerRenderer). In the future we should decide what exactly the
semantics for dealing with namespaces should be and make it consistent.

fixes #44028

PR Close #44914
2022-01-31 21:39:29 +00:00
Andrew Kushnir 98ba48eedf refactor(core): strict templates type-checking compatibility for perf tests (#44905)
This commit updates a type used in the transplanted views perf tests, to make the test compatible with strict template type-checking.

Currently, compiling the perf test results in the following TS error:
```
error TS2322: Type 'TemplateRef<{}>' is not assignable to type 'TemplateRef<NgForOfContext<any, any[]>>'.

17     <ng-container *ngFor="let n of views; template: template; trackBy: trackByIndex"></ng-container>
                                             ~~~~~~~~
```

PR Close #44905
2022-01-31 21:39:04 +00:00
arturovt 1aebbf8714 fix(forms): ensure OnPush ancestors are marked dirty when the promise resolves (#44886)
Currently, `ngModel` calls` setValue` after the `resolvedPromise` is resolved.
The promise is resolved _after_ the child template executes. The change detection
is run but `OnPush` views are not updated because they are not marked as dirty.

PR Close #44886
2022-01-31 21:38:39 +00:00
Andrew Kushnir 250dc40a46 fix(core): flush delayed scoping queue while setting up TestBed (#44814)
Previously, some NgModules that were added to the delayed scoping queue, never got removed from the queue before unit test execution. That resulted in some components (declared in those NgModules) missing their scope (which components/directives/pipes were matched).

This commit adds the logic to invoke delayed scoping queue flushing before starting a test to avoid missing/incomplete scopes for Components used in a test.

PR Close #44814
2022-01-31 21:37:53 +00:00
Lee Robinson 8fb2e3b71f docs: Update deployment docs for Vercel (#44904)
PR Close #44904
2022-01-31 21:32:42 +00:00
Doug Parker 626980f3eb build: fix update_all_goldens.js to use ESM. (#44916)
Attempting to run as is fails because we have `"type": "module"`. `shelljs` is a CommonJS module however, so we need to do a default import and destructure.

```
$ node packages/compiler-cli/test/compliance/update_all_goldens.js
const {exec} = require('shelljs');
               ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/douglasparker/Source/ng/packages/compiler-cli/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/douglasparker/Source/ng/packages/compiler-cli/test/compliance/update_all_goldens.js:11:16
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
    at async handleMainPromise (node:internal/modules/run_main:63:12)
```

PR Close #44916
2022-01-31 21:31:11 +00:00
Paul Gschwendtner 5400a3d88a build: fix formatting in zone.js BUILD file (#44911)
Fixes formatting in one of the Zone BUILD files.
The lint check on the renovate branch did not check
formatting as it seems. Needs more investigation as
the PR was green.

PR Close #44911
2022-01-31 21:28:25 +00:00
Paul Gschwendtner e07014f3d9 build: update legacy saucelabs bundle generation to account for esbuild update (#44911)
Previously with ESBuild 0.14.11, when a file had dynamic requires to
builtin NodeJS modules like `url`, the resolution completed successfully
regardless of `--platform browser`. This seems to be fixed in ESBuild now.

This unveiled some resolution errors with our Saucelabs bundle generation
because the framework code sometimes switches dynamically to `require('url')`
if `window.URL` is not defined. Previously this just didn't matter, but now
the `require('url')` is checked and a module resolution error is reported given
`url` not being available in the browser as a builtin module.

We fix this by marking the module as external. We will not hit this code path
anyway in the browser saucelabs code. Similarly we exclude all platform-server
files from the bundle. This is not strictly needed after the `url` module being
marked as external, but the issue showed that lots of unnecessary code for the
server platform is included. This can be omitted (unfortunately not from the TS
compilation without over-complicating things significantly more; experimented with
that).

PR Close #44911
2022-01-31 21:28:25 +00:00
Paul Gschwendtner 85b889e6fb build: update postinstall patch to account for benchmark macro changes (#44911)
Updates the postinstall patch for the benchmark macro rule from dev-infra.
We moved the ZoneJS setup to the bundler. This was necessary in order to
switch away from the Go-based (windows-incompatible, m1-incompatible)
concatjs devserver to a rather basic HTTP server (also provided by dev-infra now).

PR Close #44911
2022-01-31 21:28:25 +00:00
Renovate Bot 881d4696a2 build: update angular (#44911)
Updates to the latest version of Angular.

PR Close #44911
2022-01-31 21:28:25 +00:00
JoostK 07185f4ed1 fix(compiler-cli): enable nullish coalescing check only with strictNullChecks (#44862)
TypeScript configures `strictNullChecks` to be disabled by default, so the nullish
coalescing check should follow the same default. The rule actively depends on
`strictNullChecks`, as TypeScript doesn't include `null`/`undefined` in its types
otherwise so the check wouldn't have a way to differentiate between them.

This commit also takes the `strict` flag into account when `strictNullChecks` itself
is not configured.

PR Close #44862
2022-01-31 20:31:58 +00:00
JoostK 0778e6f7d7 fix(compiler-cli): accept nullish coalescing operator for any and unknown types (#44862)
We should not make assumptions about the any and unknown types; using a nullish
coalescing operator is acceptable for those.

PR Close #44862
2022-01-31 20:31:58 +00:00
Esteban Gehring 25f8305195 docs(core): showcase host listener support for specific keys in events (#44833)
PR Close #44833
2022-01-31 20:30:45 +00:00
Juri Strumpflohner b51d111d72 docs: update Nx headline (#44910)
PR Close #44910
2022-01-31 19:46:36 +00:00
Aristeidis Bampakos 72cdd1403b docs: add code format in content projection guide (#44907)
PR Close #44907
2022-01-31 19:45:47 +00:00
George Kalpakas c1fc425cd1 fix(docs-infra): make it possible to see whole notification text on smaller screens (#44900)
Previously, when the notification text did not fit on the viewport
width, it got truncated and it was not possible to see the whole text.

This commit fixes this by making the notification scrollable when the
text overflows.

PR Close #44900
2022-01-31 19:44:52 +00:00
George Kalpakas e62c98f2aa fix(docs-infra): make it easier to interact with notification on smaller screens (#44900)
On smaller screens, the action button in `NotificationComponent` is
hidden (due to limited horizontal screen "real estate"). Thus, the only
way to perform the action is to click on the notification message, which
is typically a link.

Previously, the link inside the notification did not take up the whole
height of the notification bar. As a result, clicking outside the link
would dismiss the notification without following the link.

This commit makes it easier to interact with the notification (esp. on
smaller screens) by ensuring the link covers the whole notification bar
(width and height).

PR Close #44900
2022-01-31 19:44:52 +00:00
Andrew Scott 47c02caa29 refactor(compiler-cli): Update where and how the indexed errors are exposed (#44884)
The initial commit e9124b42d5 stored the errors rather than
throwing but did not store them in a place that was accessible to consumers. Instead,
the errors should be added to the IndexedComponent so they can be surfaced where the
index results are consumed

PR Close #44884
2022-01-31 18:36:55 +00:00
George Kalpakas 94c9e47dbe Revert "fix(docs-infra): content overflow in mobile (#44851)" (#44899)
This reverts commit c2e09e0911, because it
messes up the table layouts on some resolutions/pages. See #44891 for
details.

Fixes #44891

PR Close #44899
2022-01-31 17:10:50 +00:00
Dylan Hunn 6b7fffcbeb fix(forms): Update the typed forms migration schematic to find all files. (#44881)
We were breaking out of the loop that walks the source tree due to an incorrect return.

PR Close #44881
2022-01-28 21:59:35 +00:00
fru2 641f27a9c9 fix(docs-infra): content overflow in mobile (#44851)
When reading the docs page on mobile, some page tend to scroll in horizontal direction quite a lot which is unpleasant

Fixes #44850

PR Close #44851
2022-01-28 18:01:47 +00:00
Paul Gschwendtner ab63ed3448 test(docs-infra): fix type checking errors with new jasmine types (#44876)
The jasmine types for `spyObj.calls().all()` seem to be more specific,
relying on `ThisType<Fn>` to determine the context/receiver for an invoked
spy. This type does not work as expected with class members as it seems.

This commit fixes three of these type checking failures by explicitly casting
the spy context to the actual class owning the method member.

PR Close #44876
2022-01-28 17:50:15 +00:00
Renovate Bot b89ee0819b build: update angular (#44876)
Updates to the latest versions of Angular organization NPM packages.

PR Close #44876
2022-01-28 17:50:15 +00:00
Renovate Bot 553c8d1366 build: lock file maintenance (#44876)
Cleans up the lock file by maximizing the versions as allowed per our
version ranges.

PR Close #44876
2022-01-28 17:50:15 +00:00
Maarten Tibau f398717502 docs: fix typo in update guide (#44853)
PR Close #44853
2022-01-28 17:37:25 +00:00
Aristeidis Bampakos c9abf34d88 docs: fix GitHub broken link in update guide (#44875)
PR Close #44875
2022-01-28 16:08:28 +00:00
George Kalpakas 96d2c58647 fix(docs-infra): fix links to CLI commands source code (#44835)
Recently, the [CLI repository][1] switched to not prefixing tag names
with a `v`. Update the `versionInfo` generated for CLI commands docs, so
that the links to the source code (which include the tag name) are
correct.

Fixes #44822

[1]: https://github.com/angular/angular-cli

PR Close #44835
2022-01-28 16:07:47 +00:00
Theodore Brown 49ca5bb1d8 refactor(forms): remove dead code (#37614)
This functionally dead code was originally introduced via pull request
were added to verify the fix, and the many comments on that issue after
it was closed indicate that it wasn't actually resolved.

In fact, setting `selectedIndex` does absolutely nothing here, since
the selected index is immediately overridden by setting the `value`
property. A working fix (with tests) for the IE/Safari bug is in pull
request #23784. Originally this dead code was removed as part of that PR,
but @AndrewKushnir recommended creating a separate PR for the cleanup.

PR Close #37614
2022-01-28 16:07:11 +00:00
dario-piotrowicz f6c2934f5b docs(core): edit and add docs for ng-container (#44762)
PR Close #44762
2022-01-28 15:55:33 +00:00
Andrew Kushnir 1169fae366 docs: update survey id (#44865)
The survey id is used as a key in the local storage to keep the state (don't show the message again). Reusing this survey id will make the message invisible to some users who already have that key in local storage.

PR Close #44865
2022-01-27 21:52:35 +00:00
mgechev 522b845bec docs: enable the survey banner (#44861)
PR Close #44861
2022-01-27 11:43:54 -08:00
Paul Gschwendtner 2fa2f7d34a ci: only build test targets for components repo unit test job (#44832)
To speed up the components CI job (avoiding it being a bottleneck in FW),
we will stop building everything in `src/...`, but rather only build targets
which are needed to run all tests within `src/...`.

This notably should avoid unnecessary NPM package building. Arguably that
part would also be valuable to have, but we already test the `ng_package`
rule in FW itself, plus we run snapshot tests in the components repo as well.

PR Close #44832
2022-01-27 09:22:24 -08:00
Paul Gschwendtner af19c440e2 ci: re-enable components repo unit tests job (#44832)
Re-enables the components-repo unit tests job that we previously
disabled due to the devmode target change that caused conflicts
with `angular/components` patching `ng_module.bzl` of `@angular/bazel`.

PR Close #44832
2022-01-27 09:22:24 -08:00
Andrew Scott 9f7157e560 refactor(compiler-cli): Tolerate source span errors in indexer (#44825)
When the indexer encounters a location where the source span doesn't
match up with the expected identifier, the current visitor code throws
an error. Instead, this change creates an error and moves on to the next
template item. This allows the indexer to continue analysis even when
there are errors in the source mapping. In addition, it still allows callers
to surface those errors in their own way while still providing as much indexed
information as possible about a node.

PR Close #44825
2022-01-27 09:20:09 -08:00
Renovate Bot 30ddeabca6 build: update dependency globby to v13 (#44801)
PR Close #44801
2022-01-27 09:18:58 -08:00
Renovate Bot 4a91d9b0a0 build: update dependency rules_pkg to v0.6.0 (#44818)
PR Close #44818
2022-01-26 17:37:42 -08:00
Jessica Janiuk fcc6528159 test(animations): Add bundling size regression test for animations package (#44826)
This adds a size regression test for the animations package to the test suite.

PR Close #44826
2022-01-26 12:54:36 -08:00
Andrew Kushnir dc0cac235f docs: cleanup CHANGELOG.md file (#44842)
PR Close #44842
2022-01-26 12:37:05 -08:00
Andrew Kushnir de1e35b944 release: cut the v13.2.0 release (#44838) 2022-01-26 11:44:41 -08:00
Dylan Hunn a38ae0aefa refactor(forms): Temporarily disable the typed forms migration. (#44828)
It's best to disable this optional migration in the minor release, although it shouldn't run anyway -- we don't want people accidentally running it.

This PR will be rolled back after the minor is out.

PR Close #44828
2022-01-25 17:03:48 -08:00
Andrew Scott fe3e4d6865 fix(compiler-cli): Handle ng-template with structural directive in indexer (#44788)
An `ng-template` with an inline template (i.e. has a structural
directive) would previously not get an `undefined` `tagName` because the
logic assumed the element would be `t.Element` or `t.Content` and read
the tag name from the `name` property. For a `t.Template`, this exists
instead on the `t.tagName`. The final result would be an `tagName` of `undefined`
for the parent `t.Template`, causing failures in the indexer downstream.

This `undefined` value is actually expected in the renderer code, even
though the type does not specify this possibility. This change updates
the type of `tagName` to be `string|null` and explicitly handles the
case where there is a structural directive on an `ng-template`. You can
see how the two are differentiated in the compliance code that was
modified in this commit.

PR Close #44788
2022-01-25 14:15:45 -08:00
George Kalpakas 6cb7c3ebe3 build(docs-infra): update dgeni-packages to v0.29.3 (#44810)
This version includes angular/dgeni-packages#318 and thus fixes the
rendering of overridden methods in API docs.

Fixes #44468

PR Close #44810
2022-01-25 09:24:41 -08:00
Renovate Bot 966343bb92 build: update angular (#44771)
PR Close #44771
2022-01-25 09:24:00 -08:00
Tim Bowersox 7e93513425 docs: add link to AbstractControlOptions reference (#44764)
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 7c7a1a1724 docs: exclude setValue from async-validator-usage docregion (#44764)
Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 62217efb7e docs: add missing return statement to validate() (#44764)
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 1fa14e0c84 docs: remove trailing space in code example (#44764)
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox a71eb4c18e docs: fix UniqueAlterEgoValidatorDirective (#44764)
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox ffd62b9f11 docs: expand async validators in reactive forms (#44764)
* Hone docregions for code examples
* Add more detailed description

PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox e545dd8130 docs: revise text for adding async validators to template-driven forms (#44764)
Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 4883b7d9c7 docs: restore UniqueAlterEgoValidator (#44764)
Update the docregion for the directive class to differentiate them

PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 8eb1f76341 docs: fix UniqueAlterEgoValidatorDirective (#44764)
* Use correct class name in providers
* Update parameter & return signature for validate()
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 37bbd97d6e docs: update async validators section (#44764)
* Update the UniqueAlterEgoValidator code example
* Add async-validator docregion to hero-form-reactive.component.2.ts
* Fix typo under Implementing a custom async validator
* Add h3 sections for adding async validators to reactive & template-driven forms
PR Close #44764
2022-01-24 14:53:17 -08:00
Tim Bowersox 9e9e82d7c7 docs: add note about using NG_ASYNC_VALIDATORS (#44764)
When setting up an async validator in a template-driven form, it's necessary to register the directive with NG_ASYNC_VALIDATORS instead of NG_VALIDATORS. This was not mentioned in the docs.
PR Close #44764
2022-01-24 14:53:17 -08:00
Jessica Janiuk e12dfa535b test(animations): Add bundling symbol test for animations package (#44809)
This adds a full bundling animation symbols test to the test suite.

PR Close #44809
2022-01-24 14:52:31 -08:00
iRealNirmal fa7c7afbe9 refactor(forms): update required validator and checkbox validator to inherit abstractValidator (#44162)
Modified required validator and checkbox validator to inherit abstractValidator.

For every validato type different PR will be raised as discussed in #42378.

Closes #42267

PR Close #44162
2022-01-24 14:50:58 -08:00
Kristiyan Kostadinov a4aa9b3c28 Revert "feat(core): allow for injector to be specified when creating an embedded view (#44666)" (#44807)
This reverts commit b49ffcd50e.

PR Close #44807
2022-01-24 12:22:22 -08:00
Kristiyan Kostadinov 40f27a31d2 Revert "feat(common): add injector input to ngTemplateOutlet (#44761)" (#44807)
This reverts commit ed21f5c753.

PR Close #44807
2022-01-24 12:22:22 -08:00
Kristiyan Kostadinov 94bfcdd9de fix(core): error if NgZone.isInAngularZone is called with a noop zone (#44800)
When the user opts into the noop `NgZone`, they usually still interact with the static methods on the non-noop class. This change adds a check to handle the case where zone.js hasn't been loaded.

Fixes #44784.

PR Close #44800
2022-01-24 10:44:44 -08:00
Wiley Marques f0a8303abe docs(router): fixing pathMatch doc to style code correctly (#44796)
PR Close #44796
2022-01-24 10:42:52 -08:00
Andrew Scott abd1bc8039 fix(compiler): correct spans when parsing bindings with comments (#44785)
The previous fix for correcting spans with comments in
https://github.com/angular/angular/commit/59eef29a6c5d568ca80595cd7018e21ad406c85d
had the unfortunate side effect of _breaking_ the spans with comments
when there was leading whitespace. This happened because the previous
fix was testing one without a comment, identifying that the offset shouldn't
have anything added to it, and then removing that offset adjustment
(`offsets[i] + (expressionText.length - sourceToLex.length)`).

Upon further investigation, this offset adjustment _was actually
necessary_ for when the input had comments, but this was only because
the `stripComments` function used `trim` to remove whitespace for these
cases. This is the real problem -- not only does it create a ton of confusion
but also it means that the behavior of the lexer and resulting spans is
different between inputs with comments and inputs without comments.

After reviewing how the `inputLength` of `_ParseAST` was used, it
appears that the correct behavior would be to _not_ trim the input. The
`inputLength` is used to advance the current index beyond points which
have been processed. This _should_ include any whitespace. Additionally,
`inputLength` doesn't appear to be needed at all. When there was no
comment in the input, it was always equal to the `input.length` anyways.
When there _is_ a comment, it should include that comment anyways to
advance the index beyond the comment.

PR Close #44785
2022-01-24 10:41:54 -08:00
Andrew Scott 7316e72ec5 fix(compiler-cli): properly index <svg> elements when on a template (#44785)
The original fix for svg elements in
https://github.com/angular/angular/commit/92b23f48519a1adb460a431c356bcd9917fb059d
did not account for svg elements when they also had a structural
directive on them, making the node a template. This resulted in the
logic added in fix above not being applied.

PR Close #44785
2022-01-24 10:41:54 -08:00
Doug Parker ac2f262e9a docs: add extended diagnostics documentation (#44704)
This includes the initial documentation for extended diagnostics with a page for each of the two initial checks. They follow the same general formula, and hopefully in the future they can be properly generated from metadata rather than copy-pasted as they are currently.

PR Close #44704
2022-01-24 10:41:13 -08:00
George Kalpakas f2fa67eb0b fix(docs-infra): track error docs during serve-and-sync (#44704)
Refs #42966.

Look for changes in error docs (i.e. docs under `aio/content/error/`) in
`authors-package`, so that such docs are tracked when running the
`serve-and-sync` script.

PR Close #44704
2022-01-24 10:41:13 -08:00
George Kalpakas 9bee561956 fix(docs-infra): track error docs during serve-and-sync (#44704)
Refs #42966.

Look for changes in error docs (i.e. docs under `aio/content/error/`) in
`authors-package`, so that such docs are tracked when running the
`serve-and-sync` script.

PR Close #44704
2022-01-24 10:41:13 -08:00
Andrew Kushnir fce521e4d2 release: cut the v13.2.0-rc.1 release (#44804) 2022-01-24 09:41:52 -08:00
Oleg Postoev ade305757b refactor(common): unused return value from attemptFocus (#44457)
The function attemptFocus had a return value that nowhere is used. But it still saves in the bundle.

PR Close #44457
2022-01-21 13:11:32 -08:00
JoostK ed67a074ce fix(compiler): properly compile DI factories when coverage reporting is enabled (#44732)
When running tests with code coverage using Istanbul, the code is
instrumented with coverage reporting statements. These statements are
also inserted into synthesized constructors, preventing Angular from
properly recognizing them as synthesized constructor.

This commit changes the regex to detect synthesized constructors to allow
for statements within the constructor before the `super(...arguments);`
call. This is limited to code that does not contain a `}`, but this
is sufficient to support Istanbul's coverage instrumentation statements.

The tests have been extended with an input file that is being
instrumented using `babel-plugin-istanbul` for both ES2015 and ES5
targets, in order to verify that the approach works for real-world
usages.

Fixes #31337

PR Close #44732
2022-01-21 13:10:43 -08:00
Renovate Bot 43eb934e6b build: update all non-major dependencies (#44713)
PR Close #44713
2022-01-21 11:21:52 -08:00
Douglas Parker d2ae96f742 fix(compiler-cli): skip ExtendedTemplateCheckerImpl construction if there were configuration errors (#44778)
Previously, if a bad extended diagnostic category was given, it would fail with the expected error as well as an unexpected assertion error:

```
$ ng build -c development
✔ Browser application bundle generation complete.

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Unexpected call to 'assertNever()' with value:
test
    at /home/douglasparker/Source/ng-new/node_modules/@ngtools/webpack/src/ivy/loader.js:77:18
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Unexpected call to 'assertNever()' with value:
test
    at /home/douglasparker/Source/ng-new/node_modules/@ngtools/webpack/src/ivy/loader.js:77:18
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Error: error NG4004: Angular compiler option "extendedDiagnostics.checks['invalidBananaInBox']" has an unknown diagnostic category: "test".

Allowed diagnostic categories are:
warning
error
suppress
```

The assertion comes from `ExtendedTemplateCheckerImpl`, which expects a well-formed configuration, yet the compiler would construct it even when errors were found. This commit skips constructing and running extended diagnostics if the configuration had errors, which should avoid triggering these assertion errors.

I'm unfortunately not able to actually test this change. The test passes even before the fix because the `ngc` binary and end-to-end tests [don't request diagnostics unless the configuration is considered valid](https://github.com/angular/angular/blob/ed21f5c75378e1ce717ee3d76d28c8c994209de1/packages/compiler-cli/src/perform_compile.ts#L292-L293). See [Slack](https://angular-team.slack.com/archives/C4WHZQMRA/p1642641305003800) for more details.

PR Close #44778
2022-01-21 11:20:48 -08:00
Andrew Scott 5626b34264 fix(core): consistently use namespace short name rather than URI (#44766)
`Renderer2` APIs expect to be called with the namespace name rather than
the namespace URI. Rather than passing around the URI and having to
account for different calling contexts, this change consistently uses
the namespace short names.

Importantly, the URI was only used in `component_ref.ts` `create`
(because `getNamespace returned the URIs`) and `createElementNode` in
`node_manipulation.ts` (because `getNamespaceUri` also used the URIs).
In contrast, attributes would use the _short names instead of URIs_
(see `setUpAttributes` in `attrs_utils.ts`). These names are pulled
directly from the attribute, i.e. `xhtml:href` and not converted to URI.
This dichotomy is confusing and unnecessary. The change here aligns the two
approaches in order to provide consistently throughout the system.

This relates to #44766 because the `createElementNode` was calling the
`AnimationRenderer.createElement` which delegates to the
`ServerRenderer`, which in turn was only set up to expect short names.
As a result, the `NAMESPACE_URIS` lookup failed and `Domino` created
the `svg` as a regular `Element` which does not have a `styles`
property.

resolves #44766

PR Close #44766
2022-01-21 11:19:31 -08:00
Andrew Scott 1671212a55 test: Update test to not declare component in multiple modules (#44766)
When running locally, these integration tests appear to fail because the
component is declared in many test modules.

PR Close #44766
2022-01-21 11:19:31 -08:00
Doug Parker 100091ebf0 fix(compiler-cli): remove leftover _extendedTemplateDiagnostics requirements (#44777)
Refs #42966.

There were two remaining places where `_extendedTemplateDiagnostics` needed to be set which should have been removed in #44712 but got missed. This updates them to only require `strictTemplates` and not `_extendedTemplateDiagnostics` so the feature is properly enabled in production.

PR Close #44777
2022-01-20 14:03:46 -08:00
Martin Probst b7ff6f06de refactor(compiler): pass rootDir to tsickle (#44768)
tsickle's underlying API has changed to require passing a rootDir to getGeneratedExterns.
PR Close #44768
2022-01-20 11:16:36 -08:00
Stephanie Tuerk 6b75263303 docs: correct (possible) typo (#44759)
change 'reference' to 'referencing' -- I believe this is is a typo and that this is the proper correction.
PR Close #44759
2022-01-20 09:22:37 -08:00
Dylan Hunn caeb162513 release: cut the v13.2.0-rc.0 release (#44765) 2022-01-19 17:36:11 -08:00
1156 changed files with 63540 additions and 44924 deletions
+1 -1
View File
@@ -1 +1 @@
4.2.2
5.0.0
+63 -53
View File
@@ -31,12 +31,12 @@ var_3: &cache_key v6-angular-node-14-{{ checksum "month.txt" }}-{{ checksum ".ba
var_4: &cache_key_fallback v6-angular-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
# Windows needs its own cache key because binaries in node_modules are different.
var_3_win: &cache_key_win v6-angular-win-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "aio/yarn.lock" }}
var_4_win: &cache_key_win_fallback v6-angular-win-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
var_3_win: &cache_key_win v7-angular-win-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}
var_4_win: &cache_key_win_fallback v7-angular-win-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
# Cache key for the `components-repo-unit-tests` job. **Note** when updating the SHA in the
# cache keys also update the SHA for the "COMPONENTS_REPO_COMMIT" environment variable.
var_5: &components_repo_unit_tests_cache_key v1-angular-components-{{ checksum "month.txt" }}-a931de54a786597b34259e461c2cf3ab6edc590a
var_5: &components_repo_unit_tests_cache_key v1-angular-components-{{ checksum "month.txt" }}-e65f5f5bafcd00dbb64387878fb866283909a2dd
var_6: &components_repo_unit_tests_cache_key_fallback v1-angular-components-{{ checksum "month.txt" }}
# Workspace initially persisted by the `setup` job, and then enhanced by `build-npm-packages`.
@@ -58,21 +58,26 @@ var_9: &skip_on_pull_requests
ignore:
- /pull\/\d+/
# Filter to run a job on builds for the master branch only.
var_10: &only_on_master
# Filter to run a job on builds for the main branch only.
var_10: &only_on_main_branch
filters:
branches:
only:
- master
- main
# Filter to run a job on all releasable branches.
var_11: &only_release_branches
filters:
branches:
only:
- master
- main
- /\d+\.\d+\.x/
# CircleCI orbs
# https://circleci.com/developer/orbs.
orbs:
node: circleci/node@5.0.1
# Executor Definitions
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
# **NOTE 1**: Pin to exact images using an ID (SHA). See https://circleci.com/docs/2.0/circleci-images/#using-a-docker-image-id-to-pin-an-image-to-a-fixed-version.
@@ -103,20 +108,8 @@ executors:
windows-executor:
working_directory: ~/ng
resource_class: windows.2xlarge
# CircleCI windows VMs do have the GitBash shell available:
# https://github.com/CircleCI-Public/windows-preview-docs#shells
# But in this specific case we really should not use it because Bazel must not be ran from
# GitBash. These issues discuss why:
# https://github.com/bazelbuild/bazel/issues/5751
# https://github.com/bazelbuild/bazel/issues/5724#issuecomment-410194038
# https://github.com/bazelbuild/bazel/issues/6339#issuecomment-441600879
shell: powershell.exe -ExecutionPolicy Bypass
shell: bash
machine:
# Windows preview image that includes the following:
# - Visual Studio 2019 build tools
# - Node 14
# - yarn 1.17
# - Python 3 3.7.4
image: windows-server-2019-vs2019:201908-02
# Command Definitions
@@ -188,30 +181,18 @@ commands:
steps:
- run:
name: Save month to file
# Note: Make sure this file is excluded in the `.gitignore` as otherwise the
# snapshot stamping would have the `-with-local-changes` suffix.
command: date +%Y-%m > month.txt
# Normally this would be an individual job instead of a command.
# But startup and setup time for each individual windows job are high enough to discourage
# many small jobs, so instead we use a command for setup unless the gain becomes significant.
setup_win:
description: Setup windows node environment
yarn_install:
description: Install dependencies
steps:
- checkout
- save_month_to_file
# Install Bazel pre-requisites that aren't in the preconfigured CircleCI Windows VM.
- run: ./.circleci/windows-env.ps1
- run: node --version
- run: yarn --version
- restore_cache:
keys:
- *cache_key_win
- *cache_key_win_fallback
# Install @bazel/bazelisk globally and use that for the first run.
# Workaround for https://github.com/bazelbuild/rules_nodejs/issues/894
# NB: the issue was for @bazel/bazel but the same problem applies to @bazel/bazelisk
- run: yarn global add @bazel/bazelisk@$env:BAZELISK_VERSION
# On Windows `~/` is not resolved when using as a CLI value. `../` results in the same path.
- run: yarn install --frozen-lockfile --non-interactive --cache-folder ../.cache/yarn
- run:
name: Running Yarn install
command: yarn install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
# Yarn's requests sometimes take more than 10mins to complete (especially on Windows).
no_output_timeout: 45m
notify_webhook_on_fail:
description: Notify a webhook about failure
@@ -255,11 +236,7 @@ jobs:
keys:
- *cache_key
- *cache_key_fallback
- run:
name: Running Yarn install
command: yarn install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
# Yarn's requests sometimes take more than 10mins to complete.
no_output_timeout: 45m
- yarn_install
- run: yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
# Make the bazel directories and add a file to them if they don't exist already so that
# persist_to_workspace does not fail.
@@ -327,7 +304,7 @@ jobs:
path: dist/bin/packages/core/test/bundling/todo/bundle.min.js.br
destination: core/todo/bundle.br
# NOTE: This is currently limited to master builds only. See the `monitoring` configuration.
# NOTE: This is currently limited to main builds only. See the `monitoring` configuration.
saucelabs:
executor:
name: default-executor
@@ -675,6 +652,10 @@ jobs:
# variable. It needs to be hardcoded here, because env variables interpolation is
# not supported.
- '/tmp/angular-components-repo'
- run:
# Copy zone.js package to dist/packages-dist, so `angular/components` can also use the local zone.js build.
name: Setting up zone.js release packages.
command: cp -r dist/zone.js-dist/zone.js dist/packages-dist/
- run:
# Updates the `angular/components` `package.json` file to refer to the release output
# inside the `packages-dist` directory.
@@ -718,16 +699,45 @@ jobs:
test_win:
executor: windows-executor
steps:
- setup_win
- checkout
- save_month_to_file
- init_environment
# Setup the proper NodeJS version. The image comes pre-installed with `nvm-windows`.
- run:
name: Install NodeJS version from `.nvmrc`.
command: |
nvm install $(cat .nvmrc)
nvm use $(cat .nvmrc)
- restore_cache:
keys:
- *cache_key_win
- *cache_key_win_fallback
# Install project dependencies, and install Bazelisk globally. This is necessary as
# Windows might error when `bazel` is invoked from the project node modules. The Bazel
# invocation might modify the symlinked project `node_modules` again, causing failures.
- yarn_install
- run: yarn global add @bazel/bazelisk@${BAZELISK_VERSION}
- run:
name: Build all windows CI targets
command: bazel build //packages/compiler-cli/...
command: |
$(yarn global bin)/bazelisk build //packages/compiler-cli/...
no_output_timeout: 15m
- run:
name: Test all windows CI targets
command: bazel test --test_tag_filters="-browser:chromium-local" //packages/compiler-cli/...
command: |
$(yarn global bin)/bazelisk test --test_tag_filters="-browser:chromium-local" //packages/compiler-cli/...
no_output_timeout: 15m
- save_cache:
key: *cache_key_win
paths:
- node_modules
- ~/AppData/Local/bazelisk
workflows:
version: 2
default_workflow:
@@ -786,7 +796,7 @@ workflows:
# since the publishing script expects the legacy outputs layout.
- build-npm-packages
- legacy-unit-tests-saucelabs
# TODO(devversion): re-enable once the components repo has accounted for the `ng_module` devmode target changes.
# TODO(devversion): re-enable once `angular/components` is using `rules_nodejs` v5.
#- components-repo-unit-tests:
# requires:
# - build-npm-packages
@@ -812,7 +822,7 @@ workflows:
- saucelabs:
# Testing saucelabs via Bazel currently taking longer than the legacy saucelabs job as it
# each karma_web_test target is provisioning and tearing down browsers which is adding
# a lot of overhead. Running once daily on master only to avoid wasting resources and
# a lot of overhead. Running once daily in the main branch to avoid wasting resources and
# slowing down CI for PRs.
# TODO: Run this job on all branches (including PRs) once karma_web_test targets can
# share provisioned browsers and we can remove the legacy saucelabs job.
@@ -820,6 +830,6 @@ workflows:
- setup
triggers:
- schedule:
<<: *only_on_master
<<: *only_on_main_branch
# Runs monitoring jobs at 10:00AM every day.
cron: '0 10 * * *'
+4 -1
View File
@@ -31,7 +31,10 @@ function setSecretVar() {
local -r originalShellOptions=$(set +o);
set +x -eu -o pipefail;
echo "export $1=\"${2:-}\";" >> $BASH_ENV;
local assignmentStatement="export $1=\"${2:-}\";"
echo "${assignmentStatement}" >> $BASH_ENV;
eval "${assignmentStatement}"
# Restore original shell options.
eval "$originalShellOptions";
+11
View File
@@ -0,0 +1,11 @@
####################################################################################################
# Decrypt GCP Credentials and store them as the Google default credentials.
####################################################################################################
mkdir -p "$HOME/.config/gcloud";
openssl aes-256-cbc -d -in "${PROJECT_ROOT}/.circleci/gcp_token" \
-md md5 -k "$CIRCLE_PROJECT_REPONAME" -out "$HOME/.config/gcloud/application_default_credentials.json"
####################################################################################################
# Set bazel configuration for CircleCI runs.
####################################################################################################
cp "${PROJECT_ROOT}/.circleci/bazel.linux.rc" "$HOME/.bazelrc";
+13 -22
View File
@@ -3,7 +3,6 @@
# Variables
readonly projectDir=$(realpath "$(dirname ${BASH_SOURCE[0]})/..")
readonly envHelpersPath="$projectDir/.circleci/env-helpers.inc.sh";
readonly bashEnvCachePath="$projectDir/.circleci/bash_env_cache";
# Load helpers and make them available everywhere (through `$BASH_ENV`).
source $envHelpersPath;
@@ -52,7 +51,7 @@ setSecretVar CI_SECRET_PAYLOAD_FIREBASE_TOKEN "$ANGULAR_PAYLOAD_TOKEN";
# Define SauceLabs environment variables for CircleCI.
####################################################################################################
setPublicVar SAUCE_USERNAME "angular-framework";
setSecretVar SAUCE_ACCESS_KEY "0c731274ed5f-cbc9-16f4-021a-9835e39f";
setSecretVar SAUCE_ACCESS_KEY "f4bf7c639c5a-c6bb-d6a4-a4b5-800aa111";
# TODO(josephperrott): Remove environment variables once all saucelabs tests are via bazel method.
setPublicVar SAUCE_LOG_FILE /tmp/angular/sauce-connect.log
setPublicVar SAUCE_READY_FILE /tmp/angular/sauce-connect-ready-file.lock
@@ -72,21 +71,10 @@ setPublicVar SAUCE_READY_FILE_TIMEOUT 120
# the `save_cache` path configuration in `config.yml`
setPublicVar COMPONENTS_REPO_TMP_DIR "/tmp/angular-components-repo"
setPublicVar COMPONENTS_REPO_URL "https://github.com/angular/components.git"
setPublicVar COMPONENTS_REPO_BRANCH "master"
# TODO(BRANCH_RENAME_CLEANUP): fixup branch name to point to main branch
setPublicVar COMPONENTS_REPO_BRANCH "main-branch-rename-do-not-delete"
# **NOTE**: When updating the commit SHA, also update the cache key in the CircleCI `config.yml`.
setPublicVar COMPONENTS_REPO_COMMIT "a931de54a786597b34259e461c2cf3ab6edc590a"
####################################################################################################
# Decrypt GCP Credentials and store them as the Google default credentials.
####################################################################################################
mkdir -p "$HOME/.config/gcloud";
openssl aes-256-cbc -d -in "${projectDir}/.circleci/gcp_token" \
-md md5 -k "$CIRCLE_PROJECT_REPONAME" -out "$HOME/.config/gcloud/application_default_credentials.json"
####################################################################################################
# Set bazel configuration for CircleCI runs.
####################################################################################################
cp "${projectDir}/.circleci/bazel.linux.rc" "$HOME/.bazelrc";
setPublicVar COMPONENTS_REPO_COMMIT "e65f5f5bafcd00dbb64387878fb866283909a2dd"
####################################################################################################
# Create shell script in /tmp for Bazel actions to access CI envs without
@@ -98,16 +86,19 @@ echo "export PROJECT_ROOT=\"${PROJECT_ROOT}\";" >> $bazelVarEnv
echo "export CI_BRANCH=\"${CI_BRANCH}\";" >> $bazelVarEnv
echo "export CI_BUILD_URL=\"${CI_BUILD_URL}\";" >> $bazelVarEnv
echo "export CI_COMMIT=\"${CI_COMMIT}\";" >> $bazelVarEnv
echo "export CI_COMMIT_RANGE=\"${CI_COMMIT_RANGE}\";" >> $bazelVarEnv
echo "export CI_PULL_REQUEST=\"${CI_PULL_REQUEST}\";" >> $bazelVarEnv
echo "export CI_REPO_NAME=\"${CI_REPO_NAME}\";" >> $bazelVarEnv
echo "export CI_REPO_OWNER=\"${CI_REPO_OWNER}\";" >> $bazelVarEnv
echo "export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=\"${CI_SECRET_PAYLOAD_FIREBASE_TOKEN}\";" >> $bazelVarEnv
####################################################################################################
# Platform-specific environment setup (which can leverage the base variables from here)
####################################################################################################
## Source `$BASH_ENV` to make the variables available immediately. ##
## ***NOTE: This must remain the last action in this script*** ##
####################################################################################################
####################################################################################################
source $BASH_ENV;
# Conditionally, load additional environment settings based on the current VM
# operating system running. We detect Windows by checking for `%AppData%`.
if [[ -n "${APPDATA}" ]]; then
source ${projectDir}/.circleci/env.windows.sh
else
source ${projectDir}/.circleci/env.linux.sh
fi
+17
View File
@@ -0,0 +1,17 @@
####################################################################################################
# Decrypt GCP Credentials and store them as the Google default credentials.
####################################################################################################
mkdir -p "${APPDATA}/gcloud/";
openssl aes-256-cbc -d -in "${PROJECT_ROOT}/.circleci/gcp_token" \
-md md5 -k "$CIRCLE_PROJECT_REPONAME" -out "${APPDATA}/gcloud/application_default_credentials.json"
####################################################################################################
# Set bazel configuration for CircleCI runs.
####################################################################################################
cp "${PROJECT_ROOT}/.circleci/bazel.windows.rc" "${USERPROFILE}/.bazelrc";
# Expose the Bazelisk version. We need to run Bazelisk globally since Windows has problems launching
# Bazel from a node modules directoy that might be modified by the Bazel Yarn install then.
setPublicVar BAZELISK_VERSION \
"$(cd ${PROJECT_ROOT}; node -p 'require("./package.json").devDependencies["@bazel/bazelisk"]')"
+6 -5
View File
@@ -84,22 +84,23 @@ async function _main() {
/**
* Sort a list of fullpath refs into a list and then provide the first entry.
*
* The sort order will first find master ref, and then any semver ref, followed
* The sort order will first find the the main branch, and then any semver ref, followed
* by the rest of the refs in the order provided.
*
* Branches are sorted in this order as work is primarily done on master, and
* Branches are sorted in this order as work is primarily done on main branches, and
* otherwise on a semver branch. If neither of those were to match, the most
* likely correct branch will be the first one encountered in the list.
*/
function getRefFromBranchList(gitOutput) {
const branches = gitOutput.split('\n').map(b => b.split('/').slice(1).join('/').trim());
return branches.sort((a, b) => {
if (a === 'master') {
if (a === 'main') {
return -1;
}
if (b === 'master') {
if (b === 'main') {
return 1;
}
const aIsSemver = semverRegex.test(a);
const bIsSemver = semverRegex.test(b);
if (aIsSemver && bIsSemver) {
@@ -132,7 +133,7 @@ function getShaFromRef(ref) {
* by committerdate.
*
* example:
* upstream/master
* upstream/main
* upstream/9.0.x
* upstream/test
* upstream/1.1.x
-57
View File
@@ -1,57 +0,0 @@
# Install Bazel pre-reqs on Windows
# https://docs.bazel.build/versions/master/install-windows.html
# https://docs.bazel.build/versions/master/windows.html
# Install MSYS2 and packages
choco install msys2 --version 20200903.0.0 --no-progress --package-parameters "/NoUpdate"
C:\tools\msys64\usr\bin\bash.exe -l -c "pacman --needed --noconfirm -S zip unzip patch diffutils"
# Add PATH modifications to the Powershell profile. This is the win equivalent of .bash_profile.
# https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)
new-item -path $profile -itemtype file -force
# Paths for nodejs, npm, yarn, and msys2. Use single quotes to prevent interpolation.
# Add before the original path to use msys2 instead of the installed gitbash.
Add-Content $profile '$Env:path = "${Env:ProgramFiles}\nodejs\;C:\Users\circleci\AppData\Roaming\npm\;${Env:ProgramFiles(x86)}\Yarn\bin\;C:\Users\circleci\AppData\Local\Yarn\bin\;C:\tools\msys64\usr\bin\;" + $Env:path'
# Environment variables for Bazel
Add-Content $profile '$Env:BAZEL_SH = "C:\tools\msys64\usr\bin\bash.exe"'
# Get the bazelisk version devdep and store it in a global var for use in the circleci job.
$bazeliskVersion = & ${Env:ProgramFiles}\nodejs\node.exe -e "console.log(require('./package.json').devDependencies['@bazel/bazelisk'])"
# This is a tricky situation: we want $bazeliskVersion to be evaluated but not $Env:BAZELISK_VERSION.
# Formatting works https://stackoverflow.com/questions/32127583/expand-variable-inside-single-quotes
$bazeliskVersionGlobalVar = '$Env:BAZELISK_VERSION = "{0}"' -f $bazeliskVersion
Add-Content $profile $bazeliskVersionGlobalVar
# Remove the CircleCI checkout SSH override, because it breaks cloning repositories through Bazel.
# See https://circleci.com/gh/angular/angular/401454 for an example.
# TODO: is this really needed? Maybe there's a better way. It doesn't happen on Linux or on Codefresh.
git config --global --unset url.ssh://git@github.com.insteadOf
####################################################################################################
# Decrypt GCP Credentials and store them as the Google default credentials.
####################################################################################################
mkdir ${env:APPDATA}\gcloud
openssl aes-256-cbc -d -in .circleci\gcp_token -md md5 -out "$env:APPDATA\gcloud\application_default_credentials.json" -k "$env:CIRCLE_PROJECT_REPONAME"
####################################################################################################
# Set bazel configuration for CircleCI runs.
####################################################################################################
copy .circleci\bazel.windows.rc ${Env:USERPROFILE}\.bazelrc
####################################################################################################
# Install specific version of node.
####################################################################################################
nvm install 16.10.0
nvm use 16.10.0
# These Bazel prereqs aren't needed because the CircleCI image already includes them.
# choco install yarn --version 1.16.0 --no-progress
# choco install vcredist2015 --version 14.0.24215.20170201
# We don't need VS Build Tools for the tested bazel targets.
# If it's needed again, uncomment these lines.
# VS Build Tools are needed for Bazel C++ targets (like com_google_protobuf)
# choco install visualstudio2019buildtools --version 16.1.2.0 --no-progress --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.Component.VC.Runtime.UCRTSDK --add Microsoft.VisualStudio.Component.Windows10SDK.17763"
# Add-Content $profile '$Env:BAZEL_VC = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools\VC\"'
# Python is needed for Bazel Python targets
# choco install python --version 3.5.1 --no-progress
@@ -5,7 +5,7 @@ body:
- type: dropdown
id: affected-packages
attributes:
label: Which @angular/* package(s) are relevant/releated to the feature request?
label: Which @angular/* package(s) are relevant/related to the feature request?
options:
- animations
- bazel
+1 -1
View File
@@ -10,5 +10,5 @@ contact_links:
url: https://github.com/angular/components/issues/new/choose
about: Issues and feature requests for Angular Material
- name: Support Request
url: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
url: https://github.com/angular/angular/blob/main/CONTRIBUTING.md#question
about: Questions and requests for support
+1 -1
View File
@@ -1,7 +1,7 @@
## PR Checklist
Please check if your PR fulfills the following requirements:
- [ ] The commit message follows our guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit
- [ ] The commit message follows our guidelines: https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
+16 -3
View File
@@ -42,13 +42,26 @@ merge:
exclude:
- 'packages/*'
- 'packages/bazel/*'
- 'packages/bazel/src/*'
- 'packages/bazel/src/api-extractor/**'
- 'packages/bazel/src/ng_package/**'
- 'packages/bazel/src/builders/**'
- 'packages/bazel/src/ng_module/**'
- 'packages/bazel/src/ng_package/**'
- 'packages/bazel/src/protractor/**'
- 'packages/bazel/src/schematics/**'
- 'packages/bazel/src/types_bundle/**'
- 'packages/compiler-cli/src/ngcc/**'
- 'packages/compiler-cli/linker/**'
- 'packages/compiler-cli/ngcc/**'
- 'packages/compiler-cli/src/ngtsc/sourcemaps/**'
# 'private' mostly contains entrypoints for 3P Angular.
# Note that 'private/migrations' _is_ used.
- 'packages/compiler-cli/private/bazel.ts'
- 'packages/compiler-cli/private/localize.ts'
- 'packages/compiler-cli/private/tooling.ts'
- 'packages/compiler-cli/private/babel.d.ts'
# google3 defines its own binary entrypoints.
- 'packages/compiler-cli/src/bin/**'
- 'packages/docs/**'
- 'packages/elements/schematics/**'
- 'packages/examples/**'
@@ -97,7 +110,7 @@ merge:
# whether the PR shouldn't have a conflict with the base branch
noConflict: true
# list of labels that a PR needs to have, checked with a regexp (e.g. "target:" will work for the label "target: master")
# list of labels that a PR needs to have, checked with a regexp.
requiredLabels:
- 'target: *'
@@ -119,7 +132,7 @@ merge:
# the comment that will be added when the merge label is added despite failing checks, leave empty or set to false to disable
# {{MERGE_LABEL}} will be replaced by the value of the mergeLabel option
# {{PLACEHOLDER}} will be replaced by the list of failing checks
mergeRemovedComment: "I see that you just added the `{{MERGE_LABEL}}` label, but the following checks are still failing:\n{{PLACEHOLDER}}\n\n**If you want your PR to be merged, it has to pass all the CI checks.**\n\nIf you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help."
mergeRemovedComment: "I see that you just added the `{{MERGE_LABEL}}` label, but the following checks are still failing:\n{{PLACEHOLDER}}\n\n**If you want your PR to be merged, it has to pass all the CI checks.**\n\nIf you can't get the PR to a green state due to flakes or broken `main`, please try rebasing to `main` and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help."
# options for the triage plugin
triage:
+6 -2
View File
@@ -4,11 +4,15 @@ on:
pull_request_target:
types: [opened, synchronize, reopened]
# Declare default permissions as read only.
permissions:
contents: read
jobs:
labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: angular/dev-infra/github-actions/commit-message-based-labels@744a864cfd77bfe280ac9337041a512cca2daaf9
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- uses: angular/dev-infra/github-actions/commit-message-based-labels@129a5ccbcc73d7ca960d8c166d7400bf2e94cd3d
with:
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}
+5 -1
View File
@@ -5,11 +5,15 @@ on:
# Run at 14:00 every day
- cron: '0 14 * * *'
# Declare default permissions as read only.
permissions:
contents: read
jobs:
feature_triage:
if: github.repository == 'angular/angular'
runs-on: ubuntu-latest
steps:
- uses: angular/dev-infra/github-actions/feature-request@744a864cfd77bfe280ac9337041a512cca2daaf9
- uses: angular/dev-infra/github-actions/feature-request@129a5ccbcc73d7ca960d8c166d7400bf2e94cd3d
with:
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}
+5 -1
View File
@@ -5,11 +5,15 @@ on:
# Run at 16:00 every day
- cron: '0 16 * * *'
# Declare default permissions as read only.
permissions:
contents: read
jobs:
lock_closed:
if: github.repository == 'angular/angular'
runs-on: ubuntu-latest
steps:
- uses: angular/dev-infra/github-actions/lock-closed@744a864cfd77bfe280ac9337041a512cca2daaf9
- uses: angular/dev-infra/github-actions/lock-closed@129a5ccbcc73d7ca960d8c166d7400bf2e94cd3d
with:
lock-bot-key: ${{ secrets.LOCK_BOT_PRIVATE_KEY }}
+50
View File
@@ -0,0 +1,50 @@
name: OpenSSF Scorecard
on:
branch_protection_rule:
schedule:
- cron: '0 0 * * 0'
push:
branches: [main]
workflow_dispatch:
# Declare default permissions as read only.
permissions:
contents: read
jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
actions: read
contents: read
steps:
- name: 'Checkout code'
uses: actions/checkout@230611dbd0eb52da1e1f4f7bc8bb0c3a339fc8b7
with:
persist-credentials: false
- name: 'Run analysis'
uses: ossf/scorecard-action@3662744abc9b750123cb8965fef31e3802d52da5
with:
results_file: results.sarif
results_format: sarif
repo_token: ${{ secrets.GITHUB_TOKEN }}
publish_results: true
# Upload the results as artifacts.
- name: 'Upload artifact'
uses: actions/upload-artifact@2244c8200304ec9588bf9399eac622d9fadc28c4
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: 'Upload to code-scanning'
uses: github/codeql-action/upload-sarif@040feefecff4ae0fc15c110822a5f96516b0629e
with:
sarif_file: results.sarif
+4
View File
@@ -6,6 +6,10 @@
*.log
node_modules
# CircleCI temporary file for cache key computation.
# See `save_month_to_file` in `.circleci/config.yml`.
month.txt
# Include when developing application packages.
pubspec.lock
.c9
+3 -3
View File
@@ -74,7 +74,7 @@ Fixes #<issue number>
# =============================
#
# The full specification of the Angular Commit Message Format can be found at
# https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit
# https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit
#
# The following is an excerpt of the specification with the most commonly needed info.
#
@@ -107,10 +107,10 @@ Fixes #<issue number>
# │ elements|forms|http|language-service|localize|platform-browser|
# │ platform-browser-dynamic|platform-server|router|service-worker|
# │ upgrade|zone.js|packaging|changelog|docs-infra|migrations|ngcc|ve
# │ https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope
# │ https://github.com/angular/angular/blob/main/CONTRIBUTING.md#scope
# │
# └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|style|test
# https://github.com/angular/angular/blob/master/CONTRIBUTING.md#type
# https://github.com/angular/angular/blob/main/CONTRIBUTING.md#type
#
#
# Commit Message Body
+2 -2
View File
@@ -1,4 +1,4 @@
import {CaretakerConfig} from '@angular/dev-infra-private/ng-dev/caretaker/config';
import {CaretakerConfig} from '@angular/dev-infra-private/ng-dev';
/** The configuration for `ng-dev caretaker` commands. */
export const caretaker: CaretakerConfig = {
@@ -14,7 +14,7 @@ export const caretaker: CaretakerConfig = {
{
name: 'Initial Triage Queue',
query: `is:open no:milestone`,
}
},
],
caretakerGroup: 'angular-caretaker',
};
+2 -2
View File
@@ -1,4 +1,4 @@
import {CommitMessageConfig} from '@angular/dev-infra-private/ng-dev/commit-message/config';
import {CommitMessageConfig} from '@angular/dev-infra-private/ng-dev';
/**
* The configuration for `ng-dev commit-message` commands.
@@ -36,5 +36,5 @@ export const commitMessage: CommitMessageConfig = {
'upgrade',
've',
'zone.js',
]
],
};
+4 -6
View File
@@ -1,13 +1,11 @@
import {FormatConfig} from '@angular/dev-infra-private/ng-dev/format/config';
import {FormatConfig} from '@angular/dev-infra-private/ng-dev';
/**
* Configuration for the `ng-dev format` command.
*/
export const format: FormatConfig = {
'prettier': {
'matchers': [
'**/*.{yaml,yml}',
]
'matchers': ['**/*.{yaml,yml}'],
},
'clang-format': {
'matchers': [
@@ -31,7 +29,7 @@ export const format: FormatConfig = {
'!packages/core/src/i18n/locale_en.ts',
'!packages/common/locales/closure-locale.ts',
'!packages/common/src/i18n/currencies.ts',
]
],
},
'buildifier': true
'buildifier': true,
};
+2 -2
View File
@@ -1,4 +1,4 @@
import {GithubConfig} from '@angular/dev-infra-private/ng-dev/utils/config';
import {GithubConfig} from '@angular/dev-infra-private/ng-dev';
/**
* Github configuration for the `ng-dev` command. This repository is used as
@@ -7,5 +7,5 @@ import {GithubConfig} from '@angular/dev-infra-private/ng-dev/utils/config';
export const github: GithubConfig = {
owner: 'angular',
name: 'angular',
mainBranchName: 'master',
mainBranchName: 'main',
};
+4 -4
View File
@@ -1,4 +1,4 @@
import {PullRequestConfig} from '@angular/dev-infra-private/ng-dev/pr/config';
import {PullRequestConfig} from '@angular/dev-infra-private/ng-dev';
/**
* Configuration for the merge tool in `ng-dev`. This sets up the labels which
@@ -10,14 +10,14 @@ export const pullRequest: PullRequestConfig = {
caretakerNoteLabel: /^(action: merge-assistance)|(PullApprove: disable)/,
commitMessageFixupLabel: 'commit message fixup',
requiredBaseCommits: {
// PRs that target either `master` or the patch branch, need to be rebased
// PRs that target either `main` or the patch branch, need to be rebased
// on top of the latest commit message validation fix.
// These SHAs are the commits that update the required license text in the header.
'master': '5aeb9a4124922d8ac08eb73b8f322905a32b0b3a',
'main': '5aeb9a4124922d8ac08eb73b8f322905a32b0b3a',
'10.0.x': '27b95ba64a5d99757f4042073fd1860e20e3ed24',
},
// `dev-infra` and `docs-infra` are not affecting the public NPM packages. Similarly,
// the `bazel` package is not considered part of the public API so that features
// can land in patch branches.
targetLabelExemptScopes: ['dev-infra', 'docs-infra', 'bazel']
targetLabelExemptScopes: ['dev-infra', 'docs-infra', 'bazel'],
};
+2 -2
View File
@@ -1,4 +1,4 @@
import {ReleaseConfig} from '@angular/dev-infra-private/ng-dev/release/config';
import {ReleaseConfig} from '@angular/dev-infra-private/ng-dev';
import {join} from 'path';
/** Configuration for the `ng-dev release` command. */
@@ -30,7 +30,7 @@ export const release: ReleaseConfig = {
return buildTargetPackages('dist/release-output', false, 'Release', /* isRelease */ true);
},
releaseNotes: {
hiddenScopes: ['aio', 'dev-infra', 'docs-infra', 'zone.js'],
hiddenScopes: ['aio', 'dev-infra', 'docs-infra', 'zone.js', 'devtools'],
},
releasePrLabels: ['comp: build & ci', 'action: merge', 'PullApprove: disable'],
};
+22 -15
View File
@@ -63,9 +63,9 @@
version: 3
availability:
users_unavailable:
- pkozlowski-opensource # OOO as of 2020-09-28
#availability:
# users_unavailable:
# - username
# Meta field that goes unused by PullApprove to allow for defining aliases to be
# used throughout the config.
@@ -224,7 +224,7 @@ groups:
users:
- alxhub
- crisbeto
- jelbourn
- ~jelbourn
- jessicajaniuk
# =========================================================
@@ -244,7 +244,7 @@ groups:
'aio/content/guide/angular-compiler-options.md',
'aio/content/guide/aot-compiler.md',
'aio/content/guide/aot-metadata-errors.md',
'aio/content/guide/template-typecheck.md '
'aio/content/guide/template-typecheck.md'
])
reviewers:
users:
@@ -314,6 +314,11 @@ groups:
'aio/content/images/guide/attribute-directives/**',
'aio/content/guide/bootstrapping.md',
'aio/content/examples/bootstrapping/**',
'aio/content/guide/change-detection.md',
'aio/content/guide/change-detection-zone-pollution.md',
'aio/content/guide/change-detection-slow-computations.md',
'aio/content/guide/change-detection-skipping-subtrees.md',
'aio/content/images/guide/change-detection/**',
'aio/content/guide/cheatsheet.md',
'aio/content/guide/component-interaction.md',
'aio/content/examples/component-interaction/**',
@@ -395,6 +400,7 @@ groups:
'aio/content/guide/template-expression-operators.md',
'aio/content/examples/template-expression-operators/**',
'aio/content/guide/pipes.md',
'aio/content/guide/pipes-custom-data-trans.md',
'aio/content/examples/pipes/**',
'aio/content/images/guide/pipes/**',
'aio/content/guide/providers.md',
@@ -1038,12 +1044,12 @@ groups:
'aio/content/guide/migration-module-with-providers.md',
'aio/content/guide/static-query-migration.md',
'aio/content/guide/update-to-latest-version.md',
'aio/content/guide/ivy-compatibility.md',
'aio/content/guide/ivy-compatibility-examples.md'
])
reviewers:
users:
- alxhub
- AndrewKushnir
- atscott
- jelbourn
# =========================================================
@@ -1271,6 +1277,7 @@ groups:
'docs/NAMING.md',
'aio/content/guide/angular-package-format.md',
'aio/content/errors/*.md',
'aio/content/extended-diagnostics/*.md',
'aio/content/guide/glossary.md',
'aio/content/guide/styleguide.md',
'aio/content/examples/errors/**',
@@ -1283,12 +1290,12 @@ groups:
- alxhub
- atscott
- dylhunn
- jelbourn
- ~jelbourn
- jessicajaniuk
- pkozlowski-opensource
reviews:
request: 4 # Request reviews from four people
required: 3 # Require that three people approve
request: 3 # Request reviews from 3 people
required: 2 # Require that 2 people approve
reviewed_for: required
# ================================================
@@ -1310,12 +1317,12 @@ groups:
- AndrewKushnir
- atscott
- dylhunn
- jelbourn
- ~jelbourn
- jessicajaniuk
- pkozlowski-opensource
reviews:
request: 4 # Request reviews from four people
required: 2 # Require that two people approve
request: 2 # Request reviews from 2 people
required: 1 # Require that 1 person approve
reviewed_for: required
# ================================================
@@ -1337,7 +1344,7 @@ groups:
- AndrewKushnir
- atscott
- dylhunn
- jelbourn
- ~jelbourn
- jessicajaniuk
- pkozlowski-opensource
@@ -1362,5 +1369,5 @@ groups:
- AndrewKushnir
- andrewseguin
- dgp1130
- jelbourn
- ~jelbourn
- josephperrott
+10 -1
View File
@@ -1,10 +1,12 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
package(default_visibility = ["//visibility:public"])
exports_files([
"LICENSE",
"karma-js.conf.js",
"browser-providers.conf.js",
"scripts/ci/track-payload-size.sh",
"scripts/ci/bazel-payload-size.sh",
"scripts/ci/payload-size.sh",
"scripts/ci/payload-size.js",
"package.json",
@@ -56,3 +58,10 @@ config_setting(
name = "stamp",
values = {"stamp": "true"},
)
nodejs_binary(
name = "yarn_vendored",
data = [".yarn/releases/yarn-1.22.17.cjs"],
entry_point = ".yarn/releases/yarn-1.22.17.cjs",
visibility = ["//integration:__subpackages__"],
)
+327 -6622
View File
File diff suppressed because it is too large Load Diff
+6557
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -94,7 +94,7 @@ Before you submit your Pull Request (PR) consider the following guidelines:
5. In your forked repository, make your changes in a new git branch:
```shell
git checkout -b my-fix-branch master
git checkout -b my-fix-branch main
```
6. Create your patch, **including appropriate test cases**.
@@ -117,7 +117,7 @@ Before you submit your Pull Request (PR) consider the following guidelines:
git push origin my-fix-branch
```
11. In GitHub, send a pull request to `angular:master`.
11. In GitHub, send a pull request to `angular:main`.
### Reviewing a Pull Request
@@ -181,10 +181,10 @@ After your pull request is merged, you can safely delete your branch and pull th
git push origin --delete my-fix-branch
```
* Check out the master branch:
* Check out the main branch:
```shell
git checkout master -f
git checkout main -f
```
* Delete the local branch:
@@ -193,10 +193,10 @@ After your pull request is merged, you can safely delete your branch and pull th
git branch -D my-fix-branch
```
* Update your master with the latest upstream version:
* Update your local `main` with the latest upstream version:
```shell
git pull --ff upstream master
git pull --ff upstream main
```
@@ -394,7 +394,7 @@ The following documents can help you sort out issues with GitHub accounts and mu
[coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
[corporate-cla]: https://cla.developers.google.com/about/google-corporate
[dev-doc]: https://github.com/angular/angular/blob/master/docs/DEVELOPER.md
[dev-doc]: https://github.com/angular/angular/blob/main/docs/DEVELOPER.md
[github]: https://github.com/angular/angular
[discord]: https://discord.gg/angular
[individual-cla]: https://cla.developers.google.com/about/google-individual
+4 -2
View File
@@ -24,8 +24,8 @@
</p>
<p align="center">
<a href="https://circleci.com/gh/angular/workflows/angular/tree/master">
<img src="https://img.shields.io/circleci/build/github/angular/angular/master.svg?logo=circleci&logoColor=fff&label=CircleCI" alt="CI status" />
<a href="https://circleci.com/gh/angular/workflows/angular/tree/main">
<img src="https://img.shields.io/circleci/build/github/angular/angular/main.svg?logo=circleci&logoColor=fff&label=CircleCI" alt="CI status" />
</a>&nbsp;
<a href="https://www.npmjs.com/@angular/core">
<img src="https://img.shields.io/npm/v/@angular/core.svg?logo=npm&logoColor=fff&label=NPM+package&color=limegreen" alt="Angular on npm" />
@@ -53,6 +53,7 @@ Get started with Angular, learn the fundamentals and explore advanced topics on
- [Server Side Rendering][ssr]
- [Schematics][schematics]
- [Lazy Loading][lazyloading]
- [Animations][animations]
## Development Setup
@@ -157,3 +158,4 @@ Join the conversation and help the community.
[stackoverflow]: https://stackoverflow.com/questions/tagged/angular
[youtube]: https://youtube.com/angular
[meetup]: https://www.meetup.com/find/?keywords=angular
[animations]: https://angular.io/guide/animations
+33 -18
View File
@@ -5,46 +5,59 @@ workspace(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch rules_nodejs so we can install our npm dependencies
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "ddb78717b802f8dd5d4c01c340ecdc007c8ced5c1df7db421d0df3d642ea0580",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.0/rules_nodejs-4.6.0.tar.gz"],
sha256 = "3ceb1e5b5dcad5fa2ad8870a20201cfbb9c9c63cac4055c9ab370034c765297f",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.3.0/rules_nodejs-5.3.0.tar.gz"],
)
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
build_bazel_rules_nodejs_dependencies()
# The PKG rules are needed to build tar packages for integration tests. The builtin
# rule in `@bazel_tools` is not Windows compatible and outdated.
http_archive(
name = "rules_pkg",
sha256 = "a89e203d3cf264e564fcb96b6e06dd70bc0557356eb48400ce4b5d97c2c3720d",
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
],
)
# Check the rules_nodejs version and download npm dependencies
# Note: bazel (version 2 and after) will check the .bazelversion file so we don't need to
# assert on that.
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
check_rules_nodejs_version(minimum_version_string = "2.2.0")
# Setup the Node.js toolchain
node_repositories(
nodejs_register_toolchains(
name = "nodejs",
node_version = "16.10.0",
package_json = ["//:package.json"],
)
# Download npm dependencies.
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
load("//integration:npm_package_archives.bzl", "npm_package_archives")
yarn_install(
name = "npm",
# Note that we add the postinstall script here so that the dependencies are re-installed
# Note that we add the postinstall scripts here so that the dependencies are re-installed
# when the postinstall patches are modified.
data = ["//tools:postinstall-patches.js"],
data = [
"//:.yarn/releases/yarn-1.22.17.cjs",
"//:.yarnrc",
"//:scripts/puppeteer-chromedriver-versions.js",
"//:scripts/webdriver-manager-update.js",
"//tools:postinstall-patches.js",
],
# Currently disabled due to:
# 1. Missing Windows support currently.
# 2. Incompatibilites with the `ts_library` rule.
exports_directories_only = False,
manual_build_file_contents = npm_package_archives(),
package_json = "//:package.json",
# We prefer to symlink the `node_modules` to only maintain a single install.
# See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.
symlink_node_modules = True,
yarn = "//:.yarn/releases/yarn-1.22.17.cjs",
yarn_lock = "//:yarn.lock",
)
@@ -64,7 +77,9 @@ browser_repositories()
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
esbuild_repositories()
esbuild_repositories(
npm_repository = "npm",
)
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
+1
View File
@@ -48,6 +48,7 @@
"@typescript-eslint/naming-convention": "off",
"no-console": ["error", {"allow": ["log", "warn", "error"]}],
"no-empty-function": "off",
"@angular-eslint/no-host-metadata-property": "off",
"no-restricted-syntax": [
"error",
{
+2 -2
View File
@@ -1,8 +1,8 @@
# Angular documentation project (https://angular.io)
Everything in this folder is part of the documentation project. This includes
Everything in this folder is part of the documentation project. This includes:
* the web site for displaying the documentation
* the web site for displaying the documentation.
* the dgeni configuration for converting source files to rendered files that can be viewed in the web site.
* the tooling for setting up examples for development; and generating live-example and zip files from the examples.
+13 -13
View File
@@ -1,5 +1,5 @@
# Image metadata and config
FROM debian:buster
FROM debian:bullseye
LABEL name="angular.io PR preview" \
description="This image implements the PR preview functionality for angular.io." \
@@ -72,29 +72,29 @@ RUN mkdir /var/log/aio
# Add extra package sources
RUN apt-get update -y && apt-get install -y curl=7.64.0-4+deb10u1
RUN curl --silent --show-error --location https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update -y && apt-get install -y curl
RUN curl --silent --show-error --location https://deb.nodesource.com/setup_14.x | bash -
RUN curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# Install packages
# NOTE: Some packages (such as `nginx`, `nodejs`, `openssl`) make older versions unavailable on the
# repositories, so we cannot pin to specific versions for these packages :(
# See for example:
# NOTE: Many packages make older versions unavailable on the repositories, so we cannot pin to
# specific versions :(
# See, for example:
# - https://github.com/nodesource/distributions/issues/33
# - https://askubuntu.com/questions/715104/how-can-i-downgrade-openssl-via-apt-get
RUN apt-get update -y && apt-get install -y \
cron=3.0pl1-134+deb10u1 \
dnsmasq=2.80-1 \
nano=3.2-3 \
cron \
dnsmasq \
nano \
nginx \
nodejs \
openssl \
rsyslog=8.1901.0-1 \
vim=2:8.1.0875-5 \
yarn=1.22.4-1
RUN yarn global add pm2@4.4.0
rsyslog \
vim \
yarn=1.22.18-1
RUN yarn global add pm2@5.2.0
# Set up log rotation
@@ -1,70 +1,116 @@
// Imports
import fetch from 'node-fetch';
import fetch, {RequestInit} from 'node-fetch';
import {assertNotMissingOrEmpty} from './utils';
// Constants
const CIRCLE_CI_API_URL = 'https://circleci.com/api/v1.1/project/github';
const CIRCLE_CI_BASE_API_URL = 'https://circleci.com/api/v2';
const CIRCLE_CI_BUILD_API_URL = `${CIRCLE_CI_BASE_API_URL}/project/gh`;
const CIRCLE_CI_PIPELINE_API_URL = `${CIRCLE_CI_BASE_API_URL}/pipeline`;
// Interfaces - Types
// API docs: https://circleci.com/docs/api/v2#operation/getJobArtifacts
// Example: https://circleci.com/api/v2/project/gh/angular/angular/1163941/artifacts
export interface ArtifactInfo {
/** The path of this build artifacts. */
path: string;
pretty_path: string;
node_index: number;
/** The full URL where this artifact can be downloaded from. */
url: string;
// There are other fields but they are not used in this code.
}
export type ArtifactResponse = ArtifactInfo[];
export type ArtifactResponse = {items: ArtifactInfo[]};
// API docs: https://circleci.com/docs/api/v2#operation/getJobDetails
// Example: https://circleci.com/api/v2/project/gh/angular/angular/job/1163941
export interface BuildInfo {
reponame: string;
failed: boolean;
branch: string;
username: string;
build_num: number;
has_artifacts: boolean;
outcome: string; // e.g. 'success'
vcs_revision: string; // HEAD SHA
// there are other fields but they are not used in this code
/** The job number. */
number: number;
/** The job name (e.g. `'aio_preview'`). */
name: string;
/** Info about the organization which the project related to this job belongs to. */
organization: {
name: string;
};
/** Info about the project related to this job. */
project: {
name: string;
};
/** Info about the [pipeline](https://circleci.com/docs/2.0/pipelines/) that this job is part of. */
pipeline: {
id: string;
};
// There are other fields but they are not used in this code.
}
// API docs: https://circleci.com/docs/api/v2#operation/getPipelineById
// https://circleci.com/api/v2/pipeline/356227c0-32f6-4f99-bfc2-3938db90a147
export interface PipelineInfo {
/** The pipeline ID. */
id: string;
/** Info related to/retrieved from the version control system provider (e.g. GitHub). */
vcs: {
/** The PR number. */
review_id: string;
/** The HEAD SHA. */
revision: string;
};
// There are other fields but they are not used in this code.
}
/**
* A Helper that can interact with the CircleCI API.
*/
export class CircleCiApi {
private tokenParam = `circle-token=${this.circleCiToken}`;
/**
* Construct a helper that can interact with the CircleCI REST API.
* @param githubOrg The Github organisation whose repos we want to access in CircleCI (e.g. angular).
* @param githubOrg The Github organisation whose repos we want to access in CircleCI (e.g.
* angular).
* @param githubRepo The Github repo whose builds we want to access in CircleCI (e.g. angular).
* @param circleCiToken The CircleCI API access token (secret).
*/
constructor(
private githubOrg: string,
private githubRepo: string,
private circleCiToken: string,
private githubOrg: string,
private githubRepo: string,
private circleCiToken: string,
) {
assertNotMissingOrEmpty('githubOrg', githubOrg);
assertNotMissingOrEmpty('githubRepo', githubRepo);
assertNotMissingOrEmpty('circleCiToken', circleCiToken);
}
public async fetchFromCircleCi(url: string, params: RequestInit = {}) {
params.headers = {...params.headers, 'Circle-Token': this.circleCiToken};
const response = await fetch(url, params);
if (response.status !== 200) {
throw new Error(`${url}: ${response.status} - ${response.statusText}`);
}
return response;
}
/**
* Get the info for a build from the CircleCI API
* Get the info for a build (aka job) from the CircleCI API.
* @param buildNumber The CircleCI build number that generated the artifact.
* @returns A promise to the info about the build
* @returns A promise to the info about the build.
*/
public async getBuildInfo(buildNumber: number): Promise<BuildInfo> {
try {
const baseUrl = `${CIRCLE_CI_API_URL}/${this.githubOrg}/${this.githubRepo}/${buildNumber}`;
const response = await fetch(`${baseUrl}?${this.tokenParam}`);
if (response.status !== 200) {
throw new Error(`${baseUrl}: ${response.status} - ${response.statusText}`);
}
const url = `${CIRCLE_CI_BUILD_API_URL}/${this.githubOrg}/${this.githubRepo}/job/${buildNumber}`;
const response = await this.fetchFromCircleCi(url);
return response.json();
} catch (error) {
throw new Error(`CircleCI build info request failed (${error.message})`);
throw new Error(`CircleCI build info request failed (${(error as Error).message})`);
}
}
@@ -74,17 +120,32 @@ export class CircleCiApi {
* @returns A promise to the URL that can be requested to download the actual build artifact file.
*/
public async getBuildArtifactUrl(buildNumber: number, artifactPath: string): Promise<string> {
const baseUrl = `${CIRCLE_CI_API_URL}/${this.githubOrg}/${this.githubRepo}/${buildNumber}`;
const baseUrl = `${CIRCLE_CI_BUILD_API_URL}/${this.githubOrg}/${this.githubRepo}/${buildNumber}`;
try {
const response = await fetch(`${baseUrl}/artifacts?${this.tokenParam}`);
const response = await this.fetchFromCircleCi(`${baseUrl}/artifacts`);
const artifacts = await response.json() as ArtifactResponse;
const artifact = artifacts.find(item => item.path === artifactPath);
const artifact = artifacts.items.find(item => item.path === artifactPath);
if (!artifact) {
throw new Error(`Missing artifact (${artifactPath}) for CircleCI build: ${buildNumber}`);
}
return artifact.url;
} catch (error) {
throw new Error(`CircleCI artifact URL request failed (${error.message})`);
throw new Error(`CircleCI artifact URL request failed (${(error as Error).message})`);
}
}
/**
* Get the info for a [pipeline](https://circleci.com/docs/2.0/pipelines/) from the CircleCI API.
* @param pipelineId The CircleCI pipeline ID that generated the artifact.
* @returns A promise to the info about the pipeline.
*/
public async getPipelineInfo(pipelineId: string): Promise<PipelineInfo> {
try {
const url = `${CIRCLE_CI_PIPELINE_API_URL}/${pipelineId}`;
const response = await this.fetchFromCircleCi(url);
return response.json();
} catch (error) {
throw new Error(`CircleCI pipeline info request failed (${(error as Error).message})`);
}
}
}
@@ -1,4 +1,5 @@
import {basename, resolve as resolvePath} from 'path';
import {SHORT_SHA_LEN} from './constants';
/**
@@ -17,7 +18,8 @@ export function computeShortSha(sha: string) {
* @param artifactPath The path to the artifact on CircleCI.
* @returns The fully resolved location for the specified downloaded artifact.
*/
export function computeArtifactDownloadPath(downloadsDir: string, pr: number, sha: string, artifactPath: string) {
export function computeArtifactDownloadPath(
downloadsDir: string, pr: number, sha: string, artifactPath: string) {
return resolvePath(downloadsDir, `${pr}-${computeShortSha(sha)}-${basename(artifactPath)}`);
}
@@ -48,7 +50,7 @@ export function assert(value: boolean, message: string) {
* @param name The name of the parameter.
* @param value The value of the parameter.
*/
export const assertNotMissingOrEmpty = (name: string, value: string | null | undefined) => {
export const assertNotMissingOrEmpty = (name: string, value: string|null|undefined) => {
assert(!!value, `Missing or empty required parameter '${name}'!`);
};
@@ -64,9 +66,9 @@ export const getEnvVar = (name: string, isOptional = false): string => {
if (!isOptional && !value) {
try {
throw new Error(`ERROR: Missing required environment variable '${name}'!`);
throw new Error(`ERROR: Missing required environment variable '${name}'!`);
} catch (error) {
console.error(error.stack);
console.error((error as Error).stack);
process.exit(1);
}
}
@@ -76,7 +78,8 @@ export const getEnvVar = (name: string, isOptional = false): string => {
/**
* A basic logger implementation.
* Delegates to `console`, but prepends each message with the current date and specified scope (i.e caller).
* Delegates to `console`, but prepends each message with the current date and specified scope (i.e
* caller).
*/
export class Logger {
private padding = ' '.repeat(20 - this.scope.length);
@@ -87,12 +90,20 @@ export class Logger {
*/
constructor(private scope: string) {}
public error(...args: any[]) { this.callMethod('error', args); }
public info(...args: any[]) { this.callMethod('info', args); }
public log(...args: any[]) { this.callMethod('log', args); }
public warn(...args: any[]) { this.callMethod('warn', args); }
public error(...args: any[]) {
this.callMethod('error', args);
}
public info(...args: any[]) {
this.callMethod('info', args);
}
public log(...args: any[]) {
this.callMethod('log', args);
}
public warn(...args: any[]) {
this.callMethod('warn', args);
}
private callMethod(method: 'error' | 'info' | 'log' | 'warn', args: any[]) {
private callMethod(method: 'error'|'info'|'log'|'warn', args: any[]) {
console[method](`[${new Date()}]`, `${this.scope}:${this.padding}`, ...args);
}
}
@@ -1,10 +1,11 @@
import * as fs from 'fs';
import fetch from 'node-fetch';
import {dirname} from 'path';
import {mkdir} from 'shelljs';
import {promisify} from 'util';
import {CircleCiApi} from '../common/circle-ci-api';
import {assert, assertNotMissingOrEmpty, computeArtifactDownloadPath, Logger} from '../common/utils';
import {PreviewServerError} from './preview-error';
export interface GithubInfo {
@@ -12,7 +13,6 @@ export interface GithubInfo {
pr: number;
repo: string;
sha: string;
success: boolean;
}
/**
@@ -20,8 +20,11 @@ export interface GithubInfo {
*/
export class BuildRetriever {
private logger = new Logger('BuildRetriever');
constructor(private api: CircleCiApi, private downloadSizeLimit: number, private downloadDir: string) {
assert(downloadSizeLimit > 0, 'Invalid parameter "downloadSizeLimit" should be a number greater than 0.');
constructor(
private api: CircleCiApi, private downloadSizeLimit: number, private downloadDir: string) {
assert(
downloadSizeLimit > 0,
'Invalid parameter "downloadSizeLimit" should be a number greater than 0.');
assertNotMissingOrEmpty('downloadDir', downloadDir);
}
@@ -32,12 +35,12 @@ export class BuildRetriever {
*/
public async getGithubInfo(buildNum: number): Promise<GithubInfo> {
const buildInfo = await this.api.getBuildInfo(buildNum);
const pipelineInfo = await this.api.getPipelineInfo(buildInfo.pipeline.id);
const githubInfo: GithubInfo = {
org: buildInfo.username,
pr: getPrFromBranch(buildInfo.branch),
repo: buildInfo.reponame,
sha: buildInfo.vcs_revision,
success: !buildInfo.failed,
org: buildInfo.organization.name,
pr: +pipelineInfo.vcs.review_id,
repo: buildInfo.project.name,
sha: pipelineInfo.vcs.revision,
};
return githubInfo;
}
@@ -50,34 +53,25 @@ export class BuildRetriever {
* @param artifactPath the path on CircleCI where the artifact was stored.
* @returns A promise to the file path where the downloaded file was stored.
*/
public async downloadBuildArtifact(buildNum: number, pr: number, sha: string, artifactPath: string): Promise<string> {
public async downloadBuildArtifact(
buildNum: number, pr: number, sha: string, artifactPath: string): Promise<string> {
try {
const outPath = computeArtifactDownloadPath(this.downloadDir, pr, sha, artifactPath);
const downloadExists = await new Promise(resolve => fs.exists(outPath, exists => resolve(exists)));
const downloadExists =
await new Promise(resolve => fs.exists(outPath, exists => resolve(exists)));
if (!downloadExists) {
const url = await this.api.getBuildArtifactUrl(buildNum, artifactPath);
const response = await fetch(url, {size: this.downloadSizeLimit});
if (response.status !== 200) {
throw new PreviewServerError(response.status, `Error ${response.status} - ${response.statusText}`);
}
const response = await this.api.fetchFromCircleCi(url, {size: this.downloadSizeLimit});
const buffer = await response.buffer();
mkdir('-p', dirname(outPath));
await promisify(fs.writeFile)(outPath, buffer);
}
return outPath;
} catch (error) {
} catch (error: any) {
this.logger.warn(error);
const status = (error.type === 'max-size') ? 413 : 500;
throw new PreviewServerError(status, `CircleCI artifact download failed (${error.message || error})`);
throw new PreviewServerError(
status, `CircleCI artifact download failed (${error.message || error})`);
}
}
}
function getPrFromBranch(branch: string): number {
// CircleCI only exposes PR numbers via the `branch` field :-(
const match = /^pull\/(\d+)$/.exec(branch);
if (!match) {
throw new Error(`No PR found in branch field: ${branch}`);
}
return +match[1];
}
@@ -120,13 +120,7 @@ export class PreviewServerFactory {
return;
}
const { pr, sha, org, repo, success } = await buildRetriever.getGithubInfo(buildNum);
if (!success) {
res.sendStatus(204);
logger.log(`PR:${pr}, Build:${buildNum} - Skipping preview processing because this build did not succeed.`);
return;
}
const { pr, sha, org, repo } = await buildRetriever.getGithubInfo(buildNum);
assert(cfg.githubOrg === org,
`Invalid webhook: expected "githubOrg" property to equal "${cfg.githubOrg}" but got "${org}".`);
@@ -1,9 +1,10 @@
export const enum BuildNums {
BUILD_INFO_ERROR = 1,
BUILD_INFO_404,
BUILD_INFO_BUILD_FAILED,
BUILD_INFO_INVALID_GH_ORG,
BUILD_INFO_INVALID_GH_REPO,
PIPELINE_INFO_ERROR,
PIPELINE_INFO_404,
CHANGED_FILES_ERROR,
CHANGED_FILES_404,
CHANGED_FILES_NONE,
@@ -21,6 +22,17 @@ export const enum BuildNums {
TRUST_CHECK_INACTIVE_TRUSTED_USER,
}
export const enum PipelineIds {
PIPELINE_INFO_ERROR = 'pipeline-error',
PIPELINE_INFO_404 = 'pipeline-404',
CHANGED_FILES_ERROR = 'pipeline-cfe',
CHANGED_FILES_404 = 'pipeline-cf404',
CHANGED_FILES_NONE = 'pipeline-cfn',
TRUST_CHECK_ERROR = 'pipeline-tce',
TRUST_CHECK_UNTRUSTED = 'pipeline-tcu',
PIPELINE_INFO_OK = 'pipeline-ok',
}
export const enum PrNums {
CHANGED_FILES_ERROR = 1,
CHANGED_FILES_404,
@@ -3,7 +3,7 @@ import * as nock from 'nock';
import * as tar from 'tar-stream';
import {gzipSync} from 'zlib';
import {getEnvVar, Logger} from '../common/utils';
import {BuildNums, PrNums, SHA} from './constants';
import {BuildNums, PipelineIds, PrNums, SHA} from './constants';
// We are using the `nock` library to fake responses from REST requests, when testing.
// This is necessary, because the test preview-server runs as a separate node process to
@@ -30,11 +30,17 @@ const INACTIVE_TRUSTED_USER = 'inactive-trusted-user';
const UNTRUSTED_USER = 'untrusted-user';
const BASIC_BUILD_INFO = {
branch: `pull/${PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER}`,
failed: false,
reponame: AIO_GITHUB_REPO,
username: AIO_GITHUB_ORGANIZATION,
vcs_revision: SHA,
name: 'test_job',
organization: {name: AIO_GITHUB_ORGANIZATION},
project: {name: AIO_GITHUB_REPO},
pipeline: {id: PipelineIds.PIPELINE_INFO_OK},
};
const BASIC_PIPELINE_INFO = {
id: PipelineIds.PIPELINE_INFO_OK,
vcs: {
review_id: `${PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER}`,
revision: SHA,
},
};
const ISSUE_INFO_TRUSTED_LABEL = { labels: [{ name: AIO_TRUSTED_PR_LABEL }], user: { login: UNTRUSTED_USER } };
@@ -47,7 +53,6 @@ const INACTIVE_STATE = { state: 'inactive' };
const TEST_TEAM_INFO = AIO_GITHUB_TEAM_SLUGS.map((slug, index) => ({ slug, id: index }));
const CIRCLE_CI_API_HOST = 'https://circleci.com';
const CIRCLE_CI_TOKEN_PARAM = `circle-token=${AIO_CIRCLE_CI_TOKEN}`;
const ARTIFACT_1 = { path: 'artifact-1', url: `${CIRCLE_CI_API_HOST}/artifacts/artifact-1`, _urlPath: '/artifacts/artifact-1' };
const ARTIFACT_2 = { path: 'artifact-2', url: `${CIRCLE_CI_API_HOST}/artifacts/artifact-2`, _urlPath: '/artifacts/artifact-2' };
const ARTIFACT_3 = { path: 'artifact-3', url: `${CIRCLE_CI_API_HOST}/artifacts/artifact-3`, _urlPath: '/artifacts/artifact-3' };
@@ -57,11 +62,13 @@ const ARTIFACT_VALID_TRUSTED_USER = { path: AIO_ARTIFACT_PATH, url: `${CIRCLE_CI
const ARTIFACT_VALID_TRUSTED_LABEL = { path: AIO_ARTIFACT_PATH, url: `${CIRCLE_CI_API_HOST}/artifacts/valid/label`, _urlPath: '/artifacts/valid/label' };
const ARTIFACT_VALID_UNTRUSTED = { path: AIO_ARTIFACT_PATH, url: `${CIRCLE_CI_API_HOST}/artifacts/valid/untrusted`, _urlPath: '/artifacts/valid/untrusted' };
const CIRCLE_CI_BUILD_INFO_URL = `/api/v1.1/project/github/${AIO_GITHUB_ORGANIZATION}/${AIO_GITHUB_REPO}`;
const CIRCLE_CI_BUILD_INFO_URL = `/api/v2/project/gh/${AIO_GITHUB_ORGANIZATION}/${AIO_GITHUB_REPO}`;
const CIRCLE_CI_PIPELINE_INFO_URL = '/api/v2/pipeline';
const buildInfoUrl = (buildNum: number) => `${CIRCLE_CI_BUILD_INFO_URL}/${buildNum}?${CIRCLE_CI_TOKEN_PARAM}`;
const buildArtifactsUrl = (buildNum: number) => `${CIRCLE_CI_BUILD_INFO_URL}/${buildNum}/artifacts?${CIRCLE_CI_TOKEN_PARAM}`;
const buildInfo = (prNum: number) => ({ ...BASIC_BUILD_INFO, branch: `pull/${prNum}` });
const buildInfoUrl = (buildNum: number) => `${CIRCLE_CI_BUILD_INFO_URL}/job/${buildNum}`;
const buildArtifactsUrl = (buildNum: number) => `${CIRCLE_CI_BUILD_INFO_URL}/${buildNum}/artifacts`;
const pipelineInfoUrl = (pipelineId: string) => `${CIRCLE_CI_PIPELINE_INFO_URL}/${pipelineId}`;
const buildInfo = (pipelineId: string) => ({ ...BASIC_BUILD_INFO, pipeline: { id: pipelineId } });
const GITHUB_API_HOST = 'https://api.github.com';
const GITHUB_ISSUES_URL = `/repos/${AIO_GITHUB_ORGANIZATION}/${AIO_GITHUB_REPO}/issues`;
@@ -73,6 +80,15 @@ const getFilesUrl = (prNum: number, pageNum = 1) => `${GITHUB_PULLS_URL}/${prNum
const getCommentUrl = (prNum: number) => `${getIssueUrl(prNum)}/comments`;
const getTeamMembershipUrl = (teamId: number, username: string) => `/teams/${teamId}/memberships/${username}`;
const setUpCircleCiApiForBuild =
(buildNum: number, pipelineId: string, prNum = PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, sha = SHA) => {
circleCiApi.get(buildInfoUrl(buildNum)).reply(200, buildInfo(pipelineId));
circleCiApi.get(pipelineInfoUrl(pipelineId)).reply(200, {
id: pipelineId,
vcs: { review_id: `${prNum}`, revision: sha },
});
};
const createArchive = (buildNum: number, prNum: number, sha: string) => {
logger.log('createArchive', buildNum, prNum, sha);
const pack = tar.pack();
@@ -84,7 +100,7 @@ const createArchive = (buildNum: number, prNum: number, sha: string) => {
};
// Create request scopes
const circleCiApi = nock(CIRCLE_CI_API_HOST).persist();
const circleCiApi = nock(CIRCLE_CI_API_HOST).persist().matchHeader('Circle-Token', AIO_CIRCLE_CI_TOKEN);
const githubApi = nock(GITHUB_API_HOST).persist().matchHeader('Authorization', `token ${AIO_GITHUB_TOKEN}`);
//////////////////////////////
@@ -92,50 +108,57 @@ const githubApi = nock(GITHUB_API_HOST).persist().matchHeader('Authorization', `
// GENERAL responses
githubApi.get(GITHUB_TEAMS_URL + '?page=1&per_page=100').reply(200, TEST_TEAM_INFO);
githubApi.post(getCommentUrl(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).reply(200);
circleCiApi.get(pipelineInfoUrl(PipelineIds.PIPELINE_INFO_OK)).reply(200, BASIC_PIPELINE_INFO);
// BUILD_INFO errors
// BUILD INFO errors
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_ERROR)).replyWithError('BUILD_INFO_ERROR');
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_404)).reply(404, 'BUILD_INFO_404');
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_BUILD_FAILED)).reply(200, { ...BASIC_BUILD_INFO, failed: true });
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_INVALID_GH_ORG)).reply(200, { ...BASIC_BUILD_INFO, username: 'bad' });
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_INVALID_GH_REPO)).reply(200, { ...BASIC_BUILD_INFO, reponame: 'bad' });
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_INVALID_GH_ORG)).reply(200, { ...BASIC_BUILD_INFO, organization: { name: 'bad' } });
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_INVALID_GH_REPO)).reply(200, { ...BASIC_BUILD_INFO, project: { name: 'bad' } });
// PIPELINE INFO errors
circleCiApi.get(buildInfoUrl(BuildNums.PIPELINE_INFO_ERROR)).reply(200, { ...BASIC_BUILD_INFO, pipeline: { id: PipelineIds.PIPELINE_INFO_ERROR } });
circleCiApi.get(pipelineInfoUrl(PipelineIds.PIPELINE_INFO_ERROR)).replyWithError('PIPELINE_INFO_ERROR');
circleCiApi.get(buildInfoUrl(BuildNums.PIPELINE_INFO_404)).reply(200, { ...BASIC_BUILD_INFO, pipeline: { id: PipelineIds.PIPELINE_INFO_404 } });
circleCiApi.get(pipelineInfoUrl(PipelineIds.PIPELINE_INFO_ERROR)).reply(404, 'PIPELINE_INFO_404');
// CHANGED FILE errors
circleCiApi.get(buildInfoUrl(BuildNums.CHANGED_FILES_ERROR)).reply(200, buildInfo(PrNums.CHANGED_FILES_ERROR));
setUpCircleCiApiForBuild(BuildNums.CHANGED_FILES_ERROR, PipelineIds.CHANGED_FILES_ERROR, PrNums.CHANGED_FILES_ERROR);
githubApi.get(getFilesUrl(PrNums.CHANGED_FILES_ERROR)).replyWithError('CHANGED_FILES_ERROR');
circleCiApi.get(buildInfoUrl(BuildNums.CHANGED_FILES_404)).reply(200, buildInfo(PrNums.CHANGED_FILES_404));
setUpCircleCiApiForBuild(BuildNums.CHANGED_FILES_404, PipelineIds.CHANGED_FILES_404, PrNums.CHANGED_FILES_404);
githubApi.get(getFilesUrl(PrNums.CHANGED_FILES_404)).reply(404, 'CHANGED_FILES_404');
circleCiApi.get(buildInfoUrl(BuildNums.CHANGED_FILES_NONE)).reply(200, buildInfo(PrNums.CHANGED_FILES_NONE));
setUpCircleCiApiForBuild(BuildNums.CHANGED_FILES_NONE, PipelineIds.CHANGED_FILES_NONE, PrNums.CHANGED_FILES_NONE);
githubApi.get(getFilesUrl(PrNums.CHANGED_FILES_NONE)).reply(200, []);
// ARTIFACT URL errors
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_ERROR)).reply(200, buildInfo(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER));
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_ERROR)).reply(200, BASIC_BUILD_INFO);
circleCiApi.get(buildArtifactsUrl(BuildNums.BUILD_ARTIFACTS_ERROR)).replyWithError('BUILD_ARTIFACTS_ERROR');
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_404)).reply(200, buildInfo(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER));
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_404)).reply(200, BASIC_BUILD_INFO);
circleCiApi.get(buildArtifactsUrl(BuildNums.BUILD_ARTIFACTS_404)).reply(404, 'BUILD_ARTIFACTS_ERROR');
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_EMPTY)).reply(200, buildInfo(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER));
circleCiApi.get(buildArtifactsUrl(BuildNums.BUILD_ARTIFACTS_EMPTY)).reply(200, []);
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_MISSING)).reply(200, buildInfo(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER));
circleCiApi.get(buildArtifactsUrl(BuildNums.BUILD_ARTIFACTS_MISSING)).reply(200, [ARTIFACT_1, ARTIFACT_2, ARTIFACT_3]);
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_EMPTY)).reply(200, BASIC_BUILD_INFO);
circleCiApi.get(buildArtifactsUrl(BuildNums.BUILD_ARTIFACTS_EMPTY)).reply(200, { items: [] });
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_ARTIFACTS_MISSING)).reply(200, BASIC_BUILD_INFO);
circleCiApi.get(buildArtifactsUrl(BuildNums.BUILD_ARTIFACTS_MISSING)).reply(200, { items: [ARTIFACT_1, ARTIFACT_2, ARTIFACT_3] });
// ARTIFACT DOWNLOAD errors
circleCiApi.get(buildInfoUrl(BuildNums.DOWNLOAD_ARTIFACT_ERROR)).reply(200, buildInfo(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER));
circleCiApi.get(buildArtifactsUrl(BuildNums.DOWNLOAD_ARTIFACT_ERROR)).reply(200, [ARTIFACT_ERROR]);
circleCiApi.get(buildInfoUrl(BuildNums.DOWNLOAD_ARTIFACT_ERROR)).reply(200, BASIC_BUILD_INFO);
circleCiApi.get(buildArtifactsUrl(BuildNums.DOWNLOAD_ARTIFACT_ERROR)).reply(200, { items: [ARTIFACT_ERROR] });
circleCiApi.get(ARTIFACT_ERROR._urlPath).replyWithError(ARTIFACT_ERROR._urlPath);
circleCiApi.get(buildInfoUrl(BuildNums.DOWNLOAD_ARTIFACT_404)).reply(200, buildInfo(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER));
circleCiApi.get(buildInfoUrl(BuildNums.DOWNLOAD_ARTIFACT_404)).reply(200, BASIC_BUILD_INFO);
circleCiApi.get(buildArtifactsUrl(BuildNums.DOWNLOAD_ARTIFACT_404)).reply(200, [ARTIFACT_404]);
circleCiApi.get(ARTIFACT_ERROR._urlPath).reply(404, ARTIFACT_ERROR._urlPath);
// TRUST CHECK errors
circleCiApi.get(buildInfoUrl(BuildNums.TRUST_CHECK_ERROR)).reply(200, buildInfo(PrNums.TRUST_CHECK_ERROR));
setUpCircleCiApiForBuild(BuildNums.TRUST_CHECK_ERROR, PipelineIds.TRUST_CHECK_ERROR, PrNums.TRUST_CHECK_ERROR);
githubApi.get(getFilesUrl(PrNums.TRUST_CHECK_ERROR)).reply(200, [{ filename: 'aio/a' }]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_ERROR)).reply(200, [ARTIFACT_VALID_TRUSTED_USER]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_ERROR)).reply(200, { items: [ARTIFACT_VALID_TRUSTED_USER] });
githubApi.get(getIssueUrl(PrNums.TRUST_CHECK_ERROR)).replyWithError('TRUST_CHECK_ERROR');
// ACTIVE TRUSTED USER response
circleCiApi.get(buildInfoUrl(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).reply(200, BASIC_BUILD_INFO);
githubApi.get(getFilesUrl(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).reply(200, [{ filename: 'aio/a' }]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).reply(200, [ARTIFACT_VALID_TRUSTED_USER]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).reply(200, { items: [ARTIFACT_VALID_TRUSTED_USER] });
circleCiApi.get(ARTIFACT_VALID_TRUSTED_USER._urlPath).reply(200, createArchive(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA));
githubApi.get(getIssueUrl(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).reply(200, ISSUE_INFO_ACTIVE_TRUSTED_USER);
githubApi.get(getTeamMembershipUrl(0, ACTIVE_TRUSTED_USER)).reply(200, ACTIVE_STATE);
@@ -143,7 +166,7 @@ githubApi.get(getTeamMembershipUrl(0, ACTIVE_TRUSTED_USER)).reply(200, ACTIVE_ST
// TRUSTED LABEL response
circleCiApi.get(buildInfoUrl(BuildNums.TRUST_CHECK_TRUSTED_LABEL)).reply(200, BASIC_BUILD_INFO);
githubApi.get(getFilesUrl(PrNums.TRUST_CHECK_TRUSTED_LABEL)).reply(200, [{ filename: 'aio/a' }]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_TRUSTED_LABEL)).reply(200, [ARTIFACT_VALID_TRUSTED_LABEL]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_TRUSTED_LABEL)).reply(200, { items: [ARTIFACT_VALID_TRUSTED_LABEL] });
circleCiApi.get(ARTIFACT_VALID_TRUSTED_LABEL._urlPath).reply(200, createArchive(BuildNums.TRUST_CHECK_TRUSTED_LABEL, PrNums.TRUST_CHECK_TRUSTED_LABEL, SHA));
githubApi.get(getIssueUrl(PrNums.TRUST_CHECK_TRUSTED_LABEL)).reply(200, ISSUE_INFO_TRUSTED_LABEL);
githubApi.get(getTeamMembershipUrl(0, ACTIVE_TRUSTED_USER)).reply(200, ACTIVE_STATE);
@@ -151,14 +174,14 @@ githubApi.get(getTeamMembershipUrl(0, ACTIVE_TRUSTED_USER)).reply(200, ACTIVE_ST
// INACTIVE TRUSTED USER response
circleCiApi.get(buildInfoUrl(BuildNums.TRUST_CHECK_INACTIVE_TRUSTED_USER)).reply(200, BASIC_BUILD_INFO);
githubApi.get(getFilesUrl(PrNums.TRUST_CHECK_INACTIVE_TRUSTED_USER)).reply(200, [{ filename: 'aio/a' }]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_INACTIVE_TRUSTED_USER)).reply(200, [ARTIFACT_VALID_TRUSTED_USER]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_INACTIVE_TRUSTED_USER)).reply(200, { items: [ARTIFACT_VALID_TRUSTED_USER] });
githubApi.get(getIssueUrl(PrNums.TRUST_CHECK_INACTIVE_TRUSTED_USER)).reply(200, ISSUE_INFO_INACTIVE_TRUSTED_USER);
githubApi.get(getTeamMembershipUrl(0, INACTIVE_TRUSTED_USER)).reply(200, INACTIVE_STATE);
// UNTRUSTED reponse
circleCiApi.get(buildInfoUrl(BuildNums.TRUST_CHECK_UNTRUSTED)).reply(200, buildInfo(PrNums.TRUST_CHECK_UNTRUSTED));
setUpCircleCiApiForBuild(BuildNums.TRUST_CHECK_UNTRUSTED, PipelineIds.TRUST_CHECK_UNTRUSTED, PrNums.TRUST_CHECK_UNTRUSTED);
githubApi.get(getFilesUrl(PrNums.TRUST_CHECK_UNTRUSTED)).reply(200, [{ filename: 'aio/a' }]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_UNTRUSTED)).reply(200, [ARTIFACT_VALID_UNTRUSTED]);
circleCiApi.get(buildArtifactsUrl(BuildNums.TRUST_CHECK_UNTRUSTED)).reply(200, { items: [ARTIFACT_VALID_UNTRUSTED] });
circleCiApi.get(ARTIFACT_VALID_UNTRUSTED._urlPath).reply(200, createArchive(BuildNums.TRUST_CHECK_UNTRUSTED, PrNums.TRUST_CHECK_UNTRUSTED, SHA));
githubApi.get(getIssueUrl(PrNums.TRUST_CHECK_UNTRUSTED)).reply(200, ISSUE_INFO_UNTRUSTED);
githubApi.get(getTeamMembershipUrl(0, UNTRUSTED_USER)).reply(404);
@@ -145,13 +145,11 @@ describe('preview-server', () => {
]);
});
it('should respond with 500 if the CircleCI API request errors', async () => {
it('should respond with 500 if any of the CircleCI API requests errors', async () => {
await curl(payload(BuildNums.BUILD_INFO_ERROR)).then(h.verifyResponse(500));
await curl(payload(BuildNums.BUILD_INFO_404)).then(h.verifyResponse(500));
});
it('should respond with 204 if the build on CircleCI failed', async () => {
await curl(payload(BuildNums.BUILD_INFO_BUILD_FAILED)).then(h.verifyResponse(204));
await curl(payload(BuildNums.PIPELINE_INFO_ERROR)).then(h.verifyResponse(500));
await curl(payload(BuildNums.PIPELINE_INFO_404)).then(h.verifyResponse(500));
});
it('should respond with 500 if the github org from CircleCI does not match what is configured', async () => {
@@ -4,7 +4,8 @@ import {CircleCiApi} from '../../lib/common/circle-ci-api';
const ORG = 'testorg';
const REPO = 'testrepo';
const TOKEN = 'xxxx';
const BASE_URL = `https://circleci.com/api/v1.1/project/github/${ORG}/${REPO}`;
const BASE_BUILD_URL = `https://circleci.com/api/v2/project/gh/${ORG}/${REPO}`;
const BASE_PIPELINE_URL = 'https://circleci.com/api/v2/pipeline';
describe('CircleCIApi', () => {
describe('constructor()', () => {
@@ -24,14 +25,26 @@ describe('CircleCIApi', () => {
});
});
describe('fetchFromCircleCI', () => {
it('should include the authentication token in the headers on every request', async () => {
const api = new CircleCiApi(ORG, REPO, TOKEN);
const request = nock(BASE_BUILD_URL)
.get('/')
.matchHeader('Circle-Token', TOKEN)
.reply(200);
await api.fetchFromCircleCi(`${BASE_BUILD_URL}/`);
request.done();
})
})
describe('getBuildInfo', () => {
it('should make a request to the CircleCI API for the given build number', async () => {
const api = new CircleCiApi(ORG, REPO, TOKEN);
const buildNum = 12345;
const expectedBuildInfo: any = { org: ORG, repo: REPO, build_num: buildNum };
const request = nock(BASE_URL)
.get(`/${buildNum}?circle-token=${TOKEN}`)
const request = nock(BASE_BUILD_URL)
.get(`/job/${buildNum}`)
.reply(200, expectedBuildInfo);
const buildInfo = await api.getBuildInfo(buildNum);
@@ -43,17 +56,17 @@ describe('CircleCIApi', () => {
const api = new CircleCiApi(ORG, REPO, TOKEN);
const buildNum = 12345;
const errorMessage = 'Invalid request';
const request = nock(BASE_URL).get(`/${buildNum}?circle-token=${TOKEN}`);
const request = nock(BASE_BUILD_URL).get(`/job/${buildNum}`);
request.replyWithError(errorMessage);
await expectAsync(api.getBuildInfo(buildNum)).toBeRejectedWithError(
`CircleCI build info request failed ` +
`(request to ${BASE_URL}/${buildNum}?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
`(request to ${BASE_BUILD_URL}/job/${buildNum} failed, reason: ${errorMessage})`);
request.reply(404, errorMessage);
await expectAsync(api.getBuildInfo(buildNum)).toBeRejectedWithError(
`CircleCI build info request failed ` +
`(request to ${BASE_URL}/${buildNum}?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
`(request to ${BASE_BUILD_URL}/job/${buildNum} failed, reason: ${errorMessage})`);
});
});
@@ -64,9 +77,9 @@ describe('CircleCIApi', () => {
const artifact0: any = { path: 'some/path/0', url: 'https://url/0' };
const artifact1: any = { path: 'some/path/1', url: 'https://url/1' };
const artifact2: any = { path: 'some/path/2', url: 'https://url/2' };
const request = nock(BASE_URL)
.get(`/${buildNum}/artifacts?circle-token=${TOKEN}`)
.reply(200, [artifact0, artifact1, artifact2]);
const request = nock(BASE_BUILD_URL)
.get(`/${buildNum}/artifacts`)
.reply(200, {items: [artifact0, artifact1, artifact2]});
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/1')).toBeResolvedTo('https://url/1');
request.done();
@@ -77,17 +90,17 @@ describe('CircleCIApi', () => {
const api = new CircleCiApi(ORG, REPO, TOKEN);
const buildNum = 12345;
const errorMessage = 'Invalid request';
const request = nock(BASE_URL).get(`/${buildNum}/artifacts?circle-token=${TOKEN}`);
const request = nock(BASE_BUILD_URL).get(`/${buildNum}/artifacts`);
request.replyWithError(errorMessage);
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/1')).toBeRejectedWithError(
`CircleCI artifact URL request failed ` +
`(request to ${BASE_URL}/${buildNum}/artifacts?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
`(request to ${BASE_BUILD_URL}/${buildNum}/artifacts failed, reason: ${errorMessage})`);
request.reply(404, errorMessage);
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/1')).toBeRejectedWithError(
`CircleCI artifact URL request failed ` +
`(request to ${BASE_URL}/${buildNum}/artifacts?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
`(request to ${BASE_BUILD_URL}/${buildNum}/artifacts failed, reason: ${errorMessage})`);
});
it('should throw an error if the response does not contain the specified artifact', async () => {
@@ -96,13 +109,46 @@ describe('CircleCIApi', () => {
const artifact0: any = { path: 'some/path/0', url: 'https://url/0' };
const artifact1: any = { path: 'some/path/1', url: 'https://url/1' };
const artifact2: any = { path: 'some/path/2', url: 'https://url/2' };
nock(BASE_URL)
.get(`/${buildNum}/artifacts?circle-token=${TOKEN}`)
.reply(200, [artifact0, artifact1, artifact2]);
nock(BASE_BUILD_URL)
.get(`/${buildNum}/artifacts`)
.reply(200, {items: [artifact0, artifact1, artifact2]});
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/3')).toBeRejectedWithError(
`CircleCI artifact URL request failed ` +
`(Missing artifact (some/path/3) for CircleCI build: ${buildNum})`);
});
});
describe('getPipelineInfo', () => {
it('should make a request to the CircleCI API for the given pipeline ID', async () => {
const api = new CircleCiApi(ORG, REPO, TOKEN);
const pipelineId = 'a1-b2-c3';
const expectedPipelineInfo: any = { org: ORG, repo: REPO, pipeline_id: pipelineId };
const request = nock(BASE_PIPELINE_URL)
.get(`/${pipelineId}`)
.reply(200, expectedPipelineInfo);
const pipelineInfo = await api.getPipelineInfo(pipelineId);
expect(pipelineInfo).toEqual(expectedPipelineInfo);
request.done();
});
it('should throw an error if the request fails', async () => {
const api = new CircleCiApi(ORG, REPO, TOKEN);
const pipelineId = 'a1-b2-c3';
const errorMessage = 'Invalid request';
const request = nock(BASE_PIPELINE_URL).get(`/${pipelineId}`);
request.replyWithError(errorMessage);
await expectAsync(api.getPipelineInfo(pipelineId)).toBeRejectedWithError(
`CircleCI pipeline info request failed ` +
`(request to ${BASE_PIPELINE_URL}/${pipelineId} failed, reason: ${errorMessage})`);
request.reply(404, errorMessage);
await expectAsync(api.getPipelineInfo(pipelineId)).toBeRejectedWithError(
`CircleCI pipeline info request failed ` +
`(request to ${BASE_PIPELINE_URL}/${pipelineId} failed, reason: ${errorMessage})`);
});
});
});
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as nock from 'nock';
import {resolve as resolvePath} from 'path';
import {BuildInfo, CircleCiApi} from '../../lib/common/circle-ci-api';
import {BuildInfo, CircleCiApi, PipelineInfo} from '../../lib/common/circle-ci-api';
import {Logger} from '../../lib/common/utils';
import {BuildRetriever} from '../../lib/preview-server/build-retriever';
@@ -13,6 +13,7 @@ describe('BuildRetriever', () => {
let api: CircleCiApi;
let BUILD_INFO: BuildInfo;
let PIPELINE_INFO: PipelineInfo;
let WRITEFILE_RESULT: any;
let writeFileSpy: jasmine.Spy;
let EXISTS_RESULT: boolean;
@@ -21,18 +22,23 @@ describe('BuildRetriever', () => {
beforeEach(() => {
BUILD_INFO = {
branch: 'pull/777',
build_num: 12345,
failed: false,
has_artifacts: true,
outcome: 'success',
reponame: 'REPO',
username: 'ORG',
vcs_revision: 'COMMIT',
number: 12345,
name: 'test_job',
organization: {name: 'ORG'},
project: {name: 'REPO'},
pipeline: {id: 'test_pipeline'},
};
PIPELINE_INFO = {
id: 'test_pipeline',
vcs: {
review_id: '777',
revision: 'COMMIT',
},
};
api = new CircleCiApi('ORG', 'REPO', 'TOKEN');
spyOn(api, 'getBuildInfo').and.resolveTo(BUILD_INFO);
spyOn(api, 'getPipelineInfo').and.resolveTo(PIPELINE_INFO);
getBuildArtifactUrlSpy = spyOn(api, 'getBuildArtifactUrl').and.resolveTo(BASE_URL + ARTIFACT_PATH);
WRITEFILE_RESULT = undefined;
@@ -65,18 +71,12 @@ describe('BuildRetriever', () => {
describe('getGithubInfo', () => {
it('should request the info from CircleCI', async () => {
it('should request the build and pipeline info from CircleCI', async () => {
const retriever = new BuildRetriever(api, MAX_DOWNLOAD_SIZE, DOWNLOAD_DIR);
const info = await retriever.getGithubInfo(12345);
expect(api.getBuildInfo).toHaveBeenCalledWith(12345);
expect(info).toEqual({org: 'ORG', pr: 777, repo: 'REPO', sha: 'COMMIT', success: true});
});
it('should error if it is not possible to extract the PR number from the branch', async () => {
BUILD_INFO.branch = 'master';
const retriever = new BuildRetriever(api, MAX_DOWNLOAD_SIZE, DOWNLOAD_DIR);
await expectAsync(retriever.getGithubInfo(12345)).toBeRejectedWithError('No PR found in branch field: master');
expect(api.getPipelineInfo).toHaveBeenCalledWith('test_pipeline');
expect(info).toEqual({org: 'ORG', pr: 777, repo: 'REPO', sha: 'COMMIT'});
});
});
@@ -160,7 +160,7 @@ describe('BuildRetriever', () => {
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(404, 'No such artifact');
await expectAsync(retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH)).
toBeRejectedWithError('CircleCI artifact download failed (Error 404 - Not Found)');
toBeRejectedWithError(`CircleCI artifact download failed (${BASE_URL}/some/path/build.zip: 404 - Not Found)`);
artifactRequest.done();
});
@@ -410,7 +410,6 @@ describe('PreviewServerFactory', () => {
pr: PR,
repo: defaultConfig.githubRepo,
sha: SHA,
success: true,
};
BASIC_PAYLOAD = { payload: { build_num: BUILD_NUM, build_parameters: { CIRCLE_JOB: 'aio_preview' } } };
AFFECTS_SIGNIFICANT_FILES = true;
@@ -481,15 +480,6 @@ describe('PreviewServerFactory', () => {
await agent.post(URL).send(BASIC_PAYLOAD).expect(202);
});
it('should not create a preview if the build was not successful', async () => {
BUILD_INFO.success = false;
await agent.post(URL).send(BASIC_PAYLOAD).expect(204);
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
expect(downloadBuildArtifactSpy).not.toHaveBeenCalled();
expect(getPrIsTrustedSpy).not.toHaveBeenCalled();
expect(createBuildSpy).not.toHaveBeenCalled();
});
it('should fail if the CircleCI request fails', async () => {
// Note it is important to put the `reject` into `and.callFake`;
// If you just `and.returnValue` the rejected promise
@@ -1,4 +1,5 @@
import * as express from 'express';
import {PreviewServerError} from '../../lib/preview-server/preview-error';
import {respondWithError, throwRequestError} from '../../lib/preview-server/utils';
@@ -37,11 +38,12 @@ describe('preview-server/utils', () => {
originalUrl: 'some.domain.com/path',
} as express.Request;
throwRequestError(505, 'ERROR MESSAGE', request);
} catch (error) {
} catch (error: any) {
caught = true;
expect(error).toBeInstanceOf(PreviewServerError);
expect(error.status).toEqual(505);
expect(error.message).toEqual(`ERROR MESSAGE in request: POST some.domain.com/path "The request body"`);
expect(error.message)
.toEqual(`ERROR MESSAGE in request: POST some.domain.com/path "The request body"`);
}
expect(caught).toEqual(true);
});
@@ -1,40 +1,36 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [
"es2015",
"es2016.array.include"
], /* Specify library files to be included in the compilation: */
], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "dist", /* Redirect output structure to the directory. */
"outDir": "dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
"importHelpers": true, /* Import emit helpers from 'tslib'. */
"importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
"useUnknownInCatchVariables": false, /* Avoid having to cast error objects inside `catch` clauses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
@@ -42,29 +38,26 @@
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [
"node_modules/@types"
], /* List of folders to include type definitions from. */
], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Other */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"newLine": "LF", /* Use the specified end of line sequence to be used when emitting files: "crlf" (windows) or "lf" (unix). */
"pretty": true, /* Stylize errors and messages using color and context. */
"skipLibCheck": true /* Skip type checking of all declaration files (*.d.ts). */
"newLine": "LF", /* Use the specified end of line sequence to be used when emitting files: "crlf" (windows) or "lf" (unix). */
"pretty": true, /* Stylize errors and messages using color and context. */
"skipLibCheck": true /* Skip type checking of all declaration files (*.d.ts). */
},
"include": [
"lib/**/*",
"test/**/*"
]
}
}
@@ -25,8 +25,8 @@ Necessary secrets:
- Generate new token with the `public_repo` scope.
2. `CIRCLE_CI_TOKEN`
- Visit https://circleci.com/gh/angular/angular/edit#api.
- Create an API token with `Build Artifacts` scope.
- Visit https://app.circleci.com/settings/user/tokens.
- Create a user API token.
## Save secrets on the VM
@@ -6,7 +6,7 @@ Assuming you have cloned the repository containing the preview server code (as d
[here](vm-setup--create-docker-image.md)), you can use the `update-preview-server.sh` script on the
VM host to update the preview server based on changes in the source code.
The script will pull the latest changes from the origin's master branch and examine if there have
The script will pull the latest changes from the origin's main branch and examine if there have
been any changes in files inside the preview server source code directory (see below). If there are,
it will create a new image and verify that it works as expected. Finally, it will stop and remove
the old docker container and image, create a new container based on the new image and start it.
@@ -25,8 +25,8 @@ readonly CONTAINER_NAME=aio
readonly lastDeployedCommit=$(git rev-parse HEAD)
echo "Currently at commit $lastDeployedCommit."
# Pull latest master from origin.
git pull origin master
# Pull latest main from origin.
git pull origin main
# Do not update the server unless files inside `aio-builds-setup/` have changed
# or the last attempt failed (identified by the provisional image still being around).
@@ -67,5 +67,9 @@ readonly CONTAINER_NAME=aio
--volume $HOST_LOGS_DIR:/var/log/aio \
"$LATEST_IMAGE_NAME"
# Clean up unused docker containers and images (to reclaim space).
sudo docker container prune --force
sudo docker image prune --all --force
echo "The new docker image has been successfully deployed."
)
+34 -17
View File
@@ -1,5 +1,6 @@
# Persistent disk cache
Angular CLI saves a number of cachable operations on disk by default.
When you re-run the same build, the build system restores the state of the previous build and re-uses previously performed operations, which decreases the time taken to build and test your applications and libraries.
@@ -7,9 +8,10 @@ When you re-run the same build, the build system restores the state of the previ
To amend the default cache settings, add the `cli.cache` object to your [Workspace Configuration](guide/workspace-config).
The object goes under `cli.cache` at the top level of the file, outside the `projects` sections.
```json
<code-example format="json" language="json">
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"$schema": "./node_modules/&commat;angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"cache": {
@@ -18,27 +20,35 @@ The object goes under `cli.cache` at the top level of the file, outside the `pro
},
"projects": {}
}
```
</code-example>
For more information, see [cache options](guide/workspace-config#cache-options).
### Enabling and disabling the cache
Caching is enabled by default. To disable caching run the following command:
```bash
Caching is enabled by default.
To disable caching run the following command:
<code-example format="shell" language="shell">
ng config cli.cache.enabled false
```
</code-example>
To re-enable caching, set `cli.cache.enabled` to `true`.
### Cache environments
By default, disk cache is only enabled for local environments.
To enable caching for all environments, run the following command:
```bash
<code-example format="shell" language="shell">
ng config cli.cache.environment all
```
</code-example>
For more information, see `environment` in [cache options](guide/workspace-config#cache-options).
@@ -50,11 +60,14 @@ The Angular CLI checks for the presence and value of the `CI` environment variab
### Cache path
By default, `.angular/cache` is used as a base directory to store cache results. To change this path, run the following command:
By default, `.angular/cache` is used as a base directory to store cache results.
To change this path, run the following command:
<code-example format="shell" language="shell">
```bash
ng config cli.cache.path ".cache/ng"
```
</code-example>
### Clearing the cache
@@ -62,14 +75,18 @@ To clear the cache, run one of the following commands.
To clear the cache on Unix-based operating systems:
```bash
<code-example format="shell" language="shell">
rm -rf .angular/cache
```
</code-example>
To clear the cache on Windows:
```bash
rmdir /s /q .angular/cache
```
<code-example format="shell" language="shell">
For more information, see [rm command](https://man7.org/linux/man-pages/man1/rm.1.html) and [rmdir command](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rmdir).
rmdir /s /q .angular\cache
</code-example>
For more information, see [rm command](https://man7.org/linux/man-pages/man1/rm.1.html) and [rmdir command](https://docs.microsoft.com/windows-server/administration/windows-commands/rmdir).
+46 -24
View File
@@ -7,30 +7,36 @@ The Angular CLI is a command-line interface tool that you use to initialize, dev
Major versions of Angular CLI follow the supported major version of Angular, but minor versions can be released separately.
Install the CLI using the `npm` package manager:
<code-example language="bash">
npm install -g @angular/cli
<code-example format="shell" language="shell">
npm install -g &commat;angular/cli<aio-angular-dist-tag class="pln"></aio-angular-dist-tag>
</code-example>
For details about changes between versions, and information about updating from previous releases,
see the Releases tab on GitHub: https://github.com/angular/angular-cli/releases
For details about changes between versions, and information about updating from previous releases, see the Releases tab on GitHub: https://github.com/angular/angular-cli/releases
## Basic workflow
Invoke the tool on the command line through the `ng` executable.
Online help is available on the command line.
Enter the following to list commands or options for a given command (such as [generate](cli/generate)) with a short description.
Enter the following to list commands or options for a given command \(such as [generate](cli/generate)\) with a short description.
<code-example format="shell" language="shell">
<code-example language="bash">
ng help
ng generate --help
</code-example>
To create, build, and serve a new, basic Angular project on a development server, go to the parent directory of your new workspace use the following commands:
<code-example language="bash">
<code-example format="shell" language="shell">
ng new my-first-project
cd my-first-project
ng serve
</code-example>
In your browser, open http://localhost:4200/ to see the new application run.
@@ -38,9 +44,10 @@ When you use the [ng serve](cli/serve) command to build an application and serve
<div class="alert is-helpful">
When you run `ng new my-first-project` a new folder, named `my-first-project`, will be created in the current working directory. Since you want to be able to create files inside that folder, make sure you have sufficient rights in the current working directory before running the command.
When you run `ng new my-first-project` a new folder, named `my-first-project`, will be created in the current working directory.
Since you want to be able to create files inside that folder, make sure you have sufficient rights in the current working directory before running the command.
If the current working directory is not the right place for your project, you can change to a more appropriate directory by running `cd <path-to-other-directory>` first.
If the current working directory is not the right place for your project, you can change to a more appropriate directory by running `cd <path-to-other-directory>`.
</div>
@@ -58,7 +65,7 @@ You can edit the generated files directly, or add to and modify them using CLI c
Use the [ng generate](cli/generate) command to add new files for additional components and services, and code for new pipes, directives, and so on.
Commands such as [add](cli/add) and [generate](cli/generate), which create or operate on applications and libraries, must be executed from within a workspace or project folder.
* See more about the [Workspace file structure](guide/file-structure).
* See more about the [Workspace file structure](guide/file-structure).
### Workspace and project configuration
@@ -66,10 +73,15 @@ A single workspace configuration file, `angular.json`, is created at the top lev
This is where you can set per-project defaults for CLI command options, and specify configurations to use when the CLI builds a project for different targets.
The [ng config](cli/config) command lets you set and retrieve configuration values from the command line, or you can edit the `angular.json` file directly.
Note that option names in the configuration file must use [camelCase](guide/glossary#case-types), while option names supplied to commands can use either camelCase or dash-case.
* See more about [Workspace Configuration](guide/workspace-config).
* See the [complete schema](https://github.com/angular/angular-cli/wiki/angular-workspace) for `angular.json`.
<div class="alert is-helpful">
**NOTE**: <br />
Option names in the configuration file must use [camelCase](guide/glossary#case-types), while option names supplied to commands must be dash-case.
</div>
* See more about [Workspace Configuration](guide/workspace-config).
## CLI command-language syntax
@@ -77,34 +89,44 @@ Command syntax is shown as follows:
`ng` *commandNameOrAlias* *requiredArg* [*optionalArg*] `[options]`
* Most commands, and some options, have aliases. Aliases are shown in the syntax statement for each command.
* Most commands, and some options, have aliases.
Aliases are shown in the syntax statement for each command.
* Option names are prefixed with a double dash (--).
Option aliases are prefixed with a single dash (-).
* Option names are prefixed with a double dash \(`--`\) characters.
Option aliases are prefixed with a single dash \(`-`\) character.
Arguments are not prefixed.
For example:
<code-example language="bash">
ng build my-app -c production
<code-example format="shell" language="shell">
ng build my-app -c production
</code-example>
* Typically, the name of a generated artifact can be given as an argument to the command or specified with the --name option.
* Typically, the name of a generated artifact can be given as an argument to the command or specified with the `--name` option.
* Argument and option names can be given in either
[camelCase or dash-case](guide/glossary#case-types).
`--myOptionName` is equivalent to `--my-option-name`.
* Argument and option names can be given in either [camelCase or dash-case](guide/glossary#case-types).
`--myOptionName` is equivalent to `--my-option-name`.
### Boolean options
Boolean options have two forms: `--this-option` sets the flag to `true`, `--no-this-option` sets it to `false`.
If neither option is supplied, the flag remains in its default state, as listed in the reference documentation.
### Relative paths
Options that specify files can be given as absolute paths, or as paths relative to the current working directory, which is generally either the workspace or project root.
### Schematics
The [ng generate](cli/generate) and [ng add](cli/add) commands take as an argument the artifact or library to be generated or added to the current project.
The [ng generate](cli/generate) and [ng add](cli/add) commands take, as an argument, the artifact or library to be generated or added to the current project.
In addition to any general options, each artifact or library defines its own options in a *schematic*.
Schematic options are supplied to the command in the same format as immediate command options.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+20 -4
View File
@@ -20,14 +20,18 @@ This ID is a string that looks like `UA-123456-12`.
You can choose to use a descriptive string as the key value, or be assigned a random key when you run the CLI command.
For example, the following command adds a configuration key named "tracking".
<code-example language="sh">
<code-example format="shell" language="shell">
ng config --global cli.analyticsSharing.tracking UA-123456-12
</code-example>
To turn off this feature, run the following command:
<code-example language="sh">
<code-example format="shell" language="shell">
ng config --global cli.analyticsSharing undefined
</code-example>
## Per user tracking
@@ -35,12 +39,24 @@ ng config --global cli.analyticsSharing undefined
You can add a custom user ID to the global configuration, in order to identify unique usage of commands and flags.
If that user enables CLI analytics for their own project, your analytics display tracks and labels their individual usage.
<code-example language="sh">
<code-example format="shell" language="shell">
ng config --global cli.analyticsSharing.uuid SOME_USER_NAME
</code-example>
To generate a new random user ID, run the following command:
<code-example language="sh">
<code-example format="shell" language="shell">
ng config --global cli.analyticsSharing.uuid ""
</code-example>
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+25 -6
View File
@@ -4,17 +4,36 @@
@shortDescription Expression has changed after it was checked
@description
Angular throws an `ExpressionChangedAfterItHasBeenCheckedError` when an expression value has been changed after change detection has completed. Angular only throws this error in development mode.
In development mode, Angular performs an additional check after each change detection run, to ensure the bindings haven’t changed. This catches errors where the view is left in an inconsistent state. This can occur, for example, if a method or getter returns a different value each time it is called, or if a child component changes values on its parent. If either of these occur, this is a sign that change detection is not stabilized. Angular throws the error to ensure data is always reflected correctly in the view, which prevents erratic UI behavior or a possible infinite loop.
Angular throws an `ExpressionChangedAfterItHasBeenCheckedError` when an expression value has been changed after change detection has completed.
Angular only throws this error in development mode.
This error commonly occurs when you’ve added template expressions or begun to implement lifecycle hooks like `ngAfterViewInit` or `ngOnChanges`. It is also common when dealing with loading status and asynchronous operations, or a child component changes its parent bindings.
In development mode, Angular performs an additional check after each change detection run, to ensure the bindings haven't changed.
This catches errors where the view is left in an inconsistent state.
This can occur, for example, if a method or getter returns a different value each time it is called, or if a child component changes values on its parent.
If either of these occur, this is a sign that change detection is not stabilized
Angular throws the error to ensure data is always reflected correctly in the view, which prevents erratic UI behavior or a possible infinite loop.
This error commonly occurs when you've added template expressions or have begun to implement lifecycle hooks like `ngAfterViewInit` or `ngOnChanges`.
It is also common when dealing with loading status and asynchronous operations, or when a child component changes its parent bindings.
@debugging
The [source maps](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map) generated by the CLI are very useful when debugging. Navigate up the call stack until you find a template expression where the value displayed in the error has changed.
Ensure that there are no changes to the bindings in the template after change detection is run. This often means refactoring to use the correct [component lifecycle hook](guide/lifecycle-hooks) for your use case. If the issue exists within `ngAfterViewInit`, the recommended solution is to use a constructor or `ngOnInit` to set initial values, or use `ngAfterContentInit` for other value bindings.
The [source maps](https://developer.mozilla.org/docs/Tools/Debugger/How_to/Use_a_source_map) generated by the CLI are very useful when debugging.
Navigate up the call stack until you find a template expression where the value displayed in the error has changed.
Ensure that there are no changes to the bindings in the template after change detection is run.
This often means refactoring to use the correct [component lifecycle hook](guide/lifecycle-hooks) for your use case.
If the issue exists within `ngAfterViewInit`, the recommended solution is to use a constructor or `ngOnInit` to set initial values, or use `ngAfterContentInit` for other value bindings.
If you are binding to methods in the view, ensure that the invocation does not update any of the other bindings in the template.
Read more about which solution is right for you in ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://indepth.dev/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) and why this is useful at ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging/).
Read more about which solution is right for you in ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://indepth.dev/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) and why this is useful at ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging).
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+17 -3
View File
@@ -4,9 +4,23 @@
@shortDescription Circular dependency in DI detected while instantiating a provider
@description
A cyclic dependency exists when a [dependency of a service](guide/hierarchical-dependency-injection) directly or indirectly depends on the service itself. For example, if `UserService` depends on `EmployeeService`, which also depends on `UserService`. Angular will have to instantiate `EmployeeService` to create `UserService`, which depends on `UserService`, itself.
A cyclic dependency exists when a [dependency of a service](guide/hierarchical-dependency-injection) directly or indirectly depends on the service itself.
For example, if `UserService` depends on `EmployeeService`, which also depends on `UserService`.
Angular will have to instantiate `EmployeeService` to create `UserService`, which depends on `UserService`, itself.
@debugging
Use the call stack to determine where the cyclical dependency exists. You will be able to see if any child dependencies rely on the original file by [mapping out](guide/dependency-injection-in-action) the component, module, or service’s dependencies and identify the loop causing the problem.
Break this loop (or circle) of dependency to resolve this error. This most commonly means removing or refactoring the dependencies to not be reliant on one another.
Use the call stack to determine where the cyclical dependency exists.
You will be able to see if any child dependencies rely on the original file by [mapping out](guide/dependency-injection-in-action) the component, module, or service's dependencies, and identifying the loop causing the problem.
Break this loop \(or circle\) of dependency to resolve this error.
This most commonly means removing or refactoring the dependencies to not be reliant on one another.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+17 -4
View File
@@ -4,17 +4,30 @@
@shortDescription No provider for {token} found!
@description
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping that supplies a value that you can inject into the constructor of a class in your application.
Read more on providers in our [Dependency Injection guide](guide/dependency-injection).
@debugging
Work backwards from the object where the error states that a [provider](guide/architecture-services) is missing: `No provider for ${this}!`. This is commonly thrown in [services](tutorial/toh-pt4), which require non-existing providers.
Work backwards from the object where the error states that a [provider](guide/architecture-services) is missing: `No provider for ${this}!`.
This is commonly thrown in [services](tutorial/toh-pt4), which require non-existing providers.
To fix the error ensure that your service is registered in the list of providers of an `NgModule` or has the `@Injectable` decorator with a `providedIn` property at top.
The most common solution is to add a provider in `@Injectable` using `providedIn`:
```typescript
@Injectable({ providedIn: 'app' })
```
<code-example format="typescript" language="typescript">
&commat;Injectable({ providedIn: 'app' })
</code-example>
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+16 -6
View File
@@ -7,15 +7,25 @@
Two or more components use the same [element selector](guide/component-overview#specifying-a-components-css-selector). Because there can only be a single component associated with an element, selectors must be unique strings to prevent ambiguity for Angular.
@debugging
Use the element name from the error message to search for places where you’re using the same [selector declaration](guide/architecture-components) in your codebase:
Use the element name from the error message to search for places where you're using the same [selector declaration](guide/architecture-components) in your codebase:
```typescript
@Component({
<code-example format="typescript" language="typescript">
&commat;Component({
selector: 'YOUR_STRING',
...
&hellip;
})
```
</code-example>
Ensure that each component has a unique CSS selector. This will guarantee that Angular renders the component you expect.
If you’re having trouble finding multiple components with this selector tag name, check for components from imported component libraries, such as Angular Material. Make sure you're following the [best practices](guide/styleguide#component-selectors) for your selectors to prevent collisions.
If you're having trouble finding multiple components with this selector tag name, check for components from imported component libraries, such as Angular Material. Make sure you're following the [best practices](guide/styleguide#component-selectors) for your selectors to prevent collisions.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+21 -8
View File
@@ -4,7 +4,10 @@
@shortDescription Export not found!
@description
Angular can’t find a directive with `{{ PLACEHOLDER }}` export name. The export name is specified in the `exportAs` property of the directive decorator. This is common when using FormsModule or Material modules in templates, and you’ve forgotten to [import the corresponding modules](guide/sharing-ngmodules).
Angular can't find a directive with `{{ PLACEHOLDER }}` export name.
The export name is specified in the `exportAs` property of the directive decorator.
This is common when using FormsModule or Material modules in templates and you've forgotten to [import the corresponding modules](guide/sharing-ngmodules).
<div class="alert is-helpful">
@@ -13,20 +16,30 @@ This is the runtime equivalent of a common compiler error [NG8003: No directive
</div>
@debugging
Use the export name to trace the templates or modules using this export.
Ensure that all dependencies are [properly imported and declared in your NgModules](guide/sharing-ngmodules). For example, if the export not found is `ngForm`, we need to import `FormsModule` and declare it in the list of imports in `*.module.ts` to resolve the error.
Ensure that all dependencies are [properly imported and declared in your NgModules](guide/sharing-ngmodules).
For example, if the export not found is `ngForm`, we need to import `FormsModule` and declare it in the list of imports in `*.module.ts` to resolve the error.
```typescript
import { FormsModule } from '@angular/forms';
<code-example format="typescript" language="typescript">
@NgModule({
...
import { FormsModule } from '&commat;angular/forms';
&commat;NgModule({
&hellip;
imports: [
FormsModule,
…
```
&hellip;
</code-example>
If you recently added an import, you may need to restart your server to see these changes.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+15 -4
View File
@@ -4,15 +4,26 @@
@shortDescription Pipe not found!
@description
Angular can't find a pipe with this name.
The pipe referenced in the template has not been named or declared properly.
Angular can't find a pipe with this name.
The pipe referenced in the template has not been named or declared properly.
A [pipe](guide/pipes) must be either declared or imported in the `NgModule` where it is used, and the name used in a template must match the name defined in the pipe decorator.
@debugging
Use the pipe name to trace the templates or modules where this pipe is declared and used.
To resolve this error, ensure that:
- A local custom pipe is uniquely named in the pipe's decorator, and declared in the `NgModule`, or
- A pipe from another `NgModule` is added to the imports of the `NgModule` where it is used.
* A local custom pipe is uniquely named in the pipe's decorator, and declared in the `NgModule`, or
* A pipe from another `NgModule` is added to the imports of the `NgModule` where it is used
If you recently added an import or declaration, you may need to restart your server to see these changes.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+23 -8
View File
@@ -3,27 +3,42 @@
@shortDescription Decorator argument is not an object literal
@description
To make the metadata extraction in the Angular compiler faster, the decorators `@NgModule`, `@Pipe`, `@Component`, `@Directive`, and `@Injectable` accept only object literals as arguments.
This is an [intentional change in Ivy](https://github.com/angular/angular/issues/30840#issuecomment-498869540), which enforces stricter argument requirements for decorators than View Engine. Ivy requires this approach because it compiles decorators by moving the expressions into other locations in the class output.
This is an [intentional change in Ivy](https://github.com/angular/angular/issues/30840#issuecomment-498869540), which enforces stricter argument requirements for decorators than View Engine.
Ivy requires this approach because it compiles decorators by moving the expressions into other locations in the class output.
@debugging
Move all declarations:
```typescript
const moduleDefinition = {...}
<code-example format="typescript" language="typescript">
@NgModule(moduleDefinition)
const moduleDefinition = {&hellip;}
&commat;NgModule(moduleDefinition)
export class AppModule {
constructor() {}
}
```
</code-example>
into the decorator:
```typescript
@NgModule({...})
<code-example format="typescript" language="typescript">
&commat;NgModule({&hellip;})
export class AppModule {
constructor() {}
}
```
</code-example>
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+14 -2
View File
@@ -3,9 +3,21 @@
@shortDescription No suitable injection token for parameter
@description
There is no injection token for a constructor parameter at compile time. [InjectionTokens](api/core/InjectionToken) are tokens that can be used in a Dependency Injection Provider.
@debugging
Look at the parameter that throws the error and all uses of the class. This error is commonly thrown when a constructor defines parameters with primitive types like `string`, `number`, `boolean`, and `Object`.
Use the `@Injectable` method or `@Inject` decorator from `@angular/core` to ensure that the type you are injecting is reified (has a runtime representation). Make sure to add a provider to this decorator so that you do not throw [NG0201: No Provider Found](errors/NG0201).
Look at the parameter that throws the error, and all uses of the class.
This error is commonly thrown when a constructor defines parameters with primitive types such as `string`, `number`, `boolean`, and `Object`.
Use the `@Injectable` method or `@Inject` decorator from `@angular/core` to ensure that the type you are injecting is reified \(has a runtime representation\).
Make sure to add a provider to this decorator so that you do not throw [NG0201: No Provider Found](errors/NG0201).
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+20 -11
View File
@@ -3,30 +3,39 @@
@shortDescription Component selector does not match shadow DOM requirements
@description
The selector of a component using `ViewEncapsulation.ShadowDom` doesn't match the custom element tag name requirements.
In order for a tag name to be considered a valid custom element name, it has to:
* Be in lower case.
* Contain a hyphen.
* Start with a letter (a-z).
* Be in lower case.
* Contain a hyphen.
* Start with a letter \(a-z\).
@debugging
Rename your component's selector so that it matches the requirements.
**Before:**
```typescript
@Component({
<code-example format="typescript" language="typescript">
&commat;Component({
selector: 'comp',
encapsulation: ViewEncapsulation.ShadowDom
...
&hellip;
})
```
</code-example>
**After:**
```typescript
@Component({
<code-example format="typescript" language="typescript">
&commat;Component({
selector: 'app-comp',
encapsulation: ViewEncapsulation.ShadowDom
...
&hellip;
})
```
</code-example>
+37 -32
View File
@@ -4,54 +4,59 @@
@description
A component, directive or pipe that is referenced by this component would require the compiler
to add an import that would lead to a cycle of imports. For example, consider a scenario where
a `ParentComponent` references a `ChildComponent` in its template:
A component, directive, or pipe that is referenced by this component would require the compiler to add an import that would lead to a cycle of imports.
For example, consider a scenario where a `ParentComponent` references a `ChildComponent` in its template:
<code-example path="errors/cyclic-imports/parent.component.ts" header="parent.component.ts"></code-example>
<code-example header="parent.component.ts" path="errors/cyclic-imports/parent.component.ts"></code-example>
<code-example path="errors/cyclic-imports/child.component.ts" header="child.component.ts"></code-example>
<code-example header="child.component.ts" path="errors/cyclic-imports/child.component.ts"></code-example>
There is already an import from `child.component.ts` to `parent.component.ts` since the `ChildComponent`
references the `ParentComponent` in its constructor.
There is already an import from `child.component.ts` to `parent.component.ts` since the `ChildComponent` references the `ParentComponent` in its constructor.
But note that the parent component's template contains `<child></child>`. The generated code for this
template must therefore contain a reference to the `ChildComponent` class. In order to make this reference
the compiler would have to add an import from `parent.component.ts` to `child.component.ts`, which would
cause an import cycle:
<div class="alert is-helpful">
```
parent.component.ts -> child.component.ts -> parent.component.ts
```
**NOTE**: <br />
The parent component's template contains `<child></child>`.
The generated code for this template must therefore contain a reference to the `ChildComponent` class.
In order to make this reference, the compiler would have to add an import from `parent.component.ts` to `child.component.ts`, which would cause an import cycle:
<code-example format="none" language="none">
parent.component.ts -&gt; child.component.ts -&gt; parent.component.ts
</code-example>
</div>
### Remote Scoping
To avoid adding imports that create cycles, additional code is added to the `NgModule` class where
the component is declared that wires up the dependencies. This is known as "remote scoping".
To avoid adding imports that create cycles, additional code is added to the `NgModule` class where the component that wires up the dependencies is declared.
This is known as "remote scoping".
### Libraries
Unfortunately, "remote scoping" code is side-effectful, which prevents tree shaking, and cannot
be used in libraries. So when building libraries using the `"compilationMode": "partial"` setting,
any component that would require a cyclic import will cause this `NG3003` compiler error to be raised.
Unfortunately, "remote scoping" code is side-effectful &mdash;which prevents tree shaking&mdash; and cannot be used in libraries.
So when building libraries using the `"compilationMode": "partial"` setting, any component that would require a cyclic import will cause this `NG3003` compiler error to be raised.
@debugging
The cycle that would be generated is shown as part of the error message. For example:
The cycle that would be generated is shown as part of the error message.
For example:
<code-example hideCopy="true">
<span class="nocode">The component ChildComponent is used in the template but importing it would create a cycle:
/parent.component.ts -> /child.component.ts -> /parent.component.ts</span>
The component ChildComponent is used in the template but importing it would create a cycle:
/parent.component.ts -&gt; /child.component.ts -&gt; /parent.component.ts
</code-example>
Use this to identify how the referenced component, pipe or directive has a dependency back to the
component being compiled. Here are some ideas for fixing the problem:
Use this to identify how the referenced component, pipe, or directive has a dependency back to the component being compiled.
Here are some ideas for fixing the problem:
* Try to re-arrange your dependencies to avoid the cycle. For example using an intermediate interface
that is stored in an independent file that can be imported to both dependent files without
causing an import cycle.
* Move the classes that reference each other into the same file, to avoid any imports between them.
* Convert import statements to type-only imports (using `import type` syntax) if the imported declarations
are only used as types, as type-only imports do not contribute to cycles.
* Try to rearrange your dependencies to avoid the cycle.
For example, using an intermediate interface that is stored in an independent file that can be imported to both dependent files without causing an import cycle.
* Move the classes that reference each other into the same file, to avoid any imports between them.
* Convert import statements to type-only imports \(using `import type` syntax\) if the imported declarations are only used as types, as type-only imports do not contribute to cycles.
@reviewed 2022-02-28
+2
View File
@@ -3,9 +3,11 @@
@shortDescription Invalid @NgModule() metadata
@description
This error represents the import or export of an `@NgModule()` that doesn't have valid metadata.
@debugging
The library might have been processed with `ngcc`.
If this is the case, try removing and reinstalling `node_modules`.
This error is likely due to the library being published for Angular Ivy, which cannot be used in this View Engine application.
+13 -2
View File
@@ -3,19 +3,30 @@
@shortDescription Unknown HTML element or component
@description
One or more elements cannot be resolved during compilation because the element is not defined by the HTML spec, or there is no component or directive with such element selector.
<div class="alert is-helpful">
This is the compiler equivalent of a common runtime error `NG0304: '${tagName}' is not a known element: …`.
This is the compiler equivalent of a common runtime error `NG0304: '${tagName}' is not a known element: &hellip;`.
</div>
@debugging
Use the element name in the error to find the file(s) where the element is being used.
Check that the name and selector are correct. If the component is from a different module or import, check that the component is exported from its origin module and imported into the correct `*.modules.ts` file, and declared in the imports list.
Check that the name and selector are correct.
If the component is from a different module or import, check that the component is exported from its origin module and imported into the correct `*.modules.ts` file, and declared in the imports list.
When using custom elements or web components, ensure that you add [`CUSTOM_ELEMENTS_SCHEMA`](api/core/CUSTOM_ELEMENTS_SCHEMA) to the application module.
If this does not resolve the error, check the imported libraries for any recent changes to the exports and properties you are using, and restart your server.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+19 -5
View File
@@ -4,13 +4,27 @@
@shortDescription Unknown attribute or input
@description
An attribute or property cannot be resolved during compilation.
This error arises when attempting to bind to a property that does not exist. Any property binding must correspond to either:
* A native property on the HTML element, or
* An `@Input()` property of a component or directive applied to the element.
This error arises when attempting to bind to a property that does not exist.
Any property binding must correspond to either:
The runtime error for this is `NG0304: '${tagName}' is not a known element: …’`.
* A native property on the HTML element, or
* An `@Input()` property of a component or directive applied to the element.
The runtime error for this is `NG0304: '${tagName}' is not a known element: &hellip;'`.
@debugging
Look at documentation for the specific [binding syntax](guide/binding-syntax) used. This is usually a typo or incorrect import. There may also be a missing direction with property selector ‘name’ or missing input.
Look at documentation for the specific [binding syntax](guide/binding-syntax) used.
This is usually a typo or incorrect import.
There may also be a missing direction with property selector 'name' or missing input.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+21 -8
View File
@@ -4,8 +4,9 @@
@shortDescription No directive found with export
@description
Angular can’t find a directive with `{{ PLACEHOLDER }}` export name. This is common with a missing import or a missing [`exportAs`](api/core/Directive#exportAs) on a directive.
Angular can't find a directive with `{{ PLACEHOLDER }}` export name.
This is common with a missing import or a missing [`exportAs`](api/core/Directive#exportAs) on a directive.
<div class="alert is-helpful">
@@ -14,18 +15,30 @@ This is the compiler equivalent of a common runtime error [NG0301: Export Not Fo
</div>
@debugging
Use the string name of the export not found to trace the templates or modules using this export.
Ensure that all dependencies are properly imported and declared in our Modules. For example, if the export not found is `ngForm`, we will need to import `FormsModule` and declare it in our list of imports in `*.module.ts` to resolve the missing export error.
Ensure that all dependencies are properly imported and declared in our Modules.
For example, if the export not found is `ngForm`, we will need to import `FormsModule` and declare it in our list of imports in `*.module.ts` to resolve the missing export error.
```typescript
import { FormsModule } from '@angular/forms';
<code-example format="typescript" language="typescript">
@NgModule({
...
import { FormsModule } from '&commat;angular/forms';
&commat;NgModule({
&hellip;
imports: [
FormsModule,
…
```
&hellip;
</code-example>
If you recently added an import, you will need to restart your server to see these changes.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28
+4 -4
View File
@@ -13,12 +13,12 @@
"plugin:@angular-eslint/template/recommended"
],
"rules": {
"@angular-eslint/template/accessibility-alt-text": "off", // TODO: Fix the code violating this rule and enable it.
"@angular-eslint/template/accessibility-elements-content": "off", // TODO: Fix the code violating this rule and enable it.
"@angular-eslint/template/accessibility-label-has-associated-control": "off", // TODO: Fix the code violating this rule and enable it.
"@angular-eslint/template/accessibility-alt-text": "error",
"@angular-eslint/template/accessibility-elements-content": "error",
"@angular-eslint/template/accessibility-label-has-associated-control": "error",
"@angular-eslint/template/accessibility-table-scope": "error",
"@angular-eslint/template/accessibility-valid-aria": "error",
"@angular-eslint/template/click-events-have-key-events": "off", // TODO: Fix the code violating this rule and enable it.
"@angular-eslint/template/click-events-have-key-events": "error",
"@angular-eslint/template/eqeqeq": "off",
"@angular-eslint/template/mouse-events-have-key-events": "error",
"@angular-eslint/template/no-autofocus": "error",
@@ -38,11 +38,11 @@
<p></p>
<div>
<!-- #docregion event-binding -->
<button (click)="toggleImage()">
<button type="button" (click)="toggleImage()">
<!-- #enddocregion event-binding -->
Image Toggle #1</button>
<!-- #docregion event-binding -->
<button (click)="toggleImage($event)">
<button type="button" (click)="toggleImage($event)">
<!-- #enddocregion event-binding -->
Image Toggle #2</button>
<p>Image toggle event type was {{eventType}}</p>
@@ -51,7 +51,7 @@
<p></p>
<div *ngIf="showImage">
<!-- #docregion src -->
<img [src]="movie.imageurl">
<img [src]="movie.imageurl" [alt]="movie.title">
<!-- #enddocregion src -->
</div>
@@ -39,7 +39,7 @@
<thead>
<tr>
<th>
<button (click)="toggleImage()">
<button type="button" (click)="toggleImage()">
{{showImage ? "Hide" : "Show"}} Poster
</button>
</th>
@@ -61,6 +61,7 @@
[style.height.px]="50"
[style.margin.px]="2"
[src]="movie.imageurl"
[alt]="movie.title"
[title]="movie.title">
</td>
<td>{{movie.title}}</td>
@@ -8,8 +8,11 @@ import * as auto from './auto.po';
import * as filterStagger from './filter-stagger.po';
import * as heroGroups from './hero-groups';
import { getLinkById, sleepFor } from './util';
import { getComponentSection, getToggleButton } from './querying.po';
describe('Animation Tests', () => {
const routingAnimationDuration = 350;
const openCloseHref = getLinkById('open-close');
const statusSliderHref = getLinkById('status');
const toggleHref = getLinkById('toggle');
@@ -17,6 +20,9 @@ describe('Animation Tests', () => {
const autoHref = getLinkById('auto');
const filterHref = getLinkById('heroes');
const heroGroupsHref = getLinkById('hero-groups');
const queryingHref = getLinkById('querying');
const newPageSleepFor = (ms = 0) => sleepFor(ms + routingAnimationDuration);
beforeAll(() => browser.get(''));
@@ -26,7 +32,7 @@ describe('Animation Tests', () => {
beforeAll(async () => {
await openCloseHref.click();
await sleepFor();
await newPageSleepFor(300);
});
it('should be open', async () => {
@@ -82,7 +88,7 @@ describe('Animation Tests', () => {
beforeAll(async () => {
await statusSliderHref.click();
await sleepFor(2000);
await newPageSleepFor(2000);
});
it('should be inactive with a blue background', async () => {
@@ -123,7 +129,7 @@ describe('Animation Tests', () => {
describe('Toggle Animations Component', () => {
beforeAll(async () => {
await toggleHref.click();
await sleepFor();
await newPageSleepFor();
});
it('should disabled animations on the child element', async () => {
@@ -141,7 +147,7 @@ describe('Animation Tests', () => {
describe('Enter/Leave Component', () => {
beforeAll(async () => {
await enterLeaveHref.click();
await sleepFor(100);
await newPageSleepFor(100);
});
it('should attach a flyInOut trigger to the list of items', async () => {
@@ -167,7 +173,7 @@ describe('Animation Tests', () => {
describe('Auto Calculation Component', () => {
beforeAll(async () => {
await autoHref.click();
await sleepFor(0);
await newPageSleepFor();
});
it('should attach a shrinkOut trigger to the list of items', async () => {
@@ -191,7 +197,7 @@ describe('Animation Tests', () => {
describe('Filter/Stagger Component', () => {
beforeAll(async () => {
await filterHref.click();
await sleepFor();
await newPageSleepFor();
});
it('should attach a filterAnimations trigger to the list container', async () => {
@@ -218,7 +224,7 @@ describe('Animation Tests', () => {
describe('Hero Groups Component', () => {
beforeAll(async () => {
await heroGroupsHref.click();
await sleepFor(300);
await newPageSleepFor(400);
});
it('should attach a flyInOut trigger to the list of items', async () => {
@@ -242,4 +248,49 @@ describe('Animation Tests', () => {
await browser.wait(async () => await heroesList.count() < total, 2000);
});
});
describe('Querying Component', () => {
const queryingAnimationDuration = 2500;
beforeAll(async () => {
await queryingHref.click();
await newPageSleepFor(queryingAnimationDuration);
});
it('should toggle the section', async () => {
const toggleButton = getToggleButton();
const section = getComponentSection();
expect(await section.isPresent()).toBe(true);
// toggling off
await toggleButton.click();
await newPageSleepFor(queryingAnimationDuration);
expect(await section.isPresent()).toBe(false);
// toggling on
await toggleButton.click();
await newPageSleepFor(queryingAnimationDuration);
expect(await section.isPresent()).toBe(true);
await newPageSleepFor(queryingAnimationDuration);
});
it(`should disable the button for the animation's duration`, async () => {
const toggleButton = getToggleButton();
expect(await toggleButton.isEnabled()).toBe(true);
// toggling off
await toggleButton.click();
expect(await toggleButton.isEnabled()).toBe(false);
await newPageSleepFor(queryingAnimationDuration);
expect(await toggleButton.isEnabled()).toBe(true);
// toggling on
await toggleButton.click();
expect(await toggleButton.isEnabled()).toBe(false);
await newPageSleepFor(queryingAnimationDuration);
expect(await toggleButton.isEnabled()).toBe(true);
});
});
});
@@ -0,0 +1,16 @@
import { by } from 'protractor';
import { locate } from './util';
export function getComponent() {
return by.css('app-querying');
}
export function getToggleButton() {
const toggleButton = () => by.className('toggle');
return locate(getComponent(), toggleButton());
}
export function getComponentSection() {
const findSection = () => by.css('section');
return locate(getComponent(), findSection());
}
@@ -39,11 +39,10 @@ export const slideInAnimation =
]),
query(':enter', [
animate('300ms ease-out', style({ left: '0%' }))
])
]),
]),
query(':enter', animateChild()),
]),
transition('* <=> FilterPage', [
transition('* <=> *', [
style({ position: 'relative' }),
query(':enter, :leave', [
style({
@@ -59,13 +58,13 @@ export const slideInAnimation =
query(':leave', animateChild()),
group([
query(':leave', [
animate('200ms ease-out', style({ left: '100%' }))
animate('200ms ease-out', style({ left: '100%', opacity: 0 }))
]),
query(':enter', [
animate('300ms ease-out', style({ left: '0%' }))
])
]),
query('@*', animateChild())
]),
query(':enter', animateChild()),
])
// #enddocregion query
]);
@@ -1,3 +1,15 @@
nav a {
padding: .7rem;
}
h1 {
margin-bottom: .3rem;
}
form {
margin-bottom: 2rem;
}
nav {
padding-bottom: 3rem;
}
@@ -17,11 +17,11 @@
<a id="heroes" routerLink="/heroes" routerLinkActive="active">Filter/Stagger</a>
<a id="hero-groups" routerLink="/hero-groups" routerLinkActive="active">Hero Groups</a>
<a id="insert-remove" routerLink="/insert-remove" routerLinkActive="active">Insert/Remove</a>
<a id="querying" routerLink="/querying" routerLinkActive="active">Querying</a>
</nav>
<!-- #docregion route-animations-outlet -->
<div [@routeAnimations]="prepareRoute(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
<div [@routeAnimations]="getRouteAnimationData()">
<router-outlet></router-outlet>
</div>
<!-- #enddocregion route-animations-outlet -->
@@ -11,7 +11,7 @@ import {
} from '@angular/animations';
// #enddocregion imports
import { RouterOutlet } from '@angular/router';
import { ChildrenOutletContexts, RouterOutlet } from '@angular/router';
import { slideInAnimation } from './animations';
// #docregion decorator, toggle-app-animations, define
@@ -34,12 +34,13 @@ export class AppComponent {
public animationsDisabled = false;
// #enddocregion toggle-app-animations
// #docregion prepare-router-outlet
prepareRoute(outlet: RouterOutlet) {
return outlet?.activatedRouteData?.['animation'];
}
// #docregion get-route-animations-data
constructor(private contexts: ChildrenOutletContexts) {}
// #enddocregion prepare-router-outlet
getRouteAnimationData() {
return this.contexts.getContext('primary')?.route?.snapshot?.data?.['animation'];
}
// #enddocregion get-route-animations-data
toggleAnimations() {
this.animationsDisabled = !this.animationsDisabled;
@@ -20,6 +20,7 @@ import { HeroListAutoComponent } from './hero-list-auto.component';
import { HomeComponent } from './home.component';
import { AboutComponent } from './about.component';
import { InsertRemoveComponent } from './insert-remove.component';
import { QueryingComponent } from './querying.component';
@NgModule({
@@ -28,17 +29,61 @@ import { InsertRemoveComponent } from './insert-remove.component';
BrowserAnimationsModule,
RouterModule.forRoot([
{ path: '', pathMatch: 'full', redirectTo: '/enter-leave' },
{ path: 'open-close', component: OpenClosePageComponent },
{ path: 'status', component: StatusSliderPageComponent },
{ path: 'toggle', component: ToggleAnimationsPageComponent },
{ path: 'heroes', component: HeroListPageComponent,
data: { animation: 'FilterPage' } },
{ path: 'hero-groups', component: HeroListGroupPageComponent },
{ path: 'enter-leave', component: HeroListEnterLeavePageComponent },
{ path: 'auto', component: HeroListAutoCalcPageComponent },
{ path: 'insert-remove', component: InsertRemoveComponent},
{ path: 'home', component: HomeComponent, data: { animation: 'HomePage' } },
{ path: 'about', component: AboutComponent, data: { animation: 'AboutPage' } },
{
path: 'open-close',
component: OpenClosePageComponent,
data: { animation: 'openClosePage' }
},
{
path: 'status',
component: StatusSliderPageComponent,
data: { animation: 'statusPage' }
},
{
path: 'toggle',
component: ToggleAnimationsPageComponent,
data: { animation: 'togglePage' }
},
{
path: 'heroes',
component: HeroListPageComponent,
data: { animation: 'filterPage' }
},
{
path: 'hero-groups',
component: HeroListGroupPageComponent,
data: { animation: 'heroGroupPage' }
},
{
path: 'enter-leave',
component: HeroListEnterLeavePageComponent,
data: { animation: 'enterLeavePage' }
},
{
path: 'auto',
component: HeroListAutoCalcPageComponent,
data: { animation: 'autoPage' }
},
{
path: 'insert-remove',
component: InsertRemoveComponent,
data: { animation: 'insertRemovePage' }
},
{
path: 'querying',
component: QueryingComponent,
data: { animation: 'queryingPage' }
},
{
path: 'home',
component: HomeComponent,
data: { animation: 'HomePage' }
},
{
path: 'about',
component: AboutComponent,
data: { animation: 'AboutPage' }
},
])
],
// #enddocregion route-animation-data
@@ -59,6 +104,7 @@ import { InsertRemoveComponent } from './insert-remove.component';
HeroListAutoComponent,
HomeComponent,
InsertRemoveComponent,
QueryingComponent,
AboutComponent
],
bootstrap: [AppComponent]
@@ -1,9 +1,9 @@
<ul class="heroes">
<li *ngFor="let hero of heroes"
[@shrinkOut]="'in'" (click)="removeHero(hero.id)">
<div class="inner">
[@shrinkOut]="'in'">
<button class="inner" type="button" (click)="removeHero(hero.id)">
<span class="badge">{{ hero.id }}</span>
<span>{{ hero.name }}</span>
</div>
<span class="name">{{ hero.name }}</span>
</button>
</li>
</ul>
</ul>
@@ -19,11 +19,11 @@ import { Hero } from './hero';
template: `
<ul class="heroes">
<li *ngFor="let hero of heroes"
[@flyInOut]="'in'" (click)="removeHero(hero.id)">
<div class="inner">
[@flyInOut]="'in'">
<button class="inner" type="button" (click)="removeHero(hero.id)">
<span class="badge">{{ hero.id }}</span>
<span>{{ hero.name }}</span>
</div>
<span class="name">{{ hero.name }}</span>
</button>
</li>
</ul>
`,
@@ -19,12 +19,11 @@ import { Hero } from './hero';
selector: 'app-hero-list-groups',
template: `
<ul class="heroes">
<li *ngFor="let hero of heroes"
[@flyInOut]="'in'" (click)="removeHero(hero.id)">
<div class="inner">
<li *ngFor="let hero of heroes" [@flyInOut]="'in'">
<button class="inner" type="button" (click)="removeHero(hero.id)">
<span class="badge">{{ hero.id }}</span>
<span>{{ hero.name }}</span>
</div>
<span class="name">{{ hero.name }}</span>
</button>
</li>
</ul>
`,
@@ -33,7 +32,7 @@ import { Hero } from './hero';
animations: [
trigger('flyInOut', [
state('in', style({
width: 120,
width: '*',
transform: 'translateX(0)', opacity: 1
})),
transition(':enter', [
@@ -41,7 +40,7 @@ import { Hero } from './hero';
group([
animate('0.3s 0.1s ease', style({
transform: 'translateX(0)',
width: 120
width: '*'
})),
animate('0.3s ease', style({
opacity: 1
@@ -1,25 +1,56 @@
.heroes {
margin: 0 0 2em 0;
list-style-type: none;
padding: 0;
width: 15em;
}
.heroes li {
overflow:hidden;
margin: .5em 0;
display: flex;
align-items: center;
width: 100%;
overflow: hidden;
}
.heroes li > .inner {
cursor: pointer;
.heroes .inner {
flex: 1;
background-color: #EEE;
padding: .3rem 0;
height: 1.6rem;
margin: .5em;
padding: 0;
border-radius: 4px;
display: flex;
align-items: stretch;
}
.heroes li:hover > .inner {
color: black;
background-color: #DDD;
transform: translateX(.1em);
.heroes button.inner {
cursor: pointer;
font-size: inherit;
}
.heroes button.inner:hover {
color: #2c3a41;
background-color: #e6e6e6;
left: .1em;
}
.heroes button.inner:active {
background-color: #525252;
color: #fafafa;
}
.heroes button.inner.selected {
background-color: black;
color: white;
}
.heroes button.inner.selected:hover {
background-color: #505050;
color: white;
}
.heroes button.inner.selected:active {
background-color: black;
color: white;
}
.heroes .badge {
@@ -27,17 +58,17 @@
font-size: small;
color: white;
padding: 0.8em 0.7em 0 0.7em;
background-color: #3d5157;
position: relative;
left: -1px;
top: -4px;
height: 1.8em;
min-width: 16px;
text-align: right;
background-color: #405061;
line-height: 1em;
margin-right: .8em;
border-radius: 4px 0 0 4px;
}
.heroes .name {
min-width: max-content;
padding: 0.5rem 0;
}
label {
display: block;
padding-bottom: .5rem;
@@ -11,7 +11,7 @@
<li *ngFor="let hero of heroes" class="hero">
<div class="inner">
<span class="badge">{{ hero.id }}</span>
<span>{{ hero.name }}</span>
<span class="name">{{ hero.name }}</span>
</div>
</li>
</ul>
@@ -3,7 +3,7 @@
<h2>Insert/Remove</h2>
<nav>
<button (click)="toggle()">Toggle Insert/Remove</button>
<button type="button" (click)="toggle()">Toggle Insert/Remove</button>
</nav>
<!-- #docregion insert-remove-->
@@ -2,14 +2,13 @@
import { Hero } from './hero';
export const HEROES: Hero[] = [
{ id: 11, name: 'Dr Nice' },
{ id: 12, name: 'Narco' },
{ id: 12, name: 'Dr. Nice' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
{ id: 15, name: 'Magneta' },
{ id: 16, name: 'RubberMan' },
{ id: 17, name: 'Dynama' },
{ id: 18, name: 'Dr IQ' },
{ id: 18, name: 'Dr. IQ' },
{ id: 19, name: 'Magma' },
{ id: 20, name: 'Tornado' }
];
@@ -1,7 +1,7 @@
<!-- #docplaster -->
<!-- #docregion trigger -->
<nav>
<button (click)="toggle()">Toggle Open/Close</button>
<button type="button" (click)="toggle()">Toggle Open/Close</button>
</nav>
<div [@openClose]="isOpen ? 'open' : 'closed'" class="open-close-container">
@@ -1,6 +1,6 @@
<!-- #docplaster -->
<nav>
<button (click)="toggle()">Toggle Boolean/Close</button>
<button type="button" (click)="toggle()">Toggle Boolean/Close</button>
</nav>
<!-- #docregion trigger-boolean -->
@@ -1,6 +1,6 @@
<!-- #docplaster -->
<nav>
<button (click)="toggle()">Toggle Open/Close</button>
<button type="button" (click)="toggle()">Toggle Open/Close</button>
</nav>
<!-- #docregion callbacks -->
@@ -1,6 +1,6 @@
<nav>
<button (click)="toggleAnimations()">Toggle Animations</button>
<button (click)="toggle()">Toggle Open/Closed</button>
<button type="button" (click)="toggleAnimations()">Toggle Animations</button>
<button type="button" (click)="toggle()">Toggle Open/Closed</button>
</nav>
<!-- #docregion toggle-animation -->
<div [@.disabled]="isDisabled">
@@ -1,4 +1,4 @@
<button (click)="toggle()">Toggle Open/Close</button>
<button type="button" (click)="toggle()">Toggle Open/Close</button>
<div [@openClose]="isOpen ? 'open' : 'closed'"
(@openClose.start)="onAnimationEvent($event)"
@@ -0,0 +1,31 @@
section {
border: 1px solid black;
overflow: hidden;
}
section > * {
margin: 1rem;
}
.hero {
display: flex;
align-items: center;
border-radius: 4px;
color: black;
background-color: #DDD;
}
.hero .badge {
display: inline-block;
font-size: small;
color: white;
padding: 0.5rem;
background-color: #3d5157;
margin-right: .8em;
border-radius: 4px 0 0 4px;
align-self: stretch;
}
.hero .name {
height: min-content;
}
@@ -0,0 +1,80 @@
import {
Component,
} from '@angular/core';
import {
trigger,
style,
animate,
transition,
group,
query,
animateChild,
keyframes
} from '@angular/animations';
import { HEROES } from './mock-heroes';
@Component({
selector: 'app-querying',
template: `
<nav>
<button class="toggle" (click)="show = !show" [disabled]="toggleDisabled">Toggle View</button>
</nav>
<section *ngIf="show" @query (@query.start)="toggleDisabled = true" (@query.done)="toggleDisabled = false">
<p>I am a simple child element</p>
<p *ngIf="show">I am a child element that enters and leaves with its parent</p>
<p @animateMe>I am a child element with an animation trigger</p>
<div class="hero">
<span class="badge">{{ hero.id }}</span>
<span class="name">{{ hero.name }} <small>(heroes are always animated!)</small></span>
</div>
</section>
`,
styleUrls: ['./querying.component.css'],
animations: [
trigger('query', [
transition(':enter', [
style({ height: 0 }),
group([
animate(500, style({ height: '*' })),
query(':enter', [
style({ opacity: 0, transform: 'scale(0)'}),
animate(2000, style({ opacity: 1, transform: 'scale(1)' }))
]),
query('.hero', [
style({ transform: 'translateX(-100%)'}),
animate('.7s 500ms ease-in', style({ transform: 'translateX(0)' }))
]),
]),
query('@animateMe', animateChild()),
]),
transition(':leave', [
style({ height: '*' }),
query('@animateMe', animateChild()),
group([
animate('500ms 500ms', style({ height: '0', padding: '0' })),
query(':leave', [
style({ opacity: 1, transform: 'scale(1)'}),
animate('1s', style({ opacity: 0, transform: 'scale(0)' }))
]),
query('.hero', [
style({ transform: 'translateX(0)'}),
animate('.7s ease-out', style({ transform: 'translateX(-100%)' }))
]),
]),
]),
]),
trigger('animateMe', [
transition('* <=> *', animate('500ms cubic-bezier(.68,-0.73,.26,1.65)', keyframes([
style({ backgroundColor: "transparent", color: '*', offset: 0 }),
style({ backgroundColor: "blue", color: 'white', offset: 0.2 }),
style({ backgroundColor: "transparent", color: '*', offset: 1 })
])))
]),
]
})
export class QueryingComponent {
toggleDisabled = false;
show = true;
hero = HEROES[0];
}
@@ -1,5 +1,5 @@
<nav>
<button (click)="toggle()">Toggle Status</button>
<button type="button" (click)="toggle()">Toggle Status</button>
</nav>
<div [@slideStatus]="status" class="box">
@@ -1,7 +1,8 @@
<!--#docregion binding -->
<li>{{hero.name}}</li>
<app-hero-detail [hero]="selectedHero"></app-hero-detail>
<li (click)="selectHero(hero)"></li>
<button type="button" (click)="selectHero(hero)">
{{hero.name}}
</button>
<!--#enddocregion binding -->
<!--#docregion structural -->
@@ -3,8 +3,10 @@
<p><em>Select a hero from the list to see details.</em></p>
<ul>
<li *ngFor="let hero of heroes" (click)="selectHero(hero)">
{{hero.name}}
<li *ngFor="let hero of heroes">
<button type="button" (click)="selectHero(hero)">
{{hero.name}}
</button>
</li>
</ul>
@@ -4,13 +4,21 @@ ul {
li {
list-style-type: none;
padding: 1rem;
background-color: aliceblue;
border: 1px solid #444;
margin-bottom: .5rem;
display: flex;
}
li:hover {
li button {
background-color: aliceblue;
flex: 1;
padding: 1rem;
margin: 0;
text-align: left;
border-radius: 0;
}
li button:hover, li button:active {
background-color: #444;
color: white;
cursor: pointer;
@@ -21,7 +21,7 @@
<div>
<!-- #docregion attrib-binding-aria -->
<!-- create and set an aria attribute for assistive technology -->
<button [attr.aria-label]="actionName">{{actionName}} with Aria</button>
<button type="button" [attr.aria-label]="actionName">{{actionName}} with Aria</button>
<!-- #enddocregion attrib-binding-aria -->
</div>
@@ -7,7 +7,7 @@
<h2>Button disabled state bound to isUnchanged property</h2>
<!-- #docregion disabled-button -->
<!-- Bind button disabled state to `isUnchanged` property -->
<button [disabled]="isUnchanged">Save</button>
<button type="button" [disabled]="isUnchanged">Save</button>
<!-- #enddocregion disabled-button -->
</div>
@@ -20,11 +20,11 @@
<label>HTML Attribute Initializes to "Sarah":
<input type="text" value="Sarah" #bindingInput></label>
<div>
<button (click)="getHTMLAttributeValue()">Get HTML attribute value</button> Won't change.
<button type="button" (click)="getHTMLAttributeValue()">Get HTML attribute value</button> Won't change.
</div>
<div>
<button (click)="getDOMPropertyValue()">Get DOM property value</button> Changeable. Angular works with these.
<button type="button" (click)="getDOMPropertyValue()">Get DOM property value</button> Changeable. Angular works with these.
</div>
<p>2. Change the name in the input and click the buttons again.</p>
@@ -36,10 +36,10 @@
<h3>Disabled property vs. attribute</h3>
<p>Use the inspector to see the Test Button work and its disabled property toggle.</p>
<div>
<button id="testButton" (click)="working()">Test Button</button>
<button type="button" id="testButton" (click)="working()">Test Button</button>
</div>
<div>
<button (click)="toggleDisabled()">Toggle disabled property for Test Button</button>
<button type="button" (click)="toggleDisabled()">Toggle disabled property for Test Button</button>
</div>
</div>
@@ -50,7 +50,7 @@
<label for="special">special: <input type="checkbox" [(ngModel)]="isSpecial" id="special"></label>
</li>
</ul>
<button (click)="setCurrentClasses()">Refresh currentClasses</button>
<button type="button" (click)="setCurrentClasses()">Refresh currentClasses</button>
<div [ngClass]="currentClasses">
This div should be {{ canSave ? "": "not"}} saveable,
@@ -86,7 +86,7 @@
<label>italic: <input type="checkbox" [(ngModel)]="canSave"></label> |
<label>normal: <input type="checkbox" [(ngModel)]="isUnchanged"></label> |
<label>xlarge: <input type="checkbox" [(ngModel)]="isSpecial"></label>
<button (click)="setCurrentStyles()">Refresh currentStyles</button>
<button type="button" (click)="setCurrentStyles()">Refresh currentStyles</button>
<br><br>
<div [ngStyle]="currentStyles">
This div should be {{ canSave ? "italic": "plain"}},
@@ -102,7 +102,7 @@
<app-item-detail *ngIf="isActive" [item]="item"></app-item-detail>
<!-- #enddocregion NgIf-1 -->
<button (click)="isActiveToggle()">Toggle app-item-detail</button>
<button type="button" (click)="isActiveToggle()">Toggle app-item-detail</button>
</div>
<p>If currentCustomer isn't null, say hello to Laura:</p>
<!-- #docregion NgIf-2 -->
@@ -112,7 +112,7 @@
<!-- #docregion NgIf-2b -->
<div *ngIf="nullCustomer">Hello, <span>{{nullCustomer}}</span></div>
<!-- #enddocregion NgIf-2b -->
<button (click)="giveNullCustomerValue()">Give nullCustomer a value</button>
<button type="button" (click)="giveNullCustomerValue()">Give nullCustomer a value</button>
<h4>NgIf binding with template (no *)</h4>
@@ -163,9 +163,9 @@
</div>
<h4 id="ngFor-trackBy">*ngFor trackBy</h4>
<button (click)="resetList()">Reset items</button>
<button (click)="changeIds()">Change ids</button>
<button (click)="clearTrackByCounts()">Clear counts</button>
<button type="button" (click)="resetList()">Reset items</button>
<button type="button" (click)="changeIds()">Change ids</button>
<button type="button" (click)="clearTrackByCounts()">Clear counts</button>
<p><i>without</i> trackBy</p>
<div class="box">
@@ -10,6 +10,7 @@ import { Subscription } from 'rxjs';
<p>
{{astronaut}}: <strong>{{mission}}</strong>
<button
type="button"
(click)="confirm()"
[disabled]="!announced || confirmed">
Confirm
@@ -14,8 +14,8 @@ import { CountdownTimerComponent } from './countdown-timer.component';
selector: 'app-countdown-parent-lv',
template: `
<h3>Countdown to Liftoff (via local variable)</h3>
<button (click)="timer.start()">Start</button>
<button (click)="timer.stop()">Stop</button>
<button type="button" (click)="timer.start()">Start</button>
<button type="button" (click)="timer.stop()">Stop</button>
<div class="seconds">{{timer.seconds}}</div>
<app-countdown-timer #timer></app-countdown-timer>
`,
@@ -30,8 +30,8 @@ export class CountdownLocalVarParentComponent { }
selector: 'app-countdown-parent-vc',
template: `
<h3>Countdown to Liftoff (via ViewChild)</h3>
<button (click)="start()">Start</button>
<button (click)="stop()">Stop</button>
<button type="button" (click)="start()">Start</button>
<button type="button" (click)="stop()">Stop</button>
<div class="seconds">{{ seconds() }}</div>
<app-countdown-timer></app-countdown-timer>
`,
@@ -7,7 +7,7 @@ import { MissionService } from './mission.service';
selector: 'app-mission-control',
template: `
<h2>Mission Control</h2>
<button (click)="announce()">Announce mission</button>
<button type="button" (click)="announce()">Announce mission</button>
<app-astronaut
*ngFor="let astronaut of astronauts"

Some files were not shown because too many files have changed in this diff Show More