From e1961c84fc5008232b76e6e066935eb33072b06b Mon Sep 17 00:00:00 2001 From: mikhail-klimko Date: Wed, 30 Aug 2023 18:47:51 +0300 Subject: [PATCH] feat: add arm binary (#840) ## What ## Why ## Notes --------- Co-authored-by: yaroslav-codefresh --- __mocks__/codefresh.yml | 40 +++++++++++++++++++ docs/index.js | 37 ++++++++--------- .../cli/commands/root/root.sdk.spec.js | 2 +- package.json | 6 +-- 4 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 __mocks__/codefresh.yml diff --git a/__mocks__/codefresh.yml b/__mocks__/codefresh.yml new file mode 100644 index 000000000..194fe1ca9 --- /dev/null +++ b/__mocks__/codefresh.yml @@ -0,0 +1,40 @@ +# More examples of Codefresh YAML can be found at +# https://codefresh.io/docs/docs/yaml-examples/examples/ + +version: "1.0" +# Stages can help you organize your steps in stages +stages: + - "clone" + - "build" + - "test" + +steps: + clone: + title: "Cloning repository" + type: "git-clone" + repo: "https://github.com/codefresh-io/cli/" + # Clone the master branch. Or, use ${{CF_BRANCH}} to get branch name from trigger + # Learn more at https://codefresh.io/docs/docs/codefresh-yaml/variables/ + revision: "master" + stage: "clone" + + build: + title: "Building Docker image" + type: "build" + image_name: "codefresh-io/cli" + working_directory: "${{clone}}" + # Set 'latest' tag on the image. Or, use built-in variables + # like ${{CF_BRANCH_TAG_NORMALIZED}} to use the current branch name/tag. + tag: "latest" + dockerfile: "Dockerfile" + stage: "build" + + test: + title: "Running test" + type: "freestyle" # Run any command + image: "ubuntu:latest" # The image in which command will be executed + working_directory: "${{clone}}" # Running command where code cloned + commands: + - "ls" + stage: "test" + diff --git a/docs/index.js b/docs/index.js index 5c9008099..683cdc0fe 100644 --- a/docs/index.js +++ b/docs/index.js @@ -16,21 +16,21 @@ const ALLOW_BETA_COMMANDS = process.env.ALLOW_BETA_COMMANDS; const categoriesOrder = { completion: 30, authentication: 31, - 'operate on resources' : 32, - pipelines : 40, - 'pipelines v2 (beta)' : 42, - projects : 45, + 'operate on resources': 32, + pipelines: 40, + 'pipelines v2 (beta)': 42, + projects: 45, builds: 50, - contexts : 70 , - images : 80 , - triggers : 90, - environments : 100 , - compositions : 110 , - 'helm repos' : 111 , + contexts: 70, + images: 80, + triggers: 90, + environments: 100, + compositions: 110, + 'helm repos': 111, 'predefined pipelines': 120, 'cli config': 121, teams: 130, - more : 150, + more: 150, }; @@ -115,7 +115,7 @@ const getWeight = async (command) => { } }; -const createCommandFile = async (nestedCategory,command) => { +const createCommandFile = async (nestedCategory, command) => { const docs = command.prepareDocs(); const dir = path.resolve(baseDir, `${(nestedCategory || 'undefined').toLowerCase()}`); @@ -216,7 +216,7 @@ const createCategoryFile = async (content, category) => { * updates the category main file with a specific command * possible extensions are: HEADER, COMMANDS */ -const updateCategoryFileArray = async (nestedCategory,command, existingContent) => { +const updateCategoryFileArray = async (nestedCategory, command, existingContent) => { const docs = command.prepareDocs(); const { category } = docs; const finalCategoryArr = existingContent || {}; @@ -253,7 +253,7 @@ const updateCategoryFileArray = async (nestedCategory,command, existingContent) finalCategoryArr.category = category; newCmd.weight = await getWeight(command); newCmd.content = commandString; - if (!finalCategoryArr.commands){ + if (!finalCategoryArr.commands) { finalCategoryArr.commands = []; } @@ -318,16 +318,16 @@ const createAutomatedDocs = async () => { // document only in case category field exists and there are no sub commands under it const docs = command.prepareDocs(); - const {category} = docs; + const { category } = docs; if (!category || await hasSubCommands(command)) { continue; } nestedCategories[category] = await getNestedCategories(command); const nestedCategory = nestedCategories[category]; - categories[category] = await updateCategoryFileArray(nestedCategory,command, categories[category]); + categories[category] = await updateCategoryFileArray(nestedCategory, command, categories[category]); await upsertCategoryFolder(nestedCategory); - await createCommandFile(nestedCategory,command); + await createCommandFile(nestedCategory, command); } let categoriesFinalContent = {}; @@ -356,7 +356,7 @@ const createDownloadPage = async () => { links.push(asset.browser_download_url); })); const commandFilePath = path.resolve(baseDir, './installation/download.md'); - const finalContent= + const finalContent = '+++\n' + 'title = "Download"\n' + 'description = "asd"\n' + @@ -372,6 +372,7 @@ const createDownloadPage = async () => { '
  • Linux-x64
  • \n' + '
  • Macos-x64
  • \n' + '
  • Windows-x64
  • \n' + + '
  • Alpine-arm64
  • \n' + ' \n' + '\n' + 'After downloading the binary, untar or unzip it and your are good to go.
    \n' + diff --git a/lib/interface/cli/commands/root/root.sdk.spec.js b/lib/interface/cli/commands/root/root.sdk.spec.js index b086e4aca..4032ec2c6 100644 --- a/lib/interface/cli/commands/root/root.sdk.spec.js +++ b/lib/interface/cli/commands/root/root.sdk.spec.js @@ -140,7 +140,7 @@ describe('root commands', () => { describe('Not valid yaml ', async () => { it('should throw error for not valid file', async () => { const argv = { - filenames: ['./codefresh.yml'], + filenames: ['./__mocks__/codefresh.yml'], }; const result = await validateCmd.handler(argv) .catch(err => err); diff --git a/package.json b/package.json index daeb4b8a5..f7abfbe49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.85.1", + "version": "0.86.0", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true, @@ -9,7 +9,7 @@ "test": "jest .spec.js --coverage", "e2e": "bash e2e/e2e.spec.sh", "eslint": "eslint --fix lib/logic/**", - "pkg": "pkg . -t node16-alpine-x64,node16-macos-x64,node16-linux-x64,node16-win-x64 --out-path ./dist", + "pkg": "pkg . -t node16-alpine-x64,node16-macos-x64,node16-linux-x64,node16-win-x64,node16-linux-arm64 --out-path ./dist", "serve-docs": "yarn build-local-docs && cd temp && hugo server -D", "serve-docs-beta": "ALLOW_BETA_COMMANDS=true yarn build-local-docs && cd temp && hugo server -D", "build-local-docs": "node ./docs/index.js", @@ -115,4 +115,4 @@ "./test-setup.js" ] } -} +} \ No newline at end of file