Skip to content

Commit dbc0913

Browse files
committed
chore: code cleanup
1 parent af4df1f commit dbc0913

File tree

26 files changed

+362
-500
lines changed

26 files changed

+362
-500
lines changed

.github/workflows/auto-publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
with:
2525
node-version: '18'
2626
registry-url: 'https://registry.npmjs.org'
27-
28-
- name: Setup Docker Buildx
29-
uses: docker/setup-buildx-action@v3
3027

3128
- name: Install dependencies
3229
run: npm install
@@ -60,7 +57,7 @@ jobs:
6057
6158
- name: Publish to npm
6259
if: steps.check-version.outputs.new-version == 'true'
63-
run: node scripts/publish-all.js
60+
run: npm publish --ws --iwr --tag latest --access public
6461
env:
6562
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6663

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ jobs:
1717
uses: actions/setup-node@v4
1818
with:
1919
node-version: '18'
20-
21-
- name: Setup Docker Buildx
22-
uses: docker/setup-buildx-action@v3
2320

2421
- name: Install dependencies
2522
run: npm install

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@ testem.log
145145
Thumbs.db
146146

147147
# Temporary files
148-
temp-sqld
148+
temp-sqld
149+
150+
package-lock.json

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
vlt-lock.json
2+
vlt.json
3+
contributing.md
4+
packages/
5+
scripts/
6+
.github/

CONTRIBUTING.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contributing
2+
3+
## How It Works
4+
5+
This project uses a simple platform-specific binary distribution approach:
6+
7+
1. **Platform Detection**: The package manager automatically installs only the compatible platform package based on your OS and architecture
8+
2. **Direct Binary Access**: Each platform package directly provides the `sqld` binary through its `bin` field
9+
3. **No Wrapper**: No JavaScript wrapper or bootstrap code - the platform packages directly expose the native `sqld` binary
10+
11+
### Automated Updates
12+
13+
The project automatically checks for new `libsql-server` releases daily using GitHub Actions:
14+
15+
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-)
16+
2. **Binary Extraction**: Downloads platform-specific tarballs and extracts the `sqld` binaries
17+
3. **Testing**: Verifies that all binaries work correctly
18+
4. **Publishing**: Automatically publishes new versions to npm
19+
5. **Git Commit**: Commits the updated binaries to the repository
20+
21+
The project uses the following release artifacts for each platform:
22+
- **macOS ARM64**: `libsql-server-aarch64-apple-darwin.tar.xz`
23+
- **macOS x64**: `libsql-server-x86_64-apple-darwin.tar.xz`
24+
- **Linux ARM64**: `libsql-server-aarch64-unknown-linux-gnu.tar.xz`
25+
- **Linux x64**: `libsql-server-x86_64-unknown-linux-gnu.tar.xz`
26+
27+
## Development
28+
29+
### Prerequisites
30+
31+
- Node.js 18+
32+
- `tar` command (available on macOS/Linux by default)
33+
- npm account with publishing permissions
34+
35+
### Scripts
36+
37+
```bash
38+
# Check for new versions
39+
npm run check-version
40+
41+
# Extract binaries from GitHub releases
42+
npm run extract-binaries
43+
44+
# Build everything (check + extract)
45+
npm run build
46+
47+
# Test all binaries
48+
npm run test
49+
```
50+
51+
### Versioning
52+
53+
Set the versions across all packages & update the root's dependency specs
54+
55+
```bash
56+
$ npm version --ws --iwr 0.24.1-pre.2
57+
```
58+
59+
> Note: `npm` will error because of the optional deps `"os"` & `"cpu"` definitions. You can safely ignore this error as the operation will still successfully update the `package.json
60+
61+
### Publishing
62+
63+
Setting a `--tag` may not be desired depending on if its a prerelease
64+
65+
```bash
66+
$ npm publish --ws --iwr --tag latest --access public
67+
```
68+
69+
### GitHub Actions
70+
71+
Two workflows are included:
72+
73+
1. **`auto-publish.yml`**: Runs daily and on pushes to main, automatically publishes new versions
74+
2. **`test.yml`**: Manual testing workflow that builds but doesn't publish
75+
76+
To set up automated publishing, add these secrets to your GitHub repository:
77+
78+
- `NPM_TOKEN`: Your npm authentication token with publish permissions

README.md

Lines changed: 14 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
A package wrapper for [libsql-server](https://github.com/tursodatabase/libsql) (`sqld`) with platform-specific binaries.
44

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.
66

77
## Installation
88

99
```bash
10+
# Locally install in a project
1011
vlt install sqld
1112
```
1213

14+
## Usage
15+
16+
```bash
17+
# Start sqld server
18+
vlx sqld --help
19+
20+
# Example: Start with a database file
21+
vlx sqld --db-path ./my-database.db
22+
```
23+
24+
### Binaries
25+
1326
The appropriate platform-specific binary will be automatically installed based on your system:
1427

1528
- `@sqld/darwin-arm64` - macOS ARM64 (Apple Silicon)
@@ -28,164 +41,10 @@ Windows is not directly supported as `libsql-server` does not provide native Win
2841

2942
The Linux ARM64 or x64 binary (depending on your system architecture) will be used within the WSL environment.
3043

31-
## Usage
32-
33-
### Command Line
34-
35-
After installation, you can use `sqld` directly from the command line:
36-
37-
```bash
38-
# Start sqld server
39-
vlx sqld --help
40-
41-
# Example: Start with a database file
42-
vlx sqld --db-path ./my-database.db
43-
```
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-
## How It Works
83-
84-
This project uses a multi-package approach:
85-
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`
92-
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.
94-
95-
## Automated Updates
96-
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
101-
3. **Testing**: Verifies that all binaries work correctly
102-
4. **Publishing**: Automatically publishes new versions to `npmjs.com`
103-
5. **Git Commit**: Commits the updated binaries to the repository
104-
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-
```
180-
18144
## License
18245

18346
MIT
18447

185-
## Contributing
186-
187-
Contributions are welcome! Please feel free to submit a Pull Request.
188-
18948
## Related Projects
19049

19150
- [libsql](https://github.com/tursodatabase/libsql) - The original libSQL project

bin/sqld

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)