Skip to content

Commit 0ea3b66

Browse files
authored
Document Cursor plugin export workflow (#19)
1 parent 70b1357 commit 0ea3b66

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,28 @@ pnpm build
123123
pnpm verify
124124
```
125125

126+
## Cursor Publishing
127+
128+
Cursor requires a standalone plugin repository. This repo remains the canonical source for shared WordPress skills and generated plugin packaging, while the publishable Cursor repository lives at:
129+
130+
https://github.com/Automattic/wordpress-cursor-plugin
131+
132+
Do not edit the standalone Cursor repository as the source of truth. Update `skills/` and the Cursor packaging generator here, run the normal build and verification, then export `plugins/cursor/` to the standalone repo:
133+
134+
```bash
135+
pnpm build
136+
pnpm verify
137+
pnpm export:cursor
138+
```
139+
140+
The export command runs `git subtree split --prefix=plugins/cursor` and pushes the result to `Automattic/wordpress-cursor-plugin` on `sync/from-build-with-wordpress`. Open or update a PR from that branch into the standalone repo's `main` branch, then submit the standalone repo to Cursor.
141+
142+
For a dry run:
143+
144+
```bash
145+
pnpm export:cursor -- --dry-run
146+
```
147+
126148
## Output
127149

128150
The Codex plugin repo is generated to:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"scripts": {
88
"build": "node scripts/build-telemetry-mcp.mjs && node scripts/build-plugins.mjs",
99
"build:telemetry-mcp": "node scripts/build-telemetry-mcp.mjs",
10+
"export:cursor": "node scripts/export-cursor-plugin.mjs",
1011
"verify": "node scripts/verify-plugins.mjs"
1112
},
1213
"dependencies": {

scripts/export-cursor-plugin.mjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { execFileSync } from "node:child_process";
2+
import { existsSync } from "node:fs";
3+
4+
const cursorPrefix = "plugins/cursor";
5+
const defaultRemote = "https://github.com/Automattic/wordpress-cursor-plugin.git";
6+
const defaultBranch = "sync/from-build-with-wordpress";
7+
8+
const args = process.argv.slice(2);
9+
const dryRun = args.includes("--dry-run");
10+
const remote = readOption("--remote") ?? defaultRemote;
11+
const branch = readOption("--branch") ?? defaultBranch;
12+
const splitBranch = `export-wordpress-cursor-plugin-${Date.now()}`;
13+
14+
if (!existsSync(cursorPrefix)) {
15+
throw new Error(`${cursorPrefix} does not exist. Run pnpm build first.`);
16+
}
17+
18+
if (!dryRun) {
19+
const status = run("git", ["status", "--porcelain"], { capture: true });
20+
if (status.trim()) {
21+
throw new Error("Working tree must be clean before exporting the Cursor plugin.");
22+
}
23+
}
24+
25+
runStep("Create subtree split", ["git", "subtree", "split", `--prefix=${cursorPrefix}`, "-b", splitBranch]);
26+
runStep("Push split branch", ["git", "push", remote, `${splitBranch}:refs/heads/${branch}`]);
27+
runStep("Remove local split branch", ["git", "branch", "-D", splitBranch]);
28+
29+
console.log(`Cursor plugin export branch: ${branch}`);
30+
console.log("Open or update a PR in https://github.com/Automattic/wordpress-cursor-plugin");
31+
32+
function readOption(name) {
33+
const index = args.indexOf(name);
34+
if (index === -1) {
35+
return undefined;
36+
}
37+
return args[index + 1];
38+
}
39+
40+
function runStep(label, command) {
41+
console.log(`${label}: ${command.join(" ")}`);
42+
if (dryRun) {
43+
return;
44+
}
45+
run(command[0], command.slice(1));
46+
}
47+
48+
function run(command, commandArgs, options = {}) {
49+
return execFileSync(command, commandArgs, {
50+
encoding: "utf8",
51+
stdio: options.capture ? ["ignore", "pipe", "inherit"] : "inherit",
52+
});
53+
}

0 commit comments

Comments
 (0)