Skip to content

Commit

Permalink
feat(command): add missing builds of commit command & download artifa…
Browse files Browse the repository at this point in the history
…ct command params description and order
  • Loading branch information
Alnyli07 committed Jan 16, 2024
1 parent d1049e2 commit a34fc4c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getBranches,
getWorkflows,
getCommits,
getBuildsOfCommit,
getEnterpriseProfiles,
getEnterpriseAppVersions,
publishEnterpriseAppVersion,
Expand Down Expand Up @@ -46,6 +47,7 @@ const CommandTypes = {
LIST_BUILD_PROFILE_BRANCHES: 'listBuildProfileBranches',
LIST_BUILD_PROFILE_WORKFLOWS: 'listBuildProfileWorkflows',
LIST_BUILD_PROFILE_COMMITS: 'listBuildProfileCommits',
LIST_BUILD_PROFILE_BUILDS_OF_COMMIT: 'listBuildProfileBuildsOfCommit',
LIST_DISTRIBUTION_PROFILES: 'listDistributionProfiles',
BUILD: 'build',
DOWNLOAD: 'download',
Expand Down Expand Up @@ -116,6 +118,17 @@ const Commands = [
}
]
},
{
command: CommandTypes.LIST_BUILD_PROFILE_BUILDS_OF_COMMIT,
description: 'Get list of builds of a commit',
params: [
{
name: 'commitId',
description: 'Commit ID',
type: CommandParameterTypes.STRING
}
]
},
{
command: CommandTypes.LIST_DISTRIBUTION_PROFILES,
description: 'Get list of distribution profiles',
Expand Down Expand Up @@ -155,15 +168,15 @@ const Commands = [
required: false
},
{
name: 'buildId',
description: 'Build ID of your branch. This can be retrieved from profile list',
name: 'commitId',
description: 'Commit ID of your build',
type: CommandParameterTypes.STRING
},
{
name: 'commitId',
description: 'Commit ID of your build',
name: 'buildId',
description: 'Build ID of your commit. This can be retrieved from builds of commit',
type: CommandParameterTypes.STRING
}
},
]
},
{
Expand Down Expand Up @@ -585,6 +598,9 @@ const Commands = [
case CommandTypes.LIST_BUILD_PROFILE_COMMITS:
getCommits(params);
break;
case CommandTypes.LIST_BUILD_PROFILE_BUILDS_OF_COMMIT:
getBuildsOfCommit(params);
break;
case CommandTypes.LIST_DISTRIBUTION_PROFILES:
getDistributionProfiles(params);
break;
Expand Down
34 changes: 34 additions & 0 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,40 @@ export async function getCommits(options: { branchId: string }) {
}
}

export async function getBuildsOfCommit(options: { commitId: string }) {
try {
const commits = await axios.get(
`${API_HOSTNAME}/build/v2/commits/${options.commitId}`,
{
headers: getHeaders(),
}
);
if (commits.data.builds.length === 0) {
console.info("No builds available.");
return;
}
console.log("\n");
console.table(
commits.data.builds?.map((build: any) => ({
"Build Id": build.id,
Hash: build.hash,

"Has Warning": !!build.hasWarning,
Status: build.status,
"Start Date": build.startDate
? moment(build.startDate).calendar()
: "Could not find date",
"End Date": build.endDate
? moment(build.endDate).calendar()
: "Could not find date",
}))
);
return commits.data;
} catch (error) {
handleError(error);
}
}

export async function startBuild(options: { profileId: string, branch: string,workflow: string }) {
const spinner = ora(`Try to start a new build with ${options.workflow}`).start();
try {
Expand Down

0 comments on commit a34fc4c

Please sign in to comment.