Skip to content

Commit bf11f29

Browse files
committed
Merge branch 'main' into hmacr/ser-213
2 parents 55344f2 + 372b110 commit bf11f29

251 files changed

Lines changed: 9979 additions & 4182 deletions

File tree

Some content is hidden

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

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ PUBLIC_CONSOLE_FEATURE_FLAGS=
33
PUBLIC_APPWRITE_MULTI_REGION=false
44
PUBLIC_APPWRITE_ENDPOINT=http://localhost/v1
55
PUBLIC_STRIPE_KEY=
6-
PUBLIC_GROWTH_ENDPOINT=
6+
PUBLIC_GROWTH_ENDPOINT=
7+
PUBLIC_CONSOLE_EMAIL_VERIFICATION=false
8+
PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Copilot Setup Steps
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
jobs:
15+
copilot-setup-steps:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
steps:
20+
- uses: actions/checkout@v5
21+
- name: Use Node.js
22+
uses: actions/setup-node@v6
23+
with:
24+
node-version: 20
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v4
27+
- name: Install dependencies
28+
run: pnpm install --frozen-lockfile

.github/workflows/publish.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
"PUBLIC_CONSOLE_MODE=cloud"
4242
"PUBLIC_CONSOLE_FEATURE_FLAGS="
4343
"PUBLIC_APPWRITE_MULTI_REGION=true"
44+
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=true"
45+
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=false"
4446
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
4547
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY }}"
4648
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
@@ -81,6 +83,8 @@ jobs:
8183
"PUBLIC_CONSOLE_MODE=cloud"
8284
"PUBLIC_CONSOLE_FEATURE_FLAGS="
8385
"PUBLIC_APPWRITE_MULTI_REGION=true"
86+
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=true"
87+
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=false"
8488
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
8589
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
8690
publish-self-hosted:
@@ -118,6 +122,8 @@ jobs:
118122
build-args: |
119123
"PUBLIC_CONSOLE_MODE=self-hosted"
120124
"PUBLIC_APPWRITE_MULTI_REGION=false"
125+
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=false"
126+
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=true"
121127
"PUBLIC_CONSOLE_FEATURE_FLAGS="
122128
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
123129
@@ -156,6 +162,8 @@ jobs:
156162
build-args: |
157163
"PUBLIC_CONSOLE_MODE=cloud"
158164
"PUBLIC_APPWRITE_MULTI_REGION=false"
165+
"PUBLIC_CONSOLE_EMAIL_VERIFICATION=true"
166+
"PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=false"
159167
"PUBLIC_CONSOLE_FEATURE_FLAGS="
160168
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
161169
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"

