Skip to content

Commit

Permalink
🔀 ✨ Embedded protoc bin (#257)
Browse files Browse the repository at this point in the history
* ⬆️ Bump typescript from 5.0.4 to 5.1.3

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.0.4 to 5.1.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v5.0.4...v5.1.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* ✨ Embedded protoc bin

* ✨ Release 2.3.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
devkanro and dependabot[bot] authored Sep 8, 2023
1 parent d3b8999 commit 26ac9f3
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 56 deletions.
14 changes: 7 additions & 7 deletions examples/example-simple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/example-simple",
"version": "2.2.0",
"version": "2.3.0",
"description": "Example project using sisyphus.js",
"main": "dist/index.js",
"scripts": {
Expand All @@ -26,14 +26,14 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.2.0",
"@sisyphus.js/google.proto": "^2.2.0",
"@sisyphus.js/runtime.proto": "^2.2.0"
"@sisyphus.js/cli": "^2.3.0",
"@sisyphus.js/google.proto": "^2.3.0",
"@sisyphus.js/runtime.proto": "^2.3.0"
},
"dependencies": {
"@sisyphus.js/google": "^2.2.0",
"@sisyphus.js/runtime": "^2.2.0",
"@sisyphus.js/transport-aip": "^2.2.0"
"@sisyphus.js/google": "^2.3.0",
"@sisyphus.js/runtime": "^2.3.0",
"@sisyphus.js/transport-aip": "^2.3.0"
},
"directories": {
"proto": "proto"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages/*",
"examples/*"
],
"version": "2.2.0"
"version": "2.3.0"
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/sisyphus-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/cli",
"version": "2.2.0",
"version": "2.3.0",
"description": "Protoc cli for sisyphus project on js platform",
"bin": {
"sisygen": "lib/index.js"
Expand Down Expand Up @@ -30,10 +30,10 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/compiler": "^2.2.0",
"@sisyphus.js/protoc": "^2.2.0",
"@sisyphus.js/runtime": "^2.2.0",
"@sisyphus.js/runtime.proto": "^2.2.0",
"@sisyphus.js/compiler": "^2.3.0",
"@sisyphus.js/protoc": "^2.3.0",
"@sisyphus.js/runtime": "^2.3.0",
"@sisyphus.js/runtime.proto": "^2.3.0",
"commander": "^10.0.0",
"npmlog": "^7.0.1"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/sisyphus-cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface ProtobufConfig {
* The packages name of source protos to compile in deps.
*/
packages: string[]

version: string
}

export interface DirectoryConfig {
Expand Down
4 changes: 4 additions & 0 deletions packages/sisyphus-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export async function main(args: string[]): Promise<number> {
...targetProtos
]

if (packageInfo.protobuf?.version) {
protocArgs.unshift("--version", packageInfo.protobuf.version)
}

log.info('cli', `Run protoc ${protocArgs.join(' ')}`)

const result = await protoc(...protocArgs)
Expand Down
4 changes: 2 additions & 2 deletions packages/sisyphus-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/compiler",
"version": "2.2.0",
"version": "2.3.0",
"description": "Precompiled google common protos by sisyphus protobuf compiler",
"main": "lib/index.js",
"sisyphus": {
Expand Down Expand Up @@ -35,6 +35,6 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/protoc": "^2.2.0"
"@sisyphus.js/protoc": "^2.3.0"
}
}
10 changes: 5 additions & 5 deletions packages/sisyphus-google-aip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/google.aip",
"version": "2.2.0",
"version": "2.3.0",
"description": "Precompiled google common aip clients by sisyphus protobuf compiler",
"scripts": {
"clean": "tsc --build --clean",
Expand Down Expand Up @@ -33,12 +33,12 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.2.0",
"@sisyphus.js/google.proto": "^2.2.0"
"@sisyphus.js/cli": "^2.3.0",
"@sisyphus.js/google.proto": "^2.3.0"
},
"dependencies": {
"@sisyphus.js/google": "^2.2.0",
"@sisyphus.js/transport-aip": "^2.2.0"
"@sisyphus.js/google": "^2.3.0",
"@sisyphus.js/transport-aip": "^2.3.0"
},
"directories": {
"lib": "lib"
Expand Down
10 changes: 5 additions & 5 deletions packages/sisyphus-google-proto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/google.proto",
"version": "2.2.0",
"version": "2.3.0",
"description": "Precompiled google common protos with full protobuf by sisyphus protobuf compiler",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -34,12 +34,12 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.2.0"
"@sisyphus.js/cli": "^2.3.0"
},
"dependencies": {
"@sisyphus.js/google": "^2.2.0",
"@sisyphus.js/runtime": "^2.2.0",
"@sisyphus.js/runtime.proto": "^2.2.0"
"@sisyphus.js/google": "^2.3.0",
"@sisyphus.js/runtime": "^2.3.0",
"@sisyphus.js/runtime.proto": "^2.3.0"
},
"directories": {
"lib": "lib"
Expand Down
6 changes: 3 additions & 3 deletions packages/sisyphus-google/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/google",
"version": "2.2.0",
"version": "2.3.0",
"description": "Precompiled google common protos by sisyphus protobuf compiler",
"scripts": {
"clean": "tsc --build --clean",
Expand Down Expand Up @@ -34,10 +34,10 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.2.0"
"@sisyphus.js/cli": "^2.3.0"
},
"dependencies": {
"@sisyphus.js/runtime": "^2.2.0"
"@sisyphus.js/runtime": "^2.3.0"
},
"directories": {
"lib": "lib",
Expand Down
Binary file added packages/sisyphus-protoc/bin/linux/x32/protoc
Binary file not shown.
Binary file added packages/sisyphus-protoc/bin/linux/x64/protoc
Binary file not shown.
Binary file added packages/sisyphus-protoc/bin/osx/protoc
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/sisyphus-protoc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/protoc",
"version": "2.2.0",
"version": "2.3.0",
"description": "Install protoc for current platform.",
"main": "lib/index.js",
"bin": {
Expand Down
36 changes: 22 additions & 14 deletions packages/sisyphus-protoc/src/protoc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import zip from 'adm-zip'
import {exec, spawn} from 'child_process'
import {spawn} from 'child_process'
import {constants, existsSync} from 'fs'
import fs from 'fs/promises'
import log from 'npmlog'
Expand Down Expand Up @@ -34,11 +34,9 @@ export default async function protoc(...args: string[]): Promise<number | null>

async function ensureProtoc(version: string | undefined | null): Promise<string> {
if (version == null) {
version = await resolveLocalProtoc()
if (version) {
log.info('protoc', `Use installed protoc ${version}.`)
return 'protoc'
}
const localProtoc = resolveLocalProtoc()
log.info('protoc', `Use local protoc ${localProtoc}.`)
return localProtoc
}

if (version === 'latest' || version == null) {
Expand Down Expand Up @@ -75,16 +73,26 @@ async function ensureProtoc(version: string | undefined | null): Promise<string>
return protocPath
}

function resolveLocalProtoc(): Promise<string | null> {
return new Promise((res, rej) => {
exec("protoc --version", (error, stdout, _) => {
if (error) {
res(null)
function resolveLocalProtoc(): string {
let executable = 'linux/x32/protoc'
switch (process.platform) {
case 'linux':
if (process.arch === 'x64') {
executable = 'linux/x64/protoc'
}
break
case 'darwin':
executable = 'osx/protoc'
break
case 'win32':
if (process.arch === 'x64') {
executable = 'windows/x64/protoc.exe'
} else {
res(stdout.trim())
executable = 'windows/x32/protoc.exe'
}
})
})
break
}
return path.join(__dirname, '../bin', executable)
}

async function resolveLatestProtoc(): Promise<string> {
Expand Down
4 changes: 2 additions & 2 deletions packages/sisyphus-runtime-proto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/runtime.proto",
"version": "2.2.0",
"version": "2.3.0",
"description": "Protobuf full runtime for sisyphus project on js platform, support protobuf binary format.",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/runtime": "^2.2.0"
"@sisyphus.js/runtime": "^2.3.0"
},
"directories": {
"lib": "lib"
Expand Down
2 changes: 1 addition & 1 deletion packages/sisyphus-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/runtime",
"version": "2.2.0",
"version": "2.3.0",
"description": "Protobuf lite runtime for sisyphus project on js platform, only support JSON format.",
"main": "lib/index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/sisyphus-transport-aip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/transport-aip",
"version": "2.2.0",
"version": "2.3.0",
"description": "gRPC transport based on AIP spec(gRPC to HTTP/Json Transcoding).",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -32,8 +32,8 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/google": "^2.2.0",
"@sisyphus.js/runtime": "^2.2.0"
"@sisyphus.js/google": "^2.3.0",
"@sisyphus.js/runtime": "^2.3.0"
},
"directories": {
"lib": "lib",
Expand Down

0 comments on commit 26ac9f3

Please sign in to comment.