-
Notifications
You must be signed in to change notification settings - Fork 8
support bun and deno #258
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
support bun and deno #258
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,104 @@ | ||||||||||||||||||||||
| name: Alternative Runtimes (Bun & Deno) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }} | ||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| on: | ||||||||||||||||||||||
| push: | ||||||||||||||||||||||
| branches: [ main ] | ||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||
| branches: [ main ] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||
| bun-test: | ||||||||||||||||||||||
| name: Bun ${{ matrix.bun-version }} on ${{ matrix.os }} | ||||||||||||||||||||||
| # Skip this job for version bump commits (binary won't exist yet) | ||||||||||||||||||||||
| if: "!contains(github.event.head_commit.message, 'Release')" | ||||||||||||||||||||||
| runs-on: ${{ matrix.os }} | ||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||||||||||||||||||||||
| bun-version: [ '1.0.0', 'latest' ] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v3 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Setup Bun ${{ matrix.bun-version }} | ||||||||||||||||||||||
| uses: oven-sh/setup-bun@v1 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| bun-version: ${{ matrix.bun-version }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Verify Bun installation | ||||||||||||||||||||||
| run: bun --version | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Install dependencies (npm install via postinstall) | ||||||||||||||||||||||
| working-directory: ./node | ||||||||||||||||||||||
| run: bun install | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Test CLI wrapper with Bun (--version) | ||||||||||||||||||||||
| working-directory: ./node | ||||||||||||||||||||||
| run: bun run cli.js --version | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Test CLI wrapper with Bun (--help) | ||||||||||||||||||||||
| working-directory: ./node | ||||||||||||||||||||||
| run: bun run cli.js --help | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Verify CLI wrapper is JavaScript (not binary) | ||||||||||||||||||||||
| working-directory: ./node | ||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| if file cli.js | grep -q "script\|text\|ASCII"; then | ||||||||||||||||||||||
| echo "✅ cli.js is a JavaScript file" | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| echo "❌ cli.js is not a text file!" | ||||||||||||||||||||||
| file cli.js | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| deno-test: | ||||||||||||||||||||||
| name: Deno ${{ matrix.deno-version }} on ${{ matrix.os }} | ||||||||||||||||||||||
| # Skip this job for version bump commits (binary won't exist yet) | ||||||||||||||||||||||
| if: "!contains(github.event.head_commit.message, 'Release')" | ||||||||||||||||||||||
| runs-on: ${{ matrix.os }} | ||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||||||||||||||||||||||
| deno-version: [ 'v1.x', 'v2.x' ] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v3 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Setup Deno ${{ matrix.deno-version }} | ||||||||||||||||||||||
| uses: denoland/setup-deno@v1 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| deno-version: ${{ matrix.deno-version }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Verify Deno installation | ||||||||||||||||||||||
| run: deno --version | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Install dependencies (deno install via postinstall) | ||||||||||||||||||||||
| working-directory: ./node | ||||||||||||||||||||||
| run: deno install | ||||||||||||||||||||||
|
Comment on lines
+82
to
+84
|
||||||||||||||||||||||
| - name: Install dependencies (deno install via postinstall) | |
| working-directory: ./node | |
| run: deno install | |
| - name: Install sqlx-ts Deno binary | |
| working-directory: ./node | |
| run: deno run --allow-all https://deno.land/x/sqlx_ts/install.ts |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cli.js is CommonJS and uses Node built-ins via require(...). deno run cli.js (without Node compatibility flags) will fail because require is not available in standard Deno execution. Either run Deno with the necessary Node-compat options, or rewrite the wrapper to be ESM using node: imports so it can execute under Deno without extra flags.
| run: deno run --allow-read --allow-run cli.js --version | |
| - name: Test CLI wrapper with Deno (--help) | |
| working-directory: ./node | |
| run: deno run --allow-read --allow-run cli.js --help | |
| run: deno run --compat --allow-read --allow-run cli.js --version | |
| - name: Test CLI wrapper with Deno (--help) | |
| working-directory: ./node | |
| run: deno run --compat --allow-read --allow-run cli.js --help |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,20 +36,18 @@ jobs: | |
| - name: Install dependencies (npm install) | ||
| run: npm install | ||
|
|
||
| - name: Verify sqlx-ts binary from npm install | ||
| - name: Verify sqlx-ts CLI wrapper from npm install | ||
| run: | | ||
| chmod +x ./sqlx-ts || true | ||
| ./sqlx-ts --version | ||
| ./sqlx-ts --help | ||
| node cli.js --version | ||
| node cli.js --help | ||
|
Comment on lines
+39
to
+42
|
||
|
|
||
| - name: Install using local install.sh | ||
| run: node postinstall.js | ||
|
|
||
| - name: Verify sqlx-ts binary from local install | ||
| - name: Verify sqlx-ts CLI wrapper from local install | ||
| run: | | ||
| chmod +x ./sqlx-ts || true | ||
| ./sqlx-ts --version | ||
| ./sqlx-ts --help | ||
| node cli.js --version | ||
| node cli.js --help | ||
|
Comment on lines
+47
to
+50
|
||
|
|
||
| linux-distro-static-binary-test: | ||
| name: linux distro ${{ matrix.distro }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { spawn } = require('child_process'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const path = require('path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Determine the binary name based on platform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const platform = process.platform; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const binaryName = platform === 'win32' ? 'sqlx-ts.exe' : 'sqlx-ts'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const binaryPath = path.join(__dirname, binaryName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if binary exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!fs.existsSync(binaryPath)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(`ERROR: sqlx-ts binary not found at ${binaryPath}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error('Please ensure the package was installed correctly (postinstall script should have downloaded it).'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Spawn the binary with all arguments passed through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const child = spawn(binaryPath, process.argv.slice(2), { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stdio: 'inherit', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| windowsHide: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Handle exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child.on('exit', (code, signal) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (signal) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.kill(process.pid, signal); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.exit(code || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Handle errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child.on('error', (err) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(`ERROR: Failed to execute sqlx-ts binary: ${err.message}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+38
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { spawn } = require('child_process'); | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| // Determine the binary name based on platform | |
| const platform = process.platform; | |
| const binaryName = platform === 'win32' ? 'sqlx-ts.exe' : 'sqlx-ts'; | |
| const binaryPath = path.join(__dirname, binaryName); | |
| // Check if binary exists | |
| if (!fs.existsSync(binaryPath)) { | |
| console.error(`ERROR: sqlx-ts binary not found at ${binaryPath}`); | |
| console.error('Please ensure the package was installed correctly (postinstall script should have downloaded it).'); | |
| process.exit(1); | |
| } | |
| // Spawn the binary with all arguments passed through | |
| const child = spawn(binaryPath, process.argv.slice(2), { | |
| stdio: 'inherit', | |
| windowsHide: true | |
| }); | |
| // Handle exit | |
| child.on('exit', (code, signal) => { | |
| if (signal) { | |
| process.kill(process.pid, signal); | |
| } else { | |
| process.exit(code || 0); | |
| } | |
| }); | |
| // Handle errors | |
| child.on('error', (err) => { | |
| console.error(`ERROR: Failed to execute sqlx-ts binary: ${err.message}`); | |
| process.exit(1); | |
| }); | |
| // Deno-compatible launcher path | |
| if (typeof Deno !== 'undefined') { | |
| const isWindows = Deno.build.os === 'windows'; | |
| const binaryName = isWindows ? 'sqlx-ts.exe' : 'sqlx-ts'; | |
| // Resolve binary path relative to this script using import.meta.url | |
| const binaryUrl = new URL(`./${binaryName}`, import.meta.url); | |
| // On Windows, strip leading slash from pathname to get a proper filesystem path | |
| const binaryPath = isWindows ? binaryUrl.pathname.replace(/^\\//, '') : binaryUrl.pathname; | |
| async function main() { | |
| // Check if binary exists | |
| try { | |
| const info = Deno.statSync(binaryPath); | |
| if (!info.isFile) { | |
| console.error(`ERROR: sqlx-ts binary not found at ${binaryPath}`); | |
| console.error('Please ensure the package was installed correctly (postinstall script should have downloaded it).'); | |
| Deno.exit(1); | |
| } | |
| } catch (_err) { | |
| console.error(`ERROR: sqlx-ts binary not found at ${binaryPath}`); | |
| console.error('Please ensure the package was installed correctly (postinstall script should have downloaded it).'); | |
| Deno.exit(1); | |
| } | |
| const cmd = new Deno.Command(binaryPath, { | |
| args: Deno.args, | |
| stdin: 'inherit', | |
| stdout: 'inherit', | |
| stderr: 'inherit', | |
| }); | |
| const child = cmd.spawn(); | |
| const status = await child.status; | |
| if (status.signal !== null && status.signal !== undefined) { | |
| // Deno does not expose a direct equivalent of process.kill(process.pid, signal), | |
| // so approximate by exiting with non-zero status if signaled. | |
| Deno.exit(1); | |
| } | |
| Deno.exit(status.code ?? 0); | |
| } | |
| main().catch((err) => { | |
| console.error(`ERROR: Failed to execute sqlx-ts binary: ${err && err.message ? err.message : String(err)}`); | |
| Deno.exit(1); | |
| }); | |
| } | |
| // Node.js/CommonJS launcher path (original behavior) | |
| if (typeof Deno === 'undefined') { | |
| const { spawn } = require('child_process'); | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| // Determine the binary name based on platform | |
| const platform = process.platform; | |
| const binaryName = platform === 'win32' ? 'sqlx-ts.exe' : 'sqlx-ts'; | |
| const binaryPath = path.join(__dirname, binaryName); | |
| // Check if binary exists | |
| if (!fs.existsSync(binaryPath)) { | |
| console.error(`ERROR: sqlx-ts binary not found at ${binaryPath}`); | |
| console.error('Please ensure the package was installed correctly (postinstall script should have downloaded it).'); | |
| process.exit(1); | |
| } | |
| // Spawn the binary with all arguments passed through | |
| const child = spawn(binaryPath, process.argv.slice(2), { | |
| stdio: 'inherit', | |
| windowsHide: true | |
| }); | |
| // Handle exit | |
| child.on('exit', (code, signal) => { | |
| if (signal) { | |
| process.kill(process.pid, signal); | |
| } else { | |
| process.exit(code || 0); | |
| } | |
| }); | |
| // Handle errors | |
| child.on('error', (err) => { | |
| console.error(`ERROR: Failed to execute sqlx-ts binary: ${err.message}`); | |
| process.exit(1); | |
| }); | |
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “Verify CLI wrapper is JavaScript” step uses
shell: bashand thefileutility, but this job matrix includeswindows-latestwherefileis typically unavailable. Guard this check to non-Windows runners or replace it with a cross-platform check (e.g., using a small JS/TS script to assert the first bytes don’t match known binary magic numbers).