mirror of https://github.com/grpc/grpc-node.git
simplify gulp commands in package directories
This commit is contained in:
parent
e48ac4ee4e
commit
ad8aa54fd6
|
@ -15,26 +15,52 @@
|
|||
*
|
||||
*/
|
||||
|
||||
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']);
|
||||
|
@ -42,22 +68,19 @@ gulp.task('install.all.windows', 'Install dependencies for all subdirectory pack
|
|||
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);
|
||||
});
|
||||
|
|
@ -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",
|
||||
|
@ -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"
|
||||
|
|
|
@ -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'}));
|
||||
});
|
||||
|
|
|
@ -1,197 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const _gulp = require('gulp');
|
||||
const help = require('gulp-help');
|
||||
|
||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
||||
const gulp = help(_gulp);
|
||||
|
||||
const del = require('del');
|
||||
const mocha = require('gulp-mocha');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const tslint = require('gulp-tslint');
|
||||
const typescript = require('gulp-typescript');
|
||||
const util = require('gulp-util');
|
||||
const merge2 = require('merge2');
|
||||
const path = require('path');
|
||||
const through = require('through2');
|
||||
const execa = require('execa');
|
||||
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
const jsCoreDir = __dirname;
|
||||
const tslintPath = path.resolve(jsCoreDir, 'node_modules/google-ts-style/tslint.json');
|
||||
const tsconfigPath = path.resolve(jsCoreDir, 'tsconfig.json');
|
||||
const outDir = path.resolve(jsCoreDir, 'build');
|
||||
const srcDir = path.resolve(jsCoreDir, 'src');
|
||||
const testDir = path.resolve(jsCoreDir, 'test');
|
||||
|
||||
function onError() {}
|
||||
|
||||
// Coalesces all specified --file parameters into a single array
|
||||
const files = !util.env.file ? [] :
|
||||
Array.isArray(util.env.file) ? util.env.file : [util.env.file];
|
||||
|
||||
// If --dev is passed, override certain ts config options
|
||||
let tsDevOptions = {};
|
||||
if (util.env.dev) {
|
||||
tsDevOptions = {
|
||||
allowUnreachableCode: true,
|
||||
noUnusedParameters: false,
|
||||
noImplicitAny: false,
|
||||
noImplicitThis: false,
|
||||
noEmitOnError: false
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that creates a gulp task function that opens files in a
|
||||
* directory that match a certain glob pattern, transpiles them, and writes them
|
||||
* to an output directory.
|
||||
* @param {Object} globs
|
||||
* @param {string=} globs.transpile The glob pattern for files to transpile.
|
||||
* Defaults to match all *.ts files in baseDir (incl. subdirectories).
|
||||
* @param {string=} globs.copy The glob pattern for files to transpile.
|
||||
* Defaults to match all but *.ts files in baseDir (incl. subdirectories).
|
||||
* @return A gulp task function.
|
||||
*/
|
||||
function makeCompileFn(globs) {
|
||||
const transpileGlob = globs.transpile || `${srcDir}/**/*.ts`;
|
||||
const copyGlob = globs.copy || '!(**/*)';
|
||||
return () => {
|
||||
const tsProject = typescript.createProject(tsconfigPath, tsDevOptions)();
|
||||
const data = gulp.src(transpileGlob, { base: jsCoreDir })
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(tsProject)
|
||||
.on('error', onError);
|
||||
const dts = data.dts;
|
||||
const js = data.js;
|
||||
const jsmap = js.pipe(sourcemaps.write('.', {
|
||||
includeContent: false,
|
||||
sourceRoot: '..'
|
||||
}));
|
||||
const copy = gulp.src(copyGlob, { base: jsCoreDir });
|
||||
return merge2([
|
||||
js.pipe(gulp.dest(`${outDir}`)),
|
||||
dts.pipe(gulp.dest(`${outDir}/types`)),
|
||||
jsmap.pipe(gulp.dest(`${outDir}`)),
|
||||
copy.pipe(gulp.dest(`${outDir}`))
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
gulp.task('js.core.install', 'Install native core dependencies', () => {
|
||||
return execa('npm', ['install', '--unsafe-perm'], {cwd: jsCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
/**
|
||||
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
||||
*/
|
||||
gulp.task('js.core.lint', 'Emits linting errors found in src/ and test/.', () => {
|
||||
const program = require('tslint').Linter.createProgram(tsconfigPath);
|
||||
gulp.src([`${srcDir}/**/*.ts`, `${testDir}/**/*.ts`])
|
||||
.pipe(tslint({
|
||||
configuration: tslintPath,
|
||||
formatter: 'codeFrame',
|
||||
program
|
||||
}))
|
||||
.pipe(tslint.report())
|
||||
.on('warning', onError);
|
||||
});
|
||||
|
||||
gulp.task('js.core.clean', 'Deletes transpiled code.', () => {
|
||||
return del(outDir);
|
||||
});
|
||||
|
||||
gulp.task('js.core.clean.all', 'Deletes all files added by targets',
|
||||
['js.core.clean']);
|
||||
|
||||
/**
|
||||
* Transpiles TypeScript files in src/ to JavaScript according to the settings
|
||||
* found in tsconfig.json.
|
||||
* Currently, all errors are emitted twice. This is being tracked here:
|
||||
* https://github.com/ivogabe/gulp-typescript/issues/438
|
||||
*/
|
||||
gulp.task('js.core.compile', 'Transpiles src/.',
|
||||
makeCompileFn({ transpile: [`${srcDir}/**/*.ts`] }));
|
||||
|
||||
/**
|
||||
* Transpiles TypeScript files in both src/ and test/.
|
||||
*/
|
||||
gulp.task('js.core.test.compile', 'After dep tasks, transpiles test/.', ['js.core.compile'],
|
||||
makeCompileFn({ transpile: [`${testDir}/**/*.ts`], copy: `${testDir}/**/!(*.ts)` }));
|
||||
|
||||
/**
|
||||
* Transpiles src/ and test/, and then runs all tests.
|
||||
*/
|
||||
gulp.task('js.core.test', 'After dep tasks, runs all tests.',
|
||||
['js.core.test.compile'], () => {
|
||||
return gulp.src(`${outDir}/test/**/*.js`)
|
||||
.pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Transpiles individual files, specified by the --file flag.
|
||||
*/
|
||||
gulp.task('js.core.compile.single', 'Transpiles individual files specified by --file.',
|
||||
makeCompileFn({
|
||||
transpile: files.map(f => path.relative('.', f))
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Run individual tests, specified by their pre-transpiled source path (as
|
||||
* supplied through the '--file' flag). This is intended to be used as part of a
|
||||
* VS Code "Gulp task" launch configuration; setting the "args" field to
|
||||
* ["test.single", "--file", "${file}"] makes it possible for one to debug the
|
||||
* currently open TS mocha test file in one step.
|
||||
*/
|
||||
gulp.task('js.core.test.single', 'After dep tasks, runs individual files specified ' +
|
||||
'by --file.', ['js.core.compile', 'js.core.compile.single'], () => {
|
||||
// util.env contains CLI arguments for the gulp task.
|
||||
// Determine the path to the transpiled version of this TS file.
|
||||
const getTranspiledPath = (file) => {
|
||||
const dir = path.dirname(path.relative(jsCoreDir, file));
|
||||
const basename = path.basename(file, '.ts');
|
||||
const result = `${outDir}/${dir}/${basename}.js`;
|
||||
console.log(result);
|
||||
return result;
|
||||
};
|
||||
// Construct an instance of Mocha's runner API and feed it the path to the
|
||||
// transpiled source.
|
||||
return gulp.src(files.map(getTranspiledPath))
|
||||
.pipe(through.obj((file, enc, cb) => {
|
||||
// Construct a new Mocha runner instance.
|
||||
const Mocha = require('mocha');
|
||||
const runner = new Mocha();
|
||||
// Add the path to the test file to debug.
|
||||
runner.addFile(file.path);
|
||||
// Run the test suite.
|
||||
runner.run((failures) => {
|
||||
if (failures > 0) {
|
||||
cb(new Error(`Mocha: ${failures} failures in ${file.path}]`));
|
||||
} else {
|
||||
cb(null);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
);
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
import * as _gulp from 'gulp';
|
||||
import * as help from 'gulp-help';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as mocha from 'gulp-mocha';
|
||||
import * as path from 'path';
|
||||
import * as execa from 'execa';
|
||||
import * as pify from 'pify';
|
||||
import { ncp } from 'ncp';
|
||||
|
||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
||||
const gulp = help(_gulp);
|
||||
|
||||
const ncpP = pify(ncp);
|
||||
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
const jsCoreDir = __dirname;
|
||||
const tslintPath = path.resolve(jsCoreDir, 'node_modules/google-ts-style/tslint.json');
|
||||
const tsconfigPath = path.resolve(jsCoreDir, 'tsconfig.json');
|
||||
const outDir = path.resolve(jsCoreDir, 'build');
|
||||
const srcDir = path.resolve(jsCoreDir, 'src');
|
||||
const testDir = path.resolve(jsCoreDir, 'test');
|
||||
|
||||
const execNpmVerb = (verb: string, ...args: string[]) =>
|
||||
execa('npm', [verb, ...args], {cwd: jsCoreDir, stdio: 'inherit'});
|
||||
const execNpmCommand = execNpmVerb.bind(null, 'run');
|
||||
|
||||
gulp.task('install', 'Install native core dependencies', () =>
|
||||
execNpmVerb('install', '--unsafe-perm'));
|
||||
|
||||
/**
|
||||
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
||||
*/
|
||||
gulp.task('lint', 'Emits linting errors found in src/ and test/.', () =>
|
||||
execNpmCommand('check'));
|
||||
|
||||
gulp.task('clean', 'Deletes transpiled code.', ['install'],
|
||||
() => execNpmCommand('clean'));
|
||||
|
||||
gulp.task('clean.all', 'Deletes all files added by targets', ['clean']);
|
||||
|
||||
/**
|
||||
* Transpiles TypeScript files in src/ to JavaScript according to the settings
|
||||
* found in tsconfig.json.
|
||||
*/
|
||||
gulp.task('compile', 'Transpiles src/.', () => execNpmCommand('compile'));
|
||||
|
||||
gulp.task('copy-test-fixtures', 'Copy test fixtures.', () => {
|
||||
return ncpP(`${jsCoreDir}/test/fixtures`, `${outDir}/test/fixtures`);
|
||||
});
|
||||
|
||||
/**
|
||||
* Transpiles src/ and test/, and then runs all tests.
|
||||
*/
|
||||
gulp.task('test', 'Runs all tests.', ['copy-test-fixtures'], () => {
|
||||
return gulp.src(`${outDir}/test/**/*.js`)
|
||||
.pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
|
||||
});
|
|
@ -11,14 +11,15 @@
|
|||
"author": {
|
||||
"name": "Google Inc."
|
||||
},
|
||||
"types": "src/index.ts",
|
||||
"types": "build/src/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.77",
|
||||
"@types/mocha": "^2.2.43",
|
||||
"@types/node": "^8.0.34",
|
||||
"@types/node": "^8.0.55",
|
||||
"clang-format": "^1.0.55",
|
||||
"google-ts-style": "^0.2.0"
|
||||
"gts": "^0.5.1",
|
||||
"typescript": "^2.6.1"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
|
@ -28,12 +29,16 @@
|
|||
"_id": "@grpc/js-core@0.1.0",
|
||||
"scripts": {
|
||||
"build": "npm run compile",
|
||||
"clean": "gulp clean",
|
||||
"compile": "gulp js.core.compile",
|
||||
"clean": "gts clean",
|
||||
"compile": "tsc -p .",
|
||||
"format": "clang-format -i -style=\"{Language: JavaScript, BasedOnStyle: Google, ColumnLimit: 80}\" src/*.ts test/*.ts",
|
||||
"lint": "tslint -c node_modules/google-ts-style/tslint.json -p . -t codeFrame --type-check",
|
||||
"prepare": "npm run build",
|
||||
"test": "gulp test"
|
||||
"prepare": "npm run compile",
|
||||
"test": "gulp test",
|
||||
"check": "gts check",
|
||||
"fix": "gts fix",
|
||||
"pretest": "npm run compile",
|
||||
"posttest": "npm run check"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.4"
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"extends": "./node_modules/google-ts-style/tsconfig-google.json",
|
||||
"extends": "./node_modules/gts/tsconfig-google.json",
|
||||
"compilerOptions": {
|
||||
"lib": [ "es6" ],
|
||||
"typeRoots": [
|
||||
"node_modules/h2-types", "node_modules/@types"
|
||||
]
|
||||
"rootDir": ".",
|
||||
"outDir": "build"
|
||||
},
|
||||
"include": [
|
||||
"src/*.ts",
|
||||
"src/**/*.ts",
|
||||
"test/*.ts",
|
||||
"test/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
|
|
|
@ -28,19 +28,26 @@ const linkSync = require('../../util').linkSync;
|
|||
|
||||
const jsDir = __dirname;
|
||||
|
||||
gulp.task('js.clean.links', 'Delete npm links', () => {
|
||||
const execNpmVerb = (verb: string, ...args: string[]) =>
|
||||
execa('npm', [verb, ...args], {cwd: jsDir, stdio: 'inherit'});
|
||||
const execNpmCommand = execNpmVerb.bind(null, 'run');
|
||||
|
||||
gulp.task('clean.links', 'Delete npm links', () => {
|
||||
return del([path.resolve(jsDir, 'node_modules/@grpc/js-core'),
|
||||
path.resolve(jsDir, 'node_modules/@grpc/surface')]);
|
||||
});
|
||||
|
||||
gulp.task('js.clean.all', 'Delete all files created by tasks',
|
||||
['js.clean.links']);
|
||||
gulp.task('clean.all', 'Delete all files created by tasks', ['clean.links']);
|
||||
|
||||
gulp.task('js.install', 'Install dependencies', () => {
|
||||
return execa('npm', ['install', '--unsafe-perm'], {cwd: jsDir, stdio: 'inherit'});
|
||||
});
|
||||
/**
|
||||
* Transpiles TypeScript files in src/ to JavaScript according to the settings
|
||||
* found in tsconfig.json.
|
||||
*/
|
||||
gulp.task('compile', 'Transpiles src/.', () => execNpmCommand('compile'));
|
||||
|
||||
gulp.task('js.link.add', 'Link local copies of dependencies', () => {
|
||||
gulp.task('install', 'Install dependencies', () => execNpmVerb('install'));
|
||||
|
||||
gulp.task('link.add', 'Link local copies of dependencies', () => {
|
||||
linkSync(jsDir, './node_modules/@grpc/js-core', '../grpc-js-core');
|
||||
linkSync(jsDir, './node_modules/@grpc/surface', '../grpc-surface');
|
||||
});
|
|
@ -2,9 +2,16 @@
|
|||
"name": "@grpc/js",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"main": "build/src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"compile": "tsc -p .",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"check": "gts check",
|
||||
"clean": "gts clean",
|
||||
"fix": "gts fix",
|
||||
"prepare": "npm run compile",
|
||||
"pretest": "npm run compile",
|
||||
"posttest": "npm run check"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -19,5 +26,9 @@
|
|||
"dependencies": {
|
||||
"@grpc/js-core": "^0.1.0",
|
||||
"@grpc/surface": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gts": "^0.5.1",
|
||||
"typescript": "^2.6.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"extends": "./node_modules/gts/tsconfig-google.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"outDir": "build"
|
||||
},
|
||||
"include": [
|
||||
"src/*.ts",
|
||||
"src/**/*.ts",
|
||||
"test/*.ts",
|
||||
"test/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
|
@ -35,20 +35,20 @@ const testDir = path.resolve(nativeCoreDir, 'test');
|
|||
const pkg = require('./package');
|
||||
const jshintConfig = pkg.jshintConfig;
|
||||
|
||||
gulp.task('native.core.clean', 'Delete generated files', () => {
|
||||
gulp.task('clean', 'Delete generated files', () => {
|
||||
return del([path.resolve(nativeCoreDir, 'build'),
|
||||
path.resolve(nativeCoreDir, 'ext/node')]);
|
||||
});
|
||||
|
||||
gulp.task('native.core.clean.all', 'Delete all files created by tasks',
|
||||
['native.core.clean']);
|
||||
gulp.task('clean.all', 'Delete all files created by tasks',
|
||||
['clean']);
|
||||
|
||||
gulp.task('native.core.install', 'Install native core dependencies', () => {
|
||||
gulp.task('install', 'Install native core dependencies', () => {
|
||||
return execa('npm', ['install', '--build-from-source', '--unsafe-perm'],
|
||||
{cwd: nativeCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('native.core.install.windows', 'Install native core dependencies for MS Windows', () => {
|
||||
gulp.task('install.windows', 'Install native core dependencies for MS Windows', () => {
|
||||
return execa('npm', ['install', '--build-from-source'],
|
||||
{cwd: nativeCoreDir, stdio: 'inherit'}).catch(() =>
|
||||
del(path.resolve(process.env.USERPROFILE, '.node-gyp', process.versions.node, 'include/node/openssl'), { force: true }).then(() =>
|
||||
|
@ -57,21 +57,21 @@ execa('npm', ['install', '--build-from-source'],
|
|||
))
|
||||
});
|
||||
|
||||
gulp.task('native.core.lint', 'Emits linting errors', () => {
|
||||
gulp.task('lint', 'Emits linting errors', () => {
|
||||
return gulp.src([`${nativeCoreDir}/index.js`, `${srcDir}/*.js`, `${testDir}/*.js`])
|
||||
.pipe(jshint(pkg.jshintConfig))
|
||||
.pipe(jshint.reporter('default'));
|
||||
});
|
||||
|
||||
gulp.task('native.core.build', 'Build native package', () => {
|
||||
gulp.task('build', 'Build native package', () => {
|
||||
return execa('npm', ['run', 'build'], {cwd: nativeCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('native.core.test', 'Run all tests', ['native.core.build'], () => {
|
||||
gulp.task('test', 'Run all tests', ['build'], () => {
|
||||
return gulp.src(`${testDir}/*.js`).pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
|
||||
});
|
||||
|
||||
gulp.task('native.core.doc.gen', 'Generate docs', (cb) => {
|
||||
gulp.task('doc.gen', 'Generate docs', (cb) => {
|
||||
var config = require('./jsdoc_conf.json');
|
||||
gulp.src([`${nativeCoreDir}/README.md`, `${nativeCoreDir}/index.js`, `${srcDir}/*.js`], {read: false})
|
||||
.pipe(jsdoc(config, cb));
|
||||
|
|
|
@ -28,19 +28,19 @@ const linkSync = require('../../util').linkSync;
|
|||
|
||||
const nativeDir = __dirname;
|
||||
|
||||
gulp.task('native.clean.links', 'Delete npm links', () => {
|
||||
gulp.task('clean.links', 'Delete npm links', () => {
|
||||
return del([path.resolve(nativeDir, 'node_modules/grpc'),
|
||||
path.resolve(nativeDir, 'node_modules/@grpc/surface')]);
|
||||
});
|
||||
|
||||
gulp.task('native.clean.all', 'Delete all files created by tasks',
|
||||
['native.clean.links']);
|
||||
gulp.task('clean.all', 'Delete all files created by tasks',
|
||||
['clean.links']);
|
||||
|
||||
gulp.task('native.install', 'Install dependencies', () => {
|
||||
gulp.task('install', 'Install dependencies', () => {
|
||||
return execa('npm', ['install', '--unsafe-perm'], {cwd: nativeDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('native.link.add', 'Link local copies of dependencies', () => {
|
||||
gulp.task('link.add', 'Link local copies of dependencies', () => {
|
||||
linkSync(nativeDir, './node_modules/grpc', '../grpc-native-core');
|
||||
linkSync(nativeDir, './node_modules/@grpc/surface', '../grpc-surface');
|
||||
});
|
||||
|
|
|
@ -25,6 +25,6 @@ const execa = require('execa');
|
|||
|
||||
const surfaceDir = __dirname;
|
||||
|
||||
gulp.task('surface.install', 'Install surface dependencies', () => {
|
||||
gulp.task('install', 'Install surface dependencies', () => {
|
||||
return execa('npm', ['install', '--unsafe-perm'], {cwd: surfaceDir, stdio: 'inherit'});
|
||||
});
|
||||
|
|
|
@ -29,13 +29,13 @@ const gulp = help(_gulp);
|
|||
const testDir = __dirname;
|
||||
const apiTestDir = path.resolve(testDir, 'api');
|
||||
|
||||
gulp.task('internal.test.install', 'Install test dependencies', () => {
|
||||
gulp.task('install', 'Install test dependencies', () => {
|
||||
return execa('npm', ['install'], {cwd: testDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('internal.test.clean.all', 'Delete all files created by tasks', () => {});
|
||||
gulp.task('clean.all', 'Delete all files created by tasks', () => {});
|
||||
|
||||
gulp.task('internal.test.test', 'Run API-level tests', () => {
|
||||
gulp.task('test', 'Run API-level tests', () => {
|
||||
// run mocha tests matching a glob with a pre-required fixture,
|
||||
// returning the associated gulp stream
|
||||
const apiTestGlob = `${apiTestDir}/*.js`;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"es2015"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue