serverless-offline 13.1.2 → 13.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dedicatedTo": "Blue, a great migrating bird.",
3
3
  "name": "serverless-offline",
4
- "version": "13.1.2",
4
+ "version": "13.2.1",
5
5
  "description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -79,7 +79,7 @@
79
79
  ]
80
80
  },
81
81
  "dependencies": {
82
- "@aws-sdk/client-lambda": "^3.421.0",
82
+ "@aws-sdk/client-lambda": "^3.441.0",
83
83
  "@hapi/boom": "^10.0.1",
84
84
  "@hapi/h2o2": "^10.0.4",
85
85
  "@hapi/hapi": "^21.3.2",
@@ -92,7 +92,7 @@
92
92
  "fs-extra": "^11.1.1",
93
93
  "is-wsl": "^3.1.0",
94
94
  "java-invoke-local": "0.0.6",
95
- "jose": "^4.14.6",
95
+ "jose": "^5.1.0",
96
96
  "js-string-escape": "^1.0.1",
97
97
  "jsonpath-plus": "^7.2.0",
98
98
  "jsonschema": "^1.4.1",
@@ -107,19 +107,19 @@
107
107
  "devDependencies": {
108
108
  "@istanbuljs/esm-loader-hook": "^0.2.0",
109
109
  "archiver": "^6.0.1",
110
- "eslint": "^8.50.0",
110
+ "eslint": "^8.53.0",
111
111
  "eslint-config-airbnb-base": "^15.0.0",
112
112
  "eslint-config-prettier": "^9.0.0",
113
- "eslint-plugin-import": "^2.28.1",
114
- "eslint-plugin-prettier": "^5.0.0",
115
- "eslint-plugin-unicorn": "^48.0.1",
113
+ "eslint-plugin-import": "^2.29.0",
114
+ "eslint-plugin-prettier": "^5.0.1",
115
+ "eslint-plugin-unicorn": "^49.0.0",
116
116
  "git-list-updated": "^1.2.1",
117
117
  "husky": "^8.0.3",
118
- "lint-staged": "^14.0.1",
118
+ "lint-staged": "^15.0.2",
119
119
  "mocha": "^10.2.0",
120
120
  "nyc": "^15.1.0",
121
121
  "prettier": "^3.0.3",
122
- "serverless": "^3.35.2",
122
+ "serverless": "^3.36.0",
123
123
  "standard-version": "^9.5.0"
124
124
  },
125
125
  "peerDependencies": {
@@ -2,7 +2,7 @@ import { readFile, writeFile } from 'node:fs/promises'
2
2
  import { dirname, join, resolve } from 'node:path'
3
3
  import process from 'node:process'
4
4
  import { performance } from 'node:perf_hooks'
5
- import { promisify } from 'node:util'
5
+ import { setTimeout } from 'node:timers/promises'
6
6
  import { log } from '@serverless/utils/log.js'
7
7
  import { emptyDir, ensureDir, remove } from 'fs-extra'
8
8
  import jszip from 'jszip'
@@ -20,8 +20,6 @@ import { createUniqueId } from '../utils/index.js'
20
20
  const { ceil } = Math
21
21
  const { entries, fromEntries } = Object
22
22
 
23
- const setTimeoutPromise = promisify(setTimeout)
24
-
25
23
  export default class LambdaFunction {
26
24
  #artifact = null
27
25
 
@@ -73,7 +71,7 @@ export default class LambdaFunction {
73
71
  // TEMP options.location, for compatibility with serverless-webpack:
74
72
  // https://github.com/dherault/serverless-offline/issues/787
75
73
  // TODO FIXME look into better way to work with serverless-webpack
76
- const servicepath = resolve(servicePath, options.location || '')
74
+ const servicepath = resolve(servicePath, options.location ?? '')
77
75
 
78
76
  const { handler, name, package: functionPackage = {} } = functionDefinition
79
77
 
@@ -83,8 +81,8 @@ export default class LambdaFunction {
83
81
  this.#handler = handler
84
82
 
85
83
  this.#memorySize =
86
- functionDefinition.memorySize ||
87
- provider.memorySize ||
84
+ functionDefinition.memorySize ??
85
+ provider.memorySize ??
88
86
  DEFAULT_LAMBDA_MEMORY_SIZE
89
87
 
90
88
  this.#noTimeout = options.noTimeout
@@ -92,11 +90,11 @@ export default class LambdaFunction {
92
90
  this.#region = provider.region
93
91
 
94
92
  this.#runtime =
95
- functionDefinition.runtime || provider.runtime || DEFAULT_LAMBDA_RUNTIME
93
+ functionDefinition.runtime ?? provider.runtime ?? DEFAULT_LAMBDA_RUNTIME
96
94
 
97
95
  this.#timeout =
98
- (functionDefinition.timeout ||
99
- provider.timeout ||
96
+ (functionDefinition.timeout ??
97
+ provider.timeout ??
100
98
  DEFAULT_LAMBDA_TIMEOUT) * 1000
101
99
 
102
100
  this.#verifySupportedRuntime()
@@ -278,7 +276,7 @@ export default class LambdaFunction {
278
276
  }
279
277
 
280
278
  async #timeoutAndTerminate() {
281
- await setTimeoutPromise(this.#timeout)
279
+ await setTimeout(this.#timeout)
282
280
 
283
281
  throw new LambdaTimeoutError('[504] - Lambda timeout.')
284
282
  }
@@ -37,6 +37,22 @@ export default class GoRunner {
37
37
  // refresh go.mod
38
38
  await rm(this.#tmpFile)
39
39
  await execa('go', ['mod', 'tidy'])
40
+
41
+ if (this.workspace && this.#tmpPath) {
42
+ const workPath = `${this.#codeDir}/go.work`
43
+ const workFile = await readFile(workPath, 'utf8')
44
+
45
+ const out = workFile.replace(this.#tmpPath, '')
46
+
47
+ try {
48
+ await writeFile(workPath, out, 'utf8')
49
+ } catch {
50
+ // @ignore
51
+ }
52
+
53
+ await execa('go', ['work', 'sync'])
54
+ }
55
+
40
56
  await rmdir(this.#tmpPath, {
41
57
  recursive: true,
42
58
  })
@@ -125,6 +141,14 @@ export default class GoRunner {
125
141
  try {
126
142
  chdir(cwdPath.substring(0, cwdPath.indexOf('main.go')))
127
143
 
144
+ if (this.workspace) {
145
+ /**
146
+ * We need to initialize the module, as in the case of a workspace it will not already exist
147
+ */
148
+ await execa('go', ['mod', 'init', 'tmp'])
149
+ await execa('go', ['work', 'use', this.#tmpPath])
150
+ }
151
+
128
152
  // Make sure we have the mock-lambda runner
129
153
  await execa('go', [
130
154
  'get',
@@ -171,4 +195,8 @@ export default class GoRunner {
171
195
 
172
196
  return this.#parsePayload(stdout)
173
197
  }
198
+
199
+ get workspace() {
200
+ return this.#goEnv.GOWORK && this.#goEnv.GOWORK.length > 0
201
+ }
174
202
  }