Skip to content

Commit 6f752a6

Browse files
committed
refactor: monorepo - standalone sync-engine lib
Refactors the repo to a monorepo and publishes @supabase/stripe-sync-engine as individual package. For the docker image, there are no breaking changes. The standalone package supports both ESM and CJS and can be used in any JavaScript based server environment, including Supabase Edge Functions, Node/Deno servers.
1 parent 96423fc commit 6f752a6

File tree

158 files changed

+1179
-1019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+1179
-1019
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- uses: actions/checkout@v4
27-
27+
2828
- name: Install pnpm
2929
uses: pnpm/action-setup@v4
3030

@@ -36,14 +36,14 @@ jobs:
3636

3737
- name: Set up .env file
3838
run: |
39-
touch .env
40-
echo DATABASE_URL='postgres://postgres:postgres@localhost:55432/postgres?sslmode=disable&search_path=stripe' >> .env
41-
echo NODE_ENV=dev >> .env
42-
echo STRIPE_SECRET_KEY=sk_test_ >> .env
43-
echo STRIPE_WEBHOOK_SECRET=whsec_ >> .env
44-
echo SCHEMA=stripe >> .env
45-
echo PORT=8080 >> .env
46-
echo API_KEY=api_key_test >> .env
39+
touch packages/fastify-app/.env
40+
echo DATABASE_URL='postgres://postgres:postgres@localhost:55432/postgres?sslmode=disable&search_path=stripe' >> packages/fastify-app/.env
41+
echo NODE_ENV=dev >> packages/fastify-app/.env
42+
echo STRIPE_SECRET_KEY=sk_test_ >> packages/fastify-app/.env
43+
echo STRIPE_WEBHOOK_SECRET=whsec_ >> packages/fastify-app/.env
44+
echo SCHEMA=stripe >> packages/fastify-app/.env
45+
echo PORT=8080 >> packages/fastify-app/.env
46+
echo API_KEY=api_key_test >> packages/fastify-app/.env
4747
4848
- name: Install dependencies
4949
run: |
@@ -59,8 +59,7 @@ jobs:
5959
6060
- name: Builds successfully
6161
run: |
62-
pnpm typecheck
63-
62+
pnpm build
6463
6564
- name: Initialize DB schema
6665
run: |

.github/workflows/release.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ on:
88

99
jobs:
1010
release:
11-
name: Release / Node ${{ matrix.node }}
12-
strategy:
13-
matrix:
14-
node:
15-
- '22'
11+
name: Release
1612

1713
runs-on: ubuntu-24.04
1814

@@ -23,10 +19,14 @@ jobs:
2319
steps:
2420
- uses: actions/checkout@v4
2521

22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v4
24+
2625
- name: Set up Node
2726
uses: actions/setup-node@v4
2827
with:
29-
node-version: ${{ matrix.node }}
28+
node-version-file: ./.nvmrc
29+
cache: pnpm
3030

3131
- run: |
3232
pnpm install --frozen-lockfile
@@ -68,9 +68,33 @@ jobs:
6868
id: docker_build
6969
uses: docker/build-push-action@v6
7070
with:
71+
context: packages/fastify-app
7172
push: true
7273
tags: supabase/stripe-sync-engine:latest,supabase/stripe-sync-engine:v${{ needs.release.outputs.new-release-version }}
7374
platforms: linux/amd64,linux/arm64
7475

7576
- name: Image digest
7677
run: echo ${{ steps.docker_build.outputs.digest }}
78+
79+
npm:
80+
name: Release on NPM
81+
82+
needs:
83+
- release
84+
85+
if: needs.release.outputs.new-release-published == 'true'
86+
87+
runs-on: ubuntu-24.04
88+
89+
steps:
90+
- name: Set new version in sync-engine
91+
run: |
92+
cd packages/sync-engine
93+
pnpm version ${{ needs.release.outputs.new-release-version }} --no-git-tag-version
94+
95+
- name: Publish sync-engine to npm
96+
run: |
97+
cd packages/sync-engine
98+
npm publish --access public
99+
env:
100+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dist/
33
node_modules/
44
.env
55
.env.*
6-
db/migrations/0000_schema.sql
6+
!.env.sample

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
node_modules
44
pnpm-lock.yaml
55
docker*
6-
Pulumi.*.yaml
6+
Pulumi.*.yaml
7+
LICENSE.md

