Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { HAS_ASKED_OPT_IN_NAME } from "./scripts/analytics/config.js";
import { EVENT } from "./scripts/analytics/constants.js";
import { askOptIn } from "./scripts/analytics/scripts.js";
import { sentryMonitoring } from "./scripts/utils/sentry.js";
import { setModuleDetails } from "./scripts/setModuleDetails.js";

const pkg = JSON.parse(
fs.readFileSync(new URL("package.json", import.meta.url), "utf8")
Expand Down Expand Up @@ -303,7 +304,11 @@ demo`;
"--visibility": String,
"--status": String,
"--page": String,
"--unarchive": Boolean
"--unarchive": Boolean,
"--name": String,
"--description": String,
"--acceptance-criteria": String,
"--search-description": String
});

let id;
Expand Down Expand Up @@ -338,6 +343,24 @@ demo`;
await modulesGet(id);
break;

case "set":
id = args._[2];

if (!id) {
return invalid(
"Please provide the id of the module to change info for, i.e. modules set <123>"
);
}

await setModuleDetails(id,
args["--name"],
args["--description"],
args["--acceptance-criteria"],
args["--search-description"]
);

break;

case "archive":
id = args._[2];
if (!id) {
Expand Down Expand Up @@ -409,6 +432,9 @@ Commands available:
demo Generate a local React Native and Django demo app
add Install a module in the demo app
remove Remove a module from the demo app
get Get information about a module by id
set Set information about a module by id such as name, description, acceptance criteria, and search description. The new values must be wrapped in quotes "<value>".
create Create a new module of a given type
create Create a new module of a given type
commit Update an existing module from the demo source code
init Initialize a blank modules repository
Expand Down Expand Up @@ -447,6 +473,13 @@ Install one or modules to your demo app:
Remove one or modules from your demo app:
cb remove <module-name> <module-name-2>

Get information about a module by id:
cb modules get <module-id>

Set information about a module by id such as name, description, acceptance criteria, and search description:
cb modules set <module-id> --name "<name>" --description "<description>" --acceptance-criteria "<acceptance-criteria>" --search-description "<search-description>"
The new values must be wrapped in quotes "<value>".

Install modules from other directory:
cb add --source ../other-repository <module-name>

Expand Down
42 changes: 42 additions & 0 deletions scripts/setModuleDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import ora from "ora";
import { invalid, valid } from "../utils.js";
import { apiClient } from "./utils/apiClient.js";

export const setModuleDetails = async (
id, name, description, searchDescription, acceptanceCriteria
) => {
const patchBody = {};

if (name) {
patchBody.title = name;
}
if (description) {
patchBody.description = description;
}
if (searchDescription) {
patchBody.search_description = searchDescription;
}
if (acceptanceCriteria) {
patchBody.acceptance_criteria = acceptanceCriteria;
}
if (Object.keys(patchBody).length === 0) {
invalid("No module details were provided for the update. To correctly save the new value, please enclose it in double quotes. For example, use --description \"Your detailed description here\".");
return;
}
const patchSpinner = ora(
"Updating module details."
).start();

const patchResponse = await apiClient.patch({
path: `/v1/catalog/module/${id}`,
body: patchBody
}).then(patchSpinner.stop());

if (patchResponse.ok) {
valid(`Module details updated for ${id}.`);
} else if (patchResponse.status === 404) {
invalid(`Cannot find requested module with id ${id}.`);
} else {
invalid("Unable to update modules details. Please try again later.");
}
};