Charles Lyding 7f93735e98 build: use bazel to perform release builds
When performing a release via the dev-infra `ng-dev` tooling, the release
builds for the packages that will be published are now performed using bazel.
Prior to this, the release builds were performed using a custom build script
that programmatically invoked TypeScript APIs. The Bazel build and discovery
process for the releasable packages is performed by a script that is based on
the scripts from components and framework repositories. Several small modifications
were performed to match the behavior and structure of the cli repository:
* Use of `packages` as the source root in the bazel query
* Use of `pkg_npm` rule in the bazel query
* Partial transition to native Node.js `fs` APIs instead of `shelljs`
* Directory creation per package when copying output (supports multiple package scopes)
* Copying of archives (tgz) for each package

The snapshot and local build capabilities are not modified as part of this change
but will be merged in a followup as part of a larger transition to use bazel
throughout the package build process.
2023-01-05 03:21:58 +00:00

189 lines
6.2 KiB
Python

# 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.io/license
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:ng_cli_schema_generator.bzl", "cli_json_schema")
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
ts_library(
name = "angular-cli",
package_name = "@angular/cli",
srcs = glob(
include = ["**/*.ts"],
exclude = [
"**/*_spec.ts",
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
],
) + [
# @external_begin
# These files are generated from the JSON schema
"//packages/angular/cli:lib/config/workspace-schema.ts",
"//packages/angular/cli:src/commands/update/schematic/schema.ts",
# @external_end
],
data = glob(
include = [
"bin/**/*",
"**/*.json",
"**/*.md",
],
exclude = [
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
"lib/config/workspace-schema.json",
],
) + [
# @external_begin
"//packages/angular/cli:lib/config/schema.json",
# @external_end
],
module_name = "@angular/cli",
deps = [
"//packages/angular_devkit/architect",
"//packages/angular_devkit/architect/node",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core/node",
"//packages/angular_devkit/schematics",
"//packages/angular_devkit/schematics/tasks",
"//packages/angular_devkit/schematics/tools",
"@npm//@angular/core",
"@npm//@types/ini",
"@npm//@types/inquirer",
"@npm//@types/node",
"@npm//@types/npm-package-arg",
"@npm//@types/pacote",
"@npm//@types/resolve",
"@npm//@types/semver",
"@npm//@types/yargs",
"@npm//@types/yarnpkg__lockfile",
"@npm//@yarnpkg/lockfile",
"@npm//ansi-colors",
"@npm//ini",
"@npm//jsonc-parser",
"@npm//npm-package-arg",
"@npm//open",
"@npm//ora",
"@npm//pacote",
"@npm//semver",
"@npm//yargs",
],
)
# @external_begin
CLI_SCHEMA_DATA = [
"//packages/angular_devkit/build_angular:src/builders/app-shell/schema.json",
"//packages/angular_devkit/build_angular:src/builders/browser/schema.json",
"//packages/angular_devkit/build_angular:src/builders/browser-esbuild/schema.json",
"//packages/angular_devkit/build_angular:src/builders/dev-server/schema.json",
"//packages/angular_devkit/build_angular:src/builders/extract-i18n/schema.json",
"//packages/angular_devkit/build_angular:src/builders/karma/schema.json",
"//packages/angular_devkit/build_angular:src/builders/ng-packagr/schema.json",
"//packages/angular_devkit/build_angular:src/builders/protractor/schema.json",
"//packages/angular_devkit/build_angular:src/builders/server/schema.json",
"//packages/schematics/angular:app-shell/schema.json",
"//packages/schematics/angular:application/schema.json",
"//packages/schematics/angular:class/schema.json",
"//packages/schematics/angular:component/schema.json",
"//packages/schematics/angular:directive/schema.json",
"//packages/schematics/angular:enum/schema.json",
"//packages/schematics/angular:guard/schema.json",
"//packages/schematics/angular:interceptor/schema.json",
"//packages/schematics/angular:interface/schema.json",
"//packages/schematics/angular:library/schema.json",
"//packages/schematics/angular:module/schema.json",
"//packages/schematics/angular:ng-new/schema.json",
"//packages/schematics/angular:pipe/schema.json",
"//packages/schematics/angular:resolver/schema.json",
"//packages/schematics/angular:service/schema.json",
"//packages/schematics/angular:service-worker/schema.json",
"//packages/schematics/angular:web-worker/schema.json",
]
cli_json_schema(
name = "cli_config_schema",
src = "lib/config/workspace-schema.json",
out = "lib/config/schema.json",
data = CLI_SCHEMA_DATA,
)
ts_json_schema(
name = "cli_schema",
src = "lib/config/workspace-schema.json",
data = CLI_SCHEMA_DATA,
)
ts_json_schema(
name = "update_schematic_schema",
src = "src/commands/update/schematic/schema.json",
)
ts_library(
name = "angular-cli_test_lib",
testonly = True,
srcs = glob(
include = ["**/*_spec.ts"],
exclude = [
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
],
),
deps = [
":angular-cli",
"//packages/angular_devkit/core",
"//packages/angular_devkit/schematics",
"//packages/angular_devkit/schematics/testing",
"@npm//@types/semver",
"@npm//rxjs",
],
)
[
jasmine_node_test(
name = "angular-cli_test_" + toolchain_name,
srcs = [":angular-cli_test_lib"],
tags = [toolchain_name],
toolchain = toolchain,
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]
genrule(
name = "license",
srcs = ["//:LICENSE"],
outs = ["LICENSE"],
cmd = "cp $(execpath //:LICENSE) $@",
)
pkg_npm(
name = "npm_package",
pkg_deps = [
"//packages/angular_devkit/architect:package.json",
"//packages/angular_devkit/build_angular:package.json",
"//packages/angular_devkit/build_webpack:package.json",
"//packages/angular_devkit/core:package.json",
"//packages/angular_devkit/schematics:package.json",
"//packages/schematics/angular:package.json",
],
tags = ["release-package"],
deps = [
":README.md",
":angular-cli",
":license",
":src/commands/update/schematic/collection.json",
":src/commands/update/schematic/schema.json",
],
)
# @external_end