Skip to content

Commit 42a661e

Browse files
Isolated Demo Tests (#234)
1 parent 32e342a commit 42a661e

File tree

27 files changed

+1456
-74
lines changed

27 files changed

+1456
-74
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Ensures packages and demos test correctly
2+
name: Test Isolated Demos
3+
4+
on:
5+
push:
6+
7+
jobs:
8+
test:
9+
name: Test Isolated Demos
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+
# 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+
29+
- name: Get pnpm store directory
30+
shell: bash
31+
run: |
32+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
33+
34+
- uses: actions/cache@v3
35+
name: Setup pnpm cache
36+
with:
37+
path: ${{ env.STORE_PATH }}
38+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
39+
restore-keys: |
40+
${{ runner.os }}-pnpm-store-
41+
42+
- name: Install
43+
run: pnpm install
44+
45+
- name: Build Packages
46+
run: pnpm build:packages
47+
48+
- name: Start Verdaccio
49+
run: |
50+
npm install -g verdaccio
51+
nohup verdaccio -c verdaccio-config.yaml &
52+
sleep 10 # Give Verdaccio some time to start
53+
54+
- name: Prepare For Test Publish
55+
run: npx tsx scripts/test-publish-helper.ts
56+
57+
- name: Registry login
58+
run: npx npm-cli-login -u test -p test -e [email protected] -r http://localhost:4873
59+
60+
- name: Config Temporary Registry
61+
run: echo "@powersync:registry=http://localhost:4873" >> ~/.npmrc
62+
63+
# No actual auth is ever supplied to this action.
64+
# It should never be able to publish to NPMJS
65+
- name: Test publish
66+
run: pnpm -r publish --no-git-checks
67+
68+
- name: Test Demos
69+
run: npx tsx scripts/isolated-demo-test.ts
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# See the local demo at https://github.com/powersync-ja/self-host-demo/tree/main/demos/supabase
2+
WEBPACK_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
3+
WEBPACK_PUBLIC_SUPABASE_ANON_KEY=
4+
WEBPACK_PUBLIC_POWERSYNC_URL=http://localhost:8080

demos/angular-supabase-todolist/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,3 @@ testem.log
166166
# System files
167167
.DS_Store
168168
Thumbs.db
169-
170-
environment.ts

demos/angular-supabase-todolist/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ A step-by-step guide on Supabase<>PowerSync integration is available [here](http
1313
## Quick Start
1414

1515
1. Run `pnpm install`
16-
2. Run `pnpm watch` to build application and check for code changes
17-
3. In a new terminal run `pnpm start` to start the server
18-
4. Go to <http://localhost:8080>
16+
2. Create a `.env` file by copying the template `cp .env.template .env`
17+
3. Populate the `.env` file with PowerSync and Supabase details
18+
4. Run `pnpm watch` to build application and check for code changes
19+
5. In a new terminal run `pnpm start` to start the server
20+
6. Go to <http://localhost:8080>
1921

2022
**Note:** The Angular development server (`pnpm serve`) doesn't support service worker applications
2123

demos/angular-supabase-todolist/extra-webpack.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const webpack = require('webpack');
22
const pkg = require('./package.json');
3-
const { inspect } = require('util');
43
const path = require('path');
54

5+
const dotenv = require('dotenv');
6+
7+
dotenv.config();
8+
69
module.exports = (config, options, targetOptions) => {
710
delete config.optimization;
811
return {
@@ -11,7 +14,15 @@ module.exports = (config, options, targetOptions) => {
1114
rules: config.module.rules
1215
},
1316
resolve: config.resolve,
14-
plugins: config.plugins,
17+
plugins: [
18+
...config.plugins,
19+
new webpack.DefinePlugin({
20+
// Embed environment variables starting with `WEBPACK_PUBLIC_`
21+
'process.env': JSON.stringify(
22+
Object.fromEntries(Object.entries(process.env).filter(([key]) => key.startsWith('WEBPACK_PUBLIC_')))
23+
)
24+
})
25+
],
1526
output: {
1627
filename: config.filename,
1728
path: config.path,

demos/angular-supabase-todolist/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"start": "http-server -p 8080 -c-1 dist/",
88
"build": "ng build",
99
"format": "prettier --write .",
10+
"test:build": "pnpm build",
1011
"watch": "ng build --watch --configuration development"
1112
},
1213
"private": true,
@@ -20,8 +21,8 @@
2021
"@angular/platform-browser-dynamic": "^18.1.1",
2122
"@angular/router": "^18.1.1",
2223
"@angular/service-worker": "^18.1.1",
23-
"@powersync/web": "workspace:*",
2424
"@journeyapps/wa-sqlite": "^0.2.0",
25+
"@powersync/web": "workspace:*",
2526
"@supabase/supabase-js": "^2.44.4",
2627
"rxjs": "~7.8.1",
2728
"tslib": "^2.6.3",
@@ -32,6 +33,7 @@
3233
"@angular-devkit/build-angular": "^18.1.1",
3334
"@angular/cli": "^18.1.1",
3435
"@angular/compiler-cli": "^18.1.1",
36+
"dotenv": "^16.4.5",
3537
"http-server": "^14.1.1",
3638
"typescript": "~5.5.3"
3739
}

demos/angular-supabase-todolist/src/app/supabase.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
type SupabaseClient,
88
type User
99
} from '@supabase/supabase-js';
10-
import { environment } from '../../environment';
10+
import { environment } from '../environment';
1111
import { type AbstractPowerSyncDatabase, type CrudEntry, UpdateType, PowerSyncBackendConnector } from '@powersync/web';
1212

1313
/// Postgres Response codes that we cannot recover from by retrying.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare namespace NodeJS {
2+
// These are injected in the Webpack config
3+
interface ProcessEnv {
4+
WEBPACK_PUBLIC_SUPABASE_URL: string;
5+
WEBPACK_PUBLIC_SUPABASE_ANON_KEY: string;
6+
WEBPACK_PUBLIC_POWERSYNC_URL: string;
7+
}
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const environment = {
2+
supabaseUrl: process.env.WEBPACK_PUBLIC_SUPABASE_URL,
3+
supabaseKey: process.env.WEBPACK_PUBLIC_SUPABASE_ANON_KEY,
4+
powersyncUrl: process.env.WEBPACK_PUBLIC_POWERSYNC_URL
5+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Replace the credentials below with your Supabase, PowerSync and Expo project details.
2+
EXPO_PUBLIC_DJANGO_URL=http://localhost:6061
3+
EXPO_PUBLIC_POWERSYNC_URL=http://localhost:8080

0 commit comments

Comments
 (0)