Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["powersync-example"]
}
6 changes: 6 additions & 0 deletions .changeset/serious-bobcats-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@journeyapps/powersync-sdk-react-native': patch
'@journeyapps/powersync-sdk-common': patch
---

Updated watched queries to trigger for local only tables.
38 changes: 5 additions & 33 deletions .github/workflows/build-packages.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Packages Deploy
# Ensures packages build correctly
name: Build Packages

on:
push:
Expand All @@ -8,42 +9,16 @@ jobs:
name: Build Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'yarn'

- name: Setup Yarn
run: |
npm install -g yarn
echo "Yarn version: $(yarn -v)"
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build:packages

publish:
name: Publish Production Packages
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
persist-credentials: false

- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: 18
cache: 'yarn'

- name: Setup Yarn
run: |
Expand All @@ -56,6 +31,3 @@ jobs:

- name: Build
run: yarn build:packages

- name: Publish
run: lerna exec "npm publish --tag=latest --no-git-checks" --parallel
5 changes: 4 additions & 1 deletion .github/workflows/dev-packages.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Action to publish packages under the `next` tag for testing
# Packages are versioned as `0.0.0-dev.{short-sha}`
name: Packages Deploy

on: workflow_dispatch
Expand All @@ -7,9 +9,10 @@ jobs:
name: Publish Dev Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
persist-credentials: false

- name: Setup NodeJS
uses: actions/setup-node@v2
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
# Needed for build with frozen lockfile
submodules: true

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Monorepo for all things React Native and PowerSync.

## Monorepo structure
## Monorepo Structure

- `apps/supabase-todolist`
* An Expo React native app using Supabase.
Expand All @@ -18,7 +18,7 @@ Monorepo for all things React Native and PowerSync.

# Development

## Git submodules
## Git Submodules
After cloning this repo be sure to init the Git submodules

```bash
Expand All @@ -37,6 +37,26 @@ Build packages
yarn build:packages
```


## Versioning


### Development Packages
Development packages can be published by manually triggering the `dev-packages` workflow. Development packages are versioned as `0.0.0-dev.{short-sha}`.

### Production Packages
Pull requests should contain Changesets for changed packages.

Add changesets with
```Bash
yarn changeset add
```

Submodule production packages should be versioned, tagged and published from their own repository. Any dependencies should be updated here (if applicable) before merging pull requests.


Merging a PR with Changesets will automatically create a PR with version bumps. That PR will be merged when releasing.

## Testing Supabase example app

``` bash
Expand Down
2 changes: 1 addition & 1 deletion apps/supabase-todolist
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"clean:packages": "lerna run clean",
"build:packages": "lerna run build",
"watch:packages": "yarn workspace @journeyapps/powersync-sdk-react-native watch"
"watch:packages": "yarn workspace @journeyapps/powersync-sdk-react-native watch",
"release": "yarn build:packages && yarn changeset publish"
},
"workspaces": {
"packages": [
Expand All @@ -23,6 +24,7 @@
},
"dependencies": {},
"devDependencies": {
"@changesets/cli": "^2.26.2",
"lerna": "7.3.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ export interface WatchOnChangeEvent {
changedTables: string[];
}

export interface PowerSyncDBListener extends StreamingSyncImplementationListener {}

const POWERSYNC_TABLE_MATCH = /(^ps_data__|^ps_data_local__)/;

export const DEFAULT_WATCH_THROTTLE_MS = 30;

export const DEFAULT_POWERSYNC_DB_OPTIONS = {
retryDelay: 5000,
logger: Logger.get('PowerSyncDatabase')
};

export interface PowerSyncDBListener extends StreamingSyncImplementationListener {}

export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDBListener> {
/**
* Transactions should be queued in the DBAdapter, but we also want to prevent
Expand Down Expand Up @@ -437,10 +439,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
const dispose = this.database.registerListener({
tablesUpdated: async (update) => {
const { table } = update;
if (!table.startsWith('ps_data__')) {
if (!table.match(POWERSYNC_TABLE_MATCH)) {
return;
}
const tableName = table.replace(/^ps_data__/, '');
const tableName = table.replace(POWERSYNC_TABLE_MATCH, '');
throttledTableUpdates.push(tableName);

flushTableUpdates();
Expand Down
8 changes: 6 additions & 2 deletions packages/powersync-sdk-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"homepage": "https://github.com/journeyapps/powersync-react-native-sdk/packages/powersync-sdk-react-native/#readme",
"peerDependencies": {
"@journeyapps/react-native-quick-sqlite": "^0.0.0",
"@journeyapps/react-native-quick-sqlite": "^0.0.1-alpha.0",
"base-64": "^1.0.0",
"react": "*",
"react-native-fetch-api": "^3.0.0",
Expand All @@ -45,6 +45,10 @@
"typescript": "^4.1.3"
},
"keywords": [
"data sync", "offline-first", "sqlite", "real-time data stream", "live data"
"data sync",
"offline-first",
"sqlite",
"real-time data stream",
"live data"
]
}
Loading