Skip to content

Commit 82abf15

Browse files
renovate[bot]danez
andauthored
fix(deps): update dependency dot-prop to v7 (#5737)
* fix(deps): update dependency dot-prop to v8 * Revert "fix(deps): update dependency dot-prop to v8" This reverts commit 81afc51. * fix(deps): update dependency dot-prop to v7 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Daniel Tschinder <[email protected]>
1 parent e41bd63 commit 82abf15

File tree

13 files changed

+95
-105
lines changed

13 files changed

+95
-105
lines changed

package-lock.json

+50-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"cron-parser": "4.8.1",
109109
"debug": "4.3.4",
110110
"decache": "4.6.1",
111-
"dot-prop": "6.0.1",
111+
"dot-prop": "7.2.0",
112112
"dotenv": "16.0.3",
113113
"env-paths": "3.0.0",
114114
"envinfo": "7.8.1",

src/commands/deploy/deploy.mjs

+12-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { cwd, env } from 'process'
66
import { runCoreSteps } from '@netlify/build'
77
import { restoreConfig, updateConfig } from '@netlify/config'
88
import { Option } from 'commander'
9-
import { get } from 'dot-prop'
109
import inquirer from 'inquirer'
1110
import isObject from 'lodash/isObject.js'
1211
import prettyjson from 'prettyjson'
@@ -15,7 +14,7 @@ import { cancelDeploy } from '../../lib/api.mjs'
1514
import { getBuildOptions, runBuild } from '../../lib/build.mjs'
1615
import { featureFlags as edgeFunctionsFeatureFlags } from '../../lib/edge-functions/consts.mjs'
1716
import { normalizeFunctionsConfig } from '../../lib/functions/config.mjs'
18-
import { getLogMessage } from '../../lib/log.mjs'
17+
import { BACKGROUND_FUNCTIONS_WARNING } from '../../lib/log.mjs'
1918
import { startSpinner, stopSpinner } from '../../lib/spinner.mjs'
2019
import {
2120
chalk,
@@ -74,10 +73,10 @@ const getDeployFolder = async ({ config, options, site, siteData }) => {
7473
let deployFolder
7574
if (options.dir) {
7675
deployFolder = resolve(cwd(), options.dir)
77-
} else if (get(config, 'build.publish')) {
78-
deployFolder = resolve(site.root, get(config, 'build.publish'))
79-
} else if (get(siteData, 'build_settings.dir')) {
80-
deployFolder = resolve(site.root, get(siteData, 'build_settings.dir'))
76+
} else if (config?.build?.publish) {
77+
deployFolder = resolve(site.root, config.build.publish)
78+
} else if (siteData?.build_settings?.dir) {
79+
deployFolder = resolve(site.root, siteData.build_settings.dir)
8180
}
8281

8382
if (!deployFolder) {
@@ -138,8 +137,8 @@ const getFunctionsFolder = ({ config, options, site, siteData }) => {
138137
functionsFolder = resolve(cwd(), options.functions)
139138
} else if (funcConfig) {
140139
functionsFolder = resolve(site.root, funcConfig)
141-
} else if (get(siteData, 'build_settings.functions_dir')) {
142-
functionsFolder = resolve(site.root, get(siteData, 'build_settings.functions_dir'))
140+
} else if (siteData?.build_settings?.functions_dir) {
141+
functionsFolder = resolve(site.root, siteData.build_settings.functions_dir)
143142
}
144143
return functionsFolder
145144
}
@@ -232,14 +231,12 @@ const hasErrorMessage = (actual, expected) => {
232231
return false
233232
}
234233

235-
const getJsonErrorMessage = (error_) => get(error_, 'json.message', '')
236-
237234
const reportDeployError = ({ error_, failAndExit }) => {
238235
switch (true) {
239236
case error_.name === 'JSONHTTPError': {
240-
const message = getJsonErrorMessage(error)
237+
const message = error_?.json?.message ?? ''
241238
if (hasErrorMessage(message, 'Background Functions not allowed by team plan')) {
242-
return failAndExit(`\n${getLogMessage('functions.backgroundNotSupported')}`)
239+
return failAndExit(`\n${BACKGROUND_FUNCTIONS_WARNING}`)
243240
}
244241
warn(`JSONHTTPError: ${message} ${error_.status}`)
245242
warn(`\n${JSON.stringify(error_, null, ' ')}\n`)
@@ -358,8 +355,8 @@ const runDeploy = async ({
358355
}
359356

360357
const siteUrl = results.deploy.ssl_url || results.deploy.url
361-
const deployUrl = get(results, 'deploy.deploy_ssl_url') || get(results, 'deploy.deploy_url')
362-
const logsUrl = `${get(results, 'deploy.admin_url')}/deploys/${get(results, 'deploy.id')}`
358+
const deployUrl = results.deploy.deploy_ssl_url || results.deploy.deploy_url
359+
const logsUrl = `${results.deploy.admin_url}/deploys/${results.deploy.id}`
363360

364361
return {
365362
siteId: results.deploy.site_id,
@@ -616,7 +613,7 @@ const deploy = async (options, command) => {
616613
scope: 'functions',
617614
siteInfo: siteData,
618615
})
619-
: get(siteData, 'build_settings.env')
616+
: siteData?.build_settings?.env
620617

621618
const functionsConfig = normalizeFunctionsConfig({
622619
functionsConfig: config.functions,

src/commands/init/init.mjs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @ts-check
22
import { Option } from 'commander'
3-
import dotProp from 'dot-prop'
43
import inquirer from 'inquirer'
54
import isEmpty from 'lodash/isEmpty.js'
65

@@ -17,7 +16,11 @@ const persistState = ({ siteInfo, state }) => {
1716
state.set('siteId', siteInfo.id)
1817
}
1918

20-
const getRepoUrl = ({ siteInfo }) => dotProp.get(siteInfo, 'build_settings.repo_url')
19+
/**
20+
* @param {{} | undefined} siteInfo
21+
* @returns {string | undefined}
22+
*/
23+
const getRepoUrl = (siteInfo) => siteInfo?.build_settings?.repo_url
2124

2225
const logExistingAndExit = ({ siteInfo }) => {
2326
log()
@@ -187,7 +190,7 @@ export const init = async (options, command) => {
187190
// Add .netlify to .gitignore file
188191
await ensureNetlifyIgnore(repositoryRoot)
189192

190-
const repoUrl = getRepoUrl({ siteInfo })
193+
const repoUrl = getRepoUrl(siteInfo)
191194
if (repoUrl && !options.force) {
192195
logExistingAndExit({ siteInfo })
193196
}
@@ -205,7 +208,7 @@ export const init = async (options, command) => {
205208
log()
206209

207210
// Check for existing CI setup
208-
const remoteBuildRepo = getRepoUrl({ siteInfo })
211+
const remoteBuildRepo = getRepoUrl(siteInfo)
209212
if (remoteBuildRepo && !options.force) {
210213
logExistingRepoSetupAndExit({ siteName: siteInfo.name, repoUrl: remoteBuildRepo })
211214
}

src/commands/status/status-hooks.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// @ts-check
2-
import { get } from 'dot-prop'
32
import prettyjson from 'prettyjson'
43

54
import { error, log, warn } from '../../utils/command-helpers.mjs'
@@ -48,8 +47,8 @@ const statusHooks = async (options, command) => {
4847
id: hook.id,
4948
disabled: hook.disabled,
5049
}
51-
if (get(siteData, 'build_settings.repo_url')) {
52-
data.hooks[hook.id].repo_url = get(siteData, 'build_settings.repo_url')
50+
if (siteData.build_settings?.repo_url) {
51+
data.hooks[hook.id].repo_url = siteData.build_settings.repo_url
5352
}
5453
})
5554
log(`─────────────────┐

src/lib/functions/registry.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
watchDebounced,
1616
} from '../../utils/command-helpers.mjs'
1717
import { INTERNAL_FUNCTIONS_FOLDER, SERVE_FUNCTIONS_FOLDER } from '../../utils/functions/functions.mjs'
18-
import { getLogMessage } from '../log.mjs'
18+
import { BACKGROUND_FUNCTIONS_WARNING } from '../log.mjs'
1919
import { getPathInProject } from '../settings.mjs'
2020

2121
import NetlifyFunction from './netlify-function.mjs'
@@ -140,7 +140,7 @@ export class FunctionsRegistry {
140140
}
141141

142142
if (func.isBackground && this.isConnected && !this.capabilities.backgroundFunctions) {
143-
warn(getLogMessage('functions.backgroundNotSupported'))
143+
warn(BACKGROUND_FUNCTIONS_WARNING)
144144
}
145145

146146
if (!func.hasValidName()) {

src/lib/functions/server.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// @ts-check
2-
import { get } from 'dot-prop'
32
import jwtDecode from 'jwt-decode'
43

54
import { NETLIFYDEVERR, NETLIFYDEVLOG, error as errorExit, log } from '../../utils/command-helpers.mjs'
@@ -94,7 +93,7 @@ export const createHandler = function (options) {
9493
{},
9594
)
9695
const rawQuery = new URLSearchParams(request.query).toString()
97-
const protocol = get(options, 'config.dev.https') ? 'https' : 'http'
96+
const protocol = options.config?.dev?.https ? 'https' : 'http'
9897
const url = new URL(requestPath, `${protocol}://${request.get('host') || 'localhost'}`)
9998
url.search = rawQuery
10099
const rawUrl = url.toString()

src/lib/functions/utils.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// @ts-check
22
import { chalk, warn } from '../../utils/command-helpers.mjs'
3-
import { getLogMessage } from '../log.mjs'
3+
import { MISSING_AWS_SDK_WARNING } from '../log.mjs'
44

55
export const detectAwsSdkError = ({ error }) => {
66
const isAwsSdkError = error && error.errorMessage && error.errorMessage.includes("Cannot find module 'aws-sdk'")
77

88
if (isAwsSdkError) {
9-
warn(getLogMessage('functions.missingAwsSdk'))
9+
warn(MISSING_AWS_SDK_WARNING)
1010
}
1111
}
1212

src/lib/log.mjs

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
import dotProp from 'dot-prop'
2-
31
import { chalk } from '../utils/command-helpers.mjs'
42

53
const RED_BACKGROUND = chalk.red('-background')
64
const [PRO, BUSINESS, ENTERPRISE] = ['Pro', 'Business', 'Enterprise'].map((plan) => chalk.magenta(plan))
7-
const BACKGROUND_FUNCTIONS_WARNING = `A serverless function ending in \`${RED_BACKGROUND}\` was detected.
5+
export const BACKGROUND_FUNCTIONS_WARNING = `A serverless function ending in \`${RED_BACKGROUND}\` was detected.
86
Your team’s current plan doesn’t support Background Functions, which have names ending in \`${RED_BACKGROUND}\`.
97
To be able to deploy this function successfully either:
108
- change the function name to remove \`${RED_BACKGROUND}\` and execute it synchronously
119
- upgrade your team plan to a level that supports Background Functions (${PRO}, ${BUSINESS}, or ${ENTERPRISE})
1210
`
13-
const MISSING_AWS_SDK_WARNING = `A function has thrown an error due to a missing dependency: ${chalk.yellow('aws-sdk')}.
11+
export const MISSING_AWS_SDK_WARNING = `A function has thrown an error due to a missing dependency: ${chalk.yellow(
12+
'aws-sdk',
13+
)}.
1414
You should add this module to the project's dependencies, using your package manager of choice:
1515
1616
${chalk.yellow('npm install aws-sdk --save')} or ${chalk.yellow('yarn add aws-sdk')}
1717
1818
For more information, see https://ntl.fyi/cli-aws-sdk.`
19-
20-
const messages = {
21-
functions: {
22-
backgroundNotSupported: BACKGROUND_FUNCTIONS_WARNING,
23-
missingAwsSdk: MISSING_AWS_SDK_WARNING,
24-
},
25-
}
26-
27-
export const getLogMessage = (key) => dotProp.get(messages, key, 'Missing Log Message Key')

0 commit comments

Comments
 (0)