netlify-cli 16.0.1 → 16.0.3
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 +214 -710
- package/package.json +3 -3
- package/src/commands/build/build.mjs +1 -0
- package/src/commands/deploy/deploy.mjs +11 -3
- package/src/lib/build.mjs +3 -0
- package/src/lib/functions/server.mjs +26 -5
- package/src/utils/deploy/deploy-site.mjs +2 -0
- package/src/utils/deploy/hash-fns.mjs +2 -2
- package/src/utils/functions/functions.mjs +7 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "16.0.
|
|
4
|
+
"version": "16.0.3",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@bugsnag/js": "7.20.2",
|
|
46
46
|
"@fastify/static": "6.10.2",
|
|
47
|
-
"@netlify/build": "29.20.
|
|
47
|
+
"@netlify/build": "29.20.4",
|
|
48
48
|
"@netlify/build-info": "7.7.3",
|
|
49
49
|
"@netlify/config": "20.8.0",
|
|
50
50
|
"@netlify/edge-bundler": "8.17.1",
|
|
51
51
|
"@netlify/local-functions-proxy": "1.1.1",
|
|
52
52
|
"@netlify/serverless-functions-api": "1.5.2",
|
|
53
|
-
"@netlify/zip-it-and-ship-it": "9.
|
|
53
|
+
"@netlify/zip-it-and-ship-it": "9.15.1",
|
|
54
54
|
"@octokit/rest": "19.0.13",
|
|
55
55
|
"ansi-escapes": "6.2.0",
|
|
56
56
|
"ansi-styles": "6.2.1",
|
|
@@ -13,6 +13,7 @@ import prettyjson from 'prettyjson'
|
|
|
13
13
|
|
|
14
14
|
import { cancelDeploy } from '../../lib/api.mjs'
|
|
15
15
|
import { getBuildOptions, runBuild } from '../../lib/build.mjs'
|
|
16
|
+
import { getBootstrapURL } from '../../lib/edge-functions/bootstrap.mjs'
|
|
16
17
|
import { featureFlags as edgeFunctionsFeatureFlags } from '../../lib/edge-functions/consts.mjs'
|
|
17
18
|
import { normalizeFunctionsConfig } from '../../lib/functions/config.mjs'
|
|
18
19
|
import { BACKGROUND_FUNCTIONS_WARNING } from '../../lib/log.mjs'
|
|
@@ -323,6 +324,7 @@ const runDeploy = async ({
|
|
|
323
324
|
deployToProduction,
|
|
324
325
|
functionsConfig,
|
|
325
326
|
functionsFolder,
|
|
327
|
+
packagePath,
|
|
326
328
|
silent,
|
|
327
329
|
site,
|
|
328
330
|
siteData,
|
|
@@ -344,13 +346,13 @@ const runDeploy = async ({
|
|
|
344
346
|
results = await api.createSiteDeploy({ siteId, title, body: { draft, branch: alias } })
|
|
345
347
|
deployId = results.id
|
|
346
348
|
|
|
347
|
-
const internalFunctionsFolder = await getInternalFunctionsDir({ base: site.root })
|
|
349
|
+
const internalFunctionsFolder = await getInternalFunctionsDir({ base: site.root, packagePath })
|
|
348
350
|
|
|
349
351
|
// The order of the directories matter: zip-it-and-ship-it will prioritize
|
|
350
352
|
// functions from the rightmost directories. In this case, we want user
|
|
351
353
|
// functions to take precedence over internal functions.
|
|
352
354
|
const functionDirectories = [internalFunctionsFolder, functionsFolder].filter(Boolean)
|
|
353
|
-
const manifestPath = skipFunctionsCache ? null : await getFunctionsManifestPath({ base: site.root })
|
|
355
|
+
const manifestPath = skipFunctionsCache ? null : await getFunctionsManifestPath({ base: site.root, packagePath })
|
|
354
356
|
|
|
355
357
|
// @ts-ignore
|
|
356
358
|
results = await deploySite(api, siteId, deployFolder, {
|
|
@@ -366,6 +368,7 @@ const runDeploy = async ({
|
|
|
366
368
|
workingDir: command.workingDir,
|
|
367
369
|
manifestPath,
|
|
368
370
|
skipFunctionsCache,
|
|
371
|
+
siteRoot: site.root,
|
|
369
372
|
})
|
|
370
373
|
} catch (error_) {
|
|
371
374
|
if (deployId) {
|
|
@@ -399,16 +402,18 @@ const runDeploy = async ({
|
|
|
399
402
|
*
|
|
400
403
|
* @param {object} config
|
|
401
404
|
* @param {*} config.cachedConfig
|
|
405
|
+
* @param {string} [config.packagePath]
|
|
402
406
|
* @param {import('commander').OptionValues} config.options The options of the command
|
|
403
407
|
* @returns
|
|
404
408
|
*/
|
|
405
|
-
const handleBuild = async ({ cachedConfig, options }) => {
|
|
409
|
+
const handleBuild = async ({ cachedConfig, options, packagePath }) => {
|
|
406
410
|
if (!options.build) {
|
|
407
411
|
return {}
|
|
408
412
|
}
|
|
409
413
|
const [token] = await getToken()
|
|
410
414
|
const resolvedOptions = await getBuildOptions({
|
|
411
415
|
cachedConfig,
|
|
416
|
+
packagePath,
|
|
412
417
|
token,
|
|
413
418
|
options,
|
|
414
419
|
})
|
|
@@ -442,6 +447,7 @@ const bundleEdgeFunctions = async (options, command) => {
|
|
|
442
447
|
packagePath: command.workspacePackage,
|
|
443
448
|
buffer: true,
|
|
444
449
|
featureFlags: edgeFunctionsFeatureFlags,
|
|
450
|
+
edgeFunctionsBootstrapURL: getBootstrapURL(),
|
|
445
451
|
})
|
|
446
452
|
|
|
447
453
|
if (!success) {
|
|
@@ -587,6 +593,7 @@ const deploy = async (options, command) => {
|
|
|
587
593
|
}
|
|
588
594
|
|
|
589
595
|
const { configMutations = [], newConfig } = await handleBuild({
|
|
596
|
+
packagePath: command.workspacePackage,
|
|
590
597
|
cachedConfig: command.netlify.cachedConfig,
|
|
591
598
|
options,
|
|
592
599
|
})
|
|
@@ -652,6 +659,7 @@ const deploy = async (options, command) => {
|
|
|
652
659
|
functionsConfig,
|
|
653
660
|
// pass undefined functionsFolder if doesn't exist
|
|
654
661
|
functionsFolder: functionsFolderStat && functionsFolder,
|
|
662
|
+
packagePath: command.workspacePackage,
|
|
655
663
|
silent: options.json || options.silent,
|
|
656
664
|
site,
|
|
657
665
|
siteData,
|
package/src/lib/build.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import { featureFlags as edgeFunctionsFeatureFlags } from './edge-functions/cons
|
|
|
19
19
|
*
|
|
20
20
|
* @param {object} config
|
|
21
21
|
* @param {*} config.cachedConfig
|
|
22
|
+
* @param {string} [config.packagePath]
|
|
22
23
|
* @param {string} config.token
|
|
23
24
|
* @param {import('commander').OptionValues} config.options
|
|
24
25
|
* @returns {BuildConfig}
|
|
@@ -26,10 +27,12 @@ import { featureFlags as edgeFunctionsFeatureFlags } from './edge-functions/cons
|
|
|
26
27
|
export const getBuildOptions = ({
|
|
27
28
|
cachedConfig,
|
|
28
29
|
options: { context, cwd, debug, dry, json, offline, silent },
|
|
30
|
+
packagePath,
|
|
29
31
|
token,
|
|
30
32
|
}) => ({
|
|
31
33
|
cachedConfig,
|
|
32
34
|
siteId: cachedConfig.siteInfo.id,
|
|
35
|
+
packagePath,
|
|
33
36
|
token,
|
|
34
37
|
dry,
|
|
35
38
|
debug,
|
|
@@ -219,6 +219,20 @@ const getFunctionsServer = (options) => {
|
|
|
219
219
|
return app
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
*
|
|
224
|
+
* @param {object} options
|
|
225
|
+
* @param {import('../../commands/base-command.mjs').default} options.command
|
|
226
|
+
* @param {*} options.capabilities
|
|
227
|
+
* @param {*} options.config
|
|
228
|
+
* @param {boolean} options.debug
|
|
229
|
+
* @param {*} options.loadDistFunctions
|
|
230
|
+
* @param {*} options.settings
|
|
231
|
+
* @param {*} options.site
|
|
232
|
+
* @param {string} options.siteUrl
|
|
233
|
+
* @param {*} options.timeouts
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
222
236
|
export const startFunctionsServer = async (options) => {
|
|
223
237
|
const { capabilities, command, config, debug, loadDistFunctions, settings, site, siteUrl, timeouts } = options
|
|
224
238
|
const internalFunctionsDir = await getInternalFunctionsDir({ base: site.root })
|
|
@@ -260,15 +274,22 @@ export const startFunctionsServer = async (options) => {
|
|
|
260
274
|
|
|
261
275
|
const server = await getFunctionsServer(Object.assign(options, { functionsRegistry }))
|
|
262
276
|
|
|
263
|
-
await startWebServer({ server, settings })
|
|
277
|
+
await startWebServer({ server, settings, debug })
|
|
264
278
|
}
|
|
265
279
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
* @param {object} config
|
|
283
|
+
* @param {boolean} config.debug
|
|
284
|
+
* @param {ReturnType<Awaited<typeof getFunctionsServer>>} config.server
|
|
285
|
+
* @param {*} config.settings
|
|
286
|
+
*/
|
|
287
|
+
const startWebServer = async ({ debug, server, settings }) => {
|
|
288
|
+
await new Promise((/** @type {(resolve: void) => void} */ resolve) => {
|
|
289
|
+
server.listen(settings.functionsPort, (/** @type {unknown} */ err) => {
|
|
269
290
|
if (err) {
|
|
270
291
|
errorExit(`${NETLIFYDEVERR} Unable to start functions server: ${err}`)
|
|
271
|
-
} else {
|
|
292
|
+
} else if (debug) {
|
|
272
293
|
log(`${NETLIFYDEVLOG} Functions server is listening on ${settings.functionsPort}`)
|
|
273
294
|
}
|
|
274
295
|
resolve()
|
|
@@ -40,6 +40,7 @@ export const deploySite = async (
|
|
|
40
40
|
// API calls this the 'title'
|
|
41
41
|
message: title,
|
|
42
42
|
siteEnv,
|
|
43
|
+
siteRoot,
|
|
43
44
|
skipFunctionsCache,
|
|
44
45
|
statusCb = () => {
|
|
45
46
|
/* default to noop */
|
|
@@ -78,6 +79,7 @@ export const deploySite = async (
|
|
|
78
79
|
manifestPath,
|
|
79
80
|
skipFunctionsCache,
|
|
80
81
|
siteEnv,
|
|
82
|
+
rootDir: siteRoot,
|
|
81
83
|
}),
|
|
82
84
|
])
|
|
83
85
|
const edgeFunctionsCount = Object.keys(files).filter(isEdgeFunctionFile).length
|
|
@@ -20,10 +20,10 @@ const getFunctionZips = async ({
|
|
|
20
20
|
directories,
|
|
21
21
|
functionsConfig,
|
|
22
22
|
manifestPath,
|
|
23
|
+
rootDir,
|
|
23
24
|
skipFunctionsCache,
|
|
24
25
|
statusCb,
|
|
25
26
|
tmpDir,
|
|
26
|
-
workingDir,
|
|
27
27
|
}) => {
|
|
28
28
|
statusCb({
|
|
29
29
|
type: 'functions-manifest',
|
|
@@ -68,7 +68,7 @@ const getFunctionZips = async ({
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
return await zipFunctions(directories, tmpDir, {
|
|
71
|
-
basePath:
|
|
71
|
+
basePath: rootDir,
|
|
72
72
|
configFileDirectories: [getPathInProject([INTERNAL_FUNCTIONS_FOLDER])],
|
|
73
73
|
config: functionsConfig,
|
|
74
74
|
})
|
|
@@ -19,15 +19,15 @@ export const SERVE_FUNCTIONS_FOLDER = 'functions-serve'
|
|
|
19
19
|
export const getFunctionsDir = ({ config, options }, defaultValue) =>
|
|
20
20
|
options.functions || config.dev?.functions || config.functionsDirectory || config.dev?.Functions || defaultValue
|
|
21
21
|
|
|
22
|
-
export const getFunctionsManifestPath = async ({ base }) => {
|
|
23
|
-
const path = resolve(base, getPathInProject(['functions', 'manifest.json']))
|
|
22
|
+
export const getFunctionsManifestPath = async ({ base, packagePath = '' }) => {
|
|
23
|
+
const path = resolve(base, packagePath, getPathInProject(['functions', 'manifest.json']))
|
|
24
24
|
const isFile = await isFileAsync(path)
|
|
25
25
|
|
|
26
26
|
return isFile ? path : null
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const getFunctionsDistPath = async ({ base }) => {
|
|
30
|
-
const path = resolve(base, getPathInProject(['functions']))
|
|
29
|
+
export const getFunctionsDistPath = async ({ base, packagePath = '' }) => {
|
|
30
|
+
const path = resolve(base, packagePath, getPathInProject(['functions']))
|
|
31
31
|
const isDirectory = await isDirectoryAsync(path)
|
|
32
32
|
|
|
33
33
|
return isDirectory ? path : null
|
|
@@ -38,10 +38,11 @@ export const getFunctionsDistPath = async ({ base }) => {
|
|
|
38
38
|
* @param {object} config
|
|
39
39
|
* @param {string} config.base
|
|
40
40
|
* @param {boolean=} config.ensureExists
|
|
41
|
+
* @param {string} config.packagePath
|
|
41
42
|
* @returns
|
|
42
43
|
*/
|
|
43
|
-
export const getInternalFunctionsDir = async ({ base, ensureExists }) => {
|
|
44
|
-
const path = resolve(base, getPathInProject([INTERNAL_FUNCTIONS_FOLDER]))
|
|
44
|
+
export const getInternalFunctionsDir = async ({ base, ensureExists, packagePath = '' }) => {
|
|
45
|
+
const path = resolve(base, packagePath, getPathInProject([INTERNAL_FUNCTIONS_FOLDER]))
|
|
45
46
|
|
|
46
47
|
if (ensureExists) {
|
|
47
48
|
await fs.mkdir(path, { recursive: true })
|