Skip to content

Commit

Permalink
fix(deps): update dependency @netlify/zip-it-and-ship-it to v9 (#4982)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency @netlify/zip-it-and-ship-it to v9

* chore: set correct node version

* chore: update to 9.2.1

* chore: update test

* chore: fix test

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Tschinder <231804+danez@users.noreply.github.com>
renovate[bot] and danez authored Apr 25, 2023
1 parent cc5813f commit 4a77bbc
Showing 12 changed files with 134 additions and 71 deletions.
114 changes: 55 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/build-info/tests/__snapshots__/bin.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`CLI --help flag 1`] = `
"bin.js [projectDir]
2 changes: 1 addition & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@
"@netlify/git-utils": "^5.1.1",
"@netlify/plugins-list": "^6.68.0",
"@netlify/run-utils": "^5.1.0",
"@netlify/zip-it-and-ship-it": "8.10.0",
"@netlify/zip-it-and-ship-it": "9.2.1",
"@sindresorhus/slugify": "^2.0.0",
"ansi-escapes": "^6.0.0",
"chalk": "^5.0.0",
3 changes: 3 additions & 0 deletions packages/build/src/core/build.ts
Original file line number Diff line number Diff line change
@@ -451,6 +451,7 @@ const initAndRunBuild = async function ({
packageJson,
configPath,
outputConfigPath,
userNodeVersion,
headersPath,
redirectsPath,
buildDir,
@@ -515,6 +516,7 @@ const runBuild = async function ({
packageJson,
configPath,
outputConfigPath,
userNodeVersion,
headersPath,
redirectsPath,
buildDir,
@@ -599,6 +601,7 @@ const runBuild = async function ({
testOpts,
featureFlags,
quiet,
userNodeVersion,
})

return {
10 changes: 7 additions & 3 deletions packages/build/src/plugins_core/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'path'

import { NodeBundlerType, RuntimeType, zipFunctions } from '@netlify/zip-it-and-ship-it'
import { NodeBundlerName, RUNTIME, zipFunctions } from '@netlify/zip-it-and-ship-it'
import { pathExists } from 'path-exists'

import { log } from '../../log/logger.js'
@@ -15,8 +15,8 @@ const getBundlers = (results: Awaited<ReturnType<typeof zipFunctions>> = []) =>
// using a Set to filter duplicates
new Set(
results
.map((bundle) => (bundle.runtime === RuntimeType.JAVASCRIPT ? bundle.bundler : null))
.filter(Boolean) as NodeBundlerType[],
.map((bundle) => (bundle.runtime === RUNTIME.JAVASCRIPT ? bundle.bundler : null))
.filter(Boolean) as NodeBundlerName[],
)

const zipFunctionsAndLogResults = async ({
@@ -30,6 +30,7 @@ const zipFunctionsAndLogResults = async ({
isRunningLocally,
logs,
repositoryRoot,
userNodeVersion,
}) => {
const zisiParameters = getZisiParameters({
buildDir,
@@ -40,6 +41,7 @@ const zipFunctionsAndLogResults = async ({
internalFunctionsSrc,
isRunningLocally,
repositoryRoot,
userNodeVersion,
})

try {
@@ -74,6 +76,7 @@ const coreStep = async function ({
netlifyConfig,
featureFlags,
repositoryRoot,
userNodeVersion,
}) {
const functionsSrc = relativeFunctionsSrc === undefined ? undefined : resolve(buildDir, relativeFunctionsSrc)
const functionsDist = resolve(buildDir, relativeFunctionsDist)
@@ -120,6 +123,7 @@ const coreStep = async function ({
isRunningLocally,
logs,
repositoryRoot,
userNodeVersion,
})

const metrics = getMetrics(internalFunctions, userFunctions)
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
import { join, resolve } from 'path'

import { FunctionConfig, ZipFunctionsOptions } from '@netlify/zip-it-and-ship-it'
import mapObject from 'map-obj'
import semver from 'semver'

import type { FeatureFlags } from '../../core/feature_flags.js'

import { getZisiFeatureFlags } from './feature_flags.js'

type GetZisiParametersType = {
buildDir: string
childEnv: Record<string, string>
featureFlags: FeatureFlags
functionsConfig: Record<string, any>
functionsDist: string
internalFunctionsSrc: string
isRunningLocally: boolean
repositoryRoot: string
userNodeVersion: string
}

const getLambdaNodeVersion = (childEnv: Record<string, string>, userNodeVersion: string): string | undefined => {
if (childEnv.AWS_LAMBDA_JS_RUNTIME) {
return childEnv.AWS_LAMBDA_JS_RUNTIME
}

// As of time of writing the default Lambda Node.js version is 16 and
// we do not want to take the risk and downgrade users from this default version on initial release
// of the dependency between user and lambda Node.js version.
// The check ensures that if the user version is lower than 16 we keep the default version.
//
// TODO: Remove this once Node.js 16 is deprecated. Do NOT change this if the default Lambda version is updated.
if (semver.gte(userNodeVersion, '16.0.0')) {
return userNodeVersion
}

return undefined
}

export const getZisiParameters = ({
buildDir,
childEnv,
@@ -13,12 +47,13 @@ export const getZisiParameters = ({
internalFunctionsSrc,
isRunningLocally,
repositoryRoot,
}) => {
const nodeVersion = childEnv.AWS_LAMBDA_JS_RUNTIME
userNodeVersion,
}: GetZisiParametersType): ZipFunctionsOptions => {
const nodeVersion = getLambdaNodeVersion(childEnv, userNodeVersion)
const manifest = join(functionsDist, 'manifest.json')
const config = mapObject(functionsConfig, (expression, object) => [
expression,
normalizeFunctionConfig({ buildDir, featureFlags, functionConfig: object, isRunningLocally, nodeVersion }),
normalizeFunctionConfig({ buildDir, functionConfig: object, isRunningLocally, nodeVersion }),
])
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags)
// Only internal functions are allowed to have a json config file
@@ -37,7 +72,17 @@ export const getZisiParameters = ({
// The function configuration keys returned by @netlify/config are not an exact
// match to the properties that @netlify/zip-it-and-ship-it expects. We do that
// translation here.
export const normalizeFunctionConfig = ({ buildDir, functionConfig = {}, isRunningLocally, nodeVersion }) => ({
export const normalizeFunctionConfig = ({
buildDir,
functionConfig = {},
isRunningLocally,
nodeVersion,
}: {
buildDir: string
functionConfig: Record<string, any>
isRunningLocally: boolean
nodeVersion: string | undefined
}): FunctionConfig => ({
externalNodeModules: functionConfig.external_node_modules,
includedFiles: functionConfig.included_files,
name: functionConfig.name,
2 changes: 2 additions & 0 deletions packages/build/src/steps/core_step.ts
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ export const fireCoreStep = async function ({
debug,
systemLog,
saveConfig,
userNodeVersion,
}) {
try {
const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath])
@@ -61,6 +62,7 @@ export const fireCoreStep = async function ({
debug,
systemLog,
saveConfig,
userNodeVersion,
})
const {
netlifyConfig: netlifyConfigA,
4 changes: 4 additions & 0 deletions packages/build/src/steps/run_step.ts
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ export const runStep = async function ({
testOpts,
featureFlags,
quiet,
userNodeVersion,
}) {
const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig })

@@ -129,6 +130,7 @@ export const runStep = async function ({
headersPath,
redirectsPath,
featureFlags,
userNodeVersion,
})

const newValues = await getStepReturn({
@@ -264,6 +266,7 @@ const tFireStep = function ({
headersPath,
redirectsPath,
featureFlags,
userNodeVersion,
}) {
if (coreStep !== undefined) {
return fireCoreStep({
@@ -293,6 +296,7 @@ const tFireStep = function ({
debug,
systemLog,
saveConfig,
userNodeVersion,
})
}

2 changes: 2 additions & 0 deletions packages/build/src/steps/run_steps.js
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ export const runSteps = async function ({
testOpts,
featureFlags,
quiet,
userNodeVersion,
}) {
const {
index: stepsCount,
@@ -140,6 +141,7 @@ export const runSteps = async function ({
testOpts,
featureFlags,
quiet,
userNodeVersion,
})

const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson })
9 changes: 8 additions & 1 deletion packages/build/tests/core/tests.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import test from 'ava'
import getNode from 'get-node'
import moize from 'moize'
import { pathExists } from 'path-exists'
import semver from 'semver'
import sinon from 'sinon'
import { tmpName } from 'tmp-promise'

@@ -356,9 +357,15 @@ test.serial('Passes the right properties to zip-it-and-ship-it', async (t) => {
t.is(params1.basePath, fixtureDir)
t.true(params1.config['*'].zipGo)
t.is(params1.config['*'].includedFilesBasePath, fixtureDir)
t.is(params1.config['*'].nodeVersion, undefined)
t.is(params1.repositoryRoot, fixtureDir)

const testNodeVersion = process.versions.node
if (semver.gte(testNodeVersion, '16.0.0')) {
t.is(params1.config['*'].nodeVersion, testNodeVersion)
} else {
t.is(params1.config['*'].nodeVersion, undefined)
}

const params2 = mockZipFunctions.secondCall.args[2]

t.is(params2.config['*'].nodeVersion, 'nodejs00.x')
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`getFramework > Should allow getting a specific framework 1`] = `
{
2 changes: 1 addition & 1 deletion packages/functions-utils/package.json
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@
},
"license": "MIT",
"dependencies": {
"@netlify/zip-it-and-ship-it": "^8.10.0",
"@netlify/zip-it-and-ship-it": "9.2.1",
"cpy": "^8.1.0",
"path-exists": "^5.0.0"
},

0 comments on commit 4a77bbc

Please sign in to comment.