Skip to content

Commit be43c4a

Browse files
committed
feat(deploy): add --verbose flag for resource name and id output
Add a -v/--verbose flag to `deploy` that shows the resource name and physical ID (UUID) for each created or updated resource. The --verbose flag implies --output, so both flags don't need to be passed together. Without --verbose, deploy output is unchanged.
1 parent 471229a commit be43c4a

File tree

6 files changed

+62
-10
lines changed

6 files changed

+62
-10
lines changed

packages/cli/e2e/__tests__/deploy.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,30 @@ Skip (testOnly):
321321
Update and Unchanged:
322322
ApiCheck: not-testonly-default-check
323323
ApiCheck: not-testonly-false-check`)
324+
// --output without --verbose should not show name or id
325+
expect(stdout).not.toContain('name:')
326+
expect(stdout).not.toContain('id:')
327+
})
328+
329+
it('Should show resource name and id with --verbose', async () => {
330+
const { stdout } = await runDeploy(fixt, ['--force', '--verbose'], {
331+
env: {
332+
PROJECT_LOGICAL_ID: projectLogicalId,
333+
PRIVATE_LOCATION_SLUG_NAME: privateLocationSlugname,
334+
TEST_ONLY: 'true',
335+
CHECKLY_CLI_VERSION: '4.8.0',
336+
},
337+
})
338+
const uuid = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
339+
expect(stdout).toMatch(new RegExp(
340+
`Update and Unchanged:\n`
341+
+ ` ApiCheck: not-testonly-default-check\n`
342+
+ ` name: TestOnly=false \\(default\\) Check\n`
343+
+ ` id: ${uuid}\n`
344+
+ ` ApiCheck: not-testonly-false-check\n`
345+
+ ` name: TestOnly=false Check\n`
346+
+ ` id: ${uuid}`,
347+
))
324348
})
325349
})
326350

packages/cli/src/ai-context/references/communicate.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Write commands (`incidents create`, `incidents update`, `incidents resolve`, `de
2424
3. This applies to **every** write command, not just the first one. Incident updates and resolutions also require confirmation.
2525
4. Use `--dry-run` to preview what a command will do without executing or prompting.
2626
5. Read-only commands (`incidents list`, `status-pages list`) execute immediately without confirmation.
27+
6. When deploying, use `--verbose` to include resource names and physical IDs (UUIDs) in the output. This is useful for programmatically referencing deployed resources (e.g. running `npx checkly checks get <id>` to inspect a deployed check).
2728

2829
## Available Commands
2930

packages/cli/src/ai-context/skill.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Run `npx checkly skills manage` for the full reference.
3434

3535
Write commands (e.g. `incidents create`, `deploy`, `destroy`) return exit code 2 with a `confirmation_required` JSON envelope instead of executing. **Always present the `changes` to the user and wait for approval before running the `confirmCommand`.** Never auto-append `--force`. This applies to every write command individually — updates and resolutions need confirmation too, not just the initial create.
3636

37+
When deploying, use `--verbose` to include resource names and physical IDs (UUIDs) in the output. This is useful for programmatically referencing deployed resources (e.g. running `npx checkly checks get <id>` to inspect a deployed check).
38+
3739
Run `npx checkly skills communicate` for the full protocol details.
3840

3941
<!-- SKILL_COMMANDS -->

