@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
@@ -0,0 +1,226 @@
1
+ import { OutputHelper } from '@quenty/cli-output-helpers';
2
+ import {
3
+ WATCH_BASELINE_KIND,
4
+ WATCH_INPUT_NAME,
5
+ sanitizeWatchName,
6
+ type WatchEntry,
7
+ type WatchOption,
8
+ type WatchRegistry,
9
+ } from '@quenty/nevermore-deploy';
10
+ import { HttpWatchRegistry } from './http-watch-registry.js';
11
+ import { tryResolveGithubDispatchContext } from './github-context.js';
12
+ import { type LocalWatchEntry } from './local-watch-loop.js';
13
+ import { type StreamWatchEntry } from './stream-watch-loop.js';
14
+
15
+ export interface RegisterNotifyWatchesOptions {
16
+ option: WatchOption;
17
+ /** Lease key within the repository, as for a dispatching monitor. */
18
+ monitorName: string;
19
+ entries: LocalWatchEntry[];
20
+ /** Open Cloud key to share, so the service can poll a private base place. */
21
+ robloxApiKey?: string;
22
+ /** Let the GitHub CLI supply the token when no env var does. */
23
+ useGhAuth?: boolean;
24
+ /** Injected in tests; defaults to the HTTP registry. */
25
+ createRegistry?: (registerUrl: string) => WatchRegistry;
26
+ }
27
+
28
+ export type RegisterNotifyWatchesResult =
29
+ | {
30
+ success: true;
31
+ monitorId: string;
32
+ /** Bearer token for the stream; the same one registration used. */
33
+ credential: string;
34
+ entries: StreamWatchEntry[];
35
+ }
36
+ | {
37
+ success: false;
38
+ reason:
39
+ | 'no_github_context'
40
+ | 'no_token'
41
+ | 'unwatchable_version_type'
42
+ | 'no_entries'
43
+ | 'register_failed'
44
+ | 'no_monitor_id';
45
+ detail?: string;
46
+ };
47
+
48
+ /**
49
+ * Register a monitor that notifies this process instead of dispatching CI.
50
+ *
51
+ * Best-effort on purpose. Every way this can fail — no GitHub identity to
52
+ * register under, no token, a `"saved"` base place the service cannot poll, a
53
+ * service that is unreachable — has a working answer already: poll Open Cloud
54
+ * from here. So a failure downgrades the watch rather than the run, and the
55
+ * caller falls back.
56
+ */
57
+ export async function tryRegisterNotifyWatchesAsync(
58
+ options: RegisterNotifyWatchesOptions
59
+ ): Promise<RegisterNotifyWatchesResult> {
60
+ const { option, entries } = options;
61
+
62
+ if (entries.length === 0) {
63
+ return { success: false, reason: 'no_entries' };
64
+ }
65
+
66
+ // Without a shared key the service reads asset delivery, which reports
67
+ // published content only — it refuses `"saved"` at registration, and one
68
+ // refusal fails the whole request. Rather than watch some places one way and
69
+ // some the other, the whole run falls back to polling, which handles every
70
+ // version type this machine has credentials for.
71
+ const credentialed = options.robloxApiKey != null;
72
+ const unwatchable = credentialed
73
+ ? []
74
+ : entries.filter((e) => e.versionType !== 'published');
75
+ if (unwatchable.length > 0) {
76
+ return {
77
+ success: false,
78
+ reason: 'unwatchable_version_type',
79
+ detail: unwatchable.map((e) => e.label).join(', '),
80
+ };
81
+ }
82
+
83
+ const contextResult = tryResolveGithubDispatchContext({
84
+ useGhAuth: options.useGhAuth,
85
+ });
86
+ if (!contextResult.success) {
87
+ return { success: false, reason: 'no_github_context' };
88
+ }
89
+ const context = contextResult.context;
90
+ // Registration needs a write-scoped PAT even though a notify never spends it:
91
+ // the repository is the only identity this service has, and it is what a
92
+ // monitor's leases and caps are counted against.
93
+ if (!context.token) {
94
+ return { success: false, reason: 'no_token' };
95
+ }
96
+
97
+ const streamEntries: StreamWatchEntry[] = entries.map((entry) => ({
98
+ ...entry,
99
+ watchName: sanitizeWatchName(entry.label),
100
+ }));
101
+ _disambiguateWatchNames(streamEntries);
102
+
103
+ const watches: WatchEntry[] = streamEntries.map((entry) => ({
104
+ name: entry.watchName,
105
+ source: {
106
+ type: 'roblox-place',
107
+ universeId: entry.universeId,
108
+ placeId: entry.placeId,
109
+ versionType: entry.versionType,
110
+ },
111
+ // Only when a key is shared do the two sides speak the same language; the
112
+ // `ready` reconcile covers this either way, by re-checking every watch
113
+ // against Open Cloud on connect.
114
+ ...(credentialed && entry.baseline != null
115
+ ? {
116
+ baselineVersion: String(entry.baseline),
117
+ baselineVersionKind: WATCH_BASELINE_KIND,
118
+ }
119
+ : {}),
120
+ action: {
121
+ type: 'notify',
122
+ // Same key a dispatching watch puts the selector under, so the two modes
123
+ // describe a change the same way even though only one crosses into CI.
124
+ payload: { [WATCH_INPUT_NAME]: entry.label },
125
+ },
126
+ }));
127
+
128
+ const registry = (options.createRegistry ?? _defaultRegistry)(
129
+ option.registerUrl
130
+ );
131
+
132
+ let result;
133
+ try {
134
+ result = await registry.registerAsync({
135
+ // Distinct from the dispatching monitor's name. They hold different
136
+ // actions, and re-registering replaces a monitor's whole watch list — so
137
+ // sharing a name would mean a local watch silently disarming CI's.
138
+ monitorName: sanitizeWatchName(`${options.monitorName}/local`),
139
+ repository: context.repository,
140
+ githubToken: context.token,
141
+ robloxApiKey: options.robloxApiKey,
142
+ watches,
143
+ });
144
+ } catch (err) {
145
+ return {
146
+ success: false,
147
+ reason: 'register_failed',
148
+ detail: err instanceof Error ? err.message : String(err),
149
+ };
150
+ }
151
+
152
+ if (!result.monitorId) {
153
+ return { success: false, reason: 'no_monitor_id' };
154
+ }
155
+
156
+ OutputHelper.verbose(
157
+ `Registered a notify monitor (${result.monitorId}), lease ${option.lease}.`
158
+ );
159
+
160
+ return {
161
+ success: true,
162
+ monitorId: result.monitorId,
163
+ credential: context.token,
164
+ entries: streamEntries,
165
+ };
166
+ }
167
+
168
+ /** Why the run is polling instead, in words a user can act on. */
169
+ export function describeNotifyWatchFallback(
170
+ result: RegisterNotifyWatchesResult & { success: false }
171
+ ): string {
172
+ switch (result.reason) {
173
+ case 'no_entries':
174
+ return 'nothing to watch';
175
+ case 'unwatchable_version_type':
176
+ return (
177
+ `${result.detail} tracks "saved", which the service can only see ` +
178
+ 'with a shared Open Cloud key (--watch-share-api-key)'
179
+ );
180
+ case 'no_github_context':
181
+ return 'this checkout has no GitHub repository to register under';
182
+ case 'no_token':
183
+ return (
184
+ 'no GitHub token — set NEVERMORE_WATCH_TOKEN, or pass ' +
185
+ '--watch-use-gh-auth to use the one `gh` already holds'
186
+ );
187
+ case 'no_monitor_id':
188
+ return 'the service registered the monitor but returned no id';
189
+ case 'register_failed':
190
+ return `the watch service refused the registration — ${result.detail}`;
191
+ }
192
+ }
193
+
194
+ function _defaultRegistry(registerUrl: string): WatchRegistry {
195
+ return new HttpWatchRegistry({ registerUrl });
196
+ }
197
+
198
+ /**
199
+ * Make every watch name unique within the monitor.
200
+ *
201
+ * Names come from selectors, which are unique per target — except that an
202
+ * unnamed place in a multi-place target has no name to contribute, so two of
203
+ * them produce the same selector. Appending the place id separates them without
204
+ * failing a deploy that already shipped.
205
+ */
206
+ function _disambiguateWatchNames(entries: StreamWatchEntry[]): void {
207
+ const byName = new Map<string, StreamWatchEntry[]>();
208
+ for (const entry of entries) {
209
+ const group = byName.get(entry.watchName);
210
+ if (group) {
211
+ group.push(entry);
212
+ } else {
213
+ byName.set(entry.watchName, [entry]);
214
+ }
215
+ }
216
+ for (const group of byName.values()) {
217
+ if (group.length === 1) {
218
+ continue;
219
+ }
220
+ for (const entry of group) {
221
+ entry.watchName = sanitizeWatchName(
222
+ `${entry.watchName}/${entry.placeId}`
223
+ );
224
+ }
225
+ }
226
+ }