@just-be/deploy 0.7.0 → 0.8.1

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 +28 -22
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -62,24 +62,13 @@ const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
62
62
 
63
63
  /**
64
64
  * Run wrangler command using bunx to ensure it resolves from package dependencies
65
- * Splits command into array so each part is passed as a separate argument
65
+ * Takes variable arguments and passes them as separate shell arguments
66
+ *
67
+ * @example
68
+ * wrangler('r2', 'object', 'put', 'bucket/key', '--file', 'path')
66
69
  */
67
- function wrangler(strings: TemplateStringsArray, ...values: unknown[]) {
68
- // Build an array by interleaving string parts and values
69
- const parts = [];
70
- for (let i = 0; i < strings.length; i++) {
71
- // Split string part on whitespace and add non-empty parts
72
- const words = strings[i].trim().split(/\s+/).filter(Boolean);
73
- parts.push(...words);
74
-
75
- // Add the value as a separate argument
76
- if (i < values.length) {
77
- parts.push(String(values[i]));
78
- }
79
- }
80
-
81
- // Bun's shell will treat array elements as separate arguments
82
- return $`bunx wrangler ${parts}`;
70
+ function wrangler(...args: string[]) {
71
+ return $`bunx wrangler ${args}`;
83
72
  }
84
73
 
85
74
  /**
@@ -190,7 +179,15 @@ async function findFiles(dir: string): Promise<string[]> {
190
179
  */
191
180
  async function uploadToR2(localPath: string, r2Key: string): Promise<boolean> {
192
181
  try {
193
- await wrangler`r2 object put ${BUCKET_NAME}/${r2Key} --file ${localPath}`;
182
+ await wrangler(
183
+ "r2",
184
+ "object",
185
+ "put",
186
+ `${BUCKET_NAME}/${r2Key}`,
187
+ "--file",
188
+ localPath,
189
+ "--remote"
190
+ );
194
191
  return true;
195
192
  } catch (error) {
196
193
  if (DEBUG) {
@@ -211,7 +208,7 @@ async function uploadToR2(localPath: string, r2Key: string): Promise<boolean> {
211
208
  */
212
209
  async function validateWranglerAuth(): Promise<boolean> {
213
210
  try {
214
- await wrangler`whoami`.quiet();
211
+ await wrangler("whoami").quiet();
215
212
  return true;
216
213
  } catch (error) {
217
214
  if (DEBUG) {
@@ -230,7 +227,7 @@ async function validateWranglerAuth(): Promise<boolean> {
230
227
  */
231
228
  async function validateKVAccess(): Promise<boolean> {
232
229
  try {
233
- await wrangler`kv key list --namespace-id ${KV_NAMESPACE_ID}`.quiet();
230
+ await wrangler("kv", "key", "list", "--namespace-id", KV_NAMESPACE_ID, "--remote").quiet();
234
231
  return true;
235
232
  } catch (error) {
236
233
  if (DEBUG) {
@@ -281,7 +278,16 @@ function sanitizeBranchName(branch: string): string {
281
278
  */
282
279
  async function createKVEntry(subdomain: string, routeConfig: RouteConfig): Promise<void> {
283
280
  const configJson = JSON.stringify(routeConfig);
284
- await wrangler`kv key put --namespace-id ${KV_NAMESPACE_ID} ${subdomain} ${configJson}`;
281
+ await wrangler(
282
+ "kv",
283
+ "key",
284
+ "put",
285
+ "--namespace-id",
286
+ KV_NAMESPACE_ID,
287
+ subdomain,
288
+ configJson,
289
+ "--remote"
290
+ );
285
291
  }
286
292
 
287
293
  /**
@@ -472,7 +478,7 @@ async function deploy() {
472
478
  console.log("This will open a browser window for you to authorize access.\n");
473
479
 
474
480
  try {
475
- await wrangler`login`;
481
+ await wrangler("login");
476
482
  console.log("\n✓ Successfully authenticated!");
477
483
 
478
484
  // Verify authentication worked
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-be/deploy",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "Deploy static sites to Cloudflare R2 with subdomain routing",
5
5
  "type": "module",
6
6
  "bin": {