Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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.0.1-beta.1",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be bumped to 0.1

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to all packages

"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.0.1-beta.1",
"hono": "^4.11.4",
"typescript": "^5.9.3"
},
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.0.1-beta.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"]
}
50 changes: 32 additions & 18 deletions package-lock.json

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

Loading