@just-be/deploy 0.7.0 → 0.8.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.
- package/index.ts +11 -22
- 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
|
-
*
|
|
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(
|
|
68
|
-
|
|
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,7 @@ 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
|
|
182
|
+
await wrangler("r2", "object", "put", `${BUCKET_NAME}/${r2Key}`, "--file", localPath);
|
|
194
183
|
return true;
|
|
195
184
|
} catch (error) {
|
|
196
185
|
if (DEBUG) {
|
|
@@ -211,7 +200,7 @@ async function uploadToR2(localPath: string, r2Key: string): Promise<boolean> {
|
|
|
211
200
|
*/
|
|
212
201
|
async function validateWranglerAuth(): Promise<boolean> {
|
|
213
202
|
try {
|
|
214
|
-
await wrangler
|
|
203
|
+
await wrangler("whoami").quiet();
|
|
215
204
|
return true;
|
|
216
205
|
} catch (error) {
|
|
217
206
|
if (DEBUG) {
|
|
@@ -230,7 +219,7 @@ async function validateWranglerAuth(): Promise<boolean> {
|
|
|
230
219
|
*/
|
|
231
220
|
async function validateKVAccess(): Promise<boolean> {
|
|
232
221
|
try {
|
|
233
|
-
await wrangler
|
|
222
|
+
await wrangler("kv", "key", "list", "--namespace-id", KV_NAMESPACE_ID).quiet();
|
|
234
223
|
return true;
|
|
235
224
|
} catch (error) {
|
|
236
225
|
if (DEBUG) {
|
|
@@ -281,7 +270,7 @@ function sanitizeBranchName(branch: string): string {
|
|
|
281
270
|
*/
|
|
282
271
|
async function createKVEntry(subdomain: string, routeConfig: RouteConfig): Promise<void> {
|
|
283
272
|
const configJson = JSON.stringify(routeConfig);
|
|
284
|
-
await wrangler
|
|
273
|
+
await wrangler("kv", "key", "put", "--namespace-id", KV_NAMESPACE_ID, subdomain, configJson);
|
|
285
274
|
}
|
|
286
275
|
|
|
287
276
|
/**
|
|
@@ -472,7 +461,7 @@ async function deploy() {
|
|
|
472
461
|
console.log("This will open a browser window for you to authorize access.\n");
|
|
473
462
|
|
|
474
463
|
try {
|
|
475
|
-
await wrangler
|
|
464
|
+
await wrangler("login");
|
|
476
465
|
console.log("\n✓ Successfully authenticated!");
|
|
477
466
|
|
|
478
467
|
// Verify authentication worked
|