try new links

This commit is contained in:
Kelvin Jin 2017-10-25 11:30:10 -07:00
parent 0aae3f8264
commit 94eca58f5d
10 changed files with 43 additions and 36 deletions

View File

@ -44,15 +44,9 @@ gulp.task('lint', 'Emit linting errors in source and test files',
gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build']); gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build']);
gulp.task('core.link.create', 'Initialize npm links to core packages',
['native.core.link.create', 'js.core.link.create', 'surface.link.create']);
gulp.task('core.link', 'Add links to core packages without rebuilding', gulp.task('core.link', 'Add links to core packages without rebuilding',
['js.link.add', 'native.link.add']); ['js.link.add', 'native.link.add']);
gulp.task('surface.link.create', 'Create links to surface packages',
['js.link.create', 'native.link.create']);
gulp.task('surface.link', 'Link to surface packages', gulp.task('surface.link', 'Link to surface packages',
['health-check.link.add', 'internal.test.link.add']); ['health-check.link.add', 'internal.test.link.add']);
@ -63,7 +57,7 @@ gulp.task('link', 'Link together packages', (callback) => {
* This also means that 'core.link' is not needed, and the item * This also means that 'core.link' is not needed, and the item
* 'native.core.link.create' should actually be 'core.link.create' * 'native.core.link.create' should actually be 'core.link.create'
*/ */
runSequence('native.core.link.create', /* 'core.link', 'surface.link.create', */ 'surface.link', runSequence('core.link', 'surface.link',
callback); callback);
}); });

View File

@ -23,6 +23,7 @@
"gulp-util": "^3.0.8", "gulp-util": "^3.0.8",
"jsdoc": "^3.3.2", "jsdoc": "^3.3.2",
"jshint": "^2.9.5", "jshint": "^2.9.5",
"make-dir": "^1.1.0",
"merge2": "^1.1.0", "merge2": "^1.1.0",
"mocha": "^3.5.3", "mocha": "^3.5.3",
"mocha-jenkins-reporter": "^0.3.9", "mocha-jenkins-reporter": "^0.3.9",

View File

@ -21,6 +21,7 @@ const mocha = require('gulp-mocha');
const execa = require('execa'); const execa = require('execa');
const path = require('path'); const path = require('path');
const del = require('del'); const del = require('del');
const linkSync = require('../../util').linkSync;
const gulp = help(_gulp); const gulp = help(_gulp);
@ -39,8 +40,8 @@ gulp.task('health-check.install', 'Install health check dependencies', () => {
return execa('npm', ['install', '--unsafe-perm'], {cwd: healthCheckDir, stdio: 'inherit'}); return execa('npm', ['install', '--unsafe-perm'], {cwd: healthCheckDir, stdio: 'inherit'});
}); });
gulp.task('health-check.link.add', 'Link local copy of grpc', ['health-check.install'], () => { gulp.task('health-check.link.add', 'Link local copy of grpc', () => {
return execa('npm', ['link', 'grpc'], {cwd: healthCheckDir, stdio: 'inherit'}); linkSync(healthCheckDir, './node_modules/@grpc/native', '../grpc-native');
}); });
gulp.task('health-check.test', 'Run health check tests', gulp.task('health-check.test', 'Run health check tests',

View File

@ -101,10 +101,6 @@ gulp.task('js.core.install', 'Install native core dependencies', () => {
return execa('npm', ['install', '--unsafe-perm'], {cwd: jsCoreDir, stdio: 'inherit'}); return execa('npm', ['install', '--unsafe-perm'], {cwd: jsCoreDir, stdio: 'inherit'});
}); });
gulp.task('js.core.link.create', 'Create npm link', () => {
return execa('npm', ['link'], {cwd: jsCoreDir, stdio: 'inherit'});
});
/** /**
* 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.
*/ */

View File

@ -24,6 +24,7 @@ const gulp = help(_gulp);
const execa = require('execa'); const execa = require('execa');
const path = require('path'); const path = require('path');
const del = require('del'); const del = require('del');
const linkSync = require('../../util').linkSync;
const jsDir = __dirname; const jsDir = __dirname;
@ -39,11 +40,7 @@ gulp.task('js.install', 'Install dependencies', () => {
return execa('npm', ['install', '--unsafe-perm'], {cwd: jsDir, stdio: 'inherit'}); return execa('npm', ['install', '--unsafe-perm'], {cwd: jsDir, stdio: 'inherit'});
}); });
gulp.task('js.link.create', 'Create npm link', () => {
return execa('npm', ['link'], {cwd: jsDir, stdio: 'inherit'});
});
gulp.task('js.link.add', 'Link local copies of dependencies', () => { gulp.task('js.link.add', 'Link local copies of dependencies', () => {
return execa('npm', ['link', '@grpc/js-core'], {cwd: jsDir, stdio: 'inherit'}).then( linkSync(jsDir, './node_modules/@grpc/js-core', '../grpc-js-core');
execa('npm', ['link', '@grpc/surface'], {cwd: jsDir, stdio: 'inherit'})); linkSync(jsDir, './node_modules/@grpc/surface', '../grpc-surface');
}); });

