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/constants.d.ts
CHANGED
|
@@ -8,14 +8,6 @@ export { GAME_WORKER_DOMAINS, PLAYCADEMY_BASE_URLS, PLAYCADEMY_DOMAINS } from '@
|
|
|
8
8
|
* Used when integrations.customRoutes.directory is not specified in config
|
|
9
9
|
*/
|
|
10
10
|
declare const DEFAULT_API_ROUTES_DIRECTORY: string;
|
|
11
|
-
/**
|
|
12
|
-
* Server root directory (fixed location)
|
|
13
|
-
*/
|
|
14
|
-
declare const SERVER_ROOT_DIRECTORY = "server";
|
|
15
|
-
/**
|
|
16
|
-
* Server library/utilities directory (fixed location)
|
|
17
|
-
*/
|
|
18
|
-
declare const SERVER_LIB_DIRECTORY: string;
|
|
19
11
|
/**
|
|
20
12
|
* Auth routes subdirectory name within API directory (fixed structure)
|
|
21
13
|
*/
|
|
@@ -282,9 +274,28 @@ declare const DEFAULT_PORTS: {
|
|
|
282
274
|
readonly BACKEND: 8788;
|
|
283
275
|
};
|
|
284
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Server directory structure constants
|
|
279
|
+
*
|
|
280
|
+
* Centralized path constants for server-related directories.
|
|
281
|
+
* Uses path.join() for cross-platform compatibility.
|
|
282
|
+
*/
|
|
283
|
+
/**
|
|
284
|
+
* Server root directory (fixed location)
|
|
285
|
+
*/
|
|
286
|
+
declare const SERVER_ROOT_DIRECTORY = "server";
|
|
287
|
+
/**
|
|
288
|
+
* Server library/utilities directory (fixed location)
|
|
289
|
+
*/
|
|
290
|
+
declare const SERVER_LIB_DIRECTORY: string;
|
|
291
|
+
/**
|
|
292
|
+
* Public assets directory (fixed location)
|
|
293
|
+
*/
|
|
294
|
+
declare const PUBLIC_DIRECTORY = "public";
|
|
295
|
+
|
|
285
296
|
/**
|
|
286
297
|
* Config file names to search for
|
|
287
298
|
*/
|
|
288
299
|
declare const CONFIG_FILE_NAMES: string[];
|
|
289
300
|
|
|
290
|
-
export { AUTH_API_SUBDIRECTORY, AUTH_CONFIG_FILE, AUTH_PROVIDER_NAMES, BETTER_AUTH_VERSION, BUCKET_ALWAYS_SKIP, CALLBACK_PATH, CALLBACK_PORT, CLI_DEFAULT_OUTPUTS, CLI_DIRECTORIES, CLI_FILES, CLI_USER_DIRECTORIES, CLOUDFLARE_BINDINGS, CLOUDFLARE_COMPATIBILITY_DATE, CONFIG_FILE_NAMES, DB_FILES, DEFAULT_API_ROUTES_DIRECTORY, DEFAULT_DATABASE_DIRECTORY, DEFAULT_PORTS, DRIZZLE_CONFIG_FILES, ENV_EXAMPLE_FILE, ENV_FILES, GODOT_BUILD_DIRECTORIES, GODOT_BUILD_OUTPUTS, GODOT_EXECUTABLE_PATTERNS, GODOT_EXPORT_PRESETS_FILE, GODOT_PROJECT_FILE, GODOT_WEB_PLATFORM, MINIFLARE_D1_DIRECTORY, OAUTH_CALLBACK_URL_PATTERN, PLACEHOLDER_GAME_URL, PLAYCADEMY_AUTH_VERSION, SAMPLE_API_SUBDIRECTORY, SAMPLE_BUCKET_FILENAME, SAMPLE_CUSTOM_FILENAME, SAMPLE_DATABASE_FILENAME, SAMPLE_KV_FILENAME, SCHEMA_SUBDIRECTORY, SERVER_LIB_DIRECTORY, SERVER_ROOT_DIRECTORY, SSO_AUTH_TIMEOUT_MS, TSCONFIG_FILES, WORKSPACE_NAME };
|
|
301
|
+
export { AUTH_API_SUBDIRECTORY, AUTH_CONFIG_FILE, AUTH_PROVIDER_NAMES, BETTER_AUTH_VERSION, BUCKET_ALWAYS_SKIP, CALLBACK_PATH, CALLBACK_PORT, CLI_DEFAULT_OUTPUTS, CLI_DIRECTORIES, CLI_FILES, CLI_USER_DIRECTORIES, CLOUDFLARE_BINDINGS, CLOUDFLARE_COMPATIBILITY_DATE, CONFIG_FILE_NAMES, DB_FILES, DEFAULT_API_ROUTES_DIRECTORY, DEFAULT_DATABASE_DIRECTORY, DEFAULT_PORTS, DRIZZLE_CONFIG_FILES, ENV_EXAMPLE_FILE, ENV_FILES, GODOT_BUILD_DIRECTORIES, GODOT_BUILD_OUTPUTS, GODOT_EXECUTABLE_PATTERNS, GODOT_EXPORT_PRESETS_FILE, GODOT_PROJECT_FILE, GODOT_WEB_PLATFORM, MINIFLARE_D1_DIRECTORY, OAUTH_CALLBACK_URL_PATTERN, PLACEHOLDER_GAME_URL, PLAYCADEMY_AUTH_VERSION, PUBLIC_DIRECTORY, SAMPLE_API_SUBDIRECTORY, SAMPLE_BUCKET_FILENAME, SAMPLE_CUSTOM_FILENAME, SAMPLE_DATABASE_FILENAME, SAMPLE_KV_FILENAME, SCHEMA_SUBDIRECTORY, SERVER_LIB_DIRECTORY, SERVER_ROOT_DIRECTORY, SSO_AUTH_TIMEOUT_MS, TSCONFIG_FILES, WORKSPACE_NAME };
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// src/constants/api.ts
|
|
2
|
+
import { join as join2 } from "node:path";
|
|
3
|
+
|
|
4
|
+
// src/constants/server.ts
|
|
2
5
|
import { join } from "node:path";
|
|
3
|
-
var DEFAULT_API_ROUTES_DIRECTORY = join("server", "api");
|
|
4
6
|
var SERVER_ROOT_DIRECTORY = "server";
|
|
5
|
-
var SERVER_LIB_DIRECTORY = join(
|
|
7
|
+
var SERVER_LIB_DIRECTORY = join(SERVER_ROOT_DIRECTORY, "lib");
|
|
8
|
+
var PUBLIC_DIRECTORY = "public";
|
|
9
|
+
|
|
10
|
+
// src/constants/api.ts
|
|
11
|
+
var DEFAULT_API_ROUTES_DIRECTORY = join2(SERVER_ROOT_DIRECTORY, "api");
|
|
6
12
|
var AUTH_API_SUBDIRECTORY = "auth";
|
|
7
13
|
var SAMPLE_API_SUBDIRECTORY = "sample";
|
|
8
14
|
var SAMPLE_CUSTOM_FILENAME = "custom.ts";
|
|
@@ -166,8 +172,8 @@ var CLOUDFLARE_BINDINGS = {
|
|
|
166
172
|
var MINIFLARE_D1_DIRECTORY = "miniflare-D1DatabaseObject";
|
|
167
173
|
|
|
168
174
|
// src/constants/database.ts
|
|
169
|
-
import { join as
|
|
170
|
-
var DEFAULT_DATABASE_DIRECTORY =
|
|
175
|
+
import { join as join3 } from "path";
|
|
176
|
+
var DEFAULT_DATABASE_DIRECTORY = join3("server", "db");
|
|
171
177
|
var SCHEMA_SUBDIRECTORY = "schema";
|
|
172
178
|
var DB_FILES = {
|
|
173
179
|
/** Index file name */
|
|
@@ -184,7 +190,7 @@ var DB_FILES = {
|
|
|
184
190
|
var DRIZZLE_CONFIG_FILES = ["drizzle.config.ts", "drizzle.config.js"];
|
|
185
191
|
|
|
186
192
|
// src/constants/godot.ts
|
|
187
|
-
import { join as
|
|
193
|
+
import { join as join4 } from "node:path";
|
|
188
194
|
var GODOT_PROJECT_FILE = "project.godot";
|
|
189
195
|
var GODOT_EXPORT_PRESETS_FILE = "export_presets.cfg";
|
|
190
196
|
var GODOT_WEB_PLATFORM = 'platform="Web"';
|
|
@@ -192,13 +198,13 @@ var GODOT_BUILD_DIRECTORIES = {
|
|
|
192
198
|
/** Root build directory (cleared before each export) */
|
|
193
199
|
ROOT: "build",
|
|
194
200
|
/** Web export subdirectory */
|
|
195
|
-
WEB:
|
|
201
|
+
WEB: join4("build", "web")
|
|
196
202
|
};
|
|
197
203
|
var GODOT_BUILD_OUTPUTS = {
|
|
198
204
|
/** Exported web build entry point */
|
|
199
|
-
INDEX_HTML:
|
|
205
|
+
INDEX_HTML: join4("build", "web", "index.html"),
|
|
200
206
|
/** Packaged zip file (created by Godot export) */
|
|
201
|
-
ZIP:
|
|
207
|
+
ZIP: join4("build", "web_playcademy.zip")
|
|
202
208
|
};
|
|
203
209
|
var GODOT_EXECUTABLE_PATTERNS = {
|
|
204
210
|
/** macOS app bundle suffix */
|
|
@@ -221,17 +227,17 @@ var CALLBACK_PATH = "/callback";
|
|
|
221
227
|
var SSO_AUTH_TIMEOUT_MS = 3e4;
|
|
222
228
|
|
|
223
229
|
// src/constants/paths.ts
|
|
224
|
-
import { join as
|
|
230
|
+
import { join as join5 } from "path";
|
|
225
231
|
var WORKSPACE_NAME = ".playcademy";
|
|
226
232
|
var CLI_DIRECTORIES = {
|
|
227
233
|
/** Root directory for CLI artifacts in workspace */
|
|
228
234
|
WORKSPACE: WORKSPACE_NAME,
|
|
229
235
|
/** Database directory within workspace */
|
|
230
|
-
DATABASE:
|
|
236
|
+
DATABASE: join5(WORKSPACE_NAME, "db"),
|
|
231
237
|
/** KV storage directory within workspace */
|
|
232
|
-
KV:
|
|
238
|
+
KV: join5(WORKSPACE_NAME, "kv"),
|
|
233
239
|
/** Bucket storage directory within workspace */
|
|
234
|
-
BUCKET:
|
|
240
|
+
BUCKET: join5(WORKSPACE_NAME, "bucket")
|
|
235
241
|
};
|
|
236
242
|
var CLI_USER_DIRECTORIES = {
|
|
237
243
|
/** User config directory for auth, games store, etc. */
|
|
@@ -239,7 +245,7 @@ var CLI_USER_DIRECTORIES = {
|
|
|
239
245
|
};
|
|
240
246
|
var CLI_DEFAULT_OUTPUTS = {
|
|
241
247
|
/** Default worker bundle output for debug command */
|
|
242
|
-
WORKER_BUNDLE:
|
|
248
|
+
WORKER_BUNDLE: join5(WORKSPACE_NAME, "worker-bundle.js")
|
|
243
249
|
};
|
|
244
250
|
var CLI_FILES = {
|
|
245
251
|
/** Auth store file in user config directory */
|
|
@@ -348,6 +354,7 @@ export {
|
|
|
348
354
|
PLAYCADEMY_AUTH_VERSION,
|
|
349
355
|
PLAYCADEMY_BASE_URLS,
|
|
350
356
|
PLAYCADEMY_DOMAINS,
|
|
357
|
+
PUBLIC_DIRECTORY,
|
|
351
358
|
SAMPLE_API_SUBDIRECTORY,
|
|
352
359
|
SAMPLE_BUCKET_FILENAME,
|
|
353
360
|
SAMPLE_CUSTOM_FILENAME,
|
package/dist/db.js
CHANGED
|
@@ -1430,12 +1430,18 @@ var init_file_loader = __esm({
|
|
|
1430
1430
|
|
|
1431
1431
|
// src/lib/db/path.ts
|
|
1432
1432
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, unlinkSync } from "fs";
|
|
1433
|
-
import { join as
|
|
1433
|
+
import { join as join6 } from "path";
|
|
1434
1434
|
|
|
1435
1435
|
// src/constants/api.ts
|
|
1436
|
+
import { join as join2 } from "node:path";
|
|
1437
|
+
|
|
1438
|
+
// src/constants/server.ts
|
|
1436
1439
|
import { join } from "node:path";
|
|
1437
|
-
var
|
|
1438
|
-
var SERVER_LIB_DIRECTORY = join(
|
|
1440
|
+
var SERVER_ROOT_DIRECTORY = "server";
|
|
1441
|
+
var SERVER_LIB_DIRECTORY = join(SERVER_ROOT_DIRECTORY, "lib");
|
|
1442
|
+
|
|
1443
|
+
// src/constants/api.ts
|
|
1444
|
+
var DEFAULT_API_ROUTES_DIRECTORY = join2(SERVER_ROOT_DIRECTORY, "api");
|
|
1439
1445
|
|
|
1440
1446
|
// ../../package.json
|
|
1441
1447
|
var package_default = {
|
|
@@ -1576,40 +1582,40 @@ var CLOUDFLARE_BINDINGS = {
|
|
|
1576
1582
|
var MINIFLARE_D1_DIRECTORY = "miniflare-D1DatabaseObject";
|
|
1577
1583
|
|
|
1578
1584
|
// src/constants/database.ts
|
|
1579
|
-
import { join as
|
|
1580
|
-
var DEFAULT_DATABASE_DIRECTORY =
|
|
1585
|
+
import { join as join3 } from "path";
|
|
1586
|
+
var DEFAULT_DATABASE_DIRECTORY = join3("server", "db");
|
|
1581
1587
|
|
|
1582
1588
|
// src/constants/godot.ts
|
|
1583
|
-
import { join as
|
|
1589
|
+
import { join as join4 } from "node:path";
|
|
1584
1590
|
var GODOT_BUILD_DIRECTORIES = {
|
|
1585
1591
|
/** Root build directory (cleared before each export) */
|
|
1586
1592
|
ROOT: "build",
|
|
1587
1593
|
/** Web export subdirectory */
|
|
1588
|
-
WEB:
|
|
1594
|
+
WEB: join4("build", "web")
|
|
1589
1595
|
};
|
|
1590
1596
|
var GODOT_BUILD_OUTPUTS = {
|
|
1591
1597
|
/** Exported web build entry point */
|
|
1592
|
-
INDEX_HTML:
|
|
1598
|
+
INDEX_HTML: join4("build", "web", "index.html"),
|
|
1593
1599
|
/** Packaged zip file (created by Godot export) */
|
|
1594
|
-
ZIP:
|
|
1600
|
+
ZIP: join4("build", "web_playcademy.zip")
|
|
1595
1601
|
};
|
|
1596
1602
|
|
|
1597
1603
|
// src/constants/paths.ts
|
|
1598
|
-
import { join as
|
|
1604
|
+
import { join as join5 } from "path";
|
|
1599
1605
|
var WORKSPACE_NAME = ".playcademy";
|
|
1600
1606
|
var CLI_DIRECTORIES = {
|
|
1601
1607
|
/** Root directory for CLI artifacts in workspace */
|
|
1602
1608
|
WORKSPACE: WORKSPACE_NAME,
|
|
1603
1609
|
/** Database directory within workspace */
|
|
1604
|
-
DATABASE:
|
|
1610
|
+
DATABASE: join5(WORKSPACE_NAME, "db"),
|
|
1605
1611
|
/** KV storage directory within workspace */
|
|
1606
|
-
KV:
|
|
1612
|
+
KV: join5(WORKSPACE_NAME, "kv"),
|
|
1607
1613
|
/** Bucket storage directory within workspace */
|
|
1608
|
-
BUCKET:
|
|
1614
|
+
BUCKET: join5(WORKSPACE_NAME, "bucket")
|
|
1609
1615
|
};
|
|
1610
1616
|
var CLI_DEFAULT_OUTPUTS = {
|
|
1611
1617
|
/** Default worker bundle output for debug command */
|
|
1612
|
-
WORKER_BUNDLE:
|
|
1618
|
+
WORKER_BUNDLE: join5(WORKSPACE_NAME, "worker-bundle.js")
|
|
1613
1619
|
};
|
|
1614
1620
|
var CLI_FILES = {
|
|
1615
1621
|
/** Auth store file in user config directory */
|
|
@@ -1660,11 +1666,11 @@ var ensureDirectoryExists = (dir) => {
|
|
|
1660
1666
|
}
|
|
1661
1667
|
};
|
|
1662
1668
|
var findMiniflareDatabase = (dbDir) => {
|
|
1663
|
-
const miniflareDir =
|
|
1669
|
+
const miniflareDir = join6(dbDir, MINIFLARE_D1_DIRECTORY);
|
|
1664
1670
|
if (!existsSync(miniflareDir)) return null;
|
|
1665
1671
|
const sqliteFiles = readdirSync(miniflareDir).filter((file) => file.endsWith(".sqlite"));
|
|
1666
1672
|
if (sqliteFiles.length === 0) return null;
|
|
1667
|
-
return
|
|
1673
|
+
return join6(miniflareDir, sqliteFiles[0]);
|
|
1668
1674
|
};
|
|
1669
1675
|
var migrateInitialDbToTarget = (initialPath, targetPath) => {
|
|
1670
1676
|
if (!existsSync(initialPath)) return;
|
|
@@ -1672,7 +1678,7 @@ var migrateInitialDbToTarget = (initialPath, targetPath) => {
|
|
|
1672
1678
|
unlinkSync(initialPath);
|
|
1673
1679
|
};
|
|
1674
1680
|
function getDevDbPath() {
|
|
1675
|
-
const initialDbPath =
|
|
1681
|
+
const initialDbPath = join6(DB_DIRECTORY, INITIAL_DB_NAME);
|
|
1676
1682
|
ensureDirectoryExists(DB_DIRECTORY);
|
|
1677
1683
|
const miniflareDbPath = findMiniflareDatabase(DB_DIRECTORY);
|
|
1678
1684
|
if (miniflareDbPath) {
|
|
@@ -1736,7 +1742,7 @@ async function bundleSeedWorker(seedFilePath, projectPath) {
|
|
|
1736
1742
|
// src/lib/db/reset.ts
|
|
1737
1743
|
import { execSync as execSync2 } from "child_process";
|
|
1738
1744
|
import { rmSync as rmSync2 } from "fs";
|
|
1739
|
-
import { join as
|
|
1745
|
+
import { join as join9 } from "path";
|
|
1740
1746
|
|
|
1741
1747
|
// ../utils/src/ansi.ts
|
|
1742
1748
|
var colors = {
|
|
@@ -1965,7 +1971,7 @@ init_package_json();
|
|
|
1965
1971
|
// ../utils/src/package-manager.ts
|
|
1966
1972
|
import { execSync } from "child_process";
|
|
1967
1973
|
import { existsSync as existsSync2 } from "fs";
|
|
1968
|
-
import { join as
|
|
1974
|
+
import { join as join7 } from "path";
|
|
1969
1975
|
function isCommandAvailable(command) {
|
|
1970
1976
|
try {
|
|
1971
1977
|
execSync(`command -v ${command}`, { stdio: "ignore" });
|
|
@@ -1975,16 +1981,16 @@ function isCommandAvailable(command) {
|
|
|
1975
1981
|
}
|
|
1976
1982
|
}
|
|
1977
1983
|
function detectPackageManager(cwd = process.cwd()) {
|
|
1978
|
-
if (existsSync2(
|
|
1984
|
+
if (existsSync2(join7(cwd, "bun.lock")) || existsSync2(join7(cwd, "bun.lockb"))) {
|
|
1979
1985
|
return "bun";
|
|
1980
1986
|
}
|
|
1981
|
-
if (existsSync2(
|
|
1987
|
+
if (existsSync2(join7(cwd, "pnpm-lock.yaml"))) {
|
|
1982
1988
|
return "pnpm";
|
|
1983
1989
|
}
|
|
1984
|
-
if (existsSync2(
|
|
1990
|
+
if (existsSync2(join7(cwd, "yarn.lock"))) {
|
|
1985
1991
|
return "yarn";
|
|
1986
1992
|
}
|
|
1987
|
-
if (existsSync2(
|
|
1993
|
+
if (existsSync2(join7(cwd, "package-lock.json"))) {
|
|
1988
1994
|
return "npm";
|
|
1989
1995
|
}
|
|
1990
1996
|
return detectByCommandAvailability();
|
|
@@ -2960,12 +2966,12 @@ var currentDir = dirname(fileURLToPath(import.meta.url));
|
|
|
2960
2966
|
// src/lib/core/import.ts
|
|
2961
2967
|
import { mkdtempSync, rmSync } from "fs";
|
|
2962
2968
|
import { tmpdir } from "os";
|
|
2963
|
-
import { join as
|
|
2969
|
+
import { join as join8 } from "path";
|
|
2964
2970
|
import { pathToFileURL } from "url";
|
|
2965
2971
|
import * as esbuild from "esbuild";
|
|
2966
2972
|
async function importTypescriptFile(filePath, bundleOptions) {
|
|
2967
|
-
const tempDir = mkdtempSync(
|
|
2968
|
-
const outFile =
|
|
2973
|
+
const tempDir = mkdtempSync(join8(tmpdir(), "playcademy-import-"));
|
|
2974
|
+
const outFile = join8(tempDir, "bundle.mjs");
|
|
2969
2975
|
try {
|
|
2970
2976
|
await esbuild.build({
|
|
2971
2977
|
entryPoints: [filePath],
|
|
@@ -2988,7 +2994,7 @@ async function importTypescriptFile(filePath, bundleOptions) {
|
|
|
2988
2994
|
// src/lib/db/reset.ts
|
|
2989
2995
|
async function resetDatabase(workspace, mf, options = { debug: false }) {
|
|
2990
2996
|
const { debug } = options;
|
|
2991
|
-
const dbDir =
|
|
2997
|
+
const dbDir = join9(workspace, CLI_DIRECTORIES.DATABASE);
|
|
2992
2998
|
await runStep(
|
|
2993
2999
|
"Resetting database...",
|
|
2994
3000
|
async () => {
|