From b8caf1adce6e857377f1db0023bba1c2be96d90b Mon Sep 17 00:00:00 2001 From: Shashank Sinha Date: Wed, 10 Jan 2024 18:54:35 +0400 Subject: [PATCH 1/6] PLAT-13467 add release branch input --- .github/workflows/build-deploy.yml | 2 +- .../{create-github-release.yaml => create-github-release.yml} | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) rename .github/workflows/{create-github-release.yaml => create-github-release.yml} (91%) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 58f2fe820..b40192464 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -46,4 +46,4 @@ jobs: - name: release modules run: | heroku config:set MODULES_REPO_BRANCH=$GITHUB_REF_NAME -a ${{ secrets.HEROKU_APP }} - heroku run 'python manage.py update_crowdbotics_components --quiet --no-input --no-log-file --public' --size=standard-2x -a ${{ secrets.HEROKU_APP }} + heroku run 'python manage.py update_crowdbotics_components --quiet --no-input --no-log-file --public' --size=standard-2x -a ${{ secrets.HEROKU_APP }} \ No newline at end of file diff --git a/.github/workflows/create-github-release.yaml b/.github/workflows/create-github-release.yml similarity index 91% rename from .github/workflows/create-github-release.yaml rename to .github/workflows/create-github-release.yml index fbf968ceb..4c910af0c 100644 --- a/.github/workflows/create-github-release.yaml +++ b/.github/workflows/create-github-release.yml @@ -1,4 +1,4 @@ -name: release-notes +name: create-github-release on: workflow_dispatch: @@ -36,3 +36,4 @@ jobs: working-directory: ${{ env.working-directory }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }} + release_branch: ${{ github.event.client_payload.release_branch }} From 373bb90327640a2383f3cc8fe802350402b413f0 Mon Sep 17 00:00:00 2001 From: Saurav Gharti Magar Date: Sat, 13 Jan 2024 01:05:26 +0545 Subject: [PATCH 2/6] PLAT-13351 Add action Release to QA (#1072) * add action releae to qa * reuse workflow * rename release workflow --- .github/workflows/release-to-qa.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/release-to-qa.yml diff --git a/.github/workflows/release-to-qa.yml b/.github/workflows/release-to-qa.yml new file mode 100644 index 000000000..a8933ec8b --- /dev/null +++ b/.github/workflows/release-to-qa.yml @@ -0,0 +1,34 @@ +name: release-to-qa + +on: + workflow_dispatch: + repository_dispatch: + types: + - release-to-qa + +jobs: + tag-and-pr: + runs-on: ubuntu-latest + env: + working-directory: ./modules + base-branch: qa + pr-branch: develop + pr-label: automerge + steps: + - name: Repo Clone + run: | + git clone https://${{ secrets.GIT_TOKEN }}@github.com/${{ github.repository }}.git + + - name: Checkout branch + working-directory: ${{ env.working-directory }} + run: | + git checkout ${{ env.pr-branch }} + + - name: Run Release to QA Workflow + uses: crowdbotics/github-actions/release-to-qa@master + with: + working-directory: ${{ env.working-directory }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} + base-branch: ${{ env.base-branch }} + pr-branch: ${{ env.pr-branch }} + pr-label: ${{ env.pr-label }} From 64c9190865e87b4f708c98b7505e307968b17168 Mon Sep 17 00:00:00 2001 From: Saurav Gharti Magar Date: Mon, 22 Jan 2024 19:10:31 +0545 Subject: [PATCH 3/6] clone and use reusable workflow (#1077) --- .github/workflows/release-to-qa.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-to-qa.yml b/.github/workflows/release-to-qa.yml index a8933ec8b..cdfd5abed 100644 --- a/.github/workflows/release-to-qa.yml +++ b/.github/workflows/release-to-qa.yml @@ -19,13 +19,17 @@ jobs: run: | git clone https://${{ secrets.GIT_TOKEN }}@github.com/${{ github.repository }}.git + - name: Clone Reusable Actions Repo + run: | + git clone -b master https://${{ secrets.GIT_TOKEN }}@github.com/crowdbotics/github-actions.git + - name: Checkout branch working-directory: ${{ env.working-directory }} run: | git checkout ${{ env.pr-branch }} - name: Run Release to QA Workflow - uses: crowdbotics/github-actions/release-to-qa@master + uses: ./github-actions/release-to-qa with: working-directory: ${{ env.working-directory }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} From 2a371c707521eeeaa8643f4c56afd3f56f68373e Mon Sep 17 00:00:00 2001 From: Saurav Gharti Magar Date: Wed, 24 Jan 2024 19:53:36 +0545 Subject: [PATCH 4/6] clone and use reusable workflow (#1079) --- .github/workflows/create-github-release.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml index 4c910af0c..c36f1d19b 100644 --- a/.github/workflows/create-github-release.yml +++ b/.github/workflows/create-github-release.yml @@ -7,17 +7,20 @@ on: - create-github-release jobs: - build: runs-on: ubuntu-latest - env: + env: working-directory: ./modules steps: - - name: Repo Clone + - name: Repo Clone run: | git clone https://${{ secrets.GIT_TOKEN }}@github.com/crowdbotics/modules.git - + + - name: Clone Reusable Actions Repo + run: | + git clone -b master https://${{ secrets.GIT_TOKEN }}@github.com/crowdbotics/github-actions.git + - name: Checkout branch working-directory: ${{ env.working-directory }} run: | @@ -29,9 +32,9 @@ jobs: echo "branch: ${GITHUB_REF_NAME}" git checkout ${GITHUB_REF_NAME} fi - + - name: Run Release Workflow - uses: crowdbotics/github-actions/create-github-release@master + uses: ./github-actions/create-github-release with: working-directory: ${{ env.working-directory }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} From 476eb72e6428623bc17af92bd8396e3c4cf79b2d Mon Sep 17 00:00:00 2001 From: taylor-cb <146020288+taylor-cb@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:15:30 -0700 Subject: [PATCH 5/6] PLAT-13444 archive module (#1073) * Adding module archive commands * PLAT-13444: Updating modules based on api spec * Adding help message for cli --- index.js | 29 +++++++++++++++++---- scripts/modules.js | 65 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 1dc4fdf71..a9da5ad40 100755 --- a/index.js +++ b/index.js @@ -34,7 +34,7 @@ import { login } from "./scripts/login.js"; import { configFile } from "./scripts/utils/configFile.js"; import { sendFeedback } from "./scripts/feedback.js"; import { logout } from "./scripts/logout.js"; -import { modulesGet, modulesList } from "./scripts/modules.js"; +import { modulesArchive, modulesGet, modulesList } from "./scripts/modules.js"; import { publish } from "./scripts/publish.js"; import { sendAmplitudeEvent } from "./scripts/amplitude/scripts.js"; @@ -258,7 +258,9 @@ demo`; const args = arg({ "--search": String, "--visibility": String, - "--page": String + "--status": String, + "--page": String, + "--unarchive": Boolean }); let id; @@ -275,6 +277,7 @@ demo`; case "list": modulesList({ search: args["--search"], + status: args["--status"], visibility: args["--visibility"], page: args["--page"] ? Number(args["--page"]) : undefined }); @@ -291,12 +294,27 @@ demo`; modulesGet(id); break; + case "archive": + id = args._[2]; + if (!id) { + return invalid( + "Please provide the id of the module to archive, i.e. modules archive <123>" + ); + } + + modulesArchive(id, !!args["--unarchive"]); + break; + case "help": section( `Commands available: - list List the current modules available to install - --search Search for a module by given text - --visibility Search for a module with a specific visibility (default all) + list List the current modules available to install + --search Search for a module by given text + --status Search for a module by either published or archived modules (default all) + --visibility Search for a module with a specific visibility (default all) + get Get the details for the specified module + archive Archive the specified module to prevent future installation to a project + --unarchive Undo the archive of the module to set the status back to Published ` ); break; @@ -353,6 +371,7 @@ Commands available: login Login to your Crowdbotics account. Requires 2FA authentication logout Logout of your Crowdbotics account publish Publish your modules to your organization's private catalog + modules Manage modules for your organization Parse and validate your modules: npx crowdbotics/modules parse --source diff --git a/scripts/modules.js b/scripts/modules.js index 883a1a213..65760bb06 100644 --- a/scripts/modules.js +++ b/scripts/modules.js @@ -1,4 +1,4 @@ -import { invalid, section } from "../utils.js"; +import { invalid, section, valid } from "../utils.js"; import { apiClient } from "./utils/apiClient.js"; import { configFile } from "./utils/configFile.js"; import { DEFAULT_HOST, HOST_CONFIG_NAME } from "./utils/constants.js"; @@ -6,10 +6,16 @@ import { getCurrentUserOrganization } from "./utils/organization.js"; import Table from "cli-table"; import ora from "ora"; import { formatUrlPath } from "./utils/url.js"; +import inquirer from "inquirer"; const MODULES_PAGE_LIMIT = 50; -export const modulesList = async ({ search, visibility = "", page = 1 }) => { +export const modulesList = async ({ + search, + status, + visibility = "", + page = 1 +}) => { const loadingSpinner = ora("Loading Modules").start(); try { @@ -30,6 +36,10 @@ export const modulesList = async ({ search, visibility = "", page = 1 }) => { params.visibility = "Private"; } + if (status) { + params.is_archived = status === "archived"; + } + if (visibility.toLowerCase() === "public") { params.visibility = "Public"; } @@ -121,3 +131,54 @@ export const modulesGet = async (id) => { `Module Details: ${formatUrlPath(host)}/dashboard/catalogs/${module.id}` ); }; + +export const modulesArchive = async (id, unarchive = false) => { + const loadingSpinner = ora("Preparing request").start(); + + const moduleResponse = await apiClient.get({ + path: `/v1/catalog/module/${id}` + }); + + loadingSpinner.stop(); + + if (!moduleResponse.ok) { + if (moduleResponse.status === 404) { + invalid(`Cannot find requested module with id ${id}.`); + } else { + invalid("Unable to get module. Please login and try again."); + } + + return; + } + + const verb = unarchive ? "unarchive" : "archive"; + + const module = await moduleResponse.json(); + + // Verify that the user understands which organization the modules are being published to. + const { ok } = await inquirer.prompt({ + message: `Are you sure you want to ${verb} module: ${module.title}?`, + name: "ok", + type: "input", + default: "y/n" + }); + + if (ok.trim().toLowerCase() !== "y") { + invalid(`Cancelling operation. No module has been ${verb}d.`); + return; + } + + const archivingSpinner = ora("Pending request").start(); + + const archiveResponse = await apiClient.post({ + path: `/v1/catalog/module/${id}/${verb}` + }); + + archivingSpinner.stop(); + + if (archiveResponse.ok) { + valid(`Module: ${module.title} ${verb}d.`); + } else { + invalid(`Unable to ${verb} module: ${module.title}.`); + } +}; From 11bfdfee8202b6dd44affe4379dadc318a692eb6 Mon Sep 17 00:00:00 2001 From: taylor-cb <146020288+taylor-cb@users.noreply.github.com> Date: Wed, 31 Jan 2024 08:58:44 -0700 Subject: [PATCH 6/6] PLAT-13541: Adjusting based on feedback from product (#1080) --- scripts/info.js | 5 +++++ scripts/modules.js | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/info.js b/scripts/info.js index 831ac0c71..2fbca8c2f 100644 --- a/scripts/info.js +++ b/scripts/info.js @@ -12,6 +12,11 @@ export const info = async () => { const body = await response.json(); + const organization = body.organization; + delete body.organization; section("Current User:"); console.table(body); + + section("Organization:"); + console.table(organization); }; diff --git a/scripts/modules.js b/scripts/modules.js index 65760bb06..32bff0cfa 100644 --- a/scripts/modules.js +++ b/scripts/modules.js @@ -124,7 +124,10 @@ export const modulesGet = async (id) => { section(`Description: \n${module.description}`); section(`ID: \n${module.id}`); section(`Slug: \n${module.slug}`); - section(`Visibility: \n${module.visibility}`); + section(`Public/Private: \n${module.visibility}`); + section( + `Published/Archived: \n${!module.is_archived ? "Published" : "Archived"}` + ); const host = configFile.get(HOST_CONFIG_NAME) || DEFAULT_HOST; section(