diff --git a/README.md b/README.md index fb7e7e2e..2437762a 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,16 @@ custom: - The Datadog Lambda Extension is now the default mechanism for transmitting telemetry to Datadog. +## Working with serverless-plugin-warmup +This library is compatible at best effort with [serverless-plugin-warmup](https://github.com/juanjoDiaz/serverless-plugin-warmup). If you want to exclude the warmer function from Datadog, use the `exclude` feature of this library. + +To properly package your application, this plugin *must* be listed _after_ `serverless-plugin-warmup` in your `serverless.yml` file: +```yaml +plugins: + - serverless-plugin-warmup + - serverless-plugin-datadog +``` + ## Opening Issues If you encounter a bug with this package, let us know by filing an issue! Before opening a new issue, please search the existing issues to avoid duplicates. diff --git a/src/index.spec.ts b/src/index.spec.ts index 485bb3a4..0c828cc7 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -84,7 +84,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -134,7 +134,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -181,7 +181,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -230,7 +230,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -275,7 +275,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -321,7 +321,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -374,7 +374,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -422,7 +422,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -470,7 +470,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -518,7 +518,7 @@ describe("ServerlessPlugin", () => { }; const plugin = new ServerlessPlugin(serverless, {}); - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); expect(serverless).toMatchObject({ service: { functions: { @@ -578,7 +578,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -620,7 +620,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -660,7 +660,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -700,7 +700,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -739,7 +739,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -783,7 +783,7 @@ describe("ServerlessPlugin", () => { const plugin = new ServerlessPlugin(serverless, {}); let threwError: boolean = false; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -822,7 +822,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { @@ -869,7 +869,7 @@ describe("ServerlessPlugin", () => { const plugin = new ServerlessPlugin(serverless, {}); let threwError: boolean = false; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; } @@ -909,7 +909,7 @@ describe("ServerlessPlugin", () => { const plugin = new ServerlessPlugin(serverless, {}); let threwError: boolean = false; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; } @@ -947,7 +947,7 @@ describe("ServerlessPlugin", () => { let threwError: boolean = false; let thrownErrorMessage: string | undefined; try { - await plugin.hooks["after:package:initialize"](); + await plugin.hooks["before:package:createDeploymentArtifacts"](); } catch (e) { threwError = true; if (e instanceof Error) { diff --git a/src/index.ts b/src/index.ts index c5237ab9..dd85ec9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -68,7 +68,7 @@ module.exports = class ServerlessPlugin { "after:datadog:generate:init": this.beforePackageFunction.bind(this), "after:deploy:function:packageFunction": this.afterPackageFunction.bind(this), "after:package:createDeploymentArtifacts": this.afterPackageFunction.bind(this), - "after:package:initialize": this.beforePackageFunction.bind(this), + "before:package:createDeploymentArtifacts": this.beforePackageFunction.bind(this), "after:package:compileFunctions": this.afterPackageCompileFunctions.bind(this), "before:deploy:function:packageFunction": this.beforePackageFunction.bind(this), "before:offline:start:init": this.beforePackageFunction.bind(this),