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

feat: Update deployProject to support v3 #230

Merged
merged 5 commits into from
Jan 30, 2025
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
14 changes: 13 additions & 1 deletion api/__tests__/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ describe('api/projects', () => {

describe('deployProject', () => {
const buildId = 1;
it('should call http correctly', async () => {
it('should call the v1 api when useNewDeployApi is false or omitted', async () => {
await deployProject(accountId, projectName, buildId);
expect(http.post).toHaveBeenCalledTimes(1);
expect(http.post).toHaveBeenCalledWith(accountId, {
Expand All @@ -342,6 +342,18 @@ describe('api/projects', () => {
},
});
});

it('should call the v3 api when useNewDeployApi is true', async () => {
await deployProject(accountId, projectName, buildId, true);
expect(http.post).toHaveBeenCalledTimes(1);
expect(http.post).toHaveBeenCalledWith(accountId, {
url: `dfs/deploy/v3/deploys/queue/async`,
data: {
projectName,
targetBuildId: buildId,
},
});
});
});

describe('getDeployStatus', () => {
Expand Down
13 changes: 12 additions & 1 deletion api/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
const PROJECTS_API_PATH = 'dfs/v1/projects';
const DEVELOPER_FILE_SYSTEM_PATH = 'dfs/v1';
const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
const PROJECTS_DEPLOY_API_PATH_V3 = 'dfs/deploy/v3';
const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
const MIGRATIONS_API_PATH = 'dfs/migrations/v1';
Expand Down Expand Up @@ -185,8 +186,18 @@ export function getBuildStructure(
export function deployProject(
accountId: number,
projectName: string,
buildId: number
buildId: number,
useNewDeployApi = false
): HubSpotPromise<ProjectDeployResponse> {
if (useNewDeployApi) {
return http.post<ProjectDeployResponse>(accountId, {
url: `${PROJECTS_DEPLOY_API_PATH_V3}/deploys/queue/async`,
data: {
projectName,
targetBuildId: buildId,
},
});
}
return http.post<ProjectDeployResponse>(accountId, {
url: `${PROJECTS_DEPLOY_API_PATH}/deploys/queue/async`,
data: {
Expand Down