mirror of https://github.com/grpc/grpc-node.git
Update gulp to version 4, rewrite scripts
This commit is contained in:
parent
7ee7154fd6
commit
df57548805
111
gulpfile.ts
111
gulpfile.ts
|
@ -15,96 +15,55 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as _gulp from 'gulp';
|
import * as gulp from 'gulp';
|
||||||
import * as help from 'gulp-help';
|
import * as healthCheck from './packages/grpc-health-check/gulpfile';
|
||||||
|
import * as jsCore from './packages/grpc-js/gulpfile';
|
||||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
import * as nativeCore from './packages/grpc-native-core/gulpfile';
|
||||||
const gulp = help(_gulp);
|
import * as protobuf from './packages/proto-loader/gulpfile';
|
||||||
|
import * as internalTest from './test/gulpfile';
|
||||||
const runSequence = require('run-sequence');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.core'],
|
|
||||||
['./packages/grpc-native-core/gulpfile', 'native.core'],
|
|
||||||
['./packages/proto-loader/gulpfile', 'protobuf'],
|
|
||||||
['./test/gulpfile', 'internal.test'],
|
|
||||||
].forEach((args) => loadGulpTasksWithPrefix(args[0], args[1]));
|
|
||||||
|
|
||||||
const root = __dirname;
|
const root = __dirname;
|
||||||
|
|
||||||
gulp.task('install.all', 'Install dependencies for all subdirectory packages',
|
const installAll = gulp.parallel(jsCore.install, nativeCore.install, healthCheck.install, protobuf.install, internalTest.install);
|
||||||
['js.core.install', 'native.core.install', 'health-check.install', 'protobuf.install', 'internal.test.install']);
|
|
||||||
|
|
||||||
gulp.task('install.all.windows', 'Install dependencies for all subdirectory packages for MS Windows',
|
const installAllWindows = gulp.parallel(jsCore.install, nativeCore.installWindows, healthCheck.install, protobuf.install, internalTest.install);
|
||||||
['js.core.install', 'native.core.install.windows', 'health-check.install', 'protobuf.install', 'internal.test.install']);
|
|
||||||
|
|
||||||
gulp.task('lint', 'Emit linting errors in source and test files',
|
const lint = gulp.parallel(jsCore.lint, nativeCore.lint);
|
||||||
['js.core.lint', 'native.core.lint']);
|
|
||||||
|
|
||||||
gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build', 'protobuf.compile']);
|
const build = gulp.parallel(jsCore.compile, nativeCore.build, protobuf.compile);
|
||||||
|
|
||||||
gulp.task('link.surface', 'Link to surface packages',
|
const link = gulp.series(healthCheck.linkAdd);
|
||||||
['health-check.link.add']);
|
|
||||||
|
|
||||||
gulp.task('link', 'Link together packages', (callback) => {
|
const setup = gulp.series(installAll, link);
|
||||||
/**
|
|
||||||
* We use workarounds for linking in some modules. See npm/npm#18835
|
|
||||||
*/
|
|
||||||
runSequence('link.surface', callback);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('setup', 'One-time setup for a clean repository', (callback) => {
|
const setupWindows = gulp.series(installAllWindows, link);
|
||||||
runSequence('install.all', 'link', callback);
|
|
||||||
});
|
|
||||||
gulp.task('setup.windows', 'One-time setup for a clean repository for MS Windows', (callback) => {
|
|
||||||
runSequence('install.all.windows', 'link', callback);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('clean', 'Delete generated files', ['js.core.clean', 'native.core.clean', 'protobuf.clean']);
|
const clean = gulp.parallel(jsCore.clean, nativeCore.clean, protobuf.clean);
|
||||||
|
|
||||||
gulp.task('clean.all', 'Delete all files created by tasks',
|
const cleanAll = gulp.parallel(jsCore.cleanAll, nativeCore.cleanAll, healthCheck.cleanAll, internalTest.cleanAll, protobuf.cleanAll);
|
||||||
['js.core.clean.all', 'native.core.clean.all', 'health-check.clean.all',
|
|
||||||
'internal.test.clean.all', 'protobuf.clean.all']);
|
|
||||||
|
|
||||||
gulp.task('native.test.only', 'Run tests of native code without rebuilding anything',
|
const nativeTestOnly = gulp.parallel(nativeCore.test, healthCheck.test);
|
||||||
['native.core.test', 'health-check.test']);
|
|
||||||
|
|
||||||
gulp.task('native.test', 'Run tests of native code', (callback) => {
|
const nativeTest = gulp.series(build, nativeTestOnly);
|
||||||
runSequence('build', 'native.test.only', callback);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('test.only', 'Run tests without rebuilding anything',
|
const testOnly = gulp.parallel(jsCore.test, nativeTestOnly, protobuf.test);
|
||||||
['js.core.test', 'native.test.only', 'protobuf.test']);
|
|
||||||
|
|
||||||
gulp.task('test', 'Run all tests', (callback) => {
|
const test = gulp.series(build, testOnly, internalTest.test);
|
||||||
runSequence('build', 'test.only', 'internal.test.test', callback);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('doc.gen', 'Generate documentation', ['native.core.doc.gen']);
|
const docGen = gulp.series(nativeCore.docGen);
|
||||||
|
|
||||||
gulp.task('default', ['help']);
|
export {
|
||||||
|
installAll,
|
||||||
|
installAllWindows,
|
||||||
|
lint,
|
||||||
|
build,
|
||||||
|
link,
|
||||||
|
setup,
|
||||||
|
setupWindows,
|
||||||
|
clean,
|
||||||
|
cleanAll,
|
||||||
|
nativeTestOnly,
|
||||||
|
nativeTest,
|
||||||
|
test,
|
||||||
|
docGen
|
||||||
|
};
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/execa": "^0.8.0",
|
"@types/execa": "^0.8.0",
|
||||||
"@types/gulp": "^4.0.5",
|
"@types/gulp": "^4.0.5",
|
||||||
"@types/gulp-help": "0.0.34",
|
|
||||||
"@types/gulp-mocha": "0.0.31",
|
"@types/gulp-mocha": "0.0.31",
|
||||||
"@types/ncp": "^2.0.1",
|
"@types/ncp": "^2.0.1",
|
||||||
"@types/node": "^8.0.32",
|
"@types/node": "^8.0.32",
|
||||||
|
@ -20,8 +19,7 @@
|
||||||
"coveralls": "^3.0.1",
|
"coveralls": "^3.0.1",
|
||||||
"del": "^3.0.0",
|
"del": "^3.0.0",
|
||||||
"execa": "^0.8.0",
|
"execa": "^0.8.0",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^4.0.1",
|
||||||
"gulp-help": "^1.6.1",
|
|
||||||
"gulp-jsdoc3": "^1.0.1",
|
"gulp-jsdoc3": "^1.0.1",
|
||||||
"gulp-jshint": "^2.0.4",
|
"gulp-jshint": "^2.0.4",
|
||||||
"gulp-mocha": "^4.3.1",
|
"gulp-mocha": "^4.3.1",
|
||||||
|
@ -42,7 +40,7 @@
|
||||||
"semver": "^5.5.0",
|
"semver": "^5.5.0",
|
||||||
"symlink": "^2.1.0",
|
"symlink": "^2.1.0",
|
||||||
"through2": "^2.0.3",
|
"through2": "^2.0.3",
|
||||||
"ts-node": "^3.3.0",
|
"ts-node": "^8.1.0",
|
||||||
"tslint": "^5.5.0",
|
"tslint": "^5.5.0",
|
||||||
"typescript": "~3.3.3333",
|
"typescript": "~3.3.3333",
|
||||||
"xml2js": "^0.4.19"
|
"xml2js": "^0.4.19"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -15,36 +15,41 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const _gulp = require('gulp');
|
import * as gulp from 'gulp';
|
||||||
const help = require('gulp-help');
|
import * as mocha from 'gulp-mocha';
|
||||||
const mocha = require('gulp-mocha');
|
import * as execa from 'execa';
|
||||||
const execa = require('execa');
|
import * as path from 'path';
|
||||||
const path = require('path');
|
import * as del from 'del';
|
||||||
const del = require('del');
|
import linkSync from '../../util';
|
||||||
const linkSync = require('../../util').linkSync;
|
|
||||||
|
|
||||||
const gulp = help(_gulp);
|
|
||||||
|
|
||||||
const healthCheckDir = __dirname;
|
const healthCheckDir = __dirname;
|
||||||
const baseDir = path.resolve(healthCheckDir, '..', '..');
|
const baseDir = path.resolve(healthCheckDir, '..', '..');
|
||||||
const testDir = path.resolve(healthCheckDir, 'test');
|
const testDir = path.resolve(healthCheckDir, 'test');
|
||||||
|
|
||||||
gulp.task('clean.links', 'Delete npm links', () => {
|
const cleanLinks = () => {
|
||||||
return del(path.resolve(healthCheckDir, 'node_modules/grpc'));
|
return del(path.resolve(healthCheckDir, 'node_modules/grpc'));
|
||||||
});
|
}
|
||||||
|
|
||||||
gulp.task('clean.all', 'Delete all code created by tasks',
|
const cleanAll = gulp.parallel(cleanLinks);
|
||||||
['clean.links']);
|
|
||||||
|
|
||||||
gulp.task('install', 'Install health check dependencies', ['clean.links'], () => {
|
const runInstall = () => {
|
||||||
return execa('npm', ['install', '--unsafe-perm'], {cwd: healthCheckDir, stdio: 'inherit'});
|
return execa('npm', ['install', '--unsafe-perm'], {cwd: healthCheckDir, stdio: 'inherit'});
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('link.add', 'Link local copy of grpc', () => {
|
const install = gulp.series(cleanLinks, runInstall);
|
||||||
|
|
||||||
|
const linkAdd = () => {
|
||||||
linkSync(healthCheckDir, './node_modules/grpc', '../grpc-native-core');
|
linkSync(healthCheckDir, './node_modules/grpc', '../grpc-native-core');
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('test', 'Run health check tests',
|
const test = () => {
|
||||||
() => {
|
|
||||||
return gulp.src(`${testDir}/*.js`).pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
|
return gulp.src(`${testDir}/*.js`).pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
|
||||||
});
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
cleanLinks,
|
||||||
|
cleanAll,
|
||||||
|
install,
|
||||||
|
linkAdd,
|
||||||
|
test
|
||||||
|
}
|
|
@ -15,8 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as _gulp from 'gulp';
|
import * as gulp from 'gulp';
|
||||||
import * as help from 'gulp-help';
|
|
||||||
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as mocha from 'gulp-mocha';
|
import * as mocha from 'gulp-mocha';
|
||||||
|
@ -26,9 +25,6 @@ import * as pify from 'pify';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import { ncp } from 'ncp';
|
import { ncp } from 'ncp';
|
||||||
|
|
||||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
|
||||||
const gulp = help(_gulp);
|
|
||||||
|
|
||||||
const ncpP = pify(ncp);
|
const ncpP = pify(ncp);
|
||||||
|
|
||||||
Error.stackTraceLimit = Infinity;
|
Error.stackTraceLimit = Infinity;
|
||||||
|
@ -44,34 +40,36 @@ const execNpmVerb = (verb: string, ...args: string[]) =>
|
||||||
execa('npm', [verb, ...args], {cwd: jsCoreDir, stdio: 'inherit'});
|
execa('npm', [verb, ...args], {cwd: jsCoreDir, stdio: 'inherit'});
|
||||||
const execNpmCommand = execNpmVerb.bind(null, 'run');
|
const execNpmCommand = execNpmVerb.bind(null, 'run');
|
||||||
|
|
||||||
gulp.task('install', 'Install native core dependencies', () =>
|
const install = () => {
|
||||||
execNpmVerb('install', '--unsafe-perm'));
|
execNpmVerb('install', '--unsafe-perm');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
||||||
*/
|
*/
|
||||||
gulp.task('lint', 'Emits linting errors found in src/ and test/.', () =>
|
const lint = () => {
|
||||||
execNpmCommand('check'));
|
execNpmCommand('check');
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('clean', 'Deletes transpiled code.', ['install'],
|
const clean = () => {
|
||||||
() => execNpmCommand('clean'));
|
execNpmCommand('clean');
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('clean.all', 'Deletes all files added by targets', ['clean']);
|
const cleanAll = gulp.parallel(clean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transpiles TypeScript files in src/ to JavaScript according to the settings
|
* Transpiles TypeScript files in src/ to JavaScript according to the settings
|
||||||
* found in tsconfig.json.
|
* found in tsconfig.json.
|
||||||
*/
|
*/
|
||||||
gulp.task('compile', 'Transpiles src/.', () => execNpmCommand('compile'));
|
const compile = () => {
|
||||||
|
execNpmCommand('compile');
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task('copy-test-fixtures', 'Copy test fixtures.', () => {
|
const copyTestFixtures = () => {
|
||||||
return ncpP(`${jsCoreDir}/test/fixtures`, `${outDir}/test/fixtures`);
|
return ncpP(`${jsCoreDir}/test/fixtures`, `${outDir}/test/fixtures`);
|
||||||
});
|
}
|
||||||
|
|
||||||
/**
|
const runTests = () => {
|
||||||
* Transpiles src/ and test/, and then runs all tests.
|
|
||||||
*/
|
|
||||||
gulp.task('test', 'Runs all tests.', ['lint', 'copy-test-fixtures'], () => {
|
|
||||||
if (semver.satisfies(process.version, '^8.11.2 || >=9.4')) {
|
if (semver.satisfies(process.version, '^8.11.2 || >=9.4')) {
|
||||||
return gulp.src(`${outDir}/test/**/*.js`)
|
return gulp.src(`${outDir}/test/**/*.js`)
|
||||||
.pipe(mocha({reporter: 'mocha-jenkins-reporter',
|
.pipe(mocha({reporter: 'mocha-jenkins-reporter',
|
||||||
|
@ -80,4 +78,15 @@ gulp.task('test', 'Runs all tests.', ['lint', 'copy-test-fixtures'], () => {
|
||||||
console.log(`Skipping grpc-js tests for Node ${process.version}`);
|
console.log(`Skipping grpc-js tests for Node ${process.version}`);
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const test = gulp.series(install, copyTestFixtures, runTests);
|
||||||
|
|
||||||
|
export {
|
||||||
|
install,
|
||||||
|
lint,
|
||||||
|
clean,
|
||||||
|
cleanAll,
|
||||||
|
compile,
|
||||||
|
test
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -15,18 +15,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const _gulp = require('gulp');
|
import * as gulp from 'gulp';
|
||||||
const help = require('gulp-help');
|
import * as jsdoc from 'gulp-jsdoc3';
|
||||||
|
import * as jshint from 'gulp-jshint';
|
||||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
import * as mocha from 'gulp-mocha';
|
||||||
const gulp = help(_gulp);
|
import * as execa from 'execa';
|
||||||
|
import * as path from 'path';
|
||||||
const jsdoc = require('gulp-jsdoc3');
|
import * as del from 'del';
|
||||||
const jshint = require('gulp-jshint');
|
|
||||||
const mocha = require('gulp-mocha');
|
|
||||||
const execa = require('execa');
|
|
||||||
const path = require('path');
|
|
||||||
const del = require('del');
|
|
||||||
|
|
||||||
const nativeCoreDir = __dirname;
|
const nativeCoreDir = __dirname;
|
||||||
const srcDir = path.resolve(nativeCoreDir, 'src');
|
const srcDir = path.resolve(nativeCoreDir, 'src');
|
||||||
|
@ -35,44 +30,56 @@ const testDir = path.resolve(nativeCoreDir, 'test');
|
||||||
const pkg = require('./package');
|
const pkg = require('./package');
|
||||||
const jshintConfig = pkg.jshintConfig;
|
const jshintConfig = pkg.jshintConfig;
|
||||||
|
|
||||||
gulp.task('clean', 'Delete generated files', () => {
|
const clean = () => {
|
||||||
return del([path.resolve(nativeCoreDir, 'build'),
|
return del([path.resolve(nativeCoreDir, 'build'),
|
||||||
path.resolve(nativeCoreDir, 'ext/node')]);
|
path.resolve(nativeCoreDir, 'ext/node')]);
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('clean.all', 'Delete all files created by tasks',
|
const cleanAll = gulp.parallel(clean);
|
||||||
['clean']);
|
|
||||||
|
|
||||||
gulp.task('install', 'Install native core dependencies', () => {
|
const install = () => {
|
||||||
return execa('npm', ['install', '--build-from-source', '--unsafe-perm'],
|
return execa('npm', ['install', '--build-from-source', '--unsafe-perm'],
|
||||||
{cwd: nativeCoreDir, stdio: 'inherit'});
|
{cwd: nativeCoreDir, stdio: 'inherit'});
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('install.windows', 'Install native core dependencies for MS Windows', () => {
|
const installWindows = () => {
|
||||||
return execa('npm', ['install', '--build-from-source'],
|
return execa('npm', ['install', '--build-from-source'],
|
||||||
{cwd: nativeCoreDir, stdio: 'inherit'}).catch(() =>
|
{cwd: nativeCoreDir, stdio: 'inherit'}).catch(() =>
|
||||||
del(path.resolve(process.env.USERPROFILE, '.node-gyp', process.versions.node, 'include/node/openssl'), { force: true }).then(() =>
|
del(path.resolve(process.env.USERPROFILE, '.node-gyp', process.versions.node, 'include/node/openssl'), { force: true }).then(() =>
|
||||||
execa('npm', ['install', '--build-from-source'],
|
execa('npm', ['install', '--build-from-source'],
|
||||||
{cwd: nativeCoreDir, stdio: 'inherit'})
|
{cwd: nativeCoreDir, stdio: 'inherit'})
|
||||||
))
|
));
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('lint', 'Emits linting errors', () => {
|
const lint = () => {
|
||||||
return gulp.src([`${nativeCoreDir}/index.js`, `${srcDir}/*.js`, `${testDir}/*.js`])
|
return gulp.src([`${nativeCoreDir}/index.js`, `${srcDir}/*.js`, `${testDir}/*.js`])
|
||||||
.pipe(jshint(pkg.jshintConfig))
|
.pipe(jshint(pkg.jshintConfig))
|
||||||
.pipe(jshint.reporter('default'));
|
.pipe(jshint.reporter('default'));
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('build', 'Build native package', () => {
|
const build = () => {
|
||||||
return execa('npm', ['run', 'build'], {cwd: nativeCoreDir, stdio: 'inherit'});
|
return execa('npm', ['run', 'build'], {cwd: nativeCoreDir, stdio: 'inherit'});
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('test', 'Run all tests', ['build'], () => {
|
const runTests = () => {
|
||||||
return gulp.src(`${testDir}/*.js`).pipe(mocha({timeout: 5000, reporter: 'mocha-jenkins-reporter'}));
|
return gulp.src(`${testDir}/*.js`).pipe(mocha({timeout: 5000, reporter: 'mocha-jenkins-reporter'}));
|
||||||
});
|
}
|
||||||
|
|
||||||
gulp.task('doc.gen', 'Generate docs', (cb) => {
|
const test = gulp.series(build, runTests);
|
||||||
|
|
||||||
|
const docGen = (cb) => {
|
||||||
var config = require('./jsdoc_conf.json');
|
var config = require('./jsdoc_conf.json');
|
||||||
gulp.src([`${nativeCoreDir}/README.md`, `${nativeCoreDir}/index.js`, `${srcDir}/*.js`], {read: false})
|
gulp.src([`${nativeCoreDir}/README.md`, `${nativeCoreDir}/index.js`, `${srcDir}/*.js`], {read: false})
|
||||||
.pipe(jsdoc(config, cb));
|
.pipe(jsdoc(config, cb));
|
||||||
});
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
clean,
|
||||||
|
cleanAll,
|
||||||
|
install,
|
||||||
|
installWindows,
|
||||||
|
lint,
|
||||||
|
build,
|
||||||
|
test,
|
||||||
|
docGen
|
||||||
|
};
|
|
@ -15,8 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as _gulp from 'gulp';
|
import * as gulp from 'gulp';
|
||||||
import * as help from 'gulp-help';
|
|
||||||
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as mocha from 'gulp-mocha';
|
import * as mocha from 'gulp-mocha';
|
||||||
|
@ -24,9 +23,6 @@ import * as path from 'path';
|
||||||
import * as execa from 'execa';
|
import * as execa from 'execa';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
|
||||||
const gulp = help(_gulp);
|
|
||||||
|
|
||||||
Error.stackTraceLimit = Infinity;
|
Error.stackTraceLimit = Infinity;
|
||||||
|
|
||||||
const protojsDir = __dirname;
|
const protojsDir = __dirname;
|
||||||
|
@ -40,30 +36,37 @@ const execNpmVerb = (verb: string, ...args: string[]) =>
|
||||||
execa('npm', [verb, ...args], {cwd: protojsDir, stdio: 'inherit'});
|
execa('npm', [verb, ...args], {cwd: protojsDir, stdio: 'inherit'});
|
||||||
const execNpmCommand = execNpmVerb.bind(null, 'run');
|
const execNpmCommand = execNpmVerb.bind(null, 'run');
|
||||||
|
|
||||||
gulp.task('install', 'Install native core dependencies', () =>
|
const install = () => {
|
||||||
execNpmVerb('install', '--unsafe-perm'));
|
execNpmVerb('install', '--unsafe-perm');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
||||||
*/
|
*/
|
||||||
gulp.task('lint', 'Emits linting errors found in src/ and test/.', () =>
|
const lint = () => {
|
||||||
execNpmCommand('check'));
|
execNpmCommand('check');
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('clean', 'Deletes transpiled code.', ['install'],
|
const cleanFiles = () => {
|
||||||
() => execNpmCommand('clean'));
|
execNpmCommand('clean');
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('clean.all', 'Deletes all files added by targets', ['clean']);
|
const clean = gulp.series(install, cleanFiles);
|
||||||
|
|
||||||
|
const cleanAll = gulp.parallel(clean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transpiles TypeScript files in src/ and test/ to JavaScript according to the settings
|
* Transpiles TypeScript files in src/ and test/ to JavaScript according to the settings
|
||||||
* found in tsconfig.json.
|
* found in tsconfig.json.
|
||||||
*/
|
*/
|
||||||
gulp.task('compile', 'Transpiles src/ and test/.', () => execNpmCommand('compile'));
|
const compile = () => {
|
||||||
|
execNpmCommand('compile');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transpiles src/ and test/, and then runs all tests.
|
* Transpiles src/ and test/, and then runs all tests.
|
||||||
*/
|
*/
|
||||||
gulp.task('test', 'Runs all tests.', () => {
|
const runTests = () => {
|
||||||
if (semver.satisfies(process.version, ">=6")) {
|
if (semver.satisfies(process.version, ">=6")) {
|
||||||
return gulp.src(`${outDir}/test/**/*.js`)
|
return gulp.src(`${outDir}/test/**/*.js`)
|
||||||
.pipe(mocha({reporter: 'mocha-jenkins-reporter',
|
.pipe(mocha({reporter: 'mocha-jenkins-reporter',
|
||||||
|
@ -72,4 +75,15 @@ gulp.task('test', 'Runs all tests.', () => {
|
||||||
console.log(`Skipping proto-loader tests for Node ${process.version}`);
|
console.log(`Skipping proto-loader tests for Node ${process.version}`);
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
const test = gulp.series(install, runTests);
|
||||||
|
|
||||||
|
export {
|
||||||
|
install,
|
||||||
|
lint,
|
||||||
|
clean,
|
||||||
|
cleanAll,
|
||||||
|
compile,
|
||||||
|
test
|
||||||
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ for %%v in (6 7 8 9 10 11) do (
|
||||||
|
|
||||||
node -e "process.exit(process.version.startsWith('v%%v') ? 0 : -1)" || goto :error
|
node -e "process.exit(process.version.startsWith('v%%v') ? 0 : -1)" || goto :error
|
||||||
|
|
||||||
call .\node_modules\.bin\gulp clean.all || SET FAILED=1
|
call .\node_modules\.bin\gulp cleanAll || SET FAILED=1
|
||||||
call .\node_modules\.bin\gulp setup.windows || SET FAILED=1
|
call .\node_modules\.bin\gulp setupWindows || SET FAILED=1
|
||||||
call .\node_modules\.bin\gulp test || SET FAILED=1
|
call .\node_modules\.bin\gulp test || SET FAILED=1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ do
|
||||||
node -e 'process.exit(process.version.startsWith("v'$version'") ? 0 : -1)'
|
node -e 'process.exit(process.version.startsWith("v'$version'") ? 0 : -1)'
|
||||||
|
|
||||||
# Install dependencies and link packages together.
|
# Install dependencies and link packages together.
|
||||||
./node_modules/.bin/gulp clean.all
|
./node_modules/.bin/gulp cleanAll
|
||||||
./node_modules/.bin/gulp setup
|
./node_modules/.bin/gulp setup
|
||||||
|
|
||||||
# npm test calls nyc gulp test
|
# npm test calls nyc gulp test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 gRPC authors.
|
* Copyright 2019 gRPC authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -15,28 +15,24 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const _gulp = require('gulp');
|
import * as gulp from 'gulp';
|
||||||
const help = require('gulp-help');
|
import * as mocha from 'gulp-mocha';
|
||||||
const mocha = require('gulp-mocha');
|
import * as execa from 'execa';
|
||||||
const execa = require('execa');
|
import * as path from 'path';
|
||||||
const path = require('path');
|
import * as del from 'del';
|
||||||
const del = require('del');
|
import * as semver from 'semver';
|
||||||
const semver = require('semver');
|
import linkSync from '../util';
|
||||||
const linkSync = require('../util').linkSync;
|
|
||||||
|
|
||||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
|
||||||
const gulp = help(_gulp);
|
|
||||||
|
|
||||||
const testDir = __dirname;
|
const testDir = __dirname;
|
||||||
const apiTestDir = path.resolve(testDir, 'api');
|
const apiTestDir = path.resolve(testDir, 'api');
|
||||||
|
|
||||||
gulp.task('install', 'Install test dependencies', () => {
|
const install = () => {
|
||||||
return execa('npm', ['install'], {cwd: testDir, stdio: 'inherit'});
|
return execa('npm', ['install'], {cwd: testDir, stdio: 'inherit'});
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('clean.all', 'Delete all files created by tasks', () => {});
|
const cleanAll = () => {};
|
||||||
|
|
||||||
gulp.task('test', 'Run API-level tests', () => {
|
const test = () => {
|
||||||
// run mocha tests matching a glob with a pre-required fixture,
|
// run mocha tests matching a glob with a pre-required fixture,
|
||||||
// returning the associated gulp stream
|
// returning the associated gulp stream
|
||||||
if (!semver.satisfies(process.version, '>=9.4')) {
|
if (!semver.satisfies(process.version, '>=9.4')) {
|
||||||
|
@ -50,7 +46,7 @@ gulp.task('test', 'Run API-level tests', () => {
|
||||||
gulp.src(apiTestGlob)
|
gulp.src(apiTestGlob)
|
||||||
.pipe(mocha({
|
.pipe(mocha({
|
||||||
reporter: 'mocha-jenkins-reporter',
|
reporter: 'mocha-jenkins-reporter',
|
||||||
require: `${testDir}/fixtures/${fixture}.js`
|
require: [`${testDir}/fixtures/${fixture}.js`]
|
||||||
}))
|
}))
|
||||||
.resume() // put the stream in flowing mode
|
.resume() // put the stream in flowing mode
|
||||||
.on('end', resolve)
|
.on('end', resolve)
|
||||||
|
@ -72,4 +68,10 @@ gulp.task('test', 'Run API-level tests', () => {
|
||||||
return runTestsArgPairs.reduce((previousPromise, argPair) => {
|
return runTestsArgPairs.reduce((previousPromise, argPair) => {
|
||||||
return previousPromise.then(runTestsWithFixture.bind(null, argPair[0], argPair[1]));
|
return previousPromise.then(runTestsWithFixture.bind(null, argPair[0], argPair[1]));
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
});
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
install,
|
||||||
|
cleanAll,
|
||||||
|
test
|
||||||
|
};
|
Loading…
Reference in New Issue