@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
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
import { NevermoreGlobalArgs } from '../../args/global-args.js';
|
|
16
16
|
import { getApiKeyAsync } from '@quenty/nevermore-cli-helpers';
|
|
17
17
|
import { uploadPlaceAsync } from '../../utils/build/upload.js';
|
|
18
|
+
import {
|
|
19
|
+
createBasePlaceResolver,
|
|
20
|
+
createLockOnlyBasePlaceResolver,
|
|
21
|
+
} from '../../utils/build/base-place-resolver-factory.js';
|
|
18
22
|
import {
|
|
19
23
|
type BatchDeployResult,
|
|
20
24
|
createDeployCommentConfig,
|
|
@@ -35,11 +39,31 @@ import {
|
|
|
35
39
|
readPackageVersionAsync,
|
|
36
40
|
} from '../../utils/nevermore-cli-utils.js';
|
|
37
41
|
import {
|
|
42
|
+
formatTargetSelector,
|
|
43
|
+
isBasePlaceVersionKeyword,
|
|
38
44
|
loadDeployConfigAsync,
|
|
45
|
+
parseTargetSelector,
|
|
46
|
+
parseWatchOption,
|
|
39
47
|
resolveDeployConfigPath,
|
|
40
48
|
resolveDeployTargetPlaces,
|
|
41
49
|
toManifestPlaceInfo,
|
|
42
|
-
|
|
50
|
+
type BasePlaceResolver,
|
|
51
|
+
type DeployConfig,
|
|
52
|
+
} from '@quenty/nevermore-deploy';
|
|
53
|
+
import {
|
|
54
|
+
registerWatchesAsync,
|
|
55
|
+
type RegisterWatchesResult,
|
|
56
|
+
} from '../../utils/watch/register-watches.js';
|
|
57
|
+
import {
|
|
58
|
+
runLocalWatchLoopAsync,
|
|
59
|
+
type LocalWatchEntry,
|
|
60
|
+
} from '../../utils/watch/local-watch-loop.js';
|
|
61
|
+
import {
|
|
62
|
+
describeNotifyWatchFallback,
|
|
63
|
+
tryRegisterNotifyWatchesAsync,
|
|
64
|
+
} from '../../utils/watch/register-notify-watches.js';
|
|
65
|
+
import { runStreamWatchLoopAsync } from '../../utils/watch/stream-watch-loop.js';
|
|
66
|
+
import { WebSocketWatchStream } from '../../utils/watch/websocket-watch-stream.js';
|
|
43
67
|
import { handleInitAsync } from './deploy-init.js';
|
|
44
68
|
import {
|
|
45
69
|
handleVersionUpgradeAsync,
|
|
@@ -50,6 +74,48 @@ import { selectTargetAsync } from './select-target.js';
|
|
|
50
74
|
|
|
51
75
|
const MULTI_PLACE_CONCURRENCY = 10;
|
|
52
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Which base places a local watch polls.
|
|
79
|
+
*
|
|
80
|
+
* Deliberately looser than the cloud plan. `watch` is a GitHub workflow path —
|
|
81
|
+
* a dispatch address — and nothing is dispatched locally, so requiring it would
|
|
82
|
+
* only stop a developer hot-reloading a place that never intends to use CI.
|
|
83
|
+
* `"saved"` is fair game too: the service cannot poll it yet, but this machine
|
|
84
|
+
* has Open Cloud credentials and can.
|
|
85
|
+
*
|
|
86
|
+
* An exact version pin is still excluded, for the same reason as always: it
|
|
87
|
+
* means "hold this still", so there is nothing to follow.
|
|
88
|
+
*/
|
|
89
|
+
async function _buildLocalWatchEntriesAsync(
|
|
90
|
+
config: DeployConfig,
|
|
91
|
+
targetName: string,
|
|
92
|
+
packagePath: string,
|
|
93
|
+
resolver: BasePlaceResolver
|
|
94
|
+
): Promise<LocalWatchEntry[]> {
|
|
95
|
+
const entries: LocalWatchEntry[] = [];
|
|
96
|
+
for (const place of resolveDeployTargetPlaces(config, targetName)) {
|
|
97
|
+
const basePlace = place.basePlace;
|
|
98
|
+
if (basePlace == null) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (
|
|
102
|
+
basePlace.version != null &&
|
|
103
|
+
!isBasePlaceVersionKeyword(basePlace.version)
|
|
104
|
+
) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const versionType = basePlace.version ?? 'published';
|
|
108
|
+
entries.push({
|
|
109
|
+
label: formatTargetSelector({ targetName, placeName: place.name }),
|
|
110
|
+
universeId: basePlace.universeId,
|
|
111
|
+
placeId: basePlace.placeId,
|
|
112
|
+
versionType,
|
|
113
|
+
baseline: await resolver.peekAsync(packagePath, basePlace),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return entries;
|
|
117
|
+
}
|
|
118
|
+
|
|
53
119
|
export interface DeployArgs extends NevermoreGlobalArgs {
|
|
54
120
|
apiKey?: string;
|
|
55
121
|
publish?: boolean;
|
|
@@ -63,6 +129,9 @@ export interface DeployArgs extends NevermoreGlobalArgs {
|
|
|
63
129
|
placeFile?: string;
|
|
64
130
|
output?: string;
|
|
65
131
|
logs?: boolean;
|
|
132
|
+
watch?: string;
|
|
133
|
+
watchShareApiKey?: boolean;
|
|
134
|
+
watchUseGhAuth?: boolean;
|
|
66
135
|
}
|
|
67
136
|
|
|
68
137
|
export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
@@ -126,7 +195,7 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
126
195
|
return yargs
|
|
127
196
|
.command(
|
|
128
197
|
'upgrade [target]',
|
|
129
|
-
'Re-pin every basePlace to its latest published version',
|
|
198
|
+
'Re-pin every numeric basePlace to its latest published version',
|
|
130
199
|
(upgradeYargs) => {
|
|
131
200
|
return upgradeYargs
|
|
132
201
|
.positional('target', {
|
|
@@ -227,6 +296,27 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
227
296
|
describe: 'Show build/upload logs (not just on failure)',
|
|
228
297
|
type: 'boolean',
|
|
229
298
|
default: false,
|
|
299
|
+
})
|
|
300
|
+
.option('watch', {
|
|
301
|
+
describe:
|
|
302
|
+
'After deploying, register a cloud watch so this target rebuilds when its base place changes. ' +
|
|
303
|
+
'Takes the register endpoint URL, ending in the lease: https://<watch-service>/v1/register/7d',
|
|
304
|
+
type: 'string',
|
|
305
|
+
})
|
|
306
|
+
.option('watch-use-gh-auth', {
|
|
307
|
+
describe:
|
|
308
|
+
'Let the GitHub CLI supply the watch token when no environment variable does. ' +
|
|
309
|
+
'Off by default: registering sends the token to the watch service, so it should be one you handed over.',
|
|
310
|
+
type: 'boolean',
|
|
311
|
+
default: false,
|
|
312
|
+
})
|
|
313
|
+
.option('watch-share-api-key', {
|
|
314
|
+
describe:
|
|
315
|
+
'Share the Open Cloud API key with the watch service, so it can read a private base place, ' +
|
|
316
|
+
'see "saved" versions, and report versions in the same vocabulary as the lock file. ' +
|
|
317
|
+
'Off by default — the key is stored by the service.',
|
|
318
|
+
type: 'boolean',
|
|
319
|
+
default: false,
|
|
230
320
|
});
|
|
231
321
|
},
|
|
232
322
|
async (runArgs) => {
|
|
@@ -245,10 +335,10 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
245
335
|
public handler = async () => {};
|
|
246
336
|
|
|
247
337
|
private static async _handleRunAsync(args: DeployArgs): Promise<void> {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
338
|
+
// Parsed before anything is built so a typo'd duration fails immediately
|
|
339
|
+
// rather than after a full deploy has already shipped.
|
|
340
|
+
const watchOption =
|
|
341
|
+
args.watch == null ? undefined : parseWatchOption(args.watch);
|
|
252
342
|
|
|
253
343
|
const cwd = process.cwd();
|
|
254
344
|
const packageName = (await readPackageNameAsync(cwd)) ?? path.basename(cwd);
|
|
@@ -299,6 +389,54 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
299
389
|
},
|
|
300
390
|
];
|
|
301
391
|
|
|
392
|
+
// Registering a watch is idempotent and derives entirely from committed
|
|
393
|
+
// config and the lock file, so it is safe to do for real on a dryrun — and
|
|
394
|
+
// doing it for real is the only way to exercise the watch path without
|
|
395
|
+
// shipping a build.
|
|
396
|
+
if (args.dryrun) {
|
|
397
|
+
OutputHelper.info('[DRYRUN] Would build and upload');
|
|
398
|
+
if (watchOption) {
|
|
399
|
+
OutputHelper.info(
|
|
400
|
+
'[DRYRUN] Registering a separate dryrun watch and firing it, to ' +
|
|
401
|
+
'prove routing works. This does not build or upload here — but ' +
|
|
402
|
+
'firing really does dispatch the workflow, which runs a real ' +
|
|
403
|
+
'deploy on the runner. That is the half being proved.'
|
|
404
|
+
);
|
|
405
|
+
if (args.watchShareApiKey) {
|
|
406
|
+
OutputHelper.warn(
|
|
407
|
+
'[DRYRUN] Registering without the Open Cloud key, so a "saved" ' +
|
|
408
|
+
'base place is skipped here even though a real run would watch it.'
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
const watchedTarget = parseTargetSelector(targetName).targetName;
|
|
412
|
+
// Under its own monitor name, never the one a real run owns.
|
|
413
|
+
//
|
|
414
|
+
// Re-registering replaces a monitor's entire watch list, and a dryrun
|
|
415
|
+
// cannot reproduce a real registration: the Open Cloud key is resolved
|
|
416
|
+
// after this point, so it would register anonymously — stripping the key
|
|
417
|
+
// from the live monitor, moving every source back to the anonymous
|
|
418
|
+
// driver and its content-hash vocabulary, dropping the baselines, and
|
|
419
|
+
// deleting any "saved" watch outright, because an anonymous
|
|
420
|
+
// registration skips those.
|
|
421
|
+
await registerWatchesAsync({
|
|
422
|
+
option: watchOption,
|
|
423
|
+
monitorName: `${packageName}/${watchedTarget}/dryrun`,
|
|
424
|
+
resolver: createLockOnlyBasePlaceResolver(),
|
|
425
|
+
useGhAuth: args.watchUseGhAuth,
|
|
426
|
+
triggerAfterRegister: true,
|
|
427
|
+
candidates: resolveDeployTargetPlaces(config, watchedTarget).map(
|
|
428
|
+
(place) => ({
|
|
429
|
+
targetName: watchedTarget,
|
|
430
|
+
packageName,
|
|
431
|
+
packagePath: cwd,
|
|
432
|
+
place,
|
|
433
|
+
})
|
|
434
|
+
),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
|
|
302
440
|
const publish = args.publish ?? false;
|
|
303
441
|
const showLogs = args.logs ?? false;
|
|
304
442
|
|
|
@@ -322,9 +460,46 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
322
460
|
OutputHelper.info(`Using target '${targetName}'.`);
|
|
323
461
|
}
|
|
324
462
|
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
463
|
+
const apiKey = await getApiKeyAsync(args);
|
|
464
|
+
const client = new OpenCloudClient({
|
|
465
|
+
apiKey,
|
|
466
|
+
rateLimiter: new RateLimiter(),
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// Captured only for the success message printed after the run.
|
|
470
|
+
let publishedVersion: number | undefined;
|
|
471
|
+
let publishedPlaceId: number | undefined;
|
|
472
|
+
|
|
473
|
+
// One deploy, start to finish. Factored out because a local watch runs it
|
|
474
|
+
// again on every base place change, and each pass needs its own reporter,
|
|
475
|
+
// resolver and job context — sharing them across passes would replay a
|
|
476
|
+
// finished progress display and reuse an already-flushed lock.
|
|
477
|
+
const runDeployPassAsync = async (
|
|
478
|
+
refresh: boolean
|
|
479
|
+
): Promise<{ failed: number; resolver: BasePlaceResolver }> => {
|
|
480
|
+
const reporter = _buildReporter();
|
|
481
|
+
// A rebuild triggered by the base place moving must re-resolve the pin,
|
|
482
|
+
// or it rebuilds the version it already shipped.
|
|
483
|
+
const basePlaceResolver = createBasePlaceResolver(client, {
|
|
484
|
+
frozenLockfile: refresh ? false : args.frozenLockfile,
|
|
485
|
+
refreshBasePlace: refresh || args.refreshBasePlace,
|
|
486
|
+
});
|
|
487
|
+
const context = new CloudJobContext(reporter, client, basePlaceResolver);
|
|
488
|
+
|
|
489
|
+
await reporter.startAsync();
|
|
490
|
+
let failed = 0;
|
|
491
|
+
try {
|
|
492
|
+
const results = await _runBatchAsync(context, reporter);
|
|
493
|
+
failed = results.summary.failed;
|
|
494
|
+
} finally {
|
|
495
|
+
await context.disposeAsync();
|
|
496
|
+
}
|
|
497
|
+
await reporter.stopAsync();
|
|
498
|
+
return { failed, resolver: basePlaceResolver };
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
function _buildReporter(): CompositeReporter {
|
|
502
|
+
return new CompositeReporter(targetNames, (state: LiveStateTracker) => {
|
|
328
503
|
const reporters: Reporter[] = [];
|
|
329
504
|
if (isMultiPlace) {
|
|
330
505
|
reporters.push(
|
|
@@ -377,25 +552,11 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
377
552
|
);
|
|
378
553
|
}
|
|
379
554
|
return reporters;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const apiKey = await getApiKeyAsync(args);
|
|
384
|
-
const client = new OpenCloudClient({
|
|
385
|
-
apiKey,
|
|
386
|
-
rateLimiter: new RateLimiter(),
|
|
387
|
-
});
|
|
388
|
-
const context = new CloudJobContext(reporter, client);
|
|
389
|
-
|
|
390
|
-
await reporter.startAsync();
|
|
391
|
-
|
|
392
|
-
let exitCode = 0;
|
|
393
|
-
// Captured only for the single-place success message printed after the run.
|
|
394
|
-
let publishedVersion: number | undefined;
|
|
395
|
-
let publishedPlaceId: number | undefined;
|
|
555
|
+
});
|
|
556
|
+
}
|
|
396
557
|
|
|
397
|
-
|
|
398
|
-
|
|
558
|
+
function _runBatchAsync(context: CloudJobContext, reporter: Reporter) {
|
|
559
|
+
return runBatchAsync<BatchTarget, BatchDeployResult>({
|
|
399
560
|
items: batchTargets,
|
|
400
561
|
concurrency: isMultiPlace ? MULTI_PLACE_CONCURRENCY : 1,
|
|
401
562
|
reporter,
|
|
@@ -460,16 +621,143 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
460
621
|
};
|
|
461
622
|
},
|
|
462
623
|
});
|
|
463
|
-
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
let exitCode = 0;
|
|
627
|
+
let watchResult: RegisterWatchesResult | undefined;
|
|
628
|
+
const watchedTarget = parseTargetSelector(targetName).targetName;
|
|
629
|
+
|
|
630
|
+
try {
|
|
631
|
+
const first = await runDeployPassAsync(args.refreshBasePlace ?? false);
|
|
632
|
+
if (first.failed > 0) exitCode = 1;
|
|
633
|
+
|
|
634
|
+
// Only after a clean deploy: what happens next records the base place
|
|
635
|
+
// version that just shipped, which is not a fact yet if the deploy failed.
|
|
636
|
+
if (watchOption && first.failed === 0) {
|
|
637
|
+
if (isCI()) {
|
|
638
|
+
// The monitor is named for the whole target, so it has to carry every
|
|
639
|
+
// place in that target — not just the ones this invocation deployed.
|
|
640
|
+
// Re-registering replaces its watch list, so a narrowed selector
|
|
641
|
+
// (`integration.places.hub`) would otherwise delete the sibling
|
|
642
|
+
// places' watches. Places that did not deploy keep their lock baseline.
|
|
643
|
+
watchResult = await registerWatchesAsync({
|
|
644
|
+
option: watchOption,
|
|
645
|
+
// Scoped to this package and target, so deploying one package can
|
|
646
|
+
// never replace the watch list another package registered.
|
|
647
|
+
monitorName: `${packageName}/${watchedTarget}`,
|
|
648
|
+
resolver: first.resolver,
|
|
649
|
+
useGhAuth: args.watchUseGhAuth,
|
|
650
|
+
robloxApiKey: args.watchShareApiKey ? apiKey : undefined,
|
|
651
|
+
candidates: resolveDeployTargetPlaces(config, watchedTarget).map(
|
|
652
|
+
(place) => ({
|
|
653
|
+
targetName: watchedTarget,
|
|
654
|
+
packageName,
|
|
655
|
+
packagePath: cwd,
|
|
656
|
+
place,
|
|
657
|
+
})
|
|
658
|
+
),
|
|
659
|
+
});
|
|
660
|
+
} else {
|
|
661
|
+
// Locally the rebuild belongs here, not on a runner, so the watch
|
|
662
|
+
// asks to be told rather than to dispatch. Being told beats polling —
|
|
663
|
+
// no Open Cloud quota per developer, and the rebuild starts when the
|
|
664
|
+
// change lands — but polling still works everywhere, so it is what
|
|
665
|
+
// this falls back to.
|
|
666
|
+
const localEntries = await _buildLocalWatchEntriesAsync(
|
|
667
|
+
config,
|
|
668
|
+
watchedTarget,
|
|
669
|
+
cwd,
|
|
670
|
+
first.resolver
|
|
671
|
+
);
|
|
672
|
+
const redeployAsync = async () => {
|
|
673
|
+
const pass = await runDeployPassAsync(true);
|
|
674
|
+
if (pass.failed > 0) {
|
|
675
|
+
throw new Error('deploy failed');
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
const notify = await tryRegisterNotifyWatchesAsync({
|
|
680
|
+
option: watchOption,
|
|
681
|
+
monitorName: `${packageName}/${watchedTarget}`,
|
|
682
|
+
entries: localEntries,
|
|
683
|
+
useGhAuth: args.watchUseGhAuth,
|
|
684
|
+
robloxApiKey: args.watchShareApiKey ? apiKey : undefined,
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
// Streaming is preferred but never required: whatever the reason it
|
|
688
|
+
// is unavailable, polling from here still works.
|
|
689
|
+
let pollInstead = true;
|
|
690
|
+
if (notify.success) {
|
|
691
|
+
// Anything the stream throws is still just "streaming did not
|
|
692
|
+
// work", and the promise above says polling covers that however it
|
|
693
|
+
// happens. Letting it escape to the handler's catch would exit the
|
|
694
|
+
// run instead — reporting a failure for a watch that could simply
|
|
695
|
+
// have carried on here.
|
|
696
|
+
let loop;
|
|
697
|
+
try {
|
|
698
|
+
loop = await runStreamWatchLoopAsync({
|
|
699
|
+
entries: notify.entries,
|
|
700
|
+
stream: new WebSocketWatchStream({
|
|
701
|
+
registerUrl: watchOption.registerUrl,
|
|
702
|
+
}),
|
|
703
|
+
// The stream says a place moved; Open Cloud says what it moved
|
|
704
|
+
// to. The two speak different version vocabularies, and only
|
|
705
|
+
// this one matches what the lock records.
|
|
706
|
+
source: client,
|
|
707
|
+
monitorId: notify.monitorId,
|
|
708
|
+
credential: notify.credential,
|
|
709
|
+
redeployAsync,
|
|
710
|
+
});
|
|
711
|
+
} catch (err) {
|
|
712
|
+
OutputHelper.warn(
|
|
713
|
+
'Could not hold the watch stream: ' +
|
|
714
|
+
(err instanceof Error ? err.message : String(err))
|
|
715
|
+
);
|
|
716
|
+
loop = undefined;
|
|
717
|
+
}
|
|
718
|
+
if (loop && loop.failures > 0) exitCode = 1;
|
|
719
|
+
// The service could not read any of these places — a private base
|
|
720
|
+
// place, say. This machine has credentials it does not, so the
|
|
721
|
+
// watch carries on here rather than waiting on a socket that will
|
|
722
|
+
// never say anything.
|
|
723
|
+
//
|
|
724
|
+
// A lapsed lease or a refused handshake ends the stream just as
|
|
725
|
+
// finally, and the user asked to keep watching either way — exiting
|
|
726
|
+
// there would report success while silently doing nothing.
|
|
727
|
+
pollInstead =
|
|
728
|
+
loop == null ||
|
|
729
|
+
loop.unobservable ||
|
|
730
|
+
loop.monitorGone ||
|
|
731
|
+
loop.rejected;
|
|
732
|
+
if (pollInstead) {
|
|
733
|
+
OutputHelper.info(
|
|
734
|
+
'Watching from here instead, using your own Open Cloud key.'
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
} else if (notify.reason !== 'no_entries') {
|
|
738
|
+
OutputHelper.verbose(
|
|
739
|
+
`Polling instead of streaming: ${describeNotifyWatchFallback(
|
|
740
|
+
notify
|
|
741
|
+
)}.`
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (pollInstead) {
|
|
746
|
+
const loop = await runLocalWatchLoopAsync({
|
|
747
|
+
entries: localEntries,
|
|
748
|
+
source: client,
|
|
749
|
+
durationMs: watchOption.durationMs,
|
|
750
|
+
redeployAsync,
|
|
751
|
+
});
|
|
752
|
+
if (loop.failures > 0) exitCode = 1;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
464
756
|
} catch (err) {
|
|
465
757
|
OutputHelper.error(err instanceof Error ? err.message : String(err));
|
|
466
758
|
exitCode = 1;
|
|
467
|
-
} finally {
|
|
468
|
-
await context.disposeAsync();
|
|
469
759
|
}
|
|
470
760
|
|
|
471
|
-
await reporter.stopAsync();
|
|
472
|
-
|
|
473
761
|
if (publishedVersion !== undefined) {
|
|
474
762
|
const placeUrl =
|
|
475
763
|
publishedPlaceId !== undefined
|
|
@@ -491,6 +779,13 @@ export class DeployCommand<T> implements CommandModule<T, DeployArgs> {
|
|
|
491
779
|
}
|
|
492
780
|
}
|
|
493
781
|
|
|
782
|
+
if (watchResult && watchResult.registered > 0) {
|
|
783
|
+
OutputHelper.hint(
|
|
784
|
+
'The watch rebuilds this target when its base place moves. Re-run ' +
|
|
785
|
+
'with --watch to renew the lease before it expires.'
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
|
|
494
789
|
if (exitCode !== 0) process.exit(exitCode);
|
|
495
790
|
}
|
|
496
791
|
}
|