playcademy 0.14.15 → 0.14.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -8
- package/dist/utils.js +14 -7
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6091,6 +6091,7 @@ init_core();
|
|
|
6091
6091
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
6092
6092
|
import { tmpdir as tmpdir2 } from "os";
|
|
6093
6093
|
import { join as join14, relative as relative2 } from "path";
|
|
6094
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
6094
6095
|
|
|
6095
6096
|
// src/lib/deploy/hash.ts
|
|
6096
6097
|
init_file_loader();
|
|
@@ -6154,7 +6155,8 @@ async function discoverRoutes(apiDir) {
|
|
|
6154
6155
|
async function detectExportedMethods(filePath) {
|
|
6155
6156
|
try {
|
|
6156
6157
|
const importPath = await transpileRoute(filePath);
|
|
6157
|
-
const
|
|
6158
|
+
const specifier = pathToFileURL2(importPath).href;
|
|
6159
|
+
const module = await import(specifier);
|
|
6158
6160
|
const methods = [];
|
|
6159
6161
|
if (module.GET) methods.push("GET");
|
|
6160
6162
|
if (module.POST) methods.push("POST");
|
|
@@ -6210,7 +6212,8 @@ async function registerCustomRoutes(app, routes) {
|
|
|
6210
6212
|
for (const route of routes) {
|
|
6211
6213
|
try {
|
|
6212
6214
|
const importPath = await transpileRoute(route.absolutePath);
|
|
6213
|
-
const
|
|
6215
|
+
const specifier = `${pathToFileURL2(importPath).href}?t=${Date.now()}`;
|
|
6216
|
+
const handler = await import(specifier);
|
|
6214
6217
|
if (handler.GET) app.get(route.path, handler.GET);
|
|
6215
6218
|
if (handler.POST) app.post(route.path, handler.POST);
|
|
6216
6219
|
if (handler.PUT) app.put(route.path, handler.PUT);
|
|
@@ -6368,15 +6371,20 @@ async function bundleBackend(config, options = {}) {
|
|
|
6368
6371
|
customRoutes: customRouteData
|
|
6369
6372
|
};
|
|
6370
6373
|
}
|
|
6374
|
+
function buildCustomRouteImportStatements(customRoutes, customRoutesDir) {
|
|
6375
|
+
const normalizedRoutesDir = customRoutesDir.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
6376
|
+
const customRoutesPrefix = normalizedRoutesDir.endsWith("/") ? normalizedRoutesDir : `${normalizedRoutesDir}/`;
|
|
6377
|
+
return customRoutes.map((route, i) => {
|
|
6378
|
+
const normalizedFile = route.file.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
6379
|
+
const importPath = normalizedFile.startsWith(customRoutesPrefix) ? normalizedFile.slice(customRoutesPrefix.length) : normalizedFile;
|
|
6380
|
+
return `import * as customRoute${i} from '@game-api/${importPath}'`;
|
|
6381
|
+
}).join("\n");
|
|
6382
|
+
}
|
|
6371
6383
|
function generateEntryCode(customRoutes, customRoutesDir, hasAuth) {
|
|
6372
6384
|
if (customRoutes.length === 0) {
|
|
6373
6385
|
return entryTemplate;
|
|
6374
6386
|
}
|
|
6375
|
-
const
|
|
6376
|
-
const importStatements = customRoutes.map((route, i) => {
|
|
6377
|
-
const importPath = route.file.startsWith(customRoutesPrefix) ? route.file.slice(customRoutesPrefix.length) : route.file;
|
|
6378
|
-
return `import * as customRoute${i} from '@game-api/${importPath}'`;
|
|
6379
|
-
}).join("\n");
|
|
6387
|
+
const importStatements = buildCustomRouteImportStatements(customRoutes, customRoutesDir);
|
|
6380
6388
|
const withImports = entryTemplate.replace(
|
|
6381
6389
|
"// \u26A0\uFE0F BUILD_MARKER: CUSTOM_ROUTE_IMPORTS \u26A0\uFE0F",
|
|
6382
6390
|
importStatements
|
|
@@ -7222,7 +7230,7 @@ import { join as join18 } from "path";
|
|
|
7222
7230
|
// package.json
|
|
7223
7231
|
var package_default2 = {
|
|
7224
7232
|
name: "playcademy",
|
|
7225
|
-
version: "0.14.
|
|
7233
|
+
version: "0.14.16",
|
|
7226
7234
|
type: "module",
|
|
7227
7235
|
exports: {
|
|
7228
7236
|
".": {
|
|
@@ -9133,6 +9141,7 @@ async function saveDeploymentState(game, backendMetadata, context2) {
|
|
|
9133
9141
|
|
|
9134
9142
|
// src/lib/deploy/secrets.ts
|
|
9135
9143
|
init_core();
|
|
9144
|
+
import { ApiError as ApiError2 } from "@playcademy/sdk";
|
|
9136
9145
|
function compareSecrets(current, previous) {
|
|
9137
9146
|
const currentKeys = Object.keys(current);
|
|
9138
9147
|
const changes = [];
|
|
@@ -9158,6 +9167,10 @@ async function fetchSecretsForDeployment(slug) {
|
|
|
9158
9167
|
const keys = Object.keys(secrets);
|
|
9159
9168
|
return { secrets, keys };
|
|
9160
9169
|
} catch (error) {
|
|
9170
|
+
if (error instanceof ApiError2 && error.status === 404) {
|
|
9171
|
+
logger.debug(`[Secrets] No secrets configured for game (404)`);
|
|
9172
|
+
return { secrets: {}, keys: [] };
|
|
9173
|
+
}
|
|
9161
9174
|
logger.warn(
|
|
9162
9175
|
`Could not fetch secrets: ${error instanceof Error ? error.message : String(error)}`
|
|
9163
9176
|
);
|
|
@@ -9210,6 +9223,14 @@ async function prepareDeploymentContext(options) {
|
|
|
9210
9223
|
if (!existingGame && finalConfig.slug) {
|
|
9211
9224
|
existingGame = existingGames.find((g) => g.slug === finalConfig.slug);
|
|
9212
9225
|
}
|
|
9226
|
+
if (existingGame) {
|
|
9227
|
+
const currentUser = await client.users.me();
|
|
9228
|
+
const isAdmin = currentUser.role === "admin";
|
|
9229
|
+
const isOwner = existingGame.developerId === currentUser.id;
|
|
9230
|
+
if (!isAdmin && !isOwner) {
|
|
9231
|
+
throw new Error(`Unable to deploy '${existingGame.slug}': You do not own this game`);
|
|
9232
|
+
}
|
|
9233
|
+
}
|
|
9213
9234
|
const gameIsDeployed = existingGame ? isGameDeployed(existingGame) : false;
|
|
9214
9235
|
if (existingGame && gameIsDeployed) {
|
|
9215
9236
|
finalConfig.slug = existingGame.slug;
|
|
@@ -15037,6 +15058,7 @@ export {
|
|
|
15037
15058
|
addEmailProvider,
|
|
15038
15059
|
addOAuthProvider,
|
|
15039
15060
|
analyzeChanges,
|
|
15061
|
+
buildCustomRouteImportStatements,
|
|
15040
15062
|
bundleBackend,
|
|
15041
15063
|
bundleSeedWorker,
|
|
15042
15064
|
calculateConfigDiff,
|
package/dist/utils.js
CHANGED
|
@@ -3580,6 +3580,7 @@ init_file_loader();
|
|
|
3580
3580
|
import { mkdir, writeFile } from "fs/promises";
|
|
3581
3581
|
import { tmpdir as tmpdir2 } from "os";
|
|
3582
3582
|
import { join as join9, relative } from "path";
|
|
3583
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
3583
3584
|
|
|
3584
3585
|
// src/lib/deploy/hash.ts
|
|
3585
3586
|
import { createHash } from "crypto";
|
|
@@ -3614,7 +3615,8 @@ async function discoverRoutes(apiDir) {
|
|
|
3614
3615
|
async function detectExportedMethods(filePath) {
|
|
3615
3616
|
try {
|
|
3616
3617
|
const importPath = await transpileRoute(filePath);
|
|
3617
|
-
const
|
|
3618
|
+
const specifier = pathToFileURL2(importPath).href;
|
|
3619
|
+
const module = await import(specifier);
|
|
3618
3620
|
const methods = [];
|
|
3619
3621
|
if (module.GET) methods.push("GET");
|
|
3620
3622
|
if (module.POST) methods.push("POST");
|
|
@@ -3811,15 +3813,20 @@ async function bundleBackend(config, options = {}) {
|
|
|
3811
3813
|
customRoutes: customRouteData
|
|
3812
3814
|
};
|
|
3813
3815
|
}
|
|
3816
|
+
function buildCustomRouteImportStatements(customRoutes, customRoutesDir) {
|
|
3817
|
+
const normalizedRoutesDir = customRoutesDir.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
3818
|
+
const customRoutesPrefix = normalizedRoutesDir.endsWith("/") ? normalizedRoutesDir : `${normalizedRoutesDir}/`;
|
|
3819
|
+
return customRoutes.map((route, i) => {
|
|
3820
|
+
const normalizedFile = route.file.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
3821
|
+
const importPath = normalizedFile.startsWith(customRoutesPrefix) ? normalizedFile.slice(customRoutesPrefix.length) : normalizedFile;
|
|
3822
|
+
return `import * as customRoute${i} from '@game-api/${importPath}'`;
|
|
3823
|
+
}).join("\n");
|
|
3824
|
+
}
|
|
3814
3825
|
function generateEntryCode(customRoutes, customRoutesDir, hasAuth) {
|
|
3815
3826
|
if (customRoutes.length === 0) {
|
|
3816
3827
|
return entryTemplate;
|
|
3817
3828
|
}
|
|
3818
|
-
const
|
|
3819
|
-
const importStatements = customRoutes.map((route, i) => {
|
|
3820
|
-
const importPath = route.file.startsWith(customRoutesPrefix) ? route.file.slice(customRoutesPrefix.length) : route.file;
|
|
3821
|
-
return `import * as customRoute${i} from '@game-api/${importPath}'`;
|
|
3822
|
-
}).join("\n");
|
|
3829
|
+
const importStatements = buildCustomRouteImportStatements(customRoutes, customRoutesDir);
|
|
3823
3830
|
const withImports = entryTemplate.replace(
|
|
3824
3831
|
"// \u26A0\uFE0F BUILD_MARKER: CUSTOM_ROUTE_IMPORTS \u26A0\uFE0F",
|
|
3825
3832
|
importStatements
|
|
@@ -3863,7 +3870,7 @@ import { join as join11 } from "path";
|
|
|
3863
3870
|
// package.json
|
|
3864
3871
|
var package_default2 = {
|
|
3865
3872
|
name: "playcademy",
|
|
3866
|
-
version: "0.14.
|
|
3873
|
+
version: "0.14.16",
|
|
3867
3874
|
type: "module",
|
|
3868
3875
|
exports: {
|
|
3869
3876
|
".": {
|
package/dist/version.js
CHANGED