netlify-cli 16.0.2 → 16.1.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 +9 -9
- package/package.json +2 -2
- package/src/commands/base-command.mjs +1 -1
- package/src/commands/deploy/deploy.mjs +5 -2
- 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/src/utils/proxy.mjs +20 -4
- package/src/utils/run-build.mjs +1 -1
- package/src/utils/telemetry/telemetry.mjs +20 -4
- package/src/utils/validation.mjs +4 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "16.0
|
|
3
|
+
"version": "16.1.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "16.0
|
|
9
|
+
"version": "16.1.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/build": "29.20.
|
|
15
|
+
"@netlify/build": "29.20.4",
|
|
16
16
|
"@netlify/build-info": "7.7.3",
|
|
17
17
|
"@netlify/config": "20.8.0",
|
|
18
18
|
"@netlify/edge-bundler": "8.17.1",
|
|
@@ -781,9 +781,9 @@
|
|
|
781
781
|
"integrity": "sha512-4wMPu9iN3/HL97QblBsBay3E1etIciR84izI3U+4iALY+JHCrI+a2jO0qbAZ/nxKoegypYEaiiqWXylm+/zfrw=="
|
|
782
782
|
},
|
|
783
783
|
"node_modules/@netlify/build": {
|
|
784
|
-
"version": "29.20.
|
|
785
|
-
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.20.
|
|
786
|
-
"integrity": "sha512-
|
|
784
|
+
"version": "29.20.4",
|
|
785
|
+
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.20.4.tgz",
|
|
786
|
+
"integrity": "sha512-qXht5lWE0RThGhhB5ILQv4/2Jp+p0muTDp9n+KtlqpinO1SvXicVPw+D2o3iWMsz3vQak6yX09oEvumP2Q+TVQ==",
|
|
787
787
|
"dependencies": {
|
|
788
788
|
"@bugsnag/js": "^7.0.0",
|
|
789
789
|
"@honeycombio/opentelemetry-node": "^0.4.0",
|
|
@@ -15295,9 +15295,9 @@
|
|
|
15295
15295
|
"integrity": "sha512-4wMPu9iN3/HL97QblBsBay3E1etIciR84izI3U+4iALY+JHCrI+a2jO0qbAZ/nxKoegypYEaiiqWXylm+/zfrw=="
|
|
15296
15296
|
},
|
|
15297
15297
|
"@netlify/build": {
|
|
15298
|
-
"version": "29.20.
|
|
15299
|
-
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.20.
|
|
15300
|
-
"integrity": "sha512-
|
|
15298
|
+
"version": "29.20.4",
|
|
15299
|
+
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-29.20.4.tgz",
|
|
15300
|
+
"integrity": "sha512-qXht5lWE0RThGhhB5ILQv4/2Jp+p0muTDp9n+KtlqpinO1SvXicVPw+D2o3iWMsz3vQak6yX09oEvumP2Q+TVQ==",
|
|
15301
15301
|
"requires": {
|
|
15302
15302
|
"@bugsnag/js": "^7.0.0",
|
|
15303
15303
|
"@honeycombio/opentelemetry-node": "^0.4.0",
|
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.1.0",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -44,7 +44,7 @@
|
|
|
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",
|
|
@@ -574,7 +574,7 @@ export default class BaseCommand extends Command {
|
|
|
574
574
|
// configuration file and the API
|
|
575
575
|
// ==================================================
|
|
576
576
|
const cachedConfig = await actionCommand.getConfig({
|
|
577
|
-
cwd: this.jsWorkspaceRoot || this.workingDir,
|
|
577
|
+
cwd: flags.cwd ? this.workingDir : this.jsWorkspaceRoot || this.workingDir,
|
|
578
578
|
repositoryRoot: rootDir,
|
|
579
579
|
packagePath: this.workspacePackage,
|
|
580
580
|
// The config flag needs to be resolved from the actual process working directory
|
|
@@ -324,6 +324,7 @@ const runDeploy = async ({
|
|
|
324
324
|
deployToProduction,
|
|
325
325
|
functionsConfig,
|
|
326
326
|
functionsFolder,
|
|
327
|
+
packagePath,
|
|
327
328
|
silent,
|
|
328
329
|
site,
|
|
329
330
|
siteData,
|
|
@@ -345,13 +346,13 @@ const runDeploy = async ({
|
|
|
345
346
|
results = await api.createSiteDeploy({ siteId, title, body: { draft, branch: alias } })
|
|
346
347
|
deployId = results.id
|
|
347
348
|
|
|
348
|
-
const internalFunctionsFolder = await getInternalFunctionsDir({ base: site.root })
|
|
349
|
+
const internalFunctionsFolder = await getInternalFunctionsDir({ base: site.root, packagePath })
|
|
349
350
|
|
|
350
351
|
// The order of the directories matter: zip-it-and-ship-it will prioritize
|
|
351
352
|
// functions from the rightmost directories. In this case, we want user
|
|
352
353
|
// functions to take precedence over internal functions.
|
|
353
354
|
const functionDirectories = [internalFunctionsFolder, functionsFolder].filter(Boolean)
|
|
354
|
-
const manifestPath = skipFunctionsCache ? null : await getFunctionsManifestPath({ base: site.root })
|
|
355
|
+
const manifestPath = skipFunctionsCache ? null : await getFunctionsManifestPath({ base: site.root, packagePath })
|
|
355
356
|
|
|
356
357
|
// @ts-ignore
|
|
357
358
|
results = await deploySite(api, siteId, deployFolder, {
|
|
@@ -367,6 +368,7 @@ const runDeploy = async ({
|
|
|
367
368
|
workingDir: command.workingDir,
|
|
368
369
|
manifestPath,
|
|
369
370
|
skipFunctionsCache,
|
|
371
|
+
siteRoot: site.root,
|
|
370
372
|
})
|
|
371
373
|
} catch (error_) {
|
|
372
374
|
if (deployId) {
|
|
@@ -657,6 +659,7 @@ const deploy = async (options, command) => {
|
|
|
657
659
|
functionsConfig,
|
|
658
660
|
// pass undefined functionsFolder if doesn't exist
|
|
659
661
|
functionsFolder: functionsFolderStat && functionsFolder,
|
|
662
|
+
packagePath: command.workspacePackage,
|
|
660
663
|
silent: options.json || options.silent,
|
|
661
664
|
site,
|
|
662
665
|
siteData,
|
|
@@ -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 })
|
package/src/utils/proxy.mjs
CHANGED
|
@@ -75,19 +75,35 @@ const formatEdgeFunctionError = (errorBuffer, acceptsHtml) => {
|
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} url
|
|
80
|
+
*/
|
|
81
|
+
function isInternal(url) {
|
|
79
82
|
return url.startsWith('/.netlify/')
|
|
80
83
|
}
|
|
81
|
-
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {boolean|number|undefined} functionsPort
|
|
87
|
+
* @param {string} url
|
|
88
|
+
*/
|
|
89
|
+
function isFunction(functionsPort, url) {
|
|
82
90
|
return functionsPort && url.match(/^\/.netlify\/(functions|builders)\/.+/)
|
|
83
91
|
}
|
|
84
92
|
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
/**
|
|
94
|
+
* @param {Record<string, string>} addonsUrls
|
|
95
|
+
* @param {http.IncomingMessage} req
|
|
96
|
+
*/
|
|
97
|
+
function getAddonUrl(addonsUrls, req) {
|
|
98
|
+
const matches = req.url?.match(/^\/.netlify\/([^/]+)(\/.*)/)
|
|
87
99
|
const addonUrl = matches && addonsUrls[matches[1]]
|
|
88
100
|
return addonUrl ? `${addonUrl}${matches[2]}` : null
|
|
89
101
|
}
|
|
90
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @param {string} pathname
|
|
105
|
+
* @param {string} publicFolder
|
|
106
|
+
*/
|
|
91
107
|
const getStatic = async function (pathname, publicFolder) {
|
|
92
108
|
const alternatives = [pathname, ...alternativePathsFor(pathname)].map((filePath) =>
|
|
93
109
|
path.resolve(publicFolder, filePath.slice(1)),
|
package/src/utils/run-build.mjs
CHANGED
|
@@ -80,7 +80,7 @@ export const runNetlifyBuild = async ({ command, env = {}, options, settings, ti
|
|
|
80
80
|
const devCommand = async (settingsOverrides = {}) => {
|
|
81
81
|
let cwd = command.workingDir
|
|
82
82
|
|
|
83
|
-
if (command.project.workspace?.packages.length) {
|
|
83
|
+
if (!options.cwd && command.project.workspace?.packages.length) {
|
|
84
84
|
cwd = join(command.project.jsWorkspaceRoot, settings.baseDirectory || '')
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -13,14 +13,18 @@ import isValidEventName from './validation.mjs'
|
|
|
13
13
|
|
|
14
14
|
const dirPath = dirname(fileURLToPath(import.meta.url))
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @param {'track' | 'identify'} type
|
|
18
|
+
* @param {object} payload
|
|
19
|
+
*/
|
|
20
|
+
function send(type, payload) {
|
|
17
21
|
const requestFile = join(dirPath, 'request.mjs')
|
|
18
22
|
const options = JSON.stringify({
|
|
19
23
|
data: payload,
|
|
20
24
|
type,
|
|
21
25
|
})
|
|
22
26
|
|
|
23
|
-
const args = [process.execPath, [requestFile, options]]
|
|
27
|
+
const args = /** @type {const} */ ([process.execPath, [requestFile, options]])
|
|
24
28
|
if (process.env.NETLIFY_TEST_TELEMETRY_WAIT === 'true') {
|
|
25
29
|
return execa(...args, {
|
|
26
30
|
stdio: 'inherit',
|
|
@@ -46,7 +50,12 @@ const eventConfig = {
|
|
|
46
50
|
],
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Tracks a custom event with the provided payload
|
|
55
|
+
* @param {string} eventName
|
|
56
|
+
* @param {{status?: string, duration?: number, [key: string]: unknown}} [payload]
|
|
57
|
+
*/
|
|
58
|
+
export async function track(eventName, payload = {}) {
|
|
50
59
|
if (isCI) {
|
|
51
60
|
return
|
|
52
61
|
}
|
|
@@ -83,7 +92,14 @@ export const track = async function (eventName, payload = {}) {
|
|
|
83
92
|
return send('track', defaultData)
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
|
|
95
|
+
/**
|
|
96
|
+
* @param {object} payload
|
|
97
|
+
* @param {string} payload.name
|
|
98
|
+
* @param {string} payload.email
|
|
99
|
+
* @param {string} payload.userId
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
export async function identify(payload) {
|
|
87
103
|
if (isCI) {
|
|
88
104
|
return
|
|
89
105
|
}
|
package/src/utils/validation.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { BANG, chalk } from './command-helpers.mjs'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} exampleCommand
|
|
6
|
+
* @returns {(value:string, previous: unknown) => unknown}
|
|
7
|
+
*/
|
|
4
8
|
export const getGeoCountryArgParser = (exampleCommand) => (arg) => {
|
|
5
9
|
// Validate that the arg passed is two letters only for country
|
|
6
10
|
// See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
|