From 252a761005866c226d6b6e05fd7723873db556ee Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Thu, 6 Jul 2017 12:00:04 +0300 Subject: [PATCH] Better cross-platform support for building bb-server frontend --- bulletin-board-server-frontend/build.gradle | 3 +-- .../generate-protobuf.js | 21 +++++++++++++++++++ bulletin-board-server-frontend/package.json | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 bulletin-board-server-frontend/generate-protobuf.js diff --git a/bulletin-board-server-frontend/build.gradle b/bulletin-board-server-frontend/build.gradle index fefa3d1..3810624 100644 --- a/bulletin-board-server-frontend/build.gradle +++ b/bulletin-board-server-frontend/build.gradle @@ -42,8 +42,7 @@ task generateProtobufBundle(type: NpmTask) { // We need do this in doFirst since getProtoFiles won't find all subprojects // until after configuration is complete def protoFiles = getProtoFiles() - setEnvironment([PROTO_FILES: protoFiles.join(" ")]); - generateProtobufBundle.args = ['run', 'protoc'] + generateProtobufBundle.args = ['run', 'protoc', '--' ] + protoFiles; } dependsOn npm_install diff --git a/bulletin-board-server-frontend/generate-protobuf.js b/bulletin-board-server-frontend/generate-protobuf.js new file mode 100755 index 0000000..eeb255e --- /dev/null +++ b/bulletin-board-server-frontend/generate-protobuf.js @@ -0,0 +1,21 @@ +#!/usr/bin/env node +const { execFileSync } = require('child_process'); + +const bundlejs = 'src/app/bundle.js' +const bundlets = 'src/app/bundle.d.ts' + +var pbjs_args = [ + '-t', 'static-module', '-w', 'commonjs', '-o', bundlejs +].concat(process.argv.slice(2)); + +console.log("Running pbjs " + pbjs_args.join(" ")); +var out = execFileSync('pbjs', pbjs_args); +console.log("" + out); + +var pbts_args = [ + '-o', bundlets, bundlejs +]; + +console.log("Running pbts " + pbts_args.join(" ")); +out = execFileSync('pbts', pbts_args); +console.log("" + out); diff --git a/bulletin-board-server-frontend/package.json b/bulletin-board-server-frontend/package.json index ceaaf48..58d7e8a 100644 --- a/bulletin-board-server-frontend/package.json +++ b/bulletin-board-server-frontend/package.json @@ -10,7 +10,7 @@ "lint": "ng e2e", "pbts": "pbts", "pbjs": "pbjs", - "protoc" : "pbjs -t static-module -w commonjs -o src/app/bundle.js $PROTO_FILES && pbts -o src/app/bundle.d.ts src/app/bundle.js" + "protoc" : "./generate-protobuf.js" }, "private": true, "dependencies": {