Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add liveUrl to code:status #49

Merged
merged 3 commits into from
Oct 26, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mondaycom/apps-cli",
"version": "1.3.4",
"version": "1.3.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maorb-dev also have a pr, try to talk to him to mange the deployment.

"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
"author": "monday.com Apps Team",
"type": "module",
Expand Down
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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can remove the latestUrl already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if it came back from apps-backend it will throw an error

liveUrl: z.string().optional(),
})
.optional(),
error: z
Expand Down
Loading