Skip to content

Commit

Permalink
fix: compatibility with core-cloud interactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Jun 21, 2022
1 parent 6093ee9 commit ead89ba
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export interface Events extends LoggerEvents {
serviceName: string
devMode: boolean
hotReload: boolean
localMode: boolean
force: boolean
forceBuild: boolean
skipDependencies: boolean
Expand Down
17 changes: 13 additions & 4 deletions core/src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ export async function processModules({
emoji = "fire"
prefix = `Hot reload-enabled deployment`
} else {
if (event.devMode) {
// local mode always takes precedence over dev mode
if (event.localMode) {
emoji = "left_right_arrow"
prefix = `Local-mode deployment`
} else if (event.devMode) {
emoji = "zap"
prefix = `Dev-mode deployment`
} else {
Expand Down Expand Up @@ -338,6 +342,10 @@ export interface CloudEventHandlerCommonParams {
log: LogEntry
}

/*
* TODO: initialize devModeServiceNames/hotReloadServiceNames/localModeServiceNames
* depending on the corresponding deployment flags. See class DeployCommand for details.
*/
export const cloudEventHandlers = {
buildRequested: async (params: CloudEventHandlerCommonParams & { request: Events["buildRequested"] }) => {
const { garden, graph, log } = params
Expand Down Expand Up @@ -366,14 +374,14 @@ export const cloudEventHandlers = {
skipRuntimeDependencies: params.request.skipDependencies,
devModeServiceNames: [],
hotReloadServiceNames: [],
localModeServiceNames: [],
})
})
},
deployRequested: async (params: CloudEventHandlerCommonParams & { request: Events["deployRequested"] }) => {
const { garden, graph, log } = params
const { serviceName, force, forceBuild } = params.request

const deployTask = new DeployTask({
return new DeployTask({
garden,
log,
graph,
Expand All @@ -384,8 +392,8 @@ export const cloudEventHandlers = {
skipRuntimeDependencies: params.request.skipDependencies,
devModeServiceNames: [],
hotReloadServiceNames: [],
localModeServiceNames: [],
})
return deployTask
},
taskRequested: async (params: CloudEventHandlerCommonParams & { request: Events["taskRequested"] }) => {
const { garden, graph, log } = params
Expand All @@ -397,6 +405,7 @@ export const cloudEventHandlers = {
task: graph.getTask(taskName),
devModeServiceNames: [],
hotReloadServiceNames: [],
localModeServiceNames: [],
force,
forceBuild,
})
Expand Down
24 changes: 24 additions & 0 deletions core/test/unit/src/enterprise/event-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ describe("cloudEventHandlers", () => {
forceBuild: false,
devMode: false,
hotReload: false,
localMode: false,
skipDependencies: true,
},
})
expect(deployTask["devModeServiceNames"]).to.eql([])
expect(deployTask["hotReloadServiceNames"]).to.eql([])
expect(deployTask["localModeServiceNames"]).to.eql([])
expect(deployTask.service.name).to.eql("service-a")
})

Expand All @@ -77,10 +80,31 @@ describe("cloudEventHandlers", () => {
forceBuild: false,
devMode: true,
hotReload: false,
localMode: false,
skipDependencies: true,
},
})
expect(deployTask["service"].name).to.eql("service-a")
// todo
// expect(deployTask["devModeServiceNames"]).to.eql(["service-a"])
})

it("should return a local-mode deploy task for the requested service", async () => {
const deployTask = await cloudEventHandlers.deployRequested({
...params,
request: {
serviceName: "service-a",
force: false,
forceBuild: false,
devMode: false,
hotReload: false,
localMode: true,
skipDependencies: true,
},
})
expect(deployTask["service"].name).to.eql("service-a")
// todo
// expect(deployTask["localModeServiceNames"]).to.eql(["service-a"])
})
})

Expand Down

0 comments on commit ead89ba

Please sign in to comment.