Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decouple init and start #4

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ jobs:
fail-fast: false
matrix:
settings:
- host: macos-latest
- host: macos-14-large
target: x86_64-apple-darwin
build: |
bun run build
architecture: x64
build: |-
set -e &&
bun run build --target x86_64-apple-darwin &&
strip -x *.node
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
Expand All @@ -46,6 +48,8 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.26
- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
Expand All @@ -58,7 +62,7 @@ jobs:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
Expand Down Expand Up @@ -89,7 +93,7 @@ jobs:
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
Expand All @@ -102,21 +106,25 @@ jobs:
strategy:
matrix:
settings:
- host: macos-latest
- host: macos-14-large
target: x86_64-apple-darwin
architecture: x64
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.26
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
architecture: ${{ matrix.settings.architecture }}
- name: Install dependencies
run: bun install
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: .
Expand All @@ -140,22 +148,24 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.26
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: bun install
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: docker run --rm -v $(pwd):/build -w /build oven/bun:1 bun test
run: docker run --rm -v $(pwd):/build -w /build oven/bun:1.0.26 bun test

publish:
name: Publish
Expand All @@ -167,14 +177,16 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.26
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: bun install
- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
{
devShells.aarch64-darwin.default = mkDevShell "aarch64-darwin";
devShells.x86_64-darwin.default = mkDevShell "x86_64-darwin";
devShells.x86_64-linux.default = mkDevShell "x86_64-linux";
};
}
7 changes: 5 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

/* auto-generated by NAPI-RS */

export interface Pid {
pid: number
}
export interface Size {
cols: number
rows: number
}
export class Pty {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does napi-rs preserve comments? it would be neat to have a little warning in the docstring telling folks to always start reading from the FD before calling start to avoid surprises.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, this file is auto-generated, not sure if we can inject comments into it

fd: number
pid: number
constructor(command: string, args: Array<string>, envs: Record<string, string>, dir: string, size: Size, onExit: (err: null | Error, exitCode: number) => void)
constructor(command: string, args: Array<string>, envs: Record<string, string>, dir: string, size: Size)
start(onExit: (err: null | Error, exitCode: number) => void): Pid
resize(size: Size): void
}
35 changes: 25 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,32 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'ruspty.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./ruspty.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@replit/ruspty-linux-arm-gnueabihf')
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'ruspty.linux-arm-musleabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./ruspty.linux-arm-musleabihf.node')
} else {
nativeBinding = require('@replit/ruspty-linux-arm-musleabihf')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'ruspty.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./ruspty.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@replit/ruspty-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
} catch (e) {
loadError = e
}
break
case 'riscv64':
Expand Down
Loading