@quenty/nevermore-cli 4.41.1 → 4.42.1-canary.783.30683193716.0

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.
Files changed (207) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/args/global-args.d.ts +13 -0
  3. package/dist/args/global-args.d.ts.map +1 -1
  4. package/dist/commands/batch-command/batch-deploy-command.d.ts +3 -0
  5. package/dist/commands/batch-command/batch-deploy-command.d.ts.map +1 -1
  6. package/dist/commands/batch-command/batch-deploy-command.js +90 -1
  7. package/dist/commands/batch-command/batch-deploy-command.js.map +1 -1
  8. package/dist/commands/batch-command/batch-test-command.d.ts.map +1 -1
  9. package/dist/commands/batch-command/batch-test-command.js +25 -4
  10. package/dist/commands/batch-command/batch-test-command.js.map +1 -1
  11. package/dist/commands/deploy-command/deploy-init.js +1 -1
  12. package/dist/commands/deploy-command/deploy-init.js.map +1 -1
  13. package/dist/commands/deploy-command/index.d.ts +3 -0
  14. package/dist/commands/deploy-command/index.d.ts.map +1 -1
  15. package/dist/commands/deploy-command/index.js +297 -60
  16. package/dist/commands/deploy-command/index.js.map +1 -1
  17. package/dist/commands/deploy-command/select-target.js +1 -1
  18. package/dist/commands/deploy-command/select-target.js.map +1 -1
  19. package/dist/commands/deploy-command/version-command.d.ts.map +1 -1
  20. package/dist/commands/deploy-command/version-command.js +138 -12
  21. package/dist/commands/deploy-command/version-command.js.map +1 -1
  22. package/dist/commands/test-command/test-command.d.ts.map +1 -1
  23. package/dist/commands/test-command/test-command.js +23 -11
  24. package/dist/commands/test-command/test-command.js.map +1 -1
  25. package/dist/nevermore.js +17 -0
  26. package/dist/nevermore.js.map +1 -1
  27. package/dist/utils/batch/changed-packages-utils.d.ts +1 -1
  28. package/dist/utils/batch/changed-packages-utils.d.ts.map +1 -1
  29. package/dist/utils/batch/changed-packages-utils.js +1 -1
  30. package/dist/utils/batch/changed-packages-utils.js.map +1 -1
  31. package/dist/utils/build/base-place-resolver-factory.d.ts +25 -0
  32. package/dist/utils/build/base-place-resolver-factory.d.ts.map +1 -0
  33. package/dist/utils/build/base-place-resolver-factory.js +40 -0
  34. package/dist/utils/build/base-place-resolver-factory.js.map +1 -0
  35. package/dist/utils/build/build.d.ts +13 -2
  36. package/dist/utils/build/build.d.ts.map +1 -1
  37. package/dist/utils/build/build.js.map +1 -1
  38. package/dist/utils/build/upload.d.ts +1 -1
  39. package/dist/utils/build/upload.d.ts.map +1 -1
  40. package/dist/utils/deploy/deploy-metadata.d.ts +1 -1
  41. package/dist/utils/deploy/deploy-metadata.d.ts.map +1 -1
  42. package/dist/utils/job-context/base-job-context.d.ts +3 -1
  43. package/dist/utils/job-context/base-job-context.d.ts.map +1 -1
  44. package/dist/utils/job-context/base-job-context.js +45 -6
  45. package/dist/utils/job-context/base-job-context.js.map +1 -1
  46. package/dist/utils/job-context/batch-script-job-context.d.ts +6 -0
  47. package/dist/utils/job-context/batch-script-job-context.d.ts.map +1 -1
  48. package/dist/utils/job-context/batch-script-job-context.js +13 -0
  49. package/dist/utils/job-context/batch-script-job-context.js.map +1 -1
  50. package/dist/utils/job-context/cloud-job-context.d.ts +2 -1
  51. package/dist/utils/job-context/cloud-job-context.d.ts.map +1 -1
  52. package/dist/utils/job-context/cloud-job-context.js +2 -2
  53. package/dist/utils/job-context/cloud-job-context.js.map +1 -1
  54. package/dist/utils/job-context/local-job-context.d.ts +2 -1
  55. package/dist/utils/job-context/local-job-context.d.ts.map +1 -1
  56. package/dist/utils/job-context/local-job-context.js +2 -2
  57. package/dist/utils/job-context/local-job-context.js.map +1 -1
  58. package/dist/utils/open-cloud/open-cloud-client.d.ts +20 -2
  59. package/dist/utils/open-cloud/open-cloud-client.d.ts.map +1 -1
  60. package/dist/utils/open-cloud/open-cloud-client.js +78 -21
  61. package/dist/utils/open-cloud/open-cloud-client.js.map +1 -1
  62. package/dist/utils/open-cloud/open-cloud-client.test.js +89 -12
  63. package/dist/utils/open-cloud/open-cloud-client.test.js.map +1 -1
  64. package/dist/utils/testing/parsers/batch-log-parser.d.ts +13 -5
  65. package/dist/utils/testing/parsers/batch-log-parser.d.ts.map +1 -1
  66. package/dist/utils/testing/parsers/batch-log-parser.js +114 -68
  67. package/dist/utils/testing/parsers/batch-log-parser.js.map +1 -1
  68. package/dist/utils/testing/parsers/batch-log-parser.test.js +57 -5
  69. package/dist/utils/testing/parsers/batch-log-parser.test.js.map +1 -1
  70. package/dist/utils/testing/parsers/traceback-parser.d.ts +31 -0
  71. package/dist/utils/testing/parsers/traceback-parser.d.ts.map +1 -0
  72. package/dist/utils/testing/parsers/traceback-parser.js +91 -0
  73. package/dist/utils/testing/parsers/traceback-parser.js.map +1 -0
  74. package/dist/utils/testing/parsers/traceback-parser.test.d.ts +2 -0
  75. package/dist/utils/testing/parsers/traceback-parser.test.d.ts.map +1 -0
  76. package/dist/utils/testing/parsers/traceback-parser.test.js +45 -0
  77. package/dist/utils/testing/parsers/traceback-parser.test.js.map +1 -0
  78. package/dist/utils/testing/runner/combined-project-generator.d.ts +1 -1
  79. package/dist/utils/testing/runner/combined-project-generator.d.ts.map +1 -1
  80. package/dist/utils/testing/runner/test-runner.d.ts +9 -1
  81. package/dist/utils/testing/runner/test-runner.d.ts.map +1 -1
  82. package/dist/utils/testing/runner/test-runner.js +28 -3
  83. package/dist/utils/testing/runner/test-runner.js.map +1 -1
  84. package/dist/utils/testing/runner/test-runner.test.d.ts +2 -0
  85. package/dist/utils/testing/runner/test-runner.test.d.ts.map +1 -0
  86. package/dist/utils/testing/runner/test-runner.test.js +18 -0
  87. package/dist/utils/testing/runner/test-runner.test.js.map +1 -0
  88. package/dist/utils/testing/test-log-parser.d.ts +32 -1
  89. package/dist/utils/testing/test-log-parser.d.ts.map +1 -1
  90. package/dist/utils/testing/test-log-parser.js +53 -9
  91. package/dist/utils/testing/test-log-parser.js.map +1 -1
  92. package/dist/utils/testing/test-log-parser.test.d.ts +2 -0
  93. package/dist/utils/testing/test-log-parser.test.d.ts.map +1 -0
  94. package/dist/utils/testing/test-log-parser.test.js +56 -0
  95. package/dist/utils/testing/test-log-parser.test.js.map +1 -0
  96. package/dist/utils/watch/github-context.d.ts +50 -0
  97. package/dist/utils/watch/github-context.d.ts.map +1 -0
  98. package/dist/utils/watch/github-context.js +125 -0
  99. package/dist/utils/watch/github-context.js.map +1 -0
  100. package/dist/utils/watch/github-context.test.d.ts +2 -0
  101. package/dist/utils/watch/github-context.test.d.ts.map +1 -0
  102. package/dist/utils/watch/github-context.test.js +112 -0
  103. package/dist/utils/watch/github-context.test.js.map +1 -0
  104. package/dist/utils/watch/http-watch-registry.d.ts +40 -0
  105. package/dist/utils/watch/http-watch-registry.d.ts.map +1 -0
  106. package/dist/utils/watch/http-watch-registry.js +262 -0
  107. package/dist/utils/watch/http-watch-registry.js.map +1 -0
  108. package/dist/utils/watch/http-watch-registry.test.d.ts +2 -0
  109. package/dist/utils/watch/http-watch-registry.test.d.ts.map +1 -0
  110. package/dist/utils/watch/http-watch-registry.test.js +211 -0
  111. package/dist/utils/watch/http-watch-registry.test.js.map +1 -0
  112. package/dist/utils/watch/local-watch-loop.d.ts +50 -0
  113. package/dist/utils/watch/local-watch-loop.d.ts.map +1 -0
  114. package/dist/utils/watch/local-watch-loop.js +103 -0
  115. package/dist/utils/watch/local-watch-loop.js.map +1 -0
  116. package/dist/utils/watch/local-watch-loop.test.d.ts +2 -0
  117. package/dist/utils/watch/local-watch-loop.test.d.ts.map +1 -0
  118. package/dist/utils/watch/local-watch-loop.test.js +170 -0
  119. package/dist/utils/watch/local-watch-loop.test.js.map +1 -0
  120. package/dist/utils/watch/register-notify-watches.d.ts +41 -0
  121. package/dist/utils/watch/register-notify-watches.d.ts.map +1 -0
  122. package/dist/utils/watch/register-notify-watches.js +159 -0
  123. package/dist/utils/watch/register-notify-watches.js.map +1 -0
  124. package/dist/utils/watch/register-notify-watches.test.d.ts +2 -0
  125. package/dist/utils/watch/register-notify-watches.test.d.ts.map +1 -0
  126. package/dist/utils/watch/register-notify-watches.test.js +225 -0
  127. package/dist/utils/watch/register-notify-watches.test.js.map +1 -0
  128. package/dist/utils/watch/register-watches.d.ts +68 -0
  129. package/dist/utils/watch/register-watches.d.ts.map +1 -0
  130. package/dist/utils/watch/register-watches.js +221 -0
  131. package/dist/utils/watch/register-watches.js.map +1 -0
  132. package/dist/utils/watch/register-watches.test.d.ts +2 -0
  133. package/dist/utils/watch/register-watches.test.d.ts.map +1 -0
  134. package/dist/utils/watch/register-watches.test.js +576 -0
  135. package/dist/utils/watch/register-watches.test.js.map +1 -0
  136. package/dist/utils/watch/stream-watch-loop.d.ts +54 -0
  137. package/dist/utils/watch/stream-watch-loop.d.ts.map +1 -0
  138. package/dist/utils/watch/stream-watch-loop.js +282 -0
  139. package/dist/utils/watch/stream-watch-loop.js.map +1 -0
  140. package/dist/utils/watch/stream-watch-loop.test.d.ts +2 -0
  141. package/dist/utils/watch/stream-watch-loop.test.d.ts.map +1 -0
  142. package/dist/utils/watch/stream-watch-loop.test.js +392 -0
  143. package/dist/utils/watch/stream-watch-loop.test.js.map +1 -0
  144. package/dist/utils/watch/websocket-watch-stream.d.ts +25 -0
  145. package/dist/utils/watch/websocket-watch-stream.d.ts.map +1 -0
  146. package/dist/utils/watch/websocket-watch-stream.js +306 -0
  147. package/dist/utils/watch/websocket-watch-stream.js.map +1 -0
  148. package/dist/utils/watch/websocket-watch-stream.test.d.ts +2 -0
  149. package/dist/utils/watch/websocket-watch-stream.test.d.ts.map +1 -0
  150. package/dist/utils/watch/websocket-watch-stream.test.js +475 -0
  151. package/dist/utils/watch/websocket-watch-stream.test.js.map +1 -0
  152. package/package.json +7 -4
  153. package/src/args/global-args.ts +13 -0
  154. package/src/commands/batch-command/batch-deploy-command.ts +105 -1
  155. package/src/commands/batch-command/batch-test-command.ts +86 -60
  156. package/src/commands/deploy-command/deploy-init.ts +1 -1
  157. package/src/commands/deploy-command/index.ts +327 -32
  158. package/src/commands/deploy-command/select-target.ts +1 -1
  159. package/src/commands/deploy-command/version-command.ts +215 -21
  160. package/src/commands/test-command/test-command.ts +31 -22
  161. package/src/nevermore.ts +19 -0
  162. package/src/utils/batch/changed-packages-utils.ts +1 -1
  163. package/src/utils/build/base-place-resolver-factory.ts +49 -0
  164. package/src/utils/build/build.ts +13 -2
  165. package/src/utils/build/upload.ts +1 -1
  166. package/src/utils/deploy/deploy-metadata.ts +1 -1
  167. package/src/utils/job-context/base-job-context.ts +68 -6
  168. package/src/utils/job-context/batch-script-job-context.ts +18 -0
  169. package/src/utils/job-context/cloud-job-context.ts +7 -2
  170. package/src/utils/job-context/local-job-context.ts +7 -2
  171. package/src/utils/open-cloud/open-cloud-client.test.ts +133 -14
  172. package/src/utils/open-cloud/open-cloud-client.ts +131 -35
  173. package/src/utils/testing/parsers/batch-log-parser.test.ts +70 -5
  174. package/src/utils/testing/parsers/batch-log-parser.ts +141 -80
  175. package/src/utils/testing/parsers/traceback-parser.test.ts +64 -0
  176. package/src/utils/testing/parsers/traceback-parser.ts +122 -0
  177. package/src/utils/testing/runner/combined-project-generator.ts +1 -1
  178. package/src/utils/testing/runner/test-runner.test.ts +29 -0
  179. package/src/utils/testing/runner/test-runner.ts +36 -4
  180. package/src/utils/testing/test-log-parser.test.ts +70 -0
  181. package/src/utils/testing/test-log-parser.ts +80 -10
  182. package/src/utils/watch/github-context.test.ts +154 -0
  183. package/src/utils/watch/github-context.ts +184 -0
  184. package/src/utils/watch/http-watch-registry.test.ts +330 -0
  185. package/src/utils/watch/http-watch-registry.ts +341 -0
  186. package/src/utils/watch/local-watch-loop.test.ts +197 -0
  187. package/src/utils/watch/local-watch-loop.ts +190 -0
  188. package/src/utils/watch/register-notify-watches.test.ts +282 -0
  189. package/src/utils/watch/register-notify-watches.ts +226 -0
  190. package/src/utils/watch/register-watches.test.ts +696 -0
  191. package/src/utils/watch/register-watches.ts +369 -0
  192. package/src/utils/watch/stream-watch-loop.test.ts +625 -0
  193. package/src/utils/watch/stream-watch-loop.ts +411 -0
  194. package/src/utils/watch/websocket-watch-stream.test.ts +581 -0
  195. package/src/utils/watch/websocket-watch-stream.ts +403 -0
  196. package/tsconfig.json +19 -6
  197. package/tsconfig.tsbuildinfo +1 -1
  198. package/dist/utils/build/deploy-config.d.ts +0 -71
  199. package/dist/utils/build/deploy-config.d.ts.map +0 -1
  200. package/dist/utils/build/deploy-config.js +0 -164
  201. package/dist/utils/build/deploy-config.js.map +0 -1
  202. package/dist/utils/build/deploy-config.test.d.ts +0 -2
  203. package/dist/utils/build/deploy-config.test.d.ts.map +0 -1
  204. package/dist/utils/build/deploy-config.test.js +0 -126
  205. package/dist/utils/build/deploy-config.test.js.map +0 -1
  206. package/src/utils/build/deploy-config.test.ts +0 -149
  207. package/src/utils/build/deploy-config.ts +0 -259
