@testsprite/testsprite-cli 0.12.0 → 0.14.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/README.md +59 -49
- package/dist/commands/agent.js +16 -13
- package/dist/commands/auth.d.ts +19 -0
- package/dist/commands/auth.js +60 -24
- package/dist/commands/ci.d.ts +86 -1
- package/dist/commands/ci.js +436 -5
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +34 -20
- package/dist/commands/init.js +14 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +408 -70
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +14 -5
- package/dist/commands/project.js +110 -70
- package/dist/commands/schedule.d.ts +14 -0
- package/dist/commands/schedule.js +193 -15
- package/dist/commands/test.d.ts +123 -44
- package/dist/commands/test.js +2993 -636
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +217 -47
- package/dist/commands/tunnel.d.ts +26 -3
- package/dist/commands/tunnel.js +221 -18
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.js +12 -5
- package/dist/index.js +39 -50
- package/dist/lib/agent-targets.d.ts +3 -3
- package/dist/lib/agent-targets.js +2 -2
- package/dist/lib/billing-refusal.d.ts +43 -0
- package/dist/lib/billing-refusal.js +171 -0
- package/dist/lib/bundle.d.ts +5 -0
- package/dist/lib/bundle.js +43 -13
- package/dist/lib/ci-linkage.d.ts +90 -0
- package/dist/lib/ci-linkage.js +181 -0
- package/dist/lib/client-factory.d.ts +16 -2
- package/dist/lib/client-factory.js +37 -6
- package/dist/lib/config.d.ts +17 -0
- package/dist/lib/config.js +20 -1
- package/dist/lib/conflict-reason.d.ts +27 -3
- package/dist/lib/conflict-reason.js +53 -4
- package/dist/lib/credentials.js +56 -14
- package/dist/lib/dry-run/samples.d.ts +13 -1
- package/dist/lib/dry-run/samples.js +104 -7
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.d.ts +18 -11
- package/dist/lib/errors.js +123 -14
- package/dist/lib/failing-fe-resolver.d.ts +1 -1
- package/dist/lib/failing-fe-resolver.js +3 -3
- package/dist/lib/gh-output.d.ts +1 -0
- package/dist/lib/gh-output.js +16 -4
- package/dist/lib/history-retention.d.ts +8 -0
- package/dist/lib/history-retention.js +24 -0
- package/dist/lib/http.d.ts +39 -19
- package/dist/lib/http.js +46 -24
- package/dist/lib/interrupt.d.ts +21 -13
- package/dist/lib/interrupt.js +32 -21
- package/dist/lib/junit-report.d.ts +18 -4
- package/dist/lib/junit-report.js +23 -5
- package/dist/lib/local-target.d.ts +14 -4
- package/dist/lib/local-target.js +48 -13
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.d.ts +11 -11
- package/dist/lib/plan-poll.js +15 -16
- package/dist/lib/plans.types.d.ts +9 -9
- package/dist/lib/plans.types.js +3 -3
- package/dist/lib/poll.d.ts +2 -2
- package/dist/lib/poll.js +9 -3
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +21 -5
- package/dist/lib/render-error.js +44 -0
- package/dist/lib/response-schemas.d.ts +54 -12
- package/dist/lib/response-schemas.js +88 -7
- package/dist/lib/runs.types.d.ts +68 -11
- package/dist/lib/secret-file.js +72 -14
- package/dist/lib/skill-nudge.d.ts +6 -1
- package/dist/lib/skill-nudge.js +32 -5
- package/dist/lib/target-url-preflight.d.ts +6 -4
- package/dist/lib/target-url-preflight.js +64 -51
- package/dist/lib/target-url.js +11 -11
- package/dist/lib/telemetry.d.ts +10 -8
- package/dist/lib/telemetry.js +24 -17
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +111 -4
- package/dist/lib/tunnel-session.d.ts +16 -4
- package/dist/lib/tunnel-session.js +7 -5
- package/dist/lib/tunnel.types.d.ts +12 -2
- package/dist/lib/tunnel.types.js +2 -2
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/lib/wait-exit.d.ts +8 -0
- package/dist/lib/wait-exit.js +76 -4
- package/dist/lib/workspace-status.d.ts +23 -0
- package/dist/lib/workspace-status.js +15 -0
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version-guard.d.ts +7 -1
- package/dist/version-guard.js +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/testsprite-onboard.skill.md +8 -8
- package/skills/testsprite-verify.codex.md +59 -57
- package/skills/testsprite-verify.skill.md +53 -38
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveProfileName } from '../lib/config.js';
|
|
5
|
+
import { ApiError, InterruptError } from '../lib/errors.js';
|
|
5
6
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
6
7
|
import { formatScheduleFrequencyAdvisory, runsPerMonth } from '../lib/cron.js';
|
|
7
8
|
import { renderTextTable } from '../lib/text-table.js';
|
|
8
9
|
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
10
|
+
import { historyRetentionNote } from '../lib/history-retention.js';
|
|
9
11
|
// ---------------------------------------------------------------------------
|
|
10
12
|
// schedule list
|
|
11
13
|
// ---------------------------------------------------------------------------
|
|
@@ -52,10 +54,17 @@ export async function runCreate(opts, deps = {}) {
|
|
|
52
54
|
}
|
|
53
55
|
const targetType = opts.targetType;
|
|
54
56
|
const cron = opts.cron.trim();
|
|
57
|
+
const environment = normalizeScheduleEnvironmentName(opts.env);
|
|
58
|
+
if (targetType === 'testList' && environment !== undefined) {
|
|
59
|
+
throw environmentValidationError('not_supported_for_target', `Test-list schedules inherit their list's environment bindings. ` +
|
|
60
|
+
`Use testsprite testlist update ${opts.targetId} ` +
|
|
61
|
+
'--project-env <projectId>:<environmentName> instead.');
|
|
62
|
+
}
|
|
55
63
|
const body = {
|
|
56
64
|
name: opts.name,
|
|
57
65
|
targetType,
|
|
58
66
|
targetId: opts.targetId,
|
|
67
|
+
...(environment !== undefined ? { environment } : {}),
|
|
59
68
|
cron,
|
|
60
69
|
...(opts.timezone !== undefined ? { timezone: opts.timezone } : {}),
|
|
61
70
|
...(opts.start !== undefined ? { startAt: opts.start } : {}),
|
|
@@ -71,23 +80,63 @@ export async function runCreate(opts, deps = {}) {
|
|
|
71
80
|
if (opts.dryRun) {
|
|
72
81
|
emitDryRunBanner(stderr);
|
|
73
82
|
// Carries a cost figure so the advisory below is exercised offline too.
|
|
83
|
+
// There is no real server round trip to confirm here, so the mode is
|
|
84
|
+
// synthesized straight from the flags being previewed, same as a
|
|
85
|
+
// compliant server would echo back.
|
|
74
86
|
const sample = {
|
|
75
87
|
scheduleId: 'sch_dryrun_2026',
|
|
76
88
|
estimatedCreditsPerRun: 5,
|
|
89
|
+
...(targetType === 'project'
|
|
90
|
+
? { environment: environment ?? null, environmentMode: environment ? 'pinned' : 'inherit' }
|
|
91
|
+
: {}),
|
|
77
92
|
};
|
|
78
93
|
emitCostAdvisory(sample, cron, stderr);
|
|
79
94
|
out.print(sample, data => renderCreateScheduleText(data));
|
|
80
95
|
return sample;
|
|
81
96
|
}
|
|
82
97
|
const client = makeClient(opts, deps);
|
|
98
|
+
if (environment !== undefined) {
|
|
99
|
+
await checkScheduleEnvironmentSupport(client);
|
|
100
|
+
}
|
|
83
101
|
const created = await client.post('/schedules', {
|
|
84
102
|
body,
|
|
85
103
|
headers: { 'idempotency-key': idempotencyKey },
|
|
86
104
|
});
|
|
105
|
+
if (targetType === 'project' && environment !== undefined) {
|
|
106
|
+
await confirmCreateEnvironmentPin(created, environment, client);
|
|
107
|
+
}
|
|
87
108
|
emitCostAdvisory(created, cron, stderr);
|
|
88
109
|
out.print(created, data => renderCreateScheduleText(data));
|
|
89
110
|
return created;
|
|
90
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* `--env` on create asks the server to pin the new schedule. An old server
|
|
114
|
+
* without this feature drops the field silently and echoes back a schedule
|
|
115
|
+
* with no environment mode at all — printing a confirmation on top of that
|
|
116
|
+
* would claim a pin that was never applied. Instead, best-effort undo the
|
|
117
|
+
* create (this command's own write, seconds old) and refuse.
|
|
118
|
+
*/
|
|
119
|
+
async function confirmCreateEnvironmentPin(created, environment, client) {
|
|
120
|
+
if (created.environmentMode === 'pinned' && created.environment === environment)
|
|
121
|
+
return;
|
|
122
|
+
let rolledBack = false;
|
|
123
|
+
try {
|
|
124
|
+
await client.delete(`/schedules/${encodeURIComponent(created.scheduleId)}`, {
|
|
125
|
+
headers: { 'idempotency-key': `cli-sched-create-rollback-${randomUUID()}` },
|
|
126
|
+
});
|
|
127
|
+
rolledBack = true;
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
if (err instanceof InterruptError)
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
throw unsupportedEnvironmentError(rolledBack
|
|
134
|
+
? `Schedule ${created.scheduleId} was created and then removed because this server did ` +
|
|
135
|
+
'not apply the requested environment.'
|
|
136
|
+
: `Schedule ${created.scheduleId} was created without a confirmed environment pin, and ` +
|
|
137
|
+
'the CLI could not remove it; remove it with: ' +
|
|
138
|
+
`testsprite schedule delete ${created.scheduleId} --confirm`, { scheduleId: created.scheduleId, rolledBack });
|
|
139
|
+
}
|
|
91
140
|
/**
|
|
92
141
|
* Cost advisory for a schedule that was just created.
|
|
93
142
|
*
|
|
@@ -124,8 +173,10 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
124
173
|
if (opts.pause && opts.resume) {
|
|
125
174
|
throw localValidationError('--pause and --resume cannot be combined');
|
|
126
175
|
}
|
|
176
|
+
const environment = normalizeScheduleEnvironmentName(opts.env);
|
|
127
177
|
const body = {
|
|
128
178
|
...(opts.name !== undefined ? { name: opts.name } : {}),
|
|
179
|
+
...(environment !== undefined ? { environment } : {}),
|
|
129
180
|
...(opts.cron !== undefined ? { cron: opts.cron } : {}),
|
|
130
181
|
...(opts.timezone !== undefined ? { timezone: opts.timezone } : {}),
|
|
131
182
|
...(opts.start !== undefined ? { startAt: opts.start } : {}),
|
|
@@ -149,7 +200,24 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
149
200
|
stderr(formatScheduleFrequencyAdvisory(opts.cron));
|
|
150
201
|
}
|
|
151
202
|
const client = makeClient(opts, deps);
|
|
203
|
+
if (environment !== undefined && !opts.dryRun) {
|
|
204
|
+
await checkScheduleEnvironmentSupport(client, opts.scheduleId);
|
|
205
|
+
}
|
|
152
206
|
const updated = await client.patch(`/schedules/${encodeURIComponent(opts.scheduleId)}`, { body, headers: { 'idempotency-key': idempotencyKey } });
|
|
207
|
+
// `--env` on update pins an existing schedule. An old server drops the
|
|
208
|
+
// field silently and echoes back no environment mode; unlike create there
|
|
209
|
+
// is nothing to roll back (the schedule pre-existed this command), so this
|
|
210
|
+
// just refuses rather than confirming a pin that was never applied. Other
|
|
211
|
+
// fields in the same request may still have gone through.
|
|
212
|
+
if (environment !== undefined &&
|
|
213
|
+
!(updated.environmentMode === 'pinned' && updated.environment === environment)) {
|
|
214
|
+
throw unsupportedEnvironmentError(`The server updated schedule ${updated.scheduleId} without confirming the environment ` +
|
|
215
|
+
`pin. Other requested fields (${Object.keys(body)
|
|
216
|
+
.filter(key => key !== 'environment')
|
|
217
|
+
.join(', ') || 'none'}) ` +
|
|
218
|
+
'may have been applied; inspect it with: ' +
|
|
219
|
+
`testsprite schedule get ${updated.scheduleId}`, { scheduleId: updated.scheduleId, requestedFields: Object.keys(body) });
|
|
220
|
+
}
|
|
153
221
|
out.print(updated, data => renderScheduleText(data));
|
|
154
222
|
return updated;
|
|
155
223
|
}
|
|
@@ -191,8 +259,14 @@ export async function runRunList(opts, deps = {}) {
|
|
|
191
259
|
const client = makeClient(opts, deps);
|
|
192
260
|
const response = await client.get(`/schedules/${encodeURIComponent(opts.scheduleId)}/runs`);
|
|
193
261
|
const runs = response.runs ?? [];
|
|
194
|
-
|
|
195
|
-
|
|
262
|
+
const outputResponse = { ...response, runs };
|
|
263
|
+
out.print(outputResponse, () => renderRunListText(runs, { columns: opts.columns, noHeader: opts.noHeader }));
|
|
264
|
+
if (opts.output === 'text') {
|
|
265
|
+
const note = historyRetentionNote(response.meta, client.resolvedBaseUrl);
|
|
266
|
+
if (note)
|
|
267
|
+
(deps.stderr ?? ((line) => process.stderr.write(`${line}\n`)))(note);
|
|
268
|
+
}
|
|
269
|
+
return outputResponse;
|
|
196
270
|
}
|
|
197
271
|
// ---------------------------------------------------------------------------
|
|
198
272
|
// Rendering
|
|
@@ -230,7 +304,16 @@ const SCHEDULE_LIST_COLUMNS = [
|
|
|
230
304
|
width: rows => Math.max(2, ...rows.map(s => (s.timezone ?? '').length)),
|
|
231
305
|
render: s => s.timezone ?? '',
|
|
232
306
|
},
|
|
233
|
-
{
|
|
307
|
+
{
|
|
308
|
+
header: 'LAST RUN',
|
|
309
|
+
width: rows => Math.max(8, ...rows.map(s => (s.lastRunId ?? '').length)),
|
|
310
|
+
render: s => s.lastRunId ?? '',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
header: 'ENVIRONMENT',
|
|
314
|
+
width: rows => Math.max(11, ...rows.map(s => scheduleEnvironmentText(s).length)),
|
|
315
|
+
render: scheduleEnvironmentText,
|
|
316
|
+
},
|
|
234
317
|
];
|
|
235
318
|
function renderScheduleListText(schedules, options = {}) {
|
|
236
319
|
if (schedules.length === 0)
|
|
@@ -258,10 +341,99 @@ function renderScheduleText(s) {
|
|
|
258
341
|
];
|
|
259
342
|
if (s.autoPausedAt)
|
|
260
343
|
lines.push(`autoPaused: ${s.autoPausedAt}`);
|
|
344
|
+
if (s.environmentMode !== undefined) {
|
|
345
|
+
lines.push(`environment: ${scheduleEnvironmentText(s)}`);
|
|
346
|
+
}
|
|
261
347
|
return lines.join('\n');
|
|
262
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Renders the environment/mode strictly from the server's response — never
|
|
351
|
+
* from what the command asked for. When the response omits `environmentMode`
|
|
352
|
+
* altogether (an old server that has never heard of schedule environments),
|
|
353
|
+
* this stays silent about it, matching the confirmation text from before the
|
|
354
|
+
* feature existed rather than fabricating a claim the server never made.
|
|
355
|
+
* (A request that explicitly asked to pin and got no confirmation never
|
|
356
|
+
* reaches this renderer — `confirmCreateEnvironmentPin` refuses first.)
|
|
357
|
+
*/
|
|
263
358
|
function renderCreateScheduleText(r) {
|
|
264
|
-
|
|
359
|
+
if (r.environmentMode === undefined)
|
|
360
|
+
return `id: ${r.scheduleId}`;
|
|
361
|
+
return `id: ${r.scheduleId}\nenvironment: ${scheduleEnvironmentText(r)}`;
|
|
362
|
+
}
|
|
363
|
+
function scheduleEnvironmentText(schedule) {
|
|
364
|
+
if (schedule.environmentMode === 'inherit')
|
|
365
|
+
return 'project default (inherits)';
|
|
366
|
+
if (schedule.environmentMode === 'pinned' && schedule.environment) {
|
|
367
|
+
return `${schedule.environment} (pinned)`;
|
|
368
|
+
}
|
|
369
|
+
return '-';
|
|
370
|
+
}
|
|
371
|
+
function normalizeScheduleEnvironmentName(raw) {
|
|
372
|
+
if (raw === undefined)
|
|
373
|
+
return undefined;
|
|
374
|
+
const name = raw.trim();
|
|
375
|
+
if (name.length === 0) {
|
|
376
|
+
throw environmentValidationError('blank_value', '--env must be a non-empty environment name');
|
|
377
|
+
}
|
|
378
|
+
return name;
|
|
379
|
+
}
|
|
380
|
+
/** A missing mode on a project schedule proves that the server predates pins. */
|
|
381
|
+
async function checkScheduleEnvironmentSupport(client, scheduleId) {
|
|
382
|
+
let schedules;
|
|
383
|
+
try {
|
|
384
|
+
schedules =
|
|
385
|
+
scheduleId === undefined
|
|
386
|
+
? ((await client.get('/schedules', { retry: false })).schedules ?? [])
|
|
387
|
+
: [
|
|
388
|
+
await client.get(`/schedules/${encodeURIComponent(scheduleId)}`, {
|
|
389
|
+
retry: false,
|
|
390
|
+
}),
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
catch (err) {
|
|
394
|
+
if (err instanceof InterruptError)
|
|
395
|
+
throw err;
|
|
396
|
+
// A write-scoped key may not read schedules. Keep response confirmation
|
|
397
|
+
// for inconclusive probes and for a server with no existing schedules.
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (schedules.some(schedule => schedule.targetType === 'project' && schedule.environmentMode === undefined)) {
|
|
401
|
+
throw unsupportedEnvironmentError(scheduleId === undefined
|
|
402
|
+
? 'No schedule was created. Upgrade the server before using schedule --env.'
|
|
403
|
+
: `No schedule changes were sent. Upgrade the server before using schedule --env on ${scheduleId}.`, {
|
|
404
|
+
...(scheduleId !== undefined ? { scheduleId } : {}),
|
|
405
|
+
reason: 'schedule-environments-unsupported',
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Local validation failures on `--env` — mirrors the field the API itself
|
|
411
|
+
* uses (`environment`, the wire name) rather than the flag name, so a caller
|
|
412
|
+
* inspecting `details.field` sees the same value whether the rejection was
|
|
413
|
+
* caught locally or came back from the server.
|
|
414
|
+
*/
|
|
415
|
+
function environmentValidationError(reason, nextAction) {
|
|
416
|
+
return ApiError.fromEnvelope({
|
|
417
|
+
error: {
|
|
418
|
+
code: 'VALIDATION_ERROR',
|
|
419
|
+
message: 'Invalid request.',
|
|
420
|
+
nextAction,
|
|
421
|
+
requestId: 'local',
|
|
422
|
+
details: { field: 'environment', reason },
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/** Exit 7 — a server that doesn't (yet) support schedule environments. */
|
|
427
|
+
function unsupportedEnvironmentError(nextAction, details) {
|
|
428
|
+
return ApiError.fromEnvelope({
|
|
429
|
+
error: {
|
|
430
|
+
code: 'UNSUPPORTED',
|
|
431
|
+
message: 'This server does not support schedule environments yet.',
|
|
432
|
+
nextAction,
|
|
433
|
+
requestId: 'local',
|
|
434
|
+
details,
|
|
435
|
+
},
|
|
436
|
+
});
|
|
265
437
|
}
|
|
266
438
|
const RUN_LIST_COLUMNS = [
|
|
267
439
|
{
|
|
@@ -315,7 +487,7 @@ export function createScheduleCommand(deps = {}) {
|
|
|
315
487
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
316
488
|
.action(async (cmdOpts, command) => {
|
|
317
489
|
await runList({
|
|
318
|
-
...resolveCommonOptions(command),
|
|
490
|
+
...resolveCommonOptions(command, deps.env),
|
|
319
491
|
columns: cmdOpts.columns,
|
|
320
492
|
noHeader: cmdOpts.header === false,
|
|
321
493
|
}, deps);
|
|
@@ -332,7 +504,7 @@ export function createScheduleCommand(deps = {}) {
|
|
|
332
504
|
' 13 not available on your plan')
|
|
333
505
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
334
506
|
.action(async (scheduleId, _cmdOpts, command) => {
|
|
335
|
-
await runGet({ ...resolveCommonOptions(command), scheduleId }, deps);
|
|
507
|
+
await runGet({ ...resolveCommonOptions(command, deps.env), scheduleId }, deps);
|
|
336
508
|
});
|
|
337
509
|
schedule
|
|
338
510
|
.command('create')
|
|
@@ -343,12 +515,14 @@ export function createScheduleCommand(deps = {}) {
|
|
|
343
515
|
' 4 target not found\n' +
|
|
344
516
|
' 5 validation error (e.g., missing --cron)\n' +
|
|
345
517
|
' 6 idempotency conflict\n' +
|
|
346
|
-
' 7 schedules are not available on this account
|
|
518
|
+
' 7 schedules are not available on this account, or (with --env) the server does ' +
|
|
519
|
+
'not support schedule environments yet\n' +
|
|
347
520
|
' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
|
|
348
521
|
' 13 not available on your plan, or the plan limit is reached')
|
|
349
522
|
.option('--name <name>', 'schedule name (required)')
|
|
350
523
|
.option('--target-type <project|testList>', 'what to run (required)')
|
|
351
524
|
.option('--target-id <id>', 'project id or test-list id (required)')
|
|
525
|
+
.option('--env <name>', "Pin this project schedule to an environment; omit to always use the project's default environment")
|
|
352
526
|
.option('--cron <expr>', 'standard 5-field cron (minute hour day-of-month month day-of-week), ' +
|
|
353
527
|
'e.g. "0 3 * * *". Day-of-week is 0-7, with both 0 and 7 = Sunday. ' +
|
|
354
528
|
'Constrain ' +
|
|
@@ -361,10 +535,11 @@ export function createScheduleCommand(deps = {}) {
|
|
|
361
535
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
362
536
|
.action(async (cmdOpts, command) => {
|
|
363
537
|
await runCreate({
|
|
364
|
-
...resolveCommonOptions(command),
|
|
538
|
+
...resolveCommonOptions(command, deps.env),
|
|
365
539
|
name: cmdOpts.name,
|
|
366
540
|
targetType: cmdOpts.targetType,
|
|
367
541
|
targetId: cmdOpts.targetId,
|
|
542
|
+
env: cmdOpts.env,
|
|
368
543
|
cron: cmdOpts.cron,
|
|
369
544
|
timezone: cmdOpts.timezone,
|
|
370
545
|
start: cmdOpts.start,
|
|
@@ -382,10 +557,12 @@ export function createScheduleCommand(deps = {}) {
|
|
|
382
557
|
' 4 not found\n' +
|
|
383
558
|
' 5 validation error (e.g., no fields given)\n' +
|
|
384
559
|
' 6 idempotency conflict\n' +
|
|
385
|
-
' 7 schedules are not available on this account
|
|
560
|
+
' 7 schedules are not available on this account, or (with --env) the server does ' +
|
|
561
|
+
'not support schedule environments yet\n' +
|
|
386
562
|
' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
|
|
387
563
|
' 13 not available on your plan')
|
|
388
564
|
.option('--name <name>', 'new schedule name')
|
|
565
|
+
.option('--env <name>', "Pin this project schedule to an environment; omit to always use the project's default environment")
|
|
389
566
|
.option('--cron <expr>', 'new standard 5-field cron, as printed by `schedule get`. Day-of-week is ' +
|
|
390
567
|
'0-7, with both 0 and 7 = Sunday. Constrain day-of-month or day-of-week, not both.')
|
|
391
568
|
.option('--timezone <tz>', 'new IANA timezone')
|
|
@@ -398,9 +575,10 @@ export function createScheduleCommand(deps = {}) {
|
|
|
398
575
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
399
576
|
.action(async (scheduleId, cmdOpts, command) => {
|
|
400
577
|
await runUpdate({
|
|
401
|
-
...resolveCommonOptions(command),
|
|
578
|
+
...resolveCommonOptions(command, deps.env),
|
|
402
579
|
scheduleId,
|
|
403
580
|
name: cmdOpts.name,
|
|
581
|
+
env: cmdOpts.env,
|
|
404
582
|
cron: cmdOpts.cron,
|
|
405
583
|
timezone: cmdOpts.timezone,
|
|
406
584
|
start: cmdOpts.start,
|
|
@@ -428,7 +606,7 @@ export function createScheduleCommand(deps = {}) {
|
|
|
428
606
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
429
607
|
.action(async (scheduleId, cmdOpts, command) => {
|
|
430
608
|
await runDelete({
|
|
431
|
-
...resolveCommonOptions(command),
|
|
609
|
+
...resolveCommonOptions(command, deps.env),
|
|
432
610
|
scheduleId,
|
|
433
611
|
confirm: cmdOpts.confirm === true,
|
|
434
612
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -450,7 +628,7 @@ export function createScheduleCommand(deps = {}) {
|
|
|
450
628
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
451
629
|
.action(async (scheduleId, cmdOpts, command) => {
|
|
452
630
|
await runRunList({
|
|
453
|
-
...resolveCommonOptions(command),
|
|
631
|
+
...resolveCommonOptions(command, deps.env),
|
|
454
632
|
scheduleId,
|
|
455
633
|
columns: cmdOpts.columns,
|
|
456
634
|
noHeader: cmdOpts.header === false,
|
|
@@ -461,10 +639,10 @@ export function createScheduleCommand(deps = {}) {
|
|
|
461
639
|
// ---------------------------------------------------------------------------
|
|
462
640
|
// Helpers
|
|
463
641
|
// ---------------------------------------------------------------------------
|
|
464
|
-
function resolveCommonOptions(command) {
|
|
642
|
+
function resolveCommonOptions(command, env) {
|
|
465
643
|
const globals = command.optsWithGlobals();
|
|
466
644
|
return {
|
|
467
|
-
profile: globals.profile
|
|
645
|
+
profile: resolveProfileName(globals.profile, env),
|
|
468
646
|
output: resolveOutputMode(globals.output),
|
|
469
647
|
endpointUrl: globals.endpointUrl,
|
|
470
648
|
debug: globals.debug ?? false,
|