Skip to content

Commit a54afd6

Browse files
authored
Merge pull request #1 from powersync-ja/initial-fork
feat: Initial fork and patching of sql.js
2 parents f3b1ebc + 941de22 commit a54afd6

File tree

14 files changed

+1398
-0
lines changed

14 files changed

+1398
-0
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/angry-days-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@powersync/sql-js": patch
3+
---
4+
5+
Initial release of sql.js fork with PowerSync.

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/build-package.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Ensures package builds correctly
2+
name: Build Package
3+
4+
on:
5+
push:
6+
7+
jobs:
8+
build:
9+
name: Build Packages
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
persist-credentials: false
15+
16+
- name: Setup NodeJS
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: ".nvmrc"
20+
21+
- uses: pnpm/action-setup@v2
22+
name: Install pnpm
23+
with:
24+
version: 9
25+
run_install: false
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
31+
32+
- uses: actions/cache@v3
33+
name: Setup pnpm cache
34+
with:
35+
path: ${{ env.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
39+
40+
- name: Install dependencies
41+
run: pnpm install
42+
43+
- name: Install sha3sum
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y libdigest-sha3-perl
47+
48+
- name: Setup Emscripten
49+
uses: mymindstorm/setup-emsdk@v14
50+
with:
51+
version: "latest"
52+
actions-cache-folder: "emsdk-cache"
53+
54+
- name: Build
55+
run: pnpm build

.github/workflows/dev-packages.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Action to publish packages under the `next` tag for testing
2+
# Packages are versioned as `0.0.0-{tag}-DATETIMESTAMP`
3+
name: Create Dev Release
4+
5+
on: workflow_dispatch
6+
7+
jobs:
8+
publish:
9+
name: Publish Dev Packages
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
persist-credentials: false
15+
- name: Setup NodeJS
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version-file: ".nvmrc"
19+
- uses: pnpm/action-setup@v2
20+
name: Install pnpm
21+
with:
22+
version: 9
23+
run_install: false
24+
- name: Add NPM auth
25+
run: echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc
26+
- name: Get pnpm store directory
27+
shell: bash
28+
run: |
29+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
30+
- uses: actions/cache@v3
31+
name: Setup pnpm cache
32+
with:
33+
path: ${{ env.STORE_PATH }}
34+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
35+
restore-keys: |
36+
${{ runner.os }}-pnpm-store-
37+
- name: Install dependencies
38+
run: pnpm install
39+
40+
- name: Install sha3sum
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y libdigest-sha3-perl
44+
45+
- name: Setup Emscripten
46+
uses: mymindstorm/setup-emsdk@v14
47+
with:
48+
version: "latest"
49+
actions-cache-folder: "emsdk-cache"
50+
51+
- name: Build
52+
run: pnpm build
53+
54+
- name: Publish
55+
run: |
56+
pnpm changeset version --no-git-tag --snapshot dev
57+
pnpm changeset publish --tag dev

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@v4
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: ".nvmrc"
21+
- uses: pnpm/action-setup@v2
22+
name: Install pnpm
23+
with:
24+
# Pnpm 9.4 introduces this https://github.com/pnpm/pnpm/pull/7633
25+
# which causes workspace:^1.2.0 to be converted to 1.2.0^1.2.0
26+
version: 9.3
27+
run_install: false
28+
- name: Get pnpm store directory
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
- uses: actions/cache@v3
33+
name: Setup pnpm cache
34+
with:
35+
path: ${{ env.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
39+
- name: Install dependencies
40+
run: pnpm install
41+
42+
- name: Install sha3sum
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y libdigest-sha3-perl
46+
47+
- name: Setup Emscripten
48+
uses: mymindstorm/setup-emsdk@v14
49+
with:
50+
version: "latest"
51+
actions-cache-folder: "emsdk-cache"
52+
53+
- name: Create Release Pull Request or Publish to npm
54+
id: changesets
55+
uses: changesets/action@v1
56+
with:
57+
# Update the monorepo lockfile after versioning
58+
version: pnpm changeset:version
59+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
60+
publish: pnpm release
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sql.js
2+
dist
3+
.vscode
4+
.DS_STORE
5+
.idea
6+
.fleet
7+
node_modules
8+
*.tmp

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.9.0

LICENSE

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# MIT license
2+
3+
Copyright (c) 2017 sql.js authors (see AUTHORS)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
# Some portions of the Makefile taken from:
24+
25+
Copyright 2017 Ryusei Yamaguchi
26+
27+
Permission is hereby granted, free of charge, to any person obtaining a copy of
28+
this software and associated documentation files (the "Software"), to deal in
29+
the Software without restriction, including without limitation the rights to
30+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
31+
the Software, and to permit persons to whom the Software is furnished to do so,
32+
subject to the following conditions:
33+
34+
The above copyright notice and this permission notice shall be included in all
35+
copies or substantial portions of the Software.
36+
37+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
39+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
40+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

build.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
set -e
3+
4+
SQLITE_VERSION="2.7.6"
5+
POWERSYNC_CORE_VERSION="0.4.2"
6+
SQLITE_PATH="sql.js"
7+
8+
if [ -d "$SQLITE_PATH" ]; then
9+
echo "Deleting existing clone"
10+
rm -rf $SQLITE_PATH
11+
fi
12+
13+
git clone --filter=blob:none https://github.com/sql-js/sql.js.git $SQLITE_PATH
14+
cd $SQLITE_PATH
15+
16+
# Main version as of 2024-10-01
17+
git checkout 52e5649
18+
19+
git apply ../patches/*
20+
mkdir -p powersync-libs
21+
curl -L -o powersync-libs/libpowersync-wasm.a "https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v${POWERSYNC_CORE_VERSION}/libpowersync-wasm.a"
22+
23+
make
24+
25+
cd ../
26+
mkdir -p dist
27+
cp -r $SQLITE_PATH/dist/* dist/

0 commit comments

Comments
 (0)