playcademy 0.14.21 → 0.14.22
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/constants.d.ts +20 -9
- package/dist/constants.js +20 -13
- package/dist/db.js +33 -27
- package/dist/index.js +179 -176
- package/dist/utils.js +73 -67
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2196,10 +2196,15 @@ function getAddDevDependencyCommand(pm, packageName) {
|
|
|
2196
2196
|
}
|
|
2197
2197
|
|
|
2198
2198
|
// src/constants/api.ts
|
|
2199
|
+
import { join as join3 } from "node:path";
|
|
2200
|
+
|
|
2201
|
+
// src/constants/server.ts
|
|
2199
2202
|
import { join as join2 } from "node:path";
|
|
2200
|
-
var DEFAULT_API_ROUTES_DIRECTORY = join2("server", "api");
|
|
2201
2203
|
var SERVER_ROOT_DIRECTORY = "server";
|
|
2202
|
-
var SERVER_LIB_DIRECTORY = join2(
|
|
2204
|
+
var SERVER_LIB_DIRECTORY = join2(SERVER_ROOT_DIRECTORY, "lib");
|
|
2205
|
+
|
|
2206
|
+
// src/constants/api.ts
|
|
2207
|
+
var DEFAULT_API_ROUTES_DIRECTORY = join3(SERVER_ROOT_DIRECTORY, "api");
|
|
2203
2208
|
var AUTH_API_SUBDIRECTORY = "auth";
|
|
2204
2209
|
var SAMPLE_API_SUBDIRECTORY = "sample";
|
|
2205
2210
|
var SAMPLE_CUSTOM_FILENAME = "custom.ts";
|
|
@@ -2363,8 +2368,8 @@ var CLOUDFLARE_BINDINGS = {
|
|
|
2363
2368
|
var MINIFLARE_D1_DIRECTORY = "miniflare-D1DatabaseObject";
|
|
2364
2369
|
|
|
2365
2370
|
// src/constants/database.ts
|
|
2366
|
-
import { join as
|
|
2367
|
-
var DEFAULT_DATABASE_DIRECTORY =
|
|
2371
|
+
import { join as join4 } from "path";
|
|
2372
|
+
var DEFAULT_DATABASE_DIRECTORY = join4("server", "db");
|
|
2368
2373
|
var SCHEMA_SUBDIRECTORY = "schema";
|
|
2369
2374
|
var DB_FILES = {
|
|
2370
2375
|
/** Index file name */
|
|
@@ -2381,7 +2386,7 @@ var DB_FILES = {
|
|
|
2381
2386
|
var DRIZZLE_CONFIG_FILES = ["drizzle.config.ts", "drizzle.config.js"];
|
|
2382
2387
|
|
|
2383
2388
|
// src/constants/godot.ts
|
|
2384
|
-
import { join as
|
|
2389
|
+
import { join as join5 } from "node:path";
|
|
2385
2390
|
var GODOT_PROJECT_FILE = "project.godot";
|
|
2386
2391
|
var GODOT_EXPORT_PRESETS_FILE = "export_presets.cfg";
|
|
2387
2392
|
var GODOT_WEB_PLATFORM = 'platform="Web"';
|
|
@@ -2389,13 +2394,13 @@ var GODOT_BUILD_DIRECTORIES = {
|
|
|
2389
2394
|
/** Root build directory (cleared before each export) */
|
|
2390
2395
|
ROOT: "build",
|
|
2391
2396
|
/** Web export subdirectory */
|
|
2392
|
-
WEB:
|
|
2397
|
+
WEB: join5("build", "web")
|
|
2393
2398
|
};
|
|
2394
2399
|
var GODOT_BUILD_OUTPUTS = {
|
|
2395
2400
|
/** Exported web build entry point */
|
|
2396
|
-
INDEX_HTML:
|
|
2401
|
+
INDEX_HTML: join5("build", "web", "index.html"),
|
|
2397
2402
|
/** Packaged zip file (created by Godot export) */
|
|
2398
|
-
ZIP:
|
|
2403
|
+
ZIP: join5("build", "web_playcademy.zip")
|
|
2399
2404
|
};
|
|
2400
2405
|
var GODOT_EXECUTABLE_PATTERNS = {
|
|
2401
2406
|
/** macOS app bundle suffix */
|
|
@@ -2418,17 +2423,17 @@ var CALLBACK_PATH = "/callback";
|
|
|
2418
2423
|
var SSO_AUTH_TIMEOUT_MS = 3e4;
|
|
2419
2424
|
|
|
2420
2425
|
// src/constants/paths.ts
|
|
2421
|
-
import { join as
|
|
2426
|
+
import { join as join6 } from "path";
|
|
2422
2427
|
var WORKSPACE_NAME = ".playcademy";
|
|
2423
2428
|
var CLI_DIRECTORIES = {
|
|
2424
2429
|
/** Root directory for CLI artifacts in workspace */
|
|
2425
2430
|
WORKSPACE: WORKSPACE_NAME,
|
|
2426
2431
|
/** Database directory within workspace */
|
|
2427
|
-
DATABASE:
|
|
2432
|
+
DATABASE: join6(WORKSPACE_NAME, "db"),
|
|
2428
2433
|
/** KV storage directory within workspace */
|
|
2429
|
-
KV:
|
|
2434
|
+
KV: join6(WORKSPACE_NAME, "kv"),
|
|
2430
2435
|
/** Bucket storage directory within workspace */
|
|
2431
|
-
BUCKET:
|
|
2436
|
+
BUCKET: join6(WORKSPACE_NAME, "bucket")
|
|
2432
2437
|
};
|
|
2433
2438
|
var CLI_USER_DIRECTORIES = {
|
|
2434
2439
|
/** User config directory for auth, games store, etc. */
|
|
@@ -2436,7 +2441,7 @@ var CLI_USER_DIRECTORIES = {
|
|
|
2436
2441
|
};
|
|
2437
2442
|
var CLI_DEFAULT_OUTPUTS = {
|
|
2438
2443
|
/** Default worker bundle output for debug command */
|
|
2439
|
-
WORKER_BUNDLE:
|
|
2444
|
+
WORKER_BUNDLE: join6(WORKSPACE_NAME, "worker-bundle.js")
|
|
2440
2445
|
};
|
|
2441
2446
|
var CLI_FILES = {
|
|
2442
2447
|
/** Auth store file in user config directory */
|
|
@@ -2471,7 +2476,7 @@ import { PlaycademyClient } from "@playcademy/sdk/internal";
|
|
|
2471
2476
|
// src/lib/auth/storage.ts
|
|
2472
2477
|
import { access, mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
2473
2478
|
import { homedir } from "node:os";
|
|
2474
|
-
import { join as
|
|
2479
|
+
import { join as join7 } from "node:path";
|
|
2475
2480
|
|
|
2476
2481
|
// src/lib/core/context.ts
|
|
2477
2482
|
import { existsSync as existsSync3 } from "fs";
|
|
@@ -3501,10 +3506,10 @@ function getWebBaseUrl(apiBaseUrl) {
|
|
|
3501
3506
|
|
|
3502
3507
|
// src/lib/auth/storage.ts
|
|
3503
3508
|
function getAuthPath() {
|
|
3504
|
-
return
|
|
3509
|
+
return join7(homedir(), CLI_USER_DIRECTORIES.CONFIG, CLI_FILES.AUTH_STORE);
|
|
3505
3510
|
}
|
|
3506
3511
|
async function ensureAuthDir() {
|
|
3507
|
-
const authDir =
|
|
3512
|
+
const authDir = join7(homedir(), CLI_USER_DIRECTORIES.CONFIG);
|
|
3508
3513
|
await mkdir(authDir, { recursive: true });
|
|
3509
3514
|
}
|
|
3510
3515
|
function createEmptyEnvironmentProfiles() {
|
|
@@ -3737,7 +3742,7 @@ function formatErrorAndExit(error, code = 1) {
|
|
|
3737
3742
|
// src/lib/secrets/env.ts
|
|
3738
3743
|
init_file_loader();
|
|
3739
3744
|
import { existsSync as existsSync4, writeFileSync } from "fs";
|
|
3740
|
-
import { join as
|
|
3745
|
+
import { join as join8 } from "path";
|
|
3741
3746
|
function parseEnvFile(contents) {
|
|
3742
3747
|
const secrets = {};
|
|
3743
3748
|
for (const line of contents.split("\n")) {
|
|
@@ -3773,13 +3778,13 @@ async function readEnvFile(workspace) {
|
|
|
3773
3778
|
return secrets;
|
|
3774
3779
|
}
|
|
3775
3780
|
function getLoadedEnvFiles(workspace) {
|
|
3776
|
-
return ENV_FILES.filter((filename) => existsSync4(
|
|
3781
|
+
return ENV_FILES.filter((filename) => existsSync4(join8(workspace, filename)));
|
|
3777
3782
|
}
|
|
3778
3783
|
function hasEnvFile(workspace) {
|
|
3779
|
-
return ENV_FILES.some((filename) => existsSync4(
|
|
3784
|
+
return ENV_FILES.some((filename) => existsSync4(join8(workspace, filename)));
|
|
3780
3785
|
}
|
|
3781
3786
|
async function updateEnvExample(workspace, lines) {
|
|
3782
|
-
const envExamplePath =
|
|
3787
|
+
const envExamplePath = join8(workspace, ENV_EXAMPLE_FILE);
|
|
3783
3788
|
let existing = "";
|
|
3784
3789
|
if (existsSync4(envExamplePath)) {
|
|
3785
3790
|
const loaded = await loadFile(envExamplePath);
|
|
@@ -5281,12 +5286,12 @@ async function getGameFromConfig(client) {
|
|
|
5281
5286
|
|
|
5282
5287
|
// src/lib/core/gitignore.ts
|
|
5283
5288
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
|
|
5284
|
-
import { join as
|
|
5289
|
+
import { join as join9, sep } from "path";
|
|
5285
5290
|
function normalizeGitignoreEntry(entry) {
|
|
5286
5291
|
return entry.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
5287
5292
|
}
|
|
5288
5293
|
function loadGitignorePatterns(directory) {
|
|
5289
|
-
const gitignorePath =
|
|
5294
|
+
const gitignorePath = join9(directory, ".gitignore");
|
|
5290
5295
|
if (!existsSync6(gitignorePath)) {
|
|
5291
5296
|
return [];
|
|
5292
5297
|
}
|
|
@@ -5327,12 +5332,12 @@ function isIgnoredByGitignore(filePath, patterns) {
|
|
|
5327
5332
|
// src/lib/core/import.ts
|
|
5328
5333
|
import { mkdtempSync, rmSync } from "fs";
|
|
5329
5334
|
import { tmpdir } from "os";
|
|
5330
|
-
import { join as
|
|
5335
|
+
import { join as join10 } from "path";
|
|
5331
5336
|
import { pathToFileURL } from "url";
|
|
5332
5337
|
import * as esbuild from "esbuild";
|
|
5333
5338
|
async function importTypescriptFile(filePath, bundleOptions) {
|
|
5334
|
-
const tempDir = mkdtempSync(
|
|
5335
|
-
const outFile =
|
|
5339
|
+
const tempDir = mkdtempSync(join10(tmpdir(), "playcademy-import-"));
|
|
5340
|
+
const outFile = join10(tempDir, "bundle.mjs");
|
|
5336
5341
|
try {
|
|
5337
5342
|
await esbuild.build({
|
|
5338
5343
|
entryPoints: [filePath],
|
|
@@ -5411,11 +5416,11 @@ import { bold as bold4, cyan as cyan2 } from "colorette";
|
|
|
5411
5416
|
|
|
5412
5417
|
// src/lib/init/scaffold.ts
|
|
5413
5418
|
import { existsSync as existsSync9, mkdirSync as mkdirSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
5414
|
-
import { join as
|
|
5419
|
+
import { join as join13, resolve as resolve5 } from "path";
|
|
5415
5420
|
|
|
5416
5421
|
// src/lib/init/auth.ts
|
|
5417
5422
|
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
5418
|
-
import { join as
|
|
5423
|
+
import { join as join11 } from "path";
|
|
5419
5424
|
var authTemplate = loadTemplateString("auth/auth.ts");
|
|
5420
5425
|
var authCatchAllTemplate = loadTemplateString("auth/auth-catch-all.ts");
|
|
5421
5426
|
var authSchemaTemplate = loadTemplateString("auth/auth-schema.ts");
|
|
@@ -5457,28 +5462,28 @@ function generateAuthConfig(strategies, gameName) {
|
|
|
5457
5462
|
return authContent;
|
|
5458
5463
|
}
|
|
5459
5464
|
function scaffoldAuthConfig(workspace, authContent) {
|
|
5460
|
-
const libDir =
|
|
5465
|
+
const libDir = join11(workspace, SERVER_LIB_DIRECTORY);
|
|
5461
5466
|
if (!existsSync7(libDir)) {
|
|
5462
5467
|
mkdirSync(libDir, { recursive: true });
|
|
5463
5468
|
}
|
|
5464
|
-
writeFileSync3(
|
|
5469
|
+
writeFileSync3(join11(libDir, AUTH_CONFIG_FILE), authContent);
|
|
5465
5470
|
}
|
|
5466
5471
|
function scaffoldAuthRoutes(workspace) {
|
|
5467
|
-
const apiDir =
|
|
5468
|
-
const authApiDir =
|
|
5472
|
+
const apiDir = join11(workspace, DEFAULT_API_ROUTES_DIRECTORY);
|
|
5473
|
+
const authApiDir = join11(apiDir, AUTH_API_SUBDIRECTORY);
|
|
5469
5474
|
if (!existsSync7(authApiDir)) {
|
|
5470
5475
|
mkdirSync(authApiDir, { recursive: true });
|
|
5471
5476
|
}
|
|
5472
|
-
writeFileSync3(
|
|
5477
|
+
writeFileSync3(join11(authApiDir, "[...all].ts"), authCatchAllTemplate);
|
|
5473
5478
|
}
|
|
5474
5479
|
function scaffoldAuthSchema(workspace) {
|
|
5475
|
-
const dbDir =
|
|
5476
|
-
const schemaDir =
|
|
5480
|
+
const dbDir = join11(workspace, DEFAULT_DATABASE_DIRECTORY);
|
|
5481
|
+
const schemaDir = join11(dbDir, SCHEMA_SUBDIRECTORY);
|
|
5477
5482
|
if (!existsSync7(schemaDir)) {
|
|
5478
5483
|
mkdirSync(schemaDir, { recursive: true });
|
|
5479
5484
|
}
|
|
5480
|
-
writeFileSync3(
|
|
5481
|
-
const schemaIndexPath =
|
|
5485
|
+
writeFileSync3(join11(schemaDir, "auth.ts"), authSchemaTemplate);
|
|
5486
|
+
const schemaIndexPath = join11(schemaDir, DB_FILES.SCHEMA_INDEX);
|
|
5482
5487
|
if (existsSync7(schemaIndexPath)) {
|
|
5483
5488
|
const existing = readFileSync4(schemaIndexPath, "utf-8");
|
|
5484
5489
|
if (!existing.includes("export * from './auth'")) {
|
|
@@ -5489,12 +5494,12 @@ function scaffoldAuthSchema(workspace) {
|
|
|
5489
5494
|
}
|
|
5490
5495
|
}
|
|
5491
5496
|
function scaffoldProtectedExample(workspace) {
|
|
5492
|
-
const apiDir =
|
|
5493
|
-
const sampleDir =
|
|
5497
|
+
const apiDir = join11(workspace, DEFAULT_API_ROUTES_DIRECTORY);
|
|
5498
|
+
const sampleDir = join11(apiDir, SAMPLE_API_SUBDIRECTORY);
|
|
5494
5499
|
if (!existsSync7(sampleDir)) {
|
|
5495
5500
|
mkdirSync(sampleDir, { recursive: true });
|
|
5496
5501
|
}
|
|
5497
|
-
writeFileSync3(
|
|
5502
|
+
writeFileSync3(join11(sampleDir, "protected.ts"), protectedRouteTemplate);
|
|
5498
5503
|
}
|
|
5499
5504
|
function updateEnvForAuth(workspace, strategies) {
|
|
5500
5505
|
const envLines = [];
|
|
@@ -5536,7 +5541,7 @@ async function scaffoldAuthSetup(options = {}) {
|
|
|
5536
5541
|
return packagesUpdated;
|
|
5537
5542
|
}
|
|
5538
5543
|
async function setupPackageJson(workspace) {
|
|
5539
|
-
const pkgPath =
|
|
5544
|
+
const pkgPath = join11(workspace, "package.json");
|
|
5540
5545
|
const authDeps = {
|
|
5541
5546
|
"@playcademy/better-auth": PLAYCADEMY_AUTH_VERSION,
|
|
5542
5547
|
"better-auth": BETTER_AUTH_VERSION
|
|
@@ -5557,18 +5562,18 @@ async function setupPackageJson(workspace) {
|
|
|
5557
5562
|
}
|
|
5558
5563
|
function hasAuthSetup() {
|
|
5559
5564
|
const workspace = getWorkspace();
|
|
5560
|
-
const authPath =
|
|
5565
|
+
const authPath = join11(workspace, SERVER_LIB_DIRECTORY, AUTH_CONFIG_FILE);
|
|
5561
5566
|
return existsSync7(authPath);
|
|
5562
5567
|
}
|
|
5563
5568
|
|
|
5564
5569
|
// src/lib/init/database.ts
|
|
5565
5570
|
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
5566
|
-
import { join as
|
|
5571
|
+
import { join as join12 } from "path";
|
|
5567
5572
|
|
|
5568
5573
|
// package.json
|
|
5569
5574
|
var package_default2 = {
|
|
5570
5575
|
name: "playcademy",
|
|
5571
|
-
version: "0.14.
|
|
5576
|
+
version: "0.14.21",
|
|
5572
5577
|
type: "module",
|
|
5573
5578
|
exports: {
|
|
5574
5579
|
".": {
|
|
@@ -5659,25 +5664,25 @@ async function scaffoldDatabaseSetup(options) {
|
|
|
5659
5664
|
await runStep(
|
|
5660
5665
|
"Configuring database...",
|
|
5661
5666
|
async () => {
|
|
5662
|
-
const dbDir =
|
|
5663
|
-
const schemaDir =
|
|
5667
|
+
const dbDir = join12(workspace, DEFAULT_DATABASE_DIRECTORY);
|
|
5668
|
+
const schemaDir = join12(dbDir, SCHEMA_SUBDIRECTORY);
|
|
5664
5669
|
if (!existsSync8(dbDir)) {
|
|
5665
5670
|
mkdirSync2(dbDir, { recursive: true });
|
|
5666
5671
|
}
|
|
5667
5672
|
if (!existsSync8(schemaDir)) {
|
|
5668
5673
|
mkdirSync2(schemaDir, { recursive: true });
|
|
5669
5674
|
}
|
|
5670
|
-
const exampleSchemaPath =
|
|
5675
|
+
const exampleSchemaPath = join12(schemaDir, DB_FILES.EXAMPLE_SCHEMA);
|
|
5671
5676
|
writeFileSync4(exampleSchemaPath, dbSchemaExampleTemplate);
|
|
5672
|
-
const schemaIndexPath =
|
|
5677
|
+
const schemaIndexPath = join12(schemaDir, DB_FILES.SCHEMA_INDEX);
|
|
5673
5678
|
writeFileSync4(schemaIndexPath, dbSchemaIndexTemplate);
|
|
5674
|
-
const dbIndexPath =
|
|
5679
|
+
const dbIndexPath = join12(dbDir, DB_FILES.INDEX);
|
|
5675
5680
|
writeFileSync4(dbIndexPath, dbIndexTemplate);
|
|
5676
|
-
const dbTypesPath =
|
|
5681
|
+
const dbTypesPath = join12(dbDir, DB_FILES.TYPES);
|
|
5677
5682
|
writeFileSync4(dbTypesPath, dbTypesTemplate);
|
|
5678
|
-
const dbSeedPath =
|
|
5683
|
+
const dbSeedPath = join12(dbDir, DB_FILES.SEED);
|
|
5679
5684
|
writeFileSync4(dbSeedPath, dbSeedTemplate);
|
|
5680
|
-
const drizzleConfigPath =
|
|
5685
|
+
const drizzleConfigPath = join12(workspace, DRIZZLE_CONFIG_FILES[0]);
|
|
5681
5686
|
writeFileSync4(drizzleConfigPath, drizzleConfigTemplate);
|
|
5682
5687
|
packagesUpdated = await setupPackageJson2(workspace, options.gameName);
|
|
5683
5688
|
},
|
|
@@ -5686,7 +5691,7 @@ async function scaffoldDatabaseSetup(options) {
|
|
|
5686
5691
|
return packagesUpdated;
|
|
5687
5692
|
}
|
|
5688
5693
|
async function setupPackageJson2(workspace, gameName) {
|
|
5689
|
-
const pkgPath =
|
|
5694
|
+
const pkgPath = join12(workspace, "package.json");
|
|
5690
5695
|
const dbDeps = {
|
|
5691
5696
|
"drizzle-orm": "^0.42.0",
|
|
5692
5697
|
"better-sqlite3": "^12.0.0"
|
|
@@ -5728,7 +5733,7 @@ async function setupPackageJson2(workspace, gameName) {
|
|
|
5728
5733
|
}
|
|
5729
5734
|
function hasDatabaseSetup() {
|
|
5730
5735
|
const workspace = getWorkspace();
|
|
5731
|
-
return DRIZZLE_CONFIG_FILES.some((filename) => existsSync8(
|
|
5736
|
+
return DRIZZLE_CONFIG_FILES.some((filename) => existsSync8(join12(workspace, filename)));
|
|
5732
5737
|
}
|
|
5733
5738
|
|
|
5734
5739
|
// src/lib/init/scaffold.ts
|
|
@@ -5739,7 +5744,7 @@ var sampleBucketRouteTemplate = loadTemplateString("api/sample-bucket.ts");
|
|
|
5739
5744
|
var playcademyGitignoreTemplate = loadTemplateString("playcademy-gitignore");
|
|
5740
5745
|
async function scaffoldApiDirectory(apiDirectory, sampleRoutes) {
|
|
5741
5746
|
const apiPath = resolve5(getWorkspace(), apiDirectory);
|
|
5742
|
-
const samplePath =
|
|
5747
|
+
const samplePath = join13(apiPath, "sample");
|
|
5743
5748
|
if (!existsSync9(apiPath)) {
|
|
5744
5749
|
mkdirSync3(apiPath, { recursive: true });
|
|
5745
5750
|
}
|
|
@@ -5747,7 +5752,7 @@ async function scaffoldApiDirectory(apiDirectory, sampleRoutes) {
|
|
|
5747
5752
|
mkdirSync3(samplePath, { recursive: true });
|
|
5748
5753
|
}
|
|
5749
5754
|
for (const route of sampleRoutes) {
|
|
5750
|
-
writeFileSync5(
|
|
5755
|
+
writeFileSync5(join13(samplePath, route.filename), route.template, "utf-8");
|
|
5751
5756
|
}
|
|
5752
5757
|
}
|
|
5753
5758
|
async function scaffoldSampleFileIfMissing(config, sampleFilename, template) {
|
|
@@ -5763,7 +5768,7 @@ async function scaffoldSampleFileIfMissing(config, sampleFilename, template) {
|
|
|
5763
5768
|
}
|
|
5764
5769
|
await scaffoldApiDirectory(customRoutesDir, [{ filename: sampleFilename, template }]);
|
|
5765
5770
|
logger.success(
|
|
5766
|
-
`Created sample route: <${
|
|
5771
|
+
`Created sample route: <${join13(customRoutesDir, SAMPLE_API_SUBDIRECTORY, sampleFilename)}>`
|
|
5767
5772
|
);
|
|
5768
5773
|
return true;
|
|
5769
5774
|
}
|
|
@@ -5776,11 +5781,11 @@ function validateApiDirectoryDoesNotExist(value) {
|
|
|
5776
5781
|
}
|
|
5777
5782
|
function ensurePlaycademyGitignore() {
|
|
5778
5783
|
const workspace = getWorkspace();
|
|
5779
|
-
const playcademyDir =
|
|
5784
|
+
const playcademyDir = join13(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
5780
5785
|
if (!existsSync9(playcademyDir)) {
|
|
5781
5786
|
mkdirSync3(playcademyDir, { recursive: true });
|
|
5782
5787
|
}
|
|
5783
|
-
const gitignorePath =
|
|
5788
|
+
const gitignorePath = join13(playcademyDir, ".gitignore");
|
|
5784
5789
|
writeFileSync5(gitignorePath, playcademyGitignoreTemplate);
|
|
5785
5790
|
}
|
|
5786
5791
|
async function scaffoldIntegrations(gameName, options) {
|
|
@@ -6095,16 +6100,16 @@ function hasBucketSetup(config) {
|
|
|
6095
6100
|
init_file_loader();
|
|
6096
6101
|
import { execSync as execSync3 } from "child_process";
|
|
6097
6102
|
import { existsSync as existsSync12, writeFileSync as writeFileSync7 } from "fs";
|
|
6098
|
-
import { dirname as dirname4, join as
|
|
6103
|
+
import { dirname as dirname4, join as join16 } from "path";
|
|
6099
6104
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6100
6105
|
|
|
6101
6106
|
// src/lib/deploy/backend.ts
|
|
6102
6107
|
import { existsSync as existsSync10 } from "node:fs";
|
|
6103
|
-
import { join as
|
|
6108
|
+
import { join as join14 } from "node:path";
|
|
6104
6109
|
function getCustomRoutesDirectory(projectPath, config) {
|
|
6105
6110
|
const customRoutes = config?.integrations?.customRoutes;
|
|
6106
6111
|
const customRoutesDir = typeof customRoutes === "object" && customRoutes.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
6107
|
-
return
|
|
6112
|
+
return join14(projectPath, customRoutesDir);
|
|
6108
6113
|
}
|
|
6109
6114
|
function hasLocalCustomRoutes(projectPath, config) {
|
|
6110
6115
|
const customRoutesDir = getCustomRoutesDirectory(projectPath, config);
|
|
@@ -6121,7 +6126,7 @@ async function hasBackendChanged(previousHash, currentHash) {
|
|
|
6121
6126
|
}
|
|
6122
6127
|
async function getDirectorySize(dirPath) {
|
|
6123
6128
|
const { stat: stat2, readdir } = await import("node:fs/promises");
|
|
6124
|
-
const { join:
|
|
6129
|
+
const { join: join50 } = await import("node:path");
|
|
6125
6130
|
if (!existsSync10(dirPath)) {
|
|
6126
6131
|
return null;
|
|
6127
6132
|
}
|
|
@@ -6130,7 +6135,7 @@ async function getDirectorySize(dirPath) {
|
|
|
6130
6135
|
async function calculateSize(dir) {
|
|
6131
6136
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
6132
6137
|
for (const entry of entries) {
|
|
6133
|
-
const fullPath =
|
|
6138
|
+
const fullPath = join50(dir, entry.name);
|
|
6134
6139
|
if (entry.isDirectory()) {
|
|
6135
6140
|
await calculateSize(fullPath);
|
|
6136
6141
|
} else if (entry.isFile()) {
|
|
@@ -6149,7 +6154,7 @@ async function getDirectorySize(dirPath) {
|
|
|
6149
6154
|
// src/lib/init/tsconfig.ts
|
|
6150
6155
|
init_file_loader();
|
|
6151
6156
|
import { existsSync as existsSync11, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
6152
|
-
import { join as
|
|
6157
|
+
import { join as join15 } from "path";
|
|
6153
6158
|
function hasPlaycademyEnv(config) {
|
|
6154
6159
|
return config.include?.includes("playcademy-env.d.ts") ?? false;
|
|
6155
6160
|
}
|
|
@@ -6206,7 +6211,7 @@ function addToIncludeArrayPreservingComments(content) {
|
|
|
6206
6211
|
}
|
|
6207
6212
|
async function ensureTsconfigIncludes(workspace) {
|
|
6208
6213
|
for (const filename of TSCONFIG_FILES) {
|
|
6209
|
-
const configPath =
|
|
6214
|
+
const configPath = join15(workspace, filename);
|
|
6210
6215
|
if (!existsSync11(configPath)) {
|
|
6211
6216
|
continue;
|
|
6212
6217
|
}
|
|
@@ -6256,8 +6261,8 @@ function hasAnyBackend(features) {
|
|
|
6256
6261
|
return Object.values(features).some(Boolean);
|
|
6257
6262
|
}
|
|
6258
6263
|
async function setupPlaycademyDependencies(workspace) {
|
|
6259
|
-
const playcademyDir =
|
|
6260
|
-
const playcademyPkgPath =
|
|
6264
|
+
const playcademyDir = join16(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
6265
|
+
const playcademyPkgPath = join16(playcademyDir, "package.json");
|
|
6261
6266
|
const __dirname2 = dirname4(fileURLToPath2(import.meta.url));
|
|
6262
6267
|
const cliPkg = await loadPackageJson({ cwd: __dirname2, searchUp: true, required: true });
|
|
6263
6268
|
const workersTypesVersion = cliPkg?.devDependencies?.["@cloudflare/workers-types"] || "latest";
|
|
@@ -6342,14 +6347,14 @@ async function ensurePlaycademyTypes(options = {}) {
|
|
|
6342
6347
|
const bindingsStr = generateBindingsTypeString(features);
|
|
6343
6348
|
const secretsStr = await generateSecretsTypeString(workspace, verbose);
|
|
6344
6349
|
const hasAuth = !!config.integrations?.auth;
|
|
6345
|
-
const hasAuthFile = existsSync12(
|
|
6350
|
+
const hasAuthFile = existsSync12(join16(workspace, "server/lib/auth.ts"));
|
|
6346
6351
|
const authVariablesString = generateAuthVariablesString(hasAuth, hasAuthFile);
|
|
6347
6352
|
let envContent = playcademyEnvTemplate.replace("{{BINDINGS}}", bindingsStr);
|
|
6348
6353
|
envContent = envContent.replace("{{SECRETS}}", secretsStr);
|
|
6349
6354
|
envContent = envContent.replace("{{AUTH_IMPORT}}", authVariablesString.authImport);
|
|
6350
6355
|
envContent = envContent.replace("{{VARIABLES}}", authVariablesString.variables);
|
|
6351
6356
|
envContent = envContent.replace("{{CONTEXT_VARS}}", authVariablesString.contextVars);
|
|
6352
|
-
const envPath =
|
|
6357
|
+
const envPath = join16(workspace, "playcademy-env.d.ts");
|
|
6353
6358
|
writeFileSync7(envPath, envContent);
|
|
6354
6359
|
if (verbose) {
|
|
6355
6360
|
logger.success(`Generated <playcademy-env.d.ts>`);
|
|
@@ -6367,10 +6372,10 @@ async function ensurePlaycademyTypes(options = {}) {
|
|
|
6367
6372
|
|
|
6368
6373
|
// src/lib/init/gitignore.ts
|
|
6369
6374
|
import { existsSync as existsSync13, readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
6370
|
-
import { join as
|
|
6375
|
+
import { join as join17 } from "path";
|
|
6371
6376
|
var rootGitignoreTemplate = loadTemplateString("gitignore");
|
|
6372
6377
|
function ensureRootGitignore(workspace = getWorkspace()) {
|
|
6373
|
-
const gitignorePath =
|
|
6378
|
+
const gitignorePath = join17(workspace, ".gitignore");
|
|
6374
6379
|
if (!existsSync13(gitignorePath)) {
|
|
6375
6380
|
writeFileSync8(gitignorePath, rootGitignoreTemplate);
|
|
6376
6381
|
return;
|
|
@@ -6532,7 +6537,7 @@ var integrationChangeDetectors = {
|
|
|
6532
6537
|
import { existsSync as existsSync14 } from "node:fs";
|
|
6533
6538
|
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
6534
6539
|
import { homedir as homedir2 } from "node:os";
|
|
6535
|
-
import { join as
|
|
6540
|
+
import { join as join18 } from "node:path";
|
|
6536
6541
|
|
|
6537
6542
|
// src/lib/deploy/hash.ts
|
|
6538
6543
|
init_file_loader();
|
|
@@ -6573,10 +6578,10 @@ function hashContent(content) {
|
|
|
6573
6578
|
|
|
6574
6579
|
// src/lib/games/storage.ts
|
|
6575
6580
|
function getGamesStorePath() {
|
|
6576
|
-
return
|
|
6581
|
+
return join18(homedir2(), CLI_USER_DIRECTORIES.CONFIG, CLI_FILES.GAMES_STORE);
|
|
6577
6582
|
}
|
|
6578
6583
|
async function ensureConfigDir() {
|
|
6579
|
-
const configDir =
|
|
6584
|
+
const configDir = join18(homedir2(), CLI_USER_DIRECTORIES.CONFIG);
|
|
6580
6585
|
await mkdir2(configDir, { recursive: true });
|
|
6581
6586
|
}
|
|
6582
6587
|
async function loadGameStore() {
|
|
@@ -6720,12 +6725,12 @@ async function saveDeploymentState(game, backendMetadata, context2) {
|
|
|
6720
6725
|
|
|
6721
6726
|
// src/lib/dev/backend.ts
|
|
6722
6727
|
import { existsSync as existsSync15 } from "fs";
|
|
6723
|
-
import { join as
|
|
6728
|
+
import { join as join19 } from "path";
|
|
6724
6729
|
function hasCustomRoutes(config) {
|
|
6725
6730
|
const workspace = getWorkspace();
|
|
6726
6731
|
const customRoutesConfig = config?.integrations?.customRoutes;
|
|
6727
6732
|
const customRoutesDir = typeof customRoutesConfig === "object" && customRoutesConfig.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
6728
|
-
return existsSync15(
|
|
6733
|
+
return existsSync15(join19(workspace, customRoutesDir));
|
|
6729
6734
|
}
|
|
6730
6735
|
function needsBackend(config) {
|
|
6731
6736
|
return !!config?.integrations || hasCustomRoutes(config);
|
|
@@ -6818,7 +6823,7 @@ function displayRegisteredRoutes(integrations, customRoutes = []) {
|
|
|
6818
6823
|
}
|
|
6819
6824
|
|
|
6820
6825
|
// src/lib/dev/reload.ts
|
|
6821
|
-
import { join as
|
|
6826
|
+
import { join as join20, relative } from "path";
|
|
6822
6827
|
import chokidar from "chokidar";
|
|
6823
6828
|
import { bold as bold5, cyan as cyan3, dim as dim5, green as green2 } from "colorette";
|
|
6824
6829
|
function formatTime() {
|
|
@@ -6835,9 +6840,9 @@ function startHotReload(onReload, options = {}) {
|
|
|
6835
6840
|
const customRoutesConfig = options.config?.integrations?.customRoutes;
|
|
6836
6841
|
const customRoutesDir = typeof customRoutesConfig === "object" && customRoutesConfig.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
6837
6842
|
const watchPaths = [
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6843
|
+
join20(workspace, customRoutesDir),
|
|
6844
|
+
join20(workspace, "playcademy.config.js"),
|
|
6845
|
+
join20(workspace, "playcademy.config.json")
|
|
6841
6846
|
];
|
|
6842
6847
|
const watcher = chokidar.watch(watchPaths, {
|
|
6843
6848
|
persistent: true,
|
|
@@ -6880,7 +6885,7 @@ function startHotReload(onReload, options = {}) {
|
|
|
6880
6885
|
init_file_loader();
|
|
6881
6886
|
import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
|
|
6882
6887
|
import { tmpdir as tmpdir2 } from "os";
|
|
6883
|
-
import { join as
|
|
6888
|
+
import { join as join21, relative as relative2 } from "path";
|
|
6884
6889
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
6885
6890
|
async function discoverRoutes(apiDir) {
|
|
6886
6891
|
const files = scanDirectory(apiDir, {
|
|
@@ -6890,8 +6895,8 @@ async function discoverRoutes(apiDir) {
|
|
|
6890
6895
|
const routes = await Promise.all(
|
|
6891
6896
|
files.map(async (file) => {
|
|
6892
6897
|
const routePath = filePathToRoutePath(file);
|
|
6893
|
-
const absolutePath =
|
|
6894
|
-
const relativePath = relative2(getWorkspace(), absolutePath);
|
|
6898
|
+
const absolutePath = join21(apiDir, file);
|
|
6899
|
+
const relativePath = relative2(getWorkspace(), absolutePath).replace(/\\/g, "/");
|
|
6895
6900
|
const methods = await detectExportedMethods(absolutePath);
|
|
6896
6901
|
return {
|
|
6897
6902
|
path: routePath,
|
|
@@ -6952,10 +6957,10 @@ async function transpileRoute(filePath) {
|
|
|
6952
6957
|
if (!result.outputFiles?.[0]) {
|
|
6953
6958
|
throw new Error("Transpilation failed: no output");
|
|
6954
6959
|
}
|
|
6955
|
-
const tempDir =
|
|
6960
|
+
const tempDir = join21(tmpdir2(), "playcademy-dev");
|
|
6956
6961
|
await mkdir3(tempDir, { recursive: true });
|
|
6957
6962
|
const hash = hashContent(filePath).slice(0, 12);
|
|
6958
|
-
const jsPath =
|
|
6963
|
+
const jsPath = join21(tempDir, `${hash}.mjs`);
|
|
6959
6964
|
await writeFile3(jsPath, result.outputFiles[0].text);
|
|
6960
6965
|
return jsPath;
|
|
6961
6966
|
}
|
|
@@ -6981,14 +6986,14 @@ async function registerCustomRoutes(app, routes) {
|
|
|
6981
6986
|
// src/lib/dev/server.ts
|
|
6982
6987
|
init_src();
|
|
6983
6988
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
6984
|
-
import { join as
|
|
6989
|
+
import { join as join24 } from "path";
|
|
6985
6990
|
import { Log, LogLevel, Miniflare } from "miniflare";
|
|
6986
6991
|
|
|
6987
6992
|
// ../utils/src/port.ts
|
|
6988
6993
|
import { existsSync as existsSync16, mkdirSync as mkdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync10 } from "node:fs";
|
|
6989
6994
|
import { createServer } from "node:net";
|
|
6990
6995
|
import { homedir as homedir3 } from "node:os";
|
|
6991
|
-
import { join as
|
|
6996
|
+
import { join as join22 } from "node:path";
|
|
6992
6997
|
async function isPortAvailableOnHost(port, host) {
|
|
6993
6998
|
return new Promise((resolve11) => {
|
|
6994
6999
|
const server = createServer();
|
|
@@ -7027,11 +7032,11 @@ async function findAvailablePort(startPort = 4321) {
|
|
|
7027
7032
|
}
|
|
7028
7033
|
function getRegistryPath() {
|
|
7029
7034
|
const home = homedir3();
|
|
7030
|
-
const dir =
|
|
7035
|
+
const dir = join22(home, ".playcademy");
|
|
7031
7036
|
if (!existsSync16(dir)) {
|
|
7032
7037
|
mkdirSync4(dir, { recursive: true });
|
|
7033
7038
|
}
|
|
7034
|
-
return
|
|
7039
|
+
return join22(dir, ".proc");
|
|
7035
7040
|
}
|
|
7036
7041
|
function readRegistry() {
|
|
7037
7042
|
const registryPath = getRegistryPath();
|
|
@@ -7122,7 +7127,7 @@ function cleanupServerInfo(type, projectRoot, pid) {
|
|
|
7122
7127
|
|
|
7123
7128
|
// src/lib/deploy/bundle.ts
|
|
7124
7129
|
import { existsSync as existsSync17 } from "fs";
|
|
7125
|
-
import { join as
|
|
7130
|
+
import { join as join23 } from "path";
|
|
7126
7131
|
|
|
7127
7132
|
// ../edge-play/src/entry.ts
|
|
7128
7133
|
var entry_default = "/**\n * Game Backend Entry Point\n *\n * This file is the main entry point for deployed game backends.\n * It creates a Hono app and registers all enabled integration routes.\n *\n * Bundled with esbuild and deployed to Cloudflare Workers (or AWS Lambda).\n * Config is injected at build time via esbuild's `define` option.\n *\n * DO NOT REMOVE any code wrapped by \u26A0\uFE0F BUILD_MARKER: <marker> \u26A0\uFE0F\n */\n\nimport { Hono } from 'hono'\n\nimport {\n registerApiNotFoundHandler,\n registerAssetFallback,\n registerCors,\n registerEnvSetup,\n registerPlaycademyUser,\n registerSdkInit,\n} from './entry/middleware'\nimport { setupProcessGlobal } from './entry/setup'\nimport { registerBuiltinRoutes } from './register-routes'\n\nimport type { RuntimeConfig } from './entry/types'\nimport type { HonoEnv } from './types'\n\n// DO NOT REMOVE THE BELOW COMMENT\n// \u26A0\uFE0F BUILD_MARKER: CUSTOM_ROUTE_IMPORTS \u26A0\uFE0F\n\n/**\n * Config injected at build time by esbuild\n *\n * The `declare const` tells TypeScript \"this exists at runtime, trust me.\"\n * During bundling, esbuild's `define` option does literal text replacement:\n *\n * Example bundling:\n * Source: if (PLAYCADEMY_CONFIG.integrations.timeback) { ... }\n * Define: { 'PLAYCADEMY_CONFIG': JSON.stringify({ integrations: { timeback: {...} } }) }\n * Output: if ({\"integrations\":{\"timeback\":{...}}}.integrations.timeback) { ... }\n *\n * This enables tree-shaking: if timeback is not configured, those code paths are removed.\n * The bundled Worker only includes the routes that are actually enabled.\n */\ndeclare const PLAYCADEMY_CONFIG: RuntimeConfig\n\n// Setup process global polyfill for SDK compatibility\nsetupProcessGlobal()\n\n// Create Hono app\nconst app = new Hono<HonoEnv>()\n\n// Register middleware\nregisterCors(app)\nregisterEnvSetup(app, PLAYCADEMY_CONFIG)\nregisterSdkInit(app, PLAYCADEMY_CONFIG)\nregisterPlaycademyUser(app)\n\n// DO NOT REMOVE THE BELOW COMMENT\n// \u26A0\uFE0F BUILD_MARKER: SESSION_MIDDLEWARE \u26A0\uFE0F\n\n// Register built-in integration routes based on enabled integrations\n// This function conditionally imports and registers routes like:\n// - GET /api (always included)\n// - GET /api/health (always included)\n// - POST /api/integrations/timeback/end-activity (if timeback enabled)\n//\n// Uses dynamic imports for tree-shaking: if an integration is not enabled,\n// its route code is completely removed from the bundle.\nawait registerBuiltinRoutes(app, PLAYCADEMY_CONFIG.integrations)\n\n// DO NOT REMOVE THE BELOW COMMENT\n// \u26A0\uFE0F BUILD_MARKER: CUSTOM_ROUTES \u26A0\uFE0F\n\n// Register API 404 handler\n// Returns JSON error for unmatched /api/* routes\n// Must be registered after all API routes\nregisterApiNotFoundHandler(app)\n\n// Register static asset fallback handler\n// Serves frontend assets from Workers Assets binding\n// MUST be registered last as it uses a wildcard GET route (app.get('*', ...))\n//\n// In production: Serves frontend assets from Workers Assets binding\n// In local dev: Returns 404 (Vite serves the frontend separately)\nregisterAssetFallback(app)\n\nexport default app\n";
|
|
@@ -7397,7 +7402,7 @@ async function discoverCustomRoutes(config) {
|
|
|
7397
7402
|
const workspace = getWorkspace();
|
|
7398
7403
|
const customRoutesConfig = config.integrations?.customRoutes;
|
|
7399
7404
|
const customRoutesDir = typeof customRoutesConfig === "object" && customRoutesConfig.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
7400
|
-
const customRoutes = await discoverRoutes(
|
|
7405
|
+
const customRoutes = await discoverRoutes(join23(workspace, customRoutesDir));
|
|
7401
7406
|
const customRouteData = customRoutes.map((r) => ({
|
|
7402
7407
|
path: r.path,
|
|
7403
7408
|
file: r.file,
|
|
@@ -7409,15 +7414,15 @@ async function discoverCustomRoutes(config) {
|
|
|
7409
7414
|
function resolveEmbeddedSourcePaths() {
|
|
7410
7415
|
const workspace = getWorkspace();
|
|
7411
7416
|
const distDir = new URL(".", import.meta.url).pathname;
|
|
7412
|
-
const embeddedEdgeSrc =
|
|
7417
|
+
const embeddedEdgeSrc = join23(distDir, "edge-play", "src");
|
|
7413
7418
|
const isBuiltPackage = existsSync17(embeddedEdgeSrc);
|
|
7414
7419
|
const monorepoRoot = getMonorepoRoot();
|
|
7415
|
-
const monorepoEdgeSrc =
|
|
7420
|
+
const monorepoEdgeSrc = join23(monorepoRoot, "packages/edge-play/src");
|
|
7416
7421
|
const edgePlaySrc = isBuiltPackage ? embeddedEdgeSrc : monorepoEdgeSrc;
|
|
7417
|
-
const cliPackageRoot = isBuiltPackage ?
|
|
7418
|
-
const cliNodeModules = isBuiltPackage ?
|
|
7419
|
-
const workspaceNodeModules =
|
|
7420
|
-
const constantsEntry = isBuiltPackage ?
|
|
7422
|
+
const cliPackageRoot = isBuiltPackage ? join23(distDir, "../../..") : join23(monorepoRoot, "packages/cli");
|
|
7423
|
+
const cliNodeModules = isBuiltPackage ? join23(cliPackageRoot, "node_modules") : monorepoRoot;
|
|
7424
|
+
const workspaceNodeModules = join23(workspace, "node_modules");
|
|
7425
|
+
const constantsEntry = isBuiltPackage ? join23(embeddedEdgeSrc, "..", "..", "constants", "src", "index.ts") : join23(monorepoRoot, "packages", "constants", "src", "index.ts");
|
|
7421
7426
|
return {
|
|
7422
7427
|
isBuiltPackage,
|
|
7423
7428
|
edgePlaySrc,
|
|
@@ -7482,22 +7487,22 @@ function createEsbuildConfig(entryCode, paths, bundleConfig, customRoutesDir, op
|
|
|
7482
7487
|
// │ Example: import * as route from '@game-api/hello.ts' │
|
|
7483
7488
|
// │ Resolves to: /user-project/server/api/hello.ts │
|
|
7484
7489
|
// └─────────────────────────────────────────────────────────────────┘
|
|
7485
|
-
"@game-api":
|
|
7490
|
+
"@game-api": join23(workspace, customRoutesDir),
|
|
7486
7491
|
// ┌─ User's server lib directory ───────────────────────────────────┐
|
|
7487
7492
|
// │ @game-server is a virtual module for server utilities/config │
|
|
7488
7493
|
// │ Example: import { getAuth } from '@game-server/lib/auth' │
|
|
7489
7494
|
// │ Resolves to: /user-project/server/lib/auth.ts │
|
|
7490
7495
|
// └─────────────────────────────────────────────────────────────────┘
|
|
7491
|
-
"@game-server":
|
|
7496
|
+
"@game-server": join23(workspace, "server"),
|
|
7492
7497
|
// ┌─ Node.js polyfills for Cloudflare Workers ──────────────────────┐
|
|
7493
7498
|
// │ Workers don't have fs, path, os, etc. Redirect to polyfills │
|
|
7494
7499
|
// │ that throw helpful errors if user code tries to use them. │
|
|
7495
7500
|
// └─────────────────────────────────────────────────────────────────┘
|
|
7496
|
-
fs:
|
|
7497
|
-
"fs/promises":
|
|
7498
|
-
path:
|
|
7499
|
-
os:
|
|
7500
|
-
process:
|
|
7501
|
+
fs: join23(edgePlaySrc, "polyfills.js"),
|
|
7502
|
+
"fs/promises": join23(edgePlaySrc, "polyfills.js"),
|
|
7503
|
+
path: join23(edgePlaySrc, "polyfills.js"),
|
|
7504
|
+
os: join23(edgePlaySrc, "polyfills.js"),
|
|
7505
|
+
process: join23(edgePlaySrc, "polyfills.js")
|
|
7501
7506
|
},
|
|
7502
7507
|
// ──── Build Plugins ────
|
|
7503
7508
|
plugins: [textLoaderPlugin()],
|
|
@@ -7665,7 +7670,7 @@ async function startDevServer(options) {
|
|
|
7665
7670
|
return { server: mf, port };
|
|
7666
7671
|
}
|
|
7667
7672
|
async function ensureDatabaseDirectory() {
|
|
7668
|
-
const dbDir =
|
|
7673
|
+
const dbDir = join24(getWorkspace(), CLI_DIRECTORIES.DATABASE);
|
|
7669
7674
|
try {
|
|
7670
7675
|
await mkdir4(dbDir, { recursive: true });
|
|
7671
7676
|
} catch (error) {
|
|
@@ -7674,7 +7679,7 @@ async function ensureDatabaseDirectory() {
|
|
|
7674
7679
|
return dbDir;
|
|
7675
7680
|
}
|
|
7676
7681
|
async function ensureKvDirectory() {
|
|
7677
|
-
const kvDir =
|
|
7682
|
+
const kvDir = join24(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
7678
7683
|
try {
|
|
7679
7684
|
await mkdir4(kvDir, { recursive: true });
|
|
7680
7685
|
} catch (error) {
|
|
@@ -7683,7 +7688,7 @@ async function ensureKvDirectory() {
|
|
|
7683
7688
|
return kvDir;
|
|
7684
7689
|
}
|
|
7685
7690
|
async function ensureBucketDirectory() {
|
|
7686
|
-
const bucketDir =
|
|
7691
|
+
const bucketDir = join24(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
7687
7692
|
try {
|
|
7688
7693
|
await mkdir4(bucketDir, { recursive: true });
|
|
7689
7694
|
} catch (error) {
|
|
@@ -8012,13 +8017,13 @@ function displayDeploymentDiff(options) {
|
|
|
8012
8017
|
// src/lib/deploy/godot.ts
|
|
8013
8018
|
import { execSync as execSync5 } from "child_process";
|
|
8014
8019
|
import { existsSync as existsSync18, mkdirSync as mkdirSync5, readFileSync as readFileSync10, rmSync as rmSync2 } from "fs";
|
|
8015
|
-
import { join as
|
|
8020
|
+
import { join as join25 } from "path";
|
|
8016
8021
|
import { confirm as confirm2, select as select2 } from "@inquirer/prompts";
|
|
8017
8022
|
function isGodotProject() {
|
|
8018
|
-
return existsSync18(
|
|
8023
|
+
return existsSync18(join25(getWorkspace(), GODOT_PROJECT_FILE));
|
|
8019
8024
|
}
|
|
8020
8025
|
function hasWebExportPreset() {
|
|
8021
|
-
const presetsPath =
|
|
8026
|
+
const presetsPath = join25(getWorkspace(), GODOT_EXPORT_PRESETS_FILE);
|
|
8022
8027
|
if (!existsSync18(presetsPath)) {
|
|
8023
8028
|
return { configured: false };
|
|
8024
8029
|
}
|
|
@@ -8074,7 +8079,7 @@ async function findGodotExecutable() {
|
|
|
8074
8079
|
const apps = result.split("\n").filter(Boolean);
|
|
8075
8080
|
for (const appPath of apps) {
|
|
8076
8081
|
if (seenAppBundles.has(appPath)) continue;
|
|
8077
|
-
const executable =
|
|
8082
|
+
const executable = join25(appPath, GODOT_EXECUTABLE_PATTERNS.MACOS_APP_EXECUTABLE);
|
|
8078
8083
|
const appName = appPath.split("/").pop() || "Godot";
|
|
8079
8084
|
foundExecutables.push({ path: executable, label: appName });
|
|
8080
8085
|
}
|
|
@@ -8136,11 +8141,11 @@ async function findGodotExecutable() {
|
|
|
8136
8141
|
async function runGodotExport(godotPath, presetName, outputPath) {
|
|
8137
8142
|
const root = getWorkspace();
|
|
8138
8143
|
try {
|
|
8139
|
-
const buildDir =
|
|
8144
|
+
const buildDir = join25(root, GODOT_BUILD_DIRECTORIES.ROOT);
|
|
8140
8145
|
if (existsSync18(buildDir)) {
|
|
8141
8146
|
rmSync2(buildDir, { recursive: true, force: true });
|
|
8142
8147
|
}
|
|
8143
|
-
mkdirSync5(
|
|
8148
|
+
mkdirSync5(join25(root, GODOT_BUILD_DIRECTORIES.WEB), { recursive: true });
|
|
8144
8149
|
await runStep(
|
|
8145
8150
|
`Exporting project using "${presetName}" preset`,
|
|
8146
8151
|
async () => {
|
|
@@ -8196,7 +8201,7 @@ async function handleGodotBuildPrompt() {
|
|
|
8196
8201
|
logger.newLine();
|
|
8197
8202
|
return null;
|
|
8198
8203
|
}
|
|
8199
|
-
if (existsSync18(
|
|
8204
|
+
if (existsSync18(join25(getWorkspace(), GODOT_BUILD_OUTPUTS.ZIP))) {
|
|
8200
8205
|
return GODOT_BUILD_OUTPUTS.ZIP;
|
|
8201
8206
|
}
|
|
8202
8207
|
logger.warn("Expected zip file not found, using build directory");
|
|
@@ -8209,10 +8214,10 @@ import { confirm as confirm3, input as input2, select as select3 } from "@inquir
|
|
|
8209
8214
|
|
|
8210
8215
|
// src/lib/deploy/build-discovery.ts
|
|
8211
8216
|
init_file_loader();
|
|
8212
|
-
import { join as
|
|
8217
|
+
import { join as join26, relative as relative3 } from "path";
|
|
8213
8218
|
function findSingleBuildZip() {
|
|
8214
8219
|
const workspace = getWorkspace();
|
|
8215
|
-
const playcademyDir =
|
|
8220
|
+
const playcademyDir = join26(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
8216
8221
|
const zipFiles = findFilesByExtension(playcademyDir, "zip");
|
|
8217
8222
|
if (zipFiles.length === 1) {
|
|
8218
8223
|
return zipFiles[0] ? relative3(workspace, zipFiles[0]) : null;
|
|
@@ -8223,7 +8228,7 @@ function findSingleBuildZip() {
|
|
|
8223
8228
|
// src/lib/deploy/schema.ts
|
|
8224
8229
|
import { existsSync as existsSync19 } from "fs";
|
|
8225
8230
|
import { createRequire } from "module";
|
|
8226
|
-
import { join as
|
|
8231
|
+
import { join as join27 } from "path";
|
|
8227
8232
|
async function getDatabaseDirectory() {
|
|
8228
8233
|
try {
|
|
8229
8234
|
const config = await loadConfig();
|
|
@@ -8251,7 +8256,7 @@ async function getSchemaInfo(previousSchemaSnapshot) {
|
|
|
8251
8256
|
return null;
|
|
8252
8257
|
}
|
|
8253
8258
|
const dbDirectory = await getDatabaseDirectory();
|
|
8254
|
-
const schemaPath =
|
|
8259
|
+
const schemaPath = join27(workspace, dbDirectory, SCHEMA_SUBDIRECTORY, DB_FILES.SCHEMA_INDEX);
|
|
8255
8260
|
if (!existsSync19(schemaPath)) {
|
|
8256
8261
|
return null;
|
|
8257
8262
|
}
|
|
@@ -8630,7 +8635,7 @@ function reportCancellation() {
|
|
|
8630
8635
|
|
|
8631
8636
|
// src/lib/deploy/preparation.ts
|
|
8632
8637
|
import { stat } from "node:fs/promises";
|
|
8633
|
-
import { join as
|
|
8638
|
+
import { join as join28 } from "node:path";
|
|
8634
8639
|
|
|
8635
8640
|
// ../data/src/domains/game/helpers.ts
|
|
8636
8641
|
var isHostedGame = (game) => {
|
|
@@ -9278,8 +9283,8 @@ async function analyzeChanges(context2) {
|
|
|
9278
9283
|
const bundle = await bundleBackend(context2.fullConfig);
|
|
9279
9284
|
const bundleHash = hashContent(bundle.code);
|
|
9280
9285
|
const [serverSize, dbSize] = await Promise.all([
|
|
9281
|
-
getDirectorySize(
|
|
9282
|
-
getDirectorySize(
|
|
9286
|
+
getDirectorySize(join28(projectPath, SERVER_ROOT_DIRECTORY)),
|
|
9287
|
+
getDirectorySize(join28(projectPath, DEFAULT_DATABASE_DIRECTORY))
|
|
9283
9288
|
]);
|
|
9284
9289
|
context2.currentBackendBundleHash = bundleHash;
|
|
9285
9290
|
context2.currentBackendSize = bundle.code.length;
|
|
@@ -9402,7 +9407,7 @@ function hasOptionalFieldsMissing(missing) {
|
|
|
9402
9407
|
// src/lib/deploy/steps.ts
|
|
9403
9408
|
import { existsSync as existsSync21 } from "fs";
|
|
9404
9409
|
import { readFile as readFile4 } from "fs/promises";
|
|
9405
|
-
import { basename as basename2, join as
|
|
9410
|
+
import { basename as basename2, join as join29, resolve as resolve8 } from "path";
|
|
9406
9411
|
|
|
9407
9412
|
// src/lib/deploy/stub.ts
|
|
9408
9413
|
import * as esbuild2 from "esbuild";
|
|
@@ -9619,8 +9624,8 @@ async function deployGame(context2, shouldUploadBuild, shouldDeployBackend) {
|
|
|
9619
9624
|
secrets: Object.keys(deploymentPrep.secrets).length > 0 ? deploymentPrep.secrets : void 0
|
|
9620
9625
|
};
|
|
9621
9626
|
const [serverSize, dbSize] = await Promise.all([
|
|
9622
|
-
getDirectorySize(
|
|
9623
|
-
getDirectorySize(
|
|
9627
|
+
getDirectorySize(join29(context2.projectPath, SERVER_ROOT_DIRECTORY)),
|
|
9628
|
+
getDirectorySize(join29(context2.projectPath, DEFAULT_DATABASE_DIRECTORY))
|
|
9624
9629
|
]);
|
|
9625
9630
|
backendMetadata = {
|
|
9626
9631
|
backendBundleHash: hashContent(bundle.code),
|
|
@@ -9681,7 +9686,7 @@ async function deployGame(context2, shouldUploadBuild, shouldDeployBackend) {
|
|
|
9681
9686
|
|
|
9682
9687
|
// src/lib/db/path.ts
|
|
9683
9688
|
import { copyFileSync, existsSync as existsSync22, mkdirSync as mkdirSync6, readdirSync as readdirSync2, unlinkSync } from "fs";
|
|
9684
|
-
import { join as
|
|
9689
|
+
import { join as join30 } from "path";
|
|
9685
9690
|
var DB_DIRECTORY = CLI_DIRECTORIES.DATABASE;
|
|
9686
9691
|
var INITIAL_DB_NAME = CLI_FILES.INITIAL_DATABASE;
|
|
9687
9692
|
var ensureDirectoryExists = (dir) => {
|
|
@@ -9690,11 +9695,11 @@ var ensureDirectoryExists = (dir) => {
|
|
|
9690
9695
|
}
|
|
9691
9696
|
};
|
|
9692
9697
|
var findMiniflareDatabase = (dbDir) => {
|
|
9693
|
-
const miniflareDir =
|
|
9698
|
+
const miniflareDir = join30(dbDir, MINIFLARE_D1_DIRECTORY);
|
|
9694
9699
|
if (!existsSync22(miniflareDir)) return null;
|
|
9695
9700
|
const sqliteFiles = readdirSync2(miniflareDir).filter((file) => file.endsWith(".sqlite"));
|
|
9696
9701
|
if (sqliteFiles.length === 0) return null;
|
|
9697
|
-
return
|
|
9702
|
+
return join30(miniflareDir, sqliteFiles[0]);
|
|
9698
9703
|
};
|
|
9699
9704
|
var migrateInitialDbToTarget = (initialPath, targetPath) => {
|
|
9700
9705
|
if (!existsSync22(initialPath)) return;
|
|
@@ -9702,7 +9707,7 @@ var migrateInitialDbToTarget = (initialPath, targetPath) => {
|
|
|
9702
9707
|
unlinkSync(initialPath);
|
|
9703
9708
|
};
|
|
9704
9709
|
function getDevDbPath() {
|
|
9705
|
-
const initialDbPath =
|
|
9710
|
+
const initialDbPath = join30(DB_DIRECTORY, INITIAL_DB_NAME);
|
|
9706
9711
|
ensureDirectoryExists(DB_DIRECTORY);
|
|
9707
9712
|
const miniflareDbPath = findMiniflareDatabase(DB_DIRECTORY);
|
|
9708
9713
|
if (miniflareDbPath) {
|
|
@@ -9766,10 +9771,10 @@ async function bundleSeedWorker(seedFilePath, projectPath) {
|
|
|
9766
9771
|
// src/lib/db/reset.ts
|
|
9767
9772
|
import { execSync as execSync6 } from "child_process";
|
|
9768
9773
|
import { rmSync as rmSync3 } from "fs";
|
|
9769
|
-
import { join as
|
|
9774
|
+
import { join as join31 } from "path";
|
|
9770
9775
|
async function resetDatabase(workspace, mf, options = { debug: false }) {
|
|
9771
9776
|
const { debug } = options;
|
|
9772
|
-
const dbDir =
|
|
9777
|
+
const dbDir = join31(workspace, CLI_DIRECTORIES.DATABASE);
|
|
9773
9778
|
await runStep(
|
|
9774
9779
|
"Resetting database...",
|
|
9775
9780
|
async () => {
|
|
@@ -10028,7 +10033,7 @@ import { dim as dim7 } from "colorette";
|
|
|
10028
10033
|
|
|
10029
10034
|
// src/lib/bucket/collect.ts
|
|
10030
10035
|
import { readdirSync as readdirSync3, statSync as statSync2 } from "fs";
|
|
10031
|
-
import { join as
|
|
10036
|
+
import { join as join32, relative as relative4, sep as sep2 } from "path";
|
|
10032
10037
|
function shouldSkipFile(filePath, baseDir, gitignorePatterns) {
|
|
10033
10038
|
const relativePath = relative4(baseDir, filePath);
|
|
10034
10039
|
const pathParts = relativePath.split(sep2);
|
|
@@ -10043,7 +10048,7 @@ function collectFiles(directory, baseDir, gitignorePatterns) {
|
|
|
10043
10048
|
try {
|
|
10044
10049
|
const entries = readdirSync3(directory, { withFileTypes: true });
|
|
10045
10050
|
for (const entry of entries) {
|
|
10046
|
-
const fullPath =
|
|
10051
|
+
const fullPath = join32(directory, entry.name);
|
|
10047
10052
|
if (shouldSkipFile(fullPath, baseDir, gitignorePatterns)) {
|
|
10048
10053
|
continue;
|
|
10049
10054
|
}
|
|
@@ -10783,11 +10788,11 @@ async function addPlaycademySdk() {
|
|
|
10783
10788
|
initCommand.addCommand(configCommand);
|
|
10784
10789
|
|
|
10785
10790
|
// src/commands/login.ts
|
|
10791
|
+
import { userInfo } from "os";
|
|
10786
10792
|
import { input as input3, password, select as select4 } from "@inquirer/prompts";
|
|
10787
10793
|
import { bold as bold8, dim as dim8, whiteBright } from "colorette";
|
|
10788
10794
|
import { Command as Command3 } from "commander";
|
|
10789
10795
|
import open from "open";
|
|
10790
|
-
init_file_loader();
|
|
10791
10796
|
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) => {
|
|
10792
10797
|
const { email, password: password2, sso, env } = options;
|
|
10793
10798
|
const environment = ensureEnvironment(env);
|
|
@@ -10844,10 +10849,9 @@ var loginCommand = new Command3("login").description("Authenticate with Playcade
|
|
|
10844
10849
|
const apiKeyResult = await runStep(
|
|
10845
10850
|
"Creating API key for CLI usage",
|
|
10846
10851
|
async () => {
|
|
10847
|
-
const
|
|
10848
|
-
const nameVersion = pkg ? getPackageNameVersionFromData(pkg) : `${getCurrentDirectoryName("playcademy-cli")}@0.0.0`;
|
|
10852
|
+
const username = userInfo().username.substring(0, 32);
|
|
10849
10853
|
const result = await client.auth.apiKeys.create({
|
|
10850
|
-
name:
|
|
10854
|
+
name: username,
|
|
10851
10855
|
expiresIn: null,
|
|
10852
10856
|
// No expiration
|
|
10853
10857
|
permissions: {
|
|
@@ -10911,10 +10915,9 @@ async function handleSsoLogin(environment, profileName) {
|
|
|
10911
10915
|
const apiKeyResult = await runStep(
|
|
10912
10916
|
"Creating API key for CLI usage",
|
|
10913
10917
|
async () => {
|
|
10914
|
-
const
|
|
10915
|
-
const nameVersion = pkg ? getPackageNameVersionFromData(pkg) : `${getCurrentDirectoryName("playcademy-cli")}@0.0.0`;
|
|
10918
|
+
const username = userInfo().username.substring(0, 32);
|
|
10916
10919
|
const response = await client.auth.apiKeys.create({
|
|
10917
|
-
name:
|
|
10920
|
+
name: username,
|
|
10918
10921
|
expiresIn: null,
|
|
10919
10922
|
permissions: {
|
|
10920
10923
|
games: ["read", "write", "delete"],
|
|
@@ -11575,7 +11578,7 @@ import { Command as Command17 } from "commander";
|
|
|
11575
11578
|
// src/commands/auth/add.ts
|
|
11576
11579
|
init_file_loader();
|
|
11577
11580
|
import { writeFileSync as writeFileSync13 } from "fs";
|
|
11578
|
-
import { join as
|
|
11581
|
+
import { join as join33 } from "path";
|
|
11579
11582
|
import { bold as bold10 } from "colorette";
|
|
11580
11583
|
import { Command as Command15 } from "commander";
|
|
11581
11584
|
var addAuthCommand = new Command15("add").description("Add an authentication provider to your project").argument("<provider>", "Provider to add: email | github | google").addHelpText(
|
|
@@ -11613,7 +11616,7 @@ Examples:
|
|
|
11613
11616
|
logger.highlight(`Add ${providerDisplayName} Authentication`);
|
|
11614
11617
|
logger.newLine();
|
|
11615
11618
|
const workspace = getWorkspace();
|
|
11616
|
-
const authPath =
|
|
11619
|
+
const authPath = join33(workspace, SERVER_LIB_DIRECTORY, AUTH_CONFIG_FILE);
|
|
11617
11620
|
let authContent = await loadFile(authPath);
|
|
11618
11621
|
if (!authContent) {
|
|
11619
11622
|
logger.error("Authentication configuration not found");
|
|
@@ -11891,7 +11894,7 @@ async function runDbInit() {
|
|
|
11891
11894
|
|
|
11892
11895
|
// src/commands/db/reset.ts
|
|
11893
11896
|
import { existsSync as existsSync23 } from "fs";
|
|
11894
|
-
import { join as
|
|
11897
|
+
import { join as join34 } from "path";
|
|
11895
11898
|
import { confirm as confirm8, input as input7 } from "@inquirer/prompts";
|
|
11896
11899
|
import { bold as bold11, redBright as redBright4, underline as underline3 } from "colorette";
|
|
11897
11900
|
import { Miniflare as Miniflare2 } from "miniflare";
|
|
@@ -11970,7 +11973,7 @@ async function runDbResetRemote(options) {
|
|
|
11970
11973
|
}
|
|
11971
11974
|
async function runDbResetLocal(options) {
|
|
11972
11975
|
const workspace = getWorkspace();
|
|
11973
|
-
const dbDir =
|
|
11976
|
+
const dbDir = join34(workspace, CLI_DIRECTORIES.DATABASE);
|
|
11974
11977
|
logger.newLine();
|
|
11975
11978
|
if (!existsSync23(dbDir)) {
|
|
11976
11979
|
logger.warn("No database found to reset");
|
|
@@ -12032,7 +12035,7 @@ async function runDbReset(options = {}) {
|
|
|
12032
12035
|
|
|
12033
12036
|
// src/commands/db/seed.ts
|
|
12034
12037
|
import { existsSync as existsSync24 } from "fs";
|
|
12035
|
-
import { join as
|
|
12038
|
+
import { join as join35 } from "path";
|
|
12036
12039
|
import { confirm as confirm9, input as input8 } from "@inquirer/prompts";
|
|
12037
12040
|
import { bold as bold12, redBright as redBright5, underline as underline4 } from "colorette";
|
|
12038
12041
|
import { Miniflare as Miniflare3 } from "miniflare";
|
|
@@ -12152,12 +12155,12 @@ async function runDbSeedRemote(seedFile, options) {
|
|
|
12152
12155
|
}
|
|
12153
12156
|
async function runDbSeedLocal(seedFile, options) {
|
|
12154
12157
|
const workspace = getWorkspace();
|
|
12155
|
-
const dbDir =
|
|
12158
|
+
const dbDir = join35(workspace, CLI_DIRECTORIES.DATABASE);
|
|
12156
12159
|
const config = await loadConfig();
|
|
12157
12160
|
const hasBucket = hasBucketSetup(config);
|
|
12158
12161
|
const hasKV = hasKVSetup(config);
|
|
12159
|
-
const bucketDir = hasBucket ?
|
|
12160
|
-
const kvDir = hasKV ?
|
|
12162
|
+
const bucketDir = hasBucket ? join35(workspace, CLI_DIRECTORIES.BUCKET) : void 0;
|
|
12163
|
+
const kvDir = hasKV ? join35(workspace, CLI_DIRECTORIES.KV) : void 0;
|
|
12161
12164
|
if (bucketDir) {
|
|
12162
12165
|
const { mkdir: mkdir5 } = await import("fs/promises");
|
|
12163
12166
|
await mkdir5(bucketDir, { recursive: true });
|
|
@@ -12199,7 +12202,7 @@ async function runDbSeedLocal(seedFile, options) {
|
|
|
12199
12202
|
async function runDbSeed(options = {}) {
|
|
12200
12203
|
const workspace = getWorkspace();
|
|
12201
12204
|
try {
|
|
12202
|
-
const seedFile = options.file ?
|
|
12205
|
+
const seedFile = options.file ? join35(workspace, options.file) : join35(workspace, DEFAULT_DATABASE_DIRECTORY, DB_FILES.SEED);
|
|
12203
12206
|
if (!existsSync24(seedFile)) {
|
|
12204
12207
|
logger.newLine();
|
|
12205
12208
|
logger.error(`Seed file not found: ${seedFile}`);
|
|
@@ -12252,7 +12255,7 @@ dbCommand.command("diff").description("Show schema changes since last deployment
|
|
|
12252
12255
|
import { Command as Command19 } from "commander";
|
|
12253
12256
|
|
|
12254
12257
|
// src/commands/kv/clear.ts
|
|
12255
|
-
import { join as
|
|
12258
|
+
import { join as join36 } from "path";
|
|
12256
12259
|
import { confirm as confirm10 } from "@inquirer/prompts";
|
|
12257
12260
|
import { Miniflare as Miniflare4 } from "miniflare";
|
|
12258
12261
|
async function runKVClear(options = {}) {
|
|
@@ -12285,7 +12288,7 @@ async function runKVClear(options = {}) {
|
|
|
12285
12288
|
}
|
|
12286
12289
|
process.exit(1);
|
|
12287
12290
|
}
|
|
12288
|
-
const kvDir =
|
|
12291
|
+
const kvDir = join36(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
12289
12292
|
const mf = new Miniflare4({
|
|
12290
12293
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
12291
12294
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -12356,7 +12359,7 @@ async function runKVClear(options = {}) {
|
|
|
12356
12359
|
}
|
|
12357
12360
|
|
|
12358
12361
|
// src/commands/kv/delete.ts
|
|
12359
|
-
import { join as
|
|
12362
|
+
import { join as join37 } from "path";
|
|
12360
12363
|
import { Miniflare as Miniflare5 } from "miniflare";
|
|
12361
12364
|
async function runKVDelete(key, options = {}) {
|
|
12362
12365
|
try {
|
|
@@ -12397,7 +12400,7 @@ async function runKVDelete(key, options = {}) {
|
|
|
12397
12400
|
}
|
|
12398
12401
|
process.exit(1);
|
|
12399
12402
|
}
|
|
12400
|
-
const kvDir =
|
|
12403
|
+
const kvDir = join37(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
12401
12404
|
const mf = new Miniflare5({
|
|
12402
12405
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
12403
12406
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -12433,7 +12436,7 @@ async function runKVDelete(key, options = {}) {
|
|
|
12433
12436
|
}
|
|
12434
12437
|
|
|
12435
12438
|
// src/commands/kv/get.ts
|
|
12436
|
-
import { join as
|
|
12439
|
+
import { join as join38 } from "path";
|
|
12437
12440
|
import { Miniflare as Miniflare6 } from "miniflare";
|
|
12438
12441
|
async function runKVGet(key, options = {}) {
|
|
12439
12442
|
try {
|
|
@@ -12474,7 +12477,7 @@ async function runKVGet(key, options = {}) {
|
|
|
12474
12477
|
}
|
|
12475
12478
|
process.exit(1);
|
|
12476
12479
|
}
|
|
12477
|
-
const kvDir =
|
|
12480
|
+
const kvDir = join38(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
12478
12481
|
const mf = new Miniflare6({
|
|
12479
12482
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
12480
12483
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -12603,7 +12606,7 @@ async function runKVInit() {
|
|
|
12603
12606
|
}
|
|
12604
12607
|
|
|
12605
12608
|
// src/commands/kv/inspect.ts
|
|
12606
|
-
import { join as
|
|
12609
|
+
import { join as join39 } from "path";
|
|
12607
12610
|
import { Miniflare as Miniflare7 } from "miniflare";
|
|
12608
12611
|
async function runKVInspect(key, options = {}) {
|
|
12609
12612
|
try {
|
|
@@ -12644,7 +12647,7 @@ async function runKVInspect(key, options = {}) {
|
|
|
12644
12647
|
}
|
|
12645
12648
|
process.exit(1);
|
|
12646
12649
|
}
|
|
12647
|
-
const kvDir =
|
|
12650
|
+
const kvDir = join39(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
12648
12651
|
const mf = new Miniflare7({
|
|
12649
12652
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
12650
12653
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -12730,7 +12733,7 @@ async function runKVInspect(key, options = {}) {
|
|
|
12730
12733
|
}
|
|
12731
12734
|
|
|
12732
12735
|
// src/commands/kv/list.ts
|
|
12733
|
-
import { join as
|
|
12736
|
+
import { join as join40 } from "path";
|
|
12734
12737
|
import { Miniflare as Miniflare8 } from "miniflare";
|
|
12735
12738
|
async function runKVList(options = {}) {
|
|
12736
12739
|
try {
|
|
@@ -12762,7 +12765,7 @@ async function runKVList(options = {}) {
|
|
|
12762
12765
|
}
|
|
12763
12766
|
process.exit(1);
|
|
12764
12767
|
}
|
|
12765
|
-
const kvDir =
|
|
12768
|
+
const kvDir = join40(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
12766
12769
|
const mf = new Miniflare8({
|
|
12767
12770
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
12768
12771
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -12809,7 +12812,7 @@ async function runKVList(options = {}) {
|
|
|
12809
12812
|
|
|
12810
12813
|
// src/commands/kv/seed.ts
|
|
12811
12814
|
init_file_loader();
|
|
12812
|
-
import { join as
|
|
12815
|
+
import { join as join41 } from "path";
|
|
12813
12816
|
import { confirm as confirm11 } from "@inquirer/prompts";
|
|
12814
12817
|
import { Miniflare as Miniflare9 } from "miniflare";
|
|
12815
12818
|
async function runKVSeed(seedFile, options = {}) {
|
|
@@ -12875,7 +12878,7 @@ async function runKVSeed(seedFile, options = {}) {
|
|
|
12875
12878
|
}
|
|
12876
12879
|
process.exit(1);
|
|
12877
12880
|
}
|
|
12878
|
-
const kvDir =
|
|
12881
|
+
const kvDir = join41(workspace, CLI_DIRECTORIES.KV);
|
|
12879
12882
|
const mf = new Miniflare9({
|
|
12880
12883
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
12881
12884
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -12955,7 +12958,7 @@ async function runKVSeed(seedFile, options = {}) {
|
|
|
12955
12958
|
|
|
12956
12959
|
// src/commands/kv/set.ts
|
|
12957
12960
|
init_file_loader();
|
|
12958
|
-
import { join as
|
|
12961
|
+
import { join as join42 } from "path";
|
|
12959
12962
|
import { Miniflare as Miniflare10 } from "miniflare";
|
|
12960
12963
|
async function runKVSet(key, value, options = {}) {
|
|
12961
12964
|
try {
|
|
@@ -13025,7 +13028,7 @@ async function runKVSet(key, value, options = {}) {
|
|
|
13025
13028
|
}
|
|
13026
13029
|
process.exit(1);
|
|
13027
13030
|
}
|
|
13028
|
-
const kvDir =
|
|
13031
|
+
const kvDir = join42(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
13029
13032
|
const mf = new Miniflare10({
|
|
13030
13033
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13031
13034
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -13061,7 +13064,7 @@ async function runKVSet(key, value, options = {}) {
|
|
|
13061
13064
|
}
|
|
13062
13065
|
|
|
13063
13066
|
// src/commands/kv/stats.ts
|
|
13064
|
-
import { join as
|
|
13067
|
+
import { join as join43 } from "path";
|
|
13065
13068
|
import { Miniflare as Miniflare11 } from "miniflare";
|
|
13066
13069
|
async function runKVStats(options = {}) {
|
|
13067
13070
|
try {
|
|
@@ -13093,7 +13096,7 @@ async function runKVStats(options = {}) {
|
|
|
13093
13096
|
}
|
|
13094
13097
|
process.exit(1);
|
|
13095
13098
|
}
|
|
13096
|
-
const kvDir =
|
|
13099
|
+
const kvDir = join43(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
13097
13100
|
const mf = new Miniflare11({
|
|
13098
13101
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13099
13102
|
kvNamespaces: [CLOUDFLARE_BINDINGS.KV],
|
|
@@ -13210,7 +13213,7 @@ import { Command as Command20 } from "commander";
|
|
|
13210
13213
|
|
|
13211
13214
|
// src/commands/bucket/bulk.ts
|
|
13212
13215
|
import { existsSync as existsSync25, statSync as statSync3 } from "fs";
|
|
13213
|
-
import { join as
|
|
13216
|
+
import { join as join44 } from "path";
|
|
13214
13217
|
import { Miniflare as Miniflare12 } from "miniflare";
|
|
13215
13218
|
async function runBucketBulkRemote(directory, options) {
|
|
13216
13219
|
const environment = ensureEnvironment(options.env);
|
|
@@ -13272,7 +13275,7 @@ async function runBucketBulkLocal(directory, options) {
|
|
|
13272
13275
|
outputDryRunResults(files, totalSize, options.prefix, options.json, options.raw);
|
|
13273
13276
|
return;
|
|
13274
13277
|
}
|
|
13275
|
-
const bucketDir =
|
|
13278
|
+
const bucketDir = join44(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
13276
13279
|
const mf = new Miniflare12({
|
|
13277
13280
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13278
13281
|
r2Buckets: [CLOUDFLARE_BINDINGS.BUCKET],
|
|
@@ -13351,7 +13354,7 @@ async function runBucketBulk(directory, options = {}) {
|
|
|
13351
13354
|
}
|
|
13352
13355
|
|
|
13353
13356
|
// src/commands/bucket/delete.ts
|
|
13354
|
-
import { join as
|
|
13357
|
+
import { join as join45 } from "path";
|
|
13355
13358
|
import { Miniflare as Miniflare13 } from "miniflare";
|
|
13356
13359
|
async function runBucketDeleteRemote(key, options) {
|
|
13357
13360
|
const environment = ensureEnvironment(options.env);
|
|
@@ -13407,7 +13410,7 @@ async function runBucketDeleteLocal(key, options) {
|
|
|
13407
13410
|
}
|
|
13408
13411
|
process.exit(1);
|
|
13409
13412
|
}
|
|
13410
|
-
const bucketDir =
|
|
13413
|
+
const bucketDir = join45(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
13411
13414
|
const mf = new Miniflare13({
|
|
13412
13415
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13413
13416
|
r2Buckets: [CLOUDFLARE_BINDINGS.BUCKET],
|
|
@@ -13470,7 +13473,7 @@ async function runBucketDelete(key, options = {}) {
|
|
|
13470
13473
|
|
|
13471
13474
|
// src/commands/bucket/get.ts
|
|
13472
13475
|
import { writeFileSync as writeFileSync14 } from "fs";
|
|
13473
|
-
import { join as
|
|
13476
|
+
import { join as join46 } from "path";
|
|
13474
13477
|
import { Miniflare as Miniflare14 } from "miniflare";
|
|
13475
13478
|
async function runBucketGetRemote(key, options) {
|
|
13476
13479
|
const environment = ensureEnvironment(options.env);
|
|
@@ -13563,7 +13566,7 @@ async function runBucketGetLocal(key, options) {
|
|
|
13563
13566
|
}
|
|
13564
13567
|
process.exit(1);
|
|
13565
13568
|
}
|
|
13566
|
-
const bucketDir =
|
|
13569
|
+
const bucketDir = join46(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
13567
13570
|
const mf = new Miniflare14({
|
|
13568
13571
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13569
13572
|
r2Buckets: [CLOUDFLARE_BINDINGS.BUCKET],
|
|
@@ -13718,7 +13721,7 @@ async function runBucketInit() {
|
|
|
13718
13721
|
}
|
|
13719
13722
|
|
|
13720
13723
|
// src/commands/bucket/list.ts
|
|
13721
|
-
import { join as
|
|
13724
|
+
import { join as join47 } from "path";
|
|
13722
13725
|
import { Miniflare as Miniflare15 } from "miniflare";
|
|
13723
13726
|
async function runBucketListRemote(options) {
|
|
13724
13727
|
const environment = ensureEnvironment(options.env);
|
|
@@ -13785,7 +13788,7 @@ async function runBucketListLocal(options) {
|
|
|
13785
13788
|
}
|
|
13786
13789
|
process.exit(1);
|
|
13787
13790
|
}
|
|
13788
|
-
const bucketDir =
|
|
13791
|
+
const bucketDir = join47(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
13789
13792
|
const mf = new Miniflare15({
|
|
13790
13793
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13791
13794
|
r2Buckets: [CLOUDFLARE_BINDINGS.BUCKET],
|
|
@@ -13869,7 +13872,7 @@ function formatBytes2(bytes) {
|
|
|
13869
13872
|
|
|
13870
13873
|
// src/commands/bucket/put.ts
|
|
13871
13874
|
import { readFileSync as readFileSync13, statSync as statSync4 } from "fs";
|
|
13872
|
-
import { join as
|
|
13875
|
+
import { join as join48 } from "path";
|
|
13873
13876
|
import { Miniflare as Miniflare16 } from "miniflare";
|
|
13874
13877
|
async function runBucketPutRemote(key, filePath, options) {
|
|
13875
13878
|
const environment = ensureEnvironment(options.env);
|
|
@@ -13954,7 +13957,7 @@ async function runBucketPutLocal(key, filePath, options) {
|
|
|
13954
13957
|
}
|
|
13955
13958
|
process.exit(1);
|
|
13956
13959
|
}
|
|
13957
|
-
const bucketDir =
|
|
13960
|
+
const bucketDir = join48(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
13958
13961
|
const mf = new Miniflare16({
|
|
13959
13962
|
modules: [{ type: "ESModule", path: "index.mjs", contents: "" }],
|
|
13960
13963
|
r2Buckets: [CLOUDFLARE_BINDINGS.BUCKET],
|
|
@@ -14892,7 +14895,7 @@ import { Command as Command38 } from "commander";
|
|
|
14892
14895
|
|
|
14893
14896
|
// src/commands/debug/bundle.ts
|
|
14894
14897
|
import { writeFileSync as writeFileSync15 } from "fs";
|
|
14895
|
-
import { join as
|
|
14898
|
+
import { join as join49 } from "path";
|
|
14896
14899
|
import { Command as Command37 } from "commander";
|
|
14897
14900
|
var bundleCommand = new Command37("bundle").description("Bundle and inspect the project 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) => {
|
|
14898
14901
|
try {
|
|
@@ -14922,7 +14925,7 @@ var bundleCommand = new Command37("bundle").description("Bundle and inspect the
|
|
|
14922
14925
|
}),
|
|
14923
14926
|
(result) => `Bundled ${formatSize(result.code.length)}`
|
|
14924
14927
|
);
|
|
14925
|
-
const outputPath =
|
|
14928
|
+
const outputPath = join49(workspace, options.output);
|
|
14926
14929
|
writeFileSync15(outputPath, bundle.code, "utf-8");
|
|
14927
14930
|
logger.success(`Bundle saved to ${options.output}`);
|
|
14928
14931
|
logger.newLine();
|