@just-be/deploy 0.5.0 → 0.6.0

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 (2) hide show
  1. package/index.ts +37 -5
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  * Environment Variables:
17
17
  * R2_BUCKET_NAME # R2 bucket name
18
18
  * KV_NAMESPACE_ID # KV namespace ID
19
+ * DEBUG # Set to "1" or "true" to enable verbose error output
19
20
  *
20
21
  * Example deploy.json:
21
22
  * {
@@ -57,6 +58,7 @@ import {
57
58
 
58
59
  const BUCKET_NAME = process.env.R2_BUCKET_NAME || "content-bucket";
59
60
  const KV_NAMESPACE_ID = process.env.KV_NAMESPACE_ID || "6118ae3b937c4883b3c582dfef8a0c05";
61
+ const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
60
62
 
61
63
  /**
62
64
  * Run wrangler command using bunx to ensure it resolves from package dependencies
@@ -177,7 +179,15 @@ async function uploadToR2(localPath: string, r2Key: string): Promise<boolean> {
177
179
  await wrangler`r2 object put ${BUCKET_NAME}/${r2Key} --file ${localPath}`;
178
180
  return true;
179
181
  } catch (error) {
180
- console.error(`\nFailed to upload ${localPath}:`, error);
182
+ if (DEBUG) {
183
+ console.error(`\nFailed to upload ${localPath}:`);
184
+ console.error("Error details:", error);
185
+ if (error instanceof Error) {
186
+ console.error("Stack trace:", error.stack);
187
+ }
188
+ } else {
189
+ console.error(`\nFailed to upload ${localPath}:`, error);
190
+ }
181
191
  return false;
182
192
  }
183
193
  }
@@ -189,7 +199,14 @@ async function validateWranglerAuth(): Promise<boolean> {
189
199
  try {
190
200
  await wrangler`whoami`.quiet();
191
201
  return true;
192
- } catch {
202
+ } catch (error) {
203
+ if (DEBUG) {
204
+ console.error("\nWrangler auth validation failed:");
205
+ console.error("Error details:", error);
206
+ if (error instanceof Error) {
207
+ console.error("Stack trace:", error.stack);
208
+ }
209
+ }
193
210
  return false;
194
211
  }
195
212
  }
@@ -201,7 +218,15 @@ async function validateKVAccess(): Promise<boolean> {
201
218
  try {
202
219
  await wrangler`kv key list --namespace-id ${KV_NAMESPACE_ID}`.quiet();
203
220
  return true;
204
- } catch {
221
+ } catch (error) {
222
+ if (DEBUG) {
223
+ console.error("\nKV access validation failed:");
224
+ console.error("Error details:", error);
225
+ if (error instanceof Error) {
226
+ console.error("Stack trace:", error.stack);
227
+ }
228
+ console.error(`Namespace ID: ${KV_NAMESPACE_ID}`);
229
+ }
205
230
  return false;
206
231
  }
207
232
  }
@@ -213,7 +238,14 @@ async function getCurrentBranch(): Promise<string> {
213
238
  try {
214
239
  const result = await $`git rev-parse --abbrev-ref HEAD`.text();
215
240
  return result.trim();
216
- } catch {
241
+ } catch (error) {
242
+ if (DEBUG) {
243
+ console.error("\nFailed to get current git branch:");
244
+ console.error("Error details:", error);
245
+ if (error instanceof Error) {
246
+ console.error("Stack trace:", error.stack);
247
+ }
248
+ }
217
249
  throw new Error("Failed to get current git branch. Are you in a git repository?");
218
250
  }
219
251
  }
@@ -439,7 +471,7 @@ async function deploy() {
439
471
  process.exit(1);
440
472
  }
441
473
  s.stop("✓ Authentication verified");
442
- } catch (error) {
474
+ } catch {
443
475
  console.error("\n❌ Authentication failed");
444
476
  console.error("\nAlternatively, you can set up an API token:");
445
477
  console.error(" export CLOUDFLARE_API_TOKEN=your-token");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-be/deploy",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Deploy static sites to Cloudflare R2 with subdomain routing",
5
5
  "type": "module",
6
6
  "bin": {