From 97f16bcc0d2d0fa1fa7a716f8d1922b1596ce2b3 Mon Sep 17 00:00:00 2001 From: Itai Gendler Date: Mon, 15 Jan 2018 11:27:24 +0200 Subject: [PATCH] Make refactors in favor of documentation (#95) --- auto-docs/index.js | 55 +++++++++ docs-template/config.toml | 51 +++++--- docs-template/content/Installation.md | 62 ---------- docs-template/content/_header.md | 6 + .../content/{introduction.md => _index.md} | 0 .../Create authentication context.md | 19 +++ .../authentication/Get activated context.md | 8 ++ .../authentication/Get all contexts.md | 8 ++ .../authentication/Set active context.md | 13 ++ .../_index.md} | 11 +- .../content/builds/Get a single build.md | 23 ++++ .../content/builds/Restart a build.md | 18 +++ docs-template/content/builds/Show logs.md | 18 +++ .../content/builds/Terminate a build.md | 13 ++ .../builds/Wait for a build condition.md | 20 +++ docs-template/content/builds/_index.md | 3 + .../compositions/Create a composition.md | 20 +++ .../compositions/Delete a composition.md | 13 ++ .../compositions/Get a single composition.md | 13 ++ .../compositions/Replace a composition.md | 8 ++ docs-template/content/compositions/_index.md | 3 + .../content/contexts/Create a context.md | 20 +++ .../content/contexts/Delete a context.md | 13 ++ .../content/contexts/Get a single context.md | 19 +++ .../content/contexts/Replace a context.md | 8 ++ .../content/contexts/Updated a context.md | 8 ++ docs-template/content/contexts/_index.md | 3 + .../environments/Delete an environment.md | 13 ++ .../environments/Get a single composition.md | 13 ++ docs-template/content/environments/_index.md | 3 + .../content/getting-started/_index.md | 16 +++ .../getting-started/installation/_index.md | 9 ++ .../getting-started/installation/docker.md | 14 +++ .../getting-started/installation/download.md | 19 +++ .../getting-started/installation/npm.md | 19 +++ .../getting-started/installation/yarn.md | 17 +++ .../content/images/Annotate an image.md | 18 +++ .../content/images/Get a single image.md | 24 ++++ docs-template/content/images/Tag an image.md | 14 +++ docs-template/content/images/_index.md | 3 + docs-template/content/pipelines.md | 114 ------------------ .../content/pipelines/Execute a pipeline.md | 26 ++++ .../pipelines/Get a single pipeline.md | 22 ++++ .../pipelines/Update a single pipeline.md | 23 ++++ docs-template/content/pipelines/_index.md | 3 + .../Install or upgrade Helm chart.md | 20 +++ .../Test a helm release.md | 15 +++ .../content/predefined pipelines/_index.md | 3 + docs-template/content/undefined/_index.md | 3 + docs-template/content/undefined/undefined.md | 8 ++ .../layouts/partials/menu-footer.html | 13 ++ docs-template/themes/docdock | 1 + lib/interface/cli/Command.js | 109 ++++++++++++++++- .../cli/commands/auth/create-context.cmd.js | 10 +- .../cli/commands/auth/current-context.cmd.js | 10 +- .../cli/commands/auth/get-contexts.cmd.js | 10 +- lib/interface/cli/commands/auth/login.cmd.js | 56 --------- .../cli/commands/auth/use-context.cmd.js | 11 +- .../cli/commands/composition/create.cmd.js | 10 +- .../cli/commands/composition/delete.cmd.js | 10 +- .../cli/commands/composition/describe.cmd.js | 30 ----- .../cli/commands/composition/get.cmd.js | 10 +- .../cli/commands/composition/replace.cmd.js | 10 +- .../cli/commands/context/apply.cmd.js | 10 +- .../cli/commands/context/create.cmd.js | 12 +- .../cli/commands/context/delete.cmd.js | 10 +- lib/interface/cli/commands/context/get.cmd.js | 11 +- .../cli/commands/context/replace.cmd.js | 10 +- .../cli/commands/environment/delete.cmd.js | 13 +- .../cli/commands/environment/describe.cmd.js | 28 ----- .../cli/commands/environment/get.cmd.js | 12 +- .../cli/commands/image/annotate.cmd.js | 11 +- .../cli/commands/image/describe.cmd.js | 28 ----- lib/interface/cli/commands/image/get.cmd.js | 12 +- lib/interface/cli/commands/image/tag.cmd.js | 9 +- .../cli/commands/pipeline/apply.cmd.js | 27 ++--- .../cli/commands/pipeline/describe.cmd.js | 43 ------- .../pipeline/dynamic/install-chart.cmd.js | 8 +- .../pipeline/dynamic/test-release.cmd.js | 8 +- .../cli/commands/pipeline/get.cmd.js | 11 +- .../{workflow => pipeline}/run.cmd.js | 8 +- .../cli/commands/pipeline2/create.cmd.js | 11 +- .../cli/commands/pipeline2/delete.cmd.js | 10 +- .../cli/commands/pipeline2/get.cmd.js | 11 +- .../cli/commands/pipeline2/replace.cmd.js | 12 +- .../cli/commands/pipeline2/run.cmd.js | 31 ----- .../cli/commands/root/annotate.cmd.js | 4 +- lib/interface/cli/commands/root/apply.cmd.js | 8 +- lib/interface/cli/commands/root/auth.cmd.js | 4 +- lib/interface/cli/commands/root/create.cmd.js | 4 +- lib/interface/cli/commands/root/delete.cmd.js | 4 +- .../cli/commands/root/describe.cmd.js | 29 ----- lib/interface/cli/commands/root/get.cmd.js | 4 +- .../cli/commands/root/replace.cmd.js | 4 +- .../cli/commands/root/version.cmd.js | 4 +- .../cli/commands/workflow/describe.cmd.js | 27 ----- .../cli/commands/workflow/get.cmd.js | 11 +- .../cli/commands/workflow/logs.cmd.js | 8 +- .../cli/commands/workflow/restart.cmd.js | 8 +- .../cli/commands/workflow/terminate.cmd.js | 8 +- .../cli/commands/workflow/wait.cmd.js | 8 +- lib/logic/entities/Entity.js | 5 - package.json | 2 +- 103 files changed, 1078 insertions(+), 575 deletions(-) create mode 100644 auto-docs/index.js delete mode 100644 docs-template/content/Installation.md create mode 100644 docs-template/content/_header.md rename docs-template/content/{introduction.md => _index.md} (100%) create mode 100644 docs-template/content/authentication/Create authentication context.md create mode 100644 docs-template/content/authentication/Get activated context.md create mode 100644 docs-template/content/authentication/Get all contexts.md create mode 100644 docs-template/content/authentication/Set active context.md rename docs-template/content/{authentication.md => authentication/_index.md} (81%) create mode 100644 docs-template/content/builds/Get a single build.md create mode 100644 docs-template/content/builds/Restart a build.md create mode 100644 docs-template/content/builds/Show logs.md create mode 100644 docs-template/content/builds/Terminate a build.md create mode 100644 docs-template/content/builds/Wait for a build condition.md create mode 100644 docs-template/content/builds/_index.md create mode 100644 docs-template/content/compositions/Create a composition.md create mode 100644 docs-template/content/compositions/Delete a composition.md create mode 100644 docs-template/content/compositions/Get a single composition.md create mode 100644 docs-template/content/compositions/Replace a composition.md create mode 100644 docs-template/content/compositions/_index.md create mode 100644 docs-template/content/contexts/Create a context.md create mode 100644 docs-template/content/contexts/Delete a context.md create mode 100644 docs-template/content/contexts/Get a single context.md create mode 100644 docs-template/content/contexts/Replace a context.md create mode 100644 docs-template/content/contexts/Updated a context.md create mode 100644 docs-template/content/contexts/_index.md create mode 100644 docs-template/content/environments/Delete an environment.md create mode 100644 docs-template/content/environments/Get a single composition.md create mode 100644 docs-template/content/environments/_index.md create mode 100644 docs-template/content/getting-started/_index.md create mode 100644 docs-template/content/getting-started/installation/_index.md create mode 100644 docs-template/content/getting-started/installation/docker.md create mode 100644 docs-template/content/getting-started/installation/download.md create mode 100644 docs-template/content/getting-started/installation/npm.md create mode 100644 docs-template/content/getting-started/installation/yarn.md create mode 100644 docs-template/content/images/Annotate an image.md create mode 100644 docs-template/content/images/Get a single image.md create mode 100644 docs-template/content/images/Tag an image.md create mode 100644 docs-template/content/images/_index.md delete mode 100644 docs-template/content/pipelines.md create mode 100644 docs-template/content/pipelines/Execute a pipeline.md create mode 100644 docs-template/content/pipelines/Get a single pipeline.md create mode 100644 docs-template/content/pipelines/Update a single pipeline.md create mode 100644 docs-template/content/pipelines/_index.md create mode 100644 docs-template/content/predefined pipelines/Install or upgrade Helm chart.md create mode 100644 docs-template/content/predefined pipelines/Test a helm release.md create mode 100644 docs-template/content/predefined pipelines/_index.md create mode 100644 docs-template/content/undefined/_index.md create mode 100644 docs-template/content/undefined/undefined.md create mode 100644 docs-template/layouts/partials/menu-footer.html create mode 160000 docs-template/themes/docdock delete mode 100644 lib/interface/cli/commands/auth/login.cmd.js delete mode 100644 lib/interface/cli/commands/composition/describe.cmd.js delete mode 100644 lib/interface/cli/commands/environment/describe.cmd.js delete mode 100644 lib/interface/cli/commands/image/describe.cmd.js delete mode 100644 lib/interface/cli/commands/pipeline/describe.cmd.js rename lib/interface/cli/commands/{workflow => pipeline}/run.cmd.js (94%) delete mode 100644 lib/interface/cli/commands/pipeline2/run.cmd.js delete mode 100644 lib/interface/cli/commands/root/describe.cmd.js delete mode 100644 lib/interface/cli/commands/workflow/describe.cmd.js diff --git a/auto-docs/index.js b/auto-docs/index.js new file mode 100644 index 000000000..1d662dc9a --- /dev/null +++ b/auto-docs/index.js @@ -0,0 +1,55 @@ +const fs = require('fs'); +const recursive = require('recursive-readdir'); +const path = require('path'); +const _ = require('lodash'); + + +recursive(path.resolve(__dirname, '../lib/interface/cli/commands'), (err, files) => { + + _.forEach(files, (file) => { + if (!file.endsWith('.cmd.js')) { + return; + } + + console.log(file); + const command = require(file); + + // dont document beta commands currently + if (command.isBetaCommand()) { + return; + } + + const docs = command.prepareDocs(); + + const { category } = docs; + + // create a directory according to the category + const dir = path.resolve(__dirname, `../docs-template/content/${(category || 'undefined').toLowerCase()}`); + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + + // create _index.md file if does not exist for the category + const indexFile = path.resolve(dir, '_index.md'); + if (!fs.existsSync(indexFile)){ + fs.writeFileSync(indexFile, `+++\ntitle = "${category}"\n+++`); + } + + let finalFileString = ''; + + finalFileString += `${docs.header}\n\n`; + finalFileString += `### Command\n\`${docs.command}\`\n\n`; + finalFileString += `${docs.description}\n`; + + if (docs.positionals.length) { + finalFileString += `### Positionals\n\nOption | Default | Description\n--------- | ----------- | -----------\n${docs.positionals}`; + } + + if (docs.options.length) { + finalFileString += `### Options\n\nOption | Default | Description\n--------- | ----------- | -----------\n${docs.options}`; + } + + + fs.writeFileSync(path.resolve(dir, `./${docs.title}.md`), finalFileString); + }); +}); diff --git a/docs-template/config.toml b/docs-template/config.toml index b887c079b..b6bf0d1ad 100644 --- a/docs-template/config.toml +++ b/docs-template/config.toml @@ -1,29 +1,44 @@ -theme = "docuapi" +theme = "docdock" baseurl = "http://cli.codefresh.io" title = "Codefresh CLI Documentation" publishDir = "../docs" languageCode = "en-us" +DefaultContentLanguage = "en" -# Code higlighting settings -pygmentsCodefences = true -pygmentsCodeFencesGuesSsyntax = false -pygmentsOptions = "" -pygmentsStyle = "monokai" -# The monokai stylesheet is included in the base template. -pygmentsUseClasses = true +pygmentsCodeFences = true +pygmentsStyle = "monokailight" [params] -search = true +editURL = "https://github.com/vjeantet/hugo-theme-docdock/edit/master/exampleSite/content/" +showVisitedLinks = true # default is false +themeStyle = "original" # "original" or "flex" # default "original" +themeVariant = "" # choose theme variant "green", "gold" , "gray", "blue" (default) +ordersectionsby = "weight" # ordersectionsby = "title" +disableHomeIcon = false # default is false +disableSearch = false # default is false +disableNavChevron = false # set true to hide next/prev chevron, default is false +highlightClientSide = false # set true to use highlight.pack.js instead of the default hugo chroma highlighter -# Configure the language example tabs. -[[params.language_tabs]] -key = "cli" -name = "Cli" -#Languages -[languages] +[outputs] +home = [ "HTML", "RSS", "JSON"] -[languages.en] -languageName = "English" -weight = 2 + +[[menu.shortcuts]] +pre = "

More

" +name = " Github repo" +identifier = "ds" +url = "https://github.com/codefresh-io/cli" +weight = 10 + +[[menu.shortcuts]] +name = " Examples" +url = "/Examples" +weight = 11 + +[[menu.shortcuts]] +name = " Codefresh Documentation" +identifier = "hugodoc" +url = "https://docs.codefresh.io" +weight = 20 diff --git a/docs-template/content/Installation.md b/docs-template/content/Installation.md deleted file mode 100644 index 83fe71a2f..000000000 --- a/docs-template/content/Installation.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -weight: 20 -title: Installation ---- - -# Installation -Codefresh CLI is developed and built with node.js. -In case you have node.js installed on your machine you can use npm or yarn to install it.
-If you don't have node.js installed you can install the CLI by downloading a binary. - -## NPM -Codefresh's cli is available for installation through NPM registry. - -Install: -`npm install -g codefresh` - -Install a specific version: -`npm install -g codefresh@{VERSION}` - -Update to latest version: -`npm install -g codefresh` - -Update to a specific version: -`npm install -g codefresh@${VERSION}` - -## YARN -Install: -`yarn global add codefresh` - -Install a specific version: -`yarn global add codefresh@{VERSION}` - -Update to latest version: -`yarn global upgrade codefresh` - -Update to a specific version: -`yarn global upgrade codefresh@{VERSION}` - -## Binaries -Navigate to Official Releases -and download the binary that matches your operating system.
-We currently support the following OS:
- - -After downloading the binary, untar or unzip it and your are good to go.
-You can also add the binary to your system PATH environment variable so you can use it easily. - -If your operating system is missing please feel free to open us an issue in our Github repository. - -## Docker image -You can run the CLI using our official docker image which is published to Dockerhub
- -Pull the latest version: -`docker pull codefresh/cli` - -Pull a specific version: -`docker pull codefresh/cli:${VERSION}` - diff --git a/docs-template/content/_header.md b/docs-template/content/_header.md new file mode 100644 index 000000000..68a7d8850 --- /dev/null +++ b/docs-template/content/_header.md @@ -0,0 +1,6 @@ ++++ +title = "header" +description = "" +date = "2017-04-24T18:36:24+02:00" ++++ +Codefresh CLI Documentation diff --git a/docs-template/content/introduction.md b/docs-template/content/_index.md similarity index 100% rename from docs-template/content/introduction.md rename to docs-template/content/_index.md diff --git a/docs-template/content/authentication/Create authentication context.md b/docs-template/content/authentication/Create authentication context.md new file mode 100644 index 000000000..aa6221d2b --- /dev/null +++ b/docs-template/content/authentication/Create authentication context.md @@ -0,0 +1,19 @@ ++++ +title = "Create authentication context" ++++ + +### Command +`codefresh auth create-context [name]` + +Create or update an authentication context +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +name | default | Context name +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--url | https://g.codefresh.io | Codefresh system custom url +--api-key | | API key diff --git a/docs-template/content/authentication/Get activated context.md b/docs-template/content/authentication/Get activated context.md new file mode 100644 index 000000000..a2e6fbbb0 --- /dev/null +++ b/docs-template/content/authentication/Get activated context.md @@ -0,0 +1,8 @@ ++++ +title = "Get activated context" ++++ + +### Command +`codefresh auth current-context` + +Get the current activated authentication context diff --git a/docs-template/content/authentication/Get all contexts.md b/docs-template/content/authentication/Get all contexts.md new file mode 100644 index 000000000..b0610d3a6 --- /dev/null +++ b/docs-template/content/authentication/Get all contexts.md @@ -0,0 +1,8 @@ ++++ +title = "Get all contexts" ++++ + +### Command +`codefresh auth get-contexts` + +Get all possible authentication contexts diff --git a/docs-template/content/authentication/Set active context.md b/docs-template/content/authentication/Set active context.md new file mode 100644 index 000000000..63b40ca28 --- /dev/null +++ b/docs-template/content/authentication/Set active context.md @@ -0,0 +1,13 @@ ++++ +title = "Set active context" ++++ + +### Command +`codefresh auth use-context ` + +Set the current active authentication context +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +context-name | | a context-name that exists in cfconfig file diff --git a/docs-template/content/authentication.md b/docs-template/content/authentication/_index.md similarity index 81% rename from docs-template/content/authentication.md rename to docs-template/content/authentication/_index.md index ce38cf551..136f0ff70 100644 --- a/docs-template/content/authentication.md +++ b/docs-template/content/authentication/_index.md @@ -1,9 +1,8 @@ ---- -weight: 30 -title: Authentication ---- - -# Authentication ++++ +title = "Authentication" +description = "asd" +date = "2017-04-24T18:36:24+02:00" ++++ ## Basic Usage In order to start working with the cli you will need to update the authentication configuration.
diff --git a/docs-template/content/builds/Get a single build.md b/docs-template/content/builds/Get a single build.md new file mode 100644 index 000000000..32e726eab --- /dev/null +++ b/docs-template/content/builds/Get a single build.md @@ -0,0 +1,23 @@ ++++ +title = "Get a single build" ++++ + +### Command +`codefresh get builds [id]` + +Get a specific builds or an array of builds +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Build id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--limit | 25 | Limit amount of returned results +--page | 1 | Paginated page +--status | | Filter results by statuses +--trigger | | Filter results by triggers +--pipeline-id | | Filter results by pipeline id +--pipeline-name | | Filter results by pipeline name diff --git a/docs-template/content/builds/Restart a build.md b/docs-template/content/builds/Restart a build.md new file mode 100644 index 000000000..62668be80 --- /dev/null +++ b/docs-template/content/builds/Restart a build.md @@ -0,0 +1,18 @@ ++++ +title = "Restart a build" ++++ + +### Command +`codefresh restart ` + +Restart a build by its id +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Build id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--detach | | Run build and print workflow ID diff --git a/docs-template/content/builds/Show logs.md b/docs-template/content/builds/Show logs.md new file mode 100644 index 000000000..0a01efe4c --- /dev/null +++ b/docs-template/content/builds/Show logs.md @@ -0,0 +1,18 @@ ++++ +title = "Show logs" ++++ + +### Command +`codefresh logs ` + +Show logs of a build +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Pipeline id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--f | | Continue showing build logs until it will finish diff --git a/docs-template/content/builds/Terminate a build.md b/docs-template/content/builds/Terminate a build.md new file mode 100644 index 000000000..addcb350f --- /dev/null +++ b/docs-template/content/builds/Terminate a build.md @@ -0,0 +1,13 @@ ++++ +title = "Terminate a build" ++++ + +### Command +`codefresh terminate ` + +Terminate a build by its id +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Build id diff --git a/docs-template/content/builds/Wait for a build condition.md b/docs-template/content/builds/Wait for a build condition.md new file mode 100644 index 000000000..d09448356 --- /dev/null +++ b/docs-template/content/builds/Wait for a build condition.md @@ -0,0 +1,20 @@ ++++ +title = "Wait for a build condition" ++++ + +### Command +`codefresh wait ` + +Wait until a condition will be met on a build +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Build id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--status | | Build status +--debug | | Show debug output until the condition will be met +--timeout | 30 | Define a timeout for the wait operation in minutes diff --git a/docs-template/content/builds/_index.md b/docs-template/content/builds/_index.md new file mode 100644 index 000000000..0f58369c6 --- /dev/null +++ b/docs-template/content/builds/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Builds" ++++ \ No newline at end of file diff --git a/docs-template/content/compositions/Create a composition.md b/docs-template/content/compositions/Create a composition.md new file mode 100644 index 000000000..ca361c89d --- /dev/null +++ b/docs-template/content/compositions/Create a composition.md @@ -0,0 +1,20 @@ ++++ +title = "Create a composition" ++++ + +### Command +`codefresh create composition [name]` + +Create a composition +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +name | | Name of composition +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--variable | | Variables list +--advanced | | Advanced composition +--yaml | | Path to yaml file to use to create the resource diff --git a/docs-template/content/compositions/Delete a composition.md b/docs-template/content/compositions/Delete a composition.md new file mode 100644 index 000000000..f02a89c19 --- /dev/null +++ b/docs-template/content/compositions/Delete a composition.md @@ -0,0 +1,13 @@ ++++ +title = "Delete a composition" ++++ + +### Command +`codefresh delete composition [name]` + +Delete a composition +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +name | | Composition name diff --git a/docs-template/content/compositions/Get a single composition.md b/docs-template/content/compositions/Get a single composition.md new file mode 100644 index 000000000..47b92604a --- /dev/null +++ b/docs-template/content/compositions/Get a single composition.md @@ -0,0 +1,13 @@ ++++ +title = "Get a single composition" ++++ + +### Command +`codefresh get compositions [id|name]` + +Get a specific composition or an array of compositions +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | composition id or name diff --git a/docs-template/content/compositions/Replace a composition.md b/docs-template/content/compositions/Replace a composition.md new file mode 100644 index 000000000..b028a65cd --- /dev/null +++ b/docs-template/content/compositions/Replace a composition.md @@ -0,0 +1,8 @@ ++++ +title = "Replace a composition" ++++ + +### Command +`codefresh replace composition` + +Replace a composition resource diff --git a/docs-template/content/compositions/_index.md b/docs-template/content/compositions/_index.md new file mode 100644 index 000000000..3e54b16ea --- /dev/null +++ b/docs-template/content/compositions/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Compositions" ++++ \ No newline at end of file diff --git a/docs-template/content/contexts/Create a context.md b/docs-template/content/contexts/Create a context.md new file mode 100644 index 000000000..54d6aa37a --- /dev/null +++ b/docs-template/content/contexts/Create a context.md @@ -0,0 +1,20 @@ ++++ +title = "Create a context" ++++ + +### Command +`codefresh create context [type] [name]` + +Create a context +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +name | | Name of context +type | | Type of the context +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--owner | account | Owner of the context +--variable | | Variables list diff --git a/docs-template/content/contexts/Delete a context.md b/docs-template/content/contexts/Delete a context.md new file mode 100644 index 000000000..3219b339a --- /dev/null +++ b/docs-template/content/contexts/Delete a context.md @@ -0,0 +1,13 @@ ++++ +title = "Delete a context" ++++ + +### Command +`codefresh delete context [name]` + +Delete a context +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +name | | Name of context diff --git a/docs-template/content/contexts/Get a single context.md b/docs-template/content/contexts/Get a single context.md new file mode 100644 index 000000000..cbed50153 --- /dev/null +++ b/docs-template/content/contexts/Get a single context.md @@ -0,0 +1,19 @@ ++++ +title = "Get a single context" ++++ + +### Command +`codefresh get contexts [name]` + +Get a specific or an array of contexts +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +name | | context name +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--type | | Specific type of context +--owner | | Owner of the context diff --git a/docs-template/content/contexts/Replace a context.md b/docs-template/content/contexts/Replace a context.md new file mode 100644 index 000000000..8173e4066 --- /dev/null +++ b/docs-template/content/contexts/Replace a context.md @@ -0,0 +1,8 @@ ++++ +title = "Replace a context" ++++ + +### Command +`codefresh replace context` + +Replace a context diff --git a/docs-template/content/contexts/Updated a context.md b/docs-template/content/contexts/Updated a context.md new file mode 100644 index 000000000..be926d12f --- /dev/null +++ b/docs-template/content/contexts/Updated a context.md @@ -0,0 +1,8 @@ ++++ +title = "Updated a context" ++++ + +### Command +`codefresh patch context` + +Apply changes to a context diff --git a/docs-template/content/contexts/_index.md b/docs-template/content/contexts/_index.md new file mode 100644 index 000000000..aeeab80a2 --- /dev/null +++ b/docs-template/content/contexts/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Contexts" ++++ \ No newline at end of file diff --git a/docs-template/content/environments/Delete an environment.md b/docs-template/content/environments/Delete an environment.md new file mode 100644 index 000000000..383fe996f --- /dev/null +++ b/docs-template/content/environments/Delete an environment.md @@ -0,0 +1,13 @@ ++++ +title = "Delete an environment" ++++ + +### Command +`codefresh delete environment ` + +Delete an environment +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Environment id diff --git a/docs-template/content/environments/Get a single composition.md b/docs-template/content/environments/Get a single composition.md new file mode 100644 index 000000000..29df348c5 --- /dev/null +++ b/docs-template/content/environments/Get a single composition.md @@ -0,0 +1,13 @@ ++++ +title = "Get a single composition" ++++ + +### Command +`codefresh get environments [id]` + +Get a specific or an array of environments +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | environment id or name diff --git a/docs-template/content/environments/_index.md b/docs-template/content/environments/_index.md new file mode 100644 index 000000000..8cd641e3a --- /dev/null +++ b/docs-template/content/environments/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Environments" ++++ \ No newline at end of file diff --git a/docs-template/content/getting-started/_index.md b/docs-template/content/getting-started/_index.md new file mode 100644 index 000000000..a95cfc7a9 --- /dev/null +++ b/docs-template/content/getting-started/_index.md @@ -0,0 +1,16 @@ ++++ +title = "Getting Started" +description = "" +date = "2017-04-24T18:36:24+02:00" +weight = 1 ++++ + +Welcome to Codefresh's official CLI documentation! + +Codefresh CLI provides a full and flexible interface to interact with Codefresh.
+The CLI can be used to achieve the following: +
    +
  • Perform any opeartion you would be able to do through the UI
  • +
  • Create complex automations from your local machine
  • +
  • Run complex pipeline use cases by using the CLI inside your pipeline steps
  • +
diff --git a/docs-template/content/getting-started/installation/_index.md b/docs-template/content/getting-started/installation/_index.md new file mode 100644 index 000000000..8c95f4633 --- /dev/null +++ b/docs-template/content/getting-started/installation/_index.md @@ -0,0 +1,9 @@ ++++ +title = "Installation" +description = "" +date = "2017-04-24T18:36:24+02:00" ++++ + +Codefresh CLI is developed and built with node.js. +In case you have node.js installed on your machine you can use npm or yarn to install it.
+If you don't have node.js installed you can install the CLI by downloading a binary. diff --git a/docs-template/content/getting-started/installation/docker.md b/docs-template/content/getting-started/installation/docker.md new file mode 100644 index 000000000..87d1b0d17 --- /dev/null +++ b/docs-template/content/getting-started/installation/docker.md @@ -0,0 +1,14 @@ ++++ +title = "Docker Image" +description = "" +date = "2017-04-24T18:36:24+02:00" ++++ + +You can run the CLI using our official docker image which is published to Dockerhub
+ +Pull the latest version: +`docker pull codefresh/cli` + +Pull a specific version: +`docker pull codefresh/cli:${VERSION}` + diff --git a/docs-template/content/getting-started/installation/download.md b/docs-template/content/getting-started/installation/download.md new file mode 100644 index 000000000..f5fb38331 --- /dev/null +++ b/docs-template/content/getting-started/installation/download.md @@ -0,0 +1,19 @@ ++++ +title = "Download" +description = "" +date = "2017-04-24T18:36:24+02:00" ++++ + +Navigate to Official Releases +and download the binary that matches your operating system.
+We currently support the following OS:
+ + +After downloading the binary, untar or unzip it and your are good to go.
+You can also add the binary to your system PATH environment variable so you can use it easily. + +If your operating system is missing please feel free to open us an issue in our Github repository. diff --git a/docs-template/content/getting-started/installation/npm.md b/docs-template/content/getting-started/installation/npm.md new file mode 100644 index 000000000..00ccc35d8 --- /dev/null +++ b/docs-template/content/getting-started/installation/npm.md @@ -0,0 +1,19 @@ ++++ +title = "NPM" +description = "" +date = "2017-04-24T18:36:24+02:00" ++++ + +Codefresh's cli is available for installation through NPM registry. + +Install: +`npm install -g codefresh` + +Install a specific version: +`npm install -g codefresh@{VERSION}` + +Update to latest version: +`npm install -g codefresh` + +Update to a specific version: +`npm install -g codefresh@${VERSION}` diff --git a/docs-template/content/getting-started/installation/yarn.md b/docs-template/content/getting-started/installation/yarn.md new file mode 100644 index 000000000..909662370 --- /dev/null +++ b/docs-template/content/getting-started/installation/yarn.md @@ -0,0 +1,17 @@ ++++ +title = "YARN" +description = "" +date = "2017-04-24T18:36:24+02:00" ++++ + +Install: +`yarn global add codefresh` + +Install a specific version: +`yarn global add codefresh@{VERSION}` + +Update to latest version: +`yarn global upgrade codefresh` + +Update to a specific version: +`yarn global upgrade codefresh@{VERSION}` diff --git a/docs-template/content/images/Annotate an image.md b/docs-template/content/images/Annotate an image.md new file mode 100644 index 000000000..1564ec32e --- /dev/null +++ b/docs-template/content/images/Annotate an image.md @@ -0,0 +1,18 @@ ++++ +title = "Annotate an image" ++++ + +### Command +`codefresh annotate image ` + +Annotate an image +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Docker image full name or id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--label | | annotations to add to the image diff --git a/docs-template/content/images/Get a single image.md b/docs-template/content/images/Get a single image.md new file mode 100644 index 000000000..5d73ece7a --- /dev/null +++ b/docs-template/content/images/Get a single image.md @@ -0,0 +1,24 @@ ++++ +title = "Get a single image" ++++ + +### Command +`codefresh get images [id]` + +Get a specific or an array of images +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | image id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--limit | 25 | Limit amount of returned results +--all | | Return images from all possible registries (by default only r.cfcr.io images will be returned) +--label | | Filter by a list of annotated labels +--sha | | Filter by specific commit sha +--image-name | | Filter by specific image name +--branch | | Filter by specific branch +--page | 1 | Paginated page diff --git a/docs-template/content/images/Tag an image.md b/docs-template/content/images/Tag an image.md new file mode 100644 index 000000000..750aa56ba --- /dev/null +++ b/docs-template/content/images/Tag an image.md @@ -0,0 +1,14 @@ ++++ +title = "Tag an image" ++++ + +### Command +`codefresh tag [tags..]` + +Add an image tag +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Docker image id +names | | Tag names diff --git a/docs-template/content/images/_index.md b/docs-template/content/images/_index.md new file mode 100644 index 000000000..8f85710cb --- /dev/null +++ b/docs-template/content/images/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Images" ++++ \ No newline at end of file diff --git a/docs-template/content/pipelines.md b/docs-template/content/pipelines.md deleted file mode 100644 index 3ff74f486..000000000 --- a/docs-template/content/pipelines.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -weight: 40 -title: Pipelines ---- - -# Pipelines - -## Get All Pipelines - -```cli -$ codefresh get pipelines -``` - -```string -ID NAME REPOOWNER REPONAME -55fa65a21058fb6778dc5eef codefresh-io codefresh-io codefresh-io -55fa65a21058fb6778dc5f19 repo-analyser verchol repo-analyser -55fa65a21058fb6778dc5f4f engine codefresh-io engine -55fa65a21058fb6778dc5f55 git-clone codefresh-io cf-base-images -``` - -```cli -$ codefresh get pipelines --name engine -``` - -```string -ID NAME REPOOWNER REPONAME -55fa65a21058fb6778dc5f4f engine codefresh-io engine -``` - -```cli -$ codefresh get pipelines --repo-name repo-analyser -``` - -```string -ID NAME REPOOWNER REPONAME -55fa65a21058fb6778dc5f19 repo-analyser verchol repo-analyser -``` - -```cli -$ codefresh get pipelines --repo-owner codefresh-io -``` - -```string -ID NAME REPOOWNER REPONAME -55fa65a21058fb6778dc5eef codefresh-io codefresh-io codefresh-io -55fa65a21058fb6778dc5f4f engine codefresh-io engine -55fa65a21058fb6778dc5f55 git-clone codefresh-io cf-base-images -``` - -This command will retrieve an array of pipelines according to the passed filters. - -### Command - -`codefresh get pipelines`
- -### Aliases - -
    -
  • pipeline
  • -
  • pip
  • -
- -### Filter Options - -Option | Default | Description ---------- | ----------- | ----------- ---repo-owner | | Filter pipelines by repository owner. ---repo-name | | Filter pipelines by repository name. ---name | | Filter pipelines by pipeline name. - -### Output Options - -Option | Default | Description ---------- | ----------- | ----------- ---output | | Output format [choices: "json", "yaml", "wide", "name"]. ---watch | false | If set to true, the output will continue to get updated. ---watch-interval | 3 | Interval time to get updates from the server. ---limit | 25 | Limit amount of returned results. ---page | 1 | Get a specific set of results according to the defined limit option. - - -## Get a Single Pipeline - -```cli -$ codefresh get pipeline 55fa65a21058fb6778dc5eef -``` - -> The above command returns a structured table like this: - -```string -ID NAME REPOOWNER REPONAME -55fa65a21058fb6778dc5eef codefresh-io codefresh-io codefresh-io -``` - -This command will retrieve a single pipeline. - -### Command - -`codefresh get pipeline {ID}` - -### Positionals arguments - -Argument | Description ---------- | ----------- -id | Pipeline id. - -### Output Options - -Option | Default | Description ---------- | ----------- | ----------- ---output | | Output format [choices: "json", "yaml", "wide", "name"]. ---watch | false | If set to true, the output will continue to get updated. ---watch-interval | 3 | Interval time to get updates from the server. diff --git a/docs-template/content/pipelines/Execute a pipeline.md b/docs-template/content/pipelines/Execute a pipeline.md new file mode 100644 index 000000000..d523fa2c5 --- /dev/null +++ b/docs-template/content/pipelines/Execute a pipeline.md @@ -0,0 +1,26 @@ ++++ +title = "Execute a pipeline" ++++ + +### Command +`codefresh run ` + +Run a pipeline and attach the created workflow logs. +Returns an exist code according to the workflow finish status (Success: 0, Error: 1, Terminated: 2). +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Pipeline id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--branch | | Branch +--sha | | Set commit sha +--no-cache | | Ignore cached images +--reset-volume | | Reset pipeline cached volume +--variable | | Set build variables +--scale | 1 | todo +--detach | | Run pipeline and print build ID +--variable-file | | Set build variables from a file diff --git a/docs-template/content/pipelines/Get a single pipeline.md b/docs-template/content/pipelines/Get a single pipeline.md new file mode 100644 index 000000000..3caa4c3d3 --- /dev/null +++ b/docs-template/content/pipelines/Get a single pipeline.md @@ -0,0 +1,22 @@ ++++ +title = "Get a single pipeline" ++++ + +### Command +`codefresh get pipelines [id]` + +Get a specific or an array of pipelines +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | Pipeline id +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--repo-owner | | Repository owner +--repo-name | | Repository name +--limit | 25 | Limit amount of returned results +--page | 1 | Paginated page +--name | | Filter results by pipeline name diff --git a/docs-template/content/pipelines/Update a single pipeline.md b/docs-template/content/pipelines/Update a single pipeline.md new file mode 100644 index 000000000..e98d45b07 --- /dev/null +++ b/docs-template/content/pipelines/Update a single pipeline.md @@ -0,0 +1,23 @@ ++++ +title = "Update a single pipeline" ++++ + +### Command +`codefresh patch pipeline ` + +Apply changes to a pipeline +### Positionals + +Option | Default | Description +--------- | ----------- | ----------- +id | | pipeline id +repo-owner | | repository owner +repo-name | | repository name +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--context | | context in form of: type=name +--engine-cluster | | K8 cluster name to use for execution +--engine-namespace | | K8 namespace in the chosen cluster to use for execution +--default-engine | | Use the default engine configured by the system diff --git a/docs-template/content/pipelines/_index.md b/docs-template/content/pipelines/_index.md new file mode 100644 index 000000000..6eb64f4b7 --- /dev/null +++ b/docs-template/content/pipelines/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Pipelines" ++++ \ No newline at end of file diff --git a/docs-template/content/predefined pipelines/Install or upgrade Helm chart.md b/docs-template/content/predefined pipelines/Install or upgrade Helm chart.md new file mode 100644 index 000000000..9878b906c --- /dev/null +++ b/docs-template/content/predefined pipelines/Install or upgrade Helm chart.md @@ -0,0 +1,20 @@ ++++ +title = "Install or upgrade Helm chart" ++++ + +### Command +`codefresh install-chart` + +Install or upgrade Helm chart +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--cluster | | Install on cluster +--namespace | default | Install on namespace +--tiller-namespace | kube-system | Where tiller has been installed +--repository | | Helm repository +--name | | Name of the chart in the repository +--version | | Version of the chart in the repository +--context | | Contexts (yaml || secret-yaml) to be passed to the install +--release-name | | The name to set to the release diff --git a/docs-template/content/predefined pipelines/Test a helm release.md b/docs-template/content/predefined pipelines/Test a helm release.md new file mode 100644 index 000000000..f04156871 --- /dev/null +++ b/docs-template/content/predefined pipelines/Test a helm release.md @@ -0,0 +1,15 @@ ++++ +title = "Test a helm release" ++++ + +### Command +`codefresh test-release [name]` + +Test a helm release +### Options + +Option | Default | Description +--------- | ----------- | ----------- +--cluster | | Install on cluster +--timeout | 300 | time in seconds to wait for any individual kubernetes operation (like Jobs for hooks) (default 300) +--cleanup | false | delete test pods upon completion (default false) diff --git a/docs-template/content/predefined pipelines/_index.md b/docs-template/content/predefined pipelines/_index.md new file mode 100644 index 000000000..683bb388b --- /dev/null +++ b/docs-template/content/predefined pipelines/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Predefined Pipelines" ++++ \ No newline at end of file diff --git a/docs-template/content/undefined/_index.md b/docs-template/content/undefined/_index.md new file mode 100644 index 000000000..4792ef1c2 --- /dev/null +++ b/docs-template/content/undefined/_index.md @@ -0,0 +1,3 @@ ++++ +title = "undefined" ++++ \ No newline at end of file diff --git a/docs-template/content/undefined/undefined.md b/docs-template/content/undefined/undefined.md new file mode 100644 index 000000000..27c734398 --- /dev/null +++ b/docs-template/content/undefined/undefined.md @@ -0,0 +1,8 @@ ++++ +title = "undefined" ++++ + +### Command +`codefresh version` + +Print version diff --git a/docs-template/layouts/partials/menu-footer.html b/docs-template/layouts/partials/menu-footer.html new file mode 100644 index 000000000..00243610a --- /dev/null +++ b/docs-template/layouts/partials/menu-footer.html @@ -0,0 +1,13 @@ +
+ +Download + + +Star + + +Fork + +
+ + diff --git a/docs-template/themes/docdock b/docs-template/themes/docdock new file mode 160000 index 000000000..5f4eab71c --- /dev/null +++ b/docs-template/themes/docdock @@ -0,0 +1 @@ +Subproject commit 5f4eab71c2452722ffba4af05f98d912bcb41451 diff --git a/lib/interface/cli/Command.js b/lib/interface/cli/Command.js index 44db4edf1..396cb67b6 100644 --- a/lib/interface/cli/Command.js +++ b/lib/interface/cli/Command.js @@ -13,8 +13,13 @@ class Command { this.requiresAuthentication = command.requiresAuthentication; } this.betaCommand = command.betaCommand || false; - this.command = command; + this.rawCommand = command; + this.yargsCommand = this.prepareYargsCommand(); + this.subCommands = []; + if (command.parent) { + this.setParentCommand(command.parent); + } this.builders = []; (_.isUndefined(command.handler)) ? command.handler = (args) => { printError(`Error: unknown command "${args._[args._.length - 1]}"\n` + @@ -26,6 +31,96 @@ class Command { } + prepareDocs(parentCommandExists) { + const command = this.rawCommand; + + const Mock = function () { + this.positionals = []; + this.options = []; + this.positional = (key, value) => { + this.positionals.push({ + key, + value + }); + return this; + }; + this.option = (key, value) => { + this.options.push({ + key, + value, + }); + return this; + }; + + for (var property in yargs) { + if (yargs.hasOwnProperty(property)) { + if (typeof yargs[property] === 'function' && !this[property]) { + this[property] = () => { + return this; + }; + } + } + } + }; + + const mock = new Mock(); + + const res = {}; + + const { options, positionals } = command.builder(mock); + + let parentCommandDocs; + if (this.getParentCommand()) { + parentCommandDocs = this.getParentCommand() + .prepareDocs(true); + } + + res.command = command.command; + if (parentCommandDocs) { + res.command = `codefresh ${parentCommandDocs.command} ${res.command}`; + } else if (!parentCommandExists) { + res.command = `codefresh ${res.command}`; + } + + const webDocs = _.get(command, 'webDocs', {}); + const cliDocs = _.get(command, 'cliDocs', {}); + res.description = webDocs.description || cliDocs.description || ''; + res.title = webDocs.title; + res.category = webDocs.category; + res.header = `+++\ntitle = "${res.title}"\n+++`; + + res.positionals = ''; + _.forEach(positionals, (positional) => { + const key = positional.key; + const description = positional.value.describe || positional.value.description; + const defaultValue = positional.value.default || ''; + res.positionals += `${key} | ${defaultValue} | ${description}\n`; + }); + + res.options = ''; + _.forEach(options, (option) => { + const key = option.key; + const description = option.value.describe || option.value.description; + const defaultValue = option.value.default || ''; + res.options += `--${key} | ${defaultValue} | ${description}\n`; + }); + + return res; + } + + prepareYargsCommand() { + const command = this.rawCommand; + const res = { + handler: command.handler, + builder: command.builder, + command: command.command, + aliases: command.aliases, + description: _.get(command, 'cliDocs.description', command.description), + }; + + return res; + } + isRoot() { return this.root; } @@ -43,8 +138,18 @@ class Command { return this; } + setParentCommand(parentCommand) { + this.parentCommand = parentCommand; + this.parentCommand.subCommand(this); + return this; + } + + getParentCommand() { + return this.parentCommand; + } + toCommand() { - let command = this.command; + let command = this.yargsCommand; let funcs = _.map(this.builders, (b) => { return (yargs) => { diff --git a/lib/interface/cli/commands/auth/create-context.cmd.js b/lib/interface/cli/commands/auth/create-context.cmd.js index f1659f37c..2f7162ecd 100644 --- a/lib/interface/cli/commands/auth/create-context.cmd.js +++ b/lib/interface/cli/commands/auth/create-context.cmd.js @@ -31,7 +31,14 @@ const _loginWithToken = async (url, token) => { const command = new Command({ command: 'create-context [name]', - description: 'create-context', + parent: authRoot, + cliDocs: { + description: 'Create or update an authentication context', + }, + webDocs: { + category: 'Authentication', + title: 'Create authentication context', + }, builder: (yargs) => { return yargs .usage('Create a new authentication context using an API key') @@ -75,6 +82,5 @@ const command = new Command({ console.log(`Switched to context: ${authContext.name}`); }, }); -authRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/auth/current-context.cmd.js b/lib/interface/cli/commands/auth/current-context.cmd.js index 6b36dfd6a..e2eae8be8 100644 --- a/lib/interface/cli/commands/auth/current-context.cmd.js +++ b/lib/interface/cli/commands/auth/current-context.cmd.js @@ -8,7 +8,14 @@ const authRoot = require('../root/auth.cmd'); const command = new Command({ command: 'current-context', - description: 'current-context', + parent: authRoot, + cliDocs: { + description: 'Get the current activated authentication context', + }, + webDocs: { + category: 'Authentication', + title: 'Get activated context', + }, builder: (yargs) => { return yargs; }, @@ -21,6 +28,5 @@ const command = new Command({ } }, }); -authRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/auth/get-contexts.cmd.js b/lib/interface/cli/commands/auth/get-contexts.cmd.js index cbebef3d4..fe5f215ba 100644 --- a/lib/interface/cli/commands/auth/get-contexts.cmd.js +++ b/lib/interface/cli/commands/auth/get-contexts.cmd.js @@ -6,7 +6,14 @@ const authRoot = require('../root/auth.cmd'); const command = new Command({ command: 'get-contexts', - description: 'get-contexts', + parent: authRoot, + cliDocs: { + description: 'Get all possible authentication contexts', + }, + webDocs: { + category: 'Authentication', + title: 'Get all contexts', + }, builder: (yargs) => { return yargs; }, @@ -14,7 +21,6 @@ const command = new Command({ printTableForAuthContexts(); }, }); -authRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/auth/login.cmd.js b/lib/interface/cli/commands/auth/login.cmd.js deleted file mode 100644 index 8b2d0e604..000000000 --- a/lib/interface/cli/commands/auth/login.cmd.js +++ /dev/null @@ -1,56 +0,0 @@ -const debug = require('debug')('codefresh:auth:login'); -const Command = require('../../Command'); -const _ = require('lodash'); -const CFError = require('cf-errors'); -const DEFAULTS = require('../../defaults'); -const { auth } = require('../../../../logic'); -const { JWTContext } = auth.contexts; -const authManager = auth.manager; -const authRoot = require('../root/auth.cmd'); - -const _loginWithUserPassword = async (username, password) => { - try { - // TODO implement logic to get token by calling the pai - } catch (err) { - throw new CFError({ - cause: err, - message: 'Failed to login with username and password', - }); - } -}; - -const command = new Command({ - command: 'login ', - description: 'Login', - builder: (yargs) => { - return yargs - .usage('Login options') - .positional('username', { - describe: 'username', - required: true, - }) - .positional('password', { - describe: 'password', - required: true, - }) - .option('url', { - describe: 'Codefresh system custom url', - default: DEFAULTS.URL, - }); - }, - handler: async (argv) => { - const authContext = await _loginWithUserPassword(argv.username, argv.password); - - await authContext.validate(); - await authManager.addContext(authContext); - await authManager.setCurrentContext(authContext); - await authManager.persistContexts(authContext); - - console.log(`Login succeeded to ${authContext.url}`); - console.log(`Switched to context: ${authContext.name}`); - }, -}); -authRoot.subCommand(command); - - -module.exports = command; diff --git a/lib/interface/cli/commands/auth/use-context.cmd.js b/lib/interface/cli/commands/auth/use-context.cmd.js index d27ee3b37..48abfc7b6 100644 --- a/lib/interface/cli/commands/auth/use-context.cmd.js +++ b/lib/interface/cli/commands/auth/use-context.cmd.js @@ -9,7 +9,14 @@ const authRoot = require('../root/auth.cmd'); const command = new Command({ command: 'use-context ', - description: 'use-context', + parent: authRoot, + cliDocs: { + description: 'Set the current active authentication context', + }, + webDocs: { + category: 'Authentication', + title: 'Set active context', + }, builder: (yargs) => { return yargs .positional('context-name', { @@ -30,7 +37,5 @@ const command = new Command({ } }, }); -authRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/composition/create.cmd.js b/lib/interface/cli/commands/composition/create.cmd.js index 5f3fb9edc..31275a13a 100644 --- a/lib/interface/cli/commands/composition/create.cmd.js +++ b/lib/interface/cli/commands/composition/create.cmd.js @@ -11,7 +11,14 @@ const createRoot = require('../root/create.cmd'); const command = new Command({ command: 'composition [name]', aliases: ['com'], - description: 'Create a composition', + parent: createRoot, + cliDocs: { + description: 'Create a composition', + }, + webDocs: { + category: 'Compositions', + title: 'Create a composition', + }, builder: (yargs) => { return yargs .positional('name', { @@ -55,7 +62,6 @@ const command = new Command({ console.log(`Composition: ${data.name} created`); }, }); -createRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/composition/delete.cmd.js b/lib/interface/cli/commands/composition/delete.cmd.js index c6a08bc44..193208ea3 100644 --- a/lib/interface/cli/commands/composition/delete.cmd.js +++ b/lib/interface/cli/commands/composition/delete.cmd.js @@ -9,7 +9,14 @@ const deleteRoot = require('../root/delete.cmd'); const command = new Command({ command: 'composition [name]', aliases: ['com'], - description: 'Delete a composition', + parent: deleteRoot, + cliDocs: { + description: 'Delete a composition', + }, + webDocs: { + category: 'Compositions', + title: 'Delete a composition', + }, builder: (yargs) => { return yargs .positional('name', { @@ -27,7 +34,6 @@ const command = new Command({ console.log(`Composition: ${name} deleted`); }, }); -deleteRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/composition/describe.cmd.js b/lib/interface/cli/commands/composition/describe.cmd.js deleted file mode 100644 index f2163d73c..000000000 --- a/lib/interface/cli/commands/composition/describe.cmd.js +++ /dev/null @@ -1,30 +0,0 @@ -const debug = require('debug')('codefresh:cli:create:context'); -const Command = require('../../Command'); -const CFError = require('cf-errors'); -const _ = require('lodash'); -const { composition } = require('../../../../logic').api; -const describeRoot = require('../root/describe.cmd'); - - -const command = new Command({ - command: 'composition ', - aliases: ['com'], - description: 'Describe a composition', - builder: (yargs) => { - return yargs - .positional('id', { - describe: 'composition id or name', - }); - }, - handler: async (argv) => { - const id = argv.filename ? _.get(argv.filename, 'name') : argv.id; - - const currComposition = await composition.getCompositionByIdentifier(id); - console.log(currComposition.describe()); - }, -}); -describeRoot.subCommand(command); - - -module.exports = command; - diff --git a/lib/interface/cli/commands/composition/get.cmd.js b/lib/interface/cli/commands/composition/get.cmd.js index 7ffeaa339..f473ddd46 100644 --- a/lib/interface/cli/commands/composition/get.cmd.js +++ b/lib/interface/cli/commands/composition/get.cmd.js @@ -10,7 +10,14 @@ const getRoot = require('../root/get.cmd'); const command = new Command({ command: 'compositions [id|name]', aliases: ['com', 'composition'], - description: 'Get compositions', + parent: getRoot, + cliDocs: { + description: 'Get a specific composition or an array of compositions', + }, + webDocs: { + category: 'Compositions', + title: 'Get a single composition', + }, builder: (yargs) => { return yargs .positional('id', { @@ -31,7 +38,6 @@ const command = new Command({ } }, }); -getRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/composition/replace.cmd.js b/lib/interface/cli/commands/composition/replace.cmd.js index 47596e2e8..6ee677abe 100644 --- a/lib/interface/cli/commands/composition/replace.cmd.js +++ b/lib/interface/cli/commands/composition/replace.cmd.js @@ -9,7 +9,14 @@ const replaceRoot = require('../root/replace.cmd'); const command = new Command({ command: 'composition', aliases: ['com'], - description: 'Replace a composition resource', + parent: replaceRoot, + cliDocs: { + description: 'Replace a composition resource', + }, + webDocs: { + category: 'Compositions', + title: 'Replace a composition', + }, builder: (yargs) => { return yargs; }, @@ -35,7 +42,6 @@ const command = new Command({ console.log(`Composition: ${name} replaced`); }, }); -replaceRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/context/apply.cmd.js b/lib/interface/cli/commands/context/apply.cmd.js index 30631f4ef..a4e3618c6 100644 --- a/lib/interface/cli/commands/context/apply.cmd.js +++ b/lib/interface/cli/commands/context/apply.cmd.js @@ -9,7 +9,14 @@ const applyRoot = require('../root/apply.cmd'); const command = new Command({ command: 'context', aliases: ['ctx'], - description: 'Apply changes to a context', + parent: applyRoot, + cliDocs: { + description: 'Apply changes to a context', + }, + webDocs: { + category: 'Contexts', + title: 'Updated a context', + }, builder: (yargs) => { return yargs; }, @@ -36,7 +43,6 @@ const command = new Command({ } }, }); -applyRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/context/create.cmd.js b/lib/interface/cli/commands/context/create.cmd.js index c73224192..026fe4e16 100644 --- a/lib/interface/cli/commands/context/create.cmd.js +++ b/lib/interface/cli/commands/context/create.cmd.js @@ -9,7 +9,14 @@ const createRoot = require('../root/create.cmd'); const command = new Command({ command: 'context [type] [name]', aliases: ['ctx'], - description: 'Create a context', + parent: createRoot, + cliDocs: { + description: 'Create a context', + }, + webDocs: { + category: 'Contexts', + title: 'Create a context', + }, builder: (yargs) => { return yargs .positional('name', { @@ -52,9 +59,6 @@ const command = new Command({ console.log(`Context: ${data.metadata.name} created`); }, }); -createRoot.subCommand(command); - - module.exports = command; diff --git a/lib/interface/cli/commands/context/delete.cmd.js b/lib/interface/cli/commands/context/delete.cmd.js index 994acb633..25373924b 100644 --- a/lib/interface/cli/commands/context/delete.cmd.js +++ b/lib/interface/cli/commands/context/delete.cmd.js @@ -8,7 +8,14 @@ const deleteRoot = require('../root/delete.cmd'); const command = new Command({ command: 'context [name]', aliases: ['ctx'], - description: 'Delete a context', + parent: deleteRoot, + cliDocs: { + description: 'Delete a context', + }, + webDocs: { + category: 'Contexts', + title: 'Delete a context', + }, builder: (yargs) => { return yargs .positional('name', { @@ -27,7 +34,6 @@ const command = new Command({ console.log(`Context: ${name} deleted`); }, }); -deleteRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/context/get.cmd.js b/lib/interface/cli/commands/context/get.cmd.js index cf407a972..45595f632 100644 --- a/lib/interface/cli/commands/context/get.cmd.js +++ b/lib/interface/cli/commands/context/get.cmd.js @@ -11,7 +11,14 @@ const getRoot = require('../root/get.cmd'); const command = new Command({ command: 'contexts [name]', aliases: ['ctx', 'context'], - description: 'Get contexts', + parent: getRoot, + cliDocs: { + description: 'Get a specific or an array of contexts', + }, + webDocs: { + category: 'Contexts', + title: 'Get a single context', + }, builder: (yargs) => { return yargs .positional('name', { @@ -64,7 +71,5 @@ const command = new Command({ } }, }); -getRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/context/replace.cmd.js b/lib/interface/cli/commands/context/replace.cmd.js index aa16723de..6de6cfc4a 100644 --- a/lib/interface/cli/commands/context/replace.cmd.js +++ b/lib/interface/cli/commands/context/replace.cmd.js @@ -8,7 +8,14 @@ const replaceRoot = require('../root/replace.cmd'); const command = new Command({ command: 'context', aliases: ['ctx'], - description: 'Replace a context resource', + parent: replaceRoot, + cliDocs: { + description: 'Replace a context', + }, + webDocs: { + category: 'Contexts', + title: 'Replace a context', + }, builder: (yargs) => { return yargs; }, @@ -25,7 +32,6 @@ const command = new Command({ console.log(`Context: ${name} replaced`); }, }); -replaceRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/environment/delete.cmd.js b/lib/interface/cli/commands/environment/delete.cmd.js index b87ca3536..5d927f9cb 100644 --- a/lib/interface/cli/commands/environment/delete.cmd.js +++ b/lib/interface/cli/commands/environment/delete.cmd.js @@ -8,7 +8,15 @@ const deleteRoot = require('../root/delete.cmd'); const command = new Command({ command: 'environment ', aliases: ['env'], - description: 'get-contexts', + description: 'Delete an environment', + parent: deleteRoot, + cliDocs: { + description: 'Delete an environment', + }, + webDocs: { + category: 'Environments', + title: 'Delete an environment', + }, builder: (yargs) => { return yargs .positional('id', { @@ -21,8 +29,5 @@ const command = new Command({ console.log(`Environment: ${id} deleted`); }, }); -deleteRoot.subCommand(command); - - module.exports = command; diff --git a/lib/interface/cli/commands/environment/describe.cmd.js b/lib/interface/cli/commands/environment/describe.cmd.js deleted file mode 100644 index 2e056401a..000000000 --- a/lib/interface/cli/commands/environment/describe.cmd.js +++ /dev/null @@ -1,28 +0,0 @@ -const debug = require('debug')('codefresh:cli:create:context'); -const Command = require('../../Command'); -const CFError = require('cf-errors'); -const _ = require('lodash'); -const { environment } = require('../../../../logic').api; -const describeRoot = require('../root/describe.cmd'); - - -const command = new Command({ - command: 'environment ', - aliases: ['env'], - description: 'Describe an environment', - builder: (yargs) => { - return yargs - .positional('id', { - describe: 'environment id', - }); - }, - handler: async (argv) => { - const id = argv.filename ? _.get(argv.filename, 'id') : argv.id; - const currEnvironment = await environment.getEnvironmentById(id); - console.log(currEnvironment.describe()); - }, -}); -describeRoot.subCommand(command); - - -module.exports = command; diff --git a/lib/interface/cli/commands/environment/get.cmd.js b/lib/interface/cli/commands/environment/get.cmd.js index a1a76e473..5abcdc249 100644 --- a/lib/interface/cli/commands/environment/get.cmd.js +++ b/lib/interface/cli/commands/environment/get.cmd.js @@ -10,7 +10,15 @@ const getRoot = require('../root/get.cmd'); const command = new Command({ command: 'environments [id]', aliases: ['env', 'environment'], - description: 'Get environments', + category: 'Environments', + parent: getRoot, + cliDocs: { + description: 'Get a specific or an array of environments', + }, + webDocs: { + category: 'Environments', + title: 'Get a single composition', + }, builder: (yargs) => { return yargs .positional('id', { @@ -31,8 +39,6 @@ const command = new Command({ } }, }); -getRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/image/annotate.cmd.js b/lib/interface/cli/commands/image/annotate.cmd.js index a98d21614..1ea2a9438 100644 --- a/lib/interface/cli/commands/image/annotate.cmd.js +++ b/lib/interface/cli/commands/image/annotate.cmd.js @@ -7,7 +7,14 @@ const annotateRoot = require('../root/annotate.cmd'); const command = new Command({ command: 'image ', aliases: ['img'], - description: 'Annotate an image', + parent: annotateRoot, + cliDocs: { + description: 'Annotate an image', + }, + webDocs: { + category: 'Images', + title: 'Annotate an image', + }, builder: (yargs) => { return yargs .positional('id', { @@ -35,8 +42,6 @@ const command = new Command({ console.log('annotations add successfully'); }, }); -annotateRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/image/describe.cmd.js b/lib/interface/cli/commands/image/describe.cmd.js deleted file mode 100644 index af6d288bf..000000000 --- a/lib/interface/cli/commands/image/describe.cmd.js +++ /dev/null @@ -1,28 +0,0 @@ -const debug = require('debug')('codefresh:cli:create:context'); -const Command = require('../../Command'); -const CFError = require('cf-errors'); -const _ = require('lodash'); -const { image } = require('../../../../logic').api; -const yaml = require('js-yaml'); -const describeRoot = require('../root/describe.cmd'); - -const command = new Command({ - command: 'image ', - aliases: ['img'], - description: 'describe image', - builder: (yargs) => { - return yargs - .positional('id', { - describe: 'image id', - }); - }, - handler: async (argv) => { - const id = argv.filename ? _.get(argv.filename, 'id') : argv.id; - const currImage = await image.getImageById(id); - console.log(currImage.describe()); - }, -}); -describeRoot.subCommand(command); - - -module.exports = command; diff --git a/lib/interface/cli/commands/image/get.cmd.js b/lib/interface/cli/commands/image/get.cmd.js index f0759c40b..66070868c 100644 --- a/lib/interface/cli/commands/image/get.cmd.js +++ b/lib/interface/cli/commands/image/get.cmd.js @@ -8,11 +8,17 @@ const { image } = require('../../../../logic').api; const { specifyOutputForArray } = require('../../helpers/get'); const getRoot = require('../root/get.cmd'); - const command = new Command({ command: 'images [id]', aliases: ['img', 'image'], - description: 'Get images', + parent: getRoot, + cliDocs: { + description: 'Get a specific or an array of images', + }, + webDocs: { + category: 'Images', + title: 'Get a single image', + }, builder: (yargs) => { return yargs .positional('id', { @@ -87,7 +93,5 @@ const command = new Command({ specifyOutputForArray(argv.output, images); }, }); -getRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/image/tag.cmd.js b/lib/interface/cli/commands/image/tag.cmd.js index 85fcc0666..f6801788b 100644 --- a/lib/interface/cli/commands/image/tag.cmd.js +++ b/lib/interface/cli/commands/image/tag.cmd.js @@ -8,7 +8,14 @@ const { image } = require('../../../../logic').api; const tag = new Command({ root: true, command: 'tag [tags..]', - description: 'Add an image tag', + category: 'Images', + cliDocs: { + description: 'Add an image tag', + }, + webDocs: { + category: 'Images', + title: 'Tag an image', + }, builder: (yargs) => { yargs .positional('id', { diff --git a/lib/interface/cli/commands/pipeline/apply.cmd.js b/lib/interface/cli/commands/pipeline/apply.cmd.js index 2d62cec84..7cbba6fd8 100644 --- a/lib/interface/cli/commands/pipeline/apply.cmd.js +++ b/lib/interface/cli/commands/pipeline/apply.cmd.js @@ -7,13 +7,20 @@ const { pipeline } = require('../../../../logic').api; const applyRoot = require('../root/apply.cmd'); const command = new Command({ - command: 'pipeline [repo-owner] [repo-name]', + command: 'pipeline ', aliases: ['pip'], - description: 'Apply changes to a pipeline', + parent: applyRoot, + cliDocs: { + description: 'Apply changes to a pipeline', + }, + webDocs: { + category: 'Pipelines', + title: 'Update a single pipeline', + }, builder: (yargs) => { return yargs .positional('id', { - describe: 'pipeline id or name', + describe: 'pipeline id', }) .positional('repo-owner', { describe: 'repository owner', @@ -41,10 +48,7 @@ const command = new Command({ handler: async (argv) => { let pipelineToUpdate = {}; - const pipelineName = argv.name; const pipelineId = argv.id; - const repoOwner = argv['repo-owner']; - const repoName = argv['repo-name']; const contexts = prepareKeyValueFromCLIEnvOption(argv.context); pipelineToUpdate.contexts = _.map(contexts, (name, type) => { @@ -72,17 +76,10 @@ const command = new Command({ }); } - if (repoOwner && repoName) { - await pipeline.patchPipelineByNameAndRepo(pipelineName, repoOwner, repoName, pipelineToUpdate); - } else { - await pipeline.patchPipelineById(pipelineId, pipelineToUpdate); - } - - console.log(`Pipeline: ${pipelineName} patched`); + await pipeline.patchPipelineById(pipelineId, pipelineToUpdate); + console.log(`Pipeline: ${pipelineId} patched`); }, }); -applyRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/pipeline/describe.cmd.js b/lib/interface/cli/commands/pipeline/describe.cmd.js deleted file mode 100644 index 74fcb43a4..000000000 --- a/lib/interface/cli/commands/pipeline/describe.cmd.js +++ /dev/null @@ -1,43 +0,0 @@ -const debug = require('debug')('codefresh:cli:create:context'); -const Command = require('../../Command'); -const CFError = require('cf-errors'); -const _ = require('lodash'); -const { pipeline } = require('../../../../logic').api; -const describeRoot = require('../root/describe.cmd'); - -const command = new Command({ - command: 'pipeline [repo-owner] [repo-name]', - aliases: ['pip'], - description: 'describe pipeline', - builder: (yargs) => { - return yargs - .positional('id', { - describe: 'pipeline id or name', - }) - .positional('repo-owner', { - describe: 'repository owner', - }) - .positional('repo-name', { - describe: 'repository name', - }); - }, - handler: async (argv) => { - const id = argv.id; - const repoOwner = argv['repo-owner']; - const repoName = argv['repo-name']; - - let currPipeline; - - if (repoOwner && repoName) { - currPipeline = await pipeline.getPipelineByNameAndRepo(id, repoOwner, repoName); - } else { - currPipeline = await pipeline.getPipelineById(id); - } - console.log(currPipeline.describe()); - }, -}); -describeRoot.subCommand(command); - - -module.exports = command; - diff --git a/lib/interface/cli/commands/pipeline/dynamic/install-chart.cmd.js b/lib/interface/cli/commands/pipeline/dynamic/install-chart.cmd.js index 2f9f38fdd..13ded8d04 100644 --- a/lib/interface/cli/commands/pipeline/dynamic/install-chart.cmd.js +++ b/lib/interface/cli/commands/pipeline/dynamic/install-chart.cmd.js @@ -8,7 +8,13 @@ const { log } = require('../../../../../logic').api; const install = new Command({ root: true, command: 'install-chart', - description: 'Install or upgrade Helm chart', + cliDocs: { + description: 'Install or upgrade Helm chart', + }, + webDocs: { + category: 'Predefined Pipelines', + title: 'Install or upgrade Helm chart', + }, builder: (yargs) => { return yargs .usage('Install or upgrade helm chart on cluster') diff --git a/lib/interface/cli/commands/pipeline/dynamic/test-release.cmd.js b/lib/interface/cli/commands/pipeline/dynamic/test-release.cmd.js index dcef4a269..331c38102 100644 --- a/lib/interface/cli/commands/pipeline/dynamic/test-release.cmd.js +++ b/lib/interface/cli/commands/pipeline/dynamic/test-release.cmd.js @@ -8,7 +8,13 @@ const { log } = require('../../../../../logic').api; const install = new Command({ root: true, command: 'test-release [name]', - description: 'Test helm releaes', + cliDocs: { + description: 'Test a helm release', + }, + webDocs: { + category: 'Predefined Pipelines', + title: 'Test a helm release', + }, builder: (yargs) => { return yargs .usage('Test helm relaese') diff --git a/lib/interface/cli/commands/pipeline/get.cmd.js b/lib/interface/cli/commands/pipeline/get.cmd.js index 209f9e29f..c328075fb 100644 --- a/lib/interface/cli/commands/pipeline/get.cmd.js +++ b/lib/interface/cli/commands/pipeline/get.cmd.js @@ -12,7 +12,14 @@ const DEFAULTS = require('../../defaults'); const command = new Command({ command: 'pipelines [id]', aliases: ['pip', 'pipeline'], - description: 'Get pipelines', + parent: getRoot, + cliDocs: { + description: 'Get a specific or an array of pipelines', + }, + webDocs: { + category: 'Pipelines', + title: 'Get a single pipeline', + }, builder: (yargs) => { return yargs .positional('id', { @@ -66,8 +73,6 @@ const command = new Command({ } }, }); -getRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/workflow/run.cmd.js b/lib/interface/cli/commands/pipeline/run.cmd.js similarity index 94% rename from lib/interface/cli/commands/workflow/run.cmd.js rename to lib/interface/cli/commands/pipeline/run.cmd.js index 53570c2ea..2f323d608 100644 --- a/lib/interface/cli/commands/workflow/run.cmd.js +++ b/lib/interface/cli/commands/pipeline/run.cmd.js @@ -11,7 +11,13 @@ const authManager = require('../../../../logic').auth.manager; const run = new Command({ root: true, command: 'run ', - description: 'Run a pipeline and attach the created workflow logs.\nReturns an exist code according to the workflow finish status (Success: 0, Error: 1, Terminated: 2).', + cliDocs: { + description: 'Run a pipeline and attach the created workflow logs.\nReturns an exist code according to the workflow finish status (Success: 0, Error: 1, Terminated: 2).', + }, + webDocs: { + category: 'Pipelines', + title: 'Execute a pipeline', + }, builder: (yargs) => { yargs .positional('id', { diff --git a/lib/interface/cli/commands/pipeline2/create.cmd.js b/lib/interface/cli/commands/pipeline2/create.cmd.js index df67b836b..4e2c422aa 100644 --- a/lib/interface/cli/commands/pipeline2/create.cmd.js +++ b/lib/interface/cli/commands/pipeline2/create.cmd.js @@ -9,7 +9,14 @@ const createRoot = require('../root/create.cmd'); const command = new Command({ betaCommand: true, command: 'pipeline2 [name]', - description: 'Create a pipeline', + parent: createRoot, + cliDocs: { + description: 'Create a pipeline', + }, + webDocs: { + category: 'Pipelines V2', + title: 'Create a pipeline', + }, builder: (yargs) => { return yargs .positional('name', { @@ -37,8 +44,6 @@ const command = new Command({ }, }); -createRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/pipeline2/delete.cmd.js b/lib/interface/cli/commands/pipeline2/delete.cmd.js index ce15cc9a1..c54a63b2a 100644 --- a/lib/interface/cli/commands/pipeline2/delete.cmd.js +++ b/lib/interface/cli/commands/pipeline2/delete.cmd.js @@ -10,7 +10,14 @@ const deleteRoot = require('../root/delete.cmd'); const command = new Command({ betaCommand: true, command: 'pipeline2 [name]', - description: 'Deletes a pipeline', + parent: deleteRoot, + cliDocs: { + description: 'Delete a pipeline', + }, + webDocs: { + category: 'Pipelines V2', + title: 'Delete a pipeline', + }, builder: (yargs) => { return yargs .positional('name', { @@ -24,7 +31,6 @@ const command = new Command({ console.log(`Pipeline '${name}' deleted.`); }, }); -deleteRoot.subCommand(command); module.exports = command; diff --git a/lib/interface/cli/commands/pipeline2/get.cmd.js b/lib/interface/cli/commands/pipeline2/get.cmd.js index 41f53a228..404698f96 100644 --- a/lib/interface/cli/commands/pipeline2/get.cmd.js +++ b/lib/interface/cli/commands/pipeline2/get.cmd.js @@ -11,7 +11,14 @@ const command = new Command({ betaCommand: true, command: 'pipelines2 [name]', aliases: ['pip2', 'pipeline2'], - description: 'Get pipelines', + parent: getRoot, + cliDocs: { + description: 'Get a specific pipeline or an array of pipelines', + }, + webDocs: { + category: 'Pipelines V2', + title: 'Get a single pipeline', + }, builder: (yargs) => { return yargs .positional('name', { @@ -28,8 +35,6 @@ const command = new Command({ } }, }); -getRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/pipeline2/replace.cmd.js b/lib/interface/cli/commands/pipeline2/replace.cmd.js index d719646d5..e473a7f05 100644 --- a/lib/interface/cli/commands/pipeline2/replace.cmd.js +++ b/lib/interface/cli/commands/pipeline2/replace.cmd.js @@ -9,7 +9,14 @@ const replaceRoot = require('../root/replace.cmd'); const command = new Command({ betaCommand: true, command: 'pipeline2 [name]', - description: 'Replaces a pipeline', + parent: replaceRoot, + cliDocs: { + description: 'Replace a pipeline', + }, + webDocs: { + category: 'Pipelines V2', + title: 'Replace a pipeline', + }, builder: (yargs) => { return yargs .positional('name', { @@ -37,8 +44,5 @@ const command = new Command({ }, }); -replaceRoot.subCommand(command); - - module.exports = command; diff --git a/lib/interface/cli/commands/pipeline2/run.cmd.js b/lib/interface/cli/commands/pipeline2/run.cmd.js deleted file mode 100644 index 5fbee582e..000000000 --- a/lib/interface/cli/commands/pipeline2/run.cmd.js +++ /dev/null @@ -1,31 +0,0 @@ -const debug = require('debug')('codefresh:cli:create:pipelines2'); -const Command = require('../../Command'); -const CFError = require('cf-errors'); -const _ = require('lodash'); -const { pipeline2 } = require('../../../../logic').api; -const { specifyOutputForSingle, specifyOutputForArray } = require('../../helpers/get'); -const runRoot = require('../workflow/run.cmd'); - - -const command = new Command({ - betaCommand: true, - command: 'pipeline2 [name]', - description: 'Runs a pipeline', - builder: (yargs) => { - return yargs - .positional('name', { - describe: 'Pipeline name', - }); - }, - handler: async (argv) => { - const {name, output} = argv; - - const buildId = await pipeline2.runPipelineByName(name); - console.log(`New build created for pipeline '${name}': ${buildId}`); - }, -}); -runRoot.subCommand(command); - - -module.exports = command; - diff --git a/lib/interface/cli/commands/root/annotate.cmd.js b/lib/interface/cli/commands/root/annotate.cmd.js index 43ae2afd4..73cc00356 100644 --- a/lib/interface/cli/commands/root/annotate.cmd.js +++ b/lib/interface/cli/commands/root/annotate.cmd.js @@ -3,7 +3,9 @@ const Command = require('../../Command'); const annotate = new Command({ root: true, command: 'annotate', - description: 'Annotate a resource with labels', + cliDocs: { + description: 'Annotate a resource with labels', + }, builder: (yargs) => { return yargs .usage('Annotate a resource with labels\n\n' + diff --git a/lib/interface/cli/commands/root/apply.cmd.js b/lib/interface/cli/commands/root/apply.cmd.js index 9d16657c7..090891e73 100644 --- a/lib/interface/cli/commands/root/apply.cmd.js +++ b/lib/interface/cli/commands/root/apply.cmd.js @@ -2,10 +2,12 @@ const Command = require('../../Command'); const { crudFilenameOption } = require('../../helpers/general'); -const get = new Command({ +const apply = new Command({ root: true, command: 'patch', - description: 'Patch a resource by filename or stdin', + cliDocs: { + description: 'Patch a resource by filename or stdin', + }, builder: (yargs) => { crudFilenameOption(yargs); @@ -14,4 +16,4 @@ const get = new Command({ }, }); -module.exports = get; +module.exports = apply; diff --git a/lib/interface/cli/commands/root/auth.cmd.js b/lib/interface/cli/commands/root/auth.cmd.js index 5d9e5b08f..8f17d50d1 100644 --- a/lib/interface/cli/commands/root/auth.cmd.js +++ b/lib/interface/cli/commands/root/auth.cmd.js @@ -4,7 +4,9 @@ const auth = new Command({ root: true, requiresAuthentication: false, command: 'auth', - description: 'Manage authentication contexts', + cliDocs: { + description: 'Manage authentication contexts', + }, builder: (yargs) => { return yargs .usage('Control authentication contexts.\n' + diff --git a/lib/interface/cli/commands/root/create.cmd.js b/lib/interface/cli/commands/root/create.cmd.js index 2d59d517e..815aa86f1 100644 --- a/lib/interface/cli/commands/root/create.cmd.js +++ b/lib/interface/cli/commands/root/create.cmd.js @@ -5,7 +5,9 @@ const { crudFilenameOption } = require('../../helpers/general'); const get = new Command({ root: true, command: 'create', - description: 'Create a resource from a file or from stdin', + cliDocs: { + description: 'Create a resource from a file or from stdin', + }, builder: (yargs) => { // TODO add default command in case of no // TODO should we define all possible resources in this level??? diff --git a/lib/interface/cli/commands/root/delete.cmd.js b/lib/interface/cli/commands/root/delete.cmd.js index 49cb285b7..64d8c1d04 100644 --- a/lib/interface/cli/commands/root/delete.cmd.js +++ b/lib/interface/cli/commands/root/delete.cmd.js @@ -5,7 +5,9 @@ const { crudFilenameOption } = require('../../helpers/general'); const get = new Command({ root: true, command: 'delete', - description: 'Delete a resource by file or resource name', + cliDocs: { + description: 'Delete a resource by file or resource name', + }, builder: (yargs) => { // TODO add default command in case of no // TODO should we define all possible resources in this level??? diff --git a/lib/interface/cli/commands/root/describe.cmd.js b/lib/interface/cli/commands/root/describe.cmd.js deleted file mode 100644 index 88b1c953d..000000000 --- a/lib/interface/cli/commands/root/describe.cmd.js +++ /dev/null @@ -1,29 +0,0 @@ -const Command = require('../../Command'); -const { crudFilenameOption } = require('../../helpers/general'); - - -const get = new Command({ - root: false, //TODO replace command for now will be ignored. does not bring any value currently - command: 'describe', - description: 'Show details of a specific resource or group of resources', - builder: (yargs) => { - // TODO add default command in case of no - // TODO should we define all possible resources in this level??? - yargs - .usage('Show details of a specific resource or group of resources\n\n' + - 'Available Resources:\n' + - ' * context\n' + - ' * pipeline\n' + - ' * image') - .example('$0 describe -f ./filename', '# Describe a resource from FILE') - .example('$0 describe context -f ./filename', '# Describe a context from FILE') - .example('$0 describe context name', '# Describe a config context by NAME'); - - crudFilenameOption(yargs); - - return yargs - .demandCommand(1, 'You need at least one command before moving on'); - }, -}); - -module.exports = get; diff --git a/lib/interface/cli/commands/root/get.cmd.js b/lib/interface/cli/commands/root/get.cmd.js index 02cde4ba9..ae5160789 100644 --- a/lib/interface/cli/commands/root/get.cmd.js +++ b/lib/interface/cli/commands/root/get.cmd.js @@ -6,7 +6,9 @@ const DEFAULTS = require('../../defaults'); const get = new Command({ root: true, command: 'get', - description: 'Display one or many resources', + cliDocs: { + description: 'Display one or many resources', + }, builder: (yargs) => { // TODO add default command in case of no // TODO should we define all possible resources in this level??? diff --git a/lib/interface/cli/commands/root/replace.cmd.js b/lib/interface/cli/commands/root/replace.cmd.js index 46f49b27f..682a7f3ca 100644 --- a/lib/interface/cli/commands/root/replace.cmd.js +++ b/lib/interface/cli/commands/root/replace.cmd.js @@ -4,7 +4,9 @@ const { crudFilenameOption } = require('../../helpers/general'); const annotate = new Command({ root: true, command: 'replace', - description: 'Replace a resource by filename or stdin', + cliDocs: { + description: 'Replace a resource by filename or stdin', + }, builder: (yargs) => { crudFilenameOption(yargs); diff --git a/lib/interface/cli/commands/root/version.cmd.js b/lib/interface/cli/commands/root/version.cmd.js index b87767c62..ae9a6a127 100644 --- a/lib/interface/cli/commands/root/version.cmd.js +++ b/lib/interface/cli/commands/root/version.cmd.js @@ -5,7 +5,9 @@ const version = new Command({ root: true, requiresAuthentication: false, command: 'version', - description: 'Print version', + cliDocs: { + description: 'Print version', + }, builder: (yargs) => { return yargs; }, diff --git a/lib/interface/cli/commands/workflow/describe.cmd.js b/lib/interface/cli/commands/workflow/describe.cmd.js deleted file mode 100644 index 9906ea414..000000000 --- a/lib/interface/cli/commands/workflow/describe.cmd.js +++ /dev/null @@ -1,27 +0,0 @@ -const debug = require('debug')('codefresh:cli:create:context'); -const Command = require('../../Command'); -const CFError = require('cf-errors'); -const _ = require('lodash'); -const { workflow } = require('../../../../logic').api; -const describeRoot = require('../root/describe.cmd'); - -const command = new Command({ - command: 'build ', - description: 'Describe a build', - builder: (yargs) => { - return yargs - .positional('id', { - describe: 'build id', - }); - }, - handler: async (argv) => { - const id = argv.filename ? _.get(argv.filename, 'id') : argv.id; - const currWorkflow = await workflow.getWorkflowById(id); - console.log(currWorkflow.describe()); - }, -}); -describeRoot.subCommand(command); - - -module.exports = command; - diff --git a/lib/interface/cli/commands/workflow/get.cmd.js b/lib/interface/cli/commands/workflow/get.cmd.js index deba00192..16ecb1171 100644 --- a/lib/interface/cli/commands/workflow/get.cmd.js +++ b/lib/interface/cli/commands/workflow/get.cmd.js @@ -11,7 +11,14 @@ const { printError } = require('../../helpers/general'); const command = new Command({ command: 'builds [id]', aliases: ['build'], - description: 'Get builds', + parent: getRoot, + cliDocs: { + description: 'Get a specific builds or an array of builds', + }, + webDocs: { + category: 'Builds', + title: 'Get a single build', + }, builder: (yargs) => { return yargs .positional('id', { @@ -86,7 +93,5 @@ const command = new Command({ } }, }); -getRoot.subCommand(command); - module.exports = command; diff --git a/lib/interface/cli/commands/workflow/logs.cmd.js b/lib/interface/cli/commands/workflow/logs.cmd.js index 668656967..195728ded 100644 --- a/lib/interface/cli/commands/workflow/logs.cmd.js +++ b/lib/interface/cli/commands/workflow/logs.cmd.js @@ -8,7 +8,13 @@ const { log } = require('../../../../logic').api; const run = new Command({ root: true, command: 'logs ', - description: 'Show logs of a build', + cliDocs: { + description: 'Show logs of a build', + }, + webDocs: { + category: 'Builds', + title: 'Show logs', + }, builder: (yargs) => { yargs .positional('id', { diff --git a/lib/interface/cli/commands/workflow/restart.cmd.js b/lib/interface/cli/commands/workflow/restart.cmd.js index c407c9adc..6e1690924 100644 --- a/lib/interface/cli/commands/workflow/restart.cmd.js +++ b/lib/interface/cli/commands/workflow/restart.cmd.js @@ -5,7 +5,13 @@ const { log } = require('../../../../logic').api; const restart = new Command({ root: true, command: 'restart ', - description: 'Restart a build by its id', + cliDocs: { + description: 'Restart a build by its id', + }, + webDocs: { + category: 'Builds', + title: 'Restart a build', + }, builder: (yargs) => { return yargs .positional('id', { diff --git a/lib/interface/cli/commands/workflow/terminate.cmd.js b/lib/interface/cli/commands/workflow/terminate.cmd.js index c5043fb6c..8535d4e95 100644 --- a/lib/interface/cli/commands/workflow/terminate.cmd.js +++ b/lib/interface/cli/commands/workflow/terminate.cmd.js @@ -4,7 +4,13 @@ const { workflow } = require('../../../../logic/index').api; const terminate = new Command({ root: true, command: 'terminate ', - description: 'Terminate a build by its id', + cliDocs: { + description: 'Terminate a build by its id', + }, + webDocs: { + category: 'Builds', + title: 'Terminate a build', + }, builder: (yargs) => { return yargs .positional('id', { diff --git a/lib/interface/cli/commands/workflow/wait.cmd.js b/lib/interface/cli/commands/workflow/wait.cmd.js index ffe6fe1d9..507cd521a 100644 --- a/lib/interface/cli/commands/workflow/wait.cmd.js +++ b/lib/interface/cli/commands/workflow/wait.cmd.js @@ -9,7 +9,13 @@ const moment = require('moment'); const annotate = new Command({ root: true, command: 'wait ', - description: 'Wait until a condition will be met on a build', + cliDocs: { + description: 'Wait until a condition will be met on a build', + }, + webDocs: { + category: 'Builds', + title: 'Wait for a build condition', + }, builder: (yargs) => { return yargs .option('status', { diff --git a/lib/logic/entities/Entity.js b/lib/logic/entities/Entity.js index 285fd1476..98d057a8b 100644 --- a/lib/logic/entities/Entity.js +++ b/lib/logic/entities/Entity.js @@ -34,11 +34,6 @@ class Entity { }); return values; } - - // TODO: choose which information to show when using describe command - describe() { - return yaml.safeDump(this.info); - } } module.exports = Entity; diff --git a/package.json b/package.json index 163b3114c..64a0df186 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.7.1", + "version": "0.7.2", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,