serverless-plugin-datadog 3.2.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/README.md +50 -59
  2. package/dist/package.json +11 -3
  3. package/dist/src/env.d.ts +7 -3
  4. package/dist/src/env.d.ts.map +1 -1
  5. package/dist/src/env.js +34 -2
  6. package/dist/src/env.js.map +1 -1
  7. package/dist/src/git-metadata/interfaces.d.ts +10 -0
  8. package/dist/src/git-metadata/interfaces.d.ts.map +1 -0
  9. package/dist/src/git-metadata/interfaces.js +43 -0
  10. package/dist/src/git-metadata/interfaces.js.map +1 -0
  11. package/dist/src/git.d.ts +8 -0
  12. package/dist/src/git.d.ts.map +1 -0
  13. package/dist/src/git.js +115 -0
  14. package/dist/src/git.js.map +1 -0
  15. package/dist/src/helpers/apikey.d.ts +13 -0
  16. package/dist/src/helpers/apikey.d.ts.map +1 -0
  17. package/dist/src/helpers/apikey.js +74 -0
  18. package/dist/src/helpers/apikey.js.map +1 -0
  19. package/dist/src/helpers/errors.d.ts +3 -0
  20. package/dist/src/helpers/errors.d.ts.map +1 -0
  21. package/dist/src/helpers/errors.js +7 -0
  22. package/dist/src/helpers/errors.js.map +1 -0
  23. package/dist/src/helpers/interfaces.d.ts +20 -0
  24. package/dist/src/helpers/interfaces.d.ts.map +1 -0
  25. package/dist/src/helpers/interfaces.js +3 -0
  26. package/dist/src/helpers/interfaces.js.map +1 -0
  27. package/dist/src/helpers/retry.d.ts +3 -0
  28. package/dist/src/helpers/retry.d.ts.map +1 -0
  29. package/dist/src/helpers/retry.js +39 -0
  30. package/dist/src/helpers/retry.js.map +1 -0
  31. package/dist/src/helpers/tags.d.ts +29 -0
  32. package/dist/src/helpers/tags.d.ts.map +1 -0
  33. package/dist/src/helpers/tags.js +50 -0
  34. package/dist/src/helpers/tags.js.map +1 -0
  35. package/dist/src/helpers/upload.d.ts +45 -0
  36. package/dist/src/helpers/upload.d.ts.map +1 -0
  37. package/dist/src/helpers/upload.js +70 -0
  38. package/dist/src/helpers/upload.js.map +1 -0
  39. package/dist/src/helpers/utils.d.ts +31 -0
  40. package/dist/src/helpers/utils.d.ts.map +1 -0
  41. package/dist/src/helpers/utils.js +115 -0
  42. package/dist/src/helpers/utils.js.map +1 -0
  43. package/dist/src/index.d.ts.map +1 -1
  44. package/dist/src/index.js +75 -16
  45. package/dist/src/index.js.map +1 -1
  46. package/dist/src/layer.d.ts +10 -1
  47. package/dist/src/layer.d.ts.map +1 -1
  48. package/dist/src/layer.js +39 -5
  49. package/dist/src/layer.js.map +1 -1
  50. package/dist/src/layers-gov.json +20 -14
  51. package/dist/src/layers.json +210 -147
  52. package/dist/src/serverless_monitors.js +3 -3
  53. package/dist/src/serverless_monitors.js.map +1 -1
  54. package/dist/src/source-code-integration.d.ts +12 -0
  55. package/dist/src/source-code-integration.d.ts.map +1 -0
  56. package/dist/src/source-code-integration.js +76 -0
  57. package/dist/src/source-code-integration.js.map +1 -0
  58. package/package.json +11 -3
