playcademy 0.16.3 → 0.16.4
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/cli.js +13 -3
- package/dist/constants/src/workers.ts +15 -0
- package/dist/db.d.ts +1 -0
- package/dist/db.js +22 -5
- package/dist/edge-play/src/entry/setup.ts +28 -3
- package/dist/index.d.ts +90 -9
- package/dist/index.js +1252 -899
- package/dist/utils.js +92 -16
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/utils.js
CHANGED
|
@@ -650,6 +650,14 @@ var BADGES = {
|
|
|
650
650
|
FIRST_GAME: ITEM_SLUGS.FIRST_GAME_BADGE
|
|
651
651
|
};
|
|
652
652
|
|
|
653
|
+
// ../constants/src/timeback.ts
|
|
654
|
+
var TIMEBACK_ROUTES = {
|
|
655
|
+
END_ACTIVITY: "/integrations/timeback/end-activity"
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// ../constants/src/workers.ts
|
|
659
|
+
var SECRETS_PREFIX = "secrets_";
|
|
660
|
+
|
|
653
661
|
// ../utils/src/package-manager.ts
|
|
654
662
|
import { execSync } from "child_process";
|
|
655
663
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -1311,6 +1319,27 @@ import { mkdir as mkdir2 } from "fs/promises";
|
|
|
1311
1319
|
import { join as join17 } from "path";
|
|
1312
1320
|
import { Log, LogLevel, Miniflare } from "miniflare";
|
|
1313
1321
|
|
|
1322
|
+
// ../edge-play/src/constants.ts
|
|
1323
|
+
var ROUTES = {
|
|
1324
|
+
/** Route index (lists available routes) */
|
|
1325
|
+
INDEX: "/api",
|
|
1326
|
+
/** Health check endpoint */
|
|
1327
|
+
HEALTH: "/api/health",
|
|
1328
|
+
/** TimeBack integration routes */
|
|
1329
|
+
TIMEBACK: {
|
|
1330
|
+
END_ACTIVITY: `/api${TIMEBACK_ROUTES.END_ACTIVITY}`
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
// ../edge-play/src/entry/setup.ts
|
|
1335
|
+
function prefixSecrets(secrets) {
|
|
1336
|
+
const prefixed = {};
|
|
1337
|
+
for (const [key, value] of Object.entries(secrets)) {
|
|
1338
|
+
prefixed[SECRETS_PREFIX + key] = value;
|
|
1339
|
+
}
|
|
1340
|
+
return prefixed;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1314
1343
|
// ../utils/src/port.ts
|
|
1315
1344
|
import { existsSync as existsSync3, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
1316
1345
|
import { createServer } from "node:net";
|
|
@@ -2327,7 +2356,7 @@ import { join as join12 } from "path";
|
|
|
2327
2356
|
// package.json with { type: 'json' }
|
|
2328
2357
|
var package_default2 = {
|
|
2329
2358
|
name: "playcademy",
|
|
2330
|
-
version: "0.16.
|
|
2359
|
+
version: "0.16.3",
|
|
2331
2360
|
type: "module",
|
|
2332
2361
|
exports: {
|
|
2333
2362
|
".": {
|
|
@@ -2464,6 +2493,43 @@ function hasLocalCustomRoutes(projectPath, config) {
|
|
|
2464
2493
|
return existsSync8(customRoutesDir);
|
|
2465
2494
|
}
|
|
2466
2495
|
|
|
2496
|
+
// src/lib/secrets/diff.ts
|
|
2497
|
+
import { green as green2, red as red2, yellow as yellow2 } from "colorette";
|
|
2498
|
+
|
|
2499
|
+
// src/lib/secrets/sync.ts
|
|
2500
|
+
import { confirm as confirm2 } from "@inquirer/prompts";
|
|
2501
|
+
import { bold as bold5 } from "colorette";
|
|
2502
|
+
|
|
2503
|
+
// src/lib/secrets/validate.ts
|
|
2504
|
+
var INTEGRATION_REQUIRED_SECRETS = {
|
|
2505
|
+
auth: {
|
|
2506
|
+
secrets: ["BETTER_AUTH_SECRET"],
|
|
2507
|
+
docs: "https://docs.playcademy.net/platform/integrations/authentication"
|
|
2508
|
+
}
|
|
2509
|
+
};
|
|
2510
|
+
function validateIntegrationSecrets(config, envSecrets) {
|
|
2511
|
+
const missing = [];
|
|
2512
|
+
if (!config?.integrations) {
|
|
2513
|
+
return missing;
|
|
2514
|
+
}
|
|
2515
|
+
for (const [integration, requirements] of Object.entries(INTEGRATION_REQUIRED_SECRETS)) {
|
|
2516
|
+
const isEnabled = config.integrations[integration];
|
|
2517
|
+
if (!isEnabled) {
|
|
2518
|
+
continue;
|
|
2519
|
+
}
|
|
2520
|
+
for (const secretKey of requirements.secrets) {
|
|
2521
|
+
if (!envSecrets[secretKey]) {
|
|
2522
|
+
missing.push({
|
|
2523
|
+
key: secretKey,
|
|
2524
|
+
integration,
|
|
2525
|
+
docs: requirements.docs
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
return missing;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2467
2533
|
// src/lib/init/tsconfig.ts
|
|
2468
2534
|
init_file_loader();
|
|
2469
2535
|
import { existsSync as existsSync9, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
@@ -2707,10 +2773,10 @@ import { downloadTemplate } from "giget";
|
|
|
2707
2773
|
|
|
2708
2774
|
// src/lib/init/engine/prompts.ts
|
|
2709
2775
|
import { select as select2 } from "@inquirer/prompts";
|
|
2710
|
-
import { cyan as cyan4, magenta as magenta2, yellow as
|
|
2776
|
+
import { cyan as cyan4, magenta as magenta2, yellow as yellow4 } from "colorette";
|
|
2711
2777
|
|
|
2712
2778
|
// src/lib/init/engine/registry.ts
|
|
2713
|
-
import { blue as blue2, cyan as cyan3, green as
|
|
2779
|
+
import { blue as blue2, cyan as cyan3, green as green3, magenta, red as red3, yellow as yellow3 } from "colorette";
|
|
2714
2780
|
|
|
2715
2781
|
// src/lib/init/engine/hooks.ts
|
|
2716
2782
|
import { existsSync as existsSync11, mkdirSync as mkdirSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
@@ -2777,7 +2843,7 @@ var viteFrameworks = [
|
|
|
2777
2843
|
{
|
|
2778
2844
|
id: "vanilla",
|
|
2779
2845
|
display: "Vanilla",
|
|
2780
|
-
color:
|
|
2846
|
+
color: yellow3,
|
|
2781
2847
|
templates: [
|
|
2782
2848
|
{
|
|
2783
2849
|
id: "vanilla-ts",
|
|
@@ -2805,7 +2871,7 @@ var viteFrameworks = [
|
|
|
2805
2871
|
{
|
|
2806
2872
|
id: "vue",
|
|
2807
2873
|
display: "Vue",
|
|
2808
|
-
color:
|
|
2874
|
+
color: green3,
|
|
2809
2875
|
templates: [
|
|
2810
2876
|
{
|
|
2811
2877
|
id: "vue-ts",
|
|
@@ -2819,7 +2885,7 @@ var viteFrameworks = [
|
|
|
2819
2885
|
{
|
|
2820
2886
|
id: "svelte",
|
|
2821
2887
|
display: "Svelte",
|
|
2822
|
-
color:
|
|
2888
|
+
color: red3,
|
|
2823
2889
|
templates: [
|
|
2824
2890
|
{
|
|
2825
2891
|
id: "svelte-ts",
|
|
@@ -2850,13 +2916,13 @@ var godotFrameworks = [
|
|
|
2850
2916
|
];
|
|
2851
2917
|
|
|
2852
2918
|
// src/lib/deploy/godot.ts
|
|
2853
|
-
import { confirm as
|
|
2919
|
+
import { confirm as confirm3, select as select3 } from "@inquirer/prompts";
|
|
2854
2920
|
|
|
2855
2921
|
// src/lib/init/project.ts
|
|
2856
|
-
import { confirm as
|
|
2922
|
+
import { confirm as confirm4, input as input2, select as select4 } from "@inquirer/prompts";
|
|
2857
2923
|
|
|
2858
2924
|
// src/lib/init/run.ts
|
|
2859
|
-
import { confirm as
|
|
2925
|
+
import { confirm as confirm5 } from "@inquirer/prompts";
|
|
2860
2926
|
init_file_loader();
|
|
2861
2927
|
|
|
2862
2928
|
// src/lib/dev/server.ts
|
|
@@ -2902,6 +2968,18 @@ async function startDevServer(options) {
|
|
|
2902
2968
|
const bucketDir = hasBucket ? await ensureBucketDirectory() : void 0;
|
|
2903
2969
|
const workspace = getWorkspace();
|
|
2904
2970
|
const envSecrets = await readEnvFile(workspace);
|
|
2971
|
+
const missingSecrets = validateIntegrationSecrets(config, envSecrets);
|
|
2972
|
+
if (missingSecrets.length > 0) {
|
|
2973
|
+
const missing = missingSecrets[0];
|
|
2974
|
+
logger.newLine();
|
|
2975
|
+
logger.admonition("warning", missing.key, [
|
|
2976
|
+
`The <${missing.integration}> integration requires \`${missing.key}\` to be set in <.env>`,
|
|
2977
|
+
"",
|
|
2978
|
+
`Learn more: <<${missing.docs}>>`
|
|
2979
|
+
]);
|
|
2980
|
+
logger.newLine();
|
|
2981
|
+
process.exit(1);
|
|
2982
|
+
}
|
|
2905
2983
|
const filteredLog = logger2 ? new FilteredLog(LogLevel.INFO, customLogger) : new Log(LogLevel.NONE);
|
|
2906
2984
|
const sandboxInfo = readServerInfo("sandbox", workspace);
|
|
2907
2985
|
const baseUrl = platformUrl ?? sandboxInfo?.url ?? process.env.PLAYCADEMY_BASE_URL ?? `http://localhost:${DEFAULT_PORTS.SANDBOX}`;
|
|
@@ -2909,11 +2987,9 @@ async function startDevServer(options) {
|
|
|
2909
2987
|
const bindings = {
|
|
2910
2988
|
PLAYCADEMY_API_KEY: process.env.PLAYCADEMY_API_KEY || "sandbox-game-backend-token",
|
|
2911
2989
|
GAME_ID: gameId,
|
|
2912
|
-
PLAYCADEMY_BASE_URL: baseUrl
|
|
2990
|
+
PLAYCADEMY_BASE_URL: baseUrl,
|
|
2991
|
+
...prefixSecrets(envSecrets)
|
|
2913
2992
|
};
|
|
2914
|
-
for (const [key, value] of Object.entries(envSecrets)) {
|
|
2915
|
-
bindings[`secrets_${key}`] = value;
|
|
2916
|
-
}
|
|
2917
2993
|
const mf = new Miniflare({
|
|
2918
2994
|
port,
|
|
2919
2995
|
log: filteredLog,
|
|
@@ -2994,7 +3070,7 @@ async function writeBackendServerInfo(port) {
|
|
|
2994
3070
|
// src/lib/dev/reload.ts
|
|
2995
3071
|
import { join as join18, relative as relative2 } from "path";
|
|
2996
3072
|
import chokidar from "chokidar";
|
|
2997
|
-
import { bold as
|
|
3073
|
+
import { bold as bold6, cyan as cyan5, dim as dim4, green as green4 } from "colorette";
|
|
2998
3074
|
function formatTime() {
|
|
2999
3075
|
const now = /* @__PURE__ */ new Date();
|
|
3000
3076
|
let hours = now.getHours();
|
|
@@ -3025,8 +3101,8 @@ function startHotReload(onReload, options = {}) {
|
|
|
3025
3101
|
if (changedPath) {
|
|
3026
3102
|
const relativePath = relative2(workspace, changedPath);
|
|
3027
3103
|
const timestamp = dim4(formatTime());
|
|
3028
|
-
const brand =
|
|
3029
|
-
const event = eventType === "changed" ?
|
|
3104
|
+
const brand = bold6(cyan5("[playcademy]"));
|
|
3105
|
+
const event = eventType === "changed" ? green4("reload") : green4(eventType || "reload");
|
|
3030
3106
|
console.log(`${timestamp} ${brand} ${event} ${dim4(relativePath)}`);
|
|
3031
3107
|
} else {
|
|
3032
3108
|
logger.success("Reloaded");
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playcademy",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@inquirer/prompts": "^7.8.6",
|
|
53
|
-
"@playcademy/sdk": "0.2.
|
|
53
|
+
"@playcademy/sdk": "0.2.11",
|
|
54
54
|
"chokidar": "^4.0.3",
|
|
55
55
|
"colorette": "^2.0.20",
|
|
56
56
|
"commander": "^14.0.1",
|