Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: run tslint on tool files #3436

Merged
merged 1 commit into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 14 additions & 13 deletions tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) => {
Expand All @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion tools/gulp/tasks/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion tools/gulp/tasks/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
14 changes: 8 additions & 6 deletions tools/gulp/tasks/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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'));
});
}

Expand Down
6 changes: 3 additions & 3 deletions tools/gulp/util-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
});

Expand All @@ -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);
});
});
Expand Down