diff --git a/tools/gulp/tasks/validate-release.ts b/tools/gulp/tasks/validate-release.ts index 95bf37a11f60..c538b0ed75ce 100644 --- a/tools/gulp/tasks/validate-release.ts +++ b/tools/gulp/tasks/validate-release.ts @@ -39,7 +39,7 @@ task('validate-release:check-bundles', () => { function checkReleasePackage(packageName: string): string[] { const bundlePath = join(releasesDir, packageName, '@angular', `${packageName}.js`); const bundleContent = readFileSync(bundlePath, 'utf8'); - let failures = []; + let failures: string[] = []; if (inlineStylesSourcemapRegex.exec(bundleContent) !== null) { failures.push('Bundles contain sourcemap references in component styles.'); @@ -61,7 +61,7 @@ function checkMaterialPackage(): string[] { const packagePath = join(releasesDir, 'material'); const prebuiltThemesPath = join(packagePath, 'prebuilt-themes'); const themingFilePath = join(packagePath, '_theming.scss'); - const failures = []; + const failures: string[] = []; if (glob('*.css', {cwd: prebuiltThemesPath}).length === 0) { failures.push('Prebuilt themes are not present in the Material release output.'); diff --git a/tools/package-tools/build-bundles.ts b/tools/package-tools/build-bundles.ts index 2e7465d9d47b..e08a8986ddac 100644 --- a/tools/package-tools/build-bundles.ts +++ b/tools/package-tools/build-bundles.ts @@ -1,5 +1,4 @@ import {join} from 'path'; -import {readdirSync, lstatSync} from 'fs'; import {ScriptTarget, ModuleKind, NewLineKind} from 'typescript'; import {uglifyJsFile} from './minify-sources'; import {createRollupBundle} from './rollup-helpers'; diff --git a/tools/package-tools/build-release.ts b/tools/package-tools/build-release.ts index 0792176b52cd..b64aaaf74703 100644 --- a/tools/package-tools/build-release.ts +++ b/tools/package-tools/build-release.ts @@ -48,7 +48,8 @@ export function composeRelease(packageName: string, options: ComposeReleaseOptio } /** Creates files necessary for a secondary entry-point. */ -function createFilesForSecondaryEntryPoint(packageName: string, packagePath: string, releasePath: string) { +function createFilesForSecondaryEntryPoint(packageName: string, packagePath: string, + releasePath: string) { getSecondaryEntryPointsForPackage(packageName).forEach(entryPointName => { // Create a directory in the root of the package for this entry point that contains // * A package.json that lists the different bundle locations diff --git a/tools/package-tools/entry-point-package-json.ts b/tools/package-tools/entry-point-package-json.ts index c6b0ae4e39d5..60026c172f1e 100644 --- a/tools/package-tools/entry-point-package-json.ts +++ b/tools/package-tools/entry-point-package-json.ts @@ -1,8 +1,9 @@ import {join} from 'path'; -import {lstatSync, readdirSync, writeFileSync} from 'fs'; +import {writeFileSync} from 'fs'; /** Creates a package.json for a secondary entry-point with the different bundle locations. */ -export function createEntryPointPackageJson(destDir: string, packageName: string, entryPointName: string) { +export function createEntryPointPackageJson(destDir: string, packageName: string, + entryPointName: string) { const content = { name: `@angular/${packageName}/${entryPointName}`, typings: `../${entryPointName}.d.ts`, diff --git a/tools/package-tools/gulp/build-tasks-gulp.ts b/tools/package-tools/gulp/build-tasks-gulp.ts index a8fdeead324a..eaa9cf54069a 100644 --- a/tools/package-tools/gulp/build-tasks-gulp.ts +++ b/tools/package-tools/gulp/build-tasks-gulp.ts @@ -1,6 +1,5 @@ import {dest, src, task} from 'gulp'; import {join} from 'path'; -import {readFileSync, unlink, writeFileSync} from 'fs'; import {main as tsc} from '@angular/tsc-wrapped'; import {buildConfig} from '../build-config'; import {composeRelease} from '../build-release'; @@ -27,8 +26,11 @@ const htmlMinifierOptions = { * Creates a set of gulp tasks that can build the specified package. * @param packageName Name of the package. Needs to be similar to the directory name in `src/`. * @param dependencies Required packages that will be built before building the current package. + * @param options Options that can be passed to adjust the gulp package tasks. */ -export function createPackageBuildTasks(packageName: string, dependencies: string[] = [], options: PackageTaskOptions = {}) { +export function createPackageBuildTasks(packageName: string, dependencies: string[] = [], + options: PackageTaskOptions = {}) { + // To avoid refactoring of the project the package material will map to the source path `lib/`. const packageRoot = join(packagesDir, packageName === 'material' ? 'lib' : packageName); const packageOut = join(outputDir, 'packages', packageName); diff --git a/tools/package-tools/secondary-entry-points.ts b/tools/package-tools/secondary-entry-points.ts index e81dc4f30135..fca0b036e641 100644 --- a/tools/package-tools/secondary-entry-points.ts +++ b/tools/package-tools/secondary-entry-points.ts @@ -1,8 +1,3 @@ -import {join} from 'path'; -import {readdirSync, lstatSync} from 'fs'; -import {buildConfig} from './build-config'; - - /** * List of cdk entry-points in the order that they must be built. This is necessary because * some of the entry-points depend on each other. This is temporary until we switch to bazel. diff --git a/tools/screenshot-test/functions/github.ts b/tools/screenshot-test/functions/github.ts index 87e1fbddb6e4..aea5305d811a 100644 --- a/tools/screenshot-test/functions/github.ts +++ b/tools/screenshot-test/functions/github.ts @@ -14,11 +14,13 @@ const authDomain = firebaseFunctions.config().firebase.authDomain; const toolName = firebaseFunctions.config().tool.name; export function updateGithubStatus(event: firebaseFunctions.Event) { - if (!event.data.exists() || typeof event.data.val() != 'boolean') { + if (!event.data.exists() || typeof event.data.val() != 'boolean' && event.params) { return; } - let result = event.data.val() == true; - let {prNumber, sha} = event.params; + + const result = event.data.val() == true; + const {prNumber, sha} = event.params!; + return setGithubStatus(sha, { result: result, name: toolName, diff --git a/tools/screenshot-test/functions/jwt-util.ts b/tools/screenshot-test/functions/jwt-util.ts index 12b6fcab0379..de36ff87b947 100644 --- a/tools/screenshot-test/functions/jwt-util.ts +++ b/tools/screenshot-test/functions/jwt-util.ts @@ -13,17 +13,18 @@ const secret = firebaseFunctions.config().secret.key; * Replace '/' with '.' to get the token. */ function getSecureToken(event: firebaseFunctions.Event) { - let {jwtHeader, jwtPayload, jwtSignature} = event.params; + const {jwtHeader, jwtPayload, jwtSignature} = event.params!; return `${jwtHeader}.${jwtPayload}.${jwtSignature}`; } + /** * Verify that the event has a valid JsonWebToken. If the token is *not* valid, * the data tied to the event will be deleted and the function will return a rejected promise. */ export function verifySecureToken(event: firebaseFunctions.Event) { return new Promise((resolve, reject) => { - const prNumber = event.params['prNumber']; + const prNumber = event.params!['prNumber']; const secureToken = getSecureToken(event); return verifyJWT(secureToken, prNumber, secret, repoSlug).then(() => { diff --git a/tools/screenshot-test/functions/test-goldens.ts b/tools/screenshot-test/functions/test-goldens.ts index fdb384d8654c..98f61d94cb16 100644 --- a/tools/screenshot-test/functions/test-goldens.ts +++ b/tools/screenshot-test/functions/test-goldens.ts @@ -15,17 +15,18 @@ const bucket = gcs.bucket(firebaseFunctions.config().firebase.storageBucket); export function copyTestImagesToGoldens(prNumber: string) { return firebaseAdmin.database().ref(`screenshot/reports/${prNumber}/results`).once('value') .then((snapshot: firebaseAdmin.database.DataSnapshot) => { - let failedFilenames: string[] = []; + const failedFilenames: string[] = []; let counter = 0; - snapshot.forEach((childSnapshot: firebaseAdmin.database.DataSnapshot) => { - if (childSnapshot.val() === false) { + + snapshot.forEach(childSnapshot => { + if (childSnapshot.key && childSnapshot.val() === false) { failedFilenames.push(childSnapshot.key); } + counter++; - if (counter == snapshot.numChildren()) { - return true; - } + return counter === snapshot.numChildren(); }); + return failedFilenames; }).then((failedFilenames: string[]) => { return bucket.getFiles({prefix: `screenshots/${prNumber}/test`}).then((data: any) => { diff --git a/tools/screenshot-test/src/app/firebase.service.ts b/tools/screenshot-test/src/app/firebase.service.ts index b5ad1591a118..fed28b72a409 100644 --- a/tools/screenshot-test/src/app/firebase.service.ts +++ b/tools/screenshot-test/src/app/firebase.service.ts @@ -71,10 +71,9 @@ export class FirebaseService { this._readResults(childSnapshot); break; } + counter++; - if (counter === snapshot.numChildren()) { - return true; - } + return counter === snapshot.numChildren(); }); }); } @@ -123,11 +122,11 @@ export class FirebaseService { this.screenshotResultSummary.testNames = []; this.screenshotResultSummary.testResultsByName.clear(); childSnapshot.forEach((resultSnapshot: firebase.database.DataSnapshot) => { - this._addTestResults(resultSnapshot.key, resultSnapshot.val()); - childCounter++; - if (childCounter === childSnapshot.numChildren()) { - return true; + if (resultSnapshot.key) { + this._addTestResults(resultSnapshot.key, resultSnapshot.val()); } + childCounter++; + return childCounter === childSnapshot.numChildren(); }); } diff --git a/tsconfig.json b/tsconfig.json index 939147d5ef40..6df0c68296f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,13 +16,14 @@ "baseUrl": ".", "paths": { "@angular/material": ["./src/lib/public_api.ts"], - "@angular/cdk*": ["./src/cdk/*"], - "@angular/material-examples": ["./src/material-examples"] + "@angular/cdk/*": ["./src/cdk/*"], + "@angular/material-examples": ["./src/material-examples"], + "material2-build-tools": ["./tools/package-tools"] } }, "include": [ "src/**/*.ts", - "tools/**.ts" + "tools/**/*.ts" ], "exclude": [ // Exclude files that depend on Node APIs because those depend on the Node types and therefore @@ -31,6 +32,8 @@ // IDEs should not type-check the different node_modules directories of the different packages. // This would cause the IDEs to be slower and also linters would check the node_modules. - "**/node_modules" + "node_modules/", + "tools/dashboard/node_modules/", + "tools/screenshot-test/node_modules/" ] }