-
Notifications
You must be signed in to change notification settings - Fork 0
insta logs --deploy (compute deploy events) #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,10 +78,30 @@ export async function usage(opts: { from?: string; to?: string; json?: boolean; | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // pure: platform path for a compute deploy-events request (used by `insta logs --deploy`). | ||||||||||||
| export function deployEventsPath(projectId: string, opts: { group?: string; branch?: string; limit?: string; instance?: string }): string { | ||||||||||||
| return `/projects/${projectId}/deploy-events${qs({ group: opts.group, branch: opts.branch, limit: opts.limit, instance: opts.instance })}` | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // pure: render one deploy event as a log-style line. | ||||||||||||
| export function deployEventLine(ev: { ts?: string; origin?: string; type?: string; status?: string; instance?: string }): string { | ||||||||||||
| const inst = ev.instance ? ` (${ev.instance})` : '' | ||||||||||||
| return `${ev.ts ?? ''} [${ev.origin ?? ''}] ${ev.type ?? ''}: ${ev.status ?? ''}${inst}` | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // insta logs <db|compute> [group] | ||||||||||||
| export async function logs(component: string, group: string | undefined, opts: { branch?: string; limit?: string; region?: string; instance?: string; json?: boolean }): Promise<void> { | ||||||||||||
| export async function logs(component: string, group: string | undefined, opts: { branch?: string; limit?: string; region?: string; instance?: string; json?: boolean; deploy?: boolean }): Promise<void> { | ||||||||||||
| const api = await ApiClient.load() | ||||||||||||
| const p = await requireProject() | ||||||||||||
| if (opts.deploy) { | ||||||||||||
| if (component !== 'compute') return info('deploy events are only available for compute') | ||||||||||||
|
Comment on lines
+96
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: When Prompt for AI agents
Suggested change
|
||||||||||||
| const res = await api.request('GET', deployEventsPath(p.projectId, { group, branch: opts.branch ?? p.branch, limit: opts.limit, instance: opts.instance })) | ||||||||||||
| if (opts.json) return printJson(res) | ||||||||||||
| if (res.note) info(`note: ${res.note}`) | ||||||||||||
| if (!res.events?.length) return info('(no deploy events)') | ||||||||||||
| for (const ev of res.events) info(deployEventLine(ev)) | ||||||||||||
| return | ||||||||||||
| } | ||||||||||||
| const res = await api.request('GET', `/projects/${p.projectId}/logs${qs({ component, group, branch: opts.branch ?? p.branch, limit: opts.limit, region: opts.region, instance: opts.instance })}`) | ||||||||||||
| if (opts.json) return printJson(res) | ||||||||||||
| if (res.note) info(`note: ${res.note}`) | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // `insta logs --deploy` targets /deploy-events and renders each machine event as one line. | ||
| import { describe, it, expect } from 'vitest' | ||
| import { deployEventsPath, deployEventLine } from '../src/commands/metrics.js' | ||
|
|
||
| describe('deployEventsPath', () => { | ||
| it('targets /deploy-events with defined params in order', () => { | ||
| expect(deployEventsPath('p1', { group: 'api', branch: 'main', limit: '50' })) | ||
| .toBe('/projects/p1/deploy-events?group=api&branch=main&limit=50') | ||
| }) | ||
| it('omits undefined/empty params', () => { | ||
| expect(deployEventsPath('p1', {})).toBe('/projects/p1/deploy-events') | ||
| }) | ||
| }) | ||
|
|
||
| describe('deployEventLine', () => { | ||
| it('renders [origin] type: status with the instance suffix', () => { | ||
| expect(deployEventLine({ ts: 'T', origin: 'flyd', type: 'start', status: 'started', instance: 'm-1' })) | ||
| .toBe('T [flyd] start: started (m-1)') | ||
| }) | ||
| it('omits the instance suffix when absent', () => { | ||
| expect(deployEventLine({ ts: 'T', origin: 'user', type: 'launch', status: 'created' })) | ||
| .toBe('T [user] launch: created') | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Agent-facing command references remain stale: README omits
--deploy, and the requiredskills/insta/cli-reference.mdupdate is absent from this change. Document the new flag and its compute-only deploy-event behavior with the implementation.Prompt for AI agents