diff --git a/README.md b/README.md index 3e234c694..49ee7aa88 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ # Serverless Offline -⚠️ -We are looking for maintainers! This package is entirely community-driven. Please send an email to dherault to start helping now. -⚠️ -

diff --git a/package-lock.json b/package-lock.json index f811225d4..c74be8f07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "serverless-offline", - "version": "14.2.0", + "version": "14.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "serverless-offline", - "version": "14.2.0", + "version": "14.1.1", "license": "MIT", "dependencies": { - "@aws-sdk/client-lambda": "^3.632.0", + "@aws-sdk/client-lambda": "^3.636.0", "@hapi/boom": "^10.0.1", "@hapi/h2o2": "^10.0.4", "@hapi/hapi": "^21.3.10", @@ -21,7 +21,7 @@ "fs-extra": "^11.2.0", "is-wsl": "^3.1.0", "java-invoke-local": "0.0.6", - "jose": "^5.6.3", + "jose": "^5.7.0", "js-string-escape": "^1.0.1", "jsonpath-plus": "^9.0.0", "jsonschema": "^1.4.1", @@ -48,7 +48,7 @@ "mocha": "^10.7.3", "nyc": "^17.0.0", "prettier": "^3.3.3", - "serverless": "^4.1.22" + "serverless": "^4.2.1" }, "engines": { "node": ">=18.12.0" @@ -210,16 +210,16 @@ } }, "node_modules/@aws-sdk/client-lambda": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.632.0.tgz", - "integrity": "sha512-vF4KRuHGr6EfW+dssm56S6b+jAa8dKqdWduHNms1TQFah0iOkjc9Dpo4p4j6bobZcuricGko/OZy9ynb1Dwldg==", + "version": "3.636.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.636.0.tgz", + "integrity": "sha512-rJitBBQAEVdyf4E6PhwFwD7uIM222dfx2oEIuFKkUb5rMKaFocnJbzvS3yGv/dZwDcUtMV5+5ibMCfgE8gAiJg==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -230,7 +230,7 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/eventstream-serde-browser": "^3.0.6", "@smithy/eventstream-serde-config-resolver": "^3.0.3", "@smithy/eventstream-serde-node": "^3.0.5", @@ -239,20 +239,20 @@ "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -266,13 +266,13 @@ } }, "node_modules/@aws-sdk/client-sso": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.632.0.tgz", - "integrity": "sha512-iYWHiKBz44m3chCFvtvHnvCpL2rALzyr1e6tOZV3dLlOKtQtDUlPy6OtnXDu4y+wyJCniy8ivG3+LAe4klzn1Q==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.635.0.tgz", + "integrity": "sha512-/Hl69+JpFUo9JNVmh2gSvMgYkE4xjd+1okiRoPBbQqjI7YBP2JWCUDP8IoEkNq3wj0vNTq0OWfn6RpZycIkAXQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", + "@aws-sdk/core": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -283,26 +283,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -314,14 +314,14 @@ } }, "node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -332,26 +332,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -362,19 +362,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -385,26 +385,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -416,16 +416,16 @@ } }, "node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -450,16 +450,16 @@ } }, "node_modules/@aws-sdk/credential-provider-http": { - "version": "3.622.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.622.0.tgz", - "integrity": "sha512-VUHbr24Oll1RK3WR8XLUugLpgK9ZuxEm/NVeVqyFts1Ck9gsKpRg1x4eH7L7tW3SJ4TDEQNMbD7/7J+eoL2svg==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.635.0.tgz", + "integrity": "sha512-iJyRgEjOCQlBMXqtwPLIKYc7Bsc6nqjrZybdMDenPDa+kmLg7xh8LxHsu9088e+2/wtLicE34FsJJIfzu3L82g==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-stream": "^3.1.3", "tslib": "^2.6.2" @@ -469,14 +469,14 @@ } }, "node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.632.0.tgz", - "integrity": "sha512-m6epoW41xa1ajU5OiHcmQHoGVtrbXBaRBOUhlCLZmcaqMLYsboM4iD/WZP8aatKEON5tTnVXh/4StV8D/+wemw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.635.0.tgz", + "integrity": "sha512-+OqcNhhOFFY08YHLjO9/Y1n37RKAO7LADnsJ7VTXca7IfvYh27BVBn+FdlqnyEb1MQ5ArHTY4pq3pKRIg6RW4Q==", "dependencies": { "@aws-sdk/credential-provider-env": "3.620.1", - "@aws-sdk/credential-provider-http": "3.622.0", + "@aws-sdk/credential-provider-http": "3.635.0", "@aws-sdk/credential-provider-process": "3.620.1", - "@aws-sdk/credential-provider-sso": "3.632.0", + "@aws-sdk/credential-provider-sso": "3.635.0", "@aws-sdk/credential-provider-web-identity": "3.621.0", "@aws-sdk/types": "3.609.0", "@smithy/credential-provider-imds": "^3.2.0", @@ -489,19 +489,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.632.0.tgz", - "integrity": "sha512-cL8fuJWm/xQBO4XJPkeuZzl3XinIn9EExWgzpG48NRMKR5us1RI/ucv7xFbBBaG+r/sDR2HpYBIA3lVIpm1H3Q==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.635.0.tgz", + "integrity": "sha512-bmd23mnb94S6AxmWPgqJTnvT9ONKlTx7EPafE1RNO+vUl6mHih4iyqX6ZPaRcSfaPx4U1R7H1RM8cSnafXgaBg==", "dependencies": { "@aws-sdk/credential-provider-env": "3.620.1", - "@aws-sdk/credential-provider-http": "3.622.0", - "@aws-sdk/credential-provider-ini": "3.632.0", + "@aws-sdk/credential-provider-http": "3.635.0", + "@aws-sdk/credential-provider-ini": "3.635.0", "@aws-sdk/credential-provider-process": "3.620.1", - "@aws-sdk/credential-provider-sso": "3.632.0", + "@aws-sdk/credential-provider-sso": "3.635.0", "@aws-sdk/credential-provider-web-identity": "3.621.0", "@aws-sdk/types": "3.609.0", "@smithy/credential-provider-imds": "^3.2.0", @@ -530,11 +530,11 @@ } }, "node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.632.0.tgz", - "integrity": "sha512-P/4wB6j7ym5QCPTL2xlMfvf2NcXSh+z0jmsZP4WW/tVwab4hvgabPPbLeEZDSWZ0BpgtxKGvRq0GSHuGeirQbA==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.635.0.tgz", + "integrity": "sha512-hO/fKyvUaGpK9zyvCnmJz70EputvGWDr2UTOn/RzvcR6UB4yXoFf0QcCMubEsE3v67EsAv6PadgOeJ0vz6IazA==", "dependencies": { - "@aws-sdk/client-sso": "3.632.0", + "@aws-sdk/client-sso": "3.635.0", "@aws-sdk/token-providers": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/property-provider": "^3.1.3", @@ -7327,9 +7327,9 @@ } }, "node_modules/jose": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/jose/-/jose-5.6.3.tgz", - "integrity": "sha512-1Jh//hEEwMhNYPDDLwXHa2ePWgWiFNNUadVmguAAw2IJ6sj9mNxV5tGXJNqlMkJAybF6Lgw1mISDxTePP/187g==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.7.0.tgz", + "integrity": "sha512-3P9qfTYDVnNn642LCAqIKbTGb9a1TBxZ9ti5zEVEr48aDdflgRjhspWFb6WM4PzAfFbGMJYC4+803v8riCRAKw==", "funding": { "url": "https://github.com/sponsors/panva" } @@ -9780,12 +9780,12 @@ } }, "node_modules/serverless": { - "version": "4.1.22", - "resolved": "https://registry.npmjs.org/serverless/-/serverless-4.1.22.tgz", - "integrity": "sha512-MNEZqktEIib/JB+JRc504EaijEr1CgG5jlbUfUV7u2BXpneJinhTgVQH56TVZLSPWEEMIIdA9Eu0Wdi3jUfpbw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/serverless/-/serverless-4.2.1.tgz", + "integrity": "sha512-Cifv55uej/l+p4eDDSV1/qFjUfROESdJS6Jgchxc4sBSwEHmarC2NLLa/2/AOFtqeo+1MsT1soSiRrLOsTP6tA==", "dev": true, "dependencies": { - "axios": "^1.6.0", + "axios": "^1.7.4", "axios-proxy-builder": "^0.1.2", "rimraf": "^5.0.5", "xml2js": "0.6.2" diff --git a/package.json b/package.json index f7bf08fdc..4af130ef2 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ ] }, "dependencies": { - "@aws-sdk/client-lambda": "^3.632.0", + "@aws-sdk/client-lambda": "^3.636.0", "@hapi/boom": "^10.0.1", "@hapi/h2o2": "^10.0.4", "@hapi/hapi": "^21.3.10", @@ -88,7 +88,7 @@ "fs-extra": "^11.2.0", "is-wsl": "^3.1.0", "java-invoke-local": "0.0.6", - "jose": "^5.6.3", + "jose": "^5.7.0", "js-string-escape": "^1.0.1", "jsonpath-plus": "^9.0.0", "jsonschema": "^1.4.1", @@ -115,7 +115,7 @@ "mocha": "^10.7.3", "nyc": "^17.0.0", "prettier": "^3.3.3", - "serverless": "^4.1.22" + "serverless": "^4.2.1" }, "peerDependencies": { "serverless": "^4.0.0" diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index 11214192b..eeeb98413 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -1,5 +1,6 @@ import process, { exit } from "node:process" import { log, setLogUtils } from "./utils/log.js" +import logSponsor from "./utils/logSponsor.js" import { commandOptions, CUSTOM_OPTION, @@ -64,6 +65,12 @@ export default class ServerlessOffline { async start() { this.#mergeOptions() + if (this.#cliOptions.noSponsor) { + log.notice() + } else { + logSponsor() + } + const { albEvents, httpEvents, @@ -278,13 +285,11 @@ export default class ServerlessOffline { origin: this.#options.corsAllowOrigin, } - log.notice() log.notice( `Starting Offline at stage ${ this.#options.stage || provider.stage } ${gray(`(${this.#options.region || provider.region})`)}`, ) - log.notice() log.debug("options:", this.#options) } diff --git a/src/config/commandOptions.js b/src/config/commandOptions.js index 9de897155..5c996b9ef 100644 --- a/src/config/commandOptions.js +++ b/src/config/commandOptions.js @@ -89,6 +89,10 @@ export default { type: "boolean", usage: "Don't prepend http routes with the stage.", }, + noSponsor: { + type: "boolean", + usage: "Remove sponsor message from the output.", + }, noTimeout: { shortcut: "t", type: "boolean", diff --git a/src/lambda/HttpServer.js b/src/lambda/HttpServer.js index d2eb946e2..3c4560d35 100644 --- a/src/lambda/HttpServer.js +++ b/src/lambda/HttpServer.js @@ -62,7 +62,7 @@ export default class HttpServer { .listFunctionNames() .map( (functionName) => - ` * ${funcNamePairs[functionName]}: ${functionName}`, + ` * ${funcNamePairs[functionName]}: ${functionName}`, ), ].join("\n"), ) @@ -73,9 +73,7 @@ export default class HttpServer { .listFunctionNames() .map( (functionName) => - ` * ${ - invRoute.method - } ${basePath}${invRoute.path.replace( + ` * ${invRoute.method} ${basePath}${invRoute.path.replace( "{functionName}", functionName, )}`, @@ -90,7 +88,7 @@ export default class HttpServer { .listFunctionNames() .map( (functionName) => - ` * ${ + ` * ${ invAsyncRoute.method } ${basePath}${invAsyncRoute.path.replace( "{functionName}", diff --git a/src/utils/logRoutes.js b/src/utils/logRoutes.js index ecc62c006..d4ecd11eb 100644 --- a/src/utils/logRoutes.js +++ b/src/utils/logRoutes.js @@ -10,8 +10,7 @@ import { yellow, } from "../config/colors.js" -const { max } = Math - +const post = "POST" const colorMethodMapping = new Map([ ["DELETE", red], ["GET", dodgerblue], @@ -28,13 +27,13 @@ function logRoute(method, server, path, maxLength, dimPath = false) { const methodColor = colorMethodMapping.get(method) ?? peachpuff const methodFormatted = method.padEnd(maxLength, " ") - return `${methodColor(methodFormatted)} ${yellow.dim("|")} ${gray.dim( - server, - )}${dimPath ? gray.dim(path) : lime(path)}` + return `${methodColor(methodFormatted)} ${yellow.dim("|")} ${gray.dim(server)}${dimPath ? gray.dim(path) : lime(path)}` } function getMaxHttpMethodNameLength(routeInfo) { - return max(...routeInfo.map(({ method }) => method.length)) + return Math.max( + ...routeInfo.map(({ method }) => Math.max(method.length, post.length)), + ) } export default function logRoutes(routeInfo) { @@ -55,7 +54,7 @@ export default function logRoutes(routeInfo) { // eslint-disable-next-line prefer-template logRoute(method, server, path, maxLength) + "\n" + - logRoute("POST", server, invokePath, maxLength, true), + logRoute(post, server, invokePath, maxLength, true), ) .join("\n"), boxenOptions, diff --git a/src/utils/logSponsor.js b/src/utils/logSponsor.js new file mode 100644 index 000000000..84284772b --- /dev/null +++ b/src/utils/logSponsor.js @@ -0,0 +1,69 @@ +/* eslint-disable no-use-before-define */ +/* eslint-disable no-console */ +import process from "node:process" + +import boxen from "boxen" +import { gray, dodgerblue } from "../config/colors.js" + +const boxenOptions = { + borderColor: "blue", + margin: 1, + padding: 1, +} + +// Promotion starts on August 22, 2024 +const startAt = new Date("2024-08-22T00:00:00.000Z") +// By October 22, 2024, the promotion will be displayed to 100% of users +const endAt = new Date("2024-10-22T00:00:00.000Z") +const nDays = diffDays(startAt, endAt) + +function logSponsor() { + if (!shouldDisplaySponsor()) { + console.log() + + return + } + + console.log( + boxen( + `Sponsored by ${dodgerblue("Arccode, the RPG for developers")}\nhttps://arccode.dev?ref=so\n${gray.dim( + "Disable with --noSponsor", + )}`, + boxenOptions, + ), + ) +} + +// Display the message progressively over time to 100% of users +function shouldDisplaySponsor() { + const ratio = diffDays(startAt, new Date()) / nDays + + if (ratio >= 1) return true + + try { + const nonce = Number( + encodeStringToNumber(process.cwd()).toString().padStart(2, "0").slice(-2), + ) + + return nonce <= ratio * 100 + } catch { + // + } + + return false +} + +function encodeStringToNumber(string) { + let sum = 0 + + for (let i = 0; i < string.length; i += 1) { + sum += Number(string.codePointAt(i).toString(10)) + } + + return sum +} + +function diffDays(a, b) { + return Math.round((b - a) / (1000 * 60 * 60 * 24)) +} +export default logSponsor