View File

@ -57,10 +57,6 @@ execa('npm', ['install', '--build-from-source'],
)) ))
}); });
gulp.task('native.core.link.create', 'Create npm link', () => {
return execa('npm', ['link'], {cwd: nativeCoreDir, stdio: 'inherit'});
});
gulp.task('native.core.lint', 'Emits linting errors', () => { gulp.task('native.core.lint', 'Emits linting errors', () => {
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))

View File

@ -24,6 +24,7 @@ const gulp = help(_gulp);
const execa = require('execa'); const execa = require('execa');
const path = require('path'); const path = require('path');
const del = require('del'); const del = require('del');
const linkSync = require('../../util').linkSync;
const nativeDir = __dirname; const nativeDir = __dirname;
@ -35,16 +36,11 @@ gulp.task('native.clean.links', 'Delete npm links', () => {
gulp.task('native.clean.all', 'Delete all files created by tasks', gulp.task('native.clean.all', 'Delete all files created by tasks',
['native.clean.links']); ['native.clean.links']);
gulp.task('native.link.create', 'Create npm link', () => {
return execa('npm', ['link'], {cwd: nativeDir, stdio: 'inherit'});
});
gulp.task('native.install', 'Install dependencies', () => { gulp.task('native.install', 'Install dependencies', () => {
return execa('npm', ['install', '--unsafe-perm'], {cwd: nativeDir, stdio: 'inherit'}); return execa('npm', ['install', '--unsafe-perm'], {cwd: nativeDir, stdio: 'inherit'});
}); });
gulp.task('native.link.add', 'Link local copies of dependencies', () => { gulp.task('native.link.add', 'Link local copies of dependencies', () => {
// Note: this should be 'grpc-native-core', when we change that package name linkSync(nativeDir, './node_modules/grpc', '../grpc-native-core');
return execa('npm', ['link', 'grpc'], {cwd: nativeDir, stdio: 'inherit'}).then( linkSync(nativeDir, './node_modules/@grpc/surface', '../grpc-surface');
execa('npm', ['link', '@grpc/surface'], {cwd: nativeDir, stdio: 'inherit'}));
}); });

View File

@ -25,6 +25,4 @@ const execa = require('execa');
const surfaceDir = __dirname; const surfaceDir = __dirname;
gulp.task('surface.link.create', 'Create npm link', () => { // more to come
return execa('npm', ['link'], {cwd: surfaceDir, stdio: 'inherit'});
});

View File

@ -21,6 +21,7 @@ const mocha = require('gulp-mocha');
const execa = require('execa'); const execa = require('execa');
const path = require('path'); const path = require('path');
const del = require('del'); const del = require('del');
const linkSync = require('../util').linkSync;
// gulp-help monkeypatches tasks to have an additional description parameter // gulp-help monkeypatches tasks to have an additional description parameter
const gulp = help(_gulp); const gulp = help(_gulp);
@ -29,7 +30,10 @@ const testDir = __dirname;
const apiTestDir = path.resolve(testDir, 'api'); const apiTestDir = path.resolve(testDir, 'api');
gulp.task('internal.test.clean.links', 'Delete npm links', () => { gulp.task('internal.test.clean.links', 'Delete npm links', () => {
return del(path.resolve(testDir, 'node_modules/grpc')); return del([
path.resolve(testDir, 'node_modules/@grpc/js'),
path.resolve(testDir, 'node_modules/@grpc/native')
]);
}); });
gulp.task('internal.test.install', 'Install test dependencies', () => { gulp.task('internal.test.install', 'Install test dependencies', () => {
@ -39,8 +43,9 @@ gulp.task('internal.test.install', 'Install test dependencies', () => {
gulp.task('internal.test.clean.all', 'Delete all files created by tasks', gulp.task('internal.test.clean.all', 'Delete all files created by tasks',
['internal.test.clean.links']); ['internal.test.clean.links']);
gulp.task('internal.test.link.add', 'Link local copies of grpc packages', () => { gulp.task('internal.test.link.add', 'Link local copies of dependencies', () => {
return execa('npm', ['link', 'grpc'], {cwd: testDir, stdio: 'inherit'}); linkSync(testDir, './node_modules/@grpc/js', '../packages/grpc-js');
linkSync(testDir, './node_modules/@grpc/native', '../packages/grpc-native');
}); });
gulp.task('internal.test.test', 'Run API-level tests', () => { gulp.task('internal.test.test', 'Run API-level tests', () => {

23
util.js Normal file
View File

@ -0,0 +1,23 @@
const path = require('path');
const del = require('del');
const fs = require('fs');
const makeDir = require('make-dir');
// synchronously link a module
const linkSync = (base, from, to) => {
from = path.resolve(base, from);
to = path.resolve(base, to);
try {
fs.lstatSync(from);
} catch (e) {
console.log('link: deleting', from);
del.sync(from);
}
makeDir.sync(path.dirname(from));
console.log('link: linking', from, '->', to);
fs.symlinkSync(to, from, 'junction');
};
module.exports = {
linkSync
};