@playdrop/playdrop-cli 0.12.33 → 0.12.35

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.
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.12.9",
3
- "build": 37,
4
- "runtimeSdkVersion": "0.12.5",
5
- "runtimeSdkBuild": 2,
2
+ "version": "0.12.35",
3
+ "build": 1,
4
+ "runtimeSdkVersion": "0.12.35",
5
+ "runtimeSdkBuild": 1,
6
6
  "clients": {
7
7
  "all": {
8
8
  "minimumVersion": "0.7.4"
@@ -112,6 +112,9 @@ async function loadWorkspaceAwareConfig(command, options) {
112
112
  ?? (process.env.PLAYDROP_WORKER_CONTEXT === '1' ? process.cwd() : undefined);
113
113
  try {
114
114
  workspaceAuth = workspacePath ? (0, workspaceAuth_1.findWorkspaceAuthConfig)(workspacePath) : null;
115
+ if (!workspaceAuth && workspacePath && process.env.PLAYDROP_WORKER_CONTEXT === '1') {
116
+ workspaceAuth = (0, workspaceAuth_1.findWorkerTaskWorkspaceAuthConfig)(workspacePath);
117
+ }
115
118
  }
116
119
  catch (error) {
117
120
  if (error instanceof workspaceAuth_1.WorkspaceAuthConfigError) {
@@ -15,3 +15,4 @@ export declare class WorkspaceAuthConfigError extends Error {
15
15
  constructor(filePath: string, reason: 'invalid_json' | 'invalid_shape' | 'missing_owner_username');
16
16
  }
17
17
  export declare function findWorkspaceAuthConfig(startPath: string): ResolvedWorkspaceAuthConfig | null;
18
+ export declare function findWorkerTaskWorkspaceAuthConfig(startPath: string): ResolvedWorkspaceAuthConfig | null;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WorkspaceAuthConfigError = void 0;
4
4
  exports.findWorkspaceAuthConfig = findWorkspaceAuthConfig;
5
+ exports.findWorkerTaskWorkspaceAuthConfig = findWorkerTaskWorkspaceAuthConfig;
5
6
  const node_fs_1 = require("node:fs");
6
7
  const node_path_1 = require("node:path");
7
8
  class WorkspaceAuthConfigError extends Error {
@@ -13,6 +14,7 @@ class WorkspaceAuthConfigError extends Error {
13
14
  }
14
15
  exports.WorkspaceAuthConfigError = WorkspaceAuthConfigError;
15
16
  const WORKSPACE_AUTH_FILENAME = '.playdrop.json';
17
+ const WORKER_TASK_CONTEXT_PATH = (0, node_path_1.join)('.playdrop', 'task.json');
16
18
  function normalizeOwnerUsername(value) {
17
19
  if (typeof value !== 'string') {
18
20
  return null;
@@ -87,3 +89,60 @@ function findWorkspaceAuthConfig(startPath) {
87
89
  current = parent;
88
90
  }
89
91
  }
92
+ function findWorkerTaskWorkspaceAuthConfig(startPath) {
93
+ let current = (0, node_path_1.resolve)(startPath);
94
+ if ((0, node_fs_1.existsSync)(current) && (0, node_fs_1.statSync)(current).isFile()) {
95
+ current = (0, node_path_1.dirname)(current);
96
+ }
97
+ while (true) {
98
+ const candidate = (0, node_path_1.join)(current, WORKER_TASK_CONTEXT_PATH);
99
+ if ((0, node_fs_1.existsSync)(candidate) && (0, node_fs_1.statSync)(candidate).isFile()) {
100
+ let parsed;
101
+ try {
102
+ parsed = JSON.parse((0, node_fs_1.readFileSync)(candidate, 'utf8'));
103
+ }
104
+ catch {
105
+ throw new WorkspaceAuthConfigError(candidate, 'invalid_json');
106
+ }
107
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
108
+ throw new WorkspaceAuthConfigError(candidate, 'invalid_shape');
109
+ }
110
+ const document = parsed;
111
+ const task = document.task && typeof document.task === 'object' && !Array.isArray(document.task)
112
+ ? document.task
113
+ : null;
114
+ const worker = document.worker && typeof document.worker === 'object' && !Array.isArray(document.worker)
115
+ ? document.worker
116
+ : null;
117
+ const metadata = task?.metadata && typeof task.metadata === 'object' && !Array.isArray(task.metadata)
118
+ ? task.metadata
119
+ : null;
120
+ const playdrop = metadata?.playdrop && typeof metadata.playdrop === 'object' && !Array.isArray(metadata.playdrop)
121
+ ? metadata.playdrop
122
+ : null;
123
+ const ownerUsername = normalizeOwnerUsername(playdrop?.creatorUsername);
124
+ const taskToken = normalizeTaskToken(task?.token);
125
+ const taskId = normalizePositiveInteger(task?.id);
126
+ const taskAttempt = normalizePositiveInteger(task?.attempt);
127
+ if (document.protocolVersion !== 2 || !task || !worker || !ownerUsername || !taskToken || !taskId || !taskAttempt) {
128
+ throw new WorkspaceAuthConfigError(candidate, ownerUsername ? 'invalid_shape' : 'missing_owner_username');
129
+ }
130
+ return {
131
+ path: candidate,
132
+ directory: current,
133
+ config: {
134
+ ownerUsername,
135
+ env: normalizeEnv(worker.env),
136
+ taskToken,
137
+ taskId,
138
+ taskAttempt,
139
+ },
140
+ };
141
+ }
142
+ const parent = (0, node_path_1.dirname)(current);
143
+ if (parent === current) {
144
+ return null;
145
+ }
146
+ current = parent;
147
+ }
148
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.12.9",
3
- "build": 37,
4
- "runtimeSdkVersion": "0.12.5",
5
- "runtimeSdkBuild": 2,
2
+ "version": "0.12.35",
3
+ "build": 1,
4
+ "runtimeSdkVersion": "0.12.35",
5
+ "runtimeSdkBuild": 1,
6
6
  "clients": {
7
7
  "all": {
8
8
  "minimumVersion": "0.7.4"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playdrop/playdrop-cli",
3
- "version": "0.12.33",
3
+ "version": "0.12.35",
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": {