@within-7/jetr 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/cli.js +27 -10
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @within-7/jetr
2
2
 
3
- Internal static site hosting CLI. Deploy static files to Cloudflare R2 and get a `{name}.jetr.within-7.com` subdomain.
3
+ Static site hosting CLI. Deploy files to Cloudflare R2 with one command. Incremental uploads, custom domains, password protection.
4
4
 
5
5
  ## Install
6
6
 
@@ -27,7 +27,7 @@ jetr login
27
27
  jetr
28
28
  # Site name [my-blog]:
29
29
  # ✔ Deployed!
30
- # URL: https://my-blog.jetr.within-7.com
30
+ # URL: https://my-blog.your-domain.com
31
31
 
32
32
  # 3. Re-deploy (remembers site name)
33
33
  jetr
@@ -49,7 +49,7 @@ jetr login --token <jwt> # direct token (for CI)
49
49
 
50
50
  ### `jetr create <name>`
51
51
 
52
- Create a new site. Name becomes the subdomain: `{name}.jetr.within-7.com`.
52
+ Create an empty site without deploying files.
53
53
 
54
54
  ```bash
55
55
  jetr create my-blog
package/dist/cli.js CHANGED
@@ -63,8 +63,26 @@ async function request(path, options = {}) {
63
63
  Authorization: `Bearer ${getToken()}`,
64
64
  ...options.headers || {}
65
65
  };
66
- const res = await fetch(url, { ...options, headers });
67
- return res;
66
+ const MAX_RETRIES = 3;
67
+ for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
68
+ try {
69
+ return await fetch(url, { ...options, headers });
70
+ } catch (e) {
71
+ const isLast = attempt === MAX_RETRIES;
72
+ const code = e.cause?.code || e.code || "";
73
+ const retryable = ["ECONNRESET", "ETIMEDOUT", "ECONNREFUSED", "EAI_AGAIN", "UND_ERR_CONNECT_TIMEOUT"].includes(code) || e.message === "fetch failed";
74
+ if (retryable && !isLast) {
75
+ const delay = attempt * 2e3;
76
+ await new Promise((r) => setTimeout(r, delay));
77
+ continue;
78
+ }
79
+ if (e.message === "fetch failed") {
80
+ throw new Error(`Network error: cannot reach ${config.apiUrl} (check internet connection)`);
81
+ }
82
+ throw new Error(`Network error: ${e.message}${code ? ` [${code}]` : ""}`);
83
+ }
84
+ }
85
+ throw new Error("Unreachable");
68
86
  }
69
87
  async function json(path, options = {}) {
70
88
  const res = await request(path, options);
@@ -473,21 +491,20 @@ async function promptSelection(options) {
473
491
 
474
492
  // src/cli.ts
475
493
  var program = new Command();
476
- program.name("jetr").description(`Deploy static sites instantly to {name}.jetr.within-7.com
494
+ program.name("jetr").description(`Deploy static sites instantly
477
495
 
478
496
  Just run "jetr" in any directory to deploy. First time? Run "jetr login" first.
479
497
 
480
- The name can be a simple name (gets .jetr.within-7.com subdomain) or a full
481
- domain like docs.within-7.com or blog.example.com for custom domain hosting.
498
+ The name can be a simple name (auto-assigned subdomain) or a full domain
499
+ like blog.example.com for custom domain hosting.
482
500
 
483
501
  Examples:
484
- $ jetr Deploy current directory (random name or from .jetrrc)
502
+ $ jetr Deploy current directory (name from .jetrrc or random)
485
503
  $ jetr ./dist Deploy the ./dist directory
486
- $ jetr ./dist my-blog Deploy as my-blog.jetr.within-7.com
487
- $ jetr ./dist docs.within-7.com Deploy to custom domain (auto-configures route)
488
- $ jetr ./dist blog.example.com Deploy to external domain (shows DNS setup)
504
+ $ jetr ./dist my-blog Deploy and assign a subdomain
505
+ $ jetr ./dist blog.example.com Deploy to a custom domain (shows DNS setup)
489
506
  $ jetr index.html Deploy a single file
490
- $ jetr *.html *.css my-site Deploy multiple files to a named site`).version("0.7.1");
507
+ $ jetr *.html *.css my-site Deploy multiple files to a named site`).version("0.7.6");
491
508
  program.argument("[paths...]", "directory, file(s), and/or site name to deploy").action(async (paths) => {
492
509
  const config = loadConfig();
493
510
  if (!config.token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@within-7/jetr",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "CLI for Jetr static site hosting",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "files": ["dist", "README.md"],
10
10
  "scripts": {
11
- "build": "tsup src/cli.ts --format esm --target node20 --clean",
11
+ "build": "node -e \"const v=require('./package.json').version; console.log('Building v'+v)\" && tsup src/cli.ts --format esm --target node20 --clean --define.PKG_VERSION='\"'$(node -p \"require('./package.json').version\")'\"'",
12
12
  "dev": "tsx src/cli.ts",
13
13
  "prepublishOnly": "pnpm build"
14
14
  },