build: run tslint on tool files (#3436)

* Since we had a lot of TSLint issues on our tooling scripts & tasks, we should run TSLint on those as well.
* Also updates Dgeni to latest version, because it now supports TypeScript typings.
This commit is contained in:
Paul Gschwendtner
2017-03-07 01:52:21 +01:00
committed by tinayuangao
parent 819fa0b51f
commit 4ee2aef07c
6 changed files with 28 additions and 25 deletions
+1 -1
View File
@@ -54,7 +54,7 @@
"axe-core": "^2.1.7",
"axe-webdriverjs": "^0.5.0",
"conventional-changelog": "^1.1.0",
"dgeni": "^0.4.2",
"dgeni": "^0.4.7",
"dgeni-packages": "^0.16.5",
"firebase-admin": "^4.0.6",
"firebase-tools": "^2.2.1",
+14 -13
View File
@@ -1,12 +1,14 @@
import gulp = require('gulp');
import {task, src, dest} from 'gulp';
import {Dgeni} from 'dgeni';
import * as path from 'path';
// Node packages that lack of types.
const markdown = require('gulp-markdown');
const transform = require('gulp-transform');
const highlight = require('gulp-highlight-files');
const rename = require('gulp-rename');
const flatten = require('gulp-flatten');
const hljs = require('highlight.js');
import {task} from 'gulp';
import * as path from 'path';
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
// example code should be inserted. We replace these comments with divs that have a
@@ -19,10 +21,10 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
const LINK_PATTERN = /(<a[^>]*) href="([^"]*)"/g;
gulp.task('docs', ['markdown-docs', 'highlight-docs', 'api-docs'])
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']);
gulp.task('markdown-docs', () => {
return gulp.src(['src/lib/**/*.md', 'guides/*.md'])
task('markdown-docs', () => {
return src(['src/lib/**/*.md', 'guides/*.md'])
.pipe(markdown({
// Add syntax highlight using highlight.js
highlight: (code: string, language: string) => {
@@ -36,28 +38,27 @@ gulp.task('markdown-docs', () => {
}
}))
.pipe(transform(transformMarkdownFiles))
.pipe(gulp.dest('dist/docs/markdown'));
.pipe(dest('dist/docs/markdown'));
});
gulp.task('highlight-docs', () => {
task('highlight-docs', () => {
// rename files to fit format: [filename]-[filetype].html
const renameFile = (path: any) => {
const extension = path.extname.slice(1);
path.basename = `${path.basename}-${extension}`;
};
return gulp.src('src/examples/**/*.+(html|css|ts)')
return src('src/examples/**/*.+(html|css|ts)')
.pipe(flatten())
.pipe(rename(renameFile))
.pipe(highlight())
.pipe(gulp.dest('dist/docs/examples'));
.pipe(dest('dist/docs/examples'));
});
task('api-docs', () => {
const Dgeni = require('dgeni');
const docsPackage = require(path.resolve(__dirname, '../../dgeni'));
const dgeni = new Dgeni([docsPackage]);
return dgeni.generate();
const docs = new Dgeni([docsPackage]);
return docs.generate();
});
/** Updates the markdown file's content to work inside of the docs app. */
+1 -1
View File
@@ -3,7 +3,7 @@ import * as path from 'path';
import {SOURCE_ROOT, DIST_ROOT, PROJECT_ROOT} from '../constants';
import {
tsBuildTask, sassBuildTask, copyTask, buildAppTask, execNodeTask,
tsBuildTask, copyTask, buildAppTask, execNodeTask,
vendorTask, sequenceTask, serverTask
} from '../task_helpers';
+1 -1
View File
@@ -12,4 +12,4 @@ gulp.task('stylelint', execNodeTask(
));
/** Task to run TSLint against the e2e/ and src/ directories. */
gulp.task('tslint', execNodeTask('tslint', ['-c', 'tslint.json', 'src/**/*.ts', 'e2e/**/*.ts']));
gulp.task('tslint', execNodeTask('tslint', ['-c', 'tslint.json', '+(src|e2e|tools)/**/*.ts']));
+8 -6
View File
@@ -5,7 +5,6 @@ import * as admin from 'firebase-admin';
import {openScreenshotsBucket, openFirebaseScreenshotsDatabase} from '../task_helpers';
import {updateGithubStatus} from '../util-functions';
const request = require('request');
const imageDiff = require('image-diff');
const SCREENSHOT_DIR = './screenshots';
@@ -37,12 +36,15 @@ task('screenshots', () => {
function updateFileResult(database: admin.database.Database, prNumber: string,
filenameKey: string, result: boolean) {
return database.ref(FIREBASE_REPORT).child(prNumber).child('results').child(filenameKey).set(result);
return getPullRequestRef(database, prNumber).child('results').child(filenameKey).set(result);
}
function updateResult(database: admin.database.Database, prNumber: string,
result: boolean) {
return database.ref(FIREBASE_REPORT).child(prNumber).child('result').set(result).then(() => result);
function updateResult(database: admin.database.Database, prNumber: string, result: boolean) {
return getPullRequestRef(database, prNumber).child('result').set(result).then(() => result);
}
function getPullRequestRef(database: admin.database.Database, prNumber: string) {
return database.ref(FIREBASE_REPORT).child(prNumber);
}
function updateTravis(database: admin.database.Database,
@@ -58,7 +60,7 @@ function updateTravis(database: admin.database.Database,
function getScreenshotFiles(database: admin.database.Database) {
let bucket = openScreenshotsBucket();
return bucket.getFiles({ prefix: 'golds/' }).then(function(data: any) {
return data[0].filter((file:any) => file.name.endsWith('.screenshot.png'));
return data[0].filter((file: any) => file.name.endsWith('.screenshot.png'));
});
}
+3 -3
View File
@@ -9,7 +9,7 @@ export function updateGithubStatus(result: boolean, prNumber: string) {
let data = JSON.stringify({
state: state,
target_url: `http://material2-screenshots.firebaseapp.com/${prNumber}`,
context: "screenshot-diff",
context: 'screenshot-diff',
description: `Screenshot test ${state}`
});
@@ -20,13 +20,13 @@ export function updateGithubStatus(result: boolean, prNumber: string) {
'Content-Length': Buffer.byteLength(data)
};
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
request({
url: `https://api.github.com/repos/angular/material2/statuses/${sha}`,
method: 'POST',
form: data,
headers: headers
}, function (error: any, response: any, body: any){
}, function (error: any, response: any) {
resolve(response.statusCode);
});
});