32
32
33
33
_buildJs = flag .Bool ("build-js" , false , "Build Js library" )
34
34
_pushJs = flag .Bool ("push-js" , false , "Push Js library to github.com/cs3org/js-cs3apis" )
35
+
36
+ _buildNode = flag .Bool ("build-node" , false , "Build Node.js library" )
37
+ _pushNode = flag .Bool ("push-node" , false , "Push Node.js library to github.com/cs3org/node-cs3apis" )
35
38
)
36
39
37
40
func init () {
@@ -42,17 +45,20 @@ func init() {
42
45
* _buildGo = true
43
46
* _buildPython = true
44
47
* _buildJs = true
48
+ * _buildNode = true
45
49
46
50
* _pushGo = true
47
51
* _pushPython = true
48
52
* _pushJs = true
53
+ * _pushNode = true
49
54
}
50
55
51
56
if * _only_build {
52
57
* _buildProto = true
53
58
* _buildGo = true
54
59
* _buildPython = true
55
60
* _buildJs = true
61
+ * _buildNode = true
56
62
}
57
63
}
58
64
@@ -418,6 +424,44 @@ func buildJS() {
418
424
commit (repo , msg )
419
425
}
420
426
427
+ func buildNode () {
428
+ // Remove build dir
429
+ os .RemoveAll ("build/node-cs3apis" )
430
+ os .MkdirAll ("build" , 0755 )
431
+
432
+ // Clone repo and set branch to current branch
433
+ clone ("cs3org/node-cs3apis" , "build" )
434
+ protoBranch := getGitBranch ("." )
435
+ buildBranch := getGitBranch ("build/node-cs3apis" )
436
+ fmt .Printf ("Proto branch: %s\n Build branch: %s\n " , protoBranch , buildBranch )
437
+
438
+ if buildBranch != protoBranch {
439
+ checkout (protoBranch , "build/node-cs3apis" )
440
+ }
441
+
442
+ nodeProtocPlugin , err := exec .LookPath ("grpc_tools_node_protoc_plugin" )
443
+
444
+ if err != nil {
445
+ panic (fmt .Sprintf ("grpc_tools_node_protoc_plugin binary not found in PATH: %v\n " , err ))
446
+ }
447
+
448
+ // remove leftovers (existing defs)
449
+ os .RemoveAll ("build/node-cs3apis/cs3" )
450
+
451
+ files := findProtos ()
452
+
453
+ args := []string {"--js_out=import_style=commonjs,binary:./build/node-cs3apis" , "--grpc_out=./build/node-cs3apis/" , "--plugin=protoc-gen-grpc=" + nodeProtocPlugin }
454
+ args = append (args , files ... )
455
+ cmd := exec .Command ("grpc_tools_node_protoc" , args ... )
456
+ run (cmd )
457
+
458
+ // get proto repo commit id
459
+ hash := getCommitID ("." )
460
+ repo := "build/node-cs3apis"
461
+ msg := "Synced to https://github.com/cs3org/cs3apis/tree/" + hash
462
+ commit (repo , msg )
463
+ }
464
+
421
465
func pushPython () {
422
466
push ("build/python-cs3apis" )
423
467
}
@@ -430,9 +474,13 @@ func pushJS() {
430
474
push ("build/js-cs3apis" )
431
475
}
432
476
477
+ func pushNode () {
478
+ push ("build/node-cs3apis" )
479
+ }
480
+
433
481
func main () {
434
482
if * _buildProto {
435
- fmt .Println ("Compiling and liniting protobufs ..." )
483
+ fmt .Println ("Compiling and linting protobufs ..." )
436
484
buildProto ()
437
485
}
438
486
@@ -465,4 +513,14 @@ func main() {
465
513
fmt .Println ("Pushing Js ..." )
466
514
pushJS ()
467
515
}
516
+
517
+ if * _buildNode {
518
+ fmt .Println ("Building Node.js ..." )
519
+ buildNode ()
520
+ }
521
+
522
+ if * _pushNode {
523
+ fmt .Println ("Pushing Node.js ..." )
524
+ pushNode ()
525
+ }
468
526
}
0 commit comments