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
4 changes: 3 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
- name: Setup env files for type generation
run: |
for dir in examples/*/; do
[ -f "$dir/.env.example" ] && cp "$dir/.env.example" "$dir/.env"
if [ -f "$dir/.env.example" ]; then
cp "$dir/.env.example" "$dir/.env"
fi
done

- run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion examples/csv-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"framer-api": "^0.0.1-beta.0",
"framer-api": "^0.1.1",
"papaparse": "^5.5.3",
"typescript": "^5.9.3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/json-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@hono/node-server": "^1.14.1",
"framer-api": "^0.0.1-beta.0",
"framer-api": "^0.1.1",
"hono": "^4.11.4",
"typescript": "^5.9.3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/notion-automations-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@notionhq/client": "^5.6.0",
"framer-api": "beta"
"framer-api": "0.1.1"
},
"devDependencies": {
"@types/node": "^24.10.0",
Expand Down
42 changes: 42 additions & 0 deletions examples/publish/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Publish

Publishes and deploys a Framer project. Designed to run as a one-shot script, making it ideal for cron jobs, CI/CD pipelines, and systemd timers.

## Usage

```bash
node --env-file=../../.env publish.ts

bun --env-file=../../.env run publish.ts

deno --env-file=../../.env run publish.ts
```

## Environment Variables

| Variable | Required | Description |
|----------|----------|-------------|
| `EXAMPLE_PROJECT_URL` | Yes | Your Framer project URL |

## Scheduling Examples

### Cron

Publish every 4 hours:

```bash
# Edit crontab
crontab -e

# Add this line (adjust paths as needed)
0 */4 * * * cd /path/to/examples/publish && node --env-file=../../.env publish.ts >> /var/log/framer-publish.log 2>&1
```

Common cron schedules:

```bash
0 */4 * * * # Every 4 hours
0 9-18/2 * * 1-5 # Every 2 hours between 9:00 and 18:00, mon-fri
0 9 * * * # Daily at 9:00
0 9 * * 1-5 # Weekdays at 9:00
```
16 changes: 16 additions & 0 deletions examples/publish/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "publish",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit"
},
"dependencies": {
"framer-api": "^0.1.1",
"typescript": "^5.9.3"
},
"devDependencies": {
"@types/node": "^22.10.2"
}
}
40 changes: 40 additions & 0 deletions examples/publish/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import assert from "node:assert";
import { connect } from "framer-api";

const projectUrl = process.env["EXAMPLE_PROJECT_URL"];
assert(projectUrl, "EXAMPLE_PROJECT_URL environment variable is required");

using framer = await connect(projectUrl);

// Show changes
const changedPaths = await framer.getChangedPaths();
const entries = Object.entries(changedPaths);
const totalChanges = entries.reduce((sum, [, paths]) => sum + paths.length, 0);

if (totalChanges === 0) {
console.log("⛔️ No changes to publish.");
process.exit(0);
}

console.log(`📄 ${totalChanges} change(s):`);
for (const [type, paths] of entries) {
for (const path of paths) {
console.log(` ${type}: ${path}`);
}
}

// Publish
const { deployment } = await framer.publish();
console.log(`🚀 Published deployment ${deployment.id}`);

// Deploy to custom domains
const deployed = await framer.deploy(deployment.id);

if (deployed.length > 0) {
console.log(`✅ Deployed to ${deployed.length} custom domain(s):`);
for (const hostname of deployed) {
console.log(` https://${hostname.hostname}`);
}
} else {
console.log("No custom domains to deploy — default hostname is already live.");
}
4 changes: 4 additions & 0 deletions examples/publish/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["publish.ts"]
}
125 changes: 44 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.