.vscode/settings.json

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

RELEASE.md

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

docker/compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ services:
88
- 55432:5432
99
environment:
1010
POSTGRES_PASSWORD: postgres
11-
volumes:
12-
- ./db/migrations/schema.sql:/docker-entrypoint-initdb.d/0000_schema.sql

docker/db/migrations/schema.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@ export default [
2020
ecmaVersion: 2022,
2121
sourceType: 'module',
2222
},
23+
rules: {
24+
'@typescript-eslint/ban-ts-comment': 'off',
25+
},
2326
},
2427
]

package.json

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,31 @@
11
{
22
"name": "stripe-sync-engine",
3-
"version": "0.0.0",
4-
"description": "Stripe sync engine. Sync your Stripe account to your Postgres database.",
5-
"main": "index.js",
3+
"private": true,
4+
"version": "1.0.0",
5+
"workspaces": [
6+
"packages/*"
7+
],
68
"scripts": {
7-
"dev": "tsx --watch ./src/server.ts",
8-
"build": "tsc -p tsconfig.json",
9-
"typecheck": "tsc -p tsconfig.json --noEmit",
10-
"start": "NODE_ENV=production node dist/server.js",
11-
"test": "vitest",
12-
"lint": "eslint 'src/**'",
13-
"format:check": "prettier -c src/**",
14-
"format": "prettier --write src/**",
15-
"prod:secrets:fetch": "AWS_PROFILE=supabase node internals/getSecrets.js prod",
16-
"staging:secrets:fetch": "node internals/getSecrets.js staging"
17-
},
18-
"author": "Supabase",
19-
"license": "MIT",
20-
"engines": {
21-
"node": ">= 22.0.0"
22-
},
23-
"dependencies": {
24-
"@fastify/autoload": "^6.3.0",
25-
"@fastify/swagger": "^9.5.1",
26-
"@fastify/swagger-ui": "^5.2.2",
27-
"dotenv": "^16.5.0",
28-
"fastify": "^5.3.3",
29-
"p-limit": "^3.1.0",
30-
"pg": "^8.16.0",
31-
"pg-node-migrations": "0.0.8",
32-
"pino": "^9.7.0",
33-
"stripe": "^18.2.0",
34-
"yesql": "^7.0.0"
9+
"build": "pnpm -r run build",
10+
"test": "pnpm -r run test",
11+
"typecheck": "pnpm -r run typecheck",
12+
"lint": "pnpm -r run lint",
13+
"format": "prettier --write .",
14+
"format:check": "prettier --check ."
3515
},
3616
"devDependencies": {
3717
"@eslint/eslintrc": "^3.3.1",
3818
"@eslint/js": "^9.28.0",
39-
"@types/node": "^22.15.29",
40-
"@types/pg": "^8.15.2",
41-
"@types/yesql": "^4.1.4",
4219
"@typescript-eslint/eslint-plugin": "^8.33.0",
4320
"@typescript-eslint/parser": "^8.33.0",
4421
"eslint": "^9.28.0",
4522
"eslint-config-prettier": "^10.1.5",
4623
"eslint-plugin-prettier": "^5.4.1",
24+
"pino": "^9.7.0",
4725
"prettier": "^3.5.3",
48-
"tsx": "^4.19.4",
26+
"rimraf": "^6.0.1",
4927
"typescript": "^5.8.3",
50-
"vitest": "^3.1.4"
28+
"vite": "^6.3.5"
5129
},
5230
"packageManager": "[email protected]"
5331
}

0 commit comments

Comments
 (0)