@@ -43,6 +43,12 @@ interface CombinedBuildState {
43
43
  * execution. Wraps an inner context (cloud or local) and intercepts all methods
44
44
  * using the lazy-promise pattern: the first concurrent call triggers the shared
45
45
  * operation, all others await the same promise.
46
+ *
47
+ * Note that a `basePlace` cannot be honoured here: every package is combined
48
+ * into one place, so there is no per-package place to merge Studio content
49
+ * into. Rather than silently drop that content, the constructor warns for any
50
+ * package configured with one — those belong in `nevermore batch test
51
+ * --no-aggregated`, or in an integration deploy.
46
52
  */
47
53
  export class BatchScriptJobContext implements JobContext {
48
54
  private _inner: JobContext;
@@ -80,6 +86,18 @@ export class BatchScriptJobContext implements JobContext {
80
86
  this._batchUniverseId = options?.batchUniverseId;
81
87
  this._batchTimeoutMs = options?.batchTimeoutMs ?? 300_000;
82
88
  this._reporter = options?.reporter;
89
+
90
+ const withBasePlace = batchTargets.filter((t) => t.target.basePlace);
91
+ if (withBasePlace.length > 0) {
92
+ OutputHelper.warn(
93
+ `${withBasePlace.length} package${
94
+ withBasePlace.length === 1 ? '' : 's'
95
+ } configure a basePlace, which an aggregated batch run cannot merge — ` +
96
+ `their Studio-authored content is NOT in this place: ` +
97
+ withBasePlace.map((t) => t.packageName).join(', ') +
98
+ `. Use --no-aggregated to test them against their base place.`
99
+ );
100
+ }
83
101
  }
84
102
 
85
103
  async buildPlaceAsync(options: BuildPlaceOptions): Promise<BuiltPlace> {
@@ -11,6 +11,7 @@ import {
11
11
  type RunScriptOptions,
12
12
  type ScriptRunResult,
13
13
  } from './job-context.js';
14
+ import { type BasePlaceResolver } from '@quenty/nevermore-deploy';
14
15
  import { BaseJobContext } from './base-job-context.js';
15
16
 
16
17
  const SKIP_RENAMING_PLACE = true;
@@ -30,8 +31,12 @@ class CloudDeployment implements Deployment {
30
31
  }
31
32
 
32
33
  export class CloudJobContext extends BaseJobContext {
33
- constructor(reporter: Reporter, openCloudClient: OpenCloudClient) {
34
- super(reporter, openCloudClient);
34
+ constructor(
35
+ reporter: Reporter,
36
+ openCloudClient: OpenCloudClient,
37
+ basePlaceResolver?: BasePlaceResolver
38
+ ) {
39
+ super(reporter, openCloudClient, basePlaceResolver);
35
40
  }
36
41
 
37
42
  async deployBuiltPlaceAsync(
@@ -7,6 +7,7 @@ import {
7
7
  type RunScriptOptions,
8
8
  type ScriptRunResult,
9
9
  } from './job-context.js';
10
+ import { type BasePlaceResolver } from '@quenty/nevermore-deploy';
10
11
  import { BaseJobContext } from './base-job-context.js';
11
12
  import { type OpenCloudClient } from '../open-cloud/open-cloud-client.js';
12
13
 
@@ -24,8 +25,12 @@ class LocalDeployment implements Deployment {
24
25
  export class LocalJobContext extends BaseJobContext {
25
26
  private _deployments = new Set<LocalDeployment>();
26
27
 
27
- constructor(reporter: Reporter, openCloudClient?: OpenCloudClient) {
28
- super(reporter, openCloudClient);
28
+ constructor(
29
+ reporter: Reporter,
30
+ openCloudClient?: OpenCloudClient,
31
+ basePlaceResolver?: BasePlaceResolver
32
+ ) {
33
+ super(reporter, openCloudClient, basePlaceResolver);
29
34
  }
30
35
 
31
36
  async deployBuiltPlaceAsync(
@@ -203,38 +203,157 @@ describe('OpenCloudClient.downloadPlaceAsync', () => {
203
203
  });
204
204
  });
205
205
 
206
- describe('OpenCloudClient.getLatestPlaceVersionAsync', () => {
206
+ describe('OpenCloudClient.resolveLatestPlaceVersionAsync', () => {
207
207
  afterEach(() => {
208
208
  vi.restoreAllMocks();
209
209
  });
210
210
 
211
- it('returns the numeric revisionId from the Assets API', async () => {
212
- const urls: string[] = [];
213
- const fakeLimiter = {
211
+ /** Page the Assets API newest-first, as the real endpoint does. */
212
+ function makeVersionsLimiter(
213
+ pages: Array<Array<{ version: number; published?: boolean }>>,
214
+ urls: string[] = []
215
+ ): RateLimiter {
216
+ return {
214
217
  fetchAsync: vi.fn(async (url: string | URL) => {
215
218
  urls.push(String(url));
219
+ const page = pages[urls.length - 1] ?? [];
216
220
  return new Response(
217
- JSON.stringify({ assetId: '22', revisionId: '5781' }),
221
+ JSON.stringify({
222
+ assetVersions: page.map((entry) => ({
223
+ path: `assets/22/versions/${entry.version}`,
224
+ // The real API omits `published` entirely on save-only versions.
225
+ ...(entry.published ? { published: true } : {}),
226
+ })),
227
+ ...(urls.length < pages.length
228
+ ? { nextPageToken: `token-${urls.length}` }
229
+ : {}),
230
+ }),
218
231
  { status: 200 }
219
232
  );
220
233
  }),
221
234
  } as unknown as RateLimiter;
235
+ }
222
236
 
237
+ it('resolves "saved" to the newest version of any kind', async () => {
238
+ const urls: string[] = [];
223
239
  const client = new OpenCloudClient({
224
240
  apiKey: 'test-key',
225
- rateLimiter: fakeLimiter,
241
+ rateLimiter: makeVersionsLimiter(
242
+ [[{ version: 5781 }, { version: 5780, published: true }]],
243
+ urls
244
+ ),
245
+ });
246
+
247
+ expect(await client.resolveLatestPlaceVersionAsync(1, 22, 'saved')).toBe(
248
+ 5781
249
+ );
250
+ expect(urls).toHaveLength(1);
251
+ expect(urls[0]).toBe(
252
+ 'https://apis.roblox.com/assets/v1/assets/22/versions?maxPageSize=50'
253
+ );
254
+ });
255
+
256
+ it('resolves "published" past unpublished saves at the head', async () => {
257
+ const client = new OpenCloudClient({
258
+ apiKey: 'test-key',
259
+ rateLimiter: makeVersionsLimiter([
260
+ [
261
+ { version: 5781 },
262
+ { version: 5780 },
263
+ { version: 5779, published: true },
264
+ ],
265
+ ]),
266
+ });
267
+
268
+ expect(
269
+ await client.resolveLatestPlaceVersionAsync(1, 22, 'published')
270
+ ).toBe(5779);
271
+ });
272
+
273
+ it('pages only until the newest published version is found', async () => {
274
+ const urls: string[] = [];
275
+ const client = new OpenCloudClient({
276
+ apiKey: 'test-key',
277
+ rateLimiter: makeVersionsLimiter(
278
+ [
279
+ [{ version: 300 }, { version: 299 }],
280
+ [{ version: 298, published: true }, { version: 297 }],
281
+ [{ version: 296, published: true }],
282
+ ],
283
+ urls
284
+ ),
285
+ });
286
+
287
+ expect(
288
+ await client.resolveLatestPlaceVersionAsync(1, 22, 'published')
289
+ ).toBe(298);
290
+ expect(urls).toHaveLength(2);
291
+ expect(urls[1]).toContain('pageToken=token-1');
292
+ });
293
+
294
+ it('throws when the place has never been published', async () => {
295
+ const client = new OpenCloudClient({
296
+ apiKey: 'test-key',
297
+ rateLimiter: makeVersionsLimiter([[{ version: 2 }, { version: 1 }]]),
298
+ });
299
+
300
+ await expect(
301
+ client.resolveLatestPlaceVersionAsync(1, 22, 'published')
302
+ ).rejects.toThrowError(/no published version/);
303
+ });
304
+
305
+ it('refuses to guess when the API stops paging newest-first', async () => {
306
+ const client = new OpenCloudClient({
307
+ apiKey: 'test-key',
308
+ rateLimiter: makeVersionsLimiter([
309
+ [{ version: 1 }, { version: 2, published: true }],
310
+ ]),
226
311
  });
227
- const version = await client.getLatestPlaceVersionAsync(1, 22);
228
312
 
229
- expect(version).toBe(5781);
230
- expect(urls[0]).toBe('https://apis.roblox.com/assets/v1/assets/22');
313
+ await expect(
314
+ client.resolveLatestPlaceVersionAsync(1, 22, 'published')
315
+ ).rejects.toThrowError(/no longer paging newest-first/);
231
316
  });
232
317
 
233
- it('throws when the Assets API omits a revisionId', async () => {
318
+ it('refuses a "saved" lookup when the page is not newest-first', async () => {
319
+ // "saved" answers from the first entry, so the ordering guard has to check
320
+ // the whole page before returning or this silently pins the oldest build.
321
+ const client = new OpenCloudClient({
322
+ apiKey: 'test-key',
323
+ rateLimiter: makeVersionsLimiter([
324
+ [{ version: 1 }, { version: 2 }, { version: 3 }],
325
+ ]),
326
+ });
327
+
328
+ await expect(
329
+ client.resolveLatestPlaceVersionAsync(1, 22, 'saved')
330
+ ).rejects.toThrowError(/no longer paging newest-first/);
331
+ });
332
+
333
+ it('reports the scan limit when every page is unpublished', async () => {
334
+ const pages = Array.from({ length: 25 }, (_, page) =>
335
+ Array.from({ length: 2 }, (_, i) => ({ version: 1000 - page * 2 - i }))
336
+ );
337
+ const client = new OpenCloudClient({
338
+ apiKey: 'test-key',
339
+ rateLimiter: makeVersionsLimiter(pages),
340
+ });
341
+
342
+ await expect(
343
+ client.resolveLatestPlaceVersionAsync(1, 22, 'published')
344
+ ).rejects.toThrowError(/in its most recent 1000 versions/);
345
+ });
346
+
347
+ it('throws on an unparseable version path', async () => {
234
348
  const fakeLimiter = {
235
349
  fetchAsync: vi.fn(
236
350
  async () =>
237
- new Response(JSON.stringify({ assetId: '22' }), { status: 200 })
351
+ new Response(
352
+ JSON.stringify({
353
+ assetVersions: [{ path: 'assets/22/versions/' }],
354
+ }),
355
+ { status: 200 }
356
+ )
238
357
  ),
239
358
  } as unknown as RateLimiter;
240
359
 
@@ -243,8 +362,8 @@ describe('OpenCloudClient.getLatestPlaceVersionAsync', () => {
243
362
  rateLimiter: fakeLimiter,
244
363
  });
245
364
 
246
- await expect(client.getLatestPlaceVersionAsync(1, 22)).rejects.toThrowError(
247
- /no revisionId/
248
- );
365
+ await expect(
366
+ client.resolveLatestPlaceVersionAsync(1, 22, 'saved')
367
+ ).rejects.toThrowError(/unparseable version path/);
249
368
  });
250
369
  });
@@ -33,6 +33,13 @@ export interface OpenCloudClientOptions {
33
33
  rateLimiter: RateLimiter;
34
34
  }
35
35
 
36
+ /**
37
+ * Which end of a place's version history to resolve. Mirrors the `versionType`
38
+ * the place-publishing API takes on upload, lowercased to match how it is
39
+ * written in deploy.nevermore.json.
40
+ */
41
+ export type PlaceVersionType = 'saved' | 'published';
42
+
36
43
  function formatAuthError(
37
44
  action: string,
38
45
  scope: string,
@@ -339,6 +346,7 @@ export class OpenCloudClient {
339
346
  const structured: { message: string; createTime: string }[] = [];
340
347
  let pageToken: string | undefined;
341
348
  let pagesFetched = 0;
349
+ let entriesFetched = 0;
342
350
 
343
351
  do {
344
352
  const url = new URL(`https://apis.roblox.com/cloud/v2/${taskPath}/logs`);
@@ -386,6 +394,7 @@ export class OpenCloudClient {
386
394
  }
387
395
  }
388
396
 
397
+ entriesFetched += (data.luauExecutionSessionTaskLogs ?? []).length;
389
398
  pagesFetched++;
390
399
  pageToken = data.nextPageToken || undefined;
391
400
  } while (pageToken);
@@ -402,7 +411,8 @@ export class OpenCloudClient {
402
411
  // the task and the parser, and the parser cannot tell a short run from a
403
412
  // truncated fetch. Record what arrived so a real run can settle it.
404
413
  OutputHelper.verbose(
405
- `[open-cloud] Task logs: ${pagesFetched} page(s), ${messages.length} messages, ${text.length} chars`
414
+ `[open-cloud] Task logs: ${pagesFetched} page(s), ${entriesFetched} entries, ` +
415
+ `${messages.length} messages, ${text.length} chars`
406
416
  );
407
417
 
408
418
  return text;
@@ -491,57 +501,143 @@ export class OpenCloudClient {
491
501
  }
492
502
 
493
503
  /**
494
- * Resolve the current latest published version number of a place, via the
504
+ * Resolve the newest saved or published version number of a place, via the
495
505
  * Open Cloud Assets API (`asset:read` scope; `legacy-asset:manage` also
496
506
  * grants it). The returned number is the same value the Asset Delivery API's
497
507
  * `/version/{n}` route expects, so it can be written straight into a
498
508
  * `basePlace.version` pin.
509
+ *
510
+ * `saved` is the newest version of any kind — Studio saves and publishes
511
+ * share one increasing version sequence. `published` is the newest version
512
+ * that actually went live, which is what players see and what a deploy
513
+ * merging against a base place normally wants.
514
+ *
515
+ * The endpoint pages newest-first, which is what makes this affordable: an
516
+ * actively-developed place accumulates tens of thousands of versions, and we
517
+ * never walk the history. `saved` is the first entry of the first page, and
518
+ * `published` only walks back as far as the most recent live version — one
519
+ * page unless the place has been saved 50+ times without publishing. The scan
520
+ * is capped so a never-published place fails fast instead of paging forever.
499
521
  */
500
- async getLatestPlaceVersionAsync(
522
+ async resolveLatestPlaceVersionAsync(
501
523
  universeId: number,
502
- placeId: number
524
+ placeId: number,
525
+ versionType: PlaceVersionType
503
526
  ): Promise<number> {
504
527
  const apiKey = await this._resolveApiKeyAsync();
505
- const url = `https://apis.roblox.com/assets/v1/assets/${placeId}`;
528
+ let pageToken: string | undefined;
529
+ let previousVersion: number | undefined;
506
530
 
507
- const response = await this._rateLimiter.fetchAsync(url, {
508
- method: 'GET',
509
- headers: {
510
- 'x-api-key': apiKey,
511
- },
512
- });
531
+ for (let page = 0; page < VERSION_SCAN_MAX_PAGES; page++) {
532
+ const url =
533
+ `https://apis.roblox.com/assets/v1/assets/${placeId}/versions` +
534
+ `?maxPageSize=${VERSION_SCAN_PAGE_SIZE}` +
535
+ (pageToken ? `&pageToken=${encodeURIComponent(pageToken)}` : '');
513
536
 
514
- if (!response.ok) {
515
- const text = await response.text();
516
- if (response.status === 401 || response.status === 403) {
537
+ const response = await this._rateLimiter.fetchAsync(url, {
538
+ method: 'GET',
539
+ headers: {
540
+ 'x-api-key': apiKey,
541
+ },
542
+ });
543
+
544
+ if (!response.ok) {
545
+ const text = await response.text();
546
+ if (response.status === 401 || response.status === 403) {
547
+ throw new Error(
548
+ formatAuthError(
549
+ 'Read place version',
550
+ 'asset:read',
551
+ universeId,
552
+ placeId,
553
+ response.status,
554
+ response.statusText,
555
+ text,
556
+ 'GET',
557
+ url
558
+ )
559
+ );
560
+ }
517
561
  throw new Error(
518
- formatAuthError(
519
- 'Read place version',
520
- 'asset:read',
521
- universeId,
522
- placeId,
523
- response.status,
524
- response.statusText,
525
- text,
526
- 'GET',
527
- url
528
- )
562
+ `Read place version failed: ${response.status} ${response.statusText}: ${text}`
529
563
  );
530
564
  }
531
- throw new Error(
532
- `Read place version failed: ${response.status} ${response.statusText}: ${text}`
533
- );
534
- }
535
565
 
536
- const data = (await response.json()) as { revisionId?: string };
537
- const version = Number(data.revisionId);
538
- if (!data.revisionId || !Number.isFinite(version)) {
539
- throw new Error(
540
- `Read place version failed: no revisionId for place ${placeId}`
566
+ const data = (await response.json()) as {
567
+ assetVersions?: AssetVersion[];
568
+ nextPageToken?: string;
569
+ };
570
+
571
+ const page = (data.assetVersions ?? []).map((assetVersion) => ({
572
+ versionNumber: _parseAssetVersionNumber(placeId, assetVersion),
573
+ published: assetVersion.published === true,
574
+ }));
575
+
576
+ // Everything here rests on the API paging newest-first, and a `saved`
577
+ // lookup answers from the very first entry — so the whole page is checked
578
+ // before anything is returned. Validating only as far as the match would
579
+ // leave the common case unchecked and quietly pin a years-old build.
580
+ for (const { versionNumber } of page) {
581
+ if (previousVersion != null && versionNumber >= previousVersion) {
582
+ throw new Error(
583
+ `Read place version failed: place ${placeId} returned version ` +
584
+ `${versionNumber} after ${previousVersion}. The Assets API is no ` +
585
+ `longer paging newest-first, so "${versionType}" cannot be resolved ` +
586
+ `safely — pin an explicit version number in deploy.nevermore.json.`
587
+ );
588
+ }
589
+ previousVersion = versionNumber;
590
+ }
591
+
592
+ // `published` is omitted rather than false on save-only versions.
593
+ const match = page.find(
594
+ (entry) => versionType === 'saved' || entry.published
541
595
  );
596
+ if (match) {
597
+ return match.versionNumber;
598
+ }
599
+
600
+ pageToken = data.nextPageToken;
601
+ if (!pageToken) {
602
+ break;
603
+ }
542
604
  }
543
- return version;
605
+
606
+ throw new Error(
607
+ `Place ${placeId} has no ${versionType} version` +
608
+ (pageToken
609
+ ? ` in its most recent ${
610
+ VERSION_SCAN_MAX_PAGES * VERSION_SCAN_PAGE_SIZE
611
+ } versions`
612
+ : '') +
613
+ `. Pin an explicit version number in deploy.nevermore.json, or publish the place once.`
614
+ );
615
+ }
616
+ }
617
+
618
+ /** How the Assets API reports one entry of a place's version history. */
619
+ interface AssetVersion {
620
+ /** `assets/{assetId}/versions/{versionNumber}` */
621
+ path?: string;
622
+ /** Present and true only once the version has been published live. */
623
+ published?: boolean;
624
+ }
625
+
626
+ const VERSION_SCAN_PAGE_SIZE = 50;
627
+ const VERSION_SCAN_MAX_PAGES = 20;
628
+
629
+ function _parseAssetVersionNumber(
630
+ placeId: number,
631
+ version: AssetVersion
632
+ ): number {
633
+ const versionNumber = Number(version.path?.split('/').pop());
634
+ if (!Number.isInteger(versionNumber) || versionNumber < 1) {
635
+ throw new Error(
636
+ `Read place version failed: place ${placeId} returned an unparseable ` +
637
+ `version path "${version.path}"`
638
+ );
544
639
  }
640
+ return versionNumber;
545
641
  }
546
642
 
547
643
  const CDN_MAX_ATTEMPTS = 4;
@@ -1,6 +1,10 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { countTracebacks, parseBatchTestLogs } from './batch-log-parser.js';
3
+ import {
4
+ countTracebacks,
5
+ findSummaryEntries,
6
+ parseBatchTestLogs,
7
+ } from './batch-log-parser.js';
4
8
 
5
9
  const SLUG_MAP = new Map([['egghunt2026', 'egghunt2026']]);
6
10
 
@@ -23,10 +27,11 @@ describe('parseBatchTestLogs', () => {
23
27
  expect(result?.testCounts).toEqual({ passed: 275, failed: 0, total: 275 });
24
28
  });
25
29
 
26
- it('fails a pass it cannot read, rather than trusting the pcall', () => {
27
- // The summary prints last, so it survives a log window that dropped the
28
- // head. The pcall said success, but nothing here saw a test run.
30
+ it('attributes a section closed by END when its BEGIN was dropped', () => {
31
+ // Open Cloud keeps only the tail of a long run's log, so BEGIN — printed
32
+ // first — is the first casualty while END and the summary survive.
29
33
  const logs = [
34
+ ' ✓ some test that survived (3 ms)',
30
35
  'Tests: 275 passed, 275 total',
31
36
  '===BATCH_TEST_END egghunt2026 PASS 1000===',
32
37
  '===BATCH_TEST_SUMMARY===',
@@ -35,8 +40,48 @@ describe('parseBatchTestLogs', () => {
35
40
 
36
41
  const result = parseBatchTestLogs(logs, SLUG_MAP).get('egghunt2026');
37
42
 
43
+ expect(result?.success).toBe(true);
44
+ expect(result?.testCounts).toEqual({ passed: 275, failed: 0, total: 275 });
45
+ });
46
+
47
+ it('does not let an out-of-order END steal another package’s output', () => {
48
+ // The API does not deliver messages in order, so a stray END can arrive
49
+ // mid-section. Only the first section can have lost its head; past that the
50
+ // log is well-formed and a BEGIN-less END must not claim anything.
51
+ const twoPackages = new Map([
52
+ ['alpha', 'alpha'],
53
+ ['beta', 'beta'],
54
+ ]);
55
+ const logs = [
56
+ '===BATCH_TEST_BEGIN alpha===',
57
+ 'Tests: 10 passed, 10 total',
58
+ '===BATCH_TEST_END beta PASS 5===',
59
+ '===BATCH_TEST_END alpha PASS 10===',
60
+ '===BATCH_TEST_SUMMARY===',
61
+ '[{"slug":"alpha","success":true},{"slug":"beta","success":true}]',
62
+ ].join('\n');
63
+
64
+ const results = parseBatchTestLogs(logs, twoPackages);
65
+
66
+ expect(results.get('alpha')?.testCounts?.total).toBe(10);
67
+ // beta never had a section of its own; it must not inherit alpha's.
68
+ expect(results.get('beta')?.testCounts).toBeUndefined();
69
+ expect(results.get('beta')?.success).toBe(false);
70
+ });
71
+
72
+ it('fails a pass it cannot read, rather than trusting the pcall', () => {
73
+ // No END marker either, so there is no boundary to attribute output with.
74
+ // The pcall said success, but nothing here saw a test run.
75
+ const logs = [
76
+ 'Tests: 275 passed, 275 total',
77
+ '===BATCH_TEST_SUMMARY===',
78
+ '[{"slug":"egghunt2026","success":true,"durationMs":1000}]',
79
+ ].join('\n');
80
+
81
+ const result = parseBatchTestLogs(logs, SLUG_MAP).get('egghunt2026');
82
+
38
83
  expect(result?.success).toBe(false);
39
- expect(result?.error).toContain('No test output could be attributed');
84
+ expect(result?.error).toContain('no output could be attributed');
40
85
  expect(result?.testCounts).toBeUndefined();
41
86
  });
42
87
 
@@ -72,6 +117,26 @@ describe('parseBatchTestLogs', () => {
72
117
  });
73
118
  });
74
119
 
120
+ describe('findSummaryEntries', () => {
121
+ it('finds the summary even when output landed after it', () => {
122
+ // Messages are not delivered in order, so a stray line can follow the
123
+ // summary. Treating the whole remainder as one JSON blob made the same
124
+ // batch parse on one run and fail on the next.
125
+ const lines = [
126
+ '[{"slug":"alpha","success":true}]',
127
+ ' ✓ a stray line that arrived late',
128
+ ];
129
+
130
+ expect(findSummaryEntries(lines, 0)).toEqual([
131
+ { slug: 'alpha', success: true },
132
+ ]);
133
+ });
134
+
135
+ it('returns undefined when there is no array to find', () => {
136
+ expect(findSummaryEntries(['not json at all'], 0)).toBeUndefined();
137
+ });
138
+ });
139
+
75
140
  describe('countTracebacks', () => {
76
141
  it('counts each traceback separately', () => {
77
142
  expect(countTracebacks('Stack Begin\nfoo\nStack End\nStack Begin\n')).toBe(