Skip to content

Commit 0c7363b

Browse files
committed
feat: initial implementation (still WIP)
0 parents  commit 0c7363b

File tree

129 files changed

+23587
-0
lines changed

Some content is hidden

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

129 files changed

+23587
-0
lines changed

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-24.04
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: "22"
18+
- name: Enable Corepack
19+
run: corepack enable
20+
- name: Setup pnpm
21+
run: corepack prepare pnpm@latest --activate
22+
- name: Get pnpm store directory
23+
shell: bash
24+
run: |
25+
echo "STORE_PATH=$(pnpm store path | tr -d '\n')" >> $GITHUB_ENV
26+
- name: Setup pnpm cache
27+
uses: actions/cache@v3
28+
with:
29+
path: ${{ env.STORE_PATH }}
30+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
31+
restore-keys: |
32+
${{ runner.os }}-pnpm-store-
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
- name: Run tests
36+
run: |
37+
cd apps/server
38+
pnpm test

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# prod
2+
dist/
3+
4+
# dev
5+
.yarn/
6+
!.yarn/releases
7+
.vscode/*
8+
!.vscode/launch.json
9+
!.vscode/*.code-snippets
10+
.idea/workspace.xml
11+
.idea/usage.statistics.xml
12+
.idea/shelf
13+
14+
# deps
15+
node_modules/
16+
.wrangler
17+
18+
# env
19+
.env
20+
.env.production
21+
.dev.vars
22+
23+
# logs
24+
logs/
25+
*.log
26+
npm-debug.log*
27+
yarn-debug.log*
28+
yarn-error.log*
29+
pnpm-debug.log*
30+
lerna-debug.log*
31+
32+
# misc
33+
.DS_Store
34+
35+
_old/

.zed/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"code_actions_on_format": {
3+
"source.fixAll.biome": true,
4+
"source.organizeImports.biome": true,
5+
"source.removeUnusedImports.ts": true
6+
},
7+
"formatter": {
8+
"language_server": {
9+
"name": "biome"
10+
}
11+
}
12+
}

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# CodePush on Cloudflare Workers
2+
3+
A community-driven port of Microsoft's CodePush Standalone, designed for cost-effective and scalable over-the-air updates using Cloudflare Workers.
4+
5+
**Status: Alpha** - Core functionality is **100% compatible** with the official CodePush, but further testing and improvements are ongoing.
6+
7+
**Important Note:** This project is not affiliated with, maintained, or endorsed by Microsoft or the CodePush team. It's a community initiative aimed at providing a more accessible and affordable alternative.
8+
9+
## Key Benefits
10+
11+
* **Global, Serverless, Effortless:** Deliver updates globally with low latency, powered by Cloudflare's edge network, all without managing any servers.
12+
* **Integrated Cloudflare Infrastructure:** Utilizes Cloudflare's D1 (SQLite-compatible) for data and R2 (S3-compatible) for package storage, eliminating the need for external services.
13+
* **Cost-Efficient:** Operates within Cloudflare's cost-optimized serverless environment, minimizing operational overhead.
14+
* **Simple Deployment:** Deploy directly to Cloudflare Workers with a streamlined process.
15+
* **100% API Compatible:** Functions seamlessly with existing applications using the official CodePush API.
16+
17+
## Features
18+
19+
- **Fully Compatible API**: Implements the complete CodePush API.
20+
- **Cloudflare Storage**: Leverages D1 (SQLite) and R2 (S3) for data and package storage.
21+
- **Edge Delivery**: Utilizes Cloudflare's edge network for fast updates.
22+
- **Seamless Deployment:** Deploy your CodePush server to Cloudflare Workers with a streamlined and simplified process, reducing the setup time and effort
23+
24+
## License
25+
26+
Licensed under the **Apache License 2.0**. See [LICENSE](LICENSE) for details.

apps/server/drizzle.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Config } from "drizzle-kit";
2+
3+
export default {
4+
schema: "./src/db/schema.ts",
5+
out: "./drizzle/migrations",
6+
dialect: "sqlite",
7+
} satisfies Config;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
CREATE TABLE `access_key` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`account_id` text NOT NULL,
4+
`name` text NOT NULL,
5+
`friendly_name` text NOT NULL,
6+
`description` text,
7+
`created_by` text NOT NULL,
8+
`created_time` integer NOT NULL,
9+
`expires` integer NOT NULL,
10+
`is_session` integer,
11+
FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON UPDATE no action ON DELETE no action
12+
);
13+
--> statement-breakpoint
14+
CREATE UNIQUE INDEX `access_key_name_unique` ON `access_key` (`name`);--> statement-breakpoint
15+
CREATE TABLE `account` (
16+
`id` text PRIMARY KEY NOT NULL,
17+
`email` text NOT NULL,
18+
`name` text NOT NULL,
19+
`github_id` text,
20+
`created_time` integer NOT NULL
21+
);
22+
--> statement-breakpoint
23+
CREATE UNIQUE INDEX `account_email_unique` ON `account` (`email`);--> statement-breakpoint
24+
CREATE TABLE `app` (
25+
`id` text PRIMARY KEY NOT NULL,
26+
`name` text NOT NULL,
27+
`created_time` integer NOT NULL
28+
);
29+
--> statement-breakpoint
30+
CREATE TABLE `collaborator` (
31+
`app_id` text NOT NULL,
32+
`account_id` text NOT NULL,
33+
`permission` text NOT NULL,
34+
PRIMARY KEY(`app_id`, `account_id`),
35+
FOREIGN KEY (`app_id`) REFERENCES `app`(`id`) ON UPDATE no action ON DELETE no action,
36+
FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON UPDATE no action ON DELETE no action
37+
);
38+
--> statement-breakpoint
39+
CREATE TABLE `deployment` (
40+
`id` text PRIMARY KEY NOT NULL,
41+
`app_id` text NOT NULL,
42+
`name` text NOT NULL,
43+
`key` text NOT NULL,
44+
`created_time` integer NOT NULL,
45+
FOREIGN KEY (`app_id`) REFERENCES `app`(`id`) ON UPDATE no action ON DELETE no action
46+
);
47+
--> statement-breakpoint
48+
CREATE UNIQUE INDEX `deployment_key_unique` ON `deployment` (`key`);--> statement-breakpoint
49+
CREATE TABLE `package_diff` (
50+
`id` text PRIMARY KEY NOT NULL,
51+
`package_id` text NOT NULL,
52+
`source_package_hash` text NOT NULL,
53+
`size` integer NOT NULL,
54+
`blob_path` text NOT NULL,
55+
FOREIGN KEY (`package_id`) REFERENCES `package`(`id`) ON UPDATE no action ON DELETE no action
56+
);
57+
--> statement-breakpoint
58+
CREATE UNIQUE INDEX `package_diff_package_id_source_package_hash_unique` ON `package_diff` (`package_id`,`source_package_hash`);--> statement-breakpoint
59+
CREATE TABLE `package` (
60+
`id` text PRIMARY KEY NOT NULL,
61+
`deployment_id` text NOT NULL,
62+
`label` text NOT NULL,
63+
`app_version` text NOT NULL,
64+
`description` text,
65+
`is_disabled` integer NOT NULL,
66+
`is_mandatory` integer NOT NULL,
67+
`rollout` integer,
68+
`size` integer NOT NULL,
69+
`blob_path` text NOT NULL,
70+
`manifest_blob_path` text,
71+
`package_hash` text NOT NULL,
72+
`release_method` text,
73+
`original_label` text,
74+
`original_deployment` text,
75+
`released_by` text,
76+
`upload_time` integer NOT NULL,
77+
FOREIGN KEY (`deployment_id`) REFERENCES `deployment`(`id`) ON UPDATE no action ON DELETE no action
78+
);

0 commit comments

Comments
 (0)