@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.
- package/CHANGELOG.md +28 -0
- package/dist/args/global-args.d.ts +13 -0
- package/dist/args/global-args.d.ts.map +1 -1
- package/dist/commands/batch-command/batch-deploy-command.d.ts +3 -0
- package/dist/commands/batch-command/batch-deploy-command.d.ts.map +1 -1
- package/dist/commands/batch-command/batch-deploy-command.js +90 -1
- package/dist/commands/batch-command/batch-deploy-command.js.map +1 -1
- package/dist/commands/batch-command/batch-test-command.d.ts.map +1 -1
- package/dist/commands/batch-command/batch-test-command.js +25 -4
- package/dist/commands/batch-command/batch-test-command.js.map +1 -1
- package/dist/commands/deploy-command/deploy-init.js +1 -1
- package/dist/commands/deploy-command/deploy-init.js.map +1 -1
- package/dist/commands/deploy-command/index.d.ts +3 -0
- package/dist/commands/deploy-command/index.d.ts.map +1 -1
- package/dist/commands/deploy-command/index.js +297 -60
- package/dist/commands/deploy-command/index.js.map +1 -1
- package/dist/commands/deploy-command/select-target.js +1 -1
- package/dist/commands/deploy-command/select-target.js.map +1 -1
- package/dist/commands/deploy-command/version-command.d.ts.map +1 -1
- package/dist/commands/deploy-command/version-command.js +138 -12
- package/dist/commands/deploy-command/version-command.js.map +1 -1
- package/dist/commands/test-command/test-command.d.ts.map +1 -1
- package/dist/commands/test-command/test-command.js +23 -11
- package/dist/commands/test-command/test-command.js.map +1 -1
- package/dist/nevermore.js +17 -0
- package/dist/nevermore.js.map +1 -1
- package/dist/utils/batch/changed-packages-utils.d.ts +1 -1
- package/dist/utils/batch/changed-packages-utils.d.ts.map +1 -1
- package/dist/utils/batch/changed-packages-utils.js +1 -1
- package/dist/utils/batch/changed-packages-utils.js.map +1 -1
- package/dist/utils/build/base-place-resolver-factory.d.ts +25 -0
- package/dist/utils/build/base-place-resolver-factory.d.ts.map +1 -0
- package/dist/utils/build/base-place-resolver-factory.js +40 -0
- package/dist/utils/build/base-place-resolver-factory.js.map +1 -0
- package/dist/utils/build/build.d.ts +13 -2
- package/dist/utils/build/build.d.ts.map +1 -1
- package/dist/utils/build/build.js.map +1 -1
- package/dist/utils/build/upload.d.ts +1 -1
- package/dist/utils/build/upload.d.ts.map +1 -1
- package/dist/utils/deploy/deploy-metadata.d.ts +1 -1
- package/dist/utils/deploy/deploy-metadata.d.ts.map +1 -1
- package/dist/utils/job-context/base-job-context.d.ts +3 -1
- package/dist/utils/job-context/base-job-context.d.ts.map +1 -1
- package/dist/utils/job-context/base-job-context.js +45 -6
- package/dist/utils/job-context/base-job-context.js.map +1 -1
- package/dist/utils/job-context/batch-script-job-context.d.ts +6 -0
- package/dist/utils/job-context/batch-script-job-context.d.ts.map +1 -1
- package/dist/utils/job-context/batch-script-job-context.js +13 -0
- package/dist/utils/job-context/batch-script-job-context.js.map +1 -1
- package/dist/utils/job-context/cloud-job-context.d.ts +2 -1
- package/dist/utils/job-context/cloud-job-context.d.ts.map +1 -1
- package/dist/utils/job-context/cloud-job-context.js +2 -2
- package/dist/utils/job-context/cloud-job-context.js.map +1 -1
- package/dist/utils/job-context/local-job-context.d.ts +2 -1
- package/dist/utils/job-context/local-job-context.d.ts.map +1 -1
- package/dist/utils/job-context/local-job-context.js +2 -2
- package/dist/utils/job-context/local-job-context.js.map +1 -1
- package/dist/utils/open-cloud/open-cloud-client.d.ts +20 -2
- package/dist/utils/open-cloud/open-cloud-client.d.ts.map +1 -1
- package/dist/utils/open-cloud/open-cloud-client.js +78 -21
- package/dist/utils/open-cloud/open-cloud-client.js.map +1 -1
- package/dist/utils/open-cloud/open-cloud-client.test.js +89 -12
- package/dist/utils/open-cloud/open-cloud-client.test.js.map +1 -1
- package/dist/utils/testing/parsers/batch-log-parser.d.ts +13 -5
- package/dist/utils/testing/parsers/batch-log-parser.d.ts.map +1 -1
- package/dist/utils/testing/parsers/batch-log-parser.js +114 -68
- package/dist/utils/testing/parsers/batch-log-parser.js.map +1 -1
- package/dist/utils/testing/parsers/batch-log-parser.test.js +57 -5
- package/dist/utils/testing/parsers/batch-log-parser.test.js.map +1 -1
- package/dist/utils/testing/parsers/traceback-parser.d.ts +31 -0
- package/dist/utils/testing/parsers/traceback-parser.d.ts.map +1 -0
- package/dist/utils/testing/parsers/traceback-parser.js +91 -0
- package/dist/utils/testing/parsers/traceback-parser.js.map +1 -0
- package/dist/utils/testing/parsers/traceback-parser.test.d.ts +2 -0
- package/dist/utils/testing/parsers/traceback-parser.test.d.ts.map +1 -0
- package/dist/utils/testing/parsers/traceback-parser.test.js +45 -0
- package/dist/utils/testing/parsers/traceback-parser.test.js.map +1 -0
- package/dist/utils/testing/runner/combined-project-generator.d.ts +1 -1
- package/dist/utils/testing/runner/combined-project-generator.d.ts.map +1 -1
- package/dist/utils/testing/runner/test-runner.d.ts +9 -1
- package/dist/utils/testing/runner/test-runner.d.ts.map +1 -1
- package/dist/utils/testing/runner/test-runner.js +28 -3
- package/dist/utils/testing/runner/test-runner.js.map +1 -1
- package/dist/utils/testing/runner/test-runner.test.d.ts +2 -0
- package/dist/utils/testing/runner/test-runner.test.d.ts.map +1 -0
- package/dist/utils/testing/runner/test-runner.test.js +18 -0
- package/dist/utils/testing/runner/test-runner.test.js.map +1 -0
- package/dist/utils/testing/test-log-parser.d.ts +32 -1
- package/dist/utils/testing/test-log-parser.d.ts.map +1 -1
- package/dist/utils/testing/test-log-parser.js +53 -9
- package/dist/utils/testing/test-log-parser.js.map +1 -1
- package/dist/utils/testing/test-log-parser.test.d.ts +2 -0
- package/dist/utils/testing/test-log-parser.test.d.ts.map +1 -0
- package/dist/utils/testing/test-log-parser.test.js +56 -0
- package/dist/utils/testing/test-log-parser.test.js.map +1 -0
- package/dist/utils/watch/github-context.d.ts +50 -0
- package/dist/utils/watch/github-context.d.ts.map +1 -0
- package/dist/utils/watch/github-context.js +125 -0
- package/dist/utils/watch/github-context.js.map +1 -0
- package/dist/utils/watch/github-context.test.d.ts +2 -0
- package/dist/utils/watch/github-context.test.d.ts.map +1 -0
- package/dist/utils/watch/github-context.test.js +112 -0
- package/dist/utils/watch/github-context.test.js.map +1 -0
- package/dist/utils/watch/http-watch-registry.d.ts +40 -0
- package/dist/utils/watch/http-watch-registry.d.ts.map +1 -0
- package/dist/utils/watch/http-watch-registry.js +262 -0
- package/dist/utils/watch/http-watch-registry.js.map +1 -0
- package/dist/utils/watch/http-watch-registry.test.d.ts +2 -0
- package/dist/utils/watch/http-watch-registry.test.d.ts.map +1 -0
- package/dist/utils/watch/http-watch-registry.test.js +211 -0
- package/dist/utils/watch/http-watch-registry.test.js.map +1 -0
- package/dist/utils/watch/local-watch-loop.d.ts +50 -0
- package/dist/utils/watch/local-watch-loop.d.ts.map +1 -0
- package/dist/utils/watch/local-watch-loop.js +103 -0
- package/dist/utils/watch/local-watch-loop.js.map +1 -0
- package/dist/utils/watch/local-watch-loop.test.d.ts +2 -0
- package/dist/utils/watch/local-watch-loop.test.d.ts.map +1 -0
- package/dist/utils/watch/local-watch-loop.test.js +170 -0
- package/dist/utils/watch/local-watch-loop.test.js.map +1 -0
- package/dist/utils/watch/register-notify-watches.d.ts +41 -0
- package/dist/utils/watch/register-notify-watches.d.ts.map +1 -0
- package/dist/utils/watch/register-notify-watches.js +159 -0
- package/dist/utils/watch/register-notify-watches.js.map +1 -0
- package/dist/utils/watch/register-notify-watches.test.d.ts +2 -0
- package/dist/utils/watch/register-notify-watches.test.d.ts.map +1 -0
- package/dist/utils/watch/register-notify-watches.test.js +225 -0
- package/dist/utils/watch/register-notify-watches.test.js.map +1 -0
- package/dist/utils/watch/register-watches.d.ts +68 -0
- package/dist/utils/watch/register-watches.d.ts.map +1 -0
- package/dist/utils/watch/register-watches.js +221 -0
- package/dist/utils/watch/register-watches.js.map +1 -0
- package/dist/utils/watch/register-watches.test.d.ts +2 -0
- package/dist/utils/watch/register-watches.test.d.ts.map +1 -0
- package/dist/utils/watch/register-watches.test.js +576 -0
- package/dist/utils/watch/register-watches.test.js.map +1 -0
- package/dist/utils/watch/stream-watch-loop.d.ts +54 -0
- package/dist/utils/watch/stream-watch-loop.d.ts.map +1 -0
- package/dist/utils/watch/stream-watch-loop.js +282 -0
- package/dist/utils/watch/stream-watch-loop.js.map +1 -0
- package/dist/utils/watch/stream-watch-loop.test.d.ts +2 -0
- package/dist/utils/watch/stream-watch-loop.test.d.ts.map +1 -0
- package/dist/utils/watch/stream-watch-loop.test.js +392 -0
- package/dist/utils/watch/stream-watch-loop.test.js.map +1 -0
- package/dist/utils/watch/websocket-watch-stream.d.ts +25 -0
- package/dist/utils/watch/websocket-watch-stream.d.ts.map +1 -0
- package/dist/utils/watch/websocket-watch-stream.js +306 -0
- package/dist/utils/watch/websocket-watch-stream.js.map +1 -0
- package/dist/utils/watch/websocket-watch-stream.test.d.ts +2 -0
- package/dist/utils/watch/websocket-watch-stream.test.d.ts.map +1 -0
- package/dist/utils/watch/websocket-watch-stream.test.js +475 -0
- package/dist/utils/watch/websocket-watch-stream.test.js.map +1 -0
- package/package.json +7 -4
- package/src/args/global-args.ts +13 -0
- package/src/commands/batch-command/batch-deploy-command.ts +105 -1
- package/src/commands/batch-command/batch-test-command.ts +86 -60
- package/src/commands/deploy-command/deploy-init.ts +1 -1
- package/src/commands/deploy-command/index.ts +327 -32
- package/src/commands/deploy-command/select-target.ts +1 -1
- package/src/commands/deploy-command/version-command.ts +215 -21
- package/src/commands/test-command/test-command.ts +31 -22
- package/src/nevermore.ts +19 -0
- package/src/utils/batch/changed-packages-utils.ts +1 -1
- package/src/utils/build/base-place-resolver-factory.ts +49 -0
- package/src/utils/build/build.ts +13 -2
- package/src/utils/build/upload.ts +1 -1
- package/src/utils/deploy/deploy-metadata.ts +1 -1
- package/src/utils/job-context/base-job-context.ts +68 -6
- package/src/utils/job-context/batch-script-job-context.ts +18 -0
- package/src/utils/job-context/cloud-job-context.ts +7 -2
- package/src/utils/job-context/local-job-context.ts +7 -2
- package/src/utils/open-cloud/open-cloud-client.test.ts +133 -14
- package/src/utils/open-cloud/open-cloud-client.ts +131 -35
- package/src/utils/testing/parsers/batch-log-parser.test.ts +70 -5
- package/src/utils/testing/parsers/batch-log-parser.ts +141 -80
- package/src/utils/testing/parsers/traceback-parser.test.ts +64 -0
- package/src/utils/testing/parsers/traceback-parser.ts +122 -0
- package/src/utils/testing/runner/combined-project-generator.ts +1 -1
- package/src/utils/testing/runner/test-runner.test.ts +29 -0
- package/src/utils/testing/runner/test-runner.ts +36 -4
- package/src/utils/testing/test-log-parser.test.ts +70 -0
- package/src/utils/testing/test-log-parser.ts +80 -10
- package/src/utils/watch/github-context.test.ts +154 -0
- package/src/utils/watch/github-context.ts +184 -0
- package/src/utils/watch/http-watch-registry.test.ts +330 -0
- package/src/utils/watch/http-watch-registry.ts +341 -0
- package/src/utils/watch/local-watch-loop.test.ts +197 -0
- package/src/utils/watch/local-watch-loop.ts +190 -0
- package/src/utils/watch/register-notify-watches.test.ts +282 -0
- package/src/utils/watch/register-notify-watches.ts +226 -0
- package/src/utils/watch/register-watches.test.ts +696 -0
- package/src/utils/watch/register-watches.ts +369 -0
- package/src/utils/watch/stream-watch-loop.test.ts +625 -0
- package/src/utils/watch/stream-watch-loop.ts +411 -0
- package/src/utils/watch/websocket-watch-stream.test.ts +581 -0
- package/src/utils/watch/websocket-watch-stream.ts +403 -0
- package/tsconfig.json +19 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/build/deploy-config.d.ts +0 -71
- package/dist/utils/build/deploy-config.d.ts.map +0 -1
- package/dist/utils/build/deploy-config.js +0 -164
- package/dist/utils/build/deploy-config.js.map +0 -1
- package/dist/utils/build/deploy-config.test.d.ts +0 -2
- package/dist/utils/build/deploy-config.test.d.ts.map +0 -1
- package/dist/utils/build/deploy-config.test.js +0 -126
- package/dist/utils/build/deploy-config.test.js.map +0 -1
- package/src/utils/build/deploy-config.test.ts +0 -149
- 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
|
+
}
|