Skip to content

Commit

Permalink
fix: executable issue on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Nov 24, 2021
1 parent ce7dd99 commit ec62253
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 40 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ on:
paths-ignore:
- '**.md'
jobs:
test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup node 12
uses: actions/setup-node@v2
with:
node-version: 14.x
- shell: bash
run: yarn test
- shell: bash
run: cd examples/pure && yarn --frozen-lockfile && yarn test
test:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -22,7 +36,7 @@ jobs:
- name: Setup node 12
uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: 14.x
- run: yarn --frozen-lockfile
- run: yarn codegen
- run: yarn test
Expand Down
15 changes: 15 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
third-party
test
docs
examples
scripts
.*
.tgz
# ignore everything that is typescript or proto file
src/**/*.ts
src/**/*.proto
# bazel stuff
BUILD.bazel
WORKSPACE
bazel-*

3 changes: 1 addition & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ pkg_npm(
name = "package",
package_name = "protoc-gen-ts",
srcs = [
"//bin:protoc-gen-ts",
"//bin:protoc-gen-ts.cmd",
"//bin:protoc-gen-ts.js",
"index.bzl",
"package.json",
"README.md",
Expand Down
11 changes: 6 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Setup NodeJS toolchain
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "5c40083120eadec50a3497084f99bc75a85400ea727e82e0b2f422720573130f",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.0.0-beta.0/rules_nodejs-4.0.0-beta.0.tar.gz"],
sha256 = "b32a4713b45095e9e1921a7fcb1adf584bc05959f3336e7351bcf77f015a2d7c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.1.0/rules_nodejs-4.1.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
Expand All @@ -29,10 +29,11 @@ yarn_install(
# Setup Protocol Buffers toolchain
http_archive(
name = "rules_proto",
sha256 = "57001a3b33ec690a175cdf0698243431ef27233017b9bed23f96d44b9c98242f",
strip_prefix = "rules_proto-9cd4f8f1ede19d81c6d48910429fe96776e567b1",
sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/9cd4f8f1ede19d81c6d48910429fe96776e567b1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
)

Expand Down
6 changes: 3 additions & 3 deletions bin/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package(default_visibility = ["//visibility:public"])

nodejs_binary(
name = "bin",
entry_point = ":protoc-gen-ts",
entry_point = ":protoc-gen-ts.js",
data = [
"//src",
":protoc-gen-ts"
":protoc-gen-ts.js"
],
# See: https://github.com/bazelbuild/rules_nodejs/issues/2600
templated_args = ["--bazel_patch_module_resolver"],
)

exports_files(["protoc-gen-ts", "protoc-gen-ts.cmd"])
exports_files(["protoc-gen-ts.js"])
14 changes: 0 additions & 14 deletions bin/protoc-gen-ts.cmd

This file was deleted.

1 change: 0 additions & 1 deletion bin/protoc-gen-ts → bin/protoc-gen-ts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/usr/bin/env node

require('../src/index')
5 changes: 2 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"grpc:client": "bazel run //grpc:client",
"grpc:server": "bazel run //grpc:server",
"pretest": "bazel build //grpc:type //bazel:message && node ../scripts/sync_generated_protos.js grpc && node ../scripts/sync_generated_protos.js bazel",
"test": "bazel run //bazel:bin",
"preinstall": "cd ../ && bazel build :package"
"test": "bazel run //bazel:bin"
},
"dependencies": {
"@grpc/grpc-js": "^1.2.12",
"google-protobuf": "^3.15.8",
"protoc-gen-ts": "file:../bazel-bin/package"
"protoc-gen-ts": "file:../"
},
"devDependencies": {
"@bazel/bazelisk": "^1.7.5",
Expand Down
17 changes: 7 additions & 10 deletions index.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
load("@rules_proto//proto:defs.bzl", "ProtoInfo")

def _get_bin():
# BEGIN-INTERNAL
return "//bin"
# END-INTERNAL
return "//protoc-gen-ts/bin:protoc-gen-ts"

def _proto_path(proto):
"""
The proto path is not really a file path
Expand Down Expand Up @@ -46,7 +40,7 @@ def _ts_proto_library(ctx):

protoc_args = ctx.actions.args()

protoc_args.add("--plugin=protoc-gen-ts=%s" % ( ctx.executable.protoc_gen_ts_bin.path ))
protoc_args.add("--plugin=protoc-gen-ts=%s" % (ctx.executable.protoc_gen_ts_bin.path))

protoc_args.add("--ts_out=%s" % (ctx.bin_dir.path))

Expand Down Expand Up @@ -97,12 +91,15 @@ ts_proto_library = rule(
),
"protoc_gen_ts_bin": attr.label(
executable = True,
cfg = "exec",
default = _get_bin(),
cfg = "host",
default = (
"//protoc-gen-ts/bin:protoc-gen-ts"
),
),
"_protoc": attr.label(
cfg = "host",
executable = True,
cfg = "exec",
allow_single_file = True,
default = (
"@com_google_protobuf//:protoc"
),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"codegen": "node ./scripts/sync_compiler_protos.js && bazel build //src:codegen && node ./scripts/sync_generated_protos.js src/compiler && bazel build //src:compiler && node ./scripts/sync_generated_protos.js src/compiler js"
},
"bin": {
"protoc-gen-ts": "./bin/protoc-gen-ts"
"protoc-gen-ts": "./bin/protoc-gen-ts.js"
},
"peerDependencies": {
"google-protobuf": "^3.13.0",
Expand Down
5 changes: 5 additions & 0 deletions protoc-gen-ts/bin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alias(
name = "protoc-gen-ts",
actual = "//bin",
visibility = ["//visibility:public"]
)

0 comments on commit ec62253

Please sign in to comment.