@@ -24,14 +24,11 @@ var fs = require('fs-extra');
2424var glob = require ( 'glob' ) ;
2525var packager = require ( './packager' ) ;
2626var path = require ( 'path' ) ;
27- var pbjs = require ( 'protobufjs/cli/pbjs' ) ;
28- var pbjsUtil = require ( 'protobufjs/cli/pbjs/util' ) ;
2927var readline = require ( 'readline' ) ;
3028var request = require ( 'request' ) ;
3129var tmp = require ( 'tmp' ) ;
3230
3331var EventEmitter = require ( 'events' ) . EventEmitter ;
34- var ProtoBuf = require ( 'protobufjs' ) ;
3532var StreamZip = require ( 'node-stream-zip' ) ;
3633
3734exports . ApiRepo = ApiRepo ;
@@ -214,7 +211,7 @@ ApiRepo.prototype.buildPackages =
214211 packageInfo : that . packageInfo ,
215212 generated : generated
216213 } , templateInfo [ l ] ) ;
217- if ( l === 'nodejs' && ! that . opts . nodejsUsePbjs ) {
214+ if ( l === 'nodejs' ) {
218215 opts . packageInfo . protoFiles = _ . filter ( generated , function ( file ) {
219216 return file . match ( / \. p r o t o $ / ) ;
220217 } ) ;
@@ -594,22 +591,7 @@ ApiRepo.prototype._buildProtos =
594591 var fullPathProtos = [ ] ;
595592 function makeModule ( ) {
596593 var includePath = _ . union ( that . includePath , that . repoDirs ) ;
597- if ( ! that . opts . nodejsUsePbjs ) {
598- makeProtoBasedNodeModule ( fullPathProtos , includePath ) ;
599- return ;
600- }
601- var opts = {
602- root : that . repoDirs ,
603- source : 'proto' ,
604- path : includePath
605- } ;
606-
607- var builder = loadProtos ( fullPathProtos , opts ) ;
608- var outDir = path . join ( that . outDir , language ) ;
609- fs . mkdirsSync ( outDir ) ;
610- var servicePath = path . join ( outDir , 'service.js' ) ;
611- var commonJS = pbjs . targets . commonjs ( builder , opts ) ;
612- fs . writeFile ( servicePath , commonJS , findOutputs ) ;
594+ makeProtoBasedNodeModule ( fullPathProtos , includePath ) ;
613595 }
614596
615597 this . _findProtos (
@@ -619,7 +601,6 @@ ApiRepo.prototype._buildProtos =
619601 next ( ) ;
620602 }
621603 ) ;
622- makeModule ( ) ;
623604 } . bind ( this ) ;
624605 this . _findProtos ( name , version , makeNodeModule ) ;
625606 } else {
@@ -1033,41 +1014,3 @@ ApiRepo.prototype._makeProtocFunc = function _makeProtocFunc(opts, language) {
10331014
10341015 return callProtoc ;
10351016} ;
1036-
1037- /**
1038- * Helps construct a JSON representation each proto file for the nodejs build.
1039- *
1040- * @param {string[] } filenames - The list of files.
1041- * @param {object } opts - provides configuration info
1042- * @param {object } opts.root - a virtual root folder that contains all the protos
1043- * @param {object } opts.path - an array of folders where other protos reside
1044- *
1045- * @return {object } a ProtoBuf.Builder containing loaded representations of the
1046- * protos
1047- */
1048- function loadProtos ( filenames , opts ) {
1049- opts = opts || [ ] ;
1050- var builder = ProtoBuf . newBuilder ( ) ;
1051- var loaded = [ ] ;
1052- builder . importRoot = opts . root ;
1053- filenames . forEach ( function ( filename ) {
1054- var data = pbjs . sources . proto . load ( filename , opts , loaded ) ;
1055- builder . import ( data , filename ) ;
1056- } ) ;
1057- builder . resolveAll ( ) ;
1058- return builder ;
1059- }
1060-
1061- /**
1062- * Replace isDescriptor with a version that always returns false.
1063- *
1064- * pbjs/util.isDescriptor excludes imports that in google/protobuf.
1065- *
1066- * However, the nodejs packages need to be self-contained, so we actually want
1067- * to include these.
1068- * @param {string } name - The name of the message.
1069- * @return {Boolean } Whether it is a descriptor or not.
1070- */
1071- pbjsUtil . isDescriptor = function ( name ) {
1072- return false ;
1073- } ;
0 commit comments