@playdrop/playdrop-cli 0.10.1 → 0.10.2
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/config/client-meta.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validate = validate;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
4
6
|
const types_1 = require("@playdrop/types");
|
|
5
7
|
const types_2 = require("@playdrop/types");
|
|
6
8
|
const commandContext_1 = require("../commandContext");
|
|
@@ -12,6 +14,66 @@ const assetSpecs_1 = require("../assetSpecs");
|
|
|
12
14
|
const externalAssetPackValidation_1 = require("../externalAssetPackValidation");
|
|
13
15
|
const dev_1 = require("./dev");
|
|
14
16
|
const upload_content_1 = require("./upload-content");
|
|
17
|
+
function normalizePositivePort(value) {
|
|
18
|
+
const parsed = typeof value === 'number' ? value : Number.parseInt(String(value ?? ''), 10);
|
|
19
|
+
return Number.isInteger(parsed) && parsed > 0 && parsed <= 65535 ? parsed : null;
|
|
20
|
+
}
|
|
21
|
+
function findWorkspaceMetadataFile(startPath) {
|
|
22
|
+
let current = (0, node_path_1.resolve)(startPath);
|
|
23
|
+
if ((0, node_fs_1.existsSync)(current) && (0, node_fs_1.statSync)(current).isFile()) {
|
|
24
|
+
current = (0, node_path_1.dirname)(current);
|
|
25
|
+
}
|
|
26
|
+
while (true) {
|
|
27
|
+
const workspacePinPath = (0, node_path_1.join)(current, '.playdrop.json');
|
|
28
|
+
if ((0, node_fs_1.existsSync)(workspacePinPath) && (0, node_fs_1.statSync)(workspacePinPath).isFile()) {
|
|
29
|
+
return workspacePinPath;
|
|
30
|
+
}
|
|
31
|
+
const taskContextPath = (0, node_path_1.join)(current, '.playdrop', 'task.json');
|
|
32
|
+
if ((0, node_fs_1.existsSync)(taskContextPath) && (0, node_fs_1.statSync)(taskContextPath).isFile()) {
|
|
33
|
+
return taskContextPath;
|
|
34
|
+
}
|
|
35
|
+
const parent = (0, node_path_1.dirname)(current);
|
|
36
|
+
if (parent === current) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
current = parent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function readTaskScopedDevRouterPort(workspacePath) {
|
|
43
|
+
const metadataPath = findWorkspaceMetadataFile(workspacePath);
|
|
44
|
+
if (!metadataPath) {
|
|
45
|
+
throw new Error('project_validate_task_dev_port_missing');
|
|
46
|
+
}
|
|
47
|
+
let parsed;
|
|
48
|
+
try {
|
|
49
|
+
parsed = JSON.parse((0, node_fs_1.readFileSync)(metadataPath, 'utf8'));
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
throw new Error(`project_validate_task_dev_port_invalid_json:${metadataPath}`);
|
|
53
|
+
}
|
|
54
|
+
const port = normalizePositivePort(parsed?.devPort);
|
|
55
|
+
if (!port) {
|
|
56
|
+
throw new Error(`project_validate_task_dev_port_missing:${metadataPath}`);
|
|
57
|
+
}
|
|
58
|
+
return { file: metadataPath, port };
|
|
59
|
+
}
|
|
60
|
+
function resolveValidationDevRouterPort(workspacePath, taskScoped) {
|
|
61
|
+
if (!taskScoped) {
|
|
62
|
+
return (0, dev_1.resolveDevRouterPort)(process.env.PLAYDROP_DEV_ROUTER_PORT);
|
|
63
|
+
}
|
|
64
|
+
const taskPort = readTaskScopedDevRouterPort(workspacePath);
|
|
65
|
+
const envPortRaw = process.env.PLAYDROP_DEV_ROUTER_PORT;
|
|
66
|
+
if (envPortRaw !== undefined && envPortRaw.trim()) {
|
|
67
|
+
const envPort = normalizePositivePort(envPortRaw);
|
|
68
|
+
if (!envPort) {
|
|
69
|
+
throw new Error(`project_validate_env_dev_port_invalid:${envPortRaw}`);
|
|
70
|
+
}
|
|
71
|
+
if (envPort !== taskPort.port) {
|
|
72
|
+
throw new Error(`project_validate_worker_dev_port_mismatch:env=${envPort}:task=${taskPort.port}:${taskPort.file}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return taskPort.port;
|
|
76
|
+
}
|
|
15
77
|
function buildLocalAssetSpecLookups(tasks) {
|
|
16
78
|
const exactByRef = new Map();
|
|
17
79
|
const uniqueByNameVersion = new Map();
|
|
@@ -115,7 +177,7 @@ async function loadHostedLaunchValidationContext(workspacePath, envOverride) {
|
|
|
115
177
|
apiBase: ctx.envConfig.apiBase,
|
|
116
178
|
webBase: ctx.envConfig.webBase ?? null,
|
|
117
179
|
token: ctx.token,
|
|
118
|
-
devRouterPort: (
|
|
180
|
+
devRouterPort: resolveValidationDevRouterPort(workspacePath, Boolean(ctx.workspaceAuth?.config.taskToken)),
|
|
119
181
|
taskScoped: Boolean(ctx.workspaceAuth?.config.taskToken),
|
|
120
182
|
};
|
|
121
183
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playdrop/playdrop-cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Official Playdrop CLI for publishing browser games, creator apps, and AI-generated game assets on playdrop.ai",
|
|
5
5
|
"homepage": "https://www.playdrop.ai",
|
|
6
6
|
"repository": {
|