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
51 changes: 51 additions & 0 deletions .github/workflows/deploy-cloudflare-workers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy Cloudflare Worker

"on":
push:
branches:
- main
paths-ignore:
- '.gitignore'
- '.npmrc'
- '.prettierignore'
- '.prettierrc'
- 'AGENTS.md'
- 'eslint.config.js'
- 'LICENSE'
- 'package.json'
- 'package-lock.json'
- 'README.md'
- 'tsconfig.json'
workflow_dispatch:

jobs:
deploy:
environment:
name: Production
url: https://collagejs.dev
deployment: true
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACC_ID }}
100 changes: 100 additions & 0 deletions .github/workflows/preview-cloudflare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Deploy PR Preview to Cloudflare Workers

on:
pull_request:
branches:
- main
paths-ignore:
- '.gitignore'
- '.npmrc'
- '.prettierignore'
- '.prettierrc'
- 'AGENTS.md'
- 'eslint.config.js'
- 'LICENSE'
- 'package.json'
- 'package-lock.json'
- 'README.md'
- 'tsconfig.json'

jobs:
preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Deploy Preview to Cloudflare Workers
id: deploy-preview
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACC_ID }}
command: versions upload --preview-alias preview-${{ github.event.pull_request.number }}

- name: Update PR with Preview URL
if: steps.deploy-preview.outcome == 'success'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.issue.number;
const branchName = `preview-${prNumber}`;
const previewUrl = `https://${branchName}-collagejs.webjose.workers.dev`;
const commentTitle = '🚀 **Preview deployment ready!**';

// Look for existing preview comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});

const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes(commentTitle)
);

// Extract deployment count from existing comment or start at 1
let deploymentCount = 1;
if (botComment) {
const match = botComment.body.match(/(\d+) deployment/);
deploymentCount = match ? parseInt(match[1]) + 1 : 2;
}

const commentBody = [
`${commentTitle} (${deploymentCount} ${deploymentCount === 1 ? 'deployment' : 'deployments'})`,
'',
`📍 **Preview URL:** ${previewUrl}`,
'',
'*This preview updates automatically when you push new commits to this PR.*'
].join('\n');

if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules

# Output
.output
.vercel
.netlify
.wrangler
/.svelte-kit
/build

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
bun.lock
bun.lockb

# Miscellaneous
/static/
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["svelte.svelte-vscode", "esbenp.prettier-vscode"]
}
7 changes: 7 additions & 0 deletions .vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"servers": {
"svelte": {
"url": "https://mcp.svelte.dev/mcp"
}
}
}
31 changes: 31 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Project Configuration

- **Language**: TypeScript
- **Package Manager**: npm
- **Add-ons**: prettier, vitest, mcp

---

You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:

## Available Svelte MCP Tools:

### 1. list-sections

Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.

### 2. get-documentation

Retrieves full documentation content for specific sections. Accepts single or multiple sections.
After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task.

### 3. svelte-autofixer

Analyzes Svelte code and returns issues and suggestions.
You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned.

### 4. playground-link

Generates a Svelte Playground link with the provided code.
After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# CollageJS Docs

SvelteKit docs site configured for Cloudflare Workers (server-side), using `@sveltejs/adapter-cloudflare`.

## Local development

```sh
npm install
npm run dev
```

## Build for Cloudflare Workers

```sh
npm run build
```

This generates the Worker entry at `.svelte-kit/cloudflare/_worker.js` and static assets in `.svelte-kit/cloudflare`.

## Run the built Worker locally

```sh
npm run build
npm run cf:dev
```

## Deploy manually

1. Authenticate Wrangler once:

```sh
npx wrangler login
```

2. Deploy:

```sh
npm run build
npm run cf:deploy
```

## CI/CD (GitHub Actions)

The workflow at `.github/workflows/deploy-cloudflare-workers.yml` deploys on pushes to `main`.

Set these repository secrets:

- `CLOUDFLARE_API_TOKEN`
- `CLOUDFLARE_ACCOUNT_ID`

Token permissions should include Workers edit/deploy privileges for your account.

## Configure Worker name

Edit `wrangler.jsonc` and update:

- `name`: your Worker service name

The current placeholder is `collagejs-docs`.
Loading
Loading