Skip to content

Commit

Permalink
Updated project hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
MoizAdnan committed Oct 5, 2023
1 parent 7ab464b commit 21bdbe9
Show file tree
Hide file tree
Showing 12 changed files with 417 additions and 406 deletions.
2 changes: 1 addition & 1 deletion packages/client-core/src/common/services/ProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const ProjectService = {

// restricted to admin scope
uploadProject: async (data: ProjectBuildUpdateItemType) => {
const result = await API.instance.client.service(projectPath).update({
const result = await API.instance.client.service(projectPath).update('', {
sourceURL: data.sourceURL,
destinationURL: data.destinationURL,
name: data.name,
Expand Down
3 changes: 2 additions & 1 deletion packages/engine/src/schemas/projects/project-build.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const ProjectBuildUpdateItemSchema = Type.Object(
sourceURL: Type.String(),
destinationURL: Type.String(),
name: Type.String(),
reset: Type.Boolean(),
needsRebuild: Type.Optional(Type.Boolean()),
reset: Type.Optional(Type.Boolean()),
commitSHA: Type.String(),
sourceBranch: Type.String(),
updateType: StringEnum(projectUpdateTypes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ProjectGithubPushService implements ServiceInterface<void> {
}

async patch(id: NullableId, data: any, params?: RootParams): Promise<void> {
const project = await this.app.service(projectPath)._get(id!)
const project = await this.app.service(projectPath).get(id!)
return pushProjectToGithub(this.app, project, params!.user!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const cleanup = async (app: Application) => {
const project1Dir = path.resolve(appRootPath.path, `packages/projects/projects/${newProjectName1}/`)
deleteFolderRecursive(project1Dir)
try {
await app.service(projectPath)._remove(null, { query: { name: newProjectName1 } })
await app.service(projectPath).remove(null, { query: { name: newProjectName1 } })
} catch (e) {
//
}
Expand Down
20 changes: 10 additions & 10 deletions packages/server-core/src/projects/project/project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const updateBuilder = async (
}

if (data.updateProjects) {
await Promise.all(data.projectsToUpdate.map((project) => app.service(projectPath).update(project, null, params)))
await Promise.all(data.projectsToUpdate.map((project) => app.service(projectPath).update('', project, params)))
}

const helmSettingsResult = await app.service(helmSettingPath).find()
Expand Down Expand Up @@ -1190,7 +1190,7 @@ export async function getDirectoryArchiveJobBody(
}

export const createOrUpdateProjectUpdateJob = async (app: Application, projectName: string): Promise<void> => {
const projectData = (await app.service(projectPath)._find({
const projectData = (await app.service(projectPath).find({
query: {
name: projectName,
$limit: 1
Expand Down Expand Up @@ -1246,7 +1246,7 @@ export const removeProjectUpdateJob = async (app: Application, projectName: stri

export const checkProjectAutoUpdate = async (app: Application, projectName: string): Promise<void> => {
let commitSHA
const projectData = (await app.service(projectPath)._find({
const projectData = (await app.service(projectPath).find({
query: {
name: projectName,
$limit: 1
Expand Down Expand Up @@ -1275,6 +1275,7 @@ export const checkProjectAutoUpdate = async (app: Application, projectName: stri
}
if (commitSHA)
await app.service(projectPath).update(
'',
{
sourceURL: project.sourceRepo!,
destinationURL: project.repositoryPath,
Expand All @@ -1285,7 +1286,6 @@ export const checkProjectAutoUpdate = async (app: Application, projectName: stri
updateType: project.updateType,
updateSchedule: project.updateSchedule!
},
null,
{ user: user }
)
}
Expand Down Expand Up @@ -1413,7 +1413,7 @@ export const updateProject = async (
deleteFolderRecursive(projectDirectory)
}

const projectResult = (await app.service(projectPath)._find({
const projectResult = (await app.service(projectPath).find({
query: {
name: projectName
}
Expand Down Expand Up @@ -1463,7 +1463,7 @@ export const updateProject = async (
const projectConfig = getProjectConfig(projectName) ?? {}

// when we have successfully re-installed the project, remove the database entry if it already exists
const existingProjectResult = (await app.service(projectPath)._find({
const existingProjectResult = (await app.service(projectPath).find({
query: {
name: {
$like: projectName
Expand All @@ -1480,7 +1480,7 @@ export const updateProject = async (

const returned = !existingProject
? // Add to DB
await app.service(projectPath)._create(
await app.service(projectPath).create(
{
id: v4(),
name: projectName,
Expand All @@ -1498,7 +1498,7 @@ export const updateProject = async (
},
params || {}
)
: await app.service(projectPath)._patch(existingProject.id, {
: await app.service(projectPath).patch(existingProject.id, {
commitSHA,
commitDate: toDateTimeSql(commitDate),
sourceRepo: data.sourceURL,
Expand All @@ -1518,7 +1518,7 @@ export const updateProject = async (
}

if (returned.name !== projectName)
await app.service(projectPath)._patch(existingProject!.id, {
await app.service(projectPath).patch(existingProject!.id, {
name: projectName
})

Expand All @@ -1529,7 +1529,7 @@ export const updateProject = async (
await git.raw(['lfs', 'fetch', '--all'])
await git.push('destination', branchName, ['-f', '--tags'])
const { commitSHA, commitDate } = await getCommitSHADate(projectName)
await app.service(projectPath)._patch(returned.id, {
await app.service(projectPath).patch(returned.id, {
commitSHA,
commitDate: toDateTimeSql(commitDate)
})
Expand Down

0 comments on commit 21bdbe9

Please sign in to comment.