Skip to content

Commit 32700a4

Browse files
committed
feat: add instance detach helper
1 parent 91fe57b commit 32700a4

3 files changed

Lines changed: 54 additions & 5 deletions

File tree

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@ The website is the source of truth for setup and operations:
1717

1818
Before starting, you need a registered short domain, GitHub and Cloudflare accounts, Git, Node.js 20 or newer, npm, and a text editor. The short domain must use Cloudflare as its authoritative DNS provider before the Worker can serve it.
1919

20-
Create your own repository from this project, clone it, and install dependencies:
20+
Clone the vanityURLs code, detach the clone from the upstream project, then install dependencies:
2121

2222
```bash
23-
git clone git@github.com:YOUR-ORG/YOUR-SHORT-DOMAIN.git
24-
cd YOUR-SHORT-DOMAIN
23+
git clone https://github.com/vanityURLs/code.git redirector
24+
cd redirector
25+
npm run detach
2526
npm install
2627
```
2728

28-
Run the installer, then validate the plain instance:
29+
Run the installer, install local helpers, then validate the plain instance:
2930

3031
```bash
3132
npm run setup
33+
npm run local-install
3234
npm run check
3335
```
3436

3537
Review `wrangler.toml` and set the Worker name plus the route or custom domain for your short domain. Keep instance-specific files in `custom/`; do not edit `defaults/` unless you are contributing upstream changes to vanityURLs itself.
3638

37-
Add your first links with `./scripts/lnk` or by editing `custom/v8s-links.txt`, push the repository to GitHub, and connect it to Cloudflare Workers & Pages. You can also deploy manually:
39+
Initialize Git, push the repository to GitHub, and connect it to Cloudflare Workers & Pages. You can also deploy manually:
3840

3941
```bash
4042
npx wrangler deploy --config wrangler.toml

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build:links": "node scripts/build.mjs",
99
"clean": "node scripts/clean.mjs",
1010
"convert:lnk": "node scripts/convert-lnk.mjs",
11+
"detach": "node scripts/detach-instance.mjs",
1112
"deploy": "wrangler deploy",
1213
"dev": "wrangler dev",
1314
"generate:blocklist": "node scripts/generate-blocklist.mjs build/blocklist.generated.json",

scripts/detach-instance.mjs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env node
2+
3+
import fs from "node:fs";
4+
import path from "node:path";
5+
6+
const ROOT = process.cwd();
7+
const DETACH_PATHS = [
8+
".git",
9+
".github",
10+
"CHANGELOG.txt",
11+
"package-lock.json",
12+
"release-please-config.json"
13+
];
14+
15+
function hasExpectedPackage() {
16+
const packagePath = path.join(ROOT, "package.json");
17+
if (!fs.existsSync(packagePath)) return false;
18+
19+
try {
20+
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));
21+
return packageJson.name === "vanityURLs";
22+
} catch {
23+
return false;
24+
}
25+
}
26+
27+
if (!hasExpectedPackage()) {
28+
console.error("[detach] Refusing to run: this directory does not look like a vanityURLs code checkout.");
29+
process.exit(1);
30+
}
31+
32+
for (const relativePath of DETACH_PATHS) {
33+
const target = path.join(ROOT, relativePath);
34+
if (!fs.existsSync(target)) {
35+
console.log(`[detach] Skipped ${relativePath}; not present`);
36+
continue;
37+
}
38+
39+
fs.rmSync(target, {
40+
recursive: true,
41+
force: true
42+
});
43+
console.log(`[detach] Removed ${relativePath}`);
44+
}
45+
46+
console.log("[detach] Ready for git init in your own repository.");

0 commit comments

Comments
 (0)