Skip to content

Commit 64350e8

Browse files
committed
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.
1 parent f899161 commit 64350e8

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

tools/release/release-output/check-package.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import {
99
checkMaterialPackage,
1010
checkPackageJsonFile,
1111
checkPackageJsonMigrations,
12-
checkReleaseBundle,
12+
checkJavaScriptOutput,
1313
checkTypeDefinitionFile
1414
} from './output-validations';
1515

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

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

49-
const bundlePaths = glob(releaseBundlesGlob, {cwd: packagePath, absolute: true});
49+
const jsFiles = glob(releaseJsFilesGlob, {cwd: packagePath, absolute: true});
5050
const typeDefinitions = glob(releaseTypeDefinitionsGlob, {cwd: packagePath, absolute: true});
5151
const packageJsonFiles = glob(packageJsonFilesGlob, {cwd: packagePath, absolute: true});
5252

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

5959
// Run output validations for all TypeScript definition files within the release output.

tools/release/release-output/output-validations.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const inlineStylesSourcemapRegex = /styles: ?\[["'].*sourceMappingURL=.*["']/;
1111
/** RegExp that matches Angular component metadata properties that refer to external resources. */
1212
const externalReferencesRegex = /(templateUrl|styleUrls): *["'[]/;
1313

14+
/** RegExp that matches common Bazel manifest paths in this workspace */
15+
const bazelManifestPath = /(angular_material|external)\//;
16+
1417
/**
1518
* List of fields which are mandatory in entry-point "package.json" files and refer
1619
* to files in the release output.
@@ -19,21 +22,25 @@ const packageJsonPathFields =
1922
['main', 'module', 'typings', 'es2015', 'fesm5', 'fesm2015', 'esm5', 'esm2015'];
2023

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

29-
if (inlineStylesSourcemapRegex.exec(bundleContent) !== null) {
32+
if (inlineStylesSourcemapRegex.exec(fileContent) !== null) {
3033
failures.push('Found sourcemap references in component styles.');
3134
}
3235

33-
if (externalReferencesRegex.exec(bundleContent) !== null) {
36+
if (externalReferencesRegex.exec(fileContent) !== null) {
3437
failures.push('Found external component resource references');
3538
}
3639

40+
if (bazelManifestPath.exec(fileContent) !== null) {
41+
failures.push('Found Bazel manifest path in output.');
42+
}
43+
3744
return failures;
3845
}
3946

0 commit comments

Comments
 (0)