-
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
base: main
Are you sure you want to change the base?
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,185 @@ | ||
| 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: Build docker-compose services for integration tests | ||
| run: docker compose -f docker-compose.yml up -d | ||
| env: | ||
| MYSQL_VERSION: 8 | ||
| PG_VERSION: 16 | ||
| MYSQL_MIGRATION_FILE: 'mysql_migration.sql' | ||
|
|
||
| - name: Wait for databases to be ready | ||
| uses: GuillaumeFalourd/wait-sleep-action@v1 | ||
| with: | ||
| time: '10' | ||
|
|
||
| - name: Check docker-compose services | ||
| run: docker ps -a | ||
|
|
||
| - 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: Add happy.ts test file | ||
| shell: bash | ||
| run: | | ||
| cat << 'EOF' > tests/staging/happy.ts | ||
| import { sql } from 'sqlx-ts' | ||
|
|
||
| const selectSql4 = sql` | ||
| SELECT items.* | ||
| FROM items; | ||
| ` | ||
| EOF | ||
|
|
||
| - name: Run happy test | ||
| working-directory: ./node | ||
| shell: bash | ||
| run: bun run cli.js --config=../.sqlxrc.sample.json ../tests/staging | ||
|
|
||
|
Comment on lines
+63
to
+79
|
||
| - 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: Setup Node.js (for npm install to download binary) | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Build docker-compose services for integration tests | ||
| run: docker compose -f docker-compose.yml up -d | ||
| env: | ||
| MYSQL_VERSION: 8 | ||
| PG_VERSION: 16 | ||
| MYSQL_MIGRATION_FILE: 'mysql_migration.sql' | ||
|
|
||
| - name: Wait for databases to be ready | ||
| uses: GuillaumeFalourd/wait-sleep-action@v1 | ||
| with: | ||
| time: '10' | ||
|
|
||
| - name: Check docker-compose services | ||
| run: docker ps -a | ||
|
|
||
| - name: Install dependencies (npm install via postinstall) | ||
| working-directory: ./node | ||
| run: bun install | ||
|
|
||
|
Comment on lines
+136
to
+137
|
||
| - 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 | ||
|
Comment on lines
+136
to
+143
|
||
| run: bun run cli.js --help | ||
|
|
||
| - name: Add happy.ts test file | ||
| shell: bash | ||
| run: | | ||
| cat << 'EOF' > tests/staging/happy.ts | ||
| import { sql } from 'sqlx-ts' | ||
|
|
||
| const selectSql4 = sql` | ||
| SELECT items.* | ||
| FROM items; | ||
| ` | ||
| EOF | ||
|
|
||
| - name: Run happy test | ||
| working-directory: ./node | ||
| shell: bash | ||
|
Comment on lines
+145
to
+160
|
||
| run: deno run --allow-read --allow-run cli.js --config=../.sqlxrc.sample.json ../tests/staging | ||
|
|
||
| - name: Install dependencies and download binary | ||
| working-directory: ./node | ||
| run: npm install | ||
|
|
||
| - name: Test CLI wrapper with Deno (--version) | ||
| working-directory: ./node | ||
| 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 | ||
|
|
||
| - 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 | ||
| 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.
This workflow runs
docker compose ...on macOS and Windows too. Elsewhere in this repo (e.g.,.github/workflows/compatibility.yaml:74-90) docker-compose steps are gated torunner.os == 'Linux'. Consider applying the same gating here or restricting the OS matrix, otherwise non-Linux runners may fail if Docker isn’t available.