AGENTS.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Appwrite Console - Copilot Instructions
2+
3+
## Repository Overview
4+
5+
Appwrite Console is the web-based GUI for the Appwrite backend-as-a-service platform. Single-page application built with **Svelte 5 + SvelteKit 2**, **TypeScript** (not strict mode), **Vite 7**, tested with **Vitest + Playwright**. Package manager: **pnpm 10.15.1**, Node 20+. ~1500 files with extensive component-based architecture.
6+
7+
## Critical Build & Test Commands
8+
9+
### Setup (REQUIRED before any commands)
10+
11+
1. **Install pnpm**: `npm install -g corepack && corepack enable && corepack prepare pnpm@10.15.1 --activate`
12+
2. **Create .env**: `cp .env.example .env` (configure `PUBLIC_APPWRITE_ENDPOINT` and `PUBLIC_CONSOLE_MODE`)
13+
3. **Configure network access** (if using GitHub Actions or restricted environments):
14+
- Ensure firewall/proxy allows access to: `pkg.pr.new`, `pkg.vc`, `registry.npmjs.org`
15+
- These domains are required for dependencies: `@appwrite.io/console`, `@appwrite.io/pink-icons-svelte`, `@appwrite.io/pink-svelte`
16+
- In GitHub Actions: Use `pnpm/action-setup@v4` which handles registry configuration
17+
- If network errors persist, check proxy settings: `npm config get proxy` and `npm config get https-proxy`
18+
4. **Install dependencies**: `pnpm install --frozen-lockfile` (if pkg.pr.new/pkg.vc fail due to network restrictions, installation may still succeed with cached versions)
19+
20+
### Development Commands
21+
22+
**Standard workflow**: `check``lint``test``build` (before committing)
23+
24+
- `pnpm run check` - TypeScript/Svelte validation (~30-60s)
25+
- `pnpm run lint` - ESLint check (~10-20s)
26+
- `pnpm run format` - Auto-fix Prettier formatting
27+
- `pnpm run test` - Vitest unit tests with TZ=EST (~10-30s)
28+
- `pnpm run build` - Production build via build.js (~60-120s)
29+
- `pnpm dev` - Dev server on port 3000
30+
- `pnpm run preview` - Preview build on port 4173
31+
- `pnpm run e2e` - Playwright tests (needs `pnpm exec playwright install --with-deps chromium` first, ~120s+)
32+
33+
**CI Pipeline** (`.github/workflows/tests.yml`): audit → install → check → lint → test → build
34+
35+
## Project Structure
36+
37+
```
38+
src/
39+
├── lib/ # Reusable logic ($lib alias)
40+
│ ├── components/ # Feature components (billing, domains, permissions, etc.)
41+
│ ├── elements/ # Basic UI elements
42+
│ ├── helpers/ # Utility functions (array, date, string, etc.)
43+
│ ├── stores/ # Svelte stores for state
44+
│ ├── sdk/ # Appwrite SDK wrappers
45+
│ └── constants.ts, flags.ts, system.ts
46+
├── routes/
47+
│ ├── (console)/ # Auth-required routes
48+
│ │ ├── organization-[organization]/
49+
│ │ └── project-[region]-[project]/ # databases, functions, messaging, storage
50+
│ └── (public)/ # Public routes (login, register, auth callbacks)
51+
├── themes/ # Theme definitions ($themes alias)
52+
└── app.html, hooks.{client,server}.ts, service-worker.ts
53+
```
54+
55+
**SvelteKit conventions**: `+page.svelte` (component), `+page.ts` (data loader), `+layout.svelte` (wrapper), `+error.svelte` (errors). Groups like `(console)` organize routes without affecting URLs. Dynamic params: `[param]`.
56+
57+
## Key Configuration
58+
59+
**svelte.config.js**: Adapter = static SPA (fallback: index.html), base path `/console`, aliases: `$lib`, `$routes`, `$themes`
60+
**vite.config.ts**: Dev port 3000, Vitest (client=jsdom, server=node), test files: `src/**/*.{test,spec}.{js,ts}`
61+
**tsconfig.json**: Extends `.svelte-kit/tsconfig.json`, **NOT strict mode** (`strict: false`)
62+
**eslint.config.js**: Flat config (ESLint 9+), many rules disabled (see TODOs)
63+
**.prettierrc**: 4 spaces, single quotes, 100 char width, no trailing commas
64+
65+
## Testing
66+
67+
**Unit (Vitest)**: Tests in `src/lib/helpers/*.test.ts`, run with `TZ=EST` (timezone matters). Setup mocks SvelteKit (`$app/*`) in `vitest-setup-client.ts`.
68+
**E2E (Playwright)**: Tests in `e2e/journeys/*.spec.ts`, needs build+preview on port 4173, retries 3x, timeout 120s, Chromium only.
69+
70+
## Common Pitfalls
71+
72+
1. **Blank page in dev**: Disable ad blockers if seeing "Failed to fetch dynamically imported module" (known SvelteKit issue)
73+
2. **Network errors on install**:
74+
- pkg.pr.new/pkg.vc deps may fail due to firewall/proxy restrictions
75+
- Check access: `curl -I https://pkg.pr.new` and `curl -I https://pkg.vc`
76+
- Configure proxy if needed: `npm config set proxy http://proxy:port` and `npm config set https-proxy http://proxy:port`
77+
- GitHub Actions: Ensure runner has internet access; use `pnpm/action-setup@v4` action
78+
- Local dev: Often safe to continue with cached versions if network fails
79+
3. **OOM on build**: Set `NODE_OPTIONS=--max_old_space_size=8192` (like Dockerfile does)
80+
4. **Test failures**: Always use `pnpm run test` (sets TZ=EST), not `vitest` directly
81+
5. **TS errors not showing**: Run `pnpm run check` explicitly (dev server doesn't always surface them)
82+
6. **Format vs lint conflicts**: Run `pnpm run format` before `pnpm run lint`
83+
7. **E2E timeouts**: Wait 120s for preview server startup, tests auto-retry 3x
84+
8. **Stale build**: Clear `.svelte-kit` if changes not reflected: `rm -rf .svelte-kit && pnpm run build`
85+
86+
## Code Conventions
87+
88+
- Imports: Use `$lib`, `$routes`, `$themes` aliases
89+
- Components: PascalCase, in `src/lib/components/[feature]/`
90+
- Helpers: Pure functions in `src/lib/helpers/`
91+
- Types: Inline or `.d.ts`, not `.types.ts` files
92+
- Comments: Minimal, use for TODOs or complex logic
93+
- TypeScript: Not strict mode, `any` tolerated
94+
95+
## Workflow
96+
97+
1. Run Appwrite backend locally (see [docs](https://appwrite.io/docs/advanced/self-hosting))
98+
2. Configure `.env` with backend endpoint
99+
3. `pnpm install --frozen-lockfile`
100+
4. `pnpm dev` (hot reload on port 3000)
101+
5. Before commit: `pnpm run check && pnpm run format && pnpm run lint && pnpm run test && pnpm run build`
102+
6. **Take screenshots**: For any UI changes, capture screenshots and include them in the PR description or comments before finalizing
103+
104+
**Trust these instructions** - only search if incomplete/incorrect. See CONTRIBUTING.md for PR conventions. Use `--frozen-lockfile` always. Docker builds: multi-stage, final image is nginx serving static files from `/console` path.

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN corepack prepare pnpm@10.0.0 --activate
1111
ADD ./package.json /app/package.json
1212
ADD ./pnpm-lock.yaml /app/pnpm-lock.yaml
1313

14-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
14+
RUN pnpm install --frozen-lockfile
1515

1616
ADD ./build.js /app/build.js
1717
ADD ./tsconfig.json /app/tsconfig.json
@@ -23,6 +23,8 @@ ADD ./static /app/static
2323
ARG PUBLIC_CONSOLE_MODE
2424
ARG PUBLIC_CONSOLE_FEATURE_FLAGS
2525
ARG PUBLIC_APPWRITE_MULTI_REGION
26+
ARG PUBLIC_CONSOLE_EMAIL_VERIFICATION
27+
ARG PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS
2628
ARG PUBLIC_APPWRITE_ENDPOINT
2729
ARG PUBLIC_GROWTH_ENDPOINT
2830
ARG PUBLIC_STRIPE_KEY
@@ -34,6 +36,8 @@ ENV PUBLIC_GROWTH_ENDPOINT=$PUBLIC_GROWTH_ENDPOINT
3436
ENV PUBLIC_CONSOLE_MODE=$PUBLIC_CONSOLE_MODE
3537
ENV PUBLIC_CONSOLE_FEATURE_FLAGS=$PUBLIC_CONSOLE_FEATURE_FLAGS
3638
ENV PUBLIC_APPWRITE_MULTI_REGION=$PUBLIC_APPWRITE_MULTI_REGION
39+
ENV PUBLIC_CONSOLE_EMAIL_VERIFICATION=$PUBLIC_CONSOLE_EMAIL_VERIFICATION
40+
ENV PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS=$PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS
3741
ENV PUBLIC_STRIPE_KEY=$PUBLIC_STRIPE_KEY
3842
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
3943
ENV SENTRY_RELEASE=$SENTRY_RELEASE

build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ async function main() {
2828
logEnv('MULTI REGION', env?.PUBLIC_APPWRITE_MULTI_REGION);
2929
logEnv('APPWRITE ENDPOINT', env?.PUBLIC_APPWRITE_ENDPOINT, 'relative');
3030
logEnv('GROWTH ENDPOINT', env?.PUBLIC_GROWTH_ENDPOINT);
31+
logEnv('CONSOLE EMAIL VERIFICATION', env?.PUBLIC_CONSOLE_EMAIL_VERIFICATION);
32+
logEnv('CONSOLE MOCK AI SUGGESTIONS', env?.PUBLIC_CONSOLE_MOCK_AI_SUGGESTIONS);
3133
log();
3234
logDelimiter();
3335
await build();

e2e/steps/free-project.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ export async function createFreeProject(page: Page): Promise<Metadata> {
1717
await page.waitForURL(/\/organization-[^/]+/);
1818
await page.getByRole('button', { name: 'create project' }).first().click();
1919
const dialog = page.locator('dialog[open]');
20+
2021
await dialog.getByPlaceholder('Project name').fill('test project');
22+
23+
let region = 'fra'; // for fallback
24+
const regionPicker = dialog.locator('button[role="combobox"]');
25+
if (await regionPicker.isVisible()) {
26+
await regionPicker.click();
27+
await page.getByRole('option', { name: /New York/i }).click();
28+
29+
region = 'nyc';
30+
}
31+
2132
await dialog.getByRole('button', { name: 'create' }).click();
22-
await page.waitForURL(/\/project-fra-[^/]+/);
23-
expect(page.url()).toContain('/console/project-fra-');
33+
34+
await page.waitForURL(new RegExp(`/project-${region}-[^/]+`));
35+
expect(page.url()).toContain(`/console/project-${region}-`);
2436

2537
return getProjectIdFromUrl(page.url());
2638
});

e2e/steps/pro-project.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,21 @@ export async function createProProject(page: Page): Promise<Metadata> {
5050
await page.waitForURL(/\/organization-[^/]+/);
5151
await page.getByRole('button', { name: 'create project' }).first().click();
5252
const dialog = page.locator('dialog[open]');
53+
5354
await dialog.getByPlaceholder('Project name').fill('test project');
55+
56+
let region = 'fra'; // for fallback
57+
const regionPicker = dialog.locator('button[role="combobox"]');
58+
if (await regionPicker.isVisible()) {
59+
await regionPicker.click();
60+
await page.getByRole('option', { name: /New York/i }).click();
61+
62+
region = 'nyc';
63+
}
64+
5465
await dialog.getByRole('button', { name: 'create' }).click();
55-
await page.waitForURL(/\/project-fra-[^/]+/);
56-
expect(page.url()).toContain('/console/project-fra-');
66+
await page.waitForURL(new RegExp(`/project-${region}-[^/]+`));
67+
expect(page.url()).toContain(`/console/project-${region}-`);
5768

5869
return getProjectIdFromUrl(page.url());
5970
});

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "rm -rf node_modules && rm -rf .svelte_kit && pnpm i --force",
1313
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1414
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
15-
"format": "prettier --write .",
15+
"format": "prettier --write --cache .",
1616
"lint": "prettier --check . && eslint .",
1717
"test": "TZ=EST vitest run",
1818
"test:ui": "TZ=EST vitest --ui",
@@ -22,11 +22,11 @@
2222
},
2323
"dependencies": {
2424
"@ai-sdk/svelte": "^1.1.24",
25-
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@7747562",
25+
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@2752",
2626
"@appwrite.io/pink-icons": "0.25.0",
27-
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@f2198f1",
27+
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@a8bd38d",
2828
"@appwrite.io/pink-legacy": "^1.0.3",
29-
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@f2198f1",
29+
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@a8bd38d",
3030
"@faker-js/faker": "^9.9.0",
3131
"@popperjs/core": "^2.11.8",
3232
"@sentry/sveltekit": "^8.38.0",
@@ -52,7 +52,7 @@
5252
"@eslint/js": "^9.31.0",
5353
"@melt-ui/pp": "^0.3.2",
5454
"@melt-ui/svelte": "^0.86.5",
55-
"@playwright/test": "^1.51.1",
55+
"@playwright/test": "^1.55.1",
5656
"@sveltejs/adapter-static": "^3.0.8",
5757
"@sveltejs/kit": "^2.42.1",
5858
"@sveltejs/vite-plugin-svelte": "^5.0.3",
@@ -95,5 +95,5 @@
9595
"svelte-preprocess"
9696
]
9797
},
98-
"packageManager": "pnpm@10.15.1"
98+
"packageManager": "pnpm@10.20.0"
9999
}

0 commit comments

Comments
 (0)