Datasets:

Modalities:
Text
Formats:
parquet
ArXiv:
Libraries:
Datasets
pandas
License:
Dataset Viewer
Auto-converted to Parquet
_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
angular-cli/CODE_OF_CONDUCT.md_0_3649
# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering a safe and welcoming environment, we as the Angular team pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity, gender expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Use welcoming and inclusive language * Respect each other * Provide and gracefully accept constructive criticism * Show empathy towards other community members Examples of unacceptable behavior by participants include: * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * The use of sexualized language or imagery * Unwelcome sexual attention or advances * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Angular team are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Angular team have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies to all Angular communication channels - online or in person, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Angular team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The Angular team will maintain confidentiality with regard to the reporter of an incident. Enforcement may result in an indefinite ban from all official Angular communication channels, or other actions as deemed appropriate by the Angular team. Angular maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ### Appeal If you are banned you may contest the decision. To do so email [email protected] with the subject line "Repeal Ban for {{your name here}}" and body with the responses to the following: * Why do you believe you did not violate the Code of Conduct? * Were other factors involved in this situation the leadership team may have been unaware of? * Why do you wish to be a part of the Angular community? ## Attribution This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
{ "end_byte": 3649, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/CODE_OF_CONDUCT.md" }
angular-cli/LICENSE_0_1105
The MIT License Copyright (c) 2010-2024 Google LLC. https://angular.dev/license Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{ "end_byte": 1105, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/LICENSE" }
angular-cli/WORKSPACE_0_4925
workspace( name = "angular_cli", managed_directories = {"@npm": ["node_modules"]}, ) load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_skylib", sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", ], ) http_archive( name = "io_bazel_rules_webtesting", sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a", urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz"], ) http_archive( name = "build_bazel_rules_nodejs", sha256 = "5dd1e5dea1322174c57d3ca7b899da381d516220793d0adef3ba03b9d23baa8e", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.3/rules_nodejs-5.8.3.tar.gz"], ) load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") build_bazel_rules_nodejs_dependencies() http_archive( name = "rules_pkg", sha256 = "8c20f74bca25d2d442b327ae26768c02cf3c99e93fad0381f32be9aab1967675", urls = ["https://github.com/bazelbuild/rules_pkg/releases/download/0.8.1/rules_pkg-0.8.1.tar.gz"], ) load("@bazel_tools//tools/sh:sh_configure.bzl", "sh_configure") sh_configure() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") rules_pkg_dependencies() # Setup the Node.js toolchain load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") NODE_18_REPO = { "18.19.1-darwin_arm64": ("node-v18.19.1-darwin-arm64.tar.gz", "node-v18.19.1-darwin-arm64", "0c7249318868877032ed21cc0ed450015ee44b31b9b281955521cd3fc39fbfa3"), "18.19.1-darwin_amd64": ("node-v18.19.1-darwin-x64.tar.gz", "node-v18.19.1-darwin-x64", "ab67c52c0d215d6890197c951e1bd479b6140ab630212b96867395e21d813016"), "18.19.1-linux_arm64": ("node-v18.19.1-linux-arm64.tar.xz", "node-v18.19.1-linux-arm64", "228ad1eee660fba3f9fd2cccf02f05b8ebccc294d27f22c155d20b233a9d76b3"), "18.19.1-linux_ppc64le": ("node-v18.19.1-linux-ppc64le.tar.xz", "node-v18.19.1-linux-ppc64le", "2e5812b8fc00548e2e8ab9daa88ace13974c16b6ba5595a7a50c35f848f7d432"), "18.19.1-linux_s390x": ("node-v18.19.1-linux-s390x.tar.xz", "node-v18.19.1-linux-s390x", "15106acf4c9e3aca02416dd89fb5c71af77097042455a73f9caa064c1988ead5"), "18.19.1-linux_amd64": ("node-v18.19.1-linux-x64.tar.xz", "node-v18.19.1-linux-x64", "f35f24edd4415cd609a2ebc03be03ed2cfe211d7333d55c752d831754fb849f0"), "18.19.1-windows_amd64": ("node-v18.19.1-win-x64.zip", "node-v18.19.1-win-x64", "ff08f8fe253fba9274992d7052e9d9a70141342d7b36ddbd6e84cbe823e312c6"), } nodejs_register_toolchains( name = "node18", # The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701 node_repositories = NODE_18_REPO, node_version = "18.19.1", ) # Set the default nodejs toolchain to the latest supported major version nodejs_register_toolchains( name = "nodejs", # The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701 node_repositories = NODE_18_REPO, node_version = "18.19.1", ) nodejs_register_toolchains( name = "node20", # The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701 node_repositories = { "20.11.1-darwin_arm64": ("node-v20.11.1-darwin-arm64.tar.gz", "node-v20.11.1-darwin-arm64", "e0065c61f340e85106a99c4b54746c5cee09d59b08c5712f67f99e92aa44995d"), "20.11.1-darwin_amd64": ("node-v20.11.1-darwin-x64.tar.gz", "node-v20.11.1-darwin-x64", "c52e7fb0709dbe63a4cbe08ac8af3479188692937a7bd8e776e0eedfa33bb848"), "20.11.1-linux_arm64": ("node-v20.11.1-linux-arm64.tar.xz", "node-v20.11.1-linux-arm64", "c957f29eb4e341903520caf362534f0acd1db7be79c502ae8e283994eed07fe1"), "20.11.1-linux_ppc64le": ("node-v20.11.1-linux-ppc64le.tar.xz", "node-v20.11.1-linux-ppc64le", "51343cacf5cdf5c4b5e93e919d19dd373d6ef43d5f2c666eae299f26e31d08b5"), "20.11.1-linux_s390x": ("node-v20.11.1-linux-s390x.tar.xz", "node-v20.11.1-linux-s390x", "b32616b705cd0ddbb230b95c693e3d7a37becc2ced9bcadea8dc824cceed6be0"), "20.11.1-linux_amd64": ("node-v20.11.1-linux-x64.tar.xz", "node-v20.11.1-linux-x64", "d8dab549b09672b03356aa2257699f3de3b58c96e74eb26a8b495fbdc9cf6fbe"), "20.11.1-windows_amd64": ("node-v20.11.1-win-x64.zip", "node-v20.11.1-win-x64", "bc032628d77d206ffa7f133518a6225a9c5d6d9210ead30d67e294ff37044bda"), }, node_version = "20.11.1", )
{ "end_byte": 4925, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/WORKSPACE" }
angular-cli/WORKSPACE_4927_8300
nodejs_register_toolchains( name = "node22", # The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701 node_repositories = { "22.0.0-darwin_arm64": ("node-v22.0.0-darwin-arm64.tar.gz", "node-v22.0.0-darwin-arm64", "ea96d349cfaa67aa87ceeaa3e5b52c9167f7ac302fd8d1ff162d0785e9dc0785"), "22.0.0-darwin_amd64": ("node-v22.0.0-darwin-x64.tar.gz", "node-v22.0.0-darwin-x64", "422a3887ff5418f0a4552d89cf99346ab8ab51bb5d384660baa88b8444d2c111"), "22.0.0-linux_arm64": ("node-v22.0.0-linux-arm64.tar.xz", "node-v22.0.0-linux-arm64", "83711d29cbe46375bdffab5419f3d831892e24294169272f6c39edc364556241"), "22.0.0-linux_ppc64le": ("node-v22.0.0-linux-ppc64le.tar.xz", "node-v22.0.0-linux-ppc64le", "2b3fb8707a79243bfb3131312b86716ddc3855bce21bb168095b6b916798e5e9"), "22.0.0-linux_s390x": ("node-v22.0.0-linux-s390x.tar.xz", "node-v22.0.0-linux-s390x", "89a8efeeb9f94ce9ea251b8109e079c14919f4c0dc2cbc9f545ec47ef0886737"), "22.0.0-linux_amd64": ("node-v22.0.0-linux-x64.tar.xz", "node-v22.0.0-linux-x64", "9122e50f2642afd5f6078cafd1f52ede60fc464284384f05c18a04d13d07ae5a"), "22.0.0-windows_amd64": ("node-v22.0.0-win-x64.zip", "node-v22.0.0-win-x64", "32d639b47d4c0a651ff8f8d7d41a454168a3d4045be37985f9a810cf8cef6174"), }, node_version = "22.0.0", ) load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") yarn_install( name = "npm", data = [ "//:.yarn/patches/@angular-bazel-https-9848736cf4.patch", "//:.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch", "//:.yarn/patches/@bazel-jasmine-npm-5.8.1-3370fee155.patch", "//:.yarn/releases/yarn-4.5.0.cjs", "//:.yarnrc.yml", ], # Currently disabled due to: # 1. Missing Windows support currently. # 2. Incompatibilites with the `ts_library` rule. exports_directories_only = False, 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-4.5.0.cjs", yarn_lock = "//:yarn.lock", ) http_archive( name = "aspect_bazel_lib", sha256 = "a272d79bb0ac6b6965aa199b1f84333413452e87f043b53eca7f347a23a478e8", strip_prefix = "bazel-lib-2.9.3", url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.9.3/bazel-lib-v2.9.3.tar.gz", ) load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains") aspect_bazel_lib_dependencies() aspect_bazel_lib_register_toolchains() register_toolchains( "@npm//@angular/build-tooling/bazel/git-toolchain:git_linux_toolchain", "@npm//@angular/build-tooling/bazel/git-toolchain:git_macos_x86_toolchain", "@npm//@angular/build-tooling/bazel/git-toolchain:git_macos_arm64_toolchain", "@npm//@angular/build-tooling/bazel/git-toolchain:git_windows_toolchain", ) load("@npm//@angular/build-tooling/bazel/browsers:browser_repositories.bzl", "browser_repositories") browser_repositories() load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") esbuild_repositories( npm_repository = "npm", )
{ "end_byte": 8300, "start_byte": 4927, "url": "https://github.com/angular/angular-cli/blob/main/WORKSPACE" }
angular-cli/README.md_0_3860
<!-- BEFORE UPDATING THIS FILE, READ THIS. This file is automatically generated during release. It is important for you to not update README directly. - If you need to change the content, update `scripts/templates/readme.ejs` - If you need to add/remove a package or a link, update the .monorepo.json file instead. Any changes to README.md directly will result in a failure on CI. --> <h1 style="text-align: center">Angular CLI - The CLI tool for Angular.</h1> <p style="text-align: center"> <br> <img src="/docs/images/angular-cli-logo.png" alt="Angular CLI logo" width="100px" height="108px"/> <br><br> <em>The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, <br>and maintain Angular applications directly from a command shell.</em> <br> </p> <p style="text-align: center"> <a href="https://angular.dev/tools/cli"><strong>angular.dev/tools/cli</strong></a> <br> </p> <p style="text-align: center"> <a href="CONTRIBUTING.md">Contributing Guidelines</a> · <a href="https://github.com/angular/angular-cli/issues">Submit an Issue</a> · <a href="https://blog.angular.dev">Blog</a> <br> <br> </p> <p style="text-align: center"> <a href="https://circleci.com/gh/angular/workflows/angular-cli/tree/main"> <img src="https://img.shields.io/circleci/build/github/angular/angular-cli/main.svg?logo=circleci&logoColor=fff&label=CircleCI" alt="CI status" /> </a>&nbsp; <a href="https://discord.gg/angular"> <img src="https://img.shields.io/discord/463752820026376202.svg?logo=discord&logoColor=fff&label=Discord&color=7389d8" alt="Discord conversation" /> </a> </p> <hr> ## Documentation Get started with Angular CLI, learn the fundamentals and explore advanced topics on our documentation website. - [Getting started][quickstart] - [CLI][cli] - [Workspace and project file structure][filestructure] - [Workspace configuration][workspaceconfig] - [Schematics][schematics] ## Development Setup ### Prerequisites - Install [Node.js] which includes [Node Package Manager][npm] ### Setting Up a Project Install the Angular CLI globally: ``` npm install -g @angular/cli ``` Create workspace: ``` ng new [PROJECT NAME] ``` Run the application: ``` cd [PROJECT NAME] ng serve ``` Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions. ## Quickstart [Get started in 5 minutes][quickstart]. ## Ecosystem <p> <img src="/docs/images/angular-ecosystem-logos.png" alt="angular ecosystem logos" width="500px" height="auto"> </p> - [Angular Framework][adev] - [Angular Material][angularmaterial] ## Changelog [Learn about the latest improvements][changelog]. ## Upgrading Check out our [upgrade guide](https://update.angular.dev/) to find out the best way to upgrade your project. ## Contributing ### Contributing Guidelines Read through our [contributing guidelines][contributing] to learn about our submission process, coding rules and more. ### Want to Help? Want to report a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for [contributing][contributing] and then check out one of our issues labeled as <kbd>[help wanted](https://github.com/angular/angular-cli/labels/help%20wanted)</kbd> or <kbd>[good first issue](https://github.com/angular/angular-cli/labels/good%20first%20issue)</kbd>. ### Code of Conduct Help us keep Angular open and inclusive. Please read and follow our [Code of Conduct][codeofconduct]. ### Developer Guide Read through our [developer guide][developer] to learn about how to build and test the Angular CLI locally. ## Community Join the conversation and help the community. - [Twitter][twitter] - [Discord][discord] - [Gitter][gitter] - [YouTube][youtube] - [StackOverflow][stackoverflow] - Find a Local [Meetup][meetup] ##
{ "end_byte": 3860, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/README.md" }
angular-cli/README.md_3860_10863
Packages This is a monorepo which contains many tools and packages: ### Tools | Project | Package | Version | Links | |---|---|---|---| **Angular Build System** | [`@angular/build`](https://npmjs.com/package/@angular/build) | [![latest](https://img.shields.io/npm/v/%40angular%2Fbuild/latest.svg)](https://npmjs.com/package/@angular/build) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular/build/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-build-builds) **Angular CLI** | [`@angular/cli`](https://npmjs.com/package/@angular/cli) | [![latest](https://img.shields.io/npm/v/%40angular%2Fcli/latest.svg)](https://npmjs.com/package/@angular/cli) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular/cli/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/cli-builds) **Architect CLI** | [`@angular-devkit/architect-cli`](https://npmjs.com/package/@angular-devkit/architect-cli) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Farchitect-cli/latest.svg)](https://npmjs.com/package/@angular-devkit/architect-cli) | [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-architect-cli-builds) **Schematics CLI** | [`@angular-devkit/schematics-cli`](https://npmjs.com/package/@angular-devkit/schematics-cli) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fschematics-cli/latest.svg)](https://npmjs.com/package/@angular-devkit/schematics-cli) | [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-schematics-cli-builds) ### Packages | Project | Package | Version | Links | |---|---|---|---| **Angular SSR** | [`@angular/ssr`](https://npmjs.com/package/@angular/ssr) | [![latest](https://img.shields.io/npm/v/%40angular%2Fssr/latest.svg)](https://npmjs.com/package/@angular/ssr) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular/ssr/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-ssr-builds) **Architect** | [`@angular-devkit/architect`](https://npmjs.com/package/@angular-devkit/architect) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Farchitect/latest.svg)](https://npmjs.com/package/@angular-devkit/architect) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular_devkit/architect/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-architect-builds) **Build Angular** | [`@angular-devkit/build-angular`](https://npmjs.com/package/@angular-devkit/build-angular) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fbuild-angular/latest.svg)](https://npmjs.com/package/@angular-devkit/build-angular) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular_devkit/build_angular/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-build-angular-builds) **Build Webpack** | [`@angular-devkit/build-webpack`](https://npmjs.com/package/@angular-devkit/build-webpack) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fbuild-webpack/latest.svg)](https://npmjs.com/package/@angular-devkit/build-webpack) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular_devkit/build_webpack/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-build-webpack-builds) **Core** | [`@angular-devkit/core`](https://npmjs.com/package/@angular-devkit/core) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fcore/latest.svg)](https://npmjs.com/package/@angular-devkit/core) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular_devkit/core/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-core-builds) **Schematics** | [`@angular-devkit/schematics`](https://npmjs.com/package/@angular-devkit/schematics) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fschematics/latest.svg)](https://npmjs.com/package/@angular-devkit/schematics) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular_devkit/schematics/README.md) [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-schematics-builds) #### Misc | Project | Package | Version | Links | |---|---|---|---| **Angular Create** | [`@angular/create`](https://npmjs.com/package/@angular/create) | [![latest](https://img.shields.io/npm/v/%40angular%2Fcreate/latest.svg)](https://npmjs.com/package/@angular/create) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/angular/create/README.md) **Webpack Angular Plugin** | [`@ngtools/webpack`](https://npmjs.com/package/@ngtools/webpack) | [![latest](https://img.shields.io/npm/v/%40ngtools%2Fwebpack/latest.svg)](https://npmjs.com/package/@ngtools/webpack) | [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/ngtools-webpack-builds) #### Schematics | Project | Package | Version | Links | |---|---|---|---| **Angular PWA Schematics** | [`@angular/pwa`](https://npmjs.com/package/@angular/pwa) | [![latest](https://img.shields.io/npm/v/%40angular%2Fpwa/latest.svg)](https://npmjs.com/package/@angular/pwa) | [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-pwa-builds) **Angular Schematics** | [`@schematics/angular`](https://npmjs.com/package/@schematics/angular) | [![latest](https://img.shields.io/npm/v/%40schematics%2Fangular/latest.svg)](https://npmjs.com/package/@schematics/angular) | [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/schematics-angular-builds) **Love Angular CLI? Give our repo a star :star: :arrow_up:.** [contributing]: CONTRIBUTING.md [developer]: docs/DEVELOPER.md [quickstart]: https://angular.dev/tutorials/learn-angular [changelog]: CHANGELOG.md [documentation]: https://angular.dev/overview [angularmaterial]: https://material.angular.io/ [cli]: https://angular.dev/tools/cli [adev]: https://angular.dev/ [workspaceconfig]: https://angular.dev/reference/configs/workspace-config [schematics]: https://angular.dev/tools/cli/schematics [filestructure]: https://angular.dev/reference/configs/file-structure [node.js]: https://nodejs.org/ [npm]: https://www.npmjs.com/get-npm [codeofconduct]: https://github.com/angular/angular/blob/main/CODE_OF_CONDUCT.md [twitter]: https://www.twitter.com/angular [discord]: https://discord.gg/angular [gitter]: https://gitter.im/angular/angular-cli [stackoverflow]: https://stackoverflow.com/questions/tagged/angular-cli [youtube]: https://youtube.com/angular [meetup]: https://www.meetup.com/find/?keywords=angular
{ "end_byte": 10863, "start_byte": 3860, "url": "https://github.com/angular/angular-cli/blob/main/README.md" }
angular-cli/constants.bzl_0_1097
# Engine versions to stamp in a release package.json RELEASE_ENGINES_NODE = "^18.19.1 || ^20.11.1 || >=22.0.0" RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0" RELEASE_ENGINES_YARN = ">= 1.13.0" SNAPSHOT_REPOS = { "@angular/cli": "angular/cli-builds", "@angular/pwa": "angular/angular-pwa-builds", "@angular/build": "angular/angular-build-builds", "@angular/ssr": "angular/angular-ssr-builds", "@angular-devkit/architect": "angular/angular-devkit-architect-builds", "@angular-devkit/architect-cli": "angular/angular-devkit-architect-cli-builds", "@angular-devkit/build-angular": "angular/angular-devkit-build-angular-builds", "@angular-devkit/build-webpack": "angular/angular-devkit-build-webpack-builds", "@angular-devkit/core": "angular/angular-devkit-core-builds", "@angular-devkit/schematics": "angular/angular-devkit-schematics-builds", "@angular-devkit/schematics-cli": "angular/angular-devkit-schematics-cli-builds", "@ngtools/webpack": "angular/ngtools-webpack-builds", "@schematics/angular": "angular/schematics-angular-builds", }
{ "end_byte": 1097, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/constants.bzl" }
angular-cli/CONTRIBUTING.md_0_7325
# Contributing to Angular DevKit We would love for you to contribute to DevKit and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow: - [Code of Conduct](#coc) - [Question or Problem?](#question) - [Issues and Bugs](#issue) - [Feature Requests](#feature) - [Submission Guidelines](#submit) - [Coding Rules](#rules) - [Commit Message Guidelines](#commit) - [Signing the CLA](#cla) - [Updating the Public API](#public-api) ## <a name="coc"></a> Code of Conduct Help us keep Angular open and inclusive. Please read and follow our [Code of Conduct][coc]. ## <a name="question"></a> Got a Question or Problem? Please, do not open issues for the general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [StackOverflow](https://stackoverflow.com/questions/tagged/angular-devkit) where the questions should be tagged with tag `angular-cli` or `angular-devkit`. StackOverflow is a much better place to ask questions since: - There are thousands of people willing to help on StackOverflow. - Questions and answers stay available for public viewing so your question / answer might help someone else. - StackOverflow's voting system assures that the best answers are prominently visible. To save your and our time we will be systematically closing all the issues that are requests for general support and redirecting people to StackOverflow. If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter]. ## <a name="issue"></a> Found an Issue? If you find a bug in the source code or a mistake in the documentation, you can help us by [submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can [submit a Pull Request](#submit-pr) with a fix. ## <a name="feature"></a> Want a Feature? You can *request* a new feature by [submitting an issue](#submit-issue) to our [GitHub Repository][github]. If you would like to *implement* a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it. Please consider what kind of change it is: * For a **Major Feature**, first open an issue and outline your proposal so that it can be discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. * **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). ## <a name="submit"></a> Submission Guidelines ### <a name="submit-issue"></a> Submitting an Issue Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. Having a reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like: - version of Angular CLI used - `angular.json` configuration - version of Angular DevKit used - 3rd-party libraries and their versions - and most importantly - a use-case that fails A minimal reproduce scenario using allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal repository. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it. Unfortunately we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced. You can file new issues by selecting from our [new issue templates](https://github.com/angular/angular-cli/issues/new/choose) and filling out the issue template. ### <a name="submit-pr"></a> Submitting a Pull Request (PR) Before you submit your Pull Request (PR) consider the following guidelines: * Search [GitHub](https://github.com/angular/angular-cli/pulls) for an open or closed PR that relates to your submission. You don't want to duplicate effort. * Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs. We cannot accept code without this. * Make your changes in a new git branch: ```shell git checkout -b my-fix-branch main ``` * Create your patch, **including appropriate test cases**. * Follow our [Coding Rules](#rules). * Run the full Angular CLI and DevKit test suite, as described in the [developer documentation][dev-doc], and ensure that all tests pass (coming soon). * Commit your changes using a descriptive commit message that follows our [commit message conventions](#commit). Adherence to these conventions is necessary because release notes are automatically generated from these messages. ```shell git commit -a ``` Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. * Push your branch to GitHub: ```shell git push origin my-fix-branch ``` * In GitHub, send a pull request to `angular/angular-cli:main`. * If we suggest changes then: * Make the required updates. * Re-run the Angular DevKit test suites to ensure tests are still passing. * Once your PR is approved and you are done with any follow up changes: * Rebase to the current main to pre-emptively address any merge conflicts. ```shell git rebase upstream/main -i git push -f ``` * Add the `action: merge` label and the correct [target label](https://github.com/angular/angular/blob/main/docs/TRIAGE_AND_LABELS.md#pr-target) (if PR author has the project collaborator status, or else the last reviewer should do this). * The current caretaker will merge the PR to the target branch(es) within 1-2 business days. That's it! 🎉 Thank you for your contribution! #### After your pull request is merged After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository: * Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: ```shell git push origin --delete my-fix-branch ``` * Check out the main branch: ```shell git checkout main -f ``` * Delete the local branch: ```shell git branch -D my-fix-branch ``` * Update your local `main` with the latest upstream version: ```shell git pull --ff upstream main ``` ## <a name="rules"></a> Coding Rules To ensure consistency throughout the source code, keep these rules in mind as you are working: * All features or bug fixes **must be tested** by one or more specs (unit-tests or e2e-tests). * All public API methods **must be documented**. (Details TBC). * We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at **100 characters**. ##
{ "end_byte": 7325, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md" }
angular-cli/CONTRIBUTING.md_7325_13061
<a name="commit"></a> Commit Message Guidelines We have very precise rules over how our git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**. But also, we use the git commit messages to **generate the Angular DevKit change log**. ### Commit Message Format Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**: ``` <type>(<scope>): <subject> <BLANK LINE> <body> <BLANK LINE> <footer> ``` The **header** is mandatory and the **scope** of the header is optional. Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools. ### Revert If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted. ### Type Must be one of the following: * **build**: Changes to local repository build system and tooling * **ci**: Changes to CI configuration and CI specific tooling [2] * **docs**: Changes which exclusively affects documentation. * **feat**: Creates a new feature [1] * **fix**: Fixes a previously discovered failure/bug [1] * **perf**: Improves performance without any change in functionality or API [1] * **refactor**: Refactor without any change in functionality or API (includes style changes) * **release**: A release point in the repository [2] * **test**: Improvements or corrections made to the project's test suite <sup>[1] This type MUST have a scope. See the next section for more information.</sup><br/> <sup>[2] This type MUST NOT have a scope. It only applies to general scripts and tooling.</sup> ### Scope The scope should be the name of the npm package affected as perceived by the person reading changelog generated from the commit messages. The following is the list of supported scopes: * **@angular/build** * **@angular/cli** * **@angular/create** * **@angular/pwa** * **@angular/ssr** * **@angular-devkit/architect** * **@angular-devkit/architect-cli** * **@angular-devkit/build-angular** * **@angular-devkit/build-webpack** * **@angular-devkit/core** * **@angular-devkit/schematics** * **@angular-devkit/schematics-cli** * **@ngtools/webpack** * **@schematics/angular** ### Subject The subject contains succinct description of the change: * use the imperative, present tense: "change" not "changed" nor "changes" * don't capitalize first letter * be concise and direct * no dot (.) at the end ### Examples Examples of valid commit messages: * `fix(@angular/cli): prevent the flubber from grassing` * `refactor(@schematics/angular): move all JSON classes together` Examples of invalid commit messages: * `fix(@angular/cli): add a new XYZ command` This is a feature, not a fix. * `ci(@angular/cli): fix publishing workflow` The `ci` type cannot have a scope. ### Body Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior. ### Footer The footer can contain information about breaking changes and deprecations. It is also the place to reference GitHub issues, Jira tickets, and other PRs that are related to this commit or that this commit will close. For example: ``` BREAKING CHANGE: <breaking change summary> <BLANK LINE> <breaking change description + migration instructions> <BLANK LINE> <BLANK LINE> Fixes #<issue number> ``` or ``` DEPRECATED: <what is deprecated> <BLANK LINE> <deprecation description + recommended update path> <BLANK LINE> <BLANK LINE> Closes #<pr number> ``` Breaking Change section should start with the phrase "BREAKING CHANGE: " followed by a summary of the breaking change, a blank line, and a detailed description of the breaking change that also includes migration instructions. Similarly, a Deprecation section should start with "DEPRECATED: " followed by a short description of what is deprecated, a blank line, and a detailed description of the deprecation that also mentions the recommended update path. ## <a name="cla"></a> Signing the CLA Please sign our Contributor License Agreement (CLA) before sending pull requests. For any code changes to be accepted, the CLA must be signed. It's a quick process, we promise! * For individuals we have a [simple click-through form][individual-cla]. * For corporations we'll need you to [print, sign and one of scan+email, fax or mail the form][corporate-cla]. [coc]: https://github.com/angular/code-of-conduct/blob/main/CODE_OF_CONDUCT.md [commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit# [corporate-cla]: https://code.google.com/legal/corporate-cla-v1.0.html [dev-doc]: https://github.com/angular/angular-cli/blob/main/packages/angular/cli/README.md#development-hints-for-working-on-angular-cli [GitHub]: https://github.com/angular/angular-cli [gitter]: https://gitter.im/angular/angular-cli [individual-cla]: https://code.google.com/legal/individual-cla-v1.0.html [js-style-guide]: https://google.github.io/styleguide/jsguide.html [stackoverflow]: https://stackoverflow.com/questions/tagged/angular-devkit ## <a name="public-api"></a> Updating the Public API Our Public API surface is tracked using golden files. You check all golden files by running: ```bash yarn public-api:check ``` If you modified the public API, the test will fail. To update the golden files you need to run: ```bash yarn public-api:update ```
{ "end_byte": 13061, "start_byte": 7325, "url": "https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md" }
angular-cli/BUILD.bazel_0_1583
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") load("@npm//@bazel/concatjs:index.bzl", "ts_config") package(default_visibility = ["//visibility:public"]) licenses(["notice"]) exports_files([ "LICENSE", "tsconfig.json", "tsconfig-test.json", "tsconfig-build-ng.json", "tsconfig-build.json", "package.json", ]) # Files required by e2e tests copy_to_bin( name = "config-files", srcs = [ "package.json", ], ) # Detect if the build is running under --stamp config_setting( name = "stamp", values = {"stamp": "true"}, ) # If set will replace dependency versions with tarballs for packages in this repo bool_flag( name = "enable_package_json_tar_deps", build_setting_default = False, ) config_setting( name = "package_json_use_tar_deps", flag_values = { ":enable_package_json_tar_deps": "true", }, ) # If set will replace dependency versions with snapshot repos for packages in this repo bool_flag( name = "enable_snapshot_repo_deps", build_setting_default = False, ) config_setting( name = "package_json_use_snapshot_repo_deps", flag_values = { ":enable_snapshot_repo_deps": "true", }, ) ts_config( name = "tsconfig-build-ng", src = "tsconfig-build-ng.json", deps = [ ":tsconfig.json", ], )
{ "end_byte": 1583, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/BUILD.bazel" }
angular-cli/SECURITY.md_0_413
Angular is part of Google [Open Source Software Vulnerability Reward Program](https://bughunters.google.com/about/rules/6521337925468160/google-open-source-software-vulnerability-reward-program-rules). For vulnerabilities in Angular, please submit your report [here](https://bughunters.google.com/report). For more information, check out [Angular's security policy](https://angular.dev/best-practices/security).
{ "end_byte": 413, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/SECURITY.md" }
angular-cli/tools/link_package_json_to_tarballs.bzl_0_3486
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@aspect_bazel_lib//lib:utils.bzl", "to_label") def link_package_json_to_tarballs(name, src, pkg_deps, out): """Substitute tar paths into a package.json file for the packages it depends on. src and pkg_deps must be labels in the bazel-out tree for the derived path to the npm_package_archive.tgz to be correct. Args: name: Name of the rule src: package.json file to perform substitions on pkg_deps: package.json files of dependencies to substitute out: Output package.json file """ src_pkg = to_label(src).package # Generate partial jq filters for each dependent package that, when run # against a package.json file, can replace its dependency with a tar path. filter_files = [] for i, pkg_dep in enumerate(pkg_deps): pkg_dep_name = "%s_%s.name" % (name, i) pkg_dep_filter = "%s_%s.filter" % (name, i) jq( name = "%s_%s_name" % (name, i), srcs = [pkg_dep], filter = ".name", out = pkg_dep_name, ) srcs = [ pkg_dep_name, pkg_dep, ] # Add dependent tars as srcs to include them in the dependency graph, except # for the tar for this package as that would create a circular dependency. pkg_label = to_label(pkg_dep) if pkg_label.package != src_pkg: pkg_tar = "@%s//%s:npm_package_archive.tgz" % (pkg_label.workspace_name, pkg_label.package) srcs.append(pkg_tar) # Deriving the absolute path to the tar in the execroot requries different # commands depending on whether or not the action is sandboxed. abs_path_sandbox = "readlink $(execpath {pkg_dep})".format(pkg_dep = pkg_dep) abs_path_nosandbox = "(cd $$(dirname $(execpath {pkg_dep})) && pwd)".format(pkg_dep = pkg_dep) native.genrule( name = "%s_%s_filter" % (name, i), srcs = srcs, cmd = """ TAR=$$(dirname $$({abs_path_sandbox} || {abs_path_nosandbox}))/npm_package_archive.tgz PKGNAME=$$(cat $(execpath {pkg_name})) if [[ "$$TAR" != *bazel-out* ]]; then echo "ERROR: package.json passed to substitute_tar_deps must be in the output tree. You can use copy_to_bin to copy a source file to the output tree." exit 1 fi echo "(..|objects|select(has($${{PKGNAME}})))[$${{PKGNAME}}] |= \\"file:$${{TAR}}\\"" > $@ """.format( pkg_name = pkg_dep_name, abs_path_sandbox = abs_path_sandbox, abs_path_nosandbox = abs_path_nosandbox, ), outs = [pkg_dep_filter], ) filter_files.append(pkg_dep_filter) # Combine all of the filter files into a single filter by joining with | filter = "%s.filter" % name native.genrule( name = "%s_filter" % name, srcs = filter_files, cmd = "cat $(SRCS) | sed '$$!s#$$# |#' > $@", outs = [filter], ) # Generate final package.json with tar substitutions using the above filter jq( name = name, srcs = [src], filter_file = filter, out = out, )
{ "end_byte": 3486, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/link_package_json_to_tarballs.bzl" }
angular-cli/tools/ng_cli_schema_generator.bzl_0_1090
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license def _cli_json_schema_interface_impl(ctx): args = [ ctx.files.src[0].path, ctx.outputs.json.path, ] ctx.actions.run( inputs = ctx.files.src + ctx.files.data, executable = ctx.executable._binary, outputs = [ctx.outputs.json], arguments = args, ) return [DefaultInfo()] cli_json_schema = rule( _cli_json_schema_interface_impl, attrs = { "src": attr.label( allow_files = [".json"], mandatory = True, ), "out": attr.string( mandatory = True, ), "data": attr.label_list( allow_files = [".json"], mandatory = True, ), "_binary": attr.label( default = Label("//tools:ng_cli_schema"), executable = True, cfg = "exec", ), }, outputs = { "json": "%{out}", }, )
{ "end_byte": 1090, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/ng_cli_schema_generator.bzl" }
angular-cli/tools/quicktype_runner.js_0_4888
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ const fs = require('fs'); const path = require('path'); const { InputData, JSONSchemaInput, JSONSchemaStore, TypeScriptTargetLanguage, parseJSON, quicktype, } = require('quicktype-core'); /** * This file is pure JavaScript because Bazel only support compiling to ES5, while quicktype is * ES2015. This results in an incompatible call to `super()` in the FetchingJSONSchemaStore * class as it tries to call JSONSchemaStore's constructor in ES5. * TODO: move this file to typescript when Bazel supports ES2015 output. * * This file wraps around quicktype and can do one of two things; * * `node quicktype_runner.js <in_path> <out_path>` * Reads the in path and outputs the TS file at the out_path. * * Using `-` as the out_path will output on STDOUT instead of a file. */ // Header to add to all files. const header = ` // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). `; // Footer to add to all files. const footer = ``; /** * The simplest Node JSONSchemaStore implementation we can build which supports our custom protocol. * Supports reading from ng-cli addresses, valid URLs and files (absolute). */ class FetchingJSONSchemaStore extends JSONSchemaStore { constructor(inPath) { super(); this._inPath = inPath; } async fetch(address) { const URL = require('url'); const url = URL.parse(address); let content = null; if (url.protocol === 'ng-cli:') { let filePath = path.join(__dirname, '../packages/angular/cli', url.hostname, url.path); content = fs.readFileSync(filePath, 'utf-8').trim(); } else if (url.hostname) { try { const response = await fetch(address); content = response.text(); } catch (e) { content = null; } } if (content === null && !path.isAbsolute(address)) { const resolvedPath = path.join(path.dirname(this._inPath), address); // Check relative to inPath if (fs.existsSync(resolvedPath)) { content = fs.readFileSync(resolvedPath, 'utf-8'); } } if (content === null && fs.existsSync(address)) { content = fs.readFileSync(address, 'utf-8').trim(); } if (content == null) { return undefined; } content = appendDeprecatedDescription(content); return parseJSON(content, 'JSON Schema', address); } } /** * Create the TS file from the schema, and overwrite the outPath (or log). * @param {string} inPath * @param {string} outPath */ async function main(inPath, outPath) { const content = await generate(inPath); if (outPath === '-') { console.log(content); process.exit(0); } const buildWorkspaceDirectory = process.env['BUILD_WORKSPACE_DIRECTORY'] || '.'; outPath = path.resolve(buildWorkspaceDirectory, outPath); fs.writeFileSync(outPath, content, 'utf-8'); } async function generate(inPath) { // Best description of how to use the API was found at // https://blog.quicktype.io/customizing-quicktype/ const inputData = new InputData(); const content = fs.readFileSync(inPath, 'utf-8'); const source = { name: 'Schema', schema: appendDeprecatedDescription(content) }; await inputData.addSource('schema', source, () => { return new JSONSchemaInput(new FetchingJSONSchemaStore(inPath)); }); const lang = new TypeScriptTargetLanguage(); const { lines } = await quicktype({ lang, inputData, alphabetizeProperties: true, rendererOptions: { 'just-types': 'true', 'explicit-unions': 'true', 'acronym-style': 'camel', }, }); return header + lines.join('\n') + footer; } /** * Converts `x-deprecated` to `@deprecated` comments. * @param {string} schema */ function appendDeprecatedDescription(schema) { const content = JSON.parse(schema); const props = content.properties; for (const key in props) { let { description = '', 'x-deprecated': deprecated } = props[key]; if (!deprecated) { continue; } description += '\n@deprecated' + (typeof deprecated === 'string' ? ` ${deprecated}` : ''); props[key].description = description; } return JSON.stringify(content); } if (require.main === module) { // Parse arguments and run main(). const argv = process.argv.slice(2); if (argv.length < 2 || argv.length > 3) { console.error('Must include 2 or 3 arguments.'); process.exit(1); } main(argv[0], argv[1]) .then(() => process.exit(0)) .catch((err) => { console.error('An error happened:'); console.error(err); process.exit(127); }); } exports.generate = generate;
{ "end_byte": 4888, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/quicktype_runner.js" }
angular-cli/tools/ts_json_schema.bzl_0_1681
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license def _ts_json_schema_interface_impl(ctx): args = [ ctx.files.src[0].path, ctx.outputs.ts.path, ] ctx.actions.run( inputs = ctx.files.src + ctx.files.data, executable = ctx.executable._binary, outputs = [ctx.outputs.ts], arguments = args, ) return [DefaultInfo()] _ts_json_schema_interface = rule( _ts_json_schema_interface_impl, attrs = { "src": attr.label( allow_files = [".json"], mandatory = True, ), "out": attr.string( mandatory = True, ), "data": attr.label_list( allow_files = [".json"], ), "_binary": attr.label( default = Label("//tools:quicktype_runner"), executable = True, cfg = "exec", ), }, outputs = { "ts": "%{out}", }, ) # Generates a TS file that contains the interface for a JSON Schema file. Takes a single `src` # argument as input, an optional data field for reference files, and produces a # _ts_json_schema_interface() rule containing the typescript interface. # The file produced will have the same name, with the extension replaced from `.json` to `.ts`. # Any filename collision will be an error thrown by Bazel. def ts_json_schema(name, src, data = []): out = src.replace(".json", ".ts") _ts_json_schema_interface( name = name + ".interface", src = src, out = out, data = data, )
{ "end_byte": 1681, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/ts_json_schema.bzl" }
angular-cli/tools/snapshot_repo_filter.bzl_0_775
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license load("//:constants.bzl", "SNAPSHOT_REPOS") def _generate_snapshot_repo_filter(): filter = "" for (i, pkg_name) in enumerate(SNAPSHOT_REPOS.keys()): filter += "{sep}(..|objects|select(has(\"{pkg_name}\")))[\"{pkg_name}\"] |= \"github:{snapshot_repo}#BUILD_SCM_HASH-PLACEHOLDER\"\n".format( sep = "| " if i > 0 else "", pkg_name = pkg_name, snapshot_repo = SNAPSHOT_REPOS[pkg_name], ) return filter # jq filter that replaces package.json dependencies with snapshot repos SNAPSHOT_REPO_JQ_FILTER = _generate_snapshot_repo_filter()
{ "end_byte": 775, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/snapshot_repo_filter.bzl" }
angular-cli/tools/ng_cli_schema_generator.js_0_3156
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ const { readFileSync, writeFileSync, mkdirSync } = require('fs'); const { resolve, dirname } = require('path'); /** * Generator the Angular CLI workspace schema file. */ function generate(inPath, outPath) { // While on paper we could use quicktype for this. // Quicktype doesn't handle `patternProperties` and `oneOf` that well. const jsonSchema = readFileSync(inPath, 'utf8'); const nestedDefinitions = {}; const schemaParsed = JSON.parse(jsonSchema, (key, value) => { if (key === '$ref' && typeof value === 'string' && !value.startsWith('#')) { // Resolve $ref and camelize key const definitionKey = value .replace(/(\.json|src)/g, '') .split(/\\|\/|_|-|\./) .filter((p) => !!p) .map((s) => s.charAt(0).toUpperCase() + s.slice(1)) .join(''); const nestedSchemaPath = resolve(dirname(inPath), value); const nestedSchema = readFileSync(nestedSchemaPath, 'utf8'); const nestedSchemaJson = JSON.parse(nestedSchema, (key, value) => { switch (key) { case '$ref': if (value.startsWith('#/definitions/')) { return value.replace('#/definitions/', `#/definitions/${definitionKey}/definitions/`); } else { throw new Error(`Error while resolving $ref ${value} in ${nestedSchemaPath}.`); } case '$id': case 'id': case '$schema': case 'required': case 'x-prompt': case 'x-user-analytics': return undefined; default: return value; } }); nestedDefinitions[definitionKey] = nestedSchemaJson; return `#/definitions/${definitionKey}`; } return key === '' ? { ...value, definitions: { ...value.definitions, ...nestedDefinitions, }, } : value; }); const buildWorkspaceDirectory = process.env['BUILD_WORKSPACE_DIRECTORY'] || '.'; outPath = resolve(buildWorkspaceDirectory, outPath); mkdirSync(dirname(outPath), { recursive: true }); writeFileSync( outPath, JSON.stringify( schemaParsed, (key, value) => { if (key === 'x-deprecated') { // Needed for IDEs, and will be replaced to 'deprecated' later on. This must be a boolean. // https://json-schema.org/draft/2020-12/json-schema-validation.html#name-deprecated return !!value; } return value; }, 2, ).replace(/"x-deprecated"/g, '"deprecated"'), ); } if (require.main === module) { const argv = process.argv.slice(2); if (argv.length !== 2) { console.error('Must include 2 arguments.'); process.exit(1); } const [inPath, outPath] = argv; try { generate(inPath, outPath); } catch (error) { console.error('An error happened:'); console.error(error); process.exit(127); } } exports.generate = generate;
{ "end_byte": 3156, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/ng_cli_schema_generator.js" }
angular-cli/tools/package_json_release_filter.jq_0_1282
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license # # This filter combines a subproject package.json with the root package.json # and performs substitutions to prepare it for release. It should be called # with the --slurp argument and be passed the root pacakge.json followed by # the subproject package.json. # # See jq docs for filter syntax: https://stedolan.github.io/jq/manual/. .[0] as $root | .[1] as $proj # Get the fields from root package.json that should override the project # package.json, i.e., every field except the following | ($root | del(.bin, .description, .dependencies, .name, .main, .peerDependencies, .optionalDependencies, .typings, .version, .private, .workspaces, .resolutions, .scripts, .["ng-update"]) ) as $root_overrides # Use the project package.json as a base and override other fields from root | $proj + $root_overrides # Combine keywords from both | .keywords = ($root.keywords + $proj.keywords | unique) # Remove devDependencies | del(.devDependencies) # Add engines; versions substituted via pkg_npm + {"engines": {"node": "0.0.0-ENGINES-NODE", "npm": "0.0.0-ENGINES-NPM", "yarn": "0.0.0-ENGINES-YARN"}}
{ "end_byte": 1282, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/package_json_release_filter.jq" }
angular-cli/tools/BUILD.bazel_0_771
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.dev/license # @external_begin load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") package(default_visibility = ["//visibility:public"]) exports_files([ "package_json_release_filter.jq", ]) nodejs_binary( name = "ng_cli_schema", data = [ "ng_cli_schema_generator.js", ], entry_point = "ng_cli_schema_generator.js", ) nodejs_binary( name = "quicktype_runner", data = [ "quicktype_runner.js", "@npm//quicktype-core", ], entry_point = "quicktype_runner.js", templated_args = ["--bazel_patch_module_resolver"], ) # @external_end
{ "end_byte": 771, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/BUILD.bazel" }
angular-cli/tools/defaults.bzl_0_3392
"""Re-export of some bazel rules with repository-wide defaults.""" load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@aspect_bazel_lib//lib:utils.bzl", "to_label") load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin", _js_library = "js_library", _pkg_npm = "pkg_npm") load("@npm//@angular/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package") load("@npm//@angular/build-tooling/bazel:extract_js_module_output.bzl", "extract_js_module_output") load("@npm//@bazel/concatjs:index.bzl", _ts_library = "ts_library") load("@rules_pkg//:pkg.bzl", "pkg_tar") load("//:constants.bzl", "RELEASE_ENGINES_NODE", "RELEASE_ENGINES_NPM", "RELEASE_ENGINES_YARN") load("//tools:link_package_json_to_tarballs.bzl", "link_package_json_to_tarballs") load("//tools:snapshot_repo_filter.bzl", "SNAPSHOT_REPO_JQ_FILTER") _DEFAULT_TSCONFIG = "//:tsconfig-build.json" _DEFAULT_TSCONFIG_NG = "//:tsconfig-build-ng" _DEFAULT_TSCONFIG_TEST = "//:tsconfig-test.json" NPM_PACKAGE_SUBSTITUTIONS = { # Version of the local package being built, generated via the `--workspace_status_command` flag. "0.0.0-PLACEHOLDER": "{STABLE_PROJECT_VERSION}", "0.0.0-EXPERIMENTAL-PLACEHOLDER": "{STABLE_PROJECT_EXPERIMENTAL_VERSION}", "BUILD_SCM_HASH-PLACEHOLDER": "{BUILD_SCM_ABBREV_HASH}", "0.0.0-ENGINES-NODE": RELEASE_ENGINES_NODE, "0.0.0-ENGINES-NPM": RELEASE_ENGINES_NPM, "0.0.0-ENGINES-YARN": RELEASE_ENGINES_YARN, # The below is needed for @angular/ssr FESM file. "\\./(.+)/packages/angular/ssr/third_party/beasties": "../third_party/beasties/index.js", } NO_STAMP_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{ "0.0.0-PLACEHOLDER": "0.0.0", "0.0.0-EXPERIMENTAL-PLACEHOLDER": "0.0.0", }) def _default_module_name(testonly): """ Provide better defaults for package names. e.g. rather than angular/packages/core/testing we want @angular/core/testing TODO(alexeagle): we ought to supply a default module name for every library in the repo. But we short-circuit below in cases that are currently not working. """ pkg = native.package_name() if testonly: # Some tests currently rely on the long-form package names return None if pkg.startswith("packages/"): return "@angular/" + pkg[len("packages/angular/"):] return None def ts_library( name, tsconfig = None, testonly = False, deps = [], devmode_module = None, devmode_target = None, **kwargs): """Default values for ts_library""" if testonly: # Match the types[] in //packages:tsconfig-test.json deps.append("@npm//@types/jasmine") deps.append("@npm//@types/node") if not tsconfig: if testonly: tsconfig = _DEFAULT_TSCONFIG_TEST else: tsconfig = _DEFAULT_TSCONFIG if not devmode_module: devmode_module = "commonjs" if not devmode_target: devmode_target = "es2022" _ts_library( name = name, testonly = testonly, deps = deps, # @external_begin tsconfig = tsconfig, devmode_module = devmode_module, devmode_target = devmode_target, prodmode_target = "es2022", # @external_end **kwargs ) js_library = _js_library
{ "end_byte": 3392, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/defaults.bzl" }
angular-cli/tools/defaults.bzl_3394_12080
def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs): """Override of pkg_npm to produce package outputs and version substitutions conventional to the angular-cli project. Produces a package and a tar of that package. Expects a package.json file in the same folder to exist. Args: name: Name of the pkg_npm rule. '_archive.tgz' is appended to create the tarball. pkg_deps: package.json files of dependent packages. These are used for local path substitutions when --config=local is set. use_prodmode_output: False to ship ES5 devmode output, True to ship ESM output. Defaults to False. **kwargs: Additional arguments passed to the real pkg_npm. """ pkg_json = kwargs.pop("pkg_json", ":package.json") visibility = kwargs.pop("visibility", None) if pkg_json: deps = kwargs.pop("deps", []) # The `pkg_npm` rule brings in devmode (`JSModuleInfo`) and prodmode (`JSEcmaScriptModuleInfo`) # output into the NPM package We do not intend to ship the prodmode ECMAScript `.mjs` # files, but the `JSModuleInfo` outputs (which correspond to devmode output). Depending on # the `use_prodmode_output` macro attribute, we either ship the ESM output of dependencies, # or continue shipping the devmode ES5 output. # TODO: Clean this up in the future if we have combined devmode and prodmode output. # https://github.com/bazelbuild/rules_nodejs/commit/911529fd364eb3ee1b8ecdc568a9fcf38a8b55ca. # https://github.com/bazelbuild/rules_nodejs/blob/stable/packages/typescript/internal/build_defs.bzl#L334-L337. extract_js_module_output( name = "%s_js_module_output" % name, provider = "JSEcmaScriptModuleInfo" if use_prodmode_output else "JSModuleInfo", include_declarations = True, include_default_files = True, forward_linker_mappings = False, include_external_npm_packages = False, deps = deps, ) # Merge package.json with root package.json and perform various substitutions to # prepare it for release. For jq docs, see https://stedolan.github.io/jq/manual/. jq( name = "basic_substitutions", # Note: this jq filter relies on the order of the inputs # buildifier: do not sort srcs = ["//:package.json", pkg_json], filter_file = "//tools:package_json_release_filter.jq", args = ["--slurp"], out = "substituted/package.json", ) # Copy package.json files to bazel-out so we can use their bazel-out paths to determine # the corresponding package npm package tgz path for substitutions. copy_to_bin( name = "package_json_copy", srcs = [pkg_json], ) pkg_deps_copies = [] for pkg_dep in pkg_deps: pkg_label = to_label(pkg_dep) if pkg_label.name != "package.json": fail("ERROR: only package.json files allowed in pkg_deps of pkg_npm macro") pkg_deps_copies.append("@%s//%s:package_json_copy" % (pkg_label.workspace_name, pkg_label.package)) # Substitute dependencies on other packages in this repo with tarballs. link_package_json_to_tarballs( name = "tar_substitutions", src = "substituted/package.json", pkg_deps = [":package_json_copy"] + pkg_deps_copies, out = "substituted_with_tars/package.json", ) # Substitute dependencies on other packages in this repo with snapshot repos. jq( name = "snapshot_repo_substitutions", srcs = ["substituted/package.json"], filter = SNAPSHOT_REPO_JQ_FILTER, out = "substituted_with_snapshot_repos/package.json", ) # Move the generated package.json along with other deps into a directory for pkg_npm # to package up because pkg_npm requires that all inputs be in the same directory. copy_to_directory( name = "package", srcs = select({ # Do tar substitution if config_setting 'package_json_use_tar_deps' is true (local builds) "//:package_json_use_tar_deps": [":%s_js_module_output" % name, "substituted_with_tars/package.json"], "//:package_json_use_snapshot_repo_deps": [":%s_js_module_output" % name, "substituted_with_snapshot_repos/package.json"], "//conditions:default": [":%s_js_module_output" % name, "substituted/package.json"], }), replace_prefixes = { "substituted_with_tars/": "", "substituted_with_snapshot_repos/": "", "substituted/": "", }, exclude_srcs_patterns = [ "packages/**/*", # Exclude compiled outputs of dependent packages ], allow_overwrites = True, ) nested_packages = ["package"] else: nested_packages = None _pkg_npm( name = name, # We never set a `package_name` for NPM packages, neither do we enable validation. # This is necessary because the source targets of the NPM packages all have # package names set and setting a similar `package_name` on the NPM package would # result in duplicate linker mappings that will conflict. e.g. consider the following # scenario: We have a `ts_library` for `@angular/core`. We will configure a package # name for the target so that it can be resolved in NodeJS executions from `node_modules`. # If we'd also set a `package_name` for the associated `pkg_npm` target, there would be # two mappings for `@angular/core` and the linker will complain. For a better development # experience, we want the mapping to resolve to the direct outputs of the `ts_library` # instead of requiring tests and other targets to assemble the NPM package first. # TODO(devversion): consider removing this if `rules_nodejs` allows for duplicate # linker mappings where transitive-determined mappings are skipped on conflicts. # https://github.com/bazelbuild/rules_nodejs/issues/2810. package_name = None, validate = False, substitutions = select({ "//:stamp": NPM_PACKAGE_SUBSTITUTIONS, "//conditions:default": NO_STAMP_PACKAGE_SUBSTITUTIONS, }), visibility = visibility, nested_packages = nested_packages, tgz = None, **kwargs ) if pkg_json: pkg_tar( name = name + "_archive", srcs = [":%s" % name], extension = "tgz", strip_prefix = "./%s" % name, visibility = visibility, ) def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps = [], module_name = None, package_name = None, **kwargs): """Default values for ng_module""" deps = deps + ["@npm//tslib"] if testonly: # Match the types[] in //packages:tsconfig-test.json deps.append("@npm//@types/jasmine") deps.append("@npm//@types/node") if not tsconfig: if testonly: tsconfig = _DEFAULT_TSCONFIG_TEST else: tsconfig = _DEFAULT_TSCONFIG_NG if not module_name: module_name = _default_module_name(testonly) # If no `package_name` is explicitly set, we use the default module name as package # name, so that the target can be resolved within NodeJS executions, by activating # the Bazel NodeJS linker. See: https://github.com/bazelbuild/rules_nodejs/pull/2799. if not package_name: package_name = _default_module_name(testonly) if not entry_point: entry_point = "public_api.ts" _ng_module( name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, testonly = testonly, deps = deps, # `module_name` is used for AMD module names within emitted JavaScript files. module_name = module_name, # `package_name` can be set to allow for the Bazel NodeJS linker to run. This # allows for resolution of the given target within the `node_modules/`. package_name = package_name, **kwargs ) def ng_package(deps = [], **kwargs): _ng_package( deps = deps, license = "//:LICENSE", substitutions = select({ "//:stamp": NPM_PACKAGE_SUBSTITUTIONS, "//conditions:default": NO_STAMP_PACKAGE_SUBSTITUTIONS, }), **kwargs )
{ "end_byte": 12080, "start_byte": 3394, "url": "https://github.com/angular/angular-cli/blob/main/tools/defaults.bzl" }
angular-cli/tools/toolchain_info.bzl_0_1491
# look at the toolchains registered in the workspace file with nodejs_register_toolchains # the name can be anything the user wants this is just added to the target to create unique names # the order will match against the order in the TOOLCHAIN_VERSION list. TOOLCHAINS_NAMES = [ "node18", "node20", "node22", ] # this is the list of toolchains that should be used and are registered with nodejs_register_toolchains in the WORKSPACE file TOOLCHAINS_VERSIONS = [ select({ "@bazel_tools//src/conditions:linux_x86_64": "@node18_linux_amd64//:node_toolchain", "@bazel_tools//src/conditions:darwin": "@node18_darwin_amd64//:node_toolchain", "@bazel_tools//src/conditions:windows": "@node18_windows_amd64//:node_toolchain", }), select({ "@bazel_tools//src/conditions:linux_x86_64": "@node20_linux_amd64//:node_toolchain", "@bazel_tools//src/conditions:darwin": "@node20_darwin_amd64//:node_toolchain", "@bazel_tools//src/conditions:windows": "@node20_windows_amd64//:node_toolchain", }), select({ "@bazel_tools//src/conditions:linux_x86_64": "@node22_linux_amd64//:node_toolchain", "@bazel_tools//src/conditions:darwin": "@node22_darwin_amd64//:node_toolchain", "@bazel_tools//src/conditions:windows": "@node22_windows_amd64//:node_toolchain", }), ] # A default toolchain for use when only one is necessary DEFAULT_TOOLCHAIN_VERSION = TOOLCHAINS_VERSIONS[len(TOOLCHAINS_VERSIONS) - 1]
{ "end_byte": 1491, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/toolchain_info.bzl" }
angular-cli/tools/test/BUILD.bazel_0_979
load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("@aspect_bazel_lib//lib:jq.bzl", "jq") jq( name = "final_package_json", # This jq filter relies on the order of the inputs # buildifier: do not sort srcs = [ "root_package.json", "project_package.json", ], args = [ "--slurp", ], filter_file = "//tools:package_json_release_filter.jq", ) # jq outputs CR on windows https://github.com/stedolan/jq/issues/92 # strip the CRs to do a correct comparison on all platforms genrule( name = "final_package_json_cr_stripped", srcs = [":final_package_json"], outs = ["final_package_json_cr_stripped.json"], cmd = "cat $(execpath :final_package_json) | sed \"s#\\r##\" > $@", ) # Test correctness of the filter that prepares each project's package.json file for release diff_test( name = "package_json_filter_test", file1 = "expected_package.json", file2 = ":final_package_json_cr_stripped", )
{ "end_byte": 979, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tools/test/BUILD.bazel" }
angular-cli/tests/README.md_0_250
# `/tests` Folder Contains all e2e tests and test assets. ## `legacy-cli/` Contains all assets and all e2e tests from the legacy CLI repo. ## Others Other folders contain test assets related to the Package namespace folders matching their name.
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/README.md" }
angular-cli/tests/legacy-cli/e2e.bzl_0_6649
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test") load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS") # bazel query --output=label "kind('pkg_tar', //packages/...)" TESTED_PACKAGES = [ "//packages/angular/build:npm_package_archive.tgz", "//packages/angular/cli:npm_package_archive.tgz", "//packages/angular/create:npm_package_archive.tgz", "//packages/angular/ssr:npm_package_archive.tgz", "//packages/angular/pwa:npm_package_archive.tgz", "//packages/angular_devkit/architect:npm_package_archive.tgz", "//packages/angular_devkit/architect_cli:npm_package_archive.tgz", "//packages/angular_devkit/build_angular:npm_package_archive.tgz", "//packages/angular_devkit/build_webpack:npm_package_archive.tgz", "//packages/angular_devkit/core:npm_package_archive.tgz", "//packages/angular_devkit/schematics:npm_package_archive.tgz", "//packages/angular_devkit/schematics_cli:npm_package_archive.tgz", "//packages/ngtools/webpack:npm_package_archive.tgz", "//packages/schematics/angular:npm_package_archive.tgz", ] # Number of bazel shards per test target TEST_SHARD_COUNT = 4 # NB: does not run on rbe because webdriver manager uses an absolute path to chromedriver # Requires network to fetch npm packages. TEST_TAGS = ["no-remote-exec", "requires-network"] # Subset of tests for yarn/esbuild BROWSER_TESTS = ["tests/misc/browsers.js"] PACKAGE_MANAGER_SUBSET_TESTS = ["tests/basic/**", "tests/update/**", "tests/commands/add/**", "tests/misc/create-angular.js"] ESBUILD_TESTS = [ "tests/basic/**", "tests/build/**", "tests/commands/add/**", "tests/commands/e2e/**", "tests/commands/serve/ssr-http-requests-assets.js", "tests/i18n/**", "tests/vite/**", "tests/test/**", ] WEBPACK_IGNORE_TESTS = [ "tests/vite/**", "tests/build/app-shell/**", "tests/i18n/ivy-localize-app-shell.js", "tests/i18n/ivy-localize-app-shell-service-worker.js", "tests/commands/serve/ssr-http-requests-assets.js", "tests/build/prerender/http-requests-assets.js", "tests/build/prerender/error-with-sourcemaps.js", "tests/build/server-rendering/server-routes-*", "tests/build/wasm-esm.js", ] def _to_glob(patterns): if len(patterns) == 1: return patterns[0] return "\"{%s}\"" % ",".join(patterns) def e2e_suites(name, runner, data): """ Construct all e2e test suite targets Args: name: the prefix to all rules runner: the e2e test runner entry point data: runtime deps such as tests and test data """ # Pre-configured test suites for toolchain_name, toolchain in zip( TOOLCHAINS_NAMES, TOOLCHAINS_VERSIONS, ): # Default target meant to be run manually for debugging, customizing test cli via bazel _e2e_tests(name + "_" + toolchain_name, runner, data = data, toolchain = toolchain, tags = ["manual"]) _e2e_suite(name, runner, "npm", data, toolchain_name, toolchain) _e2e_suite(name, runner, "bun", data, toolchain_name, toolchain) _e2e_suite(name, runner, "pnpm", data, toolchain_name, toolchain) _e2e_suite(name, runner, "yarn", data, toolchain_name, toolchain) _e2e_suite(name, runner, "esbuild", data, toolchain_name, toolchain) # Saucelabs tests are only run on the default toolchain _e2e_suite(name, runner, "saucelabs", data) def _e2e_tests(name, runner, **kwargs): # Always specify all the npm packages args = kwargs.pop("templated_args", []) + [ "--package $(rootpath %s)" % p for p in TESTED_PACKAGES ] # Always add all the npm packages as data data = kwargs.pop("data", []) + TESTED_PACKAGES # Tags that must always be applied tags = kwargs.pop("tags", []) + TEST_TAGS # Passthru E2E variables in case it is customized by CI etc configuration_env_vars = kwargs.pop("configuration_env_vars", []) + ["E2E_TEMP", "E2E_SHARD_INDEX", "E2E_SHARD_TOTAL"] env = kwargs.pop("env", {}) toolchains = kwargs.pop("toolchains", []) # The git toolchain + env env.update({"GIT_BIN": "$(GIT_BIN_PATH)"}) toolchains = toolchains + ["@npm//@angular/build-tooling/bazel/git-toolchain:current_git_toolchain"] # Chromium browser toolchain env.update({ "CHROME_BIN": "$(CHROMIUM)", "CHROME_PATH": "$(CHROMIUM)", "CHROMEDRIVER_BIN": "$(CHROMEDRIVER)", }) toolchains = toolchains + ["@npm//@angular/build-tooling/bazel/browsers/chromium:toolchain_alias"] data = data + ["@npm//@angular/build-tooling/bazel/browsers/chromium"] nodejs_test( name = name, templated_args = args, data = data, entry_point = runner, env = env, configuration_env_vars = configuration_env_vars, tags = tags, toolchains = toolchains, **kwargs ) def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None): """ Setup a predefined test suite (yarn|pnpm|bun|esbuild|saucelabs|npm). """ args = [] tests = None ignore = None if toolchain_name: toolchain_name = "_" + toolchain_name if type == "yarn" or type == "bun" or type == "pnpm": args.append("--package-manager=%s" % type) args.append("--esbuild") tests = PACKAGE_MANAGER_SUBSET_TESTS ignore = BROWSER_TESTS + WEBPACK_IGNORE_TESTS elif type == "esbuild": args.append("--esbuild") tests = ESBUILD_TESTS ignore = BROWSER_TESTS elif type == "saucelabs": args.append("--esbuild") tests = BROWSER_TESTS ignore = None elif type == "npm": tests = None ignore = BROWSER_TESTS + WEBPACK_IGNORE_TESTS # Standard e2e tests _e2e_tests( name = "%s.%s%s" % (name, type, toolchain_name), runner = runner, size = "enormous", data = data, toolchain = toolchain, shard_count = TEST_SHARD_COUNT, templated_args = args + [ "--glob=%s" % _to_glob(tests) if tests else "", "--ignore=%s" % _to_glob(ignore) if ignore else "", ], ) # e2e tests of snapshot builds _e2e_tests( name = "%s.snapshots.%s%s" % (name, type, toolchain_name), runner = runner, size = "enormous", data = data, toolchain = toolchain, shard_count = TEST_SHARD_COUNT, templated_args = args + [ "--ng-snapshots", "--glob=%s" % _to_glob(tests) if tests else "", "--ignore=%s" % _to_glob(ignore) if ignore else "", ], )
{ "end_byte": 6649, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e.bzl" }
angular-cli/tests/legacy-cli/verdaccio_auth.yaml_0_554
storage: ./storage auth: auth-memory: users: testing: name: testing password: s3cret listen: localhost:${HTTPS_PORT} uplinks: local: url: http://localhost:${HTTP_PORT} cache: false maxage: 20m max_fails: 32 timeout: 60s agent_options: keepAlive: true maxSockets: 32 maxFreeSockets: 8 packages: '**': access: $authenticated proxy: local log: type: stdout format: pretty level: warn # https://github.com/verdaccio/verdaccio/issues/301 server: keepAliveTimeout: 0
{ "end_byte": 554, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/verdaccio_auth.yaml" }
angular-cli/tests/legacy-cli/verdaccio.yaml_0_803
storage: ./storage auth: auth-memory: users: {} listen: localhost:${HTTP_PORT} uplinks: npmjs: url: https://registry.npmjs.org/ cache: false maxage: 20m max_fails: 32 timeout: 60s agent_options: keepAlive: true maxSockets: 32 maxFreeSockets: 8 packages: '@angular/{build,create,cli,pwa,ssr}': access: $all publish: $all '@angular-devkit/*': access: $all publish: $all '@ngtools/webpack': access: $all publish: $all '@schematics/{angular,schematics,update}': access: $all publish: $all '@*/*': access: $all proxy: npmjs '**': access: $all proxy: npmjs log: type: stdout format: pretty level: warn # https://github.com/verdaccio/verdaccio/issues/301 server: keepAliveTimeout: 0
{ "end_byte": 803, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/verdaccio.yaml" }
angular-cli/tests/legacy-cli/BUILD.bazel_0_814
load("//tools:defaults.bzl", "ts_library") load(":e2e.bzl", "e2e_suites") ts_library( name = "runner", testonly = True, srcs = [ "e2e_runner.ts", ], data = [ "verdaccio.yaml", "verdaccio_auth.yaml", ], deps = [ "//packages/angular_devkit/core", "//packages/angular_devkit/core/node", "//tests/legacy-cli/e2e/utils", "@npm//ansi-colors", "@npm//fast-glob", ], ) e2e_suites( name = "e2e", data = [ ":runner", # Tests + setup # Loaded dynamically at runtime, not compiletime deps "//tests/legacy-cli/e2e/assets", "//tests/legacy-cli/e2e/setup", "//tests/legacy-cli/e2e/initialize", "//tests/legacy-cli/e2e/tests", ], runner = ":e2e_runner.ts", )
{ "end_byte": 814, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/BUILD.bazel" }
angular-cli/tests/legacy-cli/e2e_runner.ts_0_7455
import { parseArgs } from 'node:util'; import { createConsoleLogger } from '../../packages/angular_devkit/core/node'; import colors from 'ansi-colors'; import glob from 'fast-glob'; import * as path from 'path'; import { getGlobalVariable, setGlobalVariable } from './e2e/utils/env'; import { gitClean } from './e2e/utils/git'; import { createNpmRegistry } from './e2e/utils/registry'; import { launchTestProcess } from './e2e/utils/process'; import { delimiter, dirname, join } from 'path'; import { findFreePort } from './e2e/utils/network'; import { extractFile } from './e2e/utils/tar'; import { realpathSync } from 'fs'; import { PkgInfo } from './e2e/utils/packages'; Error.stackTraceLimit = Infinity; // tslint:disable:no-global-tslint-disable no-console /** * Here's a short description of those flags: * --debug If a test fails, block the thread so the temporary directory isn't deleted. * --noproject Skip creating a project or using one. * --noglobal Skip linking your local @angular/cli directory. Can save a few seconds. * --nosilent Never silence ng commands. * --ng-tag=TAG Use a specific tag for build snapshots. Similar to ng-snapshots but point to a * tag instead of using the latest `main`. * --ng-snapshots Install angular snapshot builds in the test project. * --glob Run tests matching this glob pattern (relative to tests/e2e/). * --ignore Ignore tests matching this glob pattern. * --reuse=/path Use a path instead of create a new project. That project should have been * created, and npm installed. Ideally you want a project created by a previous * run of e2e. * --nb-shards Total number of shards that this is part of. Default is 2 if --shard is * passed in. * --shard Index of this processes' shard. * --tmpdir=path Override temporary directory to use for new projects. * --package-manager Package manager to use. * --package=path An npm package to be published before running tests * * If unnamed flags are passed in, the list of tests will be filtered to include only those passed. */ const parsed = parseArgs({ allowPositionals: true, options: { 'debug': { type: 'boolean', default: !!process.env.BUILD_WORKSPACE_DIRECTORY }, 'esbuild': { type: 'boolean' }, 'glob': { type: 'string', default: process.env.TESTBRIDGE_TEST_ONLY }, 'ignore': { type: 'string', multiple: true }, 'ng-snapshots': { type: 'boolean' }, 'ng-tag': { type: 'string' }, 'ng-version': { type: 'string' }, 'noglobal': { type: 'boolean' }, 'noproject': { type: 'boolean' }, 'nosilent': { type: 'boolean' }, 'package': { type: 'string', multiple: true, default: ['./dist/_*.tgz'] }, 'package-manager': { type: 'string', default: 'npm' }, 'reuse': { type: 'string' }, 'tmpdir': { type: 'string' }, 'verbose': { type: 'boolean' }, 'nb-shards': { type: 'string' }, 'shard': { type: 'string' }, }, }); const argv = { ...parsed.values, _: parsed.positionals, 'nb-shards': parsed.values['nb-shards'] ?? (Number(process.env.E2E_SHARD_TOTAL ?? 1) * Number(process.env.TEST_TOTAL_SHARDS ?? 1) || 1), shard: parsed.values.shard ?? (process.env.E2E_SHARD_INDEX === undefined && process.env.TEST_SHARD_INDEX === undefined ? undefined : Number(process.env.E2E_SHARD_INDEX ?? 0) * Number(process.env.TEST_TOTAL_SHARDS ?? 1) + Number(process.env.TEST_SHARD_INDEX ?? 0)), }; /** * Set the error code of the process to 255. This is to ensure that if something forces node * to exit without finishing properly, the error code will be 255. Right now that code is not used. * * - 1 When tests succeed we already call `process.exit(0)`, so this doesn't change any correct * behaviour. * * One such case that would force node <= v6 to exit with code 0, is a Promise that doesn't resolve. */ process.exitCode = 255; /** * Mark this process as the main e2e_runner */ process.env.LEGACY_CLI_RUNNER = '1'; /** * Add external git toolchain onto PATH */ if (process.env.GIT_BIN) { process.env.PATH = process.env.PATH! + delimiter + dirname(process.env.GIT_BIN!); } /** * Add external browser toolchains onto PATH */ if (process.env.CHROME_BIN) { process.env.PATH = process.env.PATH! + delimiter + dirname(process.env.CHROME_BIN!); } const logger = createConsoleLogger(argv.verbose, process.stdout, process.stderr, { info: (s) => s, debug: (s) => s, warn: (s) => colors.bold.yellow(s), error: (s) => colors.bold.red(s), fatal: (s) => colors.bold.red(s), }); const logStack = [logger]; function lastLogger() { return logStack[logStack.length - 1]; } // Under bazel the compiled file (.js) and types (.d.ts) are available. const SRC_FILE_EXT_RE = /\.js$/; const testGlob = argv.glob?.replace(/\.ts$/, '.js') || `tests/**/*.js`; const e2eRoot = path.join(__dirname, 'e2e'); const allSetups = glob.sync(`setup/**/*.js`, { cwd: e2eRoot }).sort(); const allInitializers = glob.sync(`initialize/**/*.js`, { cwd: e2eRoot }).sort(); const allTests = glob .sync(testGlob, { cwd: e2eRoot, ignore: argv.ignore }) // Replace windows slashes. .map((name) => name.replace(/\\/g, '/')) .filter((name) => { if (name.endsWith('/setup.js')) { return false; } if (!SRC_FILE_EXT_RE.test(name)) { return false; } // The below is to exclude specific tests that are not intented to run for the current package manager. // This is also important as without the trickery the tests that take the longest ex: update.ts (2.5mins) // will be executed on the same shard. const fileName = path.basename(name); if ( (fileName.startsWith('yarn-') && argv['package-manager'] !== 'yarn') || (fileName.startsWith('npm-') && argv['package-manager'] !== 'npm') ) { return false; } return true; }) .sort(); const shardId = argv['shard'] !== undefined ? Number(argv['shard']) : null; const nbShards = shardId === null ? 1 : Number(argv['nb-shards']); const tests = allTests.filter((name) => { // Check for naming tests on command line. if (argv._.length == 0) { return true; } return argv._.some((argName) => { return ( path.join(process.cwd(), argName + '') == path.join(__dirname, 'e2e', name) || argName == name || argName == name.replace(SRC_FILE_EXT_RE, '') ); }); }); // Remove tests that are not part of this shard. const testsToRun = tests.filter((name, i) => shardId === null || i % nbShards == shardId); if (testsToRun.length === 0) { if (shardId !== null && tests.length <= shardId) { console.log(`No tests to run on shard ${shardId}, exiting.`); process.exit(0); } else { console.log(`No tests would be ran, aborting.`); process.exit(1); } } if (shardId !== null) { console.log(`Running shard ${shardId} of ${nbShards}`); } /** * Load all the files from the e2e, filter and sort them and build a promise of their default * export. */ if (testsToRun.length == allTests.length) { console.log(`Running ${testsToRun.length} tests`); } else { console.log(`Running ${testsToRun.length} tests (${allTests.length} total)`); } console.log(['Tests:', ...testsToRun].join('\n ')); setGlobalVariable('argv', argv); setGlobalVariable('package-manager', argv['package-manager']);
{ "end_byte": 7455, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e_runner.ts" }
angular-cli/tests/legacy-cli/e2e_runner.ts_7457_13689
// Use the chrome supplied by bazel or the puppeteer chrome and webdriver-manager driver outside. // This is needed by karma-chrome-launcher, protractor etc. // https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer // // Resolve from relative paths to absolute paths within the bazel runfiles tree // so subprocesses spawned in a different working directory can still find them. process.env.CHROME_BIN = path.resolve(process.env.CHROME_BIN!); process.env.CHROME_PATH = path.resolve(process.env.CHROME_PATH!); process.env.CHROMEDRIVER_BIN = path.resolve(process.env.CHROMEDRIVER_BIN!); Promise.all([findFreePort(), findFreePort(), findPackageTars()]) .then(async ([httpPort, httpsPort, packageTars]) => { setGlobalVariable('package-registry', 'http://localhost:' + httpPort); setGlobalVariable('package-secure-registry', 'http://localhost:' + httpsPort); setGlobalVariable('package-tars', packageTars); // NPM registries for the lifetime of the test execution const registryProcess = await createNpmRegistry(httpPort, httpPort); const secureRegistryProcess = await createNpmRegistry(httpPort, httpsPort, true); try { await runSteps(runSetup, allSetups, 'setup'); await runSteps(runInitializer, allInitializers, 'initializer'); await runSteps(runTest, testsToRun, 'test'); if (shardId !== null) { console.log(colors.green(`Done shard ${shardId} of ${nbShards}.`)); } else { console.log(colors.green('Done.')); } process.exitCode = 0; } catch (err) { if (err instanceof Error) { console.log('\n'); console.error(colors.red(err.message)); if (err.stack) { console.error(colors.red(err.stack)); } } else { console.error(colors.red(String(err))); } if (argv.debug) { console.log(`Current Directory: ${process.cwd()}`); console.log('Will loop forever while you debug... CTRL-C to quit.'); /* eslint-disable no-constant-condition */ while (1) { // That's right! } } process.exitCode = 1; } finally { registryProcess.kill(); secureRegistryProcess.kill(); } }) .catch((err) => { console.error(colors.red(`Unkown Error: ${err}`)); process.exitCode = 1; }); async function runSteps( run: (name: string) => Promise<void> | void, steps: string[], type: 'setup' | 'test' | 'initializer', ) { const capsType = type[0].toUpperCase() + type.slice(1); for (const [stepIndex, relativeName] of steps.entries()) { // Make sure this is a windows compatible path. let absoluteName = path.join(e2eRoot, relativeName).replace(SRC_FILE_EXT_RE, ''); if (/^win/.test(process.platform)) { absoluteName = absoluteName.replace(/\\/g, path.posix.sep); } const name = relativeName.replace(SRC_FILE_EXT_RE, ''); const start = Date.now(); printHeader(name, stepIndex, steps.length, type); // Run the test function with the current file on the logStack. logStack.push(lastLogger().createChild(absoluteName)); try { await run(absoluteName); } catch (e) { console.log('\n'); console.error(colors.red(`${capsType} "${name}" failed...`)); throw e; } finally { logStack.pop(); } console.log('----'); printFooter(name, type, start); } } function runSetup(absoluteName: string): Promise<void> { const module = require(absoluteName); return (typeof module === 'function' ? module : module.default)(); } /** * Run a file from the projects root directory in a subprocess via launchTestProcess(). */ function runInitializer(absoluteName: string): Promise<void> { process.chdir(getGlobalVariable('projects-root')); return launchTestProcess(absoluteName); } /** * Run a file from the main 'test-project' directory in a subprocess via launchTestProcess(). */ async function runTest(absoluteName: string): Promise<void> { process.chdir(join(getGlobalVariable('projects-root'), 'test-project')); await launchTestProcess(absoluteName); await gitClean(); } function printHeader( testName: string, testIndex: number, count: number, type: 'setup' | 'initializer' | 'test', ) { const text = `${testIndex + 1} of ${count}`; const fullIndex = testIndex * nbShards + (shardId ?? 0) + 1; const shard = shardId === null || type !== 'test' ? '' : colors.yellow(` [${shardId}:${nbShards}]` + colors.bold(` (${fullIndex}/${tests.length})`)); console.log( colors.green( `Running ${type} "${colors.bold.blue(testName)}" (${colors.bold.white(text)}${shard})...`, ), ); } function printFooter(testName: string, type: 'setup' | 'initializer' | 'test', startTime: number) { const capsType = type[0].toUpperCase() + type.slice(1); // Round to hundredth of a second. const t = Math.round((Date.now() - startTime) / 10) / 100; console.log( colors.green(`${capsType} "${colors.bold.blue(testName)}" took `) + colors.bold.blue('' + t) + colors.green('s...'), ); console.log(''); } // Collect the packages passed as arguments and return as {package-name => pkg-path} async function findPackageTars(): Promise<{ [pkg: string]: PkgInfo }> { const pkgs: string[] = (getGlobalVariable('argv').package as string[]).flatMap((p) => glob.sync(p), ); const pkgJsons = await Promise.all( pkgs .map((pkg) => realpathSync(pkg)) .map(async (pkg) => { try { return await extractFile(pkg, './package/package.json'); } catch (e) { // TODO(bazel): currently the bazel npm packaging does not contain the standard npm ./package directory return await extractFile(pkg, './package.json'); } }), ); return pkgs.reduce( (all, pkg, i) => { const json = pkgJsons[i].toString('utf8'); const { name, version } = JSON.parse(json) as { name: string; version: string }; if (!name) { throw new Error(`Package ${pkg} - package.json name/version not found`); } all[name] = { path: realpathSync(pkg), name, version }; return all; }, {} as { [pkg: string]: PkgInfo }, ); }
{ "end_byte": 13689, "start_byte": 7457, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e_runner.ts" }
angular-cli/tests/legacy-cli/e2e/initialize/300-log-environment.ts_0_623
import { getActivePackageManager } from '../utils/packages'; import { exec, ng } from '../utils/process'; export default async function () { console.log('Environment:'); Object.keys(process.env).forEach((envName) => { // CI Logs should not contain environment variables that are considered secret const lowerName = envName.toLowerCase(); if (lowerName.includes('key') || lowerName.includes('secret')) { return; } console.log(` ${envName}: ${process.env[envName]!.replace(/[\n\r]+/g, '\n ')}`); }); await exec('which', 'ng', getActivePackageManager()); await ng('version'); }
{ "end_byte": 623, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/initialize/300-log-environment.ts" }
angular-cli/tests/legacy-cli/e2e/initialize/BUILD.bazel_0_283
load("//tools:defaults.bzl", "ts_library") ts_library( name = "initialize", testonly = True, srcs = glob(["**/*.ts"]), data = [ "//:config-files", ], visibility = ["//visibility:public"], deps = [ "//tests/legacy-cli/e2e/utils", ], )
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/initialize/BUILD.bazel" }
angular-cli/tests/legacy-cli/e2e/initialize/500-create-project.ts_0_1906
import { join } from 'path'; import { getGlobalVariable } from '../utils/env'; import { expectFileToExist } from '../utils/fs'; import { gitClean } from '../utils/git'; import { setRegistry as setNPMConfigRegistry } from '../utils/packages'; import { ng } from '../utils/process'; import { prepareProjectForE2e, updateJsonFile } from '../utils/project'; export default async function () { const argv: Record<string, unknown> = getGlobalVariable('argv'); if (argv.noproject) { return; } if (argv.reuse && typeof argv.reuse === 'string') { process.chdir(argv.reuse); await gitClean(); } else { // Ensure local test registry is used when outside a project await setNPMConfigRegistry(true); await ng('new', 'test-project', '--skip-install'); await expectFileToExist(join(process.cwd(), 'test-project')); process.chdir('./test-project'); // Setup esbuild builder if requested on the commandline const useWebpackBuilder = !getGlobalVariable('argv')['esbuild']; if (useWebpackBuilder) { await updateJsonFile('angular.json', (json) => { const build = json['projects']['test-project']['architect']['build']; build.builder = '@angular-devkit/build-angular:browser'; build.options = { ...build.options, main: build.options.browser, browser: undefined, outputPath: 'dist/test-project/browser', }; build.configurations.development = { ...build.configurations.development, vendorChunk: true, namedChunks: true, buildOptimizer: false, }; }); await updateJsonFile('tsconfig.json', (tsconfig) => { delete tsconfig.compilerOptions.esModuleInterop; tsconfig.compilerOptions.allowSyntheticDefaultImports = true; }); } } await prepareProjectForE2e('test-project'); await ng('version'); }
{ "end_byte": 1906, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/initialize/500-create-project.ts" }
angular-cli/tests/legacy-cli/e2e/setup/200-create-project-dir.ts_0_636
import { mkdir } from 'fs/promises'; import { join } from 'path'; import { getGlobalVariable, setGlobalVariable } from '../utils/env'; /** * Create a parent directory for test projects to be created within. * Change the cwd() to that directory in preparation for launching the cli. */ export default async function () { const tempRoot: string = getGlobalVariable('tmp-root'); const projectsRoot = join(tempRoot, 'e2e-test'); setGlobalVariable('projects-root', projectsRoot); await mkdir(projectsRoot); console.log(` Using "${projectsRoot}" as temporary directory for a new project.`); process.chdir(projectsRoot); }
{ "end_byte": 636, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/setup/200-create-project-dir.ts" }
angular-cli/tests/legacy-cli/e2e/setup/100-global-cli.ts_0_761
import { getGlobalVariable } from '../utils/env'; import { getActivePackageManager } from '../utils/packages'; import { globalNpm } from '../utils/process'; const PACKAGE_MANAGER_VERSION = { 'npm': '10.8.1', 'yarn': '1.22.22', 'pnpm': '9.3.0', 'bun': '1.1.13', }; export default async function () { const argv = getGlobalVariable('argv'); if (argv.noglobal) { return; } const testRegistry = getGlobalVariable('package-registry'); const packageManager = getActivePackageManager(); // Install global Angular CLI being tested, npm+yarn used by e2e tests. await globalNpm([ 'install', '--global', `--registry=${testRegistry}`, '@angular/cli', `${packageManager}@${PACKAGE_MANAGER_VERSION[packageManager]}`, ]); }
{ "end_byte": 761, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/setup/100-global-cli.ts" }
angular-cli/tests/legacy-cli/e2e/setup/002-npm-sandbox.ts_0_2497
import { mkdir, writeFile } from 'fs/promises'; import { join } from 'path'; import { getGlobalVariable, setGlobalVariable } from '../utils/env'; /** * Configure npm to use a unique sandboxed environment. */ export default async function () { const tempRoot: string = getGlobalVariable('tmp-root'); const npmModulesPrefix = join(tempRoot, 'npm-global'); const yarnModulesPrefix = join(tempRoot, 'yarn-global'); const npmRegistry: string = getGlobalVariable('package-registry'); const npmrc = join(tempRoot, '.npmrc'); const yarnrc = join(tempRoot, '.yarnrc'); // Change the npm+yarn userconfig to the sandboxed npmrc to override the default ~ process.env.NPM_CONFIG_USERCONFIG = npmrc; // The npm+yarn registry URL process.env.NPM_CONFIG_REGISTRY = npmRegistry; // Configure npm+yarn to use a sandboxed bin directory // From this point onward all yarn/npm bin files/symlinks are put into the prefix directories process.env.NPM_CONFIG_PREFIX = npmModulesPrefix; process.env.YARN_CONFIG_PREFIX = yarnModulesPrefix; // Put the npm+yarn caches in the temp dir process.env.NPM_CONFIG_CACHE = join(tempRoot, 'npm-cache'); process.env.YARN_CACHE_FOLDER = join(tempRoot, 'yarn-cache'); // Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch). // In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests. // To support this case, legacy peer dependency mode is enabled for snapshot builds. if (getGlobalVariable('argv')['ng-snapshots']) { process.env['NPM_CONFIG_legacy_peer_deps'] = 'true'; } // Configure the registry and prefix used within the test sandbox via rc files await writeFile(npmrc, `registry=${npmRegistry}\nprefix=${npmModulesPrefix}`); await writeFile(yarnrc, `registry ${npmRegistry}\nprefix ${yarnModulesPrefix}`); await mkdir(npmModulesPrefix); await mkdir(yarnModulesPrefix); setGlobalVariable('npm-global', npmModulesPrefix); setGlobalVariable('yarn-global', yarnModulesPrefix); // Disable all update/notification related npm/yarn features such as the NPM updater notifier. // The NPM updater notifier may prevent the child process from closing until it timeouts after 3 minutes. process.env.NO_UPDATE_NOTIFIER = '1'; process.env.NPM_CONFIG_UPDATE_NOTIFIER = 'false'; console.log(` Using "${npmModulesPrefix}" as e2e test global npm bin dir.`); console.log(` Using "${yarnModulesPrefix}" as e2e test global yarn bin dir.`); }
{ "end_byte": 2497, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/setup/002-npm-sandbox.ts" }
angular-cli/tests/legacy-cli/e2e/setup/BUILD.bazel_0_231
load("//tools:defaults.bzl", "ts_library") ts_library( name = "setup", testonly = True, srcs = glob(["**/*.ts"]), visibility = ["//visibility:public"], deps = [ "//tests/legacy-cli/e2e/utils", ], )
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/setup/BUILD.bazel" }
angular-cli/tests/legacy-cli/e2e/setup/010-local-publish.ts_0_950
import { writeFile } from 'node:fs/promises'; import { join } from 'node:path/posix'; import { getGlobalVariable } from '../utils/env'; import { PkgInfo } from '../utils/packages'; import { globalNpm, extractNpmEnv } from '../utils/process'; import { isPrereleaseCli } from '../utils/project'; export default async function () { const testRegistry: string = getGlobalVariable('package-registry'); const packageTars: PkgInfo[] = Object.values(getGlobalVariable('package-tars')); const npmrc = join(getGlobalVariable('tmp-root'), '.npmrc-publish'); await writeFile( npmrc, ` ${testRegistry.replace(/^https?:/, '')}/:_authToken=fake-secret `, ); // Publish packages specified with --package await Promise.all( packageTars.map(({ path: p }) => globalNpm(['publish', '--tag', isPrereleaseCli() ? 'next' : 'latest', p], { ...extractNpmEnv(), 'NPM_CONFIG_USERCONFIG': npmrc, }), ), ); }
{ "end_byte": 950, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/setup/010-local-publish.ts" }
angular-cli/tests/legacy-cli/e2e/setup/001-create-tmp-dir.ts_0_607
import { dirname } from 'path'; import { getGlobalVariable, setGlobalVariable } from '../utils/env'; import { mktempd } from '../utils/utils'; export default async function () { const argv = getGlobalVariable('argv'); // Get to a temporary directory. let tempRoot: string; if (argv.reuse) { tempRoot = dirname(argv.reuse); } else if (argv.tmpdir) { tempRoot = argv.tmpdir; } else { tempRoot = await mktempd('angular-cli-e2e-', process.env.E2E_TEMP); } console.log(` Using "${tempRoot}" as temporary directory for a new project.`); setGlobalVariable('tmp-root', tempRoot); }
{ "end_byte": 607, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/setup/001-create-tmp-dir.ts" }
angular-cli/tests/legacy-cli/e2e/tests/BUILD.bazel_0_436
load("//tools:defaults.bzl", "ts_library") ts_library( name = "tests", testonly = True, srcs = glob(["**/*.ts"]), data = [ "//tests/legacy-cli/e2e/ng-snapshot", ], visibility = ["//visibility:public"], deps = [ "//tests/legacy-cli/e2e/utils", "@npm//@types/express", "@npm//@types/semver", "@npm//express", "@npm//fast-glob", "@npm//semver", ], )
{ "end_byte": 436, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/BUILD.bazel" }
angular-cli/tests/legacy-cli/e2e/tests/misc/target-default-configuration.ts_0_1196
import { expectFileToExist } from '../../utils/fs'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; export default async function () { await updateJsonFile('angular.json', (workspace) => { const build = workspace.projects['test-project'].architect.build; build.defaultConfiguration = undefined; build.options = { ...build.options, optimization: false, buildOptimizer: false, outputHashing: 'none', sourceMap: true, }; }); await ng('build'); await expectFileToExist('dist/test-project/browser/main.js'); await expectFileToExist('dist/test-project/browser/main.js.map'); // Add new configuration and set "defaultConfiguration" await updateJsonFile('angular.json', (workspace) => { const build = workspace.projects['test-project'].architect.build; build.defaultConfiguration = 'foo'; build.configurations.foo = { sourceMap: false, }; }); await ng('build'); await expectFileToExist('dist/test-project/browser/main.js'); await expectToFail(() => expectFileToExist('dist/test-project/browser/main.js.map')); }
{ "end_byte": 1196, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/target-default-configuration.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/nested-schematic-packages.ts_0_410
import { copyAssets } from '../../utils/assets'; import { expectFileToExist } from '../../utils/fs'; import { ng } from '../../utils/process'; export default async function () { await copyAssets('nested-schematic-main', 'nested'); await copyAssets('nested-schematic-dependency', 'nested/node_modules/empty-app-nested'); await ng('generate', './nested:test'); await expectFileToExist('empty-file'); }
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/nested-schematic-packages.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts_0_2169
import { expectFileToMatch, rimraf, writeFile } from '../../utils/fs'; import { gitClean } from '../../utils/git'; import { installWorkspacePackages } from '../../utils/packages'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; export default async function () { try { // Force duplicate modules await updateJsonFile('package.json', (json) => { json.dependencies = { ...json.dependencies, 'tslib': '2.0.0', 'tslib-1': 'npm:[email protected]', 'tslib-1-copy': 'npm:[email protected]', }; }); await installWorkspacePackages(); await writeFile( './src/main.ts', ` import { __assign as __assign_0 } from 'tslib'; import { __assign as __assign_1 } from 'tslib-1'; import { __assign as __assign_2 } from 'tslib-1-copy'; console.log({ __assign_0, __assign_1, __assign_2, }) `, ); const { stderr } = await ng( 'build', '--verbose', '--no-vendor-chunk', '--no-progress', '--configuration=development', ); const outFile = 'dist/test-project/browser/main.js'; if (/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy.+ -> .+tslib-1.+/.test(stderr)) { await expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js'); await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js'), ); } else if (/\[DedupeModuleResolvePlugin\]:.+tslib-1.+ -> .+tslib-1-copy.+/.test(stderr)) { await expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js'); await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js')); } else { console.error(`\n\n\n${stderr}\n\n\n`); throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.'); } await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js'); } finally { await rimraf('node_modules/tslib'); await gitClean(); await installWorkspacePackages(); } }
{ "end_byte": 2169, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts_0_840
import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.traceResolution = true; }); const { stdout: stdoutTraced } = await ng('build', '--configuration=development'); if (!/Resolving module/.test(stdoutTraced)) { throw new Error(`Modules resolutions must be printed when 'traceResolution' is enabled.`); } await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.traceResolution = false; }); const { stdout: stdoutUnTraced } = await ng('build', '--configuration=development'); if (/Resolving module/.test(stdoutUnTraced)) { throw new Error(`Modules resolutions must not be printed when 'traceResolution' is disabled.`); } }
{ "end_byte": 840, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/fallback.ts_0_1439
import * as assert from 'assert'; import { killAllProcesses } from '../../utils/process'; import { ngServe } from '../../utils/project'; import { updateJsonFile } from '../../utils/project'; import { moveFile } from '../../utils/fs'; export default function () { // TODO(architect): Delete this test. It is now in devkit/build-angular. // should fallback to config.app[0].index (index.html by default) return ( Promise.resolve() .then(() => ngServe()) .then((port) => fetch(`http://localhost:${port}/`, { headers: { 'Accept': 'text/html' } })) .then(async (response) => { assert.strictEqual(response.status, 200); assert.match(await response.text(), /<app-root><\/app-root>/); }) .finally(() => killAllProcesses()) // should correctly fallback to a changed index .then(() => moveFile('src/index.html', 'src/not-index.html')) .then(() => updateJsonFile('angular.json', (workspaceJson) => { const appArchitect = workspaceJson.projects['test-project'].architect; appArchitect.build.options.index = 'src/not-index.html'; }), ) .then(() => ngServe()) .then((port) => fetch(`http://localhost:${port}/`, { headers: { 'Accept': 'text/html' } })) .then(async (response) => { assert.strictEqual(response.status, 200); assert.match(await response.text(), /<app-root><\/app-root>/); }) ); }
{ "end_byte": 1439, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/fallback.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/supported-angular.ts_0_1592
import { SemVer } from 'semver'; import { getGlobalVariable } from '../../utils/env'; import { readFile, writeFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { if (getGlobalVariable('argv')['ng-snapshots']) { // The snapshots job won't work correctly because it doesn't use semver for Angular. return; } const angularCliPkgJson = JSON.parse(await readFile('node_modules/@angular/cli/package.json')); const cliMajor = new SemVer(angularCliPkgJson.version as string).major; const angularCorePkgPath = 'node_modules/@angular/core/package.json'; const originalAngularCorePkgJson = await readFile(angularCorePkgPath); // Fake version by writing over the @angular/core version, since that's what the CLI checks. const fakeCoreVersion = async (newMajor: number) => { const tmpPkgJson = JSON.parse(originalAngularCorePkgJson); tmpPkgJson.version = `${newMajor}.0.0`; await writeFile(angularCorePkgPath, JSON.stringify(tmpPkgJson)); }; // Major should succeed, but we don't need to test it here since it's tested everywhere else. // Major+1 and -1 should fail architect commands, but allow other commands. try { await fakeCoreVersion(cliMajor + 1); await expectToFail(() => ng('build'), 'Should fail Major+1'); await ng('version'); await fakeCoreVersion(cliMajor - 1); await ng('version'); } finally { // Restore the original core package.json. await writeFile(angularCorePkgPath, originalAngularCorePkgJson); } }
{ "end_byte": 1592, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/supported-angular.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/negated-boolean-options.ts_0_542
import { copyAssets } from '../../utils/assets'; import { execAndWaitForOutputToMatch } from '../../utils/process'; export default async function () { await copyAssets('schematic-boolean-option-negated', 'schematic-boolean-option-negated'); await execAndWaitForOutputToMatch( 'ng', ['generate', './schematic-boolean-option-negated:test', '--no-watch'], /noWatch: true/, ); await execAndWaitForOutputToMatch( 'ng', ['generate', './schematic-boolean-option-negated:test', '--watch'], /noWatch: false/, ); }
{ "end_byte": 542, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/negated-boolean-options.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/browsers.ts_0_1609
import express from 'express'; import * as path from 'path'; import { copyProjectAsset } from '../../utils/assets'; import { replaceInFile } from '../../utils/fs'; import { ng } from '../../utils/process'; export default async function () { // Ensure SauceLabs configuration if (!process.env['SAUCE_USERNAME'] || !process.env['SAUCE_ACCESS_KEY']) { throw new Error('SauceLabs is not configured.'); } // Workaround for https://github.com/angular/angular/issues/32192 await replaceInFile('src/app/app.component.html', /class="material-icons"/g, ''); await ng('build'); // Add Protractor configuration await copyProjectAsset('protractor-saucelabs.conf.js', 'e2e/protractor-saucelabs.conf.js'); // Remove browser log checks as they are only supported with the chrome webdriver await replaceInFile( 'e2e/src/app.e2e-spec.ts', 'await browser.manage().logs().get(logging.Type.BROWSER)', '[] as any', ); // Workaround defect in getText WebDriver implementation for Safari/Edge // Leading and trailing space is not removed await replaceInFile( 'e2e/src/app.e2e-spec.ts', 'await page.getTitleText()', '(await page.getTitleText()).trim()', ); // Setup server const app = express(); app.use(express.static(path.resolve('dist/test-project/browser'))); const server = app.listen(2000, 'localhost'); try { // Execute application's E2E tests with SauceLabs await ng( 'e2e', 'test-project', '--protractor-config=e2e/protractor-saucelabs.conf.js', '--dev-server-target=', ); } finally { server.close(); } }
{ "end_byte": 1609, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/browsers.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/workspace-verification.ts_0_492
import { deleteFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default function () { return ( ng('generate', 'component', 'foo', '--dry-run') .then(() => deleteFile('angular.json')) // fails because it needs to be inside a project // without a workspace file .then(() => expectToFail(() => ng('generate', 'component', 'foo', '--dry-run'))) .then(() => ng('version')) ); }
{ "end_byte": 492, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/workspace-verification.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/ask-missing-builder.ts_0_714
import { execAndWaitForOutputToMatch, killAllProcesses } from '../../utils/process'; export default async function () { // Execute a command with TTY force enabled and check that the prompt is shown. await execAndWaitForOutputToMatch( 'ng', ['deploy'], /Would you like to add a package with "deploy" capabilities/, { ...process.env, NG_FORCE_TTY: '1', NG_CLI_ANALYTICS: 'false', }, ); await killAllProcesses(); // Execute a command with TTY force enabled and check that the prompt is shown. await execAndWaitForOutputToMatch('ng', ['lint'], /Would you like to add ESLint now/, { ...process.env, NG_FORCE_TTY: '1', NG_CLI_ANALYTICS: 'false', }); }
{ "end_byte": 714, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/ask-missing-builder.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/es2015-nometa.ts_0_624
import { prependToFile, replaceInFile } from '../../utils/fs'; import { ng } from '../../utils/process'; export default async function () { await ng('generate', 'service', 'user'); // Update the application to use the new service await prependToFile('src/app/app.component.ts', "import { UserService } from './user.service';"); await replaceInFile( 'src/app/app.component.ts', 'export class AppComponent {', 'export class AppComponent {\n constructor(user: UserService) {}', ); // Execute the application's tests with emitDecoratorMetadata disabled (default) await ng('test', '--no-watch'); }
{ "end_byte": 624, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/es2015-nometa.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/http-headers.ts_0_1436
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { // This test ensures that ng e2e serves the HTTP headers that are configured // in the 'headers' field of the serve options. We do this by serving the // strictest possible CSP headers (default-src 'none') which blocks loading of // any resources (including scripts, styles and images) and should cause ng // e2e to fail with a CSP-related error, which is asserted below. await updateJsonFile('angular.json', (json) => { const serve = json['projects']['test-project']['architect']['serve']; if (!serve['options']) serve['options'] = {}; serve['options']['headers'] = { 'Content-Security-Policy': "default-src 'none'", }; }); let errorMessage: string | null = null; try { await ng('e2e'); } catch (error) { errorMessage = error instanceof Error ? error.message : null; } if (!errorMessage) { throw new Error( 'Application loaded successfully, indicating that the CSP headers were not served.', ); } if (!errorMessage.match(/Refused to load/)) { throw new Error('Expected to see CSP loading failure in error logs.'); } }
{ "end_byte": 1436, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/http-headers.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/duplicate-command-line-option.ts_0_569
import { ng } from '../../utils/process'; import { expectFileToExist } from '../../utils/fs'; export default async function () { const { stderr } = await ng( 'generate', 'component', 'test-component', '--style=scss', '--style=sass', ); const warningMatch = `Option 'style' has been specified multiple times. The value 'sass' will be used`; if (!stderr.includes(warningMatch)) { throw new Error(`Expected stderr to contain: "${warningMatch}".`); } await expectFileToExist('src/app/test-component/test-component.component.sass'); }
{ "end_byte": 569, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/duplicate-command-line-option.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/proxy-config.ts_0_1337
import express from 'express'; import * as http from 'http'; import { writeFile } from '../../utils/fs'; import { ngServe } from '../../utils/project'; import { AddressInfo } from 'net'; import * as assert from 'assert'; export default function () { // TODO(architect): Delete this test. It is now in devkit/build-angular. // Create an express app that serves as a proxy. const app = express(); const server = http.createServer(app); server.listen(0); app.set('port', (server.address() as AddressInfo).port); app.get('/api/test', function (req, res) { res.send('TEST_API_RETURN'); }); const backendHost = 'localhost'; const backendPort = (server.address() as AddressInfo).port; const proxyServerUrl = `http://${backendHost}:${backendPort}`; const proxyConfigFile = 'proxy.config.json'; const proxyConfig = { '/api/*': { target: proxyServerUrl, }, }; return Promise.resolve() .then(() => writeFile(proxyConfigFile, JSON.stringify(proxyConfig, null, 2))) .then(() => ngServe('--proxy-config', proxyConfigFile)) .then((port) => fetch(`http://localhost:${port}/api/test`)) .then(async (response) => { assert.strictEqual(response.status, 200); assert.match(await response.text(), /TEST_API_RETURN/); }) .finally(() => { server.close(); }); }
{ "end_byte": 1337, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/proxy-config.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/multiple-targets.ts_0_382
import { expectFileToExist } from '../../utils/fs'; import { ng } from '../../utils/process'; export default async function () { await ng('generate', 'app', 'secondary-app'); await ng('build', 'secondary-app', '--configuration=development'); await expectFileToExist('dist/secondary-app/browser/index.html'); await expectFileToExist('dist/secondary-app/browser/main.js'); }
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/multiple-targets.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/e2e-host.ts_0_772
import * as os from 'os'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { const interfaces = Object.values(os.networkInterfaces()).flat() as os.NetworkInterfaceInfo[]; let host = ''; for (const { family, address, internal } of interfaces) { if (family === 'IPv4' && !internal) { host = address; break; } } await updateJsonFile('angular.json', (workspaceJson) => { const appArchitect = workspaceJson.projects['test-project'].architect; appArchitect.serve.options = appArchitect.serve.options || {}; appArchitect.serve.options.port = 8888; appArchitect.serve.options.host = host; }); await ng('e2e'); await ng('e2e', '--host', host); }
{ "end_byte": 772, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/e2e-host.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/trusted-types.ts_0_2293
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { replaceInFile, writeFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { // Add lazy route. await ng('generate', 'component', 'lazy'); await replaceInFile( 'src/app/app.routes.ts', 'routes: Routes = [];', `routes: Routes = [{path: 'lazy', loadComponent: () => import('./lazy/lazy.component').then(c => c.LazyComponent)}];`, ); // Add lazy route e2e await writeFile( 'e2e/src/app.e2e-spec.ts', ` import { browser, logging, element, by } from 'protractor'; describe('workspace-project App', () => { it('should display lazy route', async () => { await browser.get(browser.baseUrl + '/lazy'); expect(await element(by.css('app-lazy p')).getText()).toEqual('lazy works!'); }); afterEach(async () => { // Assert that there are no errors emitted from the browser const logs = await browser.manage().logs().get(logging.Type.BROWSER); expect(logs).not.toContain(jasmine.objectContaining({ level: logging.Level.SEVERE, })); }); }); `, ); const testCases = [ { aot: false, csp: `trusted-types angular angular#unsafe-bypass angular#unsafe-jit angular#bundler; require-trusted-types-for 'script';`, }, { aot: true, csp: `trusted-types angular angular#unsafe-bypass angular#bundler; require-trusted-types-for 'script';`, }, ]; for (const { aot, csp } of testCases) { await updateJsonFile('angular.json', (json) => { const architect = json['projects']['test-project']['architect']; architect['build']['options']['aot'] = aot; if (!architect['serve']['options']) architect['serve']['options'] = {}; architect['serve']['options']['headers'] = { 'Content-Security-Policy': csp, }; }); try { await ng('e2e'); } catch (error) { console.error(`Test case AOT ${aot} with CSP header ${csp} failed.`); throw error; } } }
{ "end_byte": 2293, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/trusted-types.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/create-angular.ts_0_1741
import { equal } from 'node:assert'; import { join, resolve } from 'node:path'; import { expectFileToExist, readFile, rimraf } from '../../utils/fs'; import { getActivePackageManager } from '../../utils/packages'; import { silentBun, silentNpm, silentPnpm, silentYarn } from '../../utils/process'; export default async function () { const currentDirectory = process.cwd(); const newDirectory = resolve('../'); const projectName = 'test-project-create'; try { process.chdir(newDirectory); const packageManager = getActivePackageManager(); switch (packageManager) { case 'npm': await silentNpm('init', '@angular', projectName, '--', '--style=scss'); break; case 'yarn': await silentYarn('create', '@angular', projectName, '--style=scss'); break; case 'bun': await silentBun('create', '@angular', projectName, '--style=scss'); break; case 'pnpm': await silentPnpm('create', '@angular', projectName, '--style=scss'); break; default: throw new Error(`This test is not configured to use ${packageManager}.`); } // Check that package manager has been configured based on the package manager used to invoke the create command. const workspace = JSON.parse(await readFile(join(projectName, 'angular.json'))); equal( workspace.cli?.packageManager, packageManager, `Expected 'packageManager' option to be configured to ${packageManager}.`, ); // Verify styles was create with correct extension. await expectFileToExist(join(projectName, 'src/styles.scss')); } finally { await rimraf(projectName); // Change directory back process.chdir(currentDirectory); } }
{ "end_byte": 1741, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/create-angular.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/loaders-resolution.ts_0_1320
import { createDir, moveFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { assertIsError } from '../../utils/utils'; export default async function () { await createDir('node_modules/@angular-devkit/build-angular/node_modules'); let originalInRootNodeModules = true; try { await moveFile( 'node_modules/@ngtools', 'node_modules/@angular-devkit/build-angular/node_modules/@ngtools', ); } catch (e) { assertIsError(e); if (e.code !== 'ENOENT') { throw e; } // In some cases due to module resolution '@ngtools' might already been under `@angular-devkit/build-angular`. originalInRootNodeModules = false; await moveFile( 'node_modules/@angular-devkit/build-angular/node_modules/@ngtools', 'node_modules/@ngtools', ); } await ng('build', '--configuration=development'); // Move it back. await moveBack(originalInRootNodeModules); } function moveBack(originalInRootNodeModules: Boolean): Promise<void> { return originalInRootNodeModules ? moveFile( 'node_modules/@angular-devkit/build-angular/node_modules/@ngtools', 'node_modules/@ngtools', ) : moveFile( 'node_modules/@ngtools', 'node_modules/@angular-devkit/build-angular/node_modules/@ngtools', ); }
{ "end_byte": 1320, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/loaders-resolution.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/invalid-schematic-dependencies.ts_0_2056
import { join } from 'node:path'; import { expectFileToMatch } from '../../utils/fs'; import { execWithEnv, extractNpmEnv, ng, silentNpm } from '../../utils/process'; import { getActivePackageManager, installPackage, uninstallPackage } from '../../utils/packages'; import { isPrereleaseCli } from '../../utils/project'; import { appendFile, writeFile } from 'node:fs/promises'; import { getGlobalVariable } from '../../utils/env'; export default async function () { // Must publish old version to local registry to allow install. This is especially important // for release commits as npm will try to request tooling packages that are not on the npm registry yet await publishOutdated('@schematics/angular@7'); await publishOutdated('@angular-devkit/core@7'); await publishOutdated('@angular-devkit/schematics@7'); // Install outdated and incompatible version await installPackage('@schematics/angular@7'); const isPrerelease = await isPrereleaseCli(); const tag = isPrerelease ? '@next' : ''; if (getActivePackageManager() === 'npm') { await appendFile('.npmrc', '\nlegacy-peer-deps=true'); } await ng('add', `@angular/material${tag}`, '--skip-confirmation'); await expectFileToMatch('package.json', /@angular\/material/); // Clean up existing cdk package // Not doing so can cause adding material to fail if an incompatible cdk is present await uninstallPackage('@angular/cdk'); } async function publishOutdated(npmSpecifier: string): Promise<void> { const npmrc = join(getGlobalVariable('tmp-root'), '.npmrc-publish'); const testRegistry = (getGlobalVariable('package-registry') as string).replace(/^\w+:/, ''); await writeFile( npmrc, ` ${testRegistry.replace(/^https?:/, '')}/:_authToken=fake-secret `, ); const { stdout: stdoutPack } = await silentNpm( 'pack', npmSpecifier, '--registry=https://registry.npmjs.org', ); await execWithEnv('npm', ['publish', stdoutPack.trim(), '--tag=outdated'], { ...extractNpmEnv(), 'NPM_CONFIG_USERCONFIG': npmrc, }); }
{ "end_byte": 2056, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/invalid-schematic-dependencies.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/version.ts_0_675
import { deleteFile } from '../../utils/fs'; import { ng } from '../../utils/process'; export default async function () { const { stdout: commandOutput } = await ng('version'); if (commandOutput.includes(process.versions.node + ' (Unsupported)')) { throw new Error('Node version should not show unsupported entry'); } if (commandOutput.includes('Warning: The current version of Node ')) { throw new Error('Node support warning should not be shown'); } // doesn't fail on a project with missing angular.json await deleteFile('angular.json'); await ng('version'); // Doesn't fail outside a project. process.chdir('/'); await ng('version'); }
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/version.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/update-git-clean.ts_0_445
import { appendToFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { await appendToFile('src/main.ts', "console.log('changed');\n"); const { message } = await expectToFail(() => ng('update', '@angular/cli')); if (!message || !message.includes('Repository is not clean.')) { throw new Error('Expected unclean repository'); } }
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/update-git-clean.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/check-postinstalls.ts_0_1844
import glob from 'fast-glob'; import { readFile } from '../../utils/fs'; const CURRENT_SCRIPT_PACKAGES: ReadonlySet<string> = new Set([ 'esbuild (postinstall)', 'lmdb (install)', 'msgpackr-extract (install)', 'nice-napi (install)', ]); const POTENTIAL_SCRIPTS: ReadonlyArray<string> = ['preinstall', 'install', 'postinstall']; // Some packages include test and/or example code that causes false positives const FALSE_POSITIVE_PATHS: ReadonlySet<string> = new Set([ 'jasmine-spec-reporter/examples/protractor/package.json', 'resolve/test/resolver/multirepo/package.json', ]); const INNER_NODE_MODULES_SEGMENT = '/node_modules/'; export default async function () { const manifestPaths = await glob('node_modules/**/package.json'); const newPackages: string[] = []; for (const manifestPath of manifestPaths) { const lastNodeModuleIndex = manifestPath.lastIndexOf(INNER_NODE_MODULES_SEGMENT); const packageRelativePath = manifestPath.slice( lastNodeModuleIndex === -1 ? INNER_NODE_MODULES_SEGMENT.length - 1 : lastNodeModuleIndex + INNER_NODE_MODULES_SEGMENT.length, ); if (FALSE_POSITIVE_PATHS.has(packageRelativePath)) { continue; } let manifest; try { manifest = JSON.parse(await readFile(manifestPath)); } catch { continue; } if (!manifest.scripts) { continue; } for (const script of POTENTIAL_SCRIPTS) { if (!manifest.scripts[script]) { continue; } const packageScript = `${manifest.name} (${script})`; if (!CURRENT_SCRIPT_PACKAGES.has(packageScript)) { newPackages.push(packageScript + `[${manifestPath}]`); } } } if (newPackages.length) { throw new Error( 'New install script package(s) detected:\n' + JSON.stringify(newPackages, null, 2), ); } }
{ "end_byte": 1844, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/check-postinstalls.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts_0_5754
import { writeMultipleFiles } from '../../utils/fs'; import { installWorkspacePackages } from '../../utils/packages'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { await updateJsonFile('package.json', (packageJson) => { // Install NGRX packageJson['dependencies']['@ngrx/effects'] = '^14.3.0'; packageJson['dependencies']['@ngrx/schematics'] = '^14.3.0'; packageJson['dependencies']['@ngrx/store'] = '^14.3.0'; packageJson['dependencies']['@ngrx/store-devtools'] = '^14.3.0'; }); // Force is need to prevent npm 7+ from failing due to potential peer dependency resolution range errors. // This is especially common when testing snapshot builds for new prereleases. await installWorkspacePackages({ force: true }); await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.useDefineForClassFields = false; }); // Create an app that uses ngrx decorators and has e2e tests. await writeMultipleFiles({ './e2e/src/app.po.ts': ` import { browser, by, element } from 'protractor'; export class AppPage { async navigateTo() { return browser.get('/'); } getIncrementButton() { return element(by.buttonText('Increment')); } getDecrementButton() { return element(by.buttonText('Decrement')); } getResetButton() { return element(by.buttonText('Reset Counter')); } async getCounter() { return element(by.xpath('/html/body/app-root/div/span')).getText(); } } `, './e2e/src/app.e2e-spec.ts': ` import { AppPage } from './app.po'; describe('workspace-project App', () => { let page: AppPage; beforeEach(() => { page = new AppPage(); }); it('should operate counter', async () => { await page.navigateTo(); await page.getIncrementButton().click(); await page.getIncrementButton().click(); expect(await page.getCounter()).toEqual('2'); await page.getDecrementButton().click(); expect(await page.getCounter()).toEqual('1'); await page.getResetButton().click(); expect(await page.getCounter()).toEqual('0'); }); }); `, './src/app/app.component.ts': ` import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { Store, select } from '@ngrx/store'; import { Observable } from 'rxjs'; import { INCREMENT, DECREMENT, RESET } from './counter.reducer'; interface AppState { count: number; } @Component({ standalone: true, selector: 'app-root', imports: [CommonModule], template: \` <button (click)="increment()">Increment</button> <div>Current Count: <span>{{ count$ | async }}</span></div> <button (click)="decrement()">Decrement</button> <button (click)="reset()">Reset Counter</button> \`, }) export class AppComponent { count$: Observable<number>; constructor(private store: Store<AppState>) { this.count$ = store.pipe(select(state => state.count)); } increment() { this.store.dispatch({ type: INCREMENT }); } decrement() { this.store.dispatch({ type: DECREMENT }); } reset() { this.store.dispatch({ type: RESET }); } } `, './src/app/app.effects.ts': ` import { Injectable } from '@angular/core'; import { Actions, Effect } from '@ngrx/effects'; import { filter, map, tap } from 'rxjs/operators'; @Injectable() export class AppEffects { @Effect() mapper$ = this.actions$.pipe(map(() => ({ type: 'ANOTHER'})), filter(() => false)); @Effect({ dispatch: false }) logger$ = this.actions$.pipe(tap(console.log)); constructor(private actions$: Actions) {} } `, './src/app/app.config.ts': ` import { ApplicationConfig, importProvidersFrom } from '@angular/core'; import { provideRouter } from '@angular/router'; import { provideProtractorTestingSupport } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { StoreModule } from '@ngrx/store'; import { StoreDevtoolsModule } from '@ngrx/store-devtools'; import { EffectsModule } from '@ngrx/effects'; import { AppEffects } from './app.effects'; import { counterReducer } from './counter.reducer'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideProtractorTestingSupport(), provideRouter(routes), importProvidersFrom(StoreModule.forRoot({ count: counterReducer })), importProvidersFrom(StoreDevtoolsModule.instrument()), importProvidersFrom(EffectsModule.forRoot([AppEffects])), ] }; `, './src/app/counter.reducer.ts': ` import { Action } from '@ngrx/store'; export const INCREMENT = 'INCREMENT'; export const DECREMENT = 'DECREMENT'; export const RESET = 'RESET'; const initialState = 0; export function counterReducer(state: number = initialState, action: Action) { switch (action.type) { case INCREMENT: return state + 1; case DECREMENT: return state - 1; case RESET: return 0; default: return state; } } `, }); // Run the e2e tests against a production build. await ng('e2e', '--configuration=production'); }
{ "end_byte": 5754, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts_0_1578
import { appendToFile, replaceInFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { // Update the application to use a forward reference await replaceInFile( 'src/app/app.component.ts', "import { Component } from '@angular/core';", "import { Component, Inject, Injectable, forwardRef } from '@angular/core';", ); await appendToFile('src/app/app.component.ts', '\n@Injectable() export class Lock { }\n'); await replaceInFile( 'src/app/app.component.ts', 'export class AppComponent {', 'export class AppComponent {\n constructor(@Inject(forwardRef(() => Lock)) lock: Lock) {}', ); // Update the application's unit tests to include the new injectable await replaceInFile( 'src/app/app.component.spec.ts', "import { AppComponent } from './app.component';", "import { AppComponent, Lock } from './app.component';", ); await replaceInFile( 'src/app/app.component.spec.ts', 'TestBed.configureTestingModule({', 'TestBed.configureTestingModule({ providers: [Lock],', ); // Execute the application's tests with emitDecoratorMetadata disabled (default) await ng('test', '--no-watch'); // Turn on emitDecoratorMetadata await replaceInFile( 'tsconfig.json', '"experimentalDecorators": true', '"experimentalDecorators": true, "emitDecoratorMetadata": true', ); // Execute the application's tests with emitDecoratorMetadata enabled await expectToFail(() => ng('test', '--no-watch')); }
{ "end_byte": 1578, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/karma-error-paths.ts_0_825
import { writeMultipleFiles } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { await writeMultipleFiles({ 'src/app/app.component.spec.ts': ` describe('AppComponent', () => { it('failing test', () => { expect('1').toEqual('2'); }); }); `, }); const { message } = await expectToFail(() => ng('test', '--no-watch')); if (message.includes('_karma_webpack_')) { throw new Error(`Didn't expect logs to server address and webpack scheme.\n${message}`); } if (!message.includes('(src/app/app.component.spec.ts:4:25)')) { throw new Error( `Expected logs to contain relative path to (src/app/app.component.spec.ts:4:25)\n${message}`, ); } }
{ "end_byte": 825, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/karma-error-paths.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts_0_872
import { getGlobalVariable } from '../../utils/env'; import { createDir, writeFile } from '../../utils/fs'; import { ng, silentGit } from '../../utils/process'; import { prepareProjectForE2e } from '../../utils/project'; export default async function () { process.chdir(getGlobalVariable('projects-root')); await createDir('./subdirectory'); process.chdir('./subdirectory'); await silentGit('init', '.'); await ng('new', 'subdirectory-test-project', '--skip-install'); process.chdir('./subdirectory-test-project'); await prepareProjectForE2e('subdirectory-test-project'); await writeFile('../added.ts', "console.log('created');\n"); await silentGit('add', '../added.ts'); const { stderr } = await ng('update', '@angular/cli'); if (stderr && stderr.includes('Repository is not clean.')) { throw new Error('Expected clean repository'); } }
{ "end_byte": 872, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts" }
angular-cli/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-core-mapping.ts_0_1448
import { createDir, moveFile } from '../../../utils/fs'; import { ng } from '../../../utils/process'; import { updateJsonFile } from '../../../utils/project'; import { expectToFail } from '../../../utils/utils'; export default async function () { await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.paths = { '*': ['./node_modules/*'], }; }); await ng('build', '--configuration=development'); await createDir('xyz'); await moveFile('node_modules/@angular/platform-browser', 'xyz/platform-browser'); await expectToFail(() => ng('build', '--configuration=development')); await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.paths = { '@angular/platform-browser': ['./xyz/platform-browser'], }; }); await ng('build', '--configuration=development'); await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.paths = { '*': ['./node_modules/*'], '@angular/platform-browser': ['./xyz/platform-browser'], }; }); await ng('build', '--configuration=development'); await updateJsonFile('tsconfig.json', (tsconfig) => { tsconfig.compilerOptions.paths = { '@angular/platform-browser': ['./xyz/platform-browser'], '*': ['./node_modules/*'], }; }); await ng('build', '--configuration=development'); await moveFile('xyz/platform-browser', 'node_modules/@angular/platform-browser'); }
{ "end_byte": 1448, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/misc/module-resolution/module-resolution-core-mapping.ts" }
angular-cli/tests/legacy-cli/e2e/tests/web-test-runner/basic.ts_0_390
import { noSilentNg } from '../../utils/process'; import { applyWtrBuilder } from '../../utils/web-test-runner'; export default async function () { await applyWtrBuilder(); const { stderr } = await noSilentNg('test'); if (!stderr.includes('Web Test Runner builder is currently EXPERIMENTAL')) { throw new Error(`No experimental notice in stderr.\nSTDERR:\n\n${stderr}`); } }
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/web-test-runner/basic.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-scripts.ts_0_2568
import { writeMultipleFiles } from '../../utils/fs'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; export default async function () { // TODO(architect): Delete this test. It is now in devkit/build-angular. await ng('test', '--watch=false'); // prepare global scripts test files await writeMultipleFiles({ 'src/string-script.js': `stringScriptGlobal = 'string-scripts.js';`, 'src/input-script.js': `inputScriptGlobal = 'input-scripts.js';`, 'src/typings.d.ts': ` declare var stringScriptGlobal: any; declare var inputScriptGlobal: any; `, 'src/app/app.component.ts': ` import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: '', standalone: false }) export class AppComponent { stringScriptGlobalProp = stringScriptGlobal; inputScriptGlobalProp = inputScriptGlobal; } `, 'src/app/app.component.spec.ts': ` import { TestBed } from '@angular/core/testing'; import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(() => TestBed.configureTestingModule({ declarations: [AppComponent] })); it('should have access to string-script.js', () => { let app = TestBed.createComponent(AppComponent).debugElement.componentInstance; expect(app.stringScriptGlobalProp).toEqual('string-scripts.js'); }); it('should have access to input-script.js', () => { let app = TestBed.createComponent(AppComponent).debugElement.componentInstance; expect(app.inputScriptGlobalProp).toEqual('input-scripts.js'); }); }); describe('Spec', () => { it('should have access to string-script.js', () => { expect(stringScriptGlobal).toBe('string-scripts.js'); }); it('should have access to input-script.js', () => { expect(inputScriptGlobal).toBe('input-scripts.js'); }); }); `, }); // should fail because the global scripts were not added to scripts array await expectToFail(() => ng('test', '--watch=false')); await updateJsonFile('angular.json', (workspaceJson) => { const appArchitect = workspaceJson.projects['test-project'].architect; appArchitect.test.options.scripts = [ { input: 'src/string-script.js' }, { input: 'src/input-script.js' }, ]; }); // should pass now await ng('test', '--watch=false'); }
{ "end_byte": 2568, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-scripts.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-include-glob.ts_0_142
import { ng } from '../../utils/process'; export default async function () { await ng('test', '--no-watch', `--include='**/*.spec.ts'`); }
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-include-glob.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-sourcemap.ts_0_923
import { writeFile } from '../../utils/fs'; import { ng } from '../../utils/process'; export default async function () { await writeFile( 'src/app/app.component.spec.ts', ` it('show fail', () => { expect(undefined).toBeTruthy(); }); `, ); // when sourcemaps are 'on' the stacktrace will point to the spec.ts file. try { await ng('test', '--no-watch', '--source-map'); throw new Error('ng test should have failed.'); } catch (error) { if (!(error instanceof Error && error.message.includes('app.component.spec.ts'))) { throw error; } } // when sourcemaps are 'off' the stacktrace won't point to the spec.ts file. try { await ng('test', '--no-watch', '--no-source-map'); throw new Error('ng test should have failed.'); } catch (error) { if (!(error instanceof Error && error.message.includes('main.js'))) { throw error; } } }
{ "end_byte": 923, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-sourcemap.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-environment.ts_0_1754
import { ng } from '../../utils/process'; import { writeFile, writeMultipleFiles } from '../../utils/fs'; import { updateJsonFile } from '../../utils/project'; export default function () { // Tests run in 'dev' environment by default. return ( writeMultipleFiles({ 'src/environment.prod.ts': ` export const environment = { production: true };`, 'src/environment.ts': ` export const environment = { production: false }; `, 'src/app/environment.spec.ts': ` import { environment } from '../environment'; describe('Test environment', () => { it('should have production disabled', () => { expect(environment.production).toBe(false); }); }); `, }) .then(() => ng('test', '--watch=false')) .then(() => updateJsonFile('angular.json', (configJson) => { const appArchitect = configJson.projects['test-project'].architect; appArchitect.test.configurations = { production: { fileReplacements: [ { src: 'src/environment.ts', replaceWith: 'src/environment.prod.ts', }, ], }, }; }), ) // Tests can run in different environment. .then(() => writeFile( 'src/app/environment.spec.ts', ` import { environment } from '../environment'; describe('Test environment', () => { it('should have production enabled', () => { expect(environment.production).toBe(true); }); }); `, ), ) .then(() => ng('test', '--configuration=production', '--watch=false')) ); }
{ "end_byte": 1754, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-environment.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-fail-single-run.ts_0_449
import { ng } from '../../utils/process'; import { writeFile } from '../../utils/fs'; import { expectToFail } from '../../utils/utils'; export default function () { // TODO(architect): Delete this test. It is now in devkit/build-angular. // Fails on single run with broken compilation. return writeFile('src/app.component.spec.ts', '<p> definitely not typescript </p>').then(() => expectToFail(() => ng('test', '--watch=false')), ); }
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-fail-single-run.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-code-coverage-exclude.ts_0_788
import { expectFileToExist, rimraf } from '../../utils/fs'; import { silentNg } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { // This test is already in build-angular, but that doesn't run on Windows. await silentNg('test', '--no-watch', '--code-coverage'); await expectFileToExist('coverage/test-project/app.component.ts.html'); // Delete coverage directory await rimraf('coverage'); await silentNg( 'test', '--no-watch', '--code-coverage', `--code-coverage-exclude='src/**/app.component.ts'`, ); // Doesn't include excluded. await expectFileToExist('coverage/test-project/index.html'); await expectToFail(() => expectFileToExist('coverage/test-project/app.component.ts.html')); }
{ "end_byte": 788, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-code-coverage-exclude.ts" }
angular-cli/tests/legacy-cli/e2e/tests/test/test-jasmine-clock.ts_0_763
import { ng } from '../../utils/process'; import { writeFile } from '../../utils/fs'; export default async function () { await writeFile( 'src/app/app.component.spec.ts', ` import { TestBed } from '@angular/core/testing'; import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeAll(() => { jasmine.clock().install(); }); afterAll(() => { jasmine.clock().uninstall(); }); beforeEach(() => TestBed.configureTestingModule({ imports: [AppComponent] })); it('should create the app', () => { const fixture = TestBed.createComponent(AppComponent); expect(fixture.componentInstance).toBeTruthy(); }); }); `, ); await ng('test', '--watch=false'); }
{ "end_byte": 763, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/test/test-jasmine-clock.ts" }
angular-cli/tests/legacy-cli/e2e/tests/update/update-multiple-versions.ts_0_1695
import { createProjectFromAsset } from '../../utils/assets'; import { setRegistry } from '../../utils/packages'; import { ng } from '../../utils/process'; import { isPrereleaseCli } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; export default async function () { let restoreRegistry: (() => Promise<void>) | undefined; try { restoreRegistry = await createProjectFromAsset('15.0-project', true); await setRegistry(true); const extraArgs = ['--force']; if (isPrereleaseCli()) { extraArgs.push('--next'); } // TODO(alanagius): investigate how to re-enable this. This is failing but it's correct since we are using the public registry. // Update Angular from v13 to 14 // const { stdout } = await ng('update', ...extraArgs); // if (!/@angular\/core\s+13\.\d\.\d+ -> 14\.\d\.\d+\s+ng update @angular\/core@14/.test(stdout)) { // // @angular/core 13.x.x -> 14.x.x ng update @angular/core@14 // throw new Error( // `Output didn't match "@angular/core 13.x.x -> 14.x.x ng update @angular/core@14". OUTPUT: \n` + // stdout, // ); // } const { message } = await expectToFail(() => ng('update', '@angular/core', ...extraArgs)); if ( !message.includes( `Updating multiple major versions of '@angular/core' at once is not supported`, ) ) { throw new Error( `Expected error message to include "Updating multiple major versions of '@angular/core' at once is not supported" but didn't. OUTPUT: \n` + message, ); } } finally { await restoreRegistry?.(); } }
{ "end_byte": 1695, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/update/update-multiple-versions.ts" }
angular-cli/tests/legacy-cli/e2e/tests/update/update-application-builder.ts_0_1326
import { match } from 'node:assert'; import { createProjectFromAsset } from '../../utils/assets'; import { expectFileMatchToExist, expectFileNotToExist, expectFileToExist, expectFileToMatch, } from '../../utils/fs'; import { execAndWaitForOutputToMatch, ng, noSilentNg } from '../../utils/process'; import { findFreePort } from '../../utils/network'; export default async function () { await createProjectFromAsset('19-ssr-project-webpack', false, false); await ng('update', `@angular/cli`, '--name=use-application-builder'); await Promise.all([ expectFileNotToExist('tsconfig.server.json'), expectFileToMatch('tsconfig.json', 'esModuleInterop'), expectFileToMatch('src/server.ts', 'import.meta.url'), ]); // Verify project now creates bundles await noSilentNg('build', '--configuration=production'); await Promise.all([ expectFileToExist('dist/18-ssr-project-webpack/server/server.mjs'), expectFileMatchToExist('dist/18-ssr-project-webpack/browser', /main-[a-zA-Z0-9]{8}\.js/), ]); // Verify that the app runs const port = await findFreePort(); await execAndWaitForOutputToMatch('ng', ['serve', '--port', String(port)], /complete\./); const response = await fetch(`http://localhost:${port}/`); const text = await response.text(); match(text, /app is running!/); }
{ "end_byte": 1326, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/update/update-application-builder.ts" }
angular-cli/tests/legacy-cli/e2e/tests/update/update-secure-registry.ts_0_1822
import { exec, ng } from '../../utils/process'; import { createNpmConfigForAuthentication } from '../../utils/registry'; import { expectToFail } from '../../utils/utils'; import { isPrereleaseCli } from '../../utils/project'; import { getActivePackageManager } from '../../utils/packages'; import assert from 'node:assert'; export default async function () { // The environment variable has priority over the .npmrc delete process.env['NPM_CONFIG_REGISTRY']; const worksMessage = 'We analyzed your package.json'; const extraArgs: string[] = []; if (isPrereleaseCli()) { extraArgs.push('--next'); } // Valid authentication token await createNpmConfigForAuthentication(false); const { stdout: stdout1 } = await ng('update', ...extraArgs); if (!stdout1.includes(worksMessage)) { throw new Error(`Expected stdout to contain "${worksMessage}"`); } await createNpmConfigForAuthentication(true); const { stdout: stdout2 } = await ng('update', ...extraArgs); if (!stdout2.includes(worksMessage)) { throw new Error(`Expected stdout to contain "${worksMessage}"`); } // Invalid authentication token await createNpmConfigForAuthentication(false, true); await expectToFail(() => ng('update', ...extraArgs)); await createNpmConfigForAuthentication(true, true); await expectToFail(() => ng('update', ...extraArgs)); if (getActivePackageManager() === 'yarn') { // When running `ng update` using yarn (`yarn ng update`), yarn will set the `npm_config_registry` env variable to `https://registry.yarnpkg.com` // Validate the registry in the RC is used. await createNpmConfigForAuthentication(true, true); const error = await expectToFail(() => exec('yarn', 'ng', 'update', ...extraArgs)); assert.match(error.message, /not allowed to access package/); } }
{ "end_byte": 1822, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/update/update-secure-registry.ts" }
angular-cli/tests/legacy-cli/e2e/tests/update/update.ts_0_4502
import { appendFile } from 'fs/promises'; import { SemVer } from 'semver'; import { createProjectFromAsset } from '../../utils/assets'; import { expectFileMatchToExist, readFile } from '../../utils/fs'; import { getActivePackageManager } from '../../utils/packages'; import { ng, noSilentNg } from '../../utils/process'; import { isPrereleaseCli, useCIChrome, useCIDefaults, getNgCLIVersion } from '../../utils/project'; export default async function () { let restoreRegistry: (() => Promise<void>) | undefined; try { // We need to use the public registry because in the local NPM server we don't have // older versions @angular/cli packages which would cause `npm install` during `ng update` to fail. restoreRegistry = await createProjectFromAsset('15.0-project', true); // CLI project version const cliMajorProjectVersion = 15; // If using npm, enable legacy peer deps mode to avoid defects in npm 7+'s peer dependency resolution // Example error where 11.2.14 satisfies the SemVer range ^11.0.0 but still fails: // npm ERR! Conflicting peer dependency: @angular/[email protected] // npm ERR! node_modules/@angular/compiler-cli // npm ERR! peer @angular/compiler-cli@"^11.0.0 || ^11.2.0-next" from @angular-devkit/[email protected] // npm ERR! node_modules/@angular-devkit/build-angular // npm ERR! dev @angular-devkit/build-angular@"~0.1102.19" from the root project if (getActivePackageManager() === 'npm') { await appendFile('.npmrc', '\nlegacy-peer-deps=true'); } // CLI current version. const cliMajorVersion = getNgCLIVersion().major; for (let version = cliMajorProjectVersion + 1; version < cliMajorVersion; version++) { // Run all the migrations until the current build major version - 1. // Example: when the project is using CLI version 10 and the build CLI version is 14. // We will run the following migrations: // - 10 -> 11 // - 11 -> 12 // - 12 -> 13 const { stdout } = await ng('update', `@angular/cli@${version}`, `@angular/core@${version}`); if ( !stdout.includes("Executing migrations of package '@angular/cli'") && !stdout.includes("Optional migrations of package '@angular/cli'") ) { throw new Error('Update did not execute migrations for @angular/cli. OUTPUT: \n' + stdout); } if (!stdout.includes("Executing migrations of package '@angular/core'")) { throw new Error('Update did not execute migrations for @angular/core. OUTPUT: \n' + stdout); } } } finally { await restoreRegistry?.(); } // Update Angular current build const extraUpdateArgs = isPrereleaseCli() ? ['--next', '--force'] : []; // For the latest/next release we purposely don't run `ng update @angular/core`. // During a major release when the branch version is bumped from `12.0.0-rc.x` to `12.0.0` there would be a period were in // the local NPM registry `@angular/cli@latest` will point to `12.0.0`, but on the public NPM repository `@angular/core@latest` will be `11.2.x`. // This causes `ng update @angular/core` to fail because of mismatching peer dependencies. // The reason for this is because of our bumping and release strategy. When we release a major version on NPM we don't tag it // `@latest` right away, but we wait for all teams to release their packages before doing so. While this is good because all team // packages gets tagged with `@latest` at the same time. This is problematic for our CI, since we test against the public NPM repo and are dependent on tags. // NB: `ng update @angular/cli` will still cause `@angular/core` packages to be updated therefore we still test updating the core package without running the command. await ng('update', '@angular/cli', ...extraUpdateArgs); // Generate E2E setup await ng('generate', 'private-e2e', '--related-app-name=fifteen-project'); // Setup testing to use CI Chrome. await useCIChrome('fifteen-project', './'); await useCIChrome('fifteen-project', './e2e/'); await useCIDefaults('fifteen-project'); // Run CLI commands. await ng('generate', 'component', 'my-comp', '--no-standalone'); await ng('test', '--watch=false'); await ng('e2e'); await ng('e2e', '--configuration=production'); // Verify project now creates bundles await noSilentNg('build', '--configuration=production'); await expectFileMatchToExist('dist/fifteen-project/', /main\.[0-9a-f]{16}\.js/); }
{ "end_byte": 4502, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/update/update.ts" }
angular-cli/tests/legacy-cli/e2e/tests/basic/rebuild.ts_0_4354
import { setTimeout } from 'node:timers/promises'; import { getGlobalVariable } from '../../utils/env'; import { appendToFile, replaceInFile, writeMultipleFiles } from '../../utils/fs'; import { silentNg, waitForAnyProcessOutputToMatch } from '../../utils/process'; import { ngServe } from '../../utils/project'; export default async function () { const esbuild = getGlobalVariable('argv')['esbuild']; const validBundleRegEx = esbuild ? /complete\./ : /Compiled successfully\./; const lazyBundleRegEx = esbuild ? /chunk-/ : /src_app_lazy_lazy_component_ts\.js/; // Disable component stylesheet HMR to support page reload based rebuild testing. // Ideally this environment variable would be passed directly to the new serve process // but this would require signficant test changes due to the existing `ngServe` signature. const oldHMRValue = process.env['NG_HMR_CSTYLES']; process.env['NG_HMR_CSTYLES'] = '0'; const port = await ngServe(); process.env['NG_HMR_CSTYLES'] = oldHMRValue; // Add a lazy route. await silentNg('generate', 'component', 'lazy'); // Should trigger a rebuild with a new bundle. // We need to use Promise.all to ensure we are waiting for the rebuild just before we write // the file, otherwise rebuilds can be too fast and fail CI. // Count the bundles. // Verify that a new chunk was created. await Promise.all([ waitForAnyProcessOutputToMatch(lazyBundleRegEx), replaceInFile( 'src/app/app.routes.ts', 'routes: Routes = [];', `routes: Routes = [{path: 'lazy', loadComponent: () => import('./lazy/lazy.component').then(c => c.LazyComponent)}];`, ), ]); // Change multiple files and check that all of them are invalidated and recompiled. await setTimeout(500); await Promise.all([ waitForAnyProcessOutputToMatch(validBundleRegEx), appendToFile( 'src/app/app.routes.ts', ` console.log('$$_E2E_GOLDEN_VALUE_1'); export let X = '$$_E2E_GOLDEN_VALUE_2'; `, ), appendToFile( 'src/main.ts', ` import * as m from './app/app.routes'; console.log(m.X); console.log('$$_E2E_GOLDEN_VALUE_3'); `, ), ]); await setTimeout(500); await Promise.all([ waitForAnyProcessOutputToMatch(validBundleRegEx), writeMultipleFiles({ 'src/app/app.routes.ts': ` import { Routes } from '@angular/router'; export const routes: Routes = []; console.log('$$_E2E_GOLDEN_VALUE_1'); export let X = '$$_E2E_GOLDEN_VALUE_2'; console.log('File changed with no import/export changes'); `, }), ]); { const response = await fetch(`http://localhost:${port}/main.js`); const body = await response.text(); if (!body.match(/\$\$_E2E_GOLDEN_VALUE_1/)) { throw new Error('Expected golden value 1.'); } if (!body.match(/\$\$_E2E_GOLDEN_VALUE_2/)) { throw new Error('Expected golden value 2.'); } if (!body.match(/\$\$_E2E_GOLDEN_VALUE_3/)) { throw new Error('Expected golden value 3.'); } } await setTimeout(500); await Promise.all([ waitForAnyProcessOutputToMatch(validBundleRegEx), writeMultipleFiles({ 'src/app/app.component.html': '<h1>testingTESTING123</h1>', }), ]); { const response = await fetch(`http://localhost:${port}/main.js`); const body = await response.text(); if (!body.match(/testingTESTING123/)) { throw new Error('Expected component HTML to update.'); } } await setTimeout(500); await Promise.all([ waitForAnyProcessOutputToMatch(validBundleRegEx), writeMultipleFiles({ 'src/app/app.component.css': ':host { color: blue; }', }), ]); { const response = await fetch(`http://localhost:${port}/main.js`); const body = await response.text(); if (!body.match(/color:\s?blue/)) { throw new Error('Expected component CSS to update.'); } } await setTimeout(500); await Promise.all([ waitForAnyProcessOutputToMatch(validBundleRegEx), writeMultipleFiles({ 'src/styles.css': 'div { color: green; }', }), ]); { const response = await fetch(`http://localhost:${port}/styles.css`); const body = await response.text(); if (!body.match(/color:\s?green/)) { throw new Error('Expected global CSS to update.'); } } }
{ "end_byte": 4354, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/basic/rebuild.ts" }
angular-cli/tests/legacy-cli/e2e/tests/basic/styles-array.ts_0_2068
import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { await writeMultipleFiles({ 'src/string-style.css': '.string-style { color: red }', 'src/input-style.css': '.input-style { color: red }', 'src/lazy-style.css': '.lazy-style { color: red }', 'src/pre-rename-style.css': '.pre-rename-style { color: red }', 'src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }', }); await updateJsonFile('angular.json', (workspaceJson) => { const appArchitect = workspaceJson.projects['test-project'].architect; appArchitect.build.options.styles = [ { input: 'src/string-style.css' }, { input: 'src/input-style.css' }, { input: 'src/lazy-style.css', inject: false }, { input: 'src/pre-rename-style.css', bundleName: 'renamed-style' }, { input: 'src/pre-rename-lazy-style.css', bundleName: 'renamed-lazy-style', inject: false, }, ]; }); const { stdout } = await ng('build', '--configuration=development'); await expectFileToMatch('dist/test-project/browser/styles.css', '.string-style'); await expectFileToMatch('dist/test-project/browser/styles.css', '.input-style'); await expectFileToMatch('dist/test-project/browser/lazy-style.css', '.lazy-style'); await expectFileToMatch('dist/test-project/browser/renamed-style.css', '.pre-rename-style'); await expectFileToMatch( 'dist/test-project/browser/renamed-lazy-style.css', '.pre-rename-lazy-style', ); await expectFileToMatch( 'dist/test-project/browser/index.html', '<link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="renamed-style.css">', ); // Non injected styles should be listed under lazy chunk files if (!/Lazy chunk files[\s\S]+renamed-lazy-style\.css/m.test(stdout)) { console.log(stdout); throw new Error(`Expected "renamed-lazy-style.css" to be listed under "Lazy chunk files".`); } }
{ "end_byte": 2068, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/basic/styles-array.ts" }
angular-cli/tests/legacy-cli/e2e/tests/basic/command-scope.ts_0_1003
import assert from 'node:assert/strict'; import { homedir } from 'node:os'; import { silentNg } from '../../utils/process'; export default async function () { // Run inside workspace await silentNg('generate', 'component', 'foo', '--dry-run'); // The version command can be run in and outside of a workspace. await silentNg('version'); await assert.rejects( silentNg('new', 'proj-name', '--dry-run'), /This command is not available when running the Angular CLI inside a workspace\./, ); // Change CWD to run outside a workspace. process.chdir(homedir()); // ng generate can only be ran inside. await assert.rejects( silentNg('generate', 'component', 'foo', '--dry-run'), /This command is not available when running the Angular CLI outside a workspace\./, ); // ng new can only be ran outside of a workspace await silentNg('new', 'proj-name', '--dry-run'); // The version command can be run in and outside of a workspace. await silentNg('version'); }
{ "end_byte": 1003, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/basic/command-scope.ts" }
angular-cli/tests/legacy-cli/e2e/tests/basic/e2e.ts_0_433
import assert from 'node:assert/strict'; import { setTimeout } from 'node:timers/promises'; import { silentNg } from '../../utils/process'; export default async function () { await assert.rejects(silentNg('e2e', 'test-project', '--dev-server-target=')); // These should work. await silentNg('e2e', 'test-project'); await setTimeout(500); await silentNg('e2e', 'test-project', '--dev-server-target=test-project:serve'); }
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/basic/e2e.ts" }
angular-cli/tests/legacy-cli/e2e/tests/basic/scripts-array.ts_0_3332
import { getGlobalVariable } from '../../utils/env'; import { appendToFile, expectFileToMatch, writeMultipleFiles } from '../../utils/fs'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { await writeMultipleFiles({ 'src/string-script.js': "console.log('string-script'); var number = 1+1;", 'src/zstring-script.js': "console.log('zstring-script');", 'src/fstring-script.js': "console.log('fstring-script');", 'src/ustring-script.js': "console.log('ustring-script');", 'src/bstring-script.js': "console.log('bstring-script');", 'src/astring-script.js': "console.log('astring-script');", 'src/cstring-script.js': "console.log('cstring-script');", 'src/input-script.js': "console.log('input-script');", 'src/lazy-script.js': "console.log('lazy-script');", 'src/pre-rename-script.js': "console.log('pre-rename-script');", 'src/pre-rename-lazy-script.js': "console.log('pre-rename-lazy-script');", }); await appendToFile('src/main.ts', "import './string-script.js';"); await updateJsonFile('angular.json', (configJson) => { const appArchitect = configJson.projects['test-project'].architect; appArchitect.build.options.scripts = [ { input: 'src/string-script.js' }, { input: 'src/zstring-script.js' }, { input: 'src/fstring-script.js' }, { input: 'src/ustring-script.js' }, { input: 'src/bstring-script.js' }, { input: 'src/astring-script.js' }, { input: 'src/cstring-script.js' }, { input: 'src/input-script.js' }, { input: 'src/lazy-script.js', inject: false }, { input: 'src/pre-rename-script.js', bundleName: 'renamed-script' }, { input: 'src/pre-rename-lazy-script.js', bundleName: 'renamed-lazy-script', inject: false, }, ]; }); await ng('build', '--configuration=development'); // files were created successfully await expectFileToMatch('dist/test-project/browser/scripts.js', 'string-script'); await expectFileToMatch('dist/test-project/browser/scripts.js', 'input-script'); await expectFileToMatch('dist/test-project/browser/lazy-script.js', 'lazy-script'); await expectFileToMatch('dist/test-project/browser/renamed-script.js', 'pre-rename-script'); await expectFileToMatch( 'dist/test-project/browser/renamed-lazy-script.js', 'pre-rename-lazy-script', ); // index.html lists the right bundles if (getGlobalVariable('argv')['esbuild']) { await expectFileToMatch( 'dist/test-project/browser/index.html', [ '<script src="polyfills.js" type="module"></script>', '<script src="scripts.js" defer></script>', '<script src="renamed-script.js" defer></script>', '<script src="main.js" type="module"></script>', ].join(''), ); } else { await expectFileToMatch( 'dist/test-project/browser/index.html', [ '<script src="runtime.js" type="module"></script>', '<script src="polyfills.js" type="module"></script>', '<script src="scripts.js" defer></script>', '<script src="renamed-script.js" defer></script>', '<script src="vendor.js" type="module"></script>', '<script src="main.js" type="module"></script>', ].join(''), ); } }
{ "end_byte": 3332, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/basic/scripts-array.ts" }
angular-cli/tests/legacy-cli/e2e/tests/basic/test.ts_0_1679
import { ng } from '../../utils/process'; import { writeMultipleFiles } from '../../utils/fs'; export default async function () { // make sure both --watch=false work await ng('test', '--watch=false'); // Works with custom config await writeMultipleFiles({ './karma.conf.bis.js': ` // Karma configuration file, see link for more information // https://karma-runner.github.io/1.0/config/configuration-file.html module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular-devkit/build-angular'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage'), require('@angular-devkit/build-angular/plugins/karma') ], client: { clearContext: false // leave Jasmine Spec Runner output visible in browser }, reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['ChromeHeadlessNoSandbox'], customLaunchers: { ChromeHeadlessNoSandbox: { base: 'ChromeHeadless', flags: [ '--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage', ], } }, singleRun: false, restartOnFileChange: true }); }; `, }); await ng('test', '--watch=false', '--karma-config=karma.conf.bis.js'); }
{ "end_byte": 1679, "start_byte": 0, "url": "https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/basic/test.ts" }
End of preview. Expand in Data Studio

Dataset Card for FreshStack (Corpus)

Homepage | Repository | Paper

FreshStack is a holistic framework to construct challenging IR/RAG evaluation datasets that focuses on search across niche and recent topics.

This dataset (October 2024) contains the query, nuggets, answers and nugget-level relevance judgments of 5 niche topics focused on software engineering and machine learning.

The queries and answers (accepted) are taken from Stack Overflow, GPT-4o generates the nuggets and labels the relevance between each nugget and a given document list.

This repository contains the corpus of GitHub chunked documents of five niche topics in freshstack. The queries, answers and nuggets can be found here.

Dataset Structure

To access the data using HuggingFace datasets:

topic='langchain'  # or any of the 5 topics
freshstack = datasets.load_dataset('freshstack/corpus-oct-2024', topic)

# train set
for data in freshstack['train']:
  doc_id = data['_id']
  doc_text = data['text'] 

Dataset Statistics

The following table contains the number of documents (#D) and the number of GitHub repositories used (#G) in the FreshStack collection.

Topic Versions Domain Train
#D #G
langchain - Machine Learning 49,514 10
yolo v7 & v8 Computer Vision 27,207 5
laravel 10 & 11 Back-end Development 52,351 9
angular 16, 17 & 18 Front-end Development 117,288 4
godot 4 Game Development 25,482 6

The following table contains the list of original GitHub repositories used to construct the following corpus for each topic.

Dataset Licenses

The FreshStack datasets are provided under the CC-BY-SA 4.0 license.

The original GitHub repositories used for constructing the corpus may contain non-permissive licenses; we advise the reader to check the licenses for each repository carefully.

Downloads last month
44