|
2 | 2 |
|
3 | 3 | A package wrapper for [libsql-server](https://github.com/tursodatabase/libsql) (`sqld`) with platform-specific binaries.
|
4 | 4 |
|
5 |
| -This package automatically downloads and publishes the latest `libsql-server` releases from the official Docker container, making them available as npm packages with platform-specific binaries. |
| 5 | +This package automatically downloads and publishes the latest `libsql-server` releases from the [official GitHub releases](https://github.com/tursodatabase/libsql/releases?q=libsql-server-), making them available as npm packages with platform-specific binaries. |
6 | 6 |
|
7 | 7 | ## Installation
|
8 | 8 |
|
@@ -42,150 +42,34 @@ vlx sqld --help
|
42 | 42 | vlx sqld --db-path ./my-database.db
|
43 | 43 | ```
|
44 | 44 |
|
45 |
| -### Programmatic API |
46 |
| - |
47 |
| -```javascript |
48 |
| -const sqld = require('sqld'); |
49 |
| - |
50 |
| -// Execute sqld synchronously |
51 |
| -try { |
52 |
| - const result = sqld.execSync(['--help']); |
53 |
| - console.log(result.toString()); |
54 |
| -} catch (error) { |
55 |
| - console.error('Error:', error.message); |
56 |
| -} |
57 |
| - |
58 |
| -// Execute sqld asynchronously |
59 |
| -const child = sqld.exec(['--db-path', './my-database.db']); |
60 |
| - |
61 |
| -child.stdout.on('data', (data) => { |
62 |
| - console.log('stdout:', data.toString()); |
63 |
| -}); |
64 |
| - |
65 |
| -child.stderr.on('data', (data) => { |
66 |
| - console.error('stderr:', data.toString()); |
67 |
| -}); |
68 |
| - |
69 |
| -child.on('exit', (code) => { |
70 |
| - console.log('Process exited with code:', code); |
71 |
| -}); |
72 |
| - |
73 |
| -// Get the binary path |
74 |
| -const binaryPath = sqld.getBinaryPath(); |
75 |
| -console.log('Binary located at:', binaryPath); |
76 |
| - |
77 |
| -// Get the platform package name |
78 |
| -const platformPackage = sqld.getPlatformPackage(); |
79 |
| -console.log('Using platform package:', platformPackage); |
80 |
| -``` |
81 |
| - |
82 | 45 | ## How It Works
|
83 | 46 |
|
84 |
| -This project uses a multi-package approach: |
| 47 | +This project uses a simple platform-specific binary distribution approach: |
85 | 48 |
|
86 |
| -1. **Main Package (`sqld`)**: Contains the Node.js wrapper and CLI interface |
87 |
| -2. **Platform Packages**: Contains the actual binaries for each platform: |
88 |
| - - `@sqld/darwin-arm64` |
89 |
| - - `@sqld/darwin-x64` |
90 |
| - - `@sqld/linux-arm64` |
91 |
| - - `@sqld/linux-x64` |
| 49 | +1. **Platform Detection**: The package manager automatically installs only the compatible platform package based on your OS and architecture |
| 50 | +2. **Direct Binary Access**: Each platform package directly provides the `sqld` binary through its `bin` field |
| 51 | +3. **No Wrapper**: No JavaScript wrapper or bootstrap code - the platform packages directly expose the native `sqld` binary |
92 | 52 |
|
93 |
| -The main package declares the platform packages as optional dependencies. When you install `sqld`, your package manager will only install the package that matches your current platform. |
| 53 | +### Automated Updates |
94 | 54 |
|
95 |
| -## Automated Updates |
| 55 | +The project automatically checks for new `libsql-server` releases daily using GitHub Actions: |
96 | 56 |
|
97 |
| -This project automatically checks for new `libsql-server` releases daily using GitHub Actions: |
98 |
| - |
99 |
| -1. **Daily Check**: Runs at 9 AM UTC to check for new releases |
100 |
| -2. **Binary Extraction**: Downloads the Docker container and extracts platform-specific binaries |
| 57 | +1. **Daily Check**: Runs at 9 AM UTC to check for new releases from the [libsql GitHub repository](https://github.com/tursodatabase/libsql/releases?q=libsql-server-) |
| 58 | +2. **Binary Extraction**: Downloads platform-specific tarballs and extracts the `sqld` binaries |
101 | 59 | 3. **Testing**: Verifies that all binaries work correctly
|
102 |
| -4. **Publishing**: Automatically publishes new versions to `npmjs.com` |
| 60 | +4. **Publishing**: Automatically publishes new versions to npm |
103 | 61 | 5. **Git Commit**: Commits the updated binaries to the repository
|
104 | 62 |
|
105 |
| -## Development |
106 |
| - |
107 |
| -### Prerequisites |
108 |
| - |
109 |
| -- Node.js 18+ |
110 |
| -- `vlt` (`npm i -g vlt`) |
111 |
| - |
112 |
| -### Scripts |
113 |
| - |
114 |
| -```bash |
115 |
| -# Check for new versions |
116 |
| -vlr check-version |
117 |
| - |
118 |
| -# Extract binaries from Docker containers |
119 |
| -vlr extract-binaries |
120 |
| - |
121 |
| -# Build everything (check + extract) |
122 |
| -vlr build |
123 |
| - |
124 |
| -# Test all binaries |
125 |
| -clr test |
126 |
| - |
127 |
| -# Publish all packages to npm |
128 |
| -vlr publish-all |
129 |
| -``` |
130 |
| - |
131 |
| -### Manual Testing |
132 |
| - |
133 |
| -You can test the build process manually: |
134 |
| - |
135 |
| -```bash |
136 |
| -# Install dependencies |
137 |
| -vlt install |
138 |
| - |
139 |
| -# Extract the latest binaries |
140 |
| -vlr extract-binaries |
141 |
| - |
142 |
| -# Test that everything works |
143 |
| -vlr test |
144 |
| - |
145 |
| -# Test the CLI |
146 |
| -./bin/sqld --help |
147 |
| -``` |
148 |
| - |
149 |
| -### GitHub Actions |
150 |
| - |
151 |
| -Two workflows are included: |
152 |
| - |
153 |
| -1. **`auto-publish.yml`**: Runs daily and on pushes to main, automatically publishes new versions |
154 |
| -2. **`test.yml`**: Manual testing workflow that builds but doesn't publish |
155 |
| - |
156 |
| -To set up automated publishing, add these secrets to your GitHub repository: |
157 |
| - |
158 |
| -- `NPM_TOKEN`: Your npm authentication token with publish permissions |
159 |
| - |
160 |
| -## Project Structure |
161 |
| - |
162 |
| -``` |
163 |
| -sqld/ |
164 |
| -├── package.json # Main package configuration |
165 |
| -├── lib/index.js # Node.js API |
166 |
| -├── bin/sqld # CLI wrapper |
167 |
| -├── scripts/ |
168 |
| -│ ├── check-version.js # Check for new releases |
169 |
| -│ ├── extract-binaries.js # Extract binaries from Docker |
170 |
| -│ ├── build.js # Build orchestration |
171 |
| -│ ├── publish-all.js # Publish all packages |
172 |
| -│ └── test.js # Test all binaries |
173 |
| -├── packages/ |
174 |
| -│ ├── darwin-arm64/ # macOS ARM64 package |
175 |
| -│ ├── darwin-x64/ # macOS x64 package |
176 |
| -│ ├── linux-arm64/ # Linux ARM64 package |
177 |
| -│ └── linux-x64/ # Linux x64 package |
178 |
| -└── .github/workflows/ # GitHub Actions |
179 |
| -``` |
| 63 | +The project uses the following release artifacts for each platform: |
| 64 | +- **macOS ARM64**: `libsql-server-aarch64-apple-darwin.tar.xz` |
| 65 | +- **macOS x64**: `libsql-server-x86_64-apple-darwin.tar.xz` |
| 66 | +- **Linux ARM64**: `libsql-server-aarch64-unknown-linux-gnu.tar.xz` |
| 67 | +- **Linux x64**: `libsql-server-x86_64-unknown-linux-gnu.tar.xz` |
180 | 68 |
|
181 | 69 | ## License
|
182 | 70 |
|
183 | 71 | MIT
|
184 | 72 |
|
185 |
| -## Contributing |
186 |
| - |
187 |
| -Contributions are welcome! Please feel free to submit a Pull Request. |
188 |
| - |
189 | 73 | ## Related Projects
|
190 | 74 |
|
191 | 75 | - [libsql](https://github.com/tursodatabase/libsql) - The original libSQL project
|
|
0 commit comments