@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
@@ -7,12 +7,18 @@ import {
7
7
  } from '@quenty/cli-output-helpers/reporting';
8
8
  import { getApiKeyAsync } from '@quenty/nevermore-cli-helpers';
9
9
  import {
10
+ createEmptyDeployLock,
11
+ isBasePlaceVersionKeyword,
10
12
  loadDeployConfigAsync,
13
+ loadDeployLockAsync,
11
14
  resolveDeployConfigPath,
15
+ resolveDeployLockPath,
12
16
  resolveDeployTargetPlaces,
17
+ saveDeployLockAsync,
13
18
  type BasePlaceConfig,
19
+ type BasePlaceVersion,
14
20
  type DeployConfig,
15
- } from '../../utils/build/deploy-config.js';
21
+ } from '@quenty/nevermore-deploy';
16
22
  import { OpenCloudClient } from '../../utils/open-cloud/open-cloud-client.js';
17
23
  import { RateLimiter } from '../../utils/open-cloud/rate-limiter.js';
18
24
  import { DeployArgs } from './index.js';
@@ -26,8 +32,8 @@ interface BasePlaceRef {
26
32
  /** A pending change: set `ref.basePlace.version` to `to`. */
27
33
  interface PinChange {
28
34
  ref: BasePlaceRef;
29
- from?: number;
30
- to: number;
35
+ from?: BasePlaceVersion;
36
+ to: BasePlaceVersion;
31
37
  }
32
38
 
33
39
  export interface VersionPromoteArgs extends DeployArgs {
@@ -148,9 +154,9 @@ export async function handleVersionUpgradeAsync(
148
154
  }
149
155
 
150
156
  const targetNames = args.target ? [args.target] : Object.keys(config.targets);
151
- const refs = _collectBasePlaceRefs(config, targetNames);
157
+ const allRefs = _collectBasePlaceRefs(config, targetNames);
152
158
 
153
- if (refs.length === 0) {
159
+ if (allRefs.length === 0) {
154
160
  OutputHelper.warn(
155
161
  args.target
156
162
  ? `Target "${args.target}" has no basePlace to pin.`
@@ -159,14 +165,15 @@ export async function handleVersionUpgradeAsync(
159
165
  return;
160
166
  }
161
167
 
162
- // Resolve the latest version once per unique base place id — several targets
163
- // (e.g. integration/prod) commonly point at the same base place.
164
- const uniquePlaceIds = [...new Set(refs.map((r) => r.basePlace.placeId))];
165
- OutputHelper.info(
166
- `Resolving latest version for ${uniquePlaceIds.length} base place${_plural(
167
- uniquePlaceIds.length
168
- )}...`
169
- );
168
+ // Two kinds of pin, two files. A number (or an absent pin being frozen for
169
+ // the first time) is intent and belongs in the config; a "saved"/"published"
170
+ // pin is intent that stays put while only the resolved fact moves, so those
171
+ // roll forward in the lock instead.
172
+ const isDynamic = (ref: BasePlaceRef) =>
173
+ ref.basePlace.version != null &&
174
+ isBasePlaceVersionKeyword(ref.basePlace.version);
175
+ const configRefs = allRefs.filter((ref) => !isDynamic(ref));
176
+ const lockRefs = allRefs.filter(isDynamic);
170
177
 
171
178
  const apiKey = await getApiKeyAsync(args);
172
179
  const client = new OpenCloudClient({
@@ -174,15 +181,45 @@ export async function handleVersionUpgradeAsync(
174
181
  rateLimiter: new RateLimiter(),
175
182
  });
176
183
 
184
+ if (configRefs.length > 0) {
185
+ await _upgradeConfigPinsAsync(configPath, config, configRefs, client, args);
186
+ }
187
+ // Runs even with no keyword pins left, so converting the last one back to a
188
+ // number still lets an unscoped upgrade clear its orphaned lock entry.
189
+ if (lockRefs.length > 0 || !args.target) {
190
+ await _upgradeLockPinsAsync(cwd, lockRefs, client, args, !args.target);
191
+ }
192
+ }
193
+
194
+ /** Roll numeric (and not-yet-pinned) base places forward in the config. */
195
+ async function _upgradeConfigPinsAsync(
196
+ configPath: string,
197
+ config: DeployConfig,
198
+ refs: BasePlaceRef[],
199
+ client: OpenCloudClient,
200
+ args: DeployArgs
201
+ ): Promise<void> {
202
+ // Resolve the latest version once per unique base place id — several targets
203
+ // (e.g. integration/prod) commonly point at the same base place.
204
+ const uniquePlaceIds = [...new Set(refs.map((r) => r.basePlace.placeId))];
205
+ OutputHelper.info(
206
+ `Resolving latest published version for ${
207
+ uniquePlaceIds.length
208
+ } base place${_plural(uniquePlaceIds.length)}...`
209
+ );
210
+
177
211
  const latestByPlaceId = new Map<number, number>();
178
212
  await Promise.all(
179
213
  uniquePlaceIds.map(async (placeId) => {
180
214
  const ref = refs.find((r) => r.basePlace.placeId === placeId)!;
181
- const latest = await client.getLatestPlaceVersionAsync(
182
- ref.basePlace.universeId,
183
- placeId
215
+ latestByPlaceId.set(
216
+ placeId,
217
+ await client.resolveLatestPlaceVersionAsync(
218
+ ref.basePlace.universeId,
219
+ placeId,
220
+ 'published'
221
+ )
184
222
  );
185
- latestByPlaceId.set(placeId, latest);
186
223
  })
187
224
  );
188
225
 
@@ -206,6 +243,153 @@ export async function handleVersionUpgradeAsync(
206
243
  await _commitPinChangesAsync(configPath, config, changes, args);
207
244
  }
208
245
 
246
+ /**
247
+ * Roll `"saved"`/`"published"` base places forward in the lock file. Each is
248
+ * resolved against the version type it actually tracks, so a `"saved"` pin is
249
+ * never quietly re-pointed at a published version.
250
+ *
251
+ * `prune` drops entries for base places the config no longer references. It is
252
+ * only safe when this ran unscoped, since a single target does not know about
253
+ * the base places belonging to the others.
254
+ */
255
+ async function _upgradeLockPinsAsync(
256
+ packagePath: string,
257
+ refs: BasePlaceRef[],
258
+ client: OpenCloudClient,
259
+ args: DeployArgs,
260
+ prune: boolean
261
+ ): Promise<void> {
262
+ const lockPath = resolveDeployLockPath(packagePath);
263
+ const existingLock = await loadDeployLockAsync(lockPath);
264
+ if (!existingLock && refs.length === 0) {
265
+ return;
266
+ }
267
+ const lock = existingLock ?? createEmptyDeployLock();
268
+
269
+ const uniqueRefs = [
270
+ ...new Map(refs.map((ref) => [ref.basePlace.placeId, ref])).values(),
271
+ ];
272
+ if (uniqueRefs.length > 0) {
273
+ OutputHelper.info(
274
+ `Resolving tracked version for ${uniqueRefs.length} base place${_plural(
275
+ uniqueRefs.length
276
+ )}...`
277
+ );
278
+ }
279
+
280
+ const changes: PinChange[] = [];
281
+ await Promise.all(
282
+ uniqueRefs.map(async (ref) => {
283
+ const latest = await client.resolveLatestPlaceVersionAsync(
284
+ ref.basePlace.universeId,
285
+ ref.basePlace.placeId,
286
+ _asKeyword(ref.basePlace.version)
287
+ );
288
+ changes.push({
289
+ ref,
290
+ from: lock.basePlaces[String(ref.basePlace.placeId)]?.version,
291
+ to: latest,
292
+ });
293
+ })
294
+ );
295
+
296
+ const columns: TableColumn<PinChange>[] = [
297
+ { header: 'Place', value: (c) => c.ref.placeLabel },
298
+ { header: 'Base place', value: (c) => String(c.ref.basePlace.placeId) },
299
+ { header: 'Tracks', value: (c) => String(c.ref.basePlace.version) },
300
+ { header: 'Locked', value: (c) => _formatChange(c) },
301
+ ];
302
+
303
+ if (changes.length > 0) {
304
+ console.log('');
305
+ console.log(formatTable(changes, columns, { indent: ' ' }));
306
+ console.log('');
307
+ }
308
+
309
+ const referenced = new Set(
310
+ uniqueRefs.map((r) => String(r.basePlace.placeId))
311
+ );
312
+ const stale = prune
313
+ ? Object.keys(lock.basePlaces).filter((id) => !referenced.has(id))
314
+ : [];
315
+ // An entry is stale if either half is wrong. Comparing only the version
316
+ // number strands a config that switched "published" -> "saved" while the
317
+ // number happened to stay put: nothing would be rewritten, and every later
318
+ // --frozen-lockfile build would fail telling the user to run this command.
319
+ const moved = changes.filter((change) => {
320
+ const entry = lock.basePlaces[String(change.ref.basePlace.placeId)];
321
+ return (
322
+ entry?.version !== change.to ||
323
+ entry?.from !== _asKeyword(change.ref.basePlace.version)
324
+ );
325
+ });
326
+
327
+ if (moved.length === 0 && stale.length === 0) {
328
+ OutputHelper.info('Nothing to change — lock is already up to date.');
329
+ return;
330
+ }
331
+
332
+ if (stale.length > 0) {
333
+ OutputHelper.info(
334
+ `Dropping ${stale.length} lock entr${
335
+ stale.length === 1 ? 'y' : 'ies'
336
+ } no longer referenced by deploy.nevermore.json: ${stale.join(', ')}`
337
+ );
338
+ }
339
+
340
+ if (args.dryrun) {
341
+ OutputHelper.info(
342
+ `[DRYRUN] Would update ${moved.length} and drop ${stale.length} lock ` +
343
+ `entr${moved.length + stale.length === 1 ? 'y' : 'ies'} in ${lockPath}`
344
+ );
345
+ return;
346
+ }
347
+
348
+ if (!args.yes) {
349
+ const { confirm } = await inquirer.prompt([
350
+ {
351
+ type: 'confirm',
352
+ name: 'confirm',
353
+ message:
354
+ `Update ${moved.length} and drop ${stale.length} entr` +
355
+ `${moved.length + stale.length === 1 ? 'y' : 'ies'} in ` +
356
+ `deploy.nevermore.lock.json?`,
357
+ default: true,
358
+ },
359
+ ]);
360
+ if (!confirm) {
361
+ OutputHelper.info('Aborted — no changes written.');
362
+ return;
363
+ }
364
+ }
365
+
366
+ for (const id of stale) {
367
+ delete lock.basePlaces[id];
368
+ }
369
+ for (const change of moved) {
370
+ lock.basePlaces[String(change.ref.basePlace.placeId)] = {
371
+ version: change.to as number,
372
+ from: _asKeyword(change.ref.basePlace.version),
373
+ };
374
+ }
375
+
376
+ await saveDeployLockAsync(lockPath, lock);
377
+ OutputHelper.info(`Updated ${lockPath}`);
378
+ OutputHelper.hint(
379
+ 'Commit deploy.nevermore.lock.json to roll base places forward.'
380
+ );
381
+ }
382
+
383
+ /** Narrow a pin already known to be a keyword; the caller filtered for it. */
384
+ function _asKeyword(version: BasePlaceVersion | undefined) {
385
+ if (version == null || !isBasePlaceVersionKeyword(version)) {
386
+ throw new Error(
387
+ `Expected a "saved"/"published" pin, got ${_formatVersion(version)}`
388
+ );
389
+ }
390
+ return version;
391
+ }
392
+
209
393
  /**
210
394
  * `nevermore deploy version promote <from> <to>` — copy the base-place version
211
395
  * pins from one target to another (e.g. promote validated `production-demo`
@@ -237,7 +421,7 @@ export async function handleVersionPromoteAsync(
237
421
  // Map base place id -> pinned version from the source target. A source with
238
422
  // the same base place pinned to two different versions is inconsistent, so
239
423
  // fail loudly rather than pick one arbitrarily.
240
- const versionByPlaceId = new Map<number, number>();
424
+ const versionByPlaceId = new Map<number, BasePlaceVersion>();
241
425
  for (const ref of _collectBasePlaceRefs(config, [fromTarget])) {
242
426
  const version = ref.basePlace.version;
243
427
  if (version == null) {
@@ -247,7 +431,9 @@ export async function handleVersionPromoteAsync(
247
431
  if (existing != null && existing !== version) {
248
432
  throw new Error(
249
433
  `Target "${fromTarget}" pins base place ${ref.basePlace.placeId} to ` +
250
- `two different versions (v${existing} and v${version}). ` +
434
+ `two different versions (${_formatVersion(
435
+ existing
436
+ )} and ${_formatVersion(version)}). ` +
251
437
  `Run "nevermore deploy version upgrade ${fromTarget}" to make it consistent first.`
252
438
  );
253
439
  }
@@ -304,8 +490,16 @@ export async function handleVersionPromoteAsync(
304
490
  await _commitPinChangesAsync(configPath, config, changes, args);
305
491
  }
306
492
 
493
+ function _formatVersion(version?: BasePlaceVersion): string {
494
+ if (version == null) {
495
+ return '(latest)';
496
+ }
497
+ return typeof version === 'string' ? `"${version}"` : `v${version}`;
498
+ }
499
+
307
500
  function _formatChange(change: PinChange): string {
308
- const from = change.from != null ? `v${change.from}` : '(latest)';
309
501
  const unchanged = change.from === change.to ? ' (unchanged)' : '';
310
- return `${from} → v${change.to}${unchanged}`;
502
+ return `${_formatVersion(change.from)} → ${_formatVersion(
503
+ change.to
504
+ )}${unchanged}`;
311
505
  }
@@ -6,6 +6,7 @@ import { getApiKeyAsync } from '@quenty/nevermore-cli-helpers';
6
6
  import { OpenCloudClient } from '../../utils/open-cloud/open-cloud-client.js';
7
7
  import { RateLimiter } from '../../utils/open-cloud/rate-limiter.js';
8
8
  import { isCI, readPackageNameAsync } from '../../utils/nevermore-cli-utils.js';
9
+ import { createBasePlaceResolver } from '../../utils/build/base-place-resolver-factory.js';
9
10
  import {
10
11
  CloudJobContext,
11
12
  LocalJobContext,
@@ -15,7 +16,7 @@ import {
15
16
  loadDeployConfigAsync,
16
17
  resolveDeployConfigPath,
17
18
  resolveSingleDeployTarget,
18
- } from '../../utils/build/deploy-config.js';
19
+ } from '@quenty/nevermore-deploy';
19
20
  import {
20
21
  type Reporter,
21
22
  type LiveStateTracker,
@@ -56,9 +57,9 @@ export class TestProjectCommand<T>
56
57
  type: 'string',
57
58
  });
58
59
  args.option('logs', {
59
- describe: 'Show execution logs',
60
+ describe:
61
+ 'Show execution logs. Defaults on with --script-text, whose output is the whole point of the run',
60
62
  type: 'boolean',
61
- default: false,
62
63
  });
63
64
  args.option('universe-id', {
64
65
  describe:
@@ -84,7 +85,7 @@ export class TestProjectCommand<T>
84
85
  });
85
86
  args.option('timeout', {
86
87
  describe:
87
- 'Max script execution time in seconds. Sent to the Open Cloud API so Roblox cancels server-side on overrun (default: 120)',
88
+ 'Max script execution time in seconds. Sent to the Open Cloud API so Roblox cancels server-side on overrun. Max 300s (API limit). (default: 300)',
88
89
  type: 'number',
89
90
  });
90
91
 
@@ -94,7 +95,10 @@ export class TestProjectCommand<T>
94
95
  public handler = async (args: TestProjectArgs) => {
95
96
  const cwd = process.cwd();
96
97
  const packageName = (await readPackageNameAsync(cwd)) ?? path.basename(cwd);
97
- const showLogs = args.logs ?? false;
98
+ // A probe run exists to show its output. Hiding it behind an opt-in flag
99
+ // made --script-text look broken enough that a workaround was written into
100
+ // the docs instead of a bug report.
101
+ const showLogs = args.logs ?? args.scriptText !== undefined;
98
102
  const useSpinner = process.stdout.isTTY && !args.verbose;
99
103
 
100
104
  const reporter = new CompositeReporter(
@@ -129,27 +133,32 @@ export class TestProjectCommand<T>
129
133
 
130
134
  let exitCode = 0;
131
135
  try {
136
+ const config = await loadDeployConfigAsync(resolveDeployConfigPath(cwd));
137
+ const target = resolveSingleDeployTarget(
138
+ config,
139
+ 'test',
140
+ 'nevermore batch test'
141
+ );
142
+
143
+ // A local run needs Open Cloud only to fetch a base place. The key is
144
+ // resolved lazily so a package without one is never asked for credentials.
145
+ const client = args.cloud
146
+ ? new OpenCloudClient({
147
+ apiKey: await getApiKeyAsync(args),
148
+ rateLimiter: new RateLimiter(),
149
+ })
150
+ : new OpenCloudClient({
151
+ apiKey: () => getApiKeyAsync(args),
152
+ rateLimiter: new RateLimiter(),
153
+ });
154
+ const basePlaceResolver = createBasePlaceResolver(client, args);
155
+
132
156
  const context = args.cloud
133
- ? new CloudJobContext(
134
- reporter,
135
- new OpenCloudClient({
136
- apiKey: await getApiKeyAsync(args),
137
- rateLimiter: new RateLimiter(),
138
- })
139
- )
140
- : new LocalJobContext(reporter);
157
+ ? new CloudJobContext(reporter, client, basePlaceResolver)
158
+ : new LocalJobContext(reporter, client, basePlaceResolver);
141
159
 
142
160
  let result;
143
161
  try {
144
- const config = await loadDeployConfigAsync(
145
- resolveDeployConfigPath(cwd)
146
- );
147
- const target = resolveSingleDeployTarget(
148
- config,
149
- 'test',
150
- 'nevermore batch test'
151
- );
152
-
153
162
  result = await runSingleTestAsync(context, {
154
163
  packagePath: cwd,
155
164
  packageName,
package/src/nevermore.ts CHANGED
@@ -59,6 +59,25 @@ yargs(hideBin(process.argv))
59
59
  global: true,
60
60
  type: 'boolean',
61
61
  })
62
+ // Global rather than per-command so every command that can merge a base place
63
+ // gets identical lock semantics from one definition.
64
+ .option('frozen-lockfile', {
65
+ description:
66
+ 'Fail instead of resolving a base place version that deploy.nevermore.lock.json does not already pin',
67
+ default: false,
68
+ global: true,
69
+ type: 'boolean',
70
+ })
71
+ // The other half of the same policy: a watch-dispatched build must re-resolve
72
+ // the pin the lock is holding still, or it rebuilds the base place it already
73
+ // shipped and the hot reload does nothing.
74
+ .option('refresh-base-place', {
75
+ description:
76
+ 'Re-resolve "saved"/"published" base place pins instead of reusing the locked version (use in watch-triggered builds)',
77
+ default: false,
78
+ global: true,
79
+ type: 'boolean',
80
+ })
62
81
  .middleware((argv) => {
63
82
  OutputHelper.setVerbose(argv.verbose as boolean);
64
83
  })
@@ -8,7 +8,7 @@ import {
8
8
  resolveDeployConfigPath,
9
9
  resolveDeployTargetPlaces,
10
10
  toManifestPlaceInfo,
11
- } from '../build/deploy-config.js';
11
+ } from '@quenty/nevermore-deploy';
12
12
 
13
13
  export interface TargetPackage {
14
14
  name: string;
@@ -0,0 +1,49 @@
1
+ import { BasePlaceResolver } from '@quenty/nevermore-deploy';
2
+ import { type OpenCloudClient } from '../open-cloud/open-cloud-client.js';
3
+
4
+ /**
5
+ * A resolver that can only answer from the lock file.
6
+ *
7
+ * Watch registration reads baselines with `peekAsync`, which never leaves disk,
8
+ * so registering needs no Open Cloud credentials. A dryrun has no client to
9
+ * build a real resolver from and must not acquire one just to register — and if
10
+ * some future caller does ask this to resolve, throwing beats quietly reaching
11
+ * the network on a dryrun.
12
+ */
13
+ export function createLockOnlyBasePlaceResolver(): BasePlaceResolver {
14
+ return new BasePlaceResolver({
15
+ source: {
16
+ resolveLatestPlaceVersionAsync: async () => {
17
+ throw new Error(
18
+ 'This resolver answers from deploy.nevermore.lock.json only and ' +
19
+ 'cannot reach Open Cloud.'
20
+ );
21
+ },
22
+ },
23
+ });
24
+ }
25
+
26
+ /**
27
+ * Build the one resolver a run shares.
28
+ *
29
+ * Every command that can merge a base place goes through here, so `deploy run`,
30
+ * `batch deploy`, `test`, and `batch test` cannot end up disagreeing about lock
31
+ * policy. `OpenCloudClient` satisfies the resolver's `PlaceVersionSource` port
32
+ * structurally — the deploy-config package never learns about Open Cloud.
33
+ */
34
+ export function createBasePlaceResolver(
35
+ openCloudClient: OpenCloudClient,
36
+ args: { frozenLockfile?: boolean; refreshBasePlace?: boolean }
37
+ ): BasePlaceResolver {
38
+ if (args.frozenLockfile && args.refreshBasePlace) {
39
+ throw new Error(
40
+ '--frozen-lockfile and --refresh-base-place contradict each other: ' +
41
+ 'one forbids resolving base places, the other forces it.'
42
+ );
43
+ }
44
+ return new BasePlaceResolver({
45
+ source: openCloudClient,
46
+ frozen: args.frozenLockfile ?? false,
47
+ refresh: args.refreshBasePlace ?? false,
48
+ });
49
+ }
@@ -2,7 +2,7 @@ import * as fs from 'fs/promises';
2
2
  import * as path from 'path';
3
3
  import { OutputHelper } from '@quenty/cli-output-helpers';
4
4
  import { BuildContext } from '@quenty/nevermore-template-helpers';
5
- import { DeployTarget } from './deploy-config.js';
5
+ import { DeployTarget } from '@quenty/nevermore-deploy';
6
6
  import { type Reporter } from '@quenty/cli-output-helpers/reporting';
7
7
 
8
8
  export interface DeployOverrides {
@@ -20,7 +20,18 @@ export interface BuildPlaceOptions {
20
20
  */
21
21
  target: DeployTarget;
22
22
  outputFileName?: string;
23
- packagePath?: string;
23
+ /**
24
+ * Directory the package lives in. Required, not defaulted.
25
+ *
26
+ * Everything downstream is resolved against it: the project file, the build
27
+ * cache key, and which `deploy.nevermore.lock.json` a base place pin is
28
+ * written to. Falling back to `process.cwd()` is silently wrong in a batch —
29
+ * every package sharing a relative `project` path collapses onto one cache
30
+ * key, so one package's build gets uploaded to another's place. It was
31
+ * optional once, and a refactor dropped it from a call site with nothing to
32
+ * catch it.
33
+ */
34
+ packagePath: string;
24
35
  overrides?: DeployOverrides;
25
36
  reporter?: Reporter;
26
37
  packageName?: string;
@@ -2,7 +2,7 @@ import {
2
2
  getApiKeyAsync,
3
3
  type CredentialArgs,
4
4
  } from '@quenty/nevermore-cli-helpers';
5
- import { type DeployTarget } from './deploy-config.js';
5
+ import { type DeployTarget } from '@quenty/nevermore-deploy';
6
6
  import { OpenCloudClient } from '../open-cloud/open-cloud-client.js';
7
7
  import { type BuiltPlace } from './build.js';
8
8
  import { type Reporter } from '@quenty/cli-output-helpers/reporting';
@@ -7,7 +7,7 @@ import {
7
7
  } from '@quenty/nevermore-template-helpers';
8
8
  import { OutputHelper } from '@quenty/cli-output-helpers';
9
9
  import { type BuiltPlace } from '../build/build.js';
10
- import { type ManifestPlaceInfo } from '../build/deploy-config.js';
10
+ import { type ManifestPlaceInfo } from '@quenty/nevermore-deploy';
11
11
 
12
12
  /** npm name of the package that ships the manifest module. */
13
13
  export const MANIFEST_PACKAGE_NAME = '@quenty/nevermoreclimanifest';
@@ -19,6 +19,7 @@ import {
19
19
  type ScriptRunResult,
20
20
  } from './job-context.js';
21
21
  import { type OpenCloudClient } from '../open-cloud/open-cloud-client.js';
22
+ import { type BasePlaceResolver } from '@quenty/nevermore-deploy';
22
23
 
23
24
  const MERGE_SCRIPT_PATH = resolvePackagePath(
24
25
  import.meta.url,
@@ -63,12 +64,18 @@ class TrackedBuiltPlace implements BuiltPlace {
63
64
  export abstract class BaseJobContext implements JobContext {
64
65
  protected _reporter: Reporter;
65
66
  protected _openCloudClient: OpenCloudClient | undefined;
67
+ private _basePlaceResolver: BasePlaceResolver | undefined;
66
68
  private _builtPlaces = new Set<TrackedBuiltPlace>();
67
69
  private _sharedRojoBuilds = new Map<string, SharedRojoBuild>();
68
70
 
69
- constructor(reporter: Reporter, openCloudClient?: OpenCloudClient) {
71
+ constructor(
72
+ reporter: Reporter,
73
+ openCloudClient?: OpenCloudClient,
74
+ basePlaceResolver?: BasePlaceResolver
75
+ ) {
70
76
  this._reporter = reporter;
71
77
  this._openCloudClient = openCloudClient;
78
+ this._basePlaceResolver = basePlaceResolver;
72
79
  }
73
80
 
74
81
  async buildPlaceAsync(options: BuildPlaceOptions): Promise<BuiltPlace> {
@@ -180,10 +187,20 @@ export abstract class BaseJobContext implements JobContext {
180
187
  options: BuildPlaceOptions
181
188
  ): Promise<void> {
182
189
  const { basePlace } = tracked.target;
183
- if (!basePlace || !this._openCloudClient) {
190
+ if (!basePlace) {
184
191
  return;
185
192
  }
186
193
 
194
+ // Silently building without the base place would report success on a place
195
+ // that is missing all of its Studio-authored content, so a context that
196
+ // cannot download one says so instead.
197
+ if (!this._openCloudClient || !this._basePlaceResolver) {
198
+ throw new Error(
199
+ `Target has a basePlace (${basePlace.placeId}) but this run has no Open ` +
200
+ `Cloud access to download it. Re-run with --cloud, or pass --api-key.`
201
+ );
202
+ }
203
+
187
204
  // Merge artifacts (base.rbxl, merged.rbxl) are per-place — siblings sharing
188
205
  // the rojo build would otherwise collide on filenames in one dir.
189
206
  const mergeContext = await BuildContext.createAsync({
@@ -193,11 +210,22 @@ export abstract class BaseJobContext implements JobContext {
193
210
  const resolvedName = options.packageName ?? '';
194
211
 
195
212
  this._reporter.onPackagePhaseChange(resolvedName, 'downloading');
213
+
214
+ // Every pin — number, keyword, or absent — becomes a concrete version here,
215
+ // both because the Asset Delivery API only addresses versions numerically
216
+ // and so the lock file records exactly what this build merged against.
217
+ const version = await this._basePlaceResolver.resolveAsync(
218
+ options.packagePath ?? process.cwd(),
219
+ basePlace
220
+ );
196
221
  OutputHelper.verbose(
197
- basePlace.version != null
198
- ? `Downloading base place (pinned v${basePlace.version}) for merge...`
199
- : 'Downloading base place (latest) for merge...'
222
+ typeof basePlace.version === 'number'
223
+ ? `Downloading base place (pinned v${version}) for merge...`
224
+ : `Downloading base place (${
225
+ basePlace.version ?? 'published'
226
+ } → v${version}) for merge...`
200
227
  );
228
+
201
229
  const buffer = await this._openCloudClient.downloadPlaceAsync(
202
230
  basePlace.universeId,
203
231
  basePlace.placeId,
@@ -208,7 +236,7 @@ export abstract class BaseJobContext implements JobContext {
208
236
  totalBytes: total,
209
237
  });
210
238
  },
211
- basePlace.version
239
+ version
212
240
  );
213
241
  const basePath = mergeContext.resolvePath('base.rbxl');
214
242
  await fs.writeFile(basePath, buffer);
@@ -285,5 +313,39 @@ export abstract class BaseJobContext implements JobContext {
285
313
  }
286
314
  this._sharedRojoBuilds.delete(key);
287
315
  }
316
+
317
+ // Hangs off the lifecycle every entry point already runs in a `finally`, so
318
+ // no command has to remember to persist what it resolved. Last and
319
+ // best-effort: dispose runs on the failure path too, and a lock that cannot
320
+ // be written must not bury the error the user actually needs to read, nor
321
+ // skip the cleanup above it.
322
+ if (this._basePlaceResolver) {
323
+ try {
324
+ const written = await this._basePlaceResolver.flushAsync();
325
+ for (const lockPath of written) {
326
+ OutputHelper.info(`Updated ${lockPath}`);
327
+ }
328
+ // A refreshed pin only survives if the lock is committed. Nothing here
329
+ // commits it, so on a CI runner the file is written and then thrown
330
+ // away — and the next build that does not refresh reads the old
331
+ // version out of the repo and republishes the base place this run just
332
+ // moved past. Silent, and it looks like the watch never fired.
333
+ if (written.length > 0 && this._basePlaceResolver.refreshing) {
334
+ OutputHelper.warn(
335
+ `--refresh-base-place moved ${written.length} lock file${
336
+ written.length === 1 ? '' : 's'
337
+ }. Commit the change, or the next build without ` +
338
+ `--refresh-base-place will rebuild the previous base place ` +
339
+ `version and revert this deploy.`
340
+ );
341
+ }
342
+ } catch (err) {
343
+ OutputHelper.warn(
344
+ `Could not write the deploy lock file: ${
345
+ err instanceof Error ? err.message : String(err)
346
+ }`
347
+ );
348
+ }
349
+ }
288
350
  }
289
351
  }