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/utils.js
CHANGED
|
@@ -1708,9 +1708,15 @@ init_file_loader();
|
|
|
1708
1708
|
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
1709
1709
|
|
|
1710
1710
|
// src/constants/api.ts
|
|
1711
|
+
import { join as join2 } from "node:path";
|
|
1712
|
+
|
|
1713
|
+
// src/constants/server.ts
|
|
1711
1714
|
import { join } from "node:path";
|
|
1712
|
-
var
|
|
1713
|
-
var SERVER_LIB_DIRECTORY = join(
|
|
1715
|
+
var SERVER_ROOT_DIRECTORY = "server";
|
|
1716
|
+
var SERVER_LIB_DIRECTORY = join(SERVER_ROOT_DIRECTORY, "lib");
|
|
1717
|
+
|
|
1718
|
+
// src/constants/api.ts
|
|
1719
|
+
var DEFAULT_API_ROUTES_DIRECTORY = join2(SERVER_ROOT_DIRECTORY, "api");
|
|
1714
1720
|
|
|
1715
1721
|
// ../../package.json
|
|
1716
1722
|
var package_default = {
|
|
@@ -1857,41 +1863,41 @@ var CLOUDFLARE_BINDINGS = {
|
|
|
1857
1863
|
};
|
|
1858
1864
|
|
|
1859
1865
|
// src/constants/database.ts
|
|
1860
|
-
import { join as
|
|
1861
|
-
var DEFAULT_DATABASE_DIRECTORY =
|
|
1866
|
+
import { join as join3 } from "path";
|
|
1867
|
+
var DEFAULT_DATABASE_DIRECTORY = join3("server", "db");
|
|
1862
1868
|
var DRIZZLE_CONFIG_FILES = ["drizzle.config.ts", "drizzle.config.js"];
|
|
1863
1869
|
|
|
1864
1870
|
// src/constants/godot.ts
|
|
1865
|
-
import { join as
|
|
1871
|
+
import { join as join4 } from "node:path";
|
|
1866
1872
|
var GODOT_BUILD_DIRECTORIES = {
|
|
1867
1873
|
/** Root build directory (cleared before each export) */
|
|
1868
1874
|
ROOT: "build",
|
|
1869
1875
|
/** Web export subdirectory */
|
|
1870
|
-
WEB:
|
|
1876
|
+
WEB: join4("build", "web")
|
|
1871
1877
|
};
|
|
1872
1878
|
var GODOT_BUILD_OUTPUTS = {
|
|
1873
1879
|
/** Exported web build entry point */
|
|
1874
|
-
INDEX_HTML:
|
|
1880
|
+
INDEX_HTML: join4("build", "web", "index.html"),
|
|
1875
1881
|
/** Packaged zip file (created by Godot export) */
|
|
1876
|
-
ZIP:
|
|
1882
|
+
ZIP: join4("build", "web_playcademy.zip")
|
|
1877
1883
|
};
|
|
1878
1884
|
|
|
1879
1885
|
// src/constants/paths.ts
|
|
1880
|
-
import { join as
|
|
1886
|
+
import { join as join5 } from "path";
|
|
1881
1887
|
var WORKSPACE_NAME = ".playcademy";
|
|
1882
1888
|
var CLI_DIRECTORIES = {
|
|
1883
1889
|
/** Root directory for CLI artifacts in workspace */
|
|
1884
1890
|
WORKSPACE: WORKSPACE_NAME,
|
|
1885
1891
|
/** Database directory within workspace */
|
|
1886
|
-
DATABASE:
|
|
1892
|
+
DATABASE: join5(WORKSPACE_NAME, "db"),
|
|
1887
1893
|
/** KV storage directory within workspace */
|
|
1888
|
-
KV:
|
|
1894
|
+
KV: join5(WORKSPACE_NAME, "kv"),
|
|
1889
1895
|
/** Bucket storage directory within workspace */
|
|
1890
|
-
BUCKET:
|
|
1896
|
+
BUCKET: join5(WORKSPACE_NAME, "bucket")
|
|
1891
1897
|
};
|
|
1892
1898
|
var CLI_DEFAULT_OUTPUTS = {
|
|
1893
1899
|
/** Default worker bundle output for debug command */
|
|
1894
|
-
WORKER_BUNDLE:
|
|
1900
|
+
WORKER_BUNDLE: join5(WORKSPACE_NAME, "worker-bundle.js")
|
|
1895
1901
|
};
|
|
1896
1902
|
|
|
1897
1903
|
// src/constants/ports.ts
|
|
@@ -1947,7 +1953,7 @@ var CORE_GAME_UUIDS = {
|
|
|
1947
1953
|
// ../utils/src/package-manager.ts
|
|
1948
1954
|
import { execSync } from "child_process";
|
|
1949
1955
|
import { existsSync as existsSync2 } from "fs";
|
|
1950
|
-
import { join as
|
|
1956
|
+
import { join as join6 } from "path";
|
|
1951
1957
|
function isCommandAvailable(command) {
|
|
1952
1958
|
try {
|
|
1953
1959
|
execSync(`command -v ${command}`, { stdio: "ignore" });
|
|
@@ -1957,16 +1963,16 @@ function isCommandAvailable(command) {
|
|
|
1957
1963
|
}
|
|
1958
1964
|
}
|
|
1959
1965
|
function detectPackageManager(cwd = process.cwd()) {
|
|
1960
|
-
if (existsSync2(
|
|
1966
|
+
if (existsSync2(join6(cwd, "bun.lock")) || existsSync2(join6(cwd, "bun.lockb"))) {
|
|
1961
1967
|
return "bun";
|
|
1962
1968
|
}
|
|
1963
|
-
if (existsSync2(
|
|
1969
|
+
if (existsSync2(join6(cwd, "pnpm-lock.yaml"))) {
|
|
1964
1970
|
return "pnpm";
|
|
1965
1971
|
}
|
|
1966
|
-
if (existsSync2(
|
|
1972
|
+
if (existsSync2(join6(cwd, "yarn.lock"))) {
|
|
1967
1973
|
return "yarn";
|
|
1968
1974
|
}
|
|
1969
|
-
if (existsSync2(
|
|
1975
|
+
if (existsSync2(join6(cwd, "package-lock.json"))) {
|
|
1970
1976
|
return "npm";
|
|
1971
1977
|
}
|
|
1972
1978
|
return detectByCommandAvailability();
|
|
@@ -3192,14 +3198,14 @@ function processConfigVariables(config) {
|
|
|
3192
3198
|
|
|
3193
3199
|
// src/lib/dev/server.ts
|
|
3194
3200
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
3195
|
-
import { join as
|
|
3201
|
+
import { join as join16 } from "path";
|
|
3196
3202
|
import { Log, LogLevel, Miniflare } from "miniflare";
|
|
3197
3203
|
|
|
3198
3204
|
// ../utils/src/port.ts
|
|
3199
3205
|
import { existsSync as existsSync3, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3200
3206
|
import { createServer } from "node:net";
|
|
3201
3207
|
import { homedir } from "node:os";
|
|
3202
|
-
import { join as
|
|
3208
|
+
import { join as join7 } from "node:path";
|
|
3203
3209
|
async function isPortAvailableOnHost(port, host) {
|
|
3204
3210
|
return new Promise((resolve4) => {
|
|
3205
3211
|
const server = createServer();
|
|
@@ -3238,11 +3244,11 @@ async function findAvailablePort(startPort = 4321) {
|
|
|
3238
3244
|
}
|
|
3239
3245
|
function getRegistryPath() {
|
|
3240
3246
|
const home = homedir();
|
|
3241
|
-
const dir =
|
|
3247
|
+
const dir = join7(home, ".playcademy");
|
|
3242
3248
|
if (!existsSync3(dir)) {
|
|
3243
3249
|
mkdirSync(dir, { recursive: true });
|
|
3244
3250
|
}
|
|
3245
|
-
return
|
|
3251
|
+
return join7(dir, ".proc");
|
|
3246
3252
|
}
|
|
3247
3253
|
function readRegistry() {
|
|
3248
3254
|
const registryPath = getRegistryPath();
|
|
@@ -3325,7 +3331,7 @@ init_package_json();
|
|
|
3325
3331
|
// src/lib/secrets/env.ts
|
|
3326
3332
|
init_file_loader();
|
|
3327
3333
|
import { existsSync as existsSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
3328
|
-
import { join as
|
|
3334
|
+
import { join as join8 } from "path";
|
|
3329
3335
|
function parseEnvFile(contents) {
|
|
3330
3336
|
const secrets = {};
|
|
3331
3337
|
for (const line of contents.split("\n")) {
|
|
@@ -3361,10 +3367,10 @@ async function readEnvFile(workspace) {
|
|
|
3361
3367
|
return secrets;
|
|
3362
3368
|
}
|
|
3363
3369
|
function getLoadedEnvFiles(workspace) {
|
|
3364
|
-
return ENV_FILES.filter((filename) => existsSync4(
|
|
3370
|
+
return ENV_FILES.filter((filename) => existsSync4(join8(workspace, filename)));
|
|
3365
3371
|
}
|
|
3366
3372
|
function hasEnvFile(workspace) {
|
|
3367
|
-
return ENV_FILES.some((filename) => existsSync4(
|
|
3373
|
+
return ENV_FILES.some((filename) => existsSync4(join8(workspace, filename)));
|
|
3368
3374
|
}
|
|
3369
3375
|
|
|
3370
3376
|
// src/lib/templates/loader.ts
|
|
@@ -3391,12 +3397,12 @@ function loadTemplateString(filename) {
|
|
|
3391
3397
|
// src/lib/core/import.ts
|
|
3392
3398
|
import { mkdtempSync, rmSync } from "fs";
|
|
3393
3399
|
import { tmpdir } from "os";
|
|
3394
|
-
import { join as
|
|
3400
|
+
import { join as join9 } from "path";
|
|
3395
3401
|
import { pathToFileURL } from "url";
|
|
3396
3402
|
import * as esbuild from "esbuild";
|
|
3397
3403
|
async function importTypescriptFile(filePath, bundleOptions) {
|
|
3398
|
-
const tempDir = mkdtempSync(
|
|
3399
|
-
const outFile =
|
|
3404
|
+
const tempDir = mkdtempSync(join9(tmpdir(), "playcademy-import-"));
|
|
3405
|
+
const outFile = join9(tempDir, "bundle.mjs");
|
|
3400
3406
|
try {
|
|
3401
3407
|
await esbuild.build({
|
|
3402
3408
|
entryPoints: [filePath],
|
|
@@ -3425,7 +3431,7 @@ async function importTypescriptDefault(filePath, bundleOptions) {
|
|
|
3425
3431
|
|
|
3426
3432
|
// src/lib/deploy/bundle.ts
|
|
3427
3433
|
import { existsSync as existsSync6 } from "fs";
|
|
3428
|
-
import { join as
|
|
3434
|
+
import { join as join11 } from "path";
|
|
3429
3435
|
|
|
3430
3436
|
// ../edge-play/src/entry.ts
|
|
3431
3437
|
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";
|
|
@@ -3698,7 +3704,7 @@ function textLoaderPlugin() {
|
|
|
3698
3704
|
init_file_loader();
|
|
3699
3705
|
import { mkdir, writeFile } from "fs/promises";
|
|
3700
3706
|
import { tmpdir as tmpdir2 } from "os";
|
|
3701
|
-
import { join as
|
|
3707
|
+
import { join as join10, relative } from "path";
|
|
3702
3708
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
3703
3709
|
|
|
3704
3710
|
// src/lib/deploy/hash.ts
|
|
@@ -3718,8 +3724,8 @@ async function discoverRoutes(apiDir) {
|
|
|
3718
3724
|
const routes = await Promise.all(
|
|
3719
3725
|
files.map(async (file) => {
|
|
3720
3726
|
const routePath = filePathToRoutePath(file);
|
|
3721
|
-
const absolutePath =
|
|
3722
|
-
const relativePath = relative(getWorkspace(), absolutePath);
|
|
3727
|
+
const absolutePath = join10(apiDir, file);
|
|
3728
|
+
const relativePath = relative(getWorkspace(), absolutePath).replace(/\\/g, "/");
|
|
3723
3729
|
const methods = await detectExportedMethods(absolutePath);
|
|
3724
3730
|
return {
|
|
3725
3731
|
path: routePath,
|
|
@@ -3780,10 +3786,10 @@ async function transpileRoute(filePath) {
|
|
|
3780
3786
|
if (!result.outputFiles?.[0]) {
|
|
3781
3787
|
throw new Error("Transpilation failed: no output");
|
|
3782
3788
|
}
|
|
3783
|
-
const tempDir =
|
|
3789
|
+
const tempDir = join10(tmpdir2(), "playcademy-dev");
|
|
3784
3790
|
await mkdir(tempDir, { recursive: true });
|
|
3785
3791
|
const hash = hashContent(filePath).slice(0, 12);
|
|
3786
|
-
const jsPath =
|
|
3792
|
+
const jsPath = join10(tempDir, `${hash}.mjs`);
|
|
3787
3793
|
await writeFile(jsPath, result.outputFiles[0].text);
|
|
3788
3794
|
return jsPath;
|
|
3789
3795
|
}
|
|
@@ -3794,7 +3800,7 @@ async function discoverCustomRoutes(config) {
|
|
|
3794
3800
|
const workspace = getWorkspace();
|
|
3795
3801
|
const customRoutesConfig = config.integrations?.customRoutes;
|
|
3796
3802
|
const customRoutesDir = typeof customRoutesConfig === "object" && customRoutesConfig.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
3797
|
-
const customRoutes = await discoverRoutes(
|
|
3803
|
+
const customRoutes = await discoverRoutes(join11(workspace, customRoutesDir));
|
|
3798
3804
|
const customRouteData = customRoutes.map((r) => ({
|
|
3799
3805
|
path: r.path,
|
|
3800
3806
|
file: r.file,
|
|
@@ -3806,15 +3812,15 @@ async function discoverCustomRoutes(config) {
|
|
|
3806
3812
|
function resolveEmbeddedSourcePaths() {
|
|
3807
3813
|
const workspace = getWorkspace();
|
|
3808
3814
|
const distDir = new URL(".", import.meta.url).pathname;
|
|
3809
|
-
const embeddedEdgeSrc =
|
|
3815
|
+
const embeddedEdgeSrc = join11(distDir, "edge-play", "src");
|
|
3810
3816
|
const isBuiltPackage = existsSync6(embeddedEdgeSrc);
|
|
3811
3817
|
const monorepoRoot = getMonorepoRoot();
|
|
3812
|
-
const monorepoEdgeSrc =
|
|
3818
|
+
const monorepoEdgeSrc = join11(monorepoRoot, "packages/edge-play/src");
|
|
3813
3819
|
const edgePlaySrc = isBuiltPackage ? embeddedEdgeSrc : monorepoEdgeSrc;
|
|
3814
|
-
const cliPackageRoot = isBuiltPackage ?
|
|
3815
|
-
const cliNodeModules = isBuiltPackage ?
|
|
3816
|
-
const workspaceNodeModules =
|
|
3817
|
-
const constantsEntry = isBuiltPackage ?
|
|
3820
|
+
const cliPackageRoot = isBuiltPackage ? join11(distDir, "../../..") : join11(monorepoRoot, "packages/cli");
|
|
3821
|
+
const cliNodeModules = isBuiltPackage ? join11(cliPackageRoot, "node_modules") : monorepoRoot;
|
|
3822
|
+
const workspaceNodeModules = join11(workspace, "node_modules");
|
|
3823
|
+
const constantsEntry = isBuiltPackage ? join11(embeddedEdgeSrc, "..", "..", "constants", "src", "index.ts") : join11(monorepoRoot, "packages", "constants", "src", "index.ts");
|
|
3818
3824
|
return {
|
|
3819
3825
|
isBuiltPackage,
|
|
3820
3826
|
edgePlaySrc,
|
|
@@ -3879,22 +3885,22 @@ function createEsbuildConfig(entryCode, paths, bundleConfig, customRoutesDir, op
|
|
|
3879
3885
|
// │ Example: import * as route from '@game-api/hello.ts' │
|
|
3880
3886
|
// │ Resolves to: /user-project/server/api/hello.ts │
|
|
3881
3887
|
// └─────────────────────────────────────────────────────────────────┘
|
|
3882
|
-
"@game-api":
|
|
3888
|
+
"@game-api": join11(workspace, customRoutesDir),
|
|
3883
3889
|
// ┌─ User's server lib directory ───────────────────────────────────┐
|
|
3884
3890
|
// │ @game-server is a virtual module for server utilities/config │
|
|
3885
3891
|
// │ Example: import { getAuth } from '@game-server/lib/auth' │
|
|
3886
3892
|
// │ Resolves to: /user-project/server/lib/auth.ts │
|
|
3887
3893
|
// └─────────────────────────────────────────────────────────────────┘
|
|
3888
|
-
"@game-server":
|
|
3894
|
+
"@game-server": join11(workspace, "server"),
|
|
3889
3895
|
// ┌─ Node.js polyfills for Cloudflare Workers ──────────────────────┐
|
|
3890
3896
|
// │ Workers don't have fs, path, os, etc. Redirect to polyfills │
|
|
3891
3897
|
// │ that throw helpful errors if user code tries to use them. │
|
|
3892
3898
|
// └─────────────────────────────────────────────────────────────────┘
|
|
3893
|
-
fs:
|
|
3894
|
-
"fs/promises":
|
|
3895
|
-
path:
|
|
3896
|
-
os:
|
|
3897
|
-
process:
|
|
3899
|
+
fs: join11(edgePlaySrc, "polyfills.js"),
|
|
3900
|
+
"fs/promises": join11(edgePlaySrc, "polyfills.js"),
|
|
3901
|
+
path: join11(edgePlaySrc, "polyfills.js"),
|
|
3902
|
+
os: join11(edgePlaySrc, "polyfills.js"),
|
|
3903
|
+
process: join11(edgePlaySrc, "polyfills.js")
|
|
3898
3904
|
},
|
|
3899
3905
|
// ──── Build Plugins ────
|
|
3900
3906
|
plugins: [textLoaderPlugin()],
|
|
@@ -3984,12 +3990,12 @@ var protectedRouteTemplate = loadTemplateString("api/sample-protected.ts");
|
|
|
3984
3990
|
|
|
3985
3991
|
// src/lib/init/database.ts
|
|
3986
3992
|
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
3987
|
-
import { join as
|
|
3993
|
+
import { join as join12 } from "path";
|
|
3988
3994
|
|
|
3989
3995
|
// package.json
|
|
3990
3996
|
var package_default2 = {
|
|
3991
3997
|
name: "playcademy",
|
|
3992
|
-
version: "0.14.
|
|
3998
|
+
version: "0.14.21",
|
|
3993
3999
|
type: "module",
|
|
3994
4000
|
exports: {
|
|
3995
4001
|
".": {
|
|
@@ -4076,7 +4082,7 @@ var dbSeedTemplate = loadTemplateString("database/db-seed.ts");
|
|
|
4076
4082
|
var packageTemplate = loadTemplateString("database/package.json");
|
|
4077
4083
|
function hasDatabaseSetup() {
|
|
4078
4084
|
const workspace = getWorkspace();
|
|
4079
|
-
return DRIZZLE_CONFIG_FILES.some((filename) => existsSync7(
|
|
4085
|
+
return DRIZZLE_CONFIG_FILES.some((filename) => existsSync7(join12(workspace, filename)));
|
|
4080
4086
|
}
|
|
4081
4087
|
|
|
4082
4088
|
// src/lib/init/scaffold.ts
|
|
@@ -4100,16 +4106,16 @@ function hasBucketSetup(config) {
|
|
|
4100
4106
|
init_file_loader();
|
|
4101
4107
|
import { execSync as execSync2 } from "child_process";
|
|
4102
4108
|
import { existsSync as existsSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
4103
|
-
import { dirname as dirname4, join as
|
|
4109
|
+
import { dirname as dirname4, join as join15 } from "path";
|
|
4104
4110
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4105
4111
|
|
|
4106
4112
|
// src/lib/deploy/backend.ts
|
|
4107
4113
|
import { existsSync as existsSync8 } from "node:fs";
|
|
4108
|
-
import { join as
|
|
4114
|
+
import { join as join13 } from "node:path";
|
|
4109
4115
|
function getCustomRoutesDirectory(projectPath, config) {
|
|
4110
4116
|
const customRoutes = config?.integrations?.customRoutes;
|
|
4111
4117
|
const customRoutesDir = typeof customRoutes === "object" && customRoutes.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
4112
|
-
return
|
|
4118
|
+
return join13(projectPath, customRoutesDir);
|
|
4113
4119
|
}
|
|
4114
4120
|
function hasLocalCustomRoutes(projectPath, config) {
|
|
4115
4121
|
const customRoutesDir = getCustomRoutesDirectory(projectPath, config);
|
|
@@ -4119,7 +4125,7 @@ function hasLocalCustomRoutes(projectPath, config) {
|
|
|
4119
4125
|
// src/lib/init/tsconfig.ts
|
|
4120
4126
|
init_file_loader();
|
|
4121
4127
|
import { existsSync as existsSync9, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
4122
|
-
import { join as
|
|
4128
|
+
import { join as join14 } from "path";
|
|
4123
4129
|
function hasPlaycademyEnv(config) {
|
|
4124
4130
|
return config.include?.includes("playcademy-env.d.ts") ?? false;
|
|
4125
4131
|
}
|
|
@@ -4176,7 +4182,7 @@ function addToIncludeArrayPreservingComments(content) {
|
|
|
4176
4182
|
}
|
|
4177
4183
|
async function ensureTsconfigIncludes(workspace) {
|
|
4178
4184
|
for (const filename of TSCONFIG_FILES) {
|
|
4179
|
-
const configPath =
|
|
4185
|
+
const configPath = join14(workspace, filename);
|
|
4180
4186
|
if (!existsSync9(configPath)) {
|
|
4181
4187
|
continue;
|
|
4182
4188
|
}
|
|
@@ -4226,8 +4232,8 @@ function hasAnyBackend(features) {
|
|
|
4226
4232
|
return Object.values(features).some(Boolean);
|
|
4227
4233
|
}
|
|
4228
4234
|
async function setupPlaycademyDependencies(workspace) {
|
|
4229
|
-
const playcademyDir =
|
|
4230
|
-
const playcademyPkgPath =
|
|
4235
|
+
const playcademyDir = join15(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
4236
|
+
const playcademyPkgPath = join15(playcademyDir, "package.json");
|
|
4231
4237
|
const __dirname = dirname4(fileURLToPath2(import.meta.url));
|
|
4232
4238
|
const cliPkg = await loadPackageJson({ cwd: __dirname, searchUp: true, required: true });
|
|
4233
4239
|
const workersTypesVersion = cliPkg?.devDependencies?.["@cloudflare/workers-types"] || "latest";
|
|
@@ -4312,14 +4318,14 @@ async function ensurePlaycademyTypes(options = {}) {
|
|
|
4312
4318
|
const bindingsStr = generateBindingsTypeString(features);
|
|
4313
4319
|
const secretsStr = await generateSecretsTypeString(workspace, verbose);
|
|
4314
4320
|
const hasAuth = !!config.integrations?.auth;
|
|
4315
|
-
const hasAuthFile = existsSync10(
|
|
4321
|
+
const hasAuthFile = existsSync10(join15(workspace, "server/lib/auth.ts"));
|
|
4316
4322
|
const authVariablesString = generateAuthVariablesString(hasAuth, hasAuthFile);
|
|
4317
4323
|
let envContent = playcademyEnvTemplate.replace("{{BINDINGS}}", bindingsStr);
|
|
4318
4324
|
envContent = envContent.replace("{{SECRETS}}", secretsStr);
|
|
4319
4325
|
envContent = envContent.replace("{{AUTH_IMPORT}}", authVariablesString.authImport);
|
|
4320
4326
|
envContent = envContent.replace("{{VARIABLES}}", authVariablesString.variables);
|
|
4321
4327
|
envContent = envContent.replace("{{CONTEXT_VARS}}", authVariablesString.contextVars);
|
|
4322
|
-
const envPath =
|
|
4328
|
+
const envPath = join15(workspace, "playcademy-env.d.ts");
|
|
4323
4329
|
writeFileSync5(envPath, envContent);
|
|
4324
4330
|
if (verbose) {
|
|
4325
4331
|
logger.success(`Generated <playcademy-env.d.ts>`);
|
|
@@ -4432,7 +4438,7 @@ async function startDevServer(options) {
|
|
|
4432
4438
|
return { server: mf, port };
|
|
4433
4439
|
}
|
|
4434
4440
|
async function ensureDatabaseDirectory() {
|
|
4435
|
-
const dbDir =
|
|
4441
|
+
const dbDir = join16(getWorkspace(), CLI_DIRECTORIES.DATABASE);
|
|
4436
4442
|
try {
|
|
4437
4443
|
await mkdir2(dbDir, { recursive: true });
|
|
4438
4444
|
} catch (error) {
|
|
@@ -4441,7 +4447,7 @@ async function ensureDatabaseDirectory() {
|
|
|
4441
4447
|
return dbDir;
|
|
4442
4448
|
}
|
|
4443
4449
|
async function ensureKvDirectory() {
|
|
4444
|
-
const kvDir =
|
|
4450
|
+
const kvDir = join16(getWorkspace(), CLI_DIRECTORIES.KV);
|
|
4445
4451
|
try {
|
|
4446
4452
|
await mkdir2(kvDir, { recursive: true });
|
|
4447
4453
|
} catch (error) {
|
|
@@ -4450,7 +4456,7 @@ async function ensureKvDirectory() {
|
|
|
4450
4456
|
return kvDir;
|
|
4451
4457
|
}
|
|
4452
4458
|
async function ensureBucketDirectory() {
|
|
4453
|
-
const bucketDir =
|
|
4459
|
+
const bucketDir = join16(getWorkspace(), CLI_DIRECTORIES.BUCKET);
|
|
4454
4460
|
try {
|
|
4455
4461
|
await mkdir2(bucketDir, { recursive: true });
|
|
4456
4462
|
} catch (error) {
|
|
@@ -4473,7 +4479,7 @@ async function writeBackendServerInfo(port) {
|
|
|
4473
4479
|
}
|
|
4474
4480
|
|
|
4475
4481
|
// src/lib/dev/reload.ts
|
|
4476
|
-
import { join as
|
|
4482
|
+
import { join as join17, relative as relative2 } from "path";
|
|
4477
4483
|
import chokidar from "chokidar";
|
|
4478
4484
|
import { bold as bold5, cyan as cyan3, dim as dim4, green as green2 } from "colorette";
|
|
4479
4485
|
function formatTime() {
|
|
@@ -4490,9 +4496,9 @@ function startHotReload(onReload, options = {}) {
|
|
|
4490
4496
|
const customRoutesConfig = options.config?.integrations?.customRoutes;
|
|
4491
4497
|
const customRoutesDir = typeof customRoutesConfig === "object" && customRoutesConfig.directory || DEFAULT_API_ROUTES_DIRECTORY;
|
|
4492
4498
|
const watchPaths = [
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4499
|
+
join17(workspace, customRoutesDir),
|
|
4500
|
+
join17(workspace, "playcademy.config.js"),
|
|
4501
|
+
join17(workspace, "playcademy.config.json")
|
|
4496
4502
|
];
|
|
4497
4503
|
const watcher = chokidar.watch(watchPaths, {
|
|
4498
4504
|
persistent: true,
|
package/dist/version.js
CHANGED