@netlify/zip-it-and-ship-it 16.2.2 → 16.2.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/dist/config.d.ts
CHANGED
|
@@ -51,4 +51,5 @@ declare const getConfigForFunction: ({ config, configFileDirectories, func, }: {
|
|
|
51
51
|
configFileDirectories?: string[];
|
|
52
52
|
func: FunctionWithoutConfig;
|
|
53
53
|
}) => Promise<FunctionConfig>;
|
|
54
|
+
export declare const withComputeResources: <T extends FunctionConfig>(merged: T, sources: Pick<FunctionConfig, "memory" | "vcpu">[]) => T;
|
|
54
55
|
export { Config, FunctionConfig, FunctionWithoutConfig, getConfigForFunction };
|
package/dist/config.js
CHANGED
|
@@ -75,10 +75,10 @@ const getConfigForFunction = async ({ config, configFileDirectories, func, }) =>
|
|
|
75
75
|
return fromConfig;
|
|
76
76
|
}
|
|
77
77
|
const fromFile = await getFromFile(func);
|
|
78
|
-
return {
|
|
78
|
+
return withComputeResources({
|
|
79
79
|
...fromConfig,
|
|
80
80
|
...fromFile,
|
|
81
|
-
};
|
|
81
|
+
}, [fromConfig, fromFile]);
|
|
82
82
|
};
|
|
83
83
|
const getFromMainConfig = ({ config, func, }) => {
|
|
84
84
|
if (!config) {
|
|
@@ -101,7 +101,29 @@ const getFromMainConfig = ({ config, func, }) => {
|
|
|
101
101
|
})
|
|
102
102
|
.sort(({ weight: weightA }, { weight: weightB }) => weightA - weightB)
|
|
103
103
|
.map(({ expression }) => config[expression]);
|
|
104
|
-
|
|
104
|
+
const merged = withComputeResources(mergeOptions.apply({ concatArrays: true, ignoreUndefined: true }, matches), matches);
|
|
105
|
+
const memory = merged.memory;
|
|
106
|
+
if (typeof memory === 'string') {
|
|
107
|
+
merged.memory = parseMemoryMB(memory);
|
|
108
|
+
}
|
|
109
|
+
return merged;
|
|
110
|
+
};
|
|
111
|
+
// memory and vcpu are two mutually exclusive ways of sizing a function, so
|
|
112
|
+
// they can't be merged key by key like other properties
|
|
113
|
+
// a wildcard block with memory and a more specific block with vcpu
|
|
114
|
+
// would otherwise produce both. Instead, the highest-priority source that
|
|
115
|
+
// sets either of them supplies the pair.
|
|
116
|
+
export const withComputeResources = (merged, sources) => {
|
|
117
|
+
const winner = [...sources].reverse().find((source) => source.memory !== undefined || source.vcpu !== undefined);
|
|
118
|
+
if (winner === undefined) {
|
|
119
|
+
return merged;
|
|
120
|
+
}
|
|
121
|
+
const { memory, vcpu, ...rest } = merged;
|
|
122
|
+
return {
|
|
123
|
+
...rest,
|
|
124
|
+
...(winner.memory === undefined ? {} : { memory: winner.memory }),
|
|
125
|
+
...(winner.vcpu === undefined ? {} : { vcpu: winner.vcpu }),
|
|
126
|
+
};
|
|
105
127
|
};
|
|
106
128
|
const getFromFile = async (func) => {
|
|
107
129
|
const filename = `${basename(func.mainFile, extname(func.mainFile))}.json`;
|
|
@@ -3,7 +3,7 @@ import { dirname } from 'path';
|
|
|
3
3
|
// this dependency.
|
|
4
4
|
import mergeOptions from 'merge-options';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { functionConfigShape } from '../../../config.js';
|
|
6
|
+
import { functionConfigShape, withComputeResources } from '../../../config.js';
|
|
7
7
|
import { INVOCATION_MODE } from '../../../function.js';
|
|
8
8
|
import { rateLimit } from '../../../rate_limit.js';
|
|
9
9
|
import { ensureArray } from '../../../utils/ensure_array.js';
|
|
@@ -257,7 +257,7 @@ export const parseSource = (source, { functionName }) => {
|
|
|
257
257
|
return result;
|
|
258
258
|
};
|
|
259
259
|
export const augmentFunctionConfig = (mainFile, tomlConfig, inSourceConfig = {}) => {
|
|
260
|
-
const mergedConfig = mergeOptions.call({ concatArrays: true }, tomlConfig, inSourceConfig);
|
|
260
|
+
const mergedConfig = withComputeResources(mergeOptions.call({ concatArrays: true }, tomlConfig, inSourceConfig), [tomlConfig, inSourceConfig]);
|
|
261
261
|
// We can't simply merge included files from the TOML and from in-source
|
|
262
262
|
// configuration because their globs are relative to different base paths.
|
|
263
263
|
// In the future, we could shift things around so we resolve each glob
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.3",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=22.12.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "227492a17c9821682390f6b7554bd69dfa282d9e"
|
|
104
104
|
}
|