packages/cli/src/commands/__tests__/confirm-flow-deploy.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ describe('deploy confirmation flow', () => {
149149
'force': false,
150150
'preview': false,
151151
'output': false,
152+
'verbose': false,
152153
'config': undefined,
153154
'schedule-on-deploy': true,
154155
'verify-runtime-dependencies': true,

packages/cli/src/commands/deploy.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
import chalk from 'chalk'
1515
import { splitConfigFilePath, getGitInformation } from '../services/util'
1616
import commonMessages from '../messages/common-messages'
17-
import { forceFlag } from '../helpers/flags'
1817
import { ProjectDeployResponse } from '../rest/projects'
1918
import { uploadSnapshots } from '../services/snapshot-service'
2019
import { BrowserCheckBundle } from '../constructs/browser-check-bundle'
@@ -45,12 +44,21 @@ export default class Deploy extends AuthCommand {
4544
description: 'Shows the changes made after the deploy command.',
4645
default: false,
4746
}),
47+
'verbose': Flags.boolean({
48+
char: 'v',
49+
description: 'Show resource names and IDs in the deploy output.',
50+
default: false,
51+
}),
4852
'schedule-on-deploy': Flags.boolean({
4953
description: 'Enables automatic check scheduling after a deploy.',
5054
default: true,
5155
allowNo: true,
5256
}),
53-
'force': forceFlag(),
57+
'force': Flags.boolean({
58+
char: 'f',
59+
description: commonMessages.forceMode,
60+
default: false,
61+
}),
5462
'config': Flags.string({
5563
char: 'c',
5664
description: commonMessages.configFile,
@@ -79,12 +87,14 @@ export default class Deploy extends AuthCommand {
7987
force,
8088
preview,
8189
'schedule-on-deploy': scheduleOnDeploy,
82-
output,
90+
output: outputFlag,
91+
verbose,
8392
config: configFilename,
8493
'verify-runtime-dependencies': verifyRuntimeDependencies,
8594
'debug-bundle': debugBundle,
8695
'debug-bundle-output-file': debugBundleOutputFile,
8796
} = flags
97+
const output = outputFlag || verbose
8898
const { configDirectory, configFilenames } = splitConfigFilePath(configFilename)
8999
const {
90100
config: checklyConfig,
@@ -234,7 +244,7 @@ export default class Deploy extends AuthCommand {
234244
try {
235245
const { data } = await api.projects.deploy({ ...projectPayload, repoInfo }, { dryRun: preview, scheduleOnDeploy })
236246
if (preview || output) {
237-
this.log(this.formatPreview(data, project))
247+
this.log(this.formatPreview(data, project, verbose))
238248
}
239249
if (!preview) {
240250
await setTimeout(500)
@@ -256,15 +266,15 @@ export default class Deploy extends AuthCommand {
256266
}
257267
}
258268

259-
private formatPreview (previewData: ProjectDeployResponse, project: Project): string {
269+
private formatPreview (previewData: ProjectDeployResponse, project: Project, verbose = false): string {
260270
// Current format of the data is: { checks: { logical-id-1: 'UPDATE' }, groups: { another-logical-id: 'CREATE' } }
261271
// We convert it into update: [{ logicalId, resourceType, construct }, ...], create: [], delete: []
262272
// This makes it easier to display.
263273
const updating = []
264274
const creating = []
265275
const deleting: Array<{ resourceType: string, logicalId: string }> = []
266276
for (const change of previewData?.diff ?? []) {
267-
const { type, logicalId, action } = change
277+
const { type, logicalId, physicalId, action } = change
268278
if ([
269279
AlertChannelSubscription.__checklyType,
270280
PrivateLocationCheckAssignment.__checklyType,
@@ -276,9 +286,9 @@ export default class Deploy extends AuthCommand {
276286
}
277287
const construct = project.data[type as keyof ProjectData][logicalId]
278288
if (action === ResourceDeployStatus.UPDATE) {
279-
updating.push({ resourceType: type, logicalId, construct })
289+
updating.push({ resourceType: type, logicalId, physicalId, construct })
280290
} else if (action === ResourceDeployStatus.CREATE) {
281-
creating.push({ resourceType: type, logicalId, construct })
291+
creating.push({ resourceType: type, logicalId, physicalId, construct })
282292
} else if (action === ResourceDeployStatus.DELETE) {
283293
// Since the resource is being deleted, the construct isn't in the project.
284294
deleting.push({ resourceType: type, logicalId })
@@ -331,8 +341,14 @@ export default class Deploy extends AuthCommand {
331341

332342
if (sortedCreating.filter(({ construct }) => Boolean(construct)).length) {
333343
output.push(chalk.bold.green('Create:'))
334-
for (const { logicalId, construct } of sortedCreating) {
344+
for (const { logicalId, physicalId, construct } of sortedCreating) {
335345
output.push(` ${construct.constructor.name}: ${logicalId}`)
346+
if (verbose && (construct as any).name) {
347+
output.push(` name: ${(construct as any).name}`)
348+
}
349+
if (verbose && physicalId) {
350+
output.push(` id: ${physicalId}`)
351+
}
336352
}
337353
output.push('')
338354
}
@@ -353,8 +369,14 @@ export default class Deploy extends AuthCommand {
353369
}
354370
if (sortedUpdating.length) {
355371
output.push(chalk.bold.magenta('Update and Unchanged:'))
356-
for (const { logicalId, construct } of sortedUpdating) {
372+
for (const { logicalId, physicalId, construct } of sortedUpdating) {
357373
output.push(` ${construct.constructor.name}: ${logicalId}`)
374+
if (verbose && (construct as any).name) {
375+
output.push(` name: ${(construct as any).name}`)
376+
}
377+
if (verbose && physicalId) {
378+
output.push(` id: ${physicalId}`)
379+
}
358380
}
359381
output.push('')
360382
}

skills/checkly/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Run `npx checkly skills manage` for the full reference.
3434

3535
Write commands (e.g. `incidents create`, `deploy`, `destroy`) return exit code 2 with a `confirmation_required` JSON envelope instead of executing. **Always present the `changes` to the user and wait for approval before running the `confirmCommand`.** Never auto-append `--force`. This applies to every write command individually — updates and resolutions need confirmation too, not just the initial create.
3636

37+
When deploying, use `--verbose` to include resource names and physical IDs (UUIDs) in the output. This is useful for programmatically referencing deployed resources (e.g. running `npx checkly checks get <id>` to inspect a deployed check).
38+
3739
Run `npx checkly skills communicate` for the full protocol details.
3840

3941
### `npx checkly skills initialize`

0 commit comments

Comments
 (0)