"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@heroku-cli/command"); const pipelines_1 = require("../../utils/pipelines"); const test_run_1 = require("../../utils/test-run"); class CiLast extends command_1.Command { async run() { const { flags } = this.parse(CiLast); const pipeline = await pipelines_1.getPipeline(flags, this); const headers = { Range: 'number ..; order=desc,max=1' }; const { body: latestTestRuns } = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs`, { headers }); const { body: testRun } = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs/${latestTestRuns[0].number}`); const { body: testNodes } = await this.heroku.get(`/test-runs/${testRun.id}/test-nodes`); await test_run_1.displayTestRunInfo(this, testRun, testNodes, flags.node); } } CiLast.description = 'looks for the most recent run and returns the output of that run'; CiLast.examples = [ `$ heroku ci:last --app murmuring-headland-14719 --node 100 `, ]; CiLast.flags = { node: command_1.flags.string({ description: 'the node number to show its setup and output', required: false }), pipeline: command_1.flags.pipeline({ required: false }) }; exports.default = CiLast;