Skip to content

Commit

Permalink
Add release output validation for manifest paths and downgrade… (#18865)
Browse files Browse the repository at this point in the history
* build: add release output validation for manifest paths

Ensures that angular/angular@9581658 fixed all instances, and
ensures that we don't regress on the components side.

* build: downgrade to @octokit/rest v16 to avoid broken types

We recently updated `@octokit/rest`, but the most recent version
currently has broken TypeScript definitions. To workaroun this until
the upstream issue is resolved, we downgrade to our last working version.

https://github.com/octokit/rest.js/issues/1624
  • Loading branch information
devversion authored Mar 19, 2020
1 parent 734ca15 commit 9e1b7ec
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 86 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@bazel/protractor": "^1.4.0",
"@bazel/typescript": "^1.4.0",
"@firebase/app-types": "^0.3.2",
"@octokit/rest": "^17.0.0",
"@octokit/rest": "16.28.7",
"@schematics/angular": "^9.0.4",
"@types/browser-sync": "^2.26.1",
"@types/fs-extra": "^4.0.3",
Expand Down
12 changes: 6 additions & 6 deletions tools/release/release-output/check-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
checkMaterialPackage,
checkPackageJsonFile,
checkPackageJsonMigrations,
checkReleaseBundle,
checkJavaScriptOutput,
checkTypeDefinitionFile
} from './output-validations';

/** Glob that matches all JavaScript bundle files within a release package. */
const releaseBundlesGlob = '+(fesm5|fesm2015|esm5|esm2015|bundles)/*.js';
/** Glob that matches all JavaScript files within a release package. */
const releaseJsFilesGlob = '+(fesm5|fesm2015|esm5|esm2015|bundles)/**/*.js';

/** Glob that matches all TypeScript definition files within a release package. */
const releaseTypeDefinitionsGlob = '**/*.d.ts';
Expand Down Expand Up @@ -46,14 +46,14 @@ export function checkReleasePackage(
failures.set(message, filePaths);
};

const bundlePaths = glob(releaseBundlesGlob, {cwd: packagePath, absolute: true});
const jsFiles = glob(releaseJsFilesGlob, {cwd: packagePath, absolute: true});
const typeDefinitions = glob(releaseTypeDefinitionsGlob, {cwd: packagePath, absolute: true});
const packageJsonFiles = glob(packageJsonFilesGlob, {cwd: packagePath, absolute: true});

