playcademy 0.13.17 → 0.13.19
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/dist/index.js +357 -312
- package/dist/templates/api/sample-bucket.ts.template +0 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2361,6 +2361,215 @@ var init_context = __esm({
|
|
|
2361
2361
|
}
|
|
2362
2362
|
});
|
|
2363
2363
|
|
|
2364
|
+
// src/lib/core/logger.ts
|
|
2365
|
+
import {
|
|
2366
|
+
blue,
|
|
2367
|
+
bold as bold2,
|
|
2368
|
+
cyan,
|
|
2369
|
+
dim as dim2,
|
|
2370
|
+
gray,
|
|
2371
|
+
green,
|
|
2372
|
+
greenBright,
|
|
2373
|
+
red,
|
|
2374
|
+
yellow,
|
|
2375
|
+
yellowBright
|
|
2376
|
+
} from "colorette";
|
|
2377
|
+
import { colorize } from "json-colorizer";
|
|
2378
|
+
function customTransform(text5) {
|
|
2379
|
+
const highlightCode = (text6) => text6.replace(/`([^`]+)`/g, (_, code) => greenBright(code));
|
|
2380
|
+
return highlightCode(text5);
|
|
2381
|
+
}
|
|
2382
|
+
function formatTable(data, title) {
|
|
2383
|
+
if (data.length === 0) return;
|
|
2384
|
+
const keys = Object.keys(data[0]);
|
|
2385
|
+
const rows = data.map((item) => keys.map((key) => String(item[key] ?? "")));
|
|
2386
|
+
const widths = keys.map((key, i) => {
|
|
2387
|
+
const headerWidth = key.length;
|
|
2388
|
+
const dataWidth = Math.max(...rows.map((row) => row[i].length));
|
|
2389
|
+
return Math.max(headerWidth, dataWidth);
|
|
2390
|
+
});
|
|
2391
|
+
const totalWidth = widths.reduce((sum, w) => sum + w + 3, -1);
|
|
2392
|
+
const separator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u253C") + "\u2524";
|
|
2393
|
+
const topBorder = "\u250C" + "\u2500".repeat(totalWidth) + "\u2510";
|
|
2394
|
+
const titleSeparator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u252C") + "\u2524";
|
|
2395
|
+
const bottomBorder = "\u2514" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u2534") + "\u2518";
|
|
2396
|
+
console.log(topBorder);
|
|
2397
|
+
if (title) {
|
|
2398
|
+
const titleText = bold2(title);
|
|
2399
|
+
const titlePadding = totalWidth - title.length - 1;
|
|
2400
|
+
const titleRow = "\u2502 " + titleText + " ".repeat(titlePadding) + "\u2502";
|
|
2401
|
+
console.log(titleRow);
|
|
2402
|
+
console.log(titleSeparator);
|
|
2403
|
+
}
|
|
2404
|
+
const header = "\u2502 " + keys.map((key, i) => key.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
|
|
2405
|
+
console.log(header);
|
|
2406
|
+
console.log(separator);
|
|
2407
|
+
rows.forEach((row) => {
|
|
2408
|
+
const dataRow = "\u2502 " + row.map((cell, i) => cell.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
|
|
2409
|
+
console.log(dataRow);
|
|
2410
|
+
});
|
|
2411
|
+
console.log(bottomBorder);
|
|
2412
|
+
}
|
|
2413
|
+
var logger;
|
|
2414
|
+
var init_logger = __esm({
|
|
2415
|
+
"src/lib/core/logger.ts"() {
|
|
2416
|
+
"use strict";
|
|
2417
|
+
logger = {
|
|
2418
|
+
table: (data, title) => {
|
|
2419
|
+
formatTable(data, title);
|
|
2420
|
+
},
|
|
2421
|
+
/**
|
|
2422
|
+
* Info message - general information
|
|
2423
|
+
*/
|
|
2424
|
+
info: (message, indent = 0) => {
|
|
2425
|
+
const spaces = " ".repeat(indent);
|
|
2426
|
+
console.log(`${spaces}${blue("\u2139")} ${bold2(customTransform(message))}`);
|
|
2427
|
+
},
|
|
2428
|
+
/**
|
|
2429
|
+
* Admonition - highlighted note/tip/warning box (Docusaurus-style)
|
|
2430
|
+
*/
|
|
2431
|
+
admonition: (type, title, lines, indent = 0) => {
|
|
2432
|
+
const spaces = " ".repeat(indent);
|
|
2433
|
+
const configs = {
|
|
2434
|
+
note: { color: green },
|
|
2435
|
+
tip: { color: cyan },
|
|
2436
|
+
info: { color: blue },
|
|
2437
|
+
warning: { color: yellow }
|
|
2438
|
+
};
|
|
2439
|
+
const { color: color2 } = configs[type];
|
|
2440
|
+
console.log(`${spaces}${color2("\u250C\u2500")} ${bold2(color2(title.toUpperCase()))}`);
|
|
2441
|
+
if (lines && lines.length > 0) {
|
|
2442
|
+
lines.forEach((line) => {
|
|
2443
|
+
console.log(`${spaces}${color2("\u2502")} ${customTransform(line)}`);
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
console.log(`${spaces}${color2("\u2514\u2500")}`);
|
|
2447
|
+
},
|
|
2448
|
+
/**
|
|
2449
|
+
* Dim message - less important information
|
|
2450
|
+
*/
|
|
2451
|
+
dim: (message, indent = 0) => {
|
|
2452
|
+
const spaces = " ".repeat(indent);
|
|
2453
|
+
console.log(`${spaces}${dim2(customTransform(message))}`);
|
|
2454
|
+
},
|
|
2455
|
+
/**
|
|
2456
|
+
* Success message - operation completed successfully
|
|
2457
|
+
*/
|
|
2458
|
+
success: (message, indent = 0) => {
|
|
2459
|
+
const spaces = " ".repeat(indent);
|
|
2460
|
+
console.log(`${spaces}${green("\u2714")} ${bold2(customTransform(message))}`);
|
|
2461
|
+
},
|
|
2462
|
+
remark: (message, indent = 0) => {
|
|
2463
|
+
const spaces = " ".repeat(indent);
|
|
2464
|
+
console.log(`${spaces}${bold2(yellowBright("\u2726"))} ${bold2(customTransform(message))}`);
|
|
2465
|
+
},
|
|
2466
|
+
/**
|
|
2467
|
+
* Error message - operation failed
|
|
2468
|
+
*/
|
|
2469
|
+
error: (message, indent = 0) => {
|
|
2470
|
+
const spaces = " ".repeat(indent);
|
|
2471
|
+
console.error(`${spaces}${red("\u2716")} ${customTransform(message)}`);
|
|
2472
|
+
},
|
|
2473
|
+
bold: (message, indent = 0) => {
|
|
2474
|
+
const spaces = " ".repeat(indent);
|
|
2475
|
+
console.log(`${spaces}${bold2(customTransform(message))}`);
|
|
2476
|
+
},
|
|
2477
|
+
/**
|
|
2478
|
+
* Warning message - something to be aware of
|
|
2479
|
+
*/
|
|
2480
|
+
warn: (message, indent = 0) => {
|
|
2481
|
+
const spaces = " ".repeat(indent);
|
|
2482
|
+
console.warn(`${spaces}${yellow("\u26A0")} ${bold2(customTransform(message))}`);
|
|
2483
|
+
},
|
|
2484
|
+
/**
|
|
2485
|
+
* Debug message - only shown when DEBUG env var is set
|
|
2486
|
+
*/
|
|
2487
|
+
debug: (message, indent = 0) => {
|
|
2488
|
+
const spaces = " ".repeat(indent);
|
|
2489
|
+
if (process.env.DEBUG) {
|
|
2490
|
+
console.log(gray("[DEBUG]"), `${spaces}${message}`);
|
|
2491
|
+
}
|
|
2492
|
+
},
|
|
2493
|
+
/**
|
|
2494
|
+
* Step message - shows progress through a process
|
|
2495
|
+
*/
|
|
2496
|
+
step: (step, total, message, indent = 0) => {
|
|
2497
|
+
const spaces = " ".repeat(indent);
|
|
2498
|
+
console.log(spaces + cyan(`[${step}/${total}]`), customTransform(message));
|
|
2499
|
+
},
|
|
2500
|
+
/**
|
|
2501
|
+
* Highlighted message - draws attention
|
|
2502
|
+
*/
|
|
2503
|
+
highlight: (message, indent = 0) => {
|
|
2504
|
+
const spaces = " ".repeat(indent);
|
|
2505
|
+
console.log(bold2(`${spaces}${cyan(customTransform(message))}`));
|
|
2506
|
+
},
|
|
2507
|
+
/**
|
|
2508
|
+
* Aside message - for side information
|
|
2509
|
+
*/
|
|
2510
|
+
aside: (message, indent = 0) => {
|
|
2511
|
+
const spaces = " ".repeat(indent);
|
|
2512
|
+
console.log(`${spaces}${bold2(customTransform(message))}`);
|
|
2513
|
+
},
|
|
2514
|
+
/**
|
|
2515
|
+
* Data display - for structured data output
|
|
2516
|
+
*/
|
|
2517
|
+
data: (label, value, indent = 0) => {
|
|
2518
|
+
const spaces = " ".repeat(indent);
|
|
2519
|
+
if (value !== void 0) {
|
|
2520
|
+
console.log(`${spaces}${dim2(label + ":")} ${bold2(value)}`);
|
|
2521
|
+
} else {
|
|
2522
|
+
console.log(`${spaces}${dim2(label)}`);
|
|
2523
|
+
}
|
|
2524
|
+
},
|
|
2525
|
+
/**
|
|
2526
|
+
* JSON output - pretty-printed JSON
|
|
2527
|
+
*/
|
|
2528
|
+
json: (data, indent = 0) => {
|
|
2529
|
+
const spaces = " ".repeat(indent);
|
|
2530
|
+
const jsonString = colorize(JSON.stringify(data, null, 2));
|
|
2531
|
+
jsonString.split("\n").forEach((line) => {
|
|
2532
|
+
console.log(`${spaces}${line}`);
|
|
2533
|
+
});
|
|
2534
|
+
},
|
|
2535
|
+
/**
|
|
2536
|
+
* New line
|
|
2537
|
+
*/
|
|
2538
|
+
newLine: () => {
|
|
2539
|
+
console.log();
|
|
2540
|
+
},
|
|
2541
|
+
/**
|
|
2542
|
+
* Raw output - no formatting, useful for ASCII art or pre-formatted text
|
|
2543
|
+
*/
|
|
2544
|
+
raw: (text5, indent = 0) => {
|
|
2545
|
+
const spaces = " ".repeat(indent);
|
|
2546
|
+
console.log(`${spaces}${text5}`);
|
|
2547
|
+
},
|
|
2548
|
+
/**
|
|
2549
|
+
* Display a configuration error with helpful suggestions
|
|
2550
|
+
*/
|
|
2551
|
+
configError: (error, indent = 0) => {
|
|
2552
|
+
const spaces = " ".repeat(indent);
|
|
2553
|
+
const isConfigError = error && typeof error === "object" && "name" in error && error.name === "ConfigError";
|
|
2554
|
+
if (isConfigError && "message" in error && "field" in error && "suggestion" in error) {
|
|
2555
|
+
const configErr = error;
|
|
2556
|
+
console.error(`${spaces}${red("\u2716")} ${bold2(configErr.message)}`);
|
|
2557
|
+
if (configErr.field) {
|
|
2558
|
+
console.error(`${spaces} ${dim2("Field:")} ${configErr.field}`);
|
|
2559
|
+
}
|
|
2560
|
+
if (configErr.suggestion) {
|
|
2561
|
+
console.error(`${spaces} ${dim2("Fix:")} ${configErr.suggestion}`);
|
|
2562
|
+
}
|
|
2563
|
+
} else if (error instanceof Error) {
|
|
2564
|
+
console.error(`${spaces}${red("\u2716")} ${bold2(error.message)}`);
|
|
2565
|
+
} else {
|
|
2566
|
+
console.error(`${spaces}${red("\u2716")} ${bold2(String(error))}`);
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2571
|
+
});
|
|
2572
|
+
|
|
2364
2573
|
// src/lib/core/config.ts
|
|
2365
2574
|
function normalizeEnvironment(env) {
|
|
2366
2575
|
if (!env) return null;
|
|
@@ -2373,15 +2582,15 @@ function normalizeEnvironment(env) {
|
|
|
2373
2582
|
}
|
|
2374
2583
|
return null;
|
|
2375
2584
|
}
|
|
2376
|
-
function ensureEnvironment(env
|
|
2585
|
+
function ensureEnvironment(env) {
|
|
2377
2586
|
if (env) {
|
|
2378
2587
|
const normalized = normalizeEnvironment(env);
|
|
2379
2588
|
if (!normalized) {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2589
|
+
logger.newLine();
|
|
2590
|
+
logger.error(`Invalid environment: "${env}"`);
|
|
2591
|
+
logger.newLine();
|
|
2592
|
+
logger.remark("Valid environments: staging, production");
|
|
2593
|
+
logger.newLine();
|
|
2385
2594
|
process.exit(1);
|
|
2386
2595
|
}
|
|
2387
2596
|
setCliContext({ environment: normalized });
|
|
@@ -2421,6 +2630,7 @@ var init_config = __esm({
|
|
|
2421
2630
|
"use strict";
|
|
2422
2631
|
init_constants2();
|
|
2423
2632
|
init_context();
|
|
2633
|
+
init_logger();
|
|
2424
2634
|
}
|
|
2425
2635
|
});
|
|
2426
2636
|
|
|
@@ -3373,215 +3583,6 @@ var init_config2 = __esm({
|
|
|
3373
3583
|
}
|
|
3374
3584
|
});
|
|
3375
3585
|
|
|
3376
|
-
// src/lib/core/logger.ts
|
|
3377
|
-
import {
|
|
3378
|
-
blue,
|
|
3379
|
-
bold as bold2,
|
|
3380
|
-
cyan,
|
|
3381
|
-
dim as dim2,
|
|
3382
|
-
gray,
|
|
3383
|
-
green,
|
|
3384
|
-
greenBright,
|
|
3385
|
-
red,
|
|
3386
|
-
yellow,
|
|
3387
|
-
yellowBright
|
|
3388
|
-
} from "colorette";
|
|
3389
|
-
import { colorize } from "json-colorizer";
|
|
3390
|
-
function customTransform(text5) {
|
|
3391
|
-
const highlightCode = (text6) => text6.replace(/`([^`]+)`/g, (_, code) => greenBright(code));
|
|
3392
|
-
return highlightCode(text5);
|
|
3393
|
-
}
|
|
3394
|
-
function formatTable(data, title) {
|
|
3395
|
-
if (data.length === 0) return;
|
|
3396
|
-
const keys = Object.keys(data[0]);
|
|
3397
|
-
const rows = data.map((item) => keys.map((key) => String(item[key] ?? "")));
|
|
3398
|
-
const widths = keys.map((key, i) => {
|
|
3399
|
-
const headerWidth = key.length;
|
|
3400
|
-
const dataWidth = Math.max(...rows.map((row) => row[i].length));
|
|
3401
|
-
return Math.max(headerWidth, dataWidth);
|
|
3402
|
-
});
|
|
3403
|
-
const totalWidth = widths.reduce((sum, w) => sum + w + 3, -1);
|
|
3404
|
-
const separator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u253C") + "\u2524";
|
|
3405
|
-
const topBorder = "\u250C" + "\u2500".repeat(totalWidth) + "\u2510";
|
|
3406
|
-
const titleSeparator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u252C") + "\u2524";
|
|
3407
|
-
const bottomBorder = "\u2514" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u2534") + "\u2518";
|
|
3408
|
-
console.log(topBorder);
|
|
3409
|
-
if (title) {
|
|
3410
|
-
const titleText = bold2(title);
|
|
3411
|
-
const titlePadding = totalWidth - title.length - 1;
|
|
3412
|
-
const titleRow = "\u2502 " + titleText + " ".repeat(titlePadding) + "\u2502";
|
|
3413
|
-
console.log(titleRow);
|
|
3414
|
-
console.log(titleSeparator);
|
|
3415
|
-
}
|
|
3416
|
-
const header = "\u2502 " + keys.map((key, i) => key.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
|
|
3417
|
-
console.log(header);
|
|
3418
|
-
console.log(separator);
|
|
3419
|
-
rows.forEach((row) => {
|
|
3420
|
-
const dataRow = "\u2502 " + row.map((cell, i) => cell.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
|
|
3421
|
-
console.log(dataRow);
|
|
3422
|
-
});
|
|
3423
|
-
console.log(bottomBorder);
|
|
3424
|
-
}
|
|
3425
|
-
var logger;
|
|
3426
|
-
var init_logger = __esm({
|
|
3427
|
-
"src/lib/core/logger.ts"() {
|
|
3428
|
-
"use strict";
|
|
3429
|
-
logger = {
|
|
3430
|
-
table: (data, title) => {
|
|
3431
|
-
formatTable(data, title);
|
|
3432
|
-
},
|
|
3433
|
-
/**
|
|
3434
|
-
* Info message - general information
|
|
3435
|
-
*/
|
|
3436
|
-
info: (message, indent = 0) => {
|
|
3437
|
-
const spaces = " ".repeat(indent);
|
|
3438
|
-
console.log(`${spaces}${blue("\u2139")} ${bold2(customTransform(message))}`);
|
|
3439
|
-
},
|
|
3440
|
-
/**
|
|
3441
|
-
* Admonition - highlighted note/tip/warning box (Docusaurus-style)
|
|
3442
|
-
*/
|
|
3443
|
-
admonition: (type, title, lines, indent = 0) => {
|
|
3444
|
-
const spaces = " ".repeat(indent);
|
|
3445
|
-
const configs = {
|
|
3446
|
-
note: { color: green },
|
|
3447
|
-
tip: { color: cyan },
|
|
3448
|
-
info: { color: blue },
|
|
3449
|
-
warning: { color: yellow }
|
|
3450
|
-
};
|
|
3451
|
-
const { color: color2 } = configs[type];
|
|
3452
|
-
console.log(`${spaces}${color2("\u250C\u2500")} ${bold2(color2(title.toUpperCase()))}`);
|
|
3453
|
-
if (lines && lines.length > 0) {
|
|
3454
|
-
lines.forEach((line) => {
|
|
3455
|
-
console.log(`${spaces}${color2("\u2502")} ${customTransform(line)}`);
|
|
3456
|
-
});
|
|
3457
|
-
}
|
|
3458
|
-
console.log(`${spaces}${color2("\u2514\u2500")}`);
|
|
3459
|
-
},
|
|
3460
|
-
/**
|
|
3461
|
-
* Dim message - less important information
|
|
3462
|
-
*/
|
|
3463
|
-
dim: (message, indent = 0) => {
|
|
3464
|
-
const spaces = " ".repeat(indent);
|
|
3465
|
-
console.log(`${spaces}${dim2(customTransform(message))}`);
|
|
3466
|
-
},
|
|
3467
|
-
/**
|
|
3468
|
-
* Success message - operation completed successfully
|
|
3469
|
-
*/
|
|
3470
|
-
success: (message, indent = 0) => {
|
|
3471
|
-
const spaces = " ".repeat(indent);
|
|
3472
|
-
console.log(`${spaces}${green("\u2714")} ${bold2(customTransform(message))}`);
|
|
3473
|
-
},
|
|
3474
|
-
remark: (message, indent = 0) => {
|
|
3475
|
-
const spaces = " ".repeat(indent);
|
|
3476
|
-
console.log(`${spaces}${bold2(yellowBright("\u2726"))} ${bold2(customTransform(message))}`);
|
|
3477
|
-
},
|
|
3478
|
-
/**
|
|
3479
|
-
* Error message - operation failed
|
|
3480
|
-
*/
|
|
3481
|
-
error: (message, indent = 0) => {
|
|
3482
|
-
const spaces = " ".repeat(indent);
|
|
3483
|
-
console.error(`${spaces}${red("\u2716")} ${customTransform(message)}`);
|
|
3484
|
-
},
|
|
3485
|
-
bold: (message, indent = 0) => {
|
|
3486
|
-
const spaces = " ".repeat(indent);
|
|
3487
|
-
console.log(`${spaces}${bold2(customTransform(message))}`);
|
|
3488
|
-
},
|
|
3489
|
-
/**
|
|
3490
|
-
* Warning message - something to be aware of
|
|
3491
|
-
*/
|
|
3492
|
-
warn: (message, indent = 0) => {
|
|
3493
|
-
const spaces = " ".repeat(indent);
|
|
3494
|
-
console.warn(`${spaces}${yellow("\u26A0")} ${bold2(customTransform(message))}`);
|
|
3495
|
-
},
|
|
3496
|
-
/**
|
|
3497
|
-
* Debug message - only shown when DEBUG env var is set
|
|
3498
|
-
*/
|
|
3499
|
-
debug: (message, indent = 0) => {
|
|
3500
|
-
const spaces = " ".repeat(indent);
|
|
3501
|
-
if (process.env.DEBUG) {
|
|
3502
|
-
console.log(gray("[DEBUG]"), `${spaces}${message}`);
|
|
3503
|
-
}
|
|
3504
|
-
},
|
|
3505
|
-
/**
|
|
3506
|
-
* Step message - shows progress through a process
|
|
3507
|
-
*/
|
|
3508
|
-
step: (step, total, message, indent = 0) => {
|
|
3509
|
-
const spaces = " ".repeat(indent);
|
|
3510
|
-
console.log(spaces + cyan(`[${step}/${total}]`), customTransform(message));
|
|
3511
|
-
},
|
|
3512
|
-
/**
|
|
3513
|
-
* Highlighted message - draws attention
|
|
3514
|
-
*/
|
|
3515
|
-
highlight: (message, indent = 0) => {
|
|
3516
|
-
const spaces = " ".repeat(indent);
|
|
3517
|
-
console.log(bold2(`${spaces}${cyan(customTransform(message))}`));
|
|
3518
|
-
},
|
|
3519
|
-
/**
|
|
3520
|
-
* Aside message - for side information
|
|
3521
|
-
*/
|
|
3522
|
-
aside: (message, indent = 0) => {
|
|
3523
|
-
const spaces = " ".repeat(indent);
|
|
3524
|
-
console.log(`${spaces}${bold2(customTransform(message))}`);
|
|
3525
|
-
},
|
|
3526
|
-
/**
|
|
3527
|
-
* Data display - for structured data output
|
|
3528
|
-
*/
|
|
3529
|
-
data: (label, value, indent = 0) => {
|
|
3530
|
-
const spaces = " ".repeat(indent);
|
|
3531
|
-
if (value !== void 0) {
|
|
3532
|
-
console.log(`${spaces}${dim2(label + ":")} ${bold2(value)}`);
|
|
3533
|
-
} else {
|
|
3534
|
-
console.log(`${spaces}${dim2(label)}`);
|
|
3535
|
-
}
|
|
3536
|
-
},
|
|
3537
|
-
/**
|
|
3538
|
-
* JSON output - pretty-printed JSON
|
|
3539
|
-
*/
|
|
3540
|
-
json: (data, indent = 0) => {
|
|
3541
|
-
const spaces = " ".repeat(indent);
|
|
3542
|
-
const jsonString = colorize(JSON.stringify(data, null, 2));
|
|
3543
|
-
jsonString.split("\n").forEach((line) => {
|
|
3544
|
-
console.log(`${spaces}${line}`);
|
|
3545
|
-
});
|
|
3546
|
-
},
|
|
3547
|
-
/**
|
|
3548
|
-
* New line
|
|
3549
|
-
*/
|
|
3550
|
-
newLine: () => {
|
|
3551
|
-
console.log();
|
|
3552
|
-
},
|
|
3553
|
-
/**
|
|
3554
|
-
* Raw output - no formatting, useful for ASCII art or pre-formatted text
|
|
3555
|
-
*/
|
|
3556
|
-
raw: (text5, indent = 0) => {
|
|
3557
|
-
const spaces = " ".repeat(indent);
|
|
3558
|
-
console.log(`${spaces}${text5}`);
|
|
3559
|
-
},
|
|
3560
|
-
/**
|
|
3561
|
-
* Display a configuration error with helpful suggestions
|
|
3562
|
-
*/
|
|
3563
|
-
configError: (error, indent = 0) => {
|
|
3564
|
-
const spaces = " ".repeat(indent);
|
|
3565
|
-
const isConfigError = error && typeof error === "object" && "name" in error && error.name === "ConfigError";
|
|
3566
|
-
if (isConfigError && "message" in error && "field" in error && "suggestion" in error) {
|
|
3567
|
-
const configErr = error;
|
|
3568
|
-
console.error(`${spaces}${red("\u2716")} ${bold2(configErr.message)}`);
|
|
3569
|
-
if (configErr.field) {
|
|
3570
|
-
console.error(`${spaces} ${dim2("Field:")} ${configErr.field}`);
|
|
3571
|
-
}
|
|
3572
|
-
if (configErr.suggestion) {
|
|
3573
|
-
console.error(`${spaces} ${dim2("Fix:")} ${configErr.suggestion}`);
|
|
3574
|
-
}
|
|
3575
|
-
} else if (error instanceof Error) {
|
|
3576
|
-
console.error(`${spaces}${red("\u2716")} ${bold2(error.message)}`);
|
|
3577
|
-
} else {
|
|
3578
|
-
console.error(`${spaces}${red("\u2716")} ${bold2(String(error))}`);
|
|
3579
|
-
}
|
|
3580
|
-
}
|
|
3581
|
-
};
|
|
3582
|
-
}
|
|
3583
|
-
});
|
|
3584
|
-
|
|
3585
3586
|
// src/lib/core/client.ts
|
|
3586
3587
|
import { PlaycademyClient } from "@playcademy/sdk";
|
|
3587
3588
|
async function createClient() {
|
|
@@ -4727,7 +4728,7 @@ async function setupPackageJson(workspace, gameName) {
|
|
|
4727
4728
|
const slugifiedName = generateSlug(gameName);
|
|
4728
4729
|
const packageContent = packageTemplate.replace("{{GAME_NAME}}", slugifiedName);
|
|
4729
4730
|
writeFileSync2(pkgPath, packageContent);
|
|
4730
|
-
logger.
|
|
4731
|
+
logger.success("Created package.json");
|
|
4731
4732
|
return true;
|
|
4732
4733
|
}
|
|
4733
4734
|
}
|
|
@@ -6397,7 +6398,7 @@ async function selectEnvironment(options) {
|
|
|
6397
6398
|
const authenticatedEnvs = await getAuthenticatedEnvironments();
|
|
6398
6399
|
if (authenticatedEnvs.length === 1) {
|
|
6399
6400
|
environment = authenticatedEnvs[0];
|
|
6400
|
-
logger.
|
|
6401
|
+
logger.remark(`Deploying to ${environment}`, 1);
|
|
6401
6402
|
} else if (authenticatedEnvs.length === 2 && !options.dryRun) {
|
|
6402
6403
|
logger.newLine();
|
|
6403
6404
|
environment = await select2({
|
|
@@ -7992,19 +7993,19 @@ function displayConfigPreview(config, logger2) {
|
|
|
7992
7993
|
logger2.newLine();
|
|
7993
7994
|
logger2.highlight("Dry Run");
|
|
7994
7995
|
logger2.newLine();
|
|
7995
|
-
logger2.
|
|
7996
|
+
logger2.highlight("Organization");
|
|
7996
7997
|
logger2.data("Name", config.organization.name, 1);
|
|
7997
7998
|
logger2.data("Type", config.organization.type, 1);
|
|
7998
7999
|
logger2.data("ID", config.organization.identifier, 1);
|
|
7999
8000
|
logger2.newLine();
|
|
8000
|
-
logger2.
|
|
8001
|
+
logger2.highlight("Course");
|
|
8001
8002
|
logger2.data("Title", config.course.title, 1);
|
|
8002
8003
|
logger2.data("Code", config.course.courseCode, 1);
|
|
8003
8004
|
logger2.data("Subjects", config.course.subjects.join(", "), 1);
|
|
8004
8005
|
logger2.data("Grades", config.course.grades.join(", "), 1);
|
|
8005
8006
|
logger2.data("Level", config.course.level, 1);
|
|
8006
8007
|
logger2.newLine();
|
|
8007
|
-
logger2.
|
|
8008
|
+
logger2.highlight("Resource");
|
|
8008
8009
|
logger2.data("Title", config.resource.title, 1);
|
|
8009
8010
|
logger2.data("Launch URL", config.resource.metadata.launchUrl, 1);
|
|
8010
8011
|
logger2.newLine();
|
|
@@ -8246,7 +8247,7 @@ import { Command as Command3 } from "commander";
|
|
|
8246
8247
|
import open from "open";
|
|
8247
8248
|
var loginCommand = new Command3("login").description("Authenticate with Playcademy").option("-e, --email <email>", "Email address (for email/password auth)").option("-p, --password <password>", "Password (for email/password auth)").option("--sso", "Use Timeback SSO authentication").option("--env <environment>", "Environment to login to (staging or production)").action(async (options) => {
|
|
8248
8249
|
const { email, password: password2, sso, env } = options;
|
|
8249
|
-
const environment = ensureEnvironment(env
|
|
8250
|
+
const environment = ensureEnvironment(env);
|
|
8250
8251
|
const profileName = getProfileName();
|
|
8251
8252
|
logger.newLine();
|
|
8252
8253
|
const existingProfile = await getProfile(environment, profileName);
|
|
@@ -8437,14 +8438,14 @@ async function promptForPassword() {
|
|
|
8437
8438
|
import { Command as Command4 } from "commander";
|
|
8438
8439
|
var logoutCommand = new Command4("logout").description("Log out from Playcademy").argument("[profile]", "Profile name to logout from", "default").option("--env <environment>", "Environment to logout from (staging or production)").action(async (profileName, options) => {
|
|
8439
8440
|
const { env } = options;
|
|
8440
|
-
const environment = ensureEnvironment(env
|
|
8441
|
+
const environment = ensureEnvironment(env);
|
|
8441
8442
|
try {
|
|
8442
8443
|
logger.newLine();
|
|
8443
8444
|
const profile = await getProfile(environment, profileName);
|
|
8444
8445
|
if (!profile) {
|
|
8445
8446
|
logger.error(`Profile "${profileName}" not found in ${environment}`);
|
|
8446
8447
|
logger.newLine();
|
|
8447
|
-
logger.
|
|
8448
|
+
logger.remark("Use `playcademy profiles list` to see available profiles");
|
|
8448
8449
|
logger.newLine();
|
|
8449
8450
|
process.exit(1);
|
|
8450
8451
|
}
|
|
@@ -8467,7 +8468,7 @@ var meCommand = new Command5("me").description("Display current user information
|
|
|
8467
8468
|
).action(async (options) => {
|
|
8468
8469
|
const { env } = options;
|
|
8469
8470
|
try {
|
|
8470
|
-
const environment = ensureEnvironment(env
|
|
8471
|
+
const environment = ensureEnvironment(env);
|
|
8471
8472
|
const client = await requireAuthenticatedClient();
|
|
8472
8473
|
logger.newLine();
|
|
8473
8474
|
const user = await runStep(
|
|
@@ -8525,7 +8526,7 @@ async function executeDeployment(plan, context2, environment) {
|
|
|
8525
8526
|
return { game, backendDeployment };
|
|
8526
8527
|
}
|
|
8527
8528
|
async function runDeployment(options) {
|
|
8528
|
-
const environment = ensureEnvironment(options.env
|
|
8529
|
+
const environment = ensureEnvironment(options.env);
|
|
8529
8530
|
await selectEnvironment({ env: environment, dryRun: options.dryRun });
|
|
8530
8531
|
const context2 = await prepareDeploymentContext(options);
|
|
8531
8532
|
displayCurrentConfiguration(context2);
|
|
@@ -8592,7 +8593,7 @@ import { Command as Command7 } from "commander";
|
|
|
8592
8593
|
var deleteCommand = new Command7("delete").alias("rm").alias("remove").description("Delete a game").argument("[slug]", "Game slug to delete").option("-f, --force", "Skip confirmation prompt").option("--env <environment>", "Environment to delete game from (staging or production)").action(async (slug, options) => {
|
|
8593
8594
|
const { env } = options;
|
|
8594
8595
|
try {
|
|
8595
|
-
const environment = ensureEnvironment(env
|
|
8596
|
+
const environment = ensureEnvironment(env);
|
|
8596
8597
|
const client = await requireAuthenticatedClient();
|
|
8597
8598
|
logger.newLine();
|
|
8598
8599
|
const games2 = await runStep(
|
|
@@ -8601,7 +8602,9 @@ var deleteCommand = new Command7("delete").alias("rm").alias("remove").descripti
|
|
|
8601
8602
|
(games3) => `Found ${games3.length} ${pluralize(games3.length, "game")} in ${environment}`
|
|
8602
8603
|
);
|
|
8603
8604
|
if (games2.length === 0) {
|
|
8604
|
-
logger.
|
|
8605
|
+
logger.newLine();
|
|
8606
|
+
logger.remark(`No games found in ${environment}`);
|
|
8607
|
+
logger.newLine();
|
|
8605
8608
|
return;
|
|
8606
8609
|
}
|
|
8607
8610
|
logger.newLine();
|
|
@@ -8684,7 +8687,7 @@ import { Command as Command8 } from "commander";
|
|
|
8684
8687
|
var listCommand = new Command8("list").alias("ls").description("List all games").option("--env <environment>", "Environment to list games from (staging or production)").action(async (options) => {
|
|
8685
8688
|
const { env } = options;
|
|
8686
8689
|
try {
|
|
8687
|
-
const environment = ensureEnvironment(env
|
|
8690
|
+
const environment = ensureEnvironment(env);
|
|
8688
8691
|
const client = await requireAuthenticatedClient();
|
|
8689
8692
|
logger.newLine();
|
|
8690
8693
|
const games2 = await runStep(
|
|
@@ -8693,7 +8696,7 @@ var listCommand = new Command8("list").alias("ls").description("List all games")
|
|
|
8693
8696
|
(games3) => `Found ${games3.length} ${pluralize(games3.length, "game")} in ${environment}`
|
|
8694
8697
|
);
|
|
8695
8698
|
if (games2.length === 0) {
|
|
8696
|
-
logger.
|
|
8699
|
+
logger.remark("No games found");
|
|
8697
8700
|
logger.newLine();
|
|
8698
8701
|
return;
|
|
8699
8702
|
}
|
|
@@ -8732,7 +8735,7 @@ var applyCommand = new Command10("apply").description("Apply for developer statu
|
|
|
8732
8735
|
).action(async (options) => {
|
|
8733
8736
|
const { env } = options;
|
|
8734
8737
|
try {
|
|
8735
|
-
const environment = ensureEnvironment(env
|
|
8738
|
+
const environment = ensureEnvironment(env);
|
|
8736
8739
|
const client = await requireAuthenticatedClient();
|
|
8737
8740
|
logger.newLine();
|
|
8738
8741
|
const currentStatus = await runStep(
|
|
@@ -8783,7 +8786,7 @@ var getStatusCommand = new Command11("status").description("Check your developer
|
|
|
8783
8786
|
).action(async (options) => {
|
|
8784
8787
|
const { env } = options;
|
|
8785
8788
|
try {
|
|
8786
|
-
const environment = ensureEnvironment(env
|
|
8789
|
+
const environment = ensureEnvironment(env);
|
|
8787
8790
|
const client = await requireAuthenticatedClient();
|
|
8788
8791
|
logger.newLine();
|
|
8789
8792
|
const status = await runStep(
|
|
@@ -9018,27 +9021,17 @@ async function runDbDiff() {
|
|
|
9018
9021
|
}
|
|
9019
9022
|
|
|
9020
9023
|
// src/commands/db/init.ts
|
|
9021
|
-
init_file_loader();
|
|
9022
9024
|
init_constants2();
|
|
9023
|
-
import { readFileSync as readFileSync7, writeFileSync as writeFileSync9 } from "fs";
|
|
9024
9025
|
import { input as input6 } from "@inquirer/prompts";
|
|
9026
|
+
init_writer();
|
|
9027
|
+
init_loader2();
|
|
9028
|
+
var sampleCustomRouteTemplate2 = loadTemplateString("api/sample-custom.ts");
|
|
9029
|
+
var sampleDatabaseRouteTemplate2 = loadTemplateString("api/sample-database.ts");
|
|
9025
9030
|
async function runDbInit() {
|
|
9026
9031
|
try {
|
|
9027
9032
|
logger.newLine();
|
|
9028
|
-
const
|
|
9029
|
-
|
|
9030
|
-
maxLevels: 0
|
|
9031
|
-
});
|
|
9032
|
-
if (!configFile) {
|
|
9033
|
-
logger.error("No playcademy.config file found");
|
|
9034
|
-
logger.newLine();
|
|
9035
|
-
logger.admonition("tip", "Getting Started", [
|
|
9036
|
-
"Run `playcademy init` to create a config file first"
|
|
9037
|
-
]);
|
|
9038
|
-
logger.newLine();
|
|
9039
|
-
process.exit(1);
|
|
9040
|
-
}
|
|
9041
|
-
const config = await loadConfig(configFile.path);
|
|
9033
|
+
const config = await loadConfig();
|
|
9034
|
+
const configPath = await findConfigPath();
|
|
9042
9035
|
logger.highlight("Add Database");
|
|
9043
9036
|
logger.newLine();
|
|
9044
9037
|
const dbDir = await input6({
|
|
@@ -9055,35 +9048,41 @@ async function runDbInit() {
|
|
|
9055
9048
|
ensureRootGitignore();
|
|
9056
9049
|
await scaffoldDatabaseSetup({ gameName: config.name });
|
|
9057
9050
|
if (!config.integrations?.database) {
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
const parsed = JSON.parse(configContent);
|
|
9063
|
-
if (!parsed.integrations) parsed.integrations = {};
|
|
9064
|
-
parsed.integrations.database = { directory: dbDir };
|
|
9065
|
-
updatedContent = JSON.stringify(parsed, null, 4);
|
|
9066
|
-
} else {
|
|
9067
|
-
const dbConfig = `
|
|
9068
|
-
database: { directory: '${dbDir}' },`;
|
|
9069
|
-
if (configContent.includes("integrations:")) {
|
|
9070
|
-
updatedContent = configContent.replace(/(integrations:\s*{)/, `$1${dbConfig}`);
|
|
9071
|
-
} else {
|
|
9072
|
-
const integrationsConfig = `
|
|
9073
|
-
integrations: {${dbConfig}
|
|
9074
|
-
},`;
|
|
9075
|
-
updatedContent = configContent.replace(
|
|
9076
|
-
/(\n\s*})(\s*)$/,
|
|
9077
|
-
`${integrationsConfig}$1$2`
|
|
9078
|
-
);
|
|
9051
|
+
await updateConfigFile(configPath, {
|
|
9052
|
+
integrations: {
|
|
9053
|
+
...config.integrations,
|
|
9054
|
+
database: { directory: dbDir }
|
|
9079
9055
|
}
|
|
9080
|
-
}
|
|
9081
|
-
|
|
9082
|
-
logger.success(`Updated ${configFile.path.split("/").pop()}`);
|
|
9056
|
+
});
|
|
9057
|
+
logger.success(`Updated ${configPath.split("/").pop()}`);
|
|
9083
9058
|
}
|
|
9084
9059
|
logger.newLine();
|
|
9085
9060
|
logger.success("Database added!");
|
|
9086
9061
|
logger.newLine();
|
|
9062
|
+
if (!hasLocalCustomRoutes(getWorkspace(), config)) {
|
|
9063
|
+
const apiDirectory = await input6({
|
|
9064
|
+
message: " \u2514\u2500 API routes directory:",
|
|
9065
|
+
default: DEFAULT_API_ROUTES_DIRECTORY,
|
|
9066
|
+
validate: (value) => {
|
|
9067
|
+
if (!value || value.trim().length === 0) {
|
|
9068
|
+
return "Directory name is required";
|
|
9069
|
+
}
|
|
9070
|
+
return validateApiDirectoryDoesNotExist(value);
|
|
9071
|
+
}
|
|
9072
|
+
});
|
|
9073
|
+
await scaffoldApiDirectory(apiDirectory, [
|
|
9074
|
+
{ filename: "custom.ts", template: sampleCustomRouteTemplate2 },
|
|
9075
|
+
{ filename: "database.ts", template: sampleDatabaseRouteTemplate2 }
|
|
9076
|
+
]);
|
|
9077
|
+
await updateConfigFile(configPath, {
|
|
9078
|
+
integrations: {
|
|
9079
|
+
...config.integrations,
|
|
9080
|
+
customRoutes: { directory: apiDirectory }
|
|
9081
|
+
}
|
|
9082
|
+
});
|
|
9083
|
+
logger.success(`Added custom routes to ${configPath.split("/").pop()}`);
|
|
9084
|
+
logger.newLine();
|
|
9085
|
+
}
|
|
9087
9086
|
await ensurePlaycademyTypes();
|
|
9088
9087
|
logger.admonition("tip", "Next Steps", [
|
|
9089
9088
|
"1. Install dependencies: `bun install`",
|
|
@@ -9320,7 +9319,8 @@ async function runKVClear(options = {}) {
|
|
|
9320
9319
|
} else if (options.raw) {
|
|
9321
9320
|
logger.raw("0");
|
|
9322
9321
|
} else {
|
|
9323
|
-
logger.
|
|
9322
|
+
logger.newLine();
|
|
9323
|
+
logger.remark("No keys found in KV namespace");
|
|
9324
9324
|
logger.newLine();
|
|
9325
9325
|
}
|
|
9326
9326
|
return;
|
|
@@ -9333,7 +9333,7 @@ async function runKVClear(options = {}) {
|
|
|
9333
9333
|
default: false
|
|
9334
9334
|
});
|
|
9335
9335
|
if (!confirmed) {
|
|
9336
|
-
logger.
|
|
9336
|
+
logger.remark("Cancelled");
|
|
9337
9337
|
logger.newLine();
|
|
9338
9338
|
return;
|
|
9339
9339
|
}
|
|
@@ -9573,7 +9573,12 @@ async function runKVGet(key, options = {}) {
|
|
|
9573
9573
|
}
|
|
9574
9574
|
|
|
9575
9575
|
// src/commands/kv/init.ts
|
|
9576
|
+
init_constants2();
|
|
9577
|
+
import { input as input7 } from "@inquirer/prompts";
|
|
9576
9578
|
init_writer();
|
|
9579
|
+
init_loader2();
|
|
9580
|
+
var sampleCustomRouteTemplate3 = loadTemplateString("api/sample-custom.ts");
|
|
9581
|
+
var sampleKvRouteTemplate2 = loadTemplateString("api/sample-kv.ts");
|
|
9577
9582
|
async function runKVInit() {
|
|
9578
9583
|
try {
|
|
9579
9584
|
logger.newLine();
|
|
@@ -9601,28 +9606,37 @@ async function runKVInit() {
|
|
|
9601
9606
|
});
|
|
9602
9607
|
logger.success("Added KV integration to config");
|
|
9603
9608
|
logger.newLine();
|
|
9609
|
+
if (!hasLocalCustomRoutes(getWorkspace(), config)) {
|
|
9610
|
+
const apiDirectory = await input7({
|
|
9611
|
+
message: " \u2514\u2500 API routes directory:",
|
|
9612
|
+
default: DEFAULT_API_ROUTES_DIRECTORY,
|
|
9613
|
+
validate: (value) => {
|
|
9614
|
+
if (!value || value.trim().length === 0) {
|
|
9615
|
+
return "Directory name is required";
|
|
9616
|
+
}
|
|
9617
|
+
return validateApiDirectoryDoesNotExist(value);
|
|
9618
|
+
}
|
|
9619
|
+
});
|
|
9620
|
+
await scaffoldApiDirectory(apiDirectory, [
|
|
9621
|
+
{ filename: "custom.ts", template: sampleCustomRouteTemplate3 },
|
|
9622
|
+
{ filename: "kv.ts", template: sampleKvRouteTemplate2 }
|
|
9623
|
+
]);
|
|
9624
|
+
await updateConfigFile(configPath, {
|
|
9625
|
+
integrations: {
|
|
9626
|
+
...config.integrations,
|
|
9627
|
+
customRoutes: { directory: apiDirectory }
|
|
9628
|
+
}
|
|
9629
|
+
});
|
|
9630
|
+
logger.success("Added custom routes to config");
|
|
9631
|
+
logger.newLine();
|
|
9632
|
+
}
|
|
9604
9633
|
await ensurePlaycademyTypes();
|
|
9605
|
-
logger.admonition("tip", "
|
|
9606
|
-
"
|
|
9607
|
-
"",
|
|
9608
|
-
"
|
|
9609
|
-
"export async function GET(c: Context) {",
|
|
9610
|
-
" // Read from KV",
|
|
9611
|
-
` const data = await c.env.KV.get('user:123')`,
|
|
9612
|
-
"",
|
|
9613
|
-
" // Write to KV",
|
|
9614
|
-
` await c.env.KV.put('user:123', JSON.stringify({ score: 100 }))`,
|
|
9615
|
-
"",
|
|
9616
|
-
" // Delete from KV",
|
|
9617
|
-
` await c.env.KV.delete('user:123')`,
|
|
9618
|
-
"",
|
|
9619
|
-
" return c.json({ success: true })",
|
|
9620
|
-
"}",
|
|
9621
|
-
"```"
|
|
9634
|
+
logger.admonition("tip", "Next Steps", [
|
|
9635
|
+
"1. Use `c.env.KV` in your API routes",
|
|
9636
|
+
"2. Run `playcademy dev` to test locally",
|
|
9637
|
+
"3. Run `playcademy deploy`"
|
|
9622
9638
|
]);
|
|
9623
9639
|
logger.newLine();
|
|
9624
|
-
logger.remark("Run `playcademy dev` to start using KV in local development");
|
|
9625
|
-
logger.newLine();
|
|
9626
9640
|
} catch (error) {
|
|
9627
9641
|
logger.error(
|
|
9628
9642
|
`Failed to add KV integration: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -9837,7 +9851,7 @@ async function runKVList(options = {}) {
|
|
|
9837
9851
|
return;
|
|
9838
9852
|
}
|
|
9839
9853
|
if (keyNames.length === 0) {
|
|
9840
|
-
logger.
|
|
9854
|
+
logger.remark("No keys found in KV namespace");
|
|
9841
9855
|
} else {
|
|
9842
9856
|
logger.success(`Found ${keyNames.length} ${pluralize(keyNames.length, "key")}`);
|
|
9843
9857
|
logger.newLine();
|
|
@@ -9968,7 +9982,7 @@ async function runKVSeed(seedFile, options = {}) {
|
|
|
9968
9982
|
default: false
|
|
9969
9983
|
});
|
|
9970
9984
|
if (!confirmed) {
|
|
9971
|
-
logger.
|
|
9985
|
+
logger.remark("Cancelled");
|
|
9972
9986
|
logger.newLine();
|
|
9973
9987
|
return;
|
|
9974
9988
|
}
|
|
@@ -10218,7 +10232,7 @@ async function runKVStats(options = {}) {
|
|
|
10218
10232
|
logger.raw(stats.totalKeys.toString());
|
|
10219
10233
|
} else {
|
|
10220
10234
|
if (stats.totalKeys === 0) {
|
|
10221
|
-
logger.
|
|
10235
|
+
logger.remark("No keys found in KV namespace");
|
|
10222
10236
|
logger.newLine();
|
|
10223
10237
|
return;
|
|
10224
10238
|
}
|
|
@@ -10401,7 +10415,7 @@ async function runBucketDelete(key, options = {}) {
|
|
|
10401
10415
|
|
|
10402
10416
|
// src/commands/bucket/get.ts
|
|
10403
10417
|
init_constants2();
|
|
10404
|
-
import { writeFileSync as
|
|
10418
|
+
import { writeFileSync as writeFileSync9 } from "fs";
|
|
10405
10419
|
import { join as join31 } from "path";
|
|
10406
10420
|
import { Miniflare as Miniflare12 } from "miniflare";
|
|
10407
10421
|
async function runBucketGet(key, options = {}) {
|
|
@@ -10487,7 +10501,7 @@ async function runBucketGet(key, options = {}) {
|
|
|
10487
10501
|
}
|
|
10488
10502
|
if (options.output) {
|
|
10489
10503
|
const buffer = await object.arrayBuffer();
|
|
10490
|
-
|
|
10504
|
+
writeFileSync9(options.output, Buffer.from(buffer));
|
|
10491
10505
|
if (!options.raw) {
|
|
10492
10506
|
logger.success(`Downloaded '${key}' to '${options.output}'`);
|
|
10493
10507
|
logger.newLine();
|
|
@@ -10527,7 +10541,12 @@ async function runBucketGet(key, options = {}) {
|
|
|
10527
10541
|
}
|
|
10528
10542
|
|
|
10529
10543
|
// src/commands/bucket/init.ts
|
|
10544
|
+
init_constants2();
|
|
10545
|
+
import { input as input8 } from "@inquirer/prompts";
|
|
10530
10546
|
init_writer();
|
|
10547
|
+
init_loader2();
|
|
10548
|
+
var sampleCustomRouteTemplate4 = loadTemplateString("api/sample-custom.ts");
|
|
10549
|
+
var sampleBucketRouteTemplate2 = loadTemplateString("api/sample-bucket.ts");
|
|
10531
10550
|
async function runBucketInit() {
|
|
10532
10551
|
try {
|
|
10533
10552
|
logger.newLine();
|
|
@@ -10555,6 +10574,30 @@ async function runBucketInit() {
|
|
|
10555
10574
|
});
|
|
10556
10575
|
logger.success("Added bucket integration to config");
|
|
10557
10576
|
logger.newLine();
|
|
10577
|
+
if (!hasLocalCustomRoutes(getWorkspace(), config)) {
|
|
10578
|
+
const apiDirectory = await input8({
|
|
10579
|
+
message: " \u2514\u2500 API routes directory:",
|
|
10580
|
+
default: DEFAULT_API_ROUTES_DIRECTORY,
|
|
10581
|
+
validate: (value) => {
|
|
10582
|
+
if (!value || value.trim().length === 0) {
|
|
10583
|
+
return "Directory name is required";
|
|
10584
|
+
}
|
|
10585
|
+
return validateApiDirectoryDoesNotExist(value);
|
|
10586
|
+
}
|
|
10587
|
+
});
|
|
10588
|
+
await scaffoldApiDirectory(apiDirectory, [
|
|
10589
|
+
{ filename: "custom.ts", template: sampleCustomRouteTemplate4 },
|
|
10590
|
+
{ filename: "bucket.ts", template: sampleBucketRouteTemplate2 }
|
|
10591
|
+
]);
|
|
10592
|
+
await updateConfigFile(configPath, {
|
|
10593
|
+
integrations: {
|
|
10594
|
+
...config.integrations,
|
|
10595
|
+
customRoutes: { directory: apiDirectory }
|
|
10596
|
+
}
|
|
10597
|
+
});
|
|
10598
|
+
logger.success("Added custom routes to config");
|
|
10599
|
+
logger.newLine();
|
|
10600
|
+
}
|
|
10558
10601
|
await ensurePlaycademyTypes();
|
|
10559
10602
|
logger.admonition("tip", "Next Steps", [
|
|
10560
10603
|
"1. Use `c.env.BUCKET` in your API routes to upload/download files",
|
|
@@ -10642,7 +10685,7 @@ async function runBucketList(options = {}) {
|
|
|
10642
10685
|
return;
|
|
10643
10686
|
}
|
|
10644
10687
|
if (files.length === 0) {
|
|
10645
|
-
logger.
|
|
10688
|
+
logger.remark("No files found in bucket");
|
|
10646
10689
|
if (options.prefix) {
|
|
10647
10690
|
logger.newLine();
|
|
10648
10691
|
logger.data("Prefix", options.prefix, 1);
|
|
@@ -10692,7 +10735,7 @@ function formatBytes(bytes) {
|
|
|
10692
10735
|
|
|
10693
10736
|
// src/commands/bucket/put.ts
|
|
10694
10737
|
init_constants2();
|
|
10695
|
-
import { readFileSync as
|
|
10738
|
+
import { readFileSync as readFileSync7, statSync as statSync2 } from "fs";
|
|
10696
10739
|
import { join as join33 } from "path";
|
|
10697
10740
|
import { Miniflare as Miniflare14 } from "miniflare";
|
|
10698
10741
|
async function runBucketPut(key, filePath, options = {}) {
|
|
@@ -10737,7 +10780,7 @@ async function runBucketPut(key, filePath, options = {}) {
|
|
|
10737
10780
|
let fileBuffer;
|
|
10738
10781
|
let fileSize;
|
|
10739
10782
|
try {
|
|
10740
|
-
fileBuffer =
|
|
10783
|
+
fileBuffer = readFileSync7(filePath);
|
|
10741
10784
|
fileSize = statSync2(filePath).size;
|
|
10742
10785
|
} catch {
|
|
10743
10786
|
if (!options.raw && !options.json) {
|
|
@@ -10831,19 +10874,19 @@ var bucketCommand = new Command16("bucket").description("Manage bucket storage i
|
|
|
10831
10874
|
bucketCommand.help();
|
|
10832
10875
|
});
|
|
10833
10876
|
bucketCommand.command("init").description("Add bucket storage integration to your project").action(runBucketInit);
|
|
10834
|
-
bucketCommand.command("list").alias("ls").description("List files in local bucket
|
|
10877
|
+
bucketCommand.command("list").alias("ls").description("List files in local bucket").option("--prefix <prefix>", "Filter files by key prefix").option("--raw", "Output file keys one per line, no formatting").option("--json", "Output as JSON array").option("--remote", "Use remote bucket (not yet implemented)").option(
|
|
10835
10878
|
"--env <environment>",
|
|
10836
10879
|
"Environment to use with --remote: staging (default) or production"
|
|
10837
10880
|
).action(runBucketList);
|
|
10838
|
-
bucketCommand.command("get <key>").description("Download a file from local bucket
|
|
10881
|
+
bucketCommand.command("get <key>").description("Download a file from local bucket").option("-o, --output <path>", "Output file path (required for binary files)").option("--raw", "Output file content to stdout").option("--json", "Output metadata as JSON").option("--remote", "Use remote bucket (not yet implemented)").option(
|
|
10839
10882
|
"--env <environment>",
|
|
10840
10883
|
"Environment to use with --remote: staging (default) or production"
|
|
10841
10884
|
).action(runBucketGet);
|
|
10842
|
-
bucketCommand.command("put <key> <file>").description("Upload a file to local bucket
|
|
10885
|
+
bucketCommand.command("put <key> <file>").description("Upload a file to local bucket").option("--raw", "Output minimal confirmation").option("--json", "Output result as JSON").option("--remote", "Use remote bucket (not yet implemented)").option(
|
|
10843
10886
|
"--env <environment>",
|
|
10844
10887
|
"Environment to use with --remote: staging (default) or production"
|
|
10845
10888
|
).action(runBucketPut);
|
|
10846
|
-
bucketCommand.command("delete <key>").alias("del").alias("rm").description("Delete a file from local bucket
|
|
10889
|
+
bucketCommand.command("delete <key>").alias("del").alias("rm").description("Delete a file from local bucket").option("--raw", "Output minimal confirmation").option("--json", "Output result as JSON").option("--remote", "Use remote bucket (not yet implemented)").option(
|
|
10847
10890
|
"--env <environment>",
|
|
10848
10891
|
"Environment to use with --remote: staging (default) or production"
|
|
10849
10892
|
).action(runBucketDelete);
|
|
@@ -10902,7 +10945,7 @@ import { bold as bold6 } from "colorette";
|
|
|
10902
10945
|
import { Command as Command18 } from "commander";
|
|
10903
10946
|
var removeCommand = new Command18("remove").alias("rm").description('Remove an authentication profile (defaults to "default")').argument("[name]", "Profile name to remove", "default").option("--env <environment>", "Environment to remove profile from (staging or production)").action(async (name, options) => {
|
|
10904
10947
|
const { env } = options;
|
|
10905
|
-
const environment = ensureEnvironment(env
|
|
10948
|
+
const environment = ensureEnvironment(env);
|
|
10906
10949
|
try {
|
|
10907
10950
|
logger.newLine();
|
|
10908
10951
|
const profilesMap = await listProfiles();
|
|
@@ -10968,7 +11011,9 @@ var resetCommand = new Command19("reset").description(
|
|
|
10968
11011
|
default: false
|
|
10969
11012
|
});
|
|
10970
11013
|
if (!confirmed) {
|
|
10971
|
-
logger.
|
|
11014
|
+
logger.newLine();
|
|
11015
|
+
logger.remark("Operation cancelled");
|
|
11016
|
+
logger.newLine();
|
|
10972
11017
|
return;
|
|
10973
11018
|
}
|
|
10974
11019
|
let removedCount = 0;
|
|
@@ -11019,7 +11064,7 @@ var cleanupCommand = new Command21("cleanup").description("Remove TimeBack integ
|
|
|
11019
11064
|
).action(async (options) => {
|
|
11020
11065
|
const { env } = options;
|
|
11021
11066
|
try {
|
|
11022
|
-
const environment = ensureEnvironment(env
|
|
11067
|
+
const environment = ensureEnvironment(env);
|
|
11023
11068
|
const client = await requireAuthenticatedClient();
|
|
11024
11069
|
logger.newLine();
|
|
11025
11070
|
const { game } = await getGameFromConfig(client);
|
|
@@ -11125,7 +11170,7 @@ var setupCommand = new Command23("setup").description("Set up TimeBack integrati
|
|
|
11125
11170
|
).action(async (options) => {
|
|
11126
11171
|
const { env } = options;
|
|
11127
11172
|
try {
|
|
11128
|
-
ensureEnvironment(env
|
|
11173
|
+
ensureEnvironment(env);
|
|
11129
11174
|
logger.newLine();
|
|
11130
11175
|
const config = await runStep(
|
|
11131
11176
|
"Loading configuration",
|
|
@@ -11220,7 +11265,7 @@ var updateCommand = new Command24("update").description("Update TimeBack integra
|
|
|
11220
11265
|
).action(async (options) => {
|
|
11221
11266
|
const { env } = options;
|
|
11222
11267
|
try {
|
|
11223
|
-
ensureEnvironment(env
|
|
11268
|
+
ensureEnvironment(env);
|
|
11224
11269
|
const config = await runStep(
|
|
11225
11270
|
"Loading configuration",
|
|
11226
11271
|
loadConfig,
|
|
@@ -11338,7 +11383,7 @@ var verifyCommand = new Command25("verify").description("Verify TimeBack integra
|
|
|
11338
11383
|
"Environment to verify TimeBack integration in (staging or production)"
|
|
11339
11384
|
).action(async (options) => {
|
|
11340
11385
|
const { env } = options;
|
|
11341
|
-
const environment = ensureEnvironment(env
|
|
11386
|
+
const environment = ensureEnvironment(env);
|
|
11342
11387
|
try {
|
|
11343
11388
|
const client = await requireAuthenticatedClient();
|
|
11344
11389
|
logger.newLine();
|
|
@@ -11398,7 +11443,7 @@ import { Command as Command28 } from "commander";
|
|
|
11398
11443
|
// src/commands/debug/bundle.ts
|
|
11399
11444
|
init_src();
|
|
11400
11445
|
init_constants2();
|
|
11401
|
-
import { writeFileSync as
|
|
11446
|
+
import { writeFileSync as writeFileSync10 } from "fs";
|
|
11402
11447
|
import { join as join34 } from "path";
|
|
11403
11448
|
import { Command as Command27 } from "commander";
|
|
11404
11449
|
var bundleCommand = new Command27("bundle").description("Bundle and inspect the game backend worker code (for debugging)").option("-o, --output <path>", "Output file path", CLI_DEFAULT_OUTPUTS.WORKER_BUNDLE).option("--minify", "Minify the output").option("--sourcemap", "Include source maps").action(async (options) => {
|
|
@@ -11430,7 +11475,7 @@ var bundleCommand = new Command27("bundle").description("Bundle and inspect the
|
|
|
11430
11475
|
(result) => `Bundled ${formatSize(result.code.length)}`
|
|
11431
11476
|
);
|
|
11432
11477
|
const outputPath = join34(workspace, options.output);
|
|
11433
|
-
|
|
11478
|
+
writeFileSync10(outputPath, bundle.code, "utf-8");
|
|
11434
11479
|
logger.success(`Bundle saved to ${options.output}`);
|
|
11435
11480
|
logger.newLine();
|
|
11436
11481
|
logger.highlight("Bundle Analysis");
|