diff --git a/lib/interface/cli/commands/agent/get.cmd.js b/lib/interface/cli/commands/agent/get.cmd.js index eafa4f6cc..e79cb39b8 100644 --- a/lib/interface/cli/commands/agent/get.cmd.js +++ b/lib/interface/cli/commands/agent/get.cmd.js @@ -3,7 +3,9 @@ const { sdk } = require('../../../../logic'); const Agent = require('../../../../logic/entities/Agent'); const Output = require('../../../../output/Output'); const _ = require('lodash'); +const colors = require('colors'); const { ignoreHttpError } = require('../../helpers/general'); +const { getTestPipelineLink, INSTALLATION_DEFAULTS } = require('../hybrid/helper'); const getRoot = require('../root/get.cmd'); @@ -38,6 +40,12 @@ const command = new Command({ }); } Output.print(_.map(agents, Agent.fromResponse)); + const pipelineLink = await getTestPipelineLink(INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, false); + if (pipelineLink) { + // eslint-disable-next-line max-len + console.log(`\nTest pipeline with the name: '${colors.cyan(INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME)}' exists for this account.` + + `\nWatch it here: ${colors.blue(pipelineLink)}`); + } }, }); diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index 72f17043e..8d6db9b30 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -11,6 +11,14 @@ const { followLogs } = require('../../helpers/logs'); const ProgressEvents = require('../../helpers/progressEvents'); const cliProgress = require('cli-progress'); +const INSTALLATION_DEFAULTS = { + NAMESPACE: 'codefresh', + MAKE_DEFAULT_RE: false, + RUN_DEMO_PIPELINE: true, + DEMO_PIPELINE_NAME: 'Codefresh-Runner Demo', + CF_CONTEXT_NAME: 'cf-runner', +}; + const defaultOpenIssueMessage = 'If you had any issues with this process please report them at: ' + `${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`; const url = _.get(sdk, 'config.context.url', 'https://g.codefresh.io'); @@ -51,6 +59,14 @@ async function createTestPipeline(runtimeName, pipelineName, pipelineCommands, p return pipeline; } +async function getTestPipelineLink(pipelineName) { + const pipelines = await sdk.pipelines.list({ id: pipelineName }); + if (_.get(pipelines, 'docs.length')) { + const pipeline = pipelines.docs[0]; + return `${url}/pipelines/edit/workflow?id=${pipeline.metadata.id}&pipeline=${encodeURI(pipeline.metadata.name)}`; + } +} + async function getTestPipeline(pipelineName) { const pipelines = await sdk.pipelines.list({ id: pipelineName }); if (_.get(pipelines, 'docs.length')) { @@ -61,6 +77,7 @@ async function getTestPipeline(pipelineName) { return pipeline; } + return null; } @@ -205,4 +222,6 @@ module.exports = { getTestPipeline, executeTestPipeline, createProgressBar, + getTestPipelineLink, + INSTALLATION_DEFAULTS, }; diff --git a/lib/interface/cli/commands/hybrid/info.cmd.js b/lib/interface/cli/commands/hybrid/info.cmd.js new file mode 100644 index 000000000..bdaf4554b --- /dev/null +++ b/lib/interface/cli/commands/hybrid/info.cmd.js @@ -0,0 +1,19 @@ +const Command = require('../../Command'); +const runnerRoot = require('../root/runner.cmd'); +const getAgents = require('../agent/get.cmd'); + + +const command = new Command({ + command: 'info', + parent: runnerRoot, + description: 'Get info on your runner installations', + webDocs: { + category: 'Runner', + title: 'Info', + }, + handler: async () => { + await getAgents.handler({}); + }, +}); + +module.exports = command; diff --git a/lib/interface/cli/commands/hybrid/init.cmd.js b/lib/interface/cli/commands/hybrid/init.cmd.js index 6a658b394..77a428625 100644 --- a/lib/interface/cli/commands/hybrid/init.cmd.js +++ b/lib/interface/cli/commands/hybrid/init.cmd.js @@ -19,15 +19,10 @@ const { getTestPipeline, createTestPipeline, executeTestPipeline, + INSTALLATION_DEFAULTS, } = require('./helper'); -const INSTALLATION_DEFAULTS = { - NAMESPACE: 'codefresh', - MAKE_DEFAULT_RE: false, - RUN_DEMO_PIPELINE: true, - DEMO_PIPELINE_NAME: 'Codefresh-Runner Demo', - CF_CONTEXT_NAME: 'cf-runner', -}; + const handleError = createErrorHandler(`\nIf you had any issues with the installation please report them at: ${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`); diff --git a/package.json b/package.json index b723b00a9..6e94639f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.64.4", + "version": "0.64.6", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,