Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 509f1b2

Browse files
committed
deps(latest): upgrade to the gulp and typescript (#5089)
* deps(latest): upgrade to the gulp and typescript - add in @types/loglevel and @types/yargs for webdriver-manager - upgrade tslint clean up for tslint - use latest gulp 4 and remove run sequence since this feature is supported by gulp - remove compile to es5
1 parent 2def202 commit 509f1b2

11 files changed

+3366
-970
lines changed

gulpfile.js

+41-57
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
'use strict';
22

3-
var gulp = require('gulp');
4-
var clangFormat = require('clang-format');
5-
var gulpFormat = require('gulp-clang-format');
6-
var runSequence = require('run-sequence');
7-
var spawn = require('child_process').spawn;
8-
var spawnSync = require('child_process').spawnSync;
9-
var tslint = require('gulp-tslint');
10-
var fs = require('fs');
11-
var path = require('path');
12-
var glob = require('glob');
13-
var semver = require('semver');
14-
15-
var runSpawn = function(done, task, opt_arg, opt_io) {
3+
const gulp = require('gulp');
4+
const format = require('gulp-clang-format');
5+
const clangFormat = require('clang-format');
6+
const spawn = require('child_process').spawn;
7+
const tslint = require('gulp-tslint');
8+
const fs = require('fs');
9+
const path = require('path');
10+
const semver = require('semver');
11+
12+
const runSpawn = (done, task, opt_arg, opt_io) => {
1613
opt_arg = typeof opt_arg !== 'undefined' ? opt_arg : [];
17-
var stdio = 'inherit';
14+
const stdio = 'inherit';
1815
if (opt_io === 'ignore') {
1916
stdio = 'ignore';
2017
}
21-
var child = spawn(task, opt_arg, {stdio: stdio});
22-
var running = false;
23-
child.on('close', function() {
18+
const child = spawn(task, opt_arg, {stdio: stdio});
19+
let running = false;
20+
child.on('close', () => {
2421
if (!running) {
2522
running = true;
2623
done();
2724
}
2825
});
29-
child.on('error', function() {
26+
child.on('error', () => {
3027
if (!running) {
3128
console.error('gulp encountered a child error');
3229
running = true;
@@ -35,21 +32,25 @@ var runSpawn = function(done, task, opt_arg, opt_io) {
3532
});
3633
};
3734

38-
gulp.task('tslint', function() {
35+
gulp.task('tslint', () => {
3936
return gulp.src(['lib/**/*.ts', 'spec/**/*.ts', '!spec/install/**/*.ts'])
40-
.pipe(tslint()).pipe(tslint.report());
37+
.pipe(tslint())
38+
.pipe(tslint.report());
4139
});
4240

43-
gulp.task('lint', function(done) {
44-
runSequence('tslint', 'format:enforce', done);
41+
gulp.task('format:enforce', () => {
42+
return gulp.src(['lib/**/*.ts'])
43+
.pipe(format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
4544
});
4645

46+
gulp.task('lint', gulp.series('tslint', 'format:enforce'));
47+
4748
// prevent contributors from using the wrong version of node
48-
gulp.task('checkVersion', function(done) {
49+
gulp.task('checkVersion', (done) => {
4950
// read minimum node on package.json
50-
var packageJson = JSON.parse(fs.readFileSync(path.resolve('package.json')));
51-
var protractorVersion = packageJson.version;
52-
var nodeVersion = packageJson.engines.node;
51+
const packageJson = JSON.parse(fs.readFileSync(path.resolve('package.json')));
52+
const protractorVersion = packageJson.version;
53+
const nodeVersion = packageJson.engines.node;
5354

5455
if (semver.satisfies(process.version, nodeVersion)) {
5556
done();
@@ -59,52 +60,35 @@ gulp.task('checkVersion', function(done) {
5960
}
6061
});
6162

62-
gulp.task('built:copy', function() {
63+
gulp.task('built:copy', () => {
6364
return gulp.src(['lib/**/*.js'])
6465
.pipe(gulp.dest('built/'));
6566
});
6667

67-
gulp.task('webdriver:update', function(done) {
68+
gulp.task('webdriver:update', (done) => {
6869
runSpawn(done, 'node', ['bin/webdriver-manager', 'update']);
6970
});
7071

71-
gulp.task('format:enforce', function() {
72-
var format = require('gulp-clang-format');
73-
var clangFormat = require('clang-format');
74-
return gulp.src(['lib/**/*.ts']).pipe(
75-
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
76-
});
77-
78-
gulp.task('format', function() {
79-
var format = require('gulp-clang-format');
80-
var clangFormat = require('clang-format');
81-
return gulp.src(['lib/**/*.ts'], { base: '.' }).pipe(
82-
format.format('file', clangFormat)).pipe(gulp.dest('.'));
72+
gulp.task('format', () => {
73+
return gulp.src(['lib/**/*.ts'], { base: '.' })
74+
.pipe(format.format('file', clangFormat))
75+
.pipe(gulp.dest('.'));
8376
});
8477

85-
gulp.task('tsc', function(done) {
78+
gulp.task('tsc', (done) => {
8679
runSpawn(done, 'node', ['node_modules/typescript/bin/tsc']);
8780
});
8881

89-
gulp.task('tsc:spec', function(done) {
82+
gulp.task('tsc:spec', (done) => {
9083
runSpawn(done, 'node', ['node_modules/typescript/bin/tsc', '-p', 'ts_spec_config.json']);
9184
});
9285

93-
gulp.task('tsc:es5', function(done) {
94-
runSpawn(done, './scripts/compile_to_es5.sh');
95-
});
96-
97-
gulp.task('compile_to_es5', function(done) {
98-
runSequence('checkVersion', 'tsc:es5', 'built:copy', done);
99-
});
86+
gulp.task('prepublish', gulp.series('checkVersion', 'tsc', 'built:copy'));
10087

101-
gulp.task('prepublish', function(done) {
102-
runSequence('checkVersion', 'tsc', 'built:copy', done);
103-
});
88+
gulp.task('pretest', gulp.series(
89+
'checkVersion',
90+
gulp.parallel('webdriver:update', 'tslint', 'format'),
91+
'tsc', 'built:copy', 'tsc:spec'));
10492

105-
gulp.task('pretest', function(done) {
106-
runSequence('checkVersion',
107-
['webdriver:update', 'tslint', 'format'], 'tsc', 'built:copy', 'tsc:spec', done);
108-
});
93+
gulp.task('default', gulp.series('prepublish'));
10994

110-
gulp.task('default',['prepublish']);

lib/browser.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function ptorMixin(to: any, from: any, fnName: string, setupFn?: Function) {
7272
}
7373
return run();
7474
};
75-
};
75+
}
7676

7777
export interface ElementHelper extends Function {
7878
(locator: Locator): ElementFinder;
@@ -96,7 +96,7 @@ function buildElementHelper(browser: ProtractorBrowser): ElementHelper {
9696
};
9797

9898
return element;
99-
};
99+
}
100100

101101
/**
102102
* @alias browser
@@ -725,7 +725,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
725725
*/
726726
getRegisteredMockModules(): Array<string|Function> {
727727
return this.mockModules_.map(module => module.script);
728-
};
728+
}
729729

730730
/**
731731
* Add the base mock modules used for all Protractor tests.

lib/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function processFilePatterns_(list: string): Array<string> {
201201
return list.split(',').map(function(spec) {
202202
return path.resolve(process.cwd(), spec);
203203
});
204-
};
204+
}
205205

206206
if (argv.specs) {
207207
argv.specs = processFilePatterns_(<string>argv.specs);

lib/driverProviders/driverProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export abstract class DriverProvider {
9696
* Default update job method.
9797
* @return a promise
9898
*/
99-
async updateJob(update: any): Promise<any>{};
99+
async updateJob(update: any): Promise<any> {}
100100

101101
/**
102102
* Default setup environment method, common to all driver providers.
@@ -106,7 +106,7 @@ export abstract class DriverProvider {
106106
if (this.config_.useBlockingProxy && !this.config_.blockingProxyUrl) {
107107
await this.bpRunner.start();
108108
}
109-
};
109+
}
110110

111111
/**
112112
* Set up environment specific to a particular driver provider. Overridden

lib/element.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
310310
*/
311311
first(): ElementFinder {
312312
return this.get(0);
313-
};
313+
}
314314

315315
/**
316316
* Get the last matching element for the ElementArrayFinder. This does not
@@ -643,7 +643,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
643643
return await mapResult;
644644
});
645645
return Promise.all(list);
646-
};
646+
}
647647

648648
/**
649649
* Apply a reduce function against an accumulator and every element found

lib/expectedConditions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {falseIfMissing, passBoolean} from './util';
4545
* @constructor
4646
*/
4747
export class ProtractorExpectedConditions {
48-
constructor(public browser: ProtractorBrowser){};
48+
constructor(public browser: ProtractorBrowser) {}
4949

5050
/**
5151
* Negates the result of a promise.
@@ -351,7 +351,7 @@ export class ProtractorExpectedConditions {
351351
*/
352352
presenceOf(elementFinder: ElementFinder): Function {
353353
return elementFinder.isPresent.bind(elementFinder);
354-
};
354+
}
355355

356356
/**
357357
* An expectation for checking that an element is not attached to the DOM

lib/locators.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class ProtractorBy extends WebdriverBy {
9898
}
9999
};
100100
};
101-
};
101+
}
102102

103103
/**
104104
* Find an element by text binding. Does a partial match, so any elements
@@ -143,7 +143,7 @@ export class ProtractorBy extends WebdriverBy {
143143
return 'by.binding("' + bindingDescriptor + '")';
144144
}
145145
};
146-
};
146+
}
147147

148148
/**
149149
* Find an element by exact binding.
@@ -177,7 +177,7 @@ export class ProtractorBy extends WebdriverBy {
177177
return 'by.exactBinding("' + bindingDescriptor + '")';
178178
}
179179
};
180-
};
180+
}
181181

182182
/**
183183
* Find an element by ng-model expression.
@@ -207,7 +207,7 @@ export class ProtractorBy extends WebdriverBy {
207207
return 'by.model("' + model + '")';
208208
}
209209
};
210-
};
210+
}
211211

212212
/**
213213
* Find a button by text.
@@ -234,7 +234,7 @@ export class ProtractorBy extends WebdriverBy {
234234
return 'by.buttonText("' + searchText + '")';
235235
}
236236
};
237-
};
237+
}
238238

239239
/**
240240
* Find a button by partial text.
@@ -261,7 +261,7 @@ export class ProtractorBy extends WebdriverBy {
261261
return 'by.partialButtonText("' + searchText + '")';
262262
}
263263
};
264-
};
264+
}
265265

266266
// Generate either by.repeater or by.exactRepeater
267267
private byRepeaterInner(exact: boolean, repeatDescriptor: string): ProtractorLocator {
@@ -448,7 +448,7 @@ export class ProtractorBy extends WebdriverBy {
448448
return 'by.cssContainingText("' + cssSelector + '", "' + searchText + '")';
449449
}
450450
};
451-
};
451+
}
452452

453453
/**
454454
* Find an element by ng-options expression.
@@ -482,7 +482,7 @@ export class ProtractorBy extends WebdriverBy {
482482
return 'by.option("' + optionsDescriptor + '")';
483483
}
484484
};
485-
};
485+
}
486486

487487
/**
488488
* Find an element by css selector within the Shadow DOM.
@@ -509,5 +509,5 @@ export class ProtractorBy extends WebdriverBy {
509509
// TODO(julie): syntax will change from /deep/ to >>> at some point.
510510
// When that is supported, switch it here.
511511
return By.css('* /deep/ ' + selector);
512-
};
512+
}
513513
}

lib/plugins.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export class Plugins {
310310
this.pluginObjs.push(pluginObj);
311311
});
312312
}
313-
};
313+
}
314314

315315
/**
316316
* Adds properties to a plugin's object
@@ -398,7 +398,7 @@ export class Plugins {
398398
this.printPluginResults(results.specResults);
399399
this.resultsReported = true;
400400
return results;
401-
};
401+
}
402402

403403
/**
404404
* Returns true if any loaded plugin has skipAngularStability enabled.
@@ -408,7 +408,7 @@ export class Plugins {
408408
skipAngularStability() {
409409
const result = this.pluginObjs.some(pluginObj => pluginObj.skipAngularStability);
410410
return result;
411-
};
411+
}
412412

413413
/**
414414
* @see docs/plugins.md#writing-plugins for information on these functions

0 commit comments

Comments
 (0)