diff --git a/core/src/events.ts b/core/src/events.ts index 83c0a123556..5e55795b1a0 100644 --- a/core/src/events.ts +++ b/core/src/events.ts @@ -276,6 +276,7 @@ export interface Events extends LoggerEvents { serviceName: string devMode: boolean hotReload: boolean + localMode: boolean force: boolean forceBuild: boolean skipDependencies: boolean diff --git a/core/src/process.ts b/core/src/process.ts index aff0a78e1c1..4005a9fa04c 100644 --- a/core/src/process.ts +++ b/core/src/process.ts @@ -276,9 +276,13 @@ 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 = "zap" prefix = `Dev-mode deployment` + } else if (event.devMode) { + emoji = "left_right_arrow" + prefix = `Local-mode deployment` } else { emoji = "rocket" prefix = "Deployment" @@ -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 @@ -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, @@ -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 @@ -397,6 +405,7 @@ export const cloudEventHandlers = { task: graph.getTask(taskName), devModeServiceNames: [], hotReloadServiceNames: [], + localModeServiceNames: [], force, forceBuild, }) diff --git a/core/test/unit/src/enterprise/event-handlers.ts b/core/test/unit/src/enterprise/event-handlers.ts index 37698c0677e..f888616b221 100644 --- a/core/test/unit/src/enterprise/event-handlers.ts +++ b/core/test/unit/src/enterprise/event-handlers.ts @@ -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") }) @@ -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"]) }) })