Skip to content
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
63 changes: 43 additions & 20 deletions gulpfile.js → gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,72 @@
*
*/

const _gulp = require('gulp');
const help = require('gulp-help');
import * as _gulp from 'gulp';
import * as help from 'gulp-help';

// gulp-help monkeypatches tasks to have an additional description parameter
const gulp = help(_gulp);

var runSequence = require('run-sequence');
const runSequence = require('run-sequence');

require('./packages/grpc-health-check/gulpfile');
require('./packages/grpc-js/gulpfile');
require('./packages/grpc-js-core/gulpfile');
require('./packages/grpc-native/gulpfile');
require('./packages/grpc-native-core/gulpfile');
require('./packages/grpc-surface/gulpfile');
require('./test/gulpfile');
/**
* Require a module at the given path with a patched gulp object that prepends
* the given prefix to each task name.
* @param path The path to require.
* @param prefix The string to use as a prefix. This will be prepended to a task
* name with a '.' separator.
*/
function loadGulpTasksWithPrefix(path: string, prefix: string) {
const gulpTask = gulp.task;
gulp.task = ((taskName: string, ...args: any[]) => {
// Don't create a task for ${prefix}.help
if (taskName === 'help') {
return;
}
// The only array passed to gulp.task must be a list of dependent tasks.
const newArgs = args.map(arg => Array.isArray(arg) ?
arg.map(dep => `${prefix}.${dep}`) : arg);
gulpTask(`${prefix}.${taskName}`, ...newArgs);
});
const result = require(path);
gulp.task = gulpTask;
return result;
}

[
['./packages/grpc-health-check/gulpfile', 'health-check'],
['./packages/grpc-js/gulpfile', 'js'],
['./packages/grpc-js-core/gulpfile', 'js.core'],
['./packages/grpc-native/gulpfile', 'native'],
['./packages/grpc-native-core/gulpfile', 'native.core'],
['./packages/grpc-surface/gulpfile', 'surface'],
['./test/gulpfile', 'internal.test']
].forEach((args) => loadGulpTasksWithPrefix(args[0], args[1]));

const root = __dirname;

gulp.task('install.all', 'Install dependencies for all subdirectory packages',
['js.core.install', 'native.core.install', 'surface.install', 'health-check.install', 'internal.test.install']);
['js.install', 'js.core.install', 'native.core.install', 'surface.install', 'health-check.install', 'internal.test.install']);

gulp.task('install.all.windows', 'Install dependencies for all subdirectory packages for MS Windows',
['js.core.install', 'native.core.install.windows', 'surface.install', 'health-check.install', 'internal.test.install']);

gulp.task('lint', 'Emit linting errors in source and test files',
['js.core.lint', 'native.core.lint']);

gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build']);
gulp.task('build', 'Build packages', ['js.compile', 'js.core.compile', 'native.core.build']);

gulp.task('core.link', 'Add links to core packages without rebuilding',
gulp.task('link.core', 'Add links to core packages without rebuilding',
['js.link.add', 'native.link.add']);

gulp.task('surface.link', 'Link to surface packages',
gulp.task('link.surface', 'Link to surface packages',
['health-check.link.add']);

gulp.task('link', 'Link together packages', (callback) => {
/* Currently, the target 'surface.link.create' doesn't work properly, and it
* is also not needed for the existing tests. The comment indicates where it
* belongs in the sequence. See npm/npm#18835 for the primary problem with it.
* This also means that 'core.link' is not needed, and the item
* 'native.core.link.create' should actually be 'core.link.create'
/**
* We use workarounds for linking in some modules. See npm/npm#18835
*/
runSequence('core.link', 'surface.link',
runSequence('link.core', 'link.surface',
callback);
});

Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/execa": "^0.8.0",
"@types/gulp": "^4.0.5",
"@types/gulp-help": "0.0.34",
"@types/gulp-mocha": "0.0.31",
"@types/ncp": "^2.0.1",
"@types/node": "^8.0.32",
"@types/pify": "^3.0.0",
"del": "^3.0.0",
"execa": "^0.8.0",
"gulp": "^3.9.1",
Expand All @@ -27,7 +33,10 @@
"merge2": "^1.1.0",
"mocha": "^3.5.3",
"mocha-jenkins-reporter": "^0.3.9",
"ncp": "^2.0.0",
"pify": "^3.0.0",
"through2": "^2.0.3",
"ts-node": "^3.3.0",
"tslint": "^5.5.0",
"typescript": "^2.5.1",
"xml2js": "^0.4.19"
Expand Down
12 changes: 6 additions & 6 deletions packages/grpc-health-check/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ const healthCheckDir = __dirname;
const baseDir = path.resolve(healthCheckDir, '..', '..');
const testDir = path.resolve(healthCheckDir, 'test');

gulp.task('health-check.clean.links', 'Delete npm links', () => {
gulp.task('clean.links', 'Delete npm links', () => {
return del(path.resolve(healthCheckDir, 'node_modules/grpc'));
});

gulp.task('health-check.clean.all', 'Delete all code created by tasks',
['health-check.clean.links']);
gulp.task('clean.all', 'Delete all code created by tasks',
['clean.links']);

gulp.task('health-check.install', 'Install health check dependencies', () => {
gulp.task('install', 'Install health check dependencies', () => {
return execa('npm', ['install', '--unsafe-perm'], {cwd: healthCheckDir, stdio: 'inherit'});
});

gulp.task('health-check.link.add', 'Link local copy of grpc', () => {
gulp.task('link.add', 'Link local copy of grpc', () => {
linkSync(healthCheckDir, './node_modules/grpc', '../grpc-native-core');
});

gulp.task('health-check.test', 'Run health check tests',
gulp.task('test', 'Run health check tests',
() => {
return gulp.src(`${testDir}/*.js`).pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
});
197 changes: 0 additions & 197 deletions packages/grpc-js-core/gulpfile.js

This file was deleted.

Loading