Skip to content

Commit

Permalink
Merge branch 'master' into maorba/feature/mapps_local_repository_token
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
  • Loading branch information
maorb-dev committed Oct 26, 2023
2 parents a3ac61f + 9373c1d commit 33b7bdd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/commands/code/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ import { AuthenticatedCommand } from 'commands-base/authenticated-command';
import { APP_VERSION_ID_TO_ENTER } from 'consts/messages';
import { DynamicChoicesService } from 'services/dynamic-choices-service';
import { getAppVersionDeploymentStatus } from 'services/push-service';
import { getMondayCodeBuild } from 'src/services/app-builds-service';
import { HttpError } from 'types/errors';
import { AppVersionDeploymentStatus } from 'types/services/push-service';
import logger from 'utils/logger';

const printDeploymentStatus = (appVersionId: number, deploymentStatus: AppVersionDeploymentStatus) => {
const printDeploymentStatus = (
appVersionId: number,
deploymentStatus: Pick<AppVersionDeploymentStatus, 'deployment' | 'status' | 'error'>,
) => {
const { deployment, status, error } = deploymentStatus;
const url = deployment?.url || 'none';
const liveUrl = deployment?.liveUrl;
const errorMessage: string | undefined = error?.message;
const tableData = {
id: appVersionId,
status,
url,
...(liveUrl && { liveUrl }),
...(errorMessage && { errorMessage }),
};

Expand Down Expand Up @@ -47,6 +53,12 @@ export default class Status extends AuthenticatedCommand {
try {
this.preparePrintCommand(this, { appVersionId });
const deploymentStatus = await getAppVersionDeploymentStatus(appVersionId);
const mondayCodeRelease = await getMondayCodeBuild(appVersionId);

if (deploymentStatus.deployment) {
deploymentStatus.deployment.liveUrl = mondayCodeRelease?.data?.liveUrl;
}

printDeploymentStatus(appVersionId, deploymentStatus);
} catch (error: unknown) {
if (error instanceof HttpError && error.code === StatusCodes.NOT_FOUND) {
Expand Down
5 changes: 5 additions & 0 deletions src/consts/app-release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum AppReleaseCategory {
View = 'view',
Integration = 'integration',
MondayCode = 'monday_code',
}
6 changes: 6 additions & 0 deletions src/services/app-builds-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { appReleasesUrl } from 'consts/urls';
import { execute } from 'services/api-service';
import { AppRelease, AppReleasesResponse, appReleasesSchema } from 'services/schemas/app-releases-schema';
import { AppReleaseCategory } from 'src/consts/app-release';
import { HttpError } from 'types/errors';
import { AppVersionId } from 'types/general';
import { HttpMethodTypes } from 'types/services/api-service';
Expand All @@ -27,3 +28,8 @@ export const listAppBuilds = async (appVersionId: AppVersionId): Promise<Array<A
throw new Error('Failed to list app versions.');
}
};

export const getMondayCodeBuild = async (appVersionId: AppVersionId): Promise<AppRelease | undefined> => {
const appReleases = await listAppBuilds(appVersionId);
return appReleases.find(release => release.category === AppReleaseCategory.MondayCode);
};
1 change: 1 addition & 0 deletions src/services/schemas/push-service-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const appVersionDeploymentStatusSchema = z
.object({
url: z.string(),
latestUrl: z.string(),
liveUrl: z.string().optional(),
})
.optional(),
error: z
Expand Down

0 comments on commit 33b7bdd

Please sign in to comment.