From 408090d977cf4b1d92d54d627df05c37b3090143 Mon Sep 17 00:00:00 2001 From: Derek Cormier Date: Mon, 10 Jan 2022 11:21:04 -0800 Subject: [PATCH 1/2] build: use placeholder version for stamping --- packages/angular/cli/models/version.ts | 3 ++- packages/angular/cli/package.json | 22 +++++++++---------- packages/angular/pwa/package.json | 6 ++--- .../angular_devkit/architect/package.json | 4 ++-- .../angular_devkit/architect_cli/package.json | 6 ++--- .../angular_devkit/benchmark/package.json | 4 ++-- .../angular_devkit/build_angular/package.json | 10 ++++----- .../build_optimizer/package.json | 2 +- .../angular_devkit/build_webpack/package.json | 6 ++--- packages/angular_devkit/core/package.json | 2 +- .../angular_devkit/schematics/package.json | 4 ++-- .../schematics_cli/package.json | 6 ++--- packages/ngtools/webpack/package.json | 4 ++-- packages/schematics/angular/package.json | 6 ++--- scripts/build.ts | 4 ++-- scripts/validate-licenses.ts | 2 +- tools/defaults.bzl | 7 ++---- 17 files changed, 48 insertions(+), 50 deletions(-) diff --git a/packages/angular/cli/models/version.ts b/packages/angular/cli/models/version.ts index cff0d0765c47..f24082ff1229 100644 --- a/packages/angular/cli/models/version.ts +++ b/packages/angular/cli/models/version.ts @@ -22,7 +22,8 @@ export class Version { } } -// TODO: Convert this to use build-time version stamping once implemented in the build system +// TODO: Convert this to use build-time version stamping after flipping the build script to use bazel +// export const VERSION = new Version('0.0.0-PLACEHOLDER'); export const VERSION = new Version( ( JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8')) as { version: string } diff --git a/packages/angular/cli/package.json b/packages/angular/cli/package.json index 972ffb2d6c86..aae0af126f2e 100644 --- a/packages/angular/cli/package.json +++ b/packages/angular/cli/package.json @@ -1,6 +1,6 @@ { "name": "@angular/cli", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "CLI tool for Angular", "main": "lib/cli/index.js", "bin": { @@ -25,10 +25,10 @@ }, "homepage": "https://github.com/angular/angular-cli", "dependencies": { - "@angular-devkit/architect": "0.0.0", - "@angular-devkit/core": "0.0.0", - "@angular-devkit/schematics": "0.0.0", - "@schematics/angular": "0.0.0", + "@angular-devkit/architect": "0.0.0-PLACEHOLDER", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", + "@angular-devkit/schematics": "0.0.0-PLACEHOLDER", + "@schematics/angular": "0.0.0-PLACEHOLDER", "@yarnpkg/lockfile": "1.1.0", "ansi-colors": "4.1.1", "debug": "4.3.3", @@ -51,12 +51,12 @@ "ng-update": { "migrations": "@schematics/angular/migrations/migration-collection.json", "packageGroup": { - "@angular/cli": "0.0.0", - "@angular-devkit/architect": "0.0.0", - "@angular-devkit/build-angular": "0.0.0", - "@angular-devkit/build-webpack": "0.0.0", - "@angular-devkit/core": "0.0.0", - "@angular-devkit/schematics": "0.0.0" + "@angular/cli": "0.0.0-PLACEHOLDER", + "@angular-devkit/architect": "0.0.0-PLACEHOLDER", + "@angular-devkit/build-angular": "0.0.0-PLACEHOLDER", + "@angular-devkit/build-webpack": "0.0.0-PLACEHOLDER", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", + "@angular-devkit/schematics": "0.0.0-PLACEHOLDER" } } } diff --git a/packages/angular/pwa/package.json b/packages/angular/pwa/package.json index 43e0f6920422..89a4e1fe04c8 100644 --- a/packages/angular/pwa/package.json +++ b/packages/angular/pwa/package.json @@ -1,6 +1,6 @@ { "name": "@angular/pwa", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "PWA schematics for Angular", "keywords": [ "blueprints", @@ -12,8 +12,8 @@ "save": false }, "dependencies": { - "@angular-devkit/schematics": "0.0.0", - "@schematics/angular": "0.0.0", + "@angular-devkit/schematics": "0.0.0-PLACEHOLDER", + "@schematics/angular": "0.0.0-PLACEHOLDER", "parse5-html-rewriting-stream": "6.0.1" } } diff --git a/packages/angular_devkit/architect/package.json b/packages/angular_devkit/architect/package.json index b1b49e771de1..31774c392295 100644 --- a/packages/angular_devkit/architect/package.json +++ b/packages/angular_devkit/architect/package.json @@ -1,12 +1,12 @@ { "name": "@angular-devkit/architect", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular Build Facade", "experimental": true, "main": "src/index.js", "typings": "src/index.d.ts", "dependencies": { - "@angular-devkit/core": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "rxjs": "6.6.7" }, "builders": "./builders/builders.json" diff --git a/packages/angular_devkit/architect_cli/package.json b/packages/angular_devkit/architect_cli/package.json index 962535374b8e..fbc8fd9452d4 100644 --- a/packages/angular_devkit/architect_cli/package.json +++ b/packages/angular_devkit/architect_cli/package.json @@ -1,6 +1,6 @@ { "name": "@angular-devkit/architect-cli", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular Architect CLI", "homepage": "https://github.com/angular/angular-cli", "experimental": true, @@ -14,8 +14,8 @@ "tooling" ], "dependencies": { - "@angular-devkit/architect": "0.0.0", - "@angular-devkit/core": "0.0.0", + "@angular-devkit/architect": "0.0.0-PLACEHOLDER", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "ansi-colors": "4.1.1", "minimist": "1.2.5", "progress": "2.0.3", diff --git a/packages/angular_devkit/benchmark/package.json b/packages/angular_devkit/benchmark/package.json index 916c811edfe4..46e224be3e82 100644 --- a/packages/angular_devkit/benchmark/package.json +++ b/packages/angular_devkit/benchmark/package.json @@ -1,6 +1,6 @@ { "name": "@angular-devkit/benchmark", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "private": true, "description": "Angular Benchmark", "bin": { @@ -10,7 +10,7 @@ "benchmark" ], "dependencies": { - "@angular-devkit/core": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "ansi-colors": "4.1.1", "minimist": "1.2.5", "pidusage": "3.0.0", diff --git a/packages/angular_devkit/build_angular/package.json b/packages/angular_devkit/build_angular/package.json index b1cf7000811f..e95c982fa3ac 100644 --- a/packages/angular_devkit/build_angular/package.json +++ b/packages/angular_devkit/build_angular/package.json @@ -1,15 +1,15 @@ { "name": "@angular-devkit/build-angular", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular Webpack Build Facade", "main": "src/index.js", "typings": "src/index.d.ts", "builders": "builders.json", "dependencies": { "@ampproject/remapping": "1.0.2", - "@angular-devkit/architect": "0.0.0", - "@angular-devkit/build-webpack": "0.0.0", - "@angular-devkit/core": "0.0.0", + "@angular-devkit/architect": "0.0.0-PLACEHOLDER", + "@angular-devkit/build-webpack": "0.0.0-PLACEHOLDER", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "@babel/core": "7.16.7", "@babel/generator": "7.16.7", "@babel/helper-annotate-as-pure": "7.16.7", @@ -20,7 +20,7 @@ "@babel/runtime": "7.16.7", "@babel/template": "7.16.7", "@discoveryjs/json-ext": "0.5.6", - "@ngtools/webpack": "0.0.0", + "@ngtools/webpack": "0.0.0-PLACEHOLDER", "ansi-colors": "4.1.1", "babel-loader": "8.2.3", "babel-plugin-istanbul": "6.1.1", diff --git a/packages/angular_devkit/build_optimizer/package.json b/packages/angular_devkit/build_optimizer/package.json index b8e34e97fa74..c8ff12fba7e7 100644 --- a/packages/angular_devkit/build_optimizer/package.json +++ b/packages/angular_devkit/build_optimizer/package.json @@ -1,6 +1,6 @@ { "name": "@angular-devkit/build-optimizer", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular Build Optimizer", "experimental": true, "main": "src/index.js", diff --git a/packages/angular_devkit/build_webpack/package.json b/packages/angular_devkit/build_webpack/package.json index 9fc65745fc0c..7e82f89509f4 100644 --- a/packages/angular_devkit/build_webpack/package.json +++ b/packages/angular_devkit/build_webpack/package.json @@ -1,17 +1,17 @@ { "name": "@angular-devkit/build-webpack", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Webpack Builder for Architect", "experimental": true, "main": "src/index.js", "typings": "src/index.d.ts", "builders": "builders.json", "dependencies": { - "@angular-devkit/architect": "0.0.0", + "@angular-devkit/architect": "0.0.0-PLACEHOLDER", "rxjs": "6.6.7" }, "devDependencies": { - "@angular-devkit/core": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "node-fetch": "2.6.1", "webpack": "5.65.0" }, diff --git a/packages/angular_devkit/core/package.json b/packages/angular_devkit/core/package.json index e75a03ffbaf3..4139792aa206 100644 --- a/packages/angular_devkit/core/package.json +++ b/packages/angular_devkit/core/package.json @@ -1,6 +1,6 @@ { "name": "@angular-devkit/core", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular DevKit - Core Utility Library", "main": "src/index.js", "typings": "src/index.d.ts", diff --git a/packages/angular_devkit/schematics/package.json b/packages/angular_devkit/schematics/package.json index c02f62cbad53..7c29b9aa9d9f 100644 --- a/packages/angular_devkit/schematics/package.json +++ b/packages/angular_devkit/schematics/package.json @@ -1,6 +1,6 @@ { "name": "@angular-devkit/schematics", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular Schematics - Library", "main": "src/index.js", "typings": "src/index.d.ts", @@ -13,7 +13,7 @@ "schematics" ], "dependencies": { - "@angular-devkit/core": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "jsonc-parser": "3.0.0", "magic-string": "0.25.7", "ora": "5.4.1", diff --git a/packages/angular_devkit/schematics_cli/package.json b/packages/angular_devkit/schematics_cli/package.json index 5110e9a83d72..bc89f9a4db8a 100644 --- a/packages/angular_devkit/schematics_cli/package.json +++ b/packages/angular_devkit/schematics_cli/package.json @@ -1,6 +1,6 @@ { "name": "@angular-devkit/schematics-cli", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Angular Schematics - CLI", "homepage": "https://github.com/angular/angular-cli", "bin": { @@ -16,8 +16,8 @@ ], "schematics": "./collection.json", "dependencies": { - "@angular-devkit/core": "0.0.0", - "@angular-devkit/schematics": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", + "@angular-devkit/schematics": "0.0.0-PLACEHOLDER", "ansi-colors": "4.1.1", "inquirer": "8.2.0", "minimist": "1.2.5", diff --git a/packages/ngtools/webpack/package.json b/packages/ngtools/webpack/package.json index 181f69e77ac7..e63b326d5707 100644 --- a/packages/ngtools/webpack/package.json +++ b/packages/ngtools/webpack/package.json @@ -1,6 +1,6 @@ { "name": "@ngtools/webpack", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Webpack plugin that AoT compiles your Angular components and modules.", "main": "./src/index.js", "typings": "src/index.d.ts", @@ -27,7 +27,7 @@ "webpack": "^5.30.0" }, "devDependencies": { - "@angular-devkit/core": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", "@angular/compiler": "13.1.1", "@angular/compiler-cli": "13.1.1", "typescript": "4.5.4", diff --git a/packages/schematics/angular/package.json b/packages/schematics/angular/package.json index 2dbe09db2bc4..7845c5c03aa9 100644 --- a/packages/schematics/angular/package.json +++ b/packages/schematics/angular/package.json @@ -1,6 +1,6 @@ { "name": "@schematics/angular", - "version": "0.0.0", + "version": "0.0.0-PLACEHOLDER", "description": "Schematics specific to Angular", "homepage": "https://github.com/angular/angular-cli", "keywords": [ @@ -10,8 +10,8 @@ ], "schematics": "./collection.json", "dependencies": { - "@angular-devkit/core": "0.0.0", - "@angular-devkit/schematics": "0.0.0", + "@angular-devkit/core": "0.0.0-PLACEHOLDER", + "@angular-devkit/schematics": "0.0.0-PLACEHOLDER", "jsonc-parser": "3.0.0" } } diff --git a/scripts/build.ts b/scripts/build.ts index abc83d0796a8..0141e50fa553 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -411,8 +411,8 @@ export default async function ( } else { obj[depName] = `github:${pkg.snapshotRepo}#${pkg.snapshotHash}`; } - } else if ((obj[depName] as string).match(/\b0\.0\.0\b/)) { - obj[depName] = (obj[depName] as string).replace(/\b0\.0\.0\b/, v); + } else if ((obj[depName] as string).match(/\b0\.0\.0-PLACEHOLDER\b/)) { + obj[depName] = (obj[depName] as string).replace(/\b0\.0\.0-PLACEHOLDER\b/, v); } } } diff --git a/scripts/validate-licenses.ts b/scripts/validate-licenses.ts index c6a34b544bf1..b26de3f72281 100644 --- a/scripts/validate-licenses.ts +++ b/scripts/validate-licenses.ts @@ -81,7 +81,7 @@ const ignoredPackages = [ // Ignore own packages (all MIT) for (const packageName of Object.keys(packages)) { - ignoredPackages.push(`${packageName}@0.0.0`); + ignoredPackages.push(`${packageName}@0.0.0-PLACEHOLDER`); } // Find all folders directly under a `node_modules` that have a package.json. diff --git a/tools/defaults.bzl b/tools/defaults.bzl index 5ce1876b1c1d..fa3e70612a5b 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -66,13 +66,10 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs): common_substitutions = dict(kwargs.pop("substitutions", {})) substitutions = dict(common_substitutions, **{ - # TODO: Current build script relies on 0.0.0 in package.json; uncomment after replacing build script. - #"0.0.0-PLACEHOLDER": "0.0.0", + "0.0.0-PLACEHOLDER": "0.0.0", }) stamped_substitutions = dict(common_substitutions, **{ - # TODO: Current build script relies on 0.0.0 in package.json; uncomment after replacing build script. - #"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}", - "0.0.0": "{BUILD_SCM_VERSION}", + "0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}", }) deps = kwargs.pop("deps", []) From cd529bcdbce93000913cf9343ae3f3101755093a Mon Sep 17 00:00:00 2001 From: Derek Cormier Date: Mon, 10 Jan 2022 14:26:28 -0800 Subject: [PATCH 2/2] build: move engine substitutions out of jq filter --- constants.bzl | 4 ++++ tools/defaults.bzl | 19 ++++++++++++------- tools/package_json_release_filter.jq | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 constants.bzl diff --git a/constants.bzl b/constants.bzl new file mode 100644 index 000000000000..2e9002901577 --- /dev/null +++ b/constants.bzl @@ -0,0 +1,4 @@ +# Engine versions to stamp in a release package.json +RELEASE_ENGINES_NODE = "^12.20.0 || ^14.15.0 || >=16.10.0" +RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0" +RELEASE_ENGINES_YARN = ">= 1.13.0" diff --git a/tools/defaults.bzl b/tools/defaults.bzl index fa3e70612a5b..e77ac5116c97 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -8,6 +8,7 @@ load("@aspect_bazel_lib//lib:utils.bzl", "to_label") load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") load("//tools:link_package_json_to_tarballs.bzl", "link_package_json_to_tarballs") +load("//:constants.bzl", "RELEASE_ENGINES_NODE", "RELEASE_ENGINES_NPM", "RELEASE_ENGINES_YARN") _DEFAULT_TSCONFIG = "//:tsconfig-build.json" _DEFAULT_TSCONFIG_TEST = "//:tsconfig-test.json" @@ -64,12 +65,16 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs): visibility = kwargs.pop("visibility", None) - common_substitutions = dict(kwargs.pop("substitutions", {})) - substitutions = dict(common_substitutions, **{ - "0.0.0-PLACEHOLDER": "0.0.0", - }) - stamped_substitutions = dict(common_substitutions, **{ + NPM_PACKAGE_SUBSTITUTIONS = { + # Version of the local package being built, generated via the `--workspace_status_command` flag. "0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}", + "0.0.0-ENGINES-NODE": RELEASE_ENGINES_NODE, + "0.0.0-ENGINES-NPM": RELEASE_ENGINES_NPM, + "0.0.0-ENGINES-YARN": RELEASE_ENGINES_YARN, + } + + NO_STAMP_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{ + "0.0.0-PLACEHOLDER": "0.0.0", }) deps = kwargs.pop("deps", []) @@ -161,8 +166,8 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs): package_name = None, validate = False, substitutions = select({ - "//:stamp": stamped_substitutions, - "//conditions:default": substitutions, + "//:stamp": NPM_PACKAGE_SUBSTITUTIONS, + "//conditions:default": NO_STAMP_PACKAGE_SUBSTITUTIONS, }), visibility = visibility, nested_packages = ["package"], diff --git a/tools/package_json_release_filter.jq b/tools/package_json_release_filter.jq index e025697e1fc3..019c5e19a681 100644 --- a/tools/package_json_release_filter.jq +++ b/tools/package_json_release_filter.jq @@ -28,5 +28,5 @@ # Remove devDependencies | del(.devDependencies) -# Add engines -+ {"engines": {"node": "^12.20.0 || ^14.15.0 || >=16.10.0", "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", "yarn": ">= 1.13.0"}} \ No newline at end of file +# 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"}} \ No newline at end of file