Skip to content

Commit 39a90fe

Browse files
committed
renamed to match npm package name
1 parent e8d14aa commit 39a90fe

File tree

7 files changed

+54
-18
lines changed

7 files changed

+54
-18
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "proto-ts"
2+
name = "protos-ts"
33
version = "0.1.0"
44
edition = "2021"
55
authors = ["Andrii Biletskyi <[email protected]>"]
@@ -9,13 +9,13 @@ authors = ["Andrii Biletskyi <[email protected]>"]
99
# cargo watch -x 'run -- ./test-folder --out ./out'
1010
# RUSTFLAGS=-Awarnings cargo watch -x 'run -- ./test-folder --out ./out'
1111
# RUST_BACKTRACE=1 RUSTFLAGS=-Awarnings cargo watch -x 'run -- ./test-folder --out ./out'
12-
# ./target/release/proto-ts.exe ./test-folder --out out
13-
# time ./target/release/proto-ts.exe ./test-real --out out
12+
# ./target/release/protos-ts.exe ./test-folder --out out
13+
# time ./target/release/protos-ts.exe ./test-real --out out
1414

1515

1616
[dependencies]
1717
path-clean = "0.1.0"
1818

1919
[[bin]]
20-
name = "proto-ts"
20+
name = "protos-ts"
2121
path = "main.rs"

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# proto-ts [Alpha Version]
1+
# protos-ts [Alpha Version]
22

33
This a CLI tool for transforming of .proto files into typescript modules.
44

@@ -21,7 +21,7 @@ Also `protobufjs` uses JS to read, parse and compile `.proto` schemas to javascr
2121
## Usage
2222

2323
```
24-
proto-ts ./proto --out ./out
24+
protos-ts ./proto --out ./out
2525
```
2626

2727
`./proto`

build.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
cargo b --release
44

5-
cp ./target/release/proto-ts ./package/bin/proto-ts-linux
5+
mkdir ./package/bin
6+
cp -r ./target/release/protos-ts ./package/bin/protos-ts-linux

package/bin/protos-ts-linux

4.33 MB
Binary file not shown.

package/index.js

100644100755
+40-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
#!/usr/bin/env node
22

3-
const util = require('node:util');
4-
const spawn = util.promisify(require('node:child_process').spawn);
3+
const path = require("path");
4+
const process = require("process");
5+
const { spawn } = require("child_process");
56

6-
async function main() {
7-
console.log('here')
8-
console.log('in', process.cwd())
7+
async function main(parameters) {
8+
const cliPath = getCliPath();
9+
const cliProcess = spawn(cliPath, parameters, {
10+
cwd: process.cwd(),
11+
});
12+
const code = await new Promise(resolve => cliProcess.on('close', resolve))
13+
process.exit(code)
914
}
1015

16+
function getCliPath() {
17+
const currentOs = process.platform;
1118

12-
main()
19+
if (currentOs === "linux") {
20+
return path.resolve(__dirname, "./bin/protos-ts-linux");
21+
}
22+
23+
// TODO: add support for 'aix'
24+
// TODO: add support for 'darwin'
25+
// TODO: add support for 'freebsd'
26+
// TODO: add support for 'linux'
27+
// TODO: add support for 'openbsd'
28+
// TODO: add support for 'sunos'
29+
// TODO: add support for 'win32'
30+
failWithBugReport(`Sorry, unsupported OS: "${process.platform}"`);
31+
}
32+
33+
function fail(message) {
34+
console.error(message);
35+
process.exit(1);
36+
}
37+
38+
function failWithBugReport(message) {
39+
fail(`${message}\nPlease open the issue in ${require("./package.json").bugs.url}`);
40+
}
41+
42+
const parameters = process.argv.slice(2);
43+
44+
main(parameters).catch((error) => {
45+
failWithBugReport(`Unexpacted error: ${error.message}`);
46+
});

package/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "protos-ts",
3-
"version": "0.0.1",
3+
"bin": "index.js",
4+
"version": "0.0.2",
45
"description": "CLI compiler of protocol buffer schemas to typescript es modules",
56
"main": "index.js",
67
"scripts": {
78
"test": "echo \"Error: no test specified\" && exit 1"
89
},
910
"repository": {
1011
"type": "git",
11-
"url": "git+https://github.com/whiteand/proto-ts.git"
12+
"url": "git+https://github.com/whiteand/protos-ts.git"
1213
},
1314
"keywords": [
1415
"protocol",
@@ -20,7 +21,7 @@
2021
"author": "whiteand",
2122
"license": "ISC",
2223
"bugs": {
23-
"url": "https://github.com/whiteand/proto-ts/issues"
24+
"url": "https://github.com/whiteand/protos-ts/issues"
2425
},
25-
"homepage": "https://github.com/whiteand/proto-ts#readme"
26+
"homepage": "https://github.com/whiteand/protos-ts#readme"
2627
}

0 commit comments

Comments
 (0)