|
15 | 15 | * |
16 | 16 | */ |
17 | 17 |
|
18 | | -import * as _gulp from 'gulp'; |
19 | | -import * as help from 'gulp-help'; |
20 | | - |
21 | | -// gulp-help monkeypatches tasks to have an additional description parameter |
22 | | -const gulp = help(_gulp); |
23 | | - |
24 | | -const runSequence = require('run-sequence'); |
25 | | - |
26 | | -/** |
27 | | - * Require a module at the given path with a patched gulp object that prepends |
28 | | - * the given prefix to each task name. |
29 | | - * @param path The path to require. |
30 | | - * @param prefix The string to use as a prefix. This will be prepended to a task |
31 | | - * name with a '.' separator. |
32 | | - */ |
33 | | -function loadGulpTasksWithPrefix(path: string, prefix: string) { |
34 | | - const gulpTask = gulp.task; |
35 | | - gulp.task = ((taskName: string, ...args: any[]) => { |
36 | | - // Don't create a task for ${prefix}.help |
37 | | - if (taskName === 'help') { |
38 | | - return; |
39 | | - } |
40 | | - // The only array passed to gulp.task must be a list of dependent tasks. |
41 | | - const newArgs = args.map(arg => Array.isArray(arg) ? |
42 | | - arg.map(dep => `${prefix}.${dep}`) : arg); |
43 | | - gulpTask(`${prefix}.${taskName}`, ...newArgs); |
44 | | - }); |
45 | | - const result = require(path); |
46 | | - gulp.task = gulpTask; |
47 | | - return result; |
48 | | -} |
49 | | - |
50 | | -[ |
51 | | - ['./packages/grpc-health-check/gulpfile', 'health-check'], |
52 | | - ['./packages/grpc-js/gulpfile', 'js.core'], |
53 | | - ['./packages/grpc-native-core/gulpfile', 'native.core'], |
54 | | - ['./packages/proto-loader/gulpfile', 'protobuf'], |
55 | | - ['./test/gulpfile', 'internal.test'], |
56 | | -].forEach((args) => loadGulpTasksWithPrefix(args[0], args[1])); |
| 18 | +import * as gulp from 'gulp'; |
| 19 | +import * as healthCheck from './packages/grpc-health-check/gulpfile'; |
| 20 | +import * as jsCore from './packages/grpc-js/gulpfile'; |
| 21 | +import * as nativeCore from './packages/grpc-native-core/gulpfile'; |
| 22 | +import * as protobuf from './packages/proto-loader/gulpfile'; |
| 23 | +import * as internalTest from './test/gulpfile'; |
57 | 24 |
|
58 | 25 | const root = __dirname; |
59 | 26 |
|
60 | | -gulp.task('install.all', 'Install dependencies for all subdirectory packages', |
61 | | - ['js.core.install', 'native.core.install', 'health-check.install', 'protobuf.install', 'internal.test.install']); |
| 27 | +const installAll = gulp.parallel(jsCore.install, nativeCore.install, healthCheck.install, protobuf.install, internalTest.install); |
62 | 28 |
|
63 | | -gulp.task('install.all.windows', 'Install dependencies for all subdirectory packages for MS Windows', |
64 | | - ['js.core.install', 'native.core.install.windows', 'health-check.install', 'protobuf.install', 'internal.test.install']); |
| 29 | +const installAllWindows = gulp.parallel(jsCore.install, nativeCore.installWindows, healthCheck.install, protobuf.install, internalTest.install); |
65 | 30 |
|
66 | | -gulp.task('lint', 'Emit linting errors in source and test files', |
67 | | - ['js.core.lint', 'native.core.lint']); |
| 31 | +const lint = gulp.parallel(jsCore.lint, nativeCore.lint); |
68 | 32 |
|
69 | | -gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build', 'protobuf.compile']); |
| 33 | +const build = gulp.parallel(jsCore.compile, nativeCore.build, protobuf.compile); |
70 | 34 |
|
71 | | -gulp.task('link.surface', 'Link to surface packages', |
72 | | - ['health-check.link.add']); |
| 35 | +const link = gulp.series(healthCheck.linkAdd); |
73 | 36 |
|
74 | | -gulp.task('link', 'Link together packages', (callback) => { |
75 | | - /** |
76 | | - * We use workarounds for linking in some modules. See npm/npm#18835 |
77 | | - */ |
78 | | - runSequence('link.surface', callback); |
79 | | -}); |
| 37 | +const setup = gulp.series(installAll, link); |
80 | 38 |
|
81 | | -gulp.task('setup', 'One-time setup for a clean repository', (callback) => { |
82 | | - runSequence('install.all', 'link', callback); |
83 | | -}); |
84 | | -gulp.task('setup.windows', 'One-time setup for a clean repository for MS Windows', (callback) => { |
85 | | - runSequence('install.all.windows', 'link', callback); |
86 | | -}); |
| 39 | +const setupWindows = gulp.series(installAllWindows, link); |
87 | 40 |
|
88 | | -gulp.task('clean', 'Delete generated files', ['js.core.clean', 'native.core.clean', 'protobuf.clean']); |
| 41 | +const clean = gulp.parallel(jsCore.clean, nativeCore.clean, protobuf.clean); |
89 | 42 |
|
90 | | -gulp.task('clean.all', 'Delete all files created by tasks', |
91 | | - ['js.core.clean.all', 'native.core.clean.all', 'health-check.clean.all', |
92 | | - 'internal.test.clean.all', 'protobuf.clean.all']); |
| 43 | +const cleanAll = gulp.parallel(jsCore.cleanAll, nativeCore.cleanAll, healthCheck.cleanAll, internalTest.cleanAll, protobuf.cleanAll); |
93 | 44 |
|
94 | | -gulp.task('native.test.only', 'Run tests of native code without rebuilding anything', |
95 | | - ['native.core.test', 'health-check.test']); |
| 45 | +const nativeTestOnly = gulp.parallel(nativeCore.test, healthCheck.test); |
96 | 46 |
|
97 | | -gulp.task('native.test', 'Run tests of native code', (callback) => { |
98 | | - runSequence('build', 'native.test.only', callback); |
99 | | -}); |
| 47 | +const nativeTest = gulp.series(build, nativeTestOnly); |
100 | 48 |
|
101 | | -gulp.task('test.only', 'Run tests without rebuilding anything', |
102 | | - ['js.core.test', 'native.test.only', 'protobuf.test']); |
| 49 | +const testOnly = gulp.parallel(jsCore.test, nativeTestOnly, protobuf.test); |
103 | 50 |
|
104 | | -gulp.task('test', 'Run all tests', (callback) => { |
105 | | - runSequence('build', 'test.only', 'internal.test.test', callback); |
106 | | -}); |
| 51 | +const test = gulp.series(build, testOnly, internalTest.test); |
107 | 52 |
|
108 | | -gulp.task('doc.gen', 'Generate documentation', ['native.core.doc.gen']); |
| 53 | +const docGen = gulp.series(nativeCore.docGen); |
109 | 54 |
|
110 | | -gulp.task('default', ['help']); |
| 55 | +export { |
| 56 | + installAll, |
| 57 | + installAllWindows, |
| 58 | + lint, |
| 59 | + build, |
| 60 | + link, |
| 61 | + setup, |
| 62 | + setupWindows, |
| 63 | + clean, |
| 64 | + cleanAll, |
| 65 | + nativeTestOnly, |
| 66 | + nativeTest, |
| 67 | + test, |
| 68 | + docGen |
| 69 | +}; |
0 commit comments