netlify-cli 17.13.1 → 17.14.0
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/npm-shrinkwrap.json +35 -77
- package/package.json +3 -3
- package/src/commands/dev/dev.js +7 -6
- package/src/commands/functions/functions-create.js +8 -6
- package/src/commands/serve/serve.js +2 -1
- package/src/functions-templates/rust/hello-world/src/main.rs +4 -4
- package/src/lib/blobs/blobs.js +7 -0
- package/src/lib/functions/runtimes/js/index.js +9 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.14.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "17.
|
|
9
|
+
"version": "17.14.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@bugsnag/js": "7.20.2",
|
|
14
14
|
"@fastify/static": "6.10.2",
|
|
15
|
-
"@netlify/blobs": "6.
|
|
16
|
-
"@netlify/build": "29.
|
|
15
|
+
"@netlify/blobs": "6.4.1",
|
|
16
|
+
"@netlify/build": "29.32.0",
|
|
17
17
|
"@netlify/build-info": "7.11.4",
|
|
18
18
|
"@netlify/config": "20.10.1",
|
|
19
19
|
"@netlify/edge-bundler": "11.0.0",
|
|
@@ -759,17 +759,17 @@
|
|
|
759
759
|
"integrity": "sha512-4wMPu9iN3/HL97QblBsBay3E1etIciR84izI3U+4iALY+JHCrI+a2jO0qbAZ/nxKoegypYEaiiqWXylm+/zfrw=="
|
|
760
760
|
},
|
|
761
761
|
"node_modules/@netlify/blobs": {
|
|
762
|
-
"version": "6.
|
|
763
|
-
"resolved": "https://registry.npmjs.org/@netlify/blobs/-/blobs-6.
|
|
764
|
-
"integrity": "sha512-
|
|
762
|
+
"version": "6.4.1",
|
|
763
|
+
"resolved": "https://registry.npmjs.org/@netlify/blobs/-/blobs-6.4.1.tgz",
|
|
764
|
+
"integrity": "sha512-2n65VaF8llxBl8cfOFVgXff4soZbEXSXekuux0airJ2RFSufqP4rloIWl0mvs75JQ0xLsFAoLLgPMcRNuECQqw==",
|
|
765
765
|
"engines": {
|
|
766
766
|
"node": "^14.16.0 || >=16.0.0"
|
|
767
767
|
}
|
|
768
768
|
},
|
|
769
769
|
"node_modules/@netlify/build": {
|
|
770
|
-
"version": "29.
|
|
771
|
-
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.
|
|
772
|
-
"integrity": "sha512-
|
|
770
|
+
"version": "29.32.0",
|
|
771
|
+
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.32.0.tgz",
|
|
772
|
+
"integrity": "sha512-J0Zx2MCrtFqN9Nmp1uE4exB/5Fqlf/5YuSgaRu6GsjLINzEbhCKVv2ZksMbbMxc0c/cuemcmK9IomFT3GWIeTA==",
|
|
773
773
|
"dependencies": {
|
|
774
774
|
"@bugsnag/js": "^7.0.0",
|
|
775
775
|
"@netlify/blobs": "^6.3.1",
|
|
@@ -1289,14 +1289,6 @@
|
|
|
1289
1289
|
"node": "^14.16.0 || >=16.0.0"
|
|
1290
1290
|
}
|
|
1291
1291
|
},
|
|
1292
|
-
"node_modules/@netlify/build/node_modules/@opentelemetry/api": {
|
|
1293
|
-
"version": "1.6.0",
|
|
1294
|
-
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz",
|
|
1295
|
-
"integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g==",
|
|
1296
|
-
"engines": {
|
|
1297
|
-
"node": ">=8.0.0"
|
|
1298
|
-
}
|
|
1299
|
-
},
|
|
1300
1292
|
"node_modules/@netlify/build/node_modules/@sindresorhus/is": {
|
|
1301
1293
|
"version": "5.6.0",
|
|
1302
1294
|
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.6.0.tgz",
|
|
@@ -3095,14 +3087,6 @@
|
|
|
3095
3087
|
"node": ">=18.0.0"
|
|
3096
3088
|
}
|
|
3097
3089
|
},
|
|
3098
|
-
"node_modules/@netlify/opentelemetry-utils/node_modules/@opentelemetry/api": {
|
|
3099
|
-
"version": "1.6.0",
|
|
3100
|
-
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz",
|
|
3101
|
-
"integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g==",
|
|
3102
|
-
"engines": {
|
|
3103
|
-
"node": ">=8.0.0"
|
|
3104
|
-
}
|
|
3105
|
-
},
|
|
3106
3090
|
"node_modules/@netlify/plugins-list": {
|
|
3107
3091
|
"version": "6.74.0",
|
|
3108
3092
|
"resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.74.0.tgz",
|
|
@@ -3645,21 +3629,6 @@
|
|
|
3645
3629
|
"url": "https://github.com/sindresorhus/execa?sponsor=1"
|
|
3646
3630
|
}
|
|
3647
3631
|
},
|
|
3648
|
-
"node_modules/@netlify/zip-it-and-ship-it/node_modules/fast-glob": {
|
|
3649
|
-
"version": "3.3.2",
|
|
3650
|
-
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
|
3651
|
-
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
|
3652
|
-
"dependencies": {
|
|
3653
|
-
"@nodelib/fs.stat": "^2.0.2",
|
|
3654
|
-
"@nodelib/fs.walk": "^1.2.3",
|
|
3655
|
-
"glob-parent": "^5.1.2",
|
|
3656
|
-
"merge2": "^1.3.0",
|
|
3657
|
-
"micromatch": "^4.0.4"
|
|
3658
|
-
},
|
|
3659
|
-
"engines": {
|
|
3660
|
-
"node": ">=8.6.0"
|
|
3661
|
-
}
|
|
3662
|
-
},
|
|
3663
3632
|
"node_modules/@netlify/zip-it-and-ship-it/node_modules/glob": {
|
|
3664
3633
|
"version": "8.1.0",
|
|
3665
3634
|
"resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
|
|
@@ -3993,6 +3962,14 @@
|
|
|
3993
3962
|
"@octokit/openapi-types": "^13.11.0"
|
|
3994
3963
|
}
|
|
3995
3964
|
},
|
|
3965
|
+
"node_modules/@opentelemetry/api": {
|
|
3966
|
+
"version": "1.6.0",
|
|
3967
|
+
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz",
|
|
3968
|
+
"integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g==",
|
|
3969
|
+
"engines": {
|
|
3970
|
+
"node": ">=8.0.0"
|
|
3971
|
+
}
|
|
3972
|
+
},
|
|
3996
3973
|
"node_modules/@parcel/watcher": {
|
|
3997
3974
|
"version": "2.3.0",
|
|
3998
3975
|
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.3.0.tgz",
|
|
@@ -8019,9 +7996,9 @@
|
|
|
8019
7996
|
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
|
8020
7997
|
},
|
|
8021
7998
|
"node_modules/fast-glob": {
|
|
8022
|
-
"version": "3.3.
|
|
8023
|
-
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.
|
|
8024
|
-
"integrity": "sha512-
|
|
7999
|
+
"version": "3.3.2",
|
|
8000
|
+
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
|
8001
|
+
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
|
8025
8002
|
"dependencies": {
|
|
8026
8003
|
"@nodelib/fs.stat": "^2.0.2",
|
|
8027
8004
|
"@nodelib/fs.walk": "^1.2.3",
|
|
@@ -16115,14 +16092,14 @@
|
|
|
16115
16092
|
"integrity": "sha512-4wMPu9iN3/HL97QblBsBay3E1etIciR84izI3U+4iALY+JHCrI+a2jO0qbAZ/nxKoegypYEaiiqWXylm+/zfrw=="
|
|
16116
16093
|
},
|
|
16117
16094
|
"@netlify/blobs": {
|
|
16118
|
-
"version": "6.
|
|
16119
|
-
"resolved": "https://registry.npmjs.org/@netlify/blobs/-/blobs-6.
|
|
16120
|
-
"integrity": "sha512-
|
|
16095
|
+
"version": "6.4.1",
|
|
16096
|
+
"resolved": "https://registry.npmjs.org/@netlify/blobs/-/blobs-6.4.1.tgz",
|
|
16097
|
+
"integrity": "sha512-2n65VaF8llxBl8cfOFVgXff4soZbEXSXekuux0airJ2RFSufqP4rloIWl0mvs75JQ0xLsFAoLLgPMcRNuECQqw=="
|
|
16121
16098
|
},
|
|
16122
16099
|
"@netlify/build": {
|
|
16123
|
-
"version": "29.
|
|
16124
|
-
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.
|
|
16125
|
-
"integrity": "sha512-
|
|
16100
|
+
"version": "29.32.0",
|
|
16101
|
+
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.32.0.tgz",
|
|
16102
|
+
"integrity": "sha512-J0Zx2MCrtFqN9Nmp1uE4exB/5Fqlf/5YuSgaRu6GsjLINzEbhCKVv2ZksMbbMxc0c/cuemcmK9IomFT3GWIeTA==",
|
|
16126
16103
|
"requires": {
|
|
16127
16104
|
"@bugsnag/js": "^7.0.0",
|
|
16128
16105
|
"@netlify/blobs": "^6.3.1",
|
|
@@ -16347,11 +16324,6 @@
|
|
|
16347
16324
|
"uuid": "^9.0.0"
|
|
16348
16325
|
}
|
|
16349
16326
|
},
|
|
16350
|
-
"@opentelemetry/api": {
|
|
16351
|
-
"version": "1.6.0",
|
|
16352
|
-
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz",
|
|
16353
|
-
"integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g=="
|
|
16354
|
-
},
|
|
16355
16327
|
"@sindresorhus/is": {
|
|
16356
16328
|
"version": "5.6.0",
|
|
16357
16329
|
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.6.0.tgz",
|
|
@@ -17452,13 +17424,6 @@
|
|
|
17452
17424
|
"integrity": "sha512-mL8vhn4tUpdkHg1+WuqEhguULNeN0kQWZtel6lFEEZ36G41Vxm1gv6n7RcOanNLHxQEnaLS4J8zRVUSuwj6iTQ==",
|
|
17453
17425
|
"requires": {
|
|
17454
17426
|
"@opentelemetry/api": "~1.6.0"
|
|
17455
|
-
},
|
|
17456
|
-
"dependencies": {
|
|
17457
|
-
"@opentelemetry/api": {
|
|
17458
|
-
"version": "1.6.0",
|
|
17459
|
-
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz",
|
|
17460
|
-
"integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g=="
|
|
17461
|
-
}
|
|
17462
17427
|
}
|
|
17463
17428
|
},
|
|
17464
17429
|
"@netlify/plugins-list": {
|
|
@@ -17752,18 +17717,6 @@
|
|
|
17752
17717
|
"strip-final-newline": "^3.0.0"
|
|
17753
17718
|
}
|
|
17754
17719
|
},
|
|
17755
|
-
"fast-glob": {
|
|
17756
|
-
"version": "3.3.2",
|
|
17757
|
-
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
|
17758
|
-
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
|
17759
|
-
"requires": {
|
|
17760
|
-
"@nodelib/fs.stat": "^2.0.2",
|
|
17761
|
-
"@nodelib/fs.walk": "^1.2.3",
|
|
17762
|
-
"glob-parent": "^5.1.2",
|
|
17763
|
-
"merge2": "^1.3.0",
|
|
17764
|
-
"micromatch": "^4.0.4"
|
|
17765
|
-
}
|
|
17766
|
-
},
|
|
17767
17720
|
"glob": {
|
|
17768
17721
|
"version": "8.1.0",
|
|
17769
17722
|
"resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
|
|
@@ -18018,6 +17971,11 @@
|
|
|
18018
17971
|
"@octokit/openapi-types": "^13.11.0"
|
|
18019
17972
|
}
|
|
18020
17973
|
},
|
|
17974
|
+
"@opentelemetry/api": {
|
|
17975
|
+
"version": "1.6.0",
|
|
17976
|
+
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz",
|
|
17977
|
+
"integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g=="
|
|
17978
|
+
},
|
|
18021
17979
|
"@parcel/watcher": {
|
|
18022
17980
|
"version": "2.3.0",
|
|
18023
17981
|
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.3.0.tgz",
|
|
@@ -20892,9 +20850,9 @@
|
|
|
20892
20850
|
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
|
20893
20851
|
},
|
|
20894
20852
|
"fast-glob": {
|
|
20895
|
-
"version": "3.3.
|
|
20896
|
-
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.
|
|
20897
|
-
"integrity": "sha512-
|
|
20853
|
+
"version": "3.3.2",
|
|
20854
|
+
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
|
20855
|
+
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
|
20898
20856
|
"requires": {
|
|
20899
20857
|
"@nodelib/fs.stat": "^2.0.2",
|
|
20900
20858
|
"@nodelib/fs.walk": "^1.2.3",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.14.0",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@bugsnag/js": "7.20.2",
|
|
47
47
|
"@fastify/static": "6.10.2",
|
|
48
|
-
"@netlify/blobs": "6.
|
|
49
|
-
"@netlify/build": "29.
|
|
48
|
+
"@netlify/blobs": "6.4.1",
|
|
49
|
+
"@netlify/build": "29.32.0",
|
|
50
50
|
"@netlify/build-info": "7.11.4",
|
|
51
51
|
"@netlify/config": "20.10.1",
|
|
52
52
|
"@netlify/edge-bundler": "11.0.0",
|
package/src/commands/dev/dev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
2
|
import { Option } from 'commander';
|
|
3
|
-
import { getBlobsContext } from '../../lib/blobs/blobs.js';
|
|
3
|
+
import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext, getBlobsContext } from '../../lib/blobs/blobs.js';
|
|
4
4
|
import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.js';
|
|
5
5
|
import { startFunctionsServer } from '../../lib/functions/server.js';
|
|
6
6
|
import { printBanner } from '../../utils/banner.js';
|
|
@@ -76,6 +76,12 @@ export const dev = async (options, command) => {
|
|
|
76
76
|
};
|
|
77
77
|
let { env } = cachedConfig;
|
|
78
78
|
env.NETLIFY_DEV = { sources: ['internal'], value: 'true' };
|
|
79
|
+
const blobsContext = await getBlobsContext({
|
|
80
|
+
debug: options.debug,
|
|
81
|
+
projectRoot: command.workingDir,
|
|
82
|
+
siteID: site.id ?? 'unknown-site-id',
|
|
83
|
+
});
|
|
84
|
+
env[BLOBS_CONTEXT_VARIABLE] = { sources: ['internal'], value: encodeBlobsContext(blobsContext) };
|
|
79
85
|
if (!options.offline && siteInfo.use_envelope) {
|
|
80
86
|
env = await getEnvelopeEnv({ api, context: options.context, env, siteInfo });
|
|
81
87
|
log(`${NETLIFYDEVLOG} Injecting environment variable values for ${chalk.yellow('all scopes')}`);
|
|
@@ -117,11 +123,6 @@ export const dev = async (options, command) => {
|
|
|
117
123
|
DEPLOY_URL: url,
|
|
118
124
|
},
|
|
119
125
|
});
|
|
120
|
-
const blobsContext = await getBlobsContext({
|
|
121
|
-
debug: options.debug,
|
|
122
|
-
projectRoot: command.workingDir,
|
|
123
|
-
siteID: site.id ?? 'unknown-site-id',
|
|
124
|
-
});
|
|
125
126
|
const functionsRegistry = await startFunctionsServer({
|
|
126
127
|
api,
|
|
127
128
|
blobsContext,
|
|
@@ -23,7 +23,6 @@ import { readRepoURL, validateRepoURL } from '../../utils/read-repo-url.js';
|
|
|
23
23
|
const copyTemplateDir = promisify(copyTemplateDirOriginal);
|
|
24
24
|
const require = createRequire(import.meta.url);
|
|
25
25
|
const templatesDir = path.resolve(dirname(fileURLToPath(import.meta.url)), '../../functions-templates');
|
|
26
|
-
const showRustTemplates = process.env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE === 'true';
|
|
27
26
|
/**
|
|
28
27
|
* Ensure that there's a sub-directory in `src/functions-templates` named after
|
|
29
28
|
* each `value` property in this list.
|
|
@@ -32,7 +31,7 @@ const languages = [
|
|
|
32
31
|
{ name: 'JavaScript', value: 'javascript' },
|
|
33
32
|
{ name: 'TypeScript', value: 'typescript' },
|
|
34
33
|
{ name: 'Go', value: 'go' },
|
|
35
|
-
|
|
34
|
+
{ name: 'Rust', value: 'rust' },
|
|
36
35
|
];
|
|
37
36
|
/**
|
|
38
37
|
* prompt for a name if name not supplied
|
|
@@ -153,11 +152,9 @@ const pickTemplate = async function ({ language: languageFromFlag }, funcType) {
|
|
|
153
152
|
let language = languageFromFlag;
|
|
154
153
|
if (language === undefined) {
|
|
155
154
|
const langs = funcType === 'edge'
|
|
156
|
-
?
|
|
157
|
-
languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
|
|
155
|
+
? languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
|
|
158
156
|
: languages.filter(Boolean);
|
|
159
157
|
const { language: languageFromPrompt } = await inquirer.prompt({
|
|
160
|
-
// @ts-expect-error
|
|
161
158
|
choices: langs,
|
|
162
159
|
message: 'Select the language of your function',
|
|
163
160
|
name: 'language',
|
|
@@ -202,7 +199,7 @@ const DEFAULT_PRIORITY = 999;
|
|
|
202
199
|
const selectTypeOfFunc = async () => {
|
|
203
200
|
const functionTypes = [
|
|
204
201
|
{ name: 'Edge function (Deno)', value: 'edge' },
|
|
205
|
-
{ name: 'Serverless function (Node/Go)', value: 'serverless' },
|
|
202
|
+
{ name: 'Serverless function (Node/Go/Rust)', value: 'serverless' },
|
|
206
203
|
];
|
|
207
204
|
const { functionType } = await inquirer.prompt([
|
|
208
205
|
{
|
|
@@ -468,6 +465,11 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
|
|
|
468
465
|
}
|
|
469
466
|
await installAddons(command, addons, path.resolve(functionPath));
|
|
470
467
|
await handleOnComplete({ command, onComplete });
|
|
468
|
+
log();
|
|
469
|
+
log(chalk.greenBright(`Function created!`));
|
|
470
|
+
if (lang == 'rust') {
|
|
471
|
+
log(chalk.green(`Please note that Rust functions require setting the NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE environment variable to 'true' on your site.`));
|
|
472
|
+
}
|
|
471
473
|
}
|
|
472
474
|
};
|
|
473
475
|
const TEMPLATE_PERMISSIONS = 0o777;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
|
-
import { getBlobsContext } from '../../lib/blobs/blobs.js';
|
|
2
|
+
import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext, getBlobsContext } from '../../lib/blobs/blobs.js';
|
|
3
3
|
import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.js';
|
|
4
4
|
import { startFunctionsServer } from '../../lib/functions/server.js';
|
|
5
5
|
import { printBanner } from '../../utils/banner.js';
|
|
@@ -70,6 +70,7 @@ export const serve = async (options, command) => {
|
|
|
70
70
|
projectRoot: command.workingDir,
|
|
71
71
|
siteID: site.id ?? 'unknown-site-id',
|
|
72
72
|
});
|
|
73
|
+
process.env[BLOBS_CONTEXT_VARIABLE] = encodeBlobsContext(blobsContext);
|
|
73
74
|
const functionsRegistry = await startFunctionsServer({
|
|
74
75
|
api,
|
|
75
76
|
blobsContext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use aws_lambda_events::event::apigw::{ApiGatewayProxyRequest, ApiGatewayProxyResponse};
|
|
2
2
|
use aws_lambda_events::encodings::Body;
|
|
3
3
|
use http::header::HeaderMap;
|
|
4
|
-
use lambda_runtime::{
|
|
4
|
+
use lambda_runtime::{service_fn, Error, LambdaEvent};
|
|
5
5
|
use log::LevelFilter;
|
|
6
6
|
use simple_logger::SimpleLogger;
|
|
7
7
|
|
|
@@ -9,13 +9,13 @@ use simple_logger::SimpleLogger;
|
|
|
9
9
|
async fn main() -> Result<(), Error> {
|
|
10
10
|
SimpleLogger::new().with_utc_timestamps().with_level(LevelFilter::Info).init().unwrap();
|
|
11
11
|
|
|
12
|
-
let func =
|
|
12
|
+
let func = service_fn(my_handler);
|
|
13
13
|
lambda_runtime::run(func).await?;
|
|
14
14
|
Ok(())
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
pub(crate) async fn my_handler(event: ApiGatewayProxyRequest
|
|
18
|
-
let path = event.path.unwrap();
|
|
17
|
+
pub(crate) async fn my_handler(event: LambdaEvent<ApiGatewayProxyRequest>) -> Result<ApiGatewayProxyResponse, Error> {
|
|
18
|
+
let path = event.payload.path.unwrap();
|
|
19
19
|
|
|
20
20
|
let resp = ApiGatewayProxyResponse {
|
|
21
21
|
status_code: 200,
|
package/src/lib/blobs/blobs.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import { BlobsServer } from '@netlify/blobs';
|
|
3
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
5
|
import { log, NETLIFYDEVLOG } from '../../utils/command-helpers.js';
|
|
5
6
|
import { getPathInProject } from '../settings.js';
|
|
6
7
|
let hasPrintedLocalBlobsNotice = false;
|
|
8
|
+
export const BLOBS_CONTEXT_VARIABLE = 'NETLIFY_BLOBS_CONTEXT';
|
|
7
9
|
const printLocalBlobsNotice = () => {
|
|
8
10
|
if (hasPrintedLocalBlobsNotice) {
|
|
9
11
|
return;
|
|
@@ -39,3 +41,8 @@ export const getBlobsContext = async ({ debug, projectRoot, siteID }) => {
|
|
|
39
41
|
};
|
|
40
42
|
return context;
|
|
41
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Returns a Base-64, JSON-encoded representation of the Blobs context. This is
|
|
46
|
+
* the format that the `@netlify/blobs` package expects to find the context in.
|
|
47
|
+
*/
|
|
48
|
+
export const encodeBlobsContext = (context) => Buffer.from(JSON.stringify(context)).toString('base64');
|
|
@@ -3,6 +3,7 @@ import { dirname } from 'path';
|
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
4
|
import { Worker } from 'worker_threads';
|
|
5
5
|
import lambdaLocal from 'lambda-local';
|
|
6
|
+
import { BLOBS_CONTEXT_VARIABLE } from '../../../blobs/blobs.js';
|
|
6
7
|
import detectNetlifyLambdaBuilder from './builders/netlify-lambda.js';
|
|
7
8
|
import detectZisiBuilder, { parseFunctionForMetadata } from './builders/zisi.js';
|
|
8
9
|
import { SECONDS_TO_MILLISECONDS } from './constants.js';
|
|
@@ -83,6 +84,14 @@ export const invokeFunctionDirectly = async ({ context, event, func, timeout })
|
|
|
83
84
|
const lambdaPath = func.buildData?.buildPath ?? func.mainFile;
|
|
84
85
|
const result = await lambdaLocal.execute({
|
|
85
86
|
clientContext: JSON.stringify(context),
|
|
87
|
+
environment: {
|
|
88
|
+
// We've set the Blobs context on the parent process, which means it will
|
|
89
|
+
// be available to the Lambda. This would be inconsistent with production
|
|
90
|
+
// where only V2 functions get the context injected. To fix it, unset the
|
|
91
|
+
// context variable before invoking the function.
|
|
92
|
+
// This has the side-effect of also removing the variable from `process.env`.
|
|
93
|
+
[BLOBS_CONTEXT_VARIABLE]: undefined,
|
|
94
|
+
},
|
|
86
95
|
event,
|
|
87
96
|
lambdaPath,
|
|
88
97
|
timeoutMs: timeout * SECONDS_TO_MILLISECONDS,
|