package/README.md CHANGED
@@ -31,32 +31,33 @@ Each version of the plugin is published with a [specific set of versions of the
31
31
 
32
32
  To further configure your plugin, use the following custom parameters in your `serverless.yml`:
33
33
 
34
- | Parameter | Description |
35
- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
- | `flushMetricsToLogs` | Send custom metrics by using logs with the Datadog Forwarder Lambda function (recommended). Defaults to `true`. If you disable this parameter, it's required to set `apiKey` (or `apiKMSKey` if encrypted). `flushMetricsToLogs` is ignored when `addExtension` is true. |
37
- | `site` | Set which Datadog site to send data, this is only used when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`. |
38
- | `apiKey` | Datadog API Key, only needed when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Defining `apiKey` will add the Datadog API key directly to your Lambda functions as an environment variable. For more information about getting a Datadog API key, see the [API key documentation][3]. |
39
- | `apiKMSKey` | Datadog API Key encrypted using KMS. Use this parameter in place of `apiKey` when `flushMetricsToLogs` is `false` or `addExtension` is `true`, and you are using KMS encryption. Defining `apiKMSKey` will add the Datadog API Key directly to your Lambda functions as an environment variable. |
40
- | `captureLambdaPayload` | (Experimental) This optional setting configures Datadog ingestion for incoming and outgoing AWS Lambda payloads. Function request and response values are added as part of outgoing APM spans sent to Datadog, and require Datadog APM to be configured on your function. Obfuscation of fields in the Lambda payload is available via the `replace_tags` block within `apm_config` settings in [datadog.yaml.][12] Defaults to `false`. |
41
- | `monitorsApiKey` | Datadog API Key. Only needed when using plugin to create monitors for your functions and when `monitors` is defined. Separate from `apiKey` with your function, `monitorsApiKey` is only used to create monitors through the Datadog Monitors API. You may use the same API key for both `apiKey` and `monitorsApiKey`. |
42
- | `monitorsAppKey` | Datadog Application Key. Only needed when using plugin to create monitors for your function and when `monitors` is defined. |
43
- | `addLayers` | Whether to install the Datadog Lambda library as a layer. Defaults to `true`. Set to `false` when you plan to package the Datadog Lambda library to your function's deployment package on your own so that you can install a specific version of the Datadog Lambda library ([Python][4] or [Node.js][5]). |
44
- | `addExtension` | Whether to install the Datadog Lambda Extension as a layer. Defaults to `false`. When enabled, it's required to set the `apiKey` (or `apiKMSKey`) parameter. Learn more about the Lambda Extension Layer [here][8]. Note: AWS only supports Lambda Extensions for [certain runtimes][9]. |
45
- | `logLevel` | The log level, set to `DEBUG` for extended logging. |
46
- | `enableXrayTracing` | Set `true` to enable X-Ray tracing on the Lambda functions and API Gateway integrations. Defaults to `false`. |
47
- | `enableDDTracing` | Enable Datadog tracing on the Lambda function. Note: This applies only to integrations using the Datadog Extension. Defaults to `true`. |
48
- | `enableDDLogs` | Enable Datadog log collection for the Lambda function. Note: This setting has no effect on logs sent via the Datadog Forwarder. Defaults to `true`. |
49
- | `subscribeToApiGatewayLogs` | Enable automatic subscription of the Datadog Forwarder to API Gateway log groups. Defaults to `true`. |
50
- | `subscribeToHttpApiLogs` | Enable automatic subscription of the Datadog Forwarder to Http-api log groups. Defaults to `true`. |
51
- | `subscribeToWebsocketLogs` | Enable automatic subscription of the Datadog Forwarder to Websocket log groups. Defaults to `true`. |
52
- | `forwarderArn` | Setting this parameter subscribes the given Datadog forwarder to the Lambda functions’ CloudWatch log groups. Required when `enableDDTracing` is set to `true` unless the subscription is otherwise applied. For example, if a Datadog Forwarder subscription is applied via Datadog's AWS Integration, then `forwarderArn` is not required. |
53
- | `integrationTesting` | Set `true` when running integration tests. This will bypass the validation of the Forwarder ARN and the addition of Datadog Monitor output links. Defaults to `false`. |
54
- | `enableTags` | When set, automatically tag the Lambda functions with the `service` and `env` tags using the `service` and `stage` values from the serverless application definition. It does NOT override if a `service` or `env` tag already exists. Defaults to `true`. |
55
- | `injectLogContext` | When set, the lambda layer will automatically patch console.log with Datadog's tracing ids. Defaults to `true`. |
56
- | `exclude` | When set, this plugin will ignore all specified functions. Use this parameter if you have any functions that should not include Datadog functionality. Defaults to `[]`. |
57
- | `enabled` | When set to false, the Datadog plugin will stay inactive. Defaults to `true`. You can control this option using an environment variable, e.g. `enabled: ${strToBool(${env:DD_PLUGIN_ENABLED, true})}`, to activate/deactivate the plugin during deployment. Alternatively, you can also use the value passed in through `--stage` to control this option, [see example.](#disable-plugin-for-particular-environment) |
58
- | `monitors` | When defined, the Datadog plugin will configure monitors for the deployed function. You must also have `monitorsApiKey` and `monitorsAppKey` defined. To learn how to define monitors, see [To Enable and Configure a Recommended Serverless Monitor.](#to-enable-and-configure-a-recommended-serverless-monitor) |
59
- | `customHandler` | When set, the specified handler is set as the handler for all the functions. By deafult, the handler is set to `/opt/nodejs/node_modules/datadog-lambda-js/handler.handler` if `addLayers` is set to `true`, or `node_modules/datadog-lambda-js/dist/handler.handler` if `addLayers` is set to `false` |
34
+ | Parameter | Description |
35
+ | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
+ | `flushMetricsToLogs` | Send custom metrics by using logs with the Datadog Forwarder Lambda function (recommended). Defaults to `true`. To use an encrypted key, set `apiKMSKey` or `apiKeySecretArn` in the configuration. `flushMetricsToLogs` is ignored when `addExtension` is true. |
37
+ | `site` | Set which Datadog site to send data to. This is only used when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`. |
38
+ | `apiKey` | Datadog API key. Required when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Defining `apiKey` adds the Datadog API key directly to your Lambda functions as an environment variable. For more information about getting a Datadog API key, see the [API key documentation][3]. Can also be set via the `DATADOG_API_KEY` environment variable. |
39
+ | `appKey` | Datadog app key. Only needed when the `monitors` field is defined. Can also be set via the `DATADOG_APP_KEY` environment variable. |
40
+ | `apiKeySecretArn` | An alternative to using the `apiKey` field. The ARN of the secret storing the Datadog API key in AWS Secrets Manager. Use this parameter if you're storing your secrets in AWS Secrets Manager, and when `flushMetricsToLogs` is `false` or `addExtension` is `true`. If set, remember to add the `secretsmanager:GetSecretValue` permission to the Lambda execution role. |
41
+ | `apiKMSKey` | An alternative to using the `apiKey` field. Datadog API key encrypted using KMS. Use this parameter if you're storing your secrets with KMS, and if `flushMetricsToLogs` is `false` or `addExtension` is `true`. Defining `apiKMSKey` adds the Datadog API Key directly to your Lambda functions as an environment variable. |
42
+ | `captureLambdaPayload` | (Experimental) This optional setting configures Datadog ingestion for incoming and outgoing AWS Lambda payloads. Function request and response values are added as part of outgoing APM spans sent to Datadog, and require Datadog APM to be configured on your function. You can obfuscate fields in the Lambda payload by using the `replace_tags` block within `apm_config` settings in [datadog.yaml.][12] Defaults to `false`. |
43
+ | `addLayers` | Whether to install the Datadog Lambda library as a layer. Defaults to `true`. Set to `false` when you plan to package the Datadog Lambda library to your function's deployment package on your own so that you can install a specific version of the Datadog Lambda library ([Python][4] or [Node.js][5]). |
44
+ | `addExtension` | Whether to install the Datadog Lambda Extension as a layer. Defaults to `false`. When enabled, you must set either the environment variable `DATADOG_API_KEY`, or the configuration values `apiKMSKey` or `apiKeySecretArn`. Learn more about the [Datadog Lambda Extension Layer][8] in the documentation. **Note**: AWS only supports Lambda Extensions for [certain runtimes][9]. |
45
+ | `logLevel` | The log level, set to `DEBUG` for extended logging. |
46
+ | `enableXrayTracing` | Set `true` to enable X-Ray tracing on the Lambda functions and API Gateway integrations. Defaults to `false`. |
47
+ | `enableDDTracing` | Enable Datadog tracing on the Lambda function. Note: This applies only to integrations using the Datadog Extension. Defaults to `true`. |
48
+ | `enableDDLogs` | Enable Datadog log collection for the Lambda function. Note: This setting has no effect on logs sent by the Datadog Forwarder. Defaults to `true`. |
49
+ | `enableSourceCodeIntegration` | Enable Datadog source code integration for the function. This feature links your Github repository information to the function in Datadog and allows you to view stack traces from Datadog directly in Github. For more information, see [Source Code Integration](https://docs.datadoghq.com/integrations/guide/source-code-integration). |
50
+ | `subscribeToApiGatewayLogs` | Enable automatic subscription of the Datadog Forwarder to API Gateway log groups. Defaults to `true`. |
51
+ | `subscribeToHttpApiLogs` | Enable automatic subscription of the Datadog Forwarder to HTTP API log groups. Defaults to `true`. |
52
+ | `subscribeToWebsocketLogs` | Enable automatic subscription of the Datadog Forwarder to WebSocket log groups. Defaults to `true`. |
53
+ | `forwarderArn` | Setting this parameter subscribes the given Datadog forwarder to the Lambda functions’ CloudWatch log groups. Required when `enableDDTracing` is set to `true` unless the subscription is otherwise applied. For example, if a Datadog Forwarder subscription is applied using Datadog's AWS Integration, then `forwarderArn` is not required. |
54
+ | `integrationTesting` | Set `true` when running integration tests. This bypasses the validation of the Forwarder ARN and the addition of Datadog Monitor output links. Defaults to `false`. |
55
+ | `enableTags` | When set, automatically tag the Lambda functions with the `service` and `env` tags using the `service` and `stage` values from the serverless application definition. It does NOT override if a `service` or `env` tag already exists. Defaults to `true`. |
56
+ | `injectLogContext` | When set, the Lambda layer automatically patches `console.log` with Datadog's tracing IDs. Defaults to `true`. |
57
+ | `exclude` | When set, this plugin ignores all specified functions. Use this parameter if you have any functions that should not include Datadog functionality. Defaults to `[]`. |
58
+ | `enabled` | When set to `false`, the Datadog plugin stays inactive. Defaults to `true`. You can control this option using an environment variable. For example, use `enabled: ${strToBool(${env:DD_PLUGIN_ENABLED, true})}` to activate/deactivate the plugin during deployment. Alternatively, you can also use the value passed in through `--stage` to control this option—[see example](#disable-plugin-for-particular-environment). |
59
+ | `monitors` | When defined, the Datadog plugin will configure monitors for the deployed function. Requires setting `DATADOG_API_KEY` and `DATADOG_APP_KEY` in your environment. To learn how to define monitors, see [To Enable and Configure a Recommended Serverless Monitor](#to-enable-and-configure-a-recommended-serverless-monitor). |
60
+ | `customHandler` | When set, the specified handler is set as the handler for all the functions. By default, the handler is set to `/opt/nodejs/node_modules/datadog-lambda-js/handler.handler` if `addLayers` is set to `true`, or `node_modules/datadog-lambda-js/dist/handler.handler` if `addLayers` is set to `false`. |
60
61
 
61
62
  To use any of these parameters, add a `custom` > `datadog` section to your `serverless.yml` similar to this example:
62
63
 
@@ -64,10 +65,8 @@ To use any of these parameters, add a `custom` > `datadog` section to your `serv
64
65
  custom:
65
66
  datadog:
66
67
  flushMetricsToLogs: true
67
- apiKey: "{Datadog_API_Key}"
68
+ apiKeySecretArn: "{Datadog_API_Key_Secret_ARN}"
68
69
  apiKMSKey: "{Encrypted_Datadog_API_Key}"
69
- monitorsApiKey: "{Datadog_API_Key}"
70
- monitorsAppKey: "{Datadog_Application_Key}"
71
70
  addLayers: true
72
71
  logLevel: "info"
73
72
  enableXrayTracing: false
@@ -83,6 +82,8 @@ custom:
83
82
 
84
83
  **Note**: If you use webpack, Datadog recommends using the prebuilt layers by setting `addLayers` to `true`, which is the default, and add `datadog-lambda-js` and `dd-trace` to the [externals][6] section of your webpack config.
85
84
 
85
+ **Note**: Many of the above configuration values require setting `DATADOG_API_KEY` in your environment. If you store these values in AWS Secrets Manager or AWS KMS, refer to the above options `apiKeySecretArn` and `apiKMSKey` to pull your Datadog API key from the correct location.
86
+
86
87
  ### TypeScript
87
88
 
88
89
  If you are using serverless-typescript, make sure that `serverless-datadog` is above the `serverless-typescript` entry in your `serverless.yml`. The plugin will automatically detect `.ts` files.
@@ -171,7 +172,7 @@ There are seven recommended monitors with default values pre-configured.
171
172
 
172
173
  #### To Enable and Configure a Recommended Serverless Monitor
173
174
 
174
- To create a recommended monitor, you must use its respective serverless monitor ID. Note that you must also set the `monitorApiKey` and `monitorAppKey`.
175
+ To create a recommended monitor, you must use its respective serverless monitor ID. Note that you must also set the `DATADOG_API_KEY` and `DATADOG_APP_KEY` in your environment.
175
176
 
176
177
  If you’d like to further configure the parameters for a recommended monitor, you can directly define the parameter values below the serverless monitor ID. Parameters not specified under a recommended monitor will use the default recommended value. The `query` parameter for recommended monitors cannot be directly modified and will default to using the `query` valued as defined above; however, you may change the threshold value in `query` by re-defining it within the `options` parameter. To delete a monitor, remove the monitor from the `serverless.yml` template. For further documentation on how to define monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor).
177
178
 
@@ -185,8 +186,6 @@ Define the appropriate serverless monitor ID without specifying any parameter va
185
186
  custom:
186
187
  datadog:
187
188
  addLayers: true
188
- monitorsApiKey: "{Datadog_API_Key}"
189
- monitorsAppKey: "{Datadog_APP_Key}"
190
189
  monitors:
191
190
  - high_error_rate:
192
191
  ```
@@ -195,25 +194,21 @@ custom:
195
194
 
196
195
  ```yaml
197
196
  custom:
198
- datadog:
199
- addLayers: true
200
- monitorsApiKey: "{Datadog_API_Key}"
201
- monitorsAppKey: "{Datadog_APP_Key}"
202
- monitors:
203
- - high_error_rate:
204
- name: "High Error Rate with Modified Warning Threshold"
205
- message: "More than 10% of the function’s invocations were errors in the selected time range. Notify @data.dog@datadoghq.com @slack-serverless-monitors"
206
- tags: ["modified_error_rate", "serverless", "error_rate"]
207
- require_full_window: true
208
- priority: 2
209
- options: {
210
- include_tags: true
211
- notify_audit:true
212
- thresholds: {
213
- ok: 0.025
214
- warning: 0.05
215
- }
216
- }
197
+ datadog:
198
+ addLayers: true
199
+ monitors:
200
+ - high_error_rate:
201
+ name: "High Error Rate with Modified Warning Threshold"
202
+ message: "More than 10% of the function’s invocations were errors in the selected time range. Notify @data.dog@datadoghq.com @slack-serverless-monitors"
203
+ tags: ["modified_error_rate", "serverless", "error_rate"]
204
+ require_full_window: true
205
+ priority: 2
206
+ options:
207
+ include_tags: true
208
+ notify_audit: true
209
+ thresholds:
210
+ ok: 0.025
211
+ warning: 0.05
217
212
  ```
218
213
 
219
214
  ##### To delete a monitor
@@ -222,14 +217,12 @@ Removing the serverless monitor ID and its parameters will delete the monitor.
222
217
 
223
218
  #### To Enable and Configure a Custom Monitor
224
219
 
225
- To define a custom monitor, you must define a unique serverless monitor ID string in addition to passing in the API key and Application key. The `query` parameter is required but every other parameter is optional. Define a unique serverless monitor ID string and specify the necessary parameters below. For further documentation on monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor).
220
+ To define a custom monitor, you must define a unique serverless monitor ID string in addition to passing in the API key and Application key, `DATADOG_API_KEY` and `DATADOG_APP_KEY`, in your environment. The `query` parameter is required but every other parameter is optional. Define a unique serverless monitor ID string and specify the necessary parameters below. For further documentation on monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor).
226
221
 
227
222
  ```yaml
228
223
  custom:
229
224
  datadog:
230
225
  addLayers: true
231
- monitorsApiKey: "{Datadog_API_Key}"
232
- monitorsAppKey: "{Datadog_APP_Key}"
233
226
  monitors:
234
227
  - custom_monitor_id:
235
228
  name: "Custom Monitor"
@@ -237,17 +230,15 @@ custom:
237
230
  message: "Custom message for custom monitor. Notify @data.dog@datadoghq.com @slack-serverless-monitors"
238
231
  tags: ["custom_monitor", "serverless"]
239
232
  priority: 3
240
- options: {
233
+ options:
241
234
  enable_logs_sample: true
242
235
  require_full_window: true
243
236
  include_tags: false
244
- notify_audit:true
237
+ notify_audit: true
245
238
  notify_no_data: false
246
- thresholds: {
239
+ thresholds:
247
240
  ok: 1
248
241
  warning: 2
249
- }
250
- }
251
242
  ```
252
243
 
253
244
  ## Opening Issues
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-plugin-datadog",
3
- "version": "3.2.0",
3
+ "version": "3.5.0",
4
4
  "description": "Serverless plugin to automatically instrument python and node functions with datadog tracing",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/DataDog/serverless-plugin-datadog",
@@ -26,7 +26,7 @@
26
26
  "mock-fs": "4.13.0",
27
27
  "nock": "^13.0.5",
28
28
  "prettier": "^2.2.1",
29
- "serverless": "2.38.0",
29
+ "serverless": "2.63.0",
30
30
  "ts-jest": "^26.4.4",
31
31
  "tslint": "^6.1.3",
32
32
  "typescript": "^4.1.3"
@@ -51,11 +51,19 @@
51
51
  "\\.snap$",
52
52
  "<rootDir>/node_modules/"
53
53
  ],
54
+ "testEnvironment": "<rootDir>/testEnvironment.js",
55
+ "clearMocks": true,
54
56
  "collectCoverageFrom": [
55
57
  "src/**/*.ts"
56
58
  ]
57
59
  },