// We want to walk through each bundle within the current package and run
// release validations that ensure that the bundles are not invalid.
bundlePaths.forEach(bundlePath => {
checkReleaseBundle(bundlePath).forEach(message => addFailure(message, bundlePath));
jsFiles.forEach(bundlePath => {
checkJavaScriptOutput(bundlePath).forEach(message => addFailure(message, bundlePath));
});

// Run output validations for all TypeScript definition files within the release output.
Expand Down
19 changes: 13 additions & 6 deletions tools/release/release-output/output-validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const inlineStylesSourcemapRegex = /styles: ?\[["'].*sourceMappingURL=.*["']/;
/** RegExp that matches Angular component metadata properties that refer to external resources. */
const externalReferencesRegex = /(templateUrl|styleUrls): *["'[]/;

/** RegExp that matches common Bazel manifest paths in this workspace */
const bazelManifestPath = /(angular_material|external)\//;

/**
* List of fields which are mandatory in entry-point "package.json" files and refer
* to files in the release output.
Expand All @@ -19,21 +22,25 @@ const packageJsonPathFields =
['main', 'module', 'typings', 'es2015', 'fesm5', 'fesm2015', 'esm5', 'esm2015'];

/**
* Checks the specified release bundle and ensures that it does not contain
* any external resource URLs.
* Checks the specified JavaScript file and ensures that it does not
* contain any external resource URLs, or Bazel manifest paths.
*/
export function checkReleaseBundle(bundlePath: string): string[] {
const bundleContent = readFileSync(bundlePath, 'utf8');
export function checkJavaScriptOutput(filePath: string): string[] {
const fileContent = readFileSync(filePath, 'utf8');
const failures: string[] = [];

if (inlineStylesSourcemapRegex.exec(bundleContent) !== null) {
if (inlineStylesSourcemapRegex.exec(fileContent) !== null) {
failures.push('Found sourcemap references in component styles.');
}

if (externalReferencesRegex.exec(bundleContent) !== null) {
if (externalReferencesRegex.exec(fileContent) !== null) {
failures.push('Found external component resource references');
}

if (bazelManifestPath.exec(fileContent) !== null) {
failures.push('Found Bazel manifest path in output.');
}

return failures;
}

Expand Down
6 changes: 3 additions & 3 deletions tools/release/stage-release.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as OctokitApi from '@octokit/rest';
import * as Octokit from '@octokit/rest';
import chalk from 'chalk';
import {existsSync, readFileSync, writeFileSync} from 'fs';
import {join} from 'path';
Expand Down Expand Up @@ -50,7 +50,7 @@ class StageReleaseTask extends BaseReleaseTask {
git: GitClient;

/** Octokit API instance that can be used to make Github API calls. */
githubApi: OctokitApi;
githubApi: Octokit;

constructor(
public projectDir: string, public packagesDir: string, public repositoryOwner: string,
Expand All @@ -68,7 +68,7 @@ class StageReleaseTask extends BaseReleaseTask {
process.exit(1);
}

this.githubApi = new OctokitApi();
this.githubApi = new Octokit();
}

async run() {
Expand Down
140 changes: 70 additions & 70 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -917,25 +917,6 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@octokit/auth-token@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.0.tgz#b64178975218b99e4dfe948253f0673cbbb59d9f"
integrity sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg==
dependencies:
"@octokit/types" "^2.0.0"

"@octokit/core@^2.4.0":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-2.4.2.tgz#c22e583afc97e74015ea5bfd3ffb3ffc56c186ed"
integrity sha512-fUx/Qt774cgiPhb3HRKfdl6iufVL/ltECkwkCg373I4lIPYvAPY4cbidVZqyVqHI+ThAIlFlTW8FT4QHChv3Sg==
dependencies:
"@octokit/auth-token" "^2.4.0"
"@octokit/graphql" "^4.3.1"
"@octokit/request" "^5.3.1"
"@octokit/types" "^2.0.0"
before-after-hook "^2.1.0"
universal-user-agent "^5.0.0"

"@octokit/endpoint@^5.5.0":
version "5.5.3"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.3.tgz#0397d1baaca687a4c8454ba424a627699d97c978"
Expand All @@ -945,35 +926,6 @@
is-plain-object "^3.0.0"
universal-user-agent "^5.0.0"

"@octokit/graphql@^4.3.1":
version "4.3.1"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.3.1.tgz#9ee840e04ed2906c7d6763807632de84cdecf418"
integrity sha512-hCdTjfvrK+ilU2keAdqNBWOk+gm1kai1ZcdjRfB30oA3/T6n53UVJb7w0L5cR3/rhU91xT3HSqCd+qbvH06yxA==
dependencies:
"@octokit/request" "^5.3.0"
"@octokit/types" "^2.0.0"
universal-user-agent "^4.0.0"

"@octokit/plugin-paginate-rest@^2.0.0":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.0.2.tgz#fee7a81a4cc7d03784aaf9225499dd6e27f6d01e"
integrity sha512-HzODcSUt9mjErly26TlTOGZrhf9bmF/FEDQ2zln1izhgmIV6ulsjsHmgmR4VZ0wzVr/m52Eb6U2XuyS8fkcR1A==
dependencies:
"@octokit/types" "^2.0.1"

"@octokit/plugin-request-log@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e"
integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw==

"@octokit/plugin-rest-endpoint-methods@^3.0.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-3.2.0.tgz#ecc4bc594a57ebfb418b8c4a8c0f200455759004"
integrity sha512-k+RLsegQn4s0wvAFYuk3R18FVKRg3ktvzIGW6MkmrSiSXBwYfaEsv4CuPysyef0DL+74DRj/X9MLJYlbleUO+Q==
dependencies:
"@octokit/types" "^2.0.1"
deprecation "^2.3.1"

"@octokit/request-error@^1.0.1":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.0.4.tgz#15e1dc22123ba4a9a4391914d80ec1e5303a23be"
Expand All @@ -982,7 +934,16 @@
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.3.0", "@octokit/request@^5.3.1":
"@octokit/request-error@^1.0.2":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801"
integrity sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA==
dependencies:
"@octokit/types" "^2.0.0"
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.0.0":
version "5.3.2"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.2.tgz#1ca8b90a407772a1ee1ab758e7e0aced213b9883"
integrity sha512-7NPJpg19wVQy1cs2xqXjjRq/RmtSomja/VSWnptfYwuBxLdbYh2UjhGi0Wx7B1v5Iw5GKhfFDQL7jM7SSp7K2g==
Expand All @@ -996,17 +957,26 @@
once "^1.4.0"
universal-user-agent "^5.0.0"

"@octokit/rest@^17.0.0":
version "17.0.0"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-17.0.0.tgz#1f44d96005f5946665fd42a85cd3e428172f01dc"
integrity sha512-nSlmyy1DBEOsC4voRbk/SN56V/iuZfxZzjFFz+ocb2MAYwHC+z1TyVOMV9W630dVn9ukioJO34VD5NSYwcgFWg==
"@octokit/rest@16.28.7":
version "16.28.7"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.28.7.tgz#a2c2db5b318da84144beba82d19c1a9dbdb1a1fa"
integrity sha512-cznFSLEhh22XD3XeqJw51OLSfyL2fcFKUO+v2Ep9MTAFfFLS1cK1Zwd1yEgQJmJoDnj4/vv3+fGGZweG+xsbIA==
dependencies:
"@octokit/core" "^2.4.0"
"@octokit/plugin-paginate-rest" "^2.0.0"
"@octokit/plugin-request-log" "^1.0.0"
"@octokit/plugin-rest-endpoint-methods" "^3.0.0"
"@octokit/request" "^5.0.0"
"@octokit/request-error" "^1.0.2"
atob-lite "^2.0.0"
before-after-hook "^2.0.0"
btoa-lite "^1.0.0"
deprecation "^2.0.0"
lodash.get "^4.4.2"
lodash.set "^4.3.2"
lodash.uniq "^4.5.0"
octokit-pagination-methods "^1.1.0"
once "^1.4.0"
universal-user-agent "^3.0.0"
url-template "^2.0.8"

"@octokit/types@^2.0.0", "@octokit/types@^2.0.1":
"@octokit/types@^2.0.0":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.3.1.tgz#40cd61c125a6161cfb3bfabc75805ac7a54213b4"
integrity sha512-rvJP1Y9A/+Cky2C3var1vsw3Lf5Rjn/0sojNl2AjCX+WbpIHYccaJ46abrZoIxMYnOToul6S9tPytUVkFI7CXQ==
Expand Down Expand Up @@ -1288,9 +1258,9 @@
integrity sha512-8KmlRxwbKZfjUHFIt3q8TF5S2B+/E5BaAoo/3mgc5h6FJzqxXkCK/VMetO+IRDtwtU6HUvovHMBn+XRj7SV9Qg==

"@types/node@>= 8":
version "13.7.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.7.tgz#1628e6461ba8cc9b53196dfeaeec7b07fa6eea99"
integrity sha512-Uo4chgKbnPNlxQwoFmYIwctkQVkMMmsAoGGU4JKwLuvBefF0pCq4FybNSnfkfRCpC7ZW7kttcC/TrRtAJsvGtg==
version "13.9.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.0.tgz#5b6ee7a77faacddd7de719017d0bc12f52f81589"
integrity sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ==

"@types/node@^10.1.0":
version "10.14.5"
Expand Down Expand Up @@ -2043,6 +2013,11 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=

atob-lite@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696"
integrity sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=

atob@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
Expand Down Expand Up @@ -2197,7 +2172,7 @@ beeper@^1.0.0:
resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809"
integrity sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=

before-after-hook@^2.1.0:
before-after-hook@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635"
integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==
Expand Down Expand Up @@ -2451,6 +2426,11 @@ bs-snippet-injector@^2.0.1:
resolved "https://registry.yarnpkg.com/bs-snippet-injector/-/bs-snippet-injector-2.0.1.tgz#61b5393f11f52559ed120693100343b6edb04dd5"
integrity sha1-YbU5PxH1JVntEgaTEANDtu2wTdU=

btoa-lite@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337"
integrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc=

buffer-alloc-unsafe@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0"
Expand Down Expand Up @@ -3784,7 +3764,7 @@ deprecated@^0.0.1:
resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19"
integrity sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=

deprecation@^2.0.0, deprecation@^2.3.1:
deprecation@^2.0.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==
Expand Down Expand Up @@ -7193,7 +7173,7 @@ lodash.flatten@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=

lodash.get@^4.0.0:
lodash.get@^4.0.0, lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
Expand Down Expand Up @@ -7298,6 +7278,11 @@ lodash.restparam@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=

lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=

lodash.template@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-2.4.1.tgz#9e611007edf629129a974ab3c48b817b3e1cf20d"
Expand Down Expand Up @@ -7372,6 +7357,11 @@ lodash.union@^4.6.0:
resolved "https://registry.yarnpkg.com/lodash.union/-/lodash.union-4.6.0.tgz#48bb5088409f16f1821666641c44dd1aaae3cd88"
integrity sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=

lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash.values@^2.4.1, lodash.values@~2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/lodash.values/-/lodash.values-2.4.1.tgz#abf514436b3cb705001627978cbcf30b1280eea4"
Expand Down Expand Up @@ -8416,6 +8406,11 @@ objectdiff@^1.1.0:
resolved "https://registry.yarnpkg.com/objectdiff/-/objectdiff-1.1.0.tgz#8d7a15be6cb8670df8a490cc6be12a4f05ea82f4"
integrity sha1-jXoVvmy4Zw34pJDMa+EqTwXqgvQ=

octokit-pagination-methods@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz#cf472edc9d551055f9ef73f6e42b4dbb4c80bea4"
integrity sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==

on-finished@^2.2.0, on-finished@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
Expand Down Expand Up @@ -8564,7 +8559,7 @@ os-locale@^3.1.0:
lcid "^2.0.0"
mem "^4.0.0"

os-name@^3.1.0:
os-name@^3.0.0, os-name@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.1.0.tgz#dec19d966296e1cd62d701a5a66ee1ddeae70801"
integrity sha512-h8L+8aNjNcMpo/mAIBPn5PXCM16iyPGjHNWo6U1YO8sJTMHtEtyczI6QJnLoplswm6goopQkqc7OAnjhWcugVg==
Expand Down Expand Up @@ -11774,12 +11769,12 @@ universal-analytics@^0.4.16:
request "^2.88.0"
uuid "^3.0.0"

universal-user-agent@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.1.tgz#fd8d6cb773a679a709e967ef8288a31fcc03e557"
integrity sha512-LnST3ebHwVL2aNe4mejI9IQh2HfZ1RLo8Io2HugSif8ekzD1TlWpHpColOB/eh8JHMLkGH3Akqf040I+4ylNxg==
universal-user-agent@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-3.0.0.tgz#4cc88d68097bffd7ac42e3b7c903e7481424b4b9"
integrity sha512-T3siHThqoj5X0benA5H0qcDnrKGXzU8TKoX15x/tQHw1hQBvIEBHjxQ2klizYsqBOO/Q+WuxoQUihadeeqDnoA==
dependencies:
os-name "^3.1.0"
os-name "^3.0.0"

universal-user-agent@^5.0.0:
version "5.0.0"
Expand Down Expand Up @@ -11883,6 +11878,11 @@ url-parse-lax@^1.0.0:
dependencies:
prepend-http "^1.0.1"

url-template@^2.0.8:
version "2.0.8"
resolved "https://registry.yarnpkg.com/url-template/-/url-template-2.0.8.tgz#fc565a3cccbff7730c775f5641f9555791439f21"
integrity sha1-/FZaPMy/93MMd19WQflVV5FDnyE=

urlencode@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/urlencode/-/urlencode-1.1.0.tgz#1f2ba26f013c85f0133f7a3ad6ff2730adf7cbb7"
Expand Down

0 comments on commit 9e1b7ec

Please sign in to comment.