58
60
  "dependencies": {
59
- "node-fetch": "^2.6.1"
61
+ "@datadog/datadog-ci": "^0.17.9",
62
+ "@types/async-retry": "^1.4.3",
63
+ "@types/datadog-metrics": "^0.6.2",
64
+ "@types/deep-extend": "^0.4.32",
65
+ "datadog-metrics": "^0.9.3",
66
+ "node-fetch": "^2.6.1",
67
+ "proxy": "^1.0.2"
60
68
  }
61
69
  }
package/dist/src/env.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- import { FunctionInfo } from "layer";
2
1
  import Service from "serverless/classes/Service";
2
+ import { FunctionInfo } from "./layer";
3
3
  export interface Configuration {
4
4
  enabled?: boolean;
5
5
  addLayers: boolean;
6
6
  apiKey?: string;
7
- apiKMSKey?: string;
8
- captureLambdaPayload?: boolean;
7
+ appKey?: string;
9
8
  monitorsApiKey?: string;
10
9
  monitorsAppKey?: string;
10
+ apiKeySecretArn?: string;
11
+ apiKMSKey?: string;
12
+ captureLambdaPayload?: boolean;
11
13
  site: string;
12
14
  logLevel: string | undefined;
13
15
  flushMetricsToLogs: boolean;
@@ -20,6 +22,7 @@ export interface Configuration {
20
22
  integrationTesting?: boolean;
21
23
  enableTags: boolean;
22
24
  injectLogContext: boolean;
25
+ enableSourceCodeIntegration: boolean;
23
26
  exclude: string[];
24
27
  monitors?: {
25
28
  [id: string]: {
@@ -30,6 +33,7 @@ export interface Configuration {
30
33
  subscribeToExecutionLogs: boolean;
31
34
  customHandler?: string;
32
35
  }
36
+ export declare const ddTagsEnvVar = "DD_TAGS";
33
37
  export declare const defaultConfiguration: Configuration;
34
38
  export declare function setEnvConfiguration(config: Configuration, handlers: FunctionInfo[]): void;
35
39
  export declare function getConfig(service: Service): Configuration;
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAEjD,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,kBAAkB,EAAE,OAAO,CAAC;IAE5B,iBAAiB,EAAE,OAAO,CAAC;IAE3B,eAAe,EAAE,OAAO,CAAC;IAEzB,YAAY,EAAE,OAAO,CAAC;IAEtB,YAAY,EAAE,OA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esModule", { value: true });
10
- exports.hasWebpackPlugin = exports.forceExcludeDepsFromWebpack = exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = void 0;
10
+ exports.hasWebpackPlugin = exports.forceExcludeDepsFromWebpack = exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = exports.ddTagsEnvVar = void 0;
11
+ const layer_1 = require("./layer");
11
12
  const webpackPluginName = "serverless-webpack";
12
13
  const apiKeyEnvVar = "DD_API_KEY";
13
14
  const apiKeyKMSEnvVar = "DD_KMS_API_KEY";
15
+ const apiKeySecretArnEnvVar = "DD_API_KEY_SECRET_ARN";
14
16
  const siteURLEnvVar = "DD_SITE";
15
17
  const logLevelEnvVar = "DD_LOG_LEVEL";
16
18
  const logForwardingEnvVar = "DD_FLUSH_TO_LOG";
@@ -18,6 +20,7 @@ const ddTracingEnabledEnvVar = "DD_TRACE_ENABLED";
18
20
  const logInjectionEnvVar = "DD_LOGS_INJECTION";
19
21
  const ddLogsEnabledEnvVar = "DD_SERVERLESS_LOGS_ENABLED";
20
22
  const ddCaptureLambdaPayloadEnvVar = "DD_CAPTURE_LAMBDA_PAYLOAD";
23
+ exports.ddTagsEnvVar = "DD_TAGS";
21
24
  exports.defaultConfiguration = {
22
25
  addLayers: true,
23
26
  flushMetricsToLogs: true,
@@ -28,6 +31,7 @@ exports.defaultConfiguration = {
28
31
  addExtension: false,
29
32
  enableTags: true,
30
33
  injectLogContext: true,
34
+ enableSourceCodeIntegration: true,
31
35
  exclude: [],
32
36
  integrationTesting: false,
33
37
  subscribeToAccessLogs: true,
@@ -40,12 +44,31 @@ function setEnvConfiguration(config, handlers) {
40
44
  var _a;
41
45
  (_a = handler.environment) !== null && _a !== void 0 ? _a : (handler.environment = {});
42
46
  const environment = handler.environment;
47
+ if (process.env.DATADOG_API_KEY !== undefined &&
48
+ environment[apiKeyEnvVar] === undefined &&
49
+ // Only set this from the environment if all other methods of authentication
50
+ // are not in use. This will set DATADOG_API_KEY on the lambda from the environment
51
+ // variable directly if they haven't set one of the below three options
52
+ // in the configuration.
53
+ config.apiKMSKey === undefined &&
54
+ config.apiKey === undefined &&
55
+ config.apiKeySecretArn === undefined) {
56
+ environment[apiKeyEnvVar] = process.env.DATADOG_API_KEY;
57
+ }
43
58
  if (config.apiKey !== undefined && environment[apiKeyEnvVar] === undefined) {
44
59
  environment[apiKeyEnvVar] = config.apiKey;
45
60
  }
46
61
  if (config.apiKMSKey !== undefined && environment[apiKeyKMSEnvVar] === undefined) {
47
62
  environment[apiKeyKMSEnvVar] = config.apiKMSKey;
48
63
  }
64
+ if (config.apiKeySecretArn !== undefined && environment[apiKeySecretArnEnvVar] === undefined) {
65
+ const isNode = layer_1.runtimeLookup[handler.runtime] === layer_1.RuntimeType.NODE;
66
+ const isSendingSynchronousMetrics = !config.addExtension && !config.flushMetricsToLogs;
67
+ if (isSendingSynchronousMetrics && isNode) {
68
+ throw new Error("`apiKeySecretArn` is not supported for Node runtimes when using Synchronous Metrics. Set DATADOG_API_KEY in your environment, or use `apiKmsKey` in the configuration.");
69
+ }
70
+ environment[apiKeySecretArnEnvVar] = config.apiKeySecretArn;
71
+ }
49
72
  if (environment[siteURLEnvVar] === undefined) {
50
73
  environment[siteURLEnvVar] = config.site;
51
74
  }
@@ -71,6 +94,7 @@ function setEnvConfiguration(config, handlers) {
71
94
  }
72
95
  exports.setEnvConfiguration = setEnvConfiguration;
73
96
  function getConfig(service) {
97
+ var _a, _b, _c, _d, _e, _f;
74
98
  let custom = service.custom;
75
99
  if (custom === undefined) {
76
100
  custom = {};
@@ -79,7 +103,15 @@ function getConfig(service) {
79
103
  if (datadog === undefined) {
80
104
  datadog = {};
81
105
  }
82
- return Object.assign(Object.assign({}, exports.defaultConfiguration), datadog);
106
+ // These values are deprecated but will supersede everything if set
107
+ if ((_a = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _a === void 0 ? void 0 : _a.monitorsApiKey) {
108
+ datadog.apiKey = (_c = (_b = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _b === void 0 ? void 0 : _b.monitorsApiKey) !== null && _c !== void 0 ? _c : datadog.apiKey;
109
+ }
110
+ if ((_d = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _d === void 0 ? void 0 : _d.monitorsAppKey) {
111
+ datadog.appKey = (_f = (_e = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _e === void 0 ? void 0 : _e.monitorsAppKey) !== null && _f !== void 0 ? _f : datadog.appKey;
112
+ }
113
+ const config = Object.assign(Object.assign({}, exports.defaultConfiguration), datadog);
114
+ return config;
83
115
  }
84
116
  exports.getConfig = getConfig;
85
117
  function forceExcludeDepsFromWebpack(service) {
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA8DH,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAC9C,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAClD,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAC/C,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AACzD,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AAEpD,QAAA,oBAAoB,GAAkB;IACjD,SAAS,EAAE,IAAI;IACf,kBAAkB,EAAE,IAAI;IACxB,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,eAAe;IACrB,iBAAiB,EAAE,KAAK;IACxB,eAAe,EAAE,IAAI;IACrB,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,IAAI;IAChB,gBAAgB,EAAE,IAAI;IACtB,OAAO,EAAE,EAAE;IACX,kBAAkB,EAAE,KAAK;IACzB,qBAAqB,EAAE,IAAI;IAC3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IACnD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACvB,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE;YACvC,IAAI,GAAG,EAAE,CAAC;YACV,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;SAClB;QACD,IAAI,IAAI,KAAK,KAAK,EAAE;YAClB,OAAO;SACR;QACD,GAAG,GAAG,IAAI,CAAC;KACZ;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,OAAO,GAA0B,OAAe,CAAC,OAAO,CAAC;IAC/D,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC1B,gCAAgC;QAChC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,iBAAiB,CAAC,KAAK,SAAS,CAAC;KAC7E;IACD,qCAAqC;IACrC,MAAM,OAAO,GAA0B,OAAe,CAAC,OAAO,CAAC,OAAO,CAAC;IACvE,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,iBAAiB,CAAC,KAAK,SAAS,CAAC;AAC9E,CAAC;AAfD,4CAeC"}
@@ -0,0 +1,10 @@
1
+ import { MultipartPayload } from "../helpers/upload";
2
+ export declare class CommitInfo {
3
+ hash: string;
4
+ remote: string;
5
+ trackedFiles: string[];
6
+ constructor(hash: string, remote: string, trackedFiles: string[]);
7
+ asMultipartPayload(cliVersion: string): MultipartPayload;
8
+ private repositoryPayload;
9
+ }
10
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/git-metadata/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,qBAAa,UAAU;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;gBAElB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAMzD,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAqB/D,OAAO,CAAC,iBAAiB,CAWpB;CACN"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommitInfo = void 0;
4
+ class CommitInfo {
5
+ constructor(hash, remote, trackedFiles) {
6
+ this.repositoryPayload = () => JSON.stringify({
7
+ data: [
8
+ {
9
+ files: this.trackedFiles,
10
+ hash: this.hash,
11
+ repository_url: this.remote,
12
+ },
13
+ ],
14
+ // Make sure to update the version if the format of the JSON payloads changes in any way.
15
+ version: 1,
16
+ });
17
+ this.hash = hash;
18
+ this.remote = remote;
19
+ this.trackedFiles = trackedFiles;
20
+ }
21
+ asMultipartPayload(cliVersion) {
22
+ return {
23
+ content: new Map([
24
+ ["cli_version", { value: cliVersion }],
25
+ ["type", { value: "repository" }],
26
+ [
27
+ "repository",
28
+ {
29
+ options: {
30
+ contentType: "application/json",
31
+ filename: "repository",
32
+ },
33
+ value: this.repositoryPayload(),
34
+ },
35
+ ],
36
+ ["git_repository_url", { value: this.remote }],
37
+ ["git_commit_sha", { value: this.hash }],
38
+ ]),
39
+ };
40
+ }
41
+ }
42
+ exports.CommitInfo = CommitInfo;
43
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/git-metadata/interfaces.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAKrB,YAAY,IAAY,EAAE,MAAc,EAAE,YAAsB;QA2BxD,sBAAiB,GAAG,GAAW,EAAE,CACvC,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE;gBACJ;oBACE,KAAK,EAAE,IAAI,CAAC,YAAY;oBACxB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,cAAc,EAAE,IAAI,CAAC,MAAM;iBAC5B;aACF;YACD,yFAAyF;YACzF,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QArCH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,kBAAkB,CAAC,UAAkB;QAC1C,OAAO;YACL,OAAO,EAAE,IAAI,GAAG,CAAC;gBACf,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;gBACtC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;gBACjC;oBACE,YAAY;oBACZ;wBACE,OAAO,EAAE;4BACP,WAAW,EAAE,kBAAkB;4BAC/B,QAAQ,EAAE,YAAY;yBACvB;wBACD,KAAK,EAAE,IAAI,CAAC,iBAAiB,EAAE;qBAChC;iBACF;gBACD,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC9C,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;aACzC,CAAC;SACH,CAAC;IACJ,CAAC;CAcF;AA5CD,gCA4CC"}
@@ -0,0 +1,8 @@
1
+ import * as simpleGit from "simple-git";
2
+ import { CommitInfo } from "./git-metadata/interfaces";
3
+ export declare const newSimpleGit: () => Promise<simpleGit.SimpleGit>;
4
+ export declare const gitRemote: (git: simpleGit.SimpleGit) => Promise<string>;
5
+ export declare const stripCredentials: (remote: string) => string;
6
+ export declare const gitTrackedFiles: (git: simpleGit.SimpleGit) => Promise<string[]>;
7
+ export declare const getCommitInfo: (git: simpleGit.SimpleGit, repositoryURL?: string | undefined) => Promise<CommitInfo | undefined>;
8
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,eAAO,MAAM,YAAY,QAAa,QAAQ,UAAU,SAAS,CAiBhE,CAAC;AAGF,eAAO,MAAM,SAAS,QAAe,UAAU,SAAS,KAAG,QAAQ,MAAM,CAexE,CAAC;AAGF,eAAO,MAAM,gBAAgB,WAAY,MAAM,WAU9C,CAAC;AAMF,eAAO,MAAM,eAAe,QAAe,UAAU,SAAS,KAAG,QAAQ,MAAM,EAAE,CAIhF,CAAC;AAGF,eAAO,MAAM,aAAa,QACnB,UAAU,SAAS,yCAEvB,QAAQ,UAAU,GAAG,SAAS,CAmBhC,CAAC"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.getCommitInfo = exports.gitTrackedFiles = exports.stripCredentials = exports.gitRemote = exports.newSimpleGit = void 0;
32
+ const simpleGit = __importStar(require("simple-git"));
33
+ const url_1 = require("url");
34
+ const interfaces_1 = require("./git-metadata/interfaces");
35
+ // Returns a configured SimpleGit.
36
+ const newSimpleGit = () => __awaiter(void 0, void 0, void 0, function* () {
37
+ const options = {
38
+ baseDir: process.cwd(),
39
+ binary: "git",
40
+ maxConcurrentProcesses: 1,
41
+ };
42
+ try {
43
+ // Attempt to set the baseDir to the root of the repository so the 'git ls-files' command
44
+ // returns the tracked files paths relative to the root of the repository.
45
+ const git = simpleGit.gitP(options);
46
+ const root = yield git.revparse("--show-toplevel");
47
+ options.baseDir = root;
48
+ }
49
+ catch (_a) {
50
+ // Ignore exception as it will fail if we are not inside a git repository.
51
+ }
52
+ return simpleGit.gitP(options);
53
+ });
54
+ exports.newSimpleGit = newSimpleGit;
55
+ // Returns the remote of the current repository.
56
+ const gitRemote = (git) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const remotes = yield git.getRemotes(true);
58
+ if (remotes.length === 0) {
59
+ throw new Error("No git remotes available");
60
+ }
61
+ for (const remote of remotes) {
62
+ // We're trying to pick the remote called with the default git name 'origin'.
63
+ if (remote.name === "origin") {
64
+ return (0, exports.stripCredentials)(remote.refs.push);
65
+ }
66
+ }
67
+ // Falling back to picking the first remote in the list if 'origin' is not found.
68
+ return (0, exports.stripCredentials)(remotes[0].refs.push);
69
+ });
70
+ exports.gitRemote = gitRemote;
71
+ // StripCredentials removes credentials from a remote HTTP url.
72
+ const stripCredentials = (remote) => {
73
+ try {
74
+ const url = new url_1.URL(remote);
75
+ url.username = "";
76
+ url.password = "";
77
+ return url.toString();
78
+ }
79
+ catch (_a) {
80
+ return remote;
81
+ }
82
+ };
83
+ exports.stripCredentials = stripCredentials;
84
+ // Returns the hash of the current repository.
85
+ const gitHash = (git) => __awaiter(void 0, void 0, void 0, function* () { return git.revparse("HEAD"); });
86
+ // Returns the tracked files of the current repository.
87
+ const gitTrackedFiles = (git) => __awaiter(void 0, void 0, void 0, function* () {
88
+ const files = yield git.raw("ls-files");
89
+ return files.split(/\r\n|\r|\n/).filter((s) => s !== "");
90
+ });
91
+ exports.gitTrackedFiles = gitTrackedFiles;
92
+ // Returns the current hash, remote URL and tracked files paths.
93
+ const getCommitInfo = (git, repositoryURL) => __awaiter(void 0, void 0, void 0, function* () {
94
+ // Invoke git commands to retrieve the remote, hash and tracked files.
95
+ // We're using Promise.all instead of Promive.allSettled since we want to fail early if
96
+ // any of the promises fails.
97
+ let remote;
98
+ let hash;
99
+ let trackedFiles;
100
+ try {
101
+ if (repositoryURL) {
102
+ [hash, trackedFiles] = yield Promise.all([gitHash(git), (0, exports.gitTrackedFiles)(git)]);
103
+ remote = repositoryURL;
104
+ }
105
+ else {
106
+ [remote, hash, trackedFiles] = yield Promise.all([(0, exports.gitRemote)(git), gitHash(git), (0, exports.gitTrackedFiles)(git)]);
107
+ }
108
+ }
109
+ catch (e) {
110
+ throw e;
111
+ }
112
+ return new interfaces_1.CommitInfo(hash, remote, trackedFiles);
113
+ });
114
+ exports.getCommitInfo = getCommitInfo;
115
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"m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