@netlify/zip-it-and-ship-it 16.5.0 → 16.6.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/dist/config.d.ts +8 -0
- package/dist/config.js +12 -0
- package/dist/main.d.ts +1 -1
- package/dist/manifest.d.ts +2 -1
- package/dist/manifest.js +2 -1
- package/dist/runtimes/node/in_source_config/index.d.ts +4 -0
- package/dist/runtimes/node/in_source_config/index.js +5 -2
- package/dist/server.d.ts +9 -0
- package/dist/server.js +17 -0
- package/dist/zip.d.ts +2 -2
- package/dist/zip.js +1 -1
- package/package.json +3 -3
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ export declare const serverSize: z.ZodPreprocess<z.ZodEnum<{
|
|
|
9
9
|
medium: "medium";
|
|
10
10
|
large: "large";
|
|
11
11
|
}>>;
|
|
12
|
+
export declare const isValidRange: ({ min, max }: {
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
}) => boolean;
|
|
16
|
+
export declare const serverScale: z.ZodObject<{
|
|
17
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strict>;
|
|
12
20
|
export declare const functionConfigShape: z.ZodObject<{
|
|
13
21
|
background: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
|
|
14
22
|
externalNodeModules: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
package/dist/config.js
CHANGED
|
@@ -41,6 +41,18 @@ const SERVER_REGION_CODES = ['cmh', 'fra'];
|
|
|
41
41
|
export const serverRegion = z.preprocess((input) => (typeof input === 'string' ? input.toLowerCase() : input), z.enum(SERVER_REGION_CODES));
|
|
42
42
|
const SERVER_SIZES = ['small', 'medium', 'large'];
|
|
43
43
|
export const serverSize = z.preprocess((input) => (typeof input === 'string' ? input.toLowerCase() : input), z.enum(SERVER_SIZES));
|
|
44
|
+
const integerAtLeast = (min) => {
|
|
45
|
+
const message = `Must be an integer greater than or equal to ${String(min)}`;
|
|
46
|
+
return z.number({ message }).int({ message }).min(min, { message }).optional();
|
|
47
|
+
};
|
|
48
|
+
export const isValidRange = ({ min, max }) => min === undefined || max === undefined || min <= max;
|
|
49
|
+
export const serverScale = z
|
|
50
|
+
.object({
|
|
51
|
+
min: integerAtLeast(0),
|
|
52
|
+
max: integerAtLeast(1),
|
|
53
|
+
})
|
|
54
|
+
.strict()
|
|
55
|
+
.refine(isValidRange, { message: "'min' cannot be greater than 'max'" });
|
|
44
56
|
const FUNCTION_MEMORY_MIN_MB = 1024;
|
|
45
57
|
const FUNCTION_MEMORY_MAX_MB = 4096;
|
|
46
58
|
const functionMemory = z.preprocess((input) => (typeof input === 'string' || typeof input === 'number' ? parseMemoryMB(input) : input), z.number().int().min(FUNCTION_MEMORY_MIN_MB).max(FUNCTION_MEMORY_MAX_MB));
|
package/dist/main.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { RuntimeName } from './runtimes/runtime.js';
|
|
|
6
6
|
import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
7
7
|
export { Config, FunctionConfig } from './config.js';
|
|
8
8
|
export { zipFunction, zipFunctions, zipServer, ZipFunctionOptions, ZipFunctionsOptions } from './zip.js';
|
|
9
|
-
export type { NetlifyServerConfig, ServerOptions, ServerResult, ZipServerOptions } from './zip.js';
|
|
9
|
+
export type { NetlifyServerConfig, ServerOptions, ServerResult, ServerScale, ZipServerOptions } from './zip.js';
|
|
10
10
|
export { findServerEntry, getServerRoutes } from './server.js';
|
|
11
11
|
export type { FunctionsBag, MixedPaths } from './paths.js';
|
|
12
12
|
export { ArchiveFormat, ARCHIVE_FORMAT } from './archive.js';
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InvocationMode } from './function.js';
|
|
2
2
|
import type { TrafficRules } from './rate_limit.js';
|
|
3
|
-
import type { ServerResult } from './server.js';
|
|
3
|
+
import type { ServerResult, ServerScale } from './server.js';
|
|
4
4
|
import type { FunctionResult } from './utils/format_result.js';
|
|
5
5
|
import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
6
6
|
interface ManifestFunction {
|
|
@@ -35,6 +35,7 @@ interface ManifestServer {
|
|
|
35
35
|
routes?: ExtendedRoute[];
|
|
36
36
|
runtime: string;
|
|
37
37
|
runtimeVersion?: string;
|
|
38
|
+
scale?: ServerScale;
|
|
38
39
|
}
|
|
39
40
|
interface ManifestBase {
|
|
40
41
|
system: {
|
package/dist/manifest.js
CHANGED
|
@@ -21,7 +21,7 @@ export const createServerManifest = async ({ path, server }) => {
|
|
|
21
21
|
};
|
|
22
22
|
await fs.writeFile(path, JSON.stringify(payload));
|
|
23
23
|
};
|
|
24
|
-
const formatServerForManifest = ({ bundler, excludedRoutes, instanceSize, mainFile, path, region, routes, runtime, runtimeVersion, }) => {
|
|
24
|
+
const formatServerForManifest = ({ bundler, excludedRoutes, instanceSize, mainFile, path, region, routes, runtime, runtimeVersion, scale, }) => {
|
|
25
25
|
const server = {
|
|
26
26
|
bundler,
|
|
27
27
|
instanceSize,
|
|
@@ -30,6 +30,7 @@ const formatServerForManifest = ({ bundler, excludedRoutes, instanceSize, mainFi
|
|
|
30
30
|
region,
|
|
31
31
|
runtime,
|
|
32
32
|
runtimeVersion,
|
|
33
|
+
scale,
|
|
33
34
|
};
|
|
34
35
|
if (routes?.length) {
|
|
35
36
|
server.routes = routes;
|
|
@@ -100,6 +100,10 @@ export declare const serverConfig: z.ZodObject<{
|
|
|
100
100
|
cmh: "cmh";
|
|
101
101
|
fra: "fra";
|
|
102
102
|
}>>>;
|
|
103
|
+
scale: z.ZodOptional<z.ZodObject<{
|
|
104
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strict>>;
|
|
103
107
|
size: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
|
|
104
108
|
small: "small";
|
|
105
109
|
medium: "medium";
|
|
@@ -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, serverRegion, serverSize, withComputeResources } from '../../../config.js';
|
|
6
|
+
import { functionConfigShape, serverRegion, serverScale, serverSize, 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';
|
|
@@ -62,6 +62,7 @@ export const serverConfig = z
|
|
|
62
62
|
includedFiles: z.array(z.string()).optional(),
|
|
63
63
|
path: paths,
|
|
64
64
|
region: serverRegion.optional(),
|
|
65
|
+
scale: serverScale.optional(),
|
|
65
66
|
size: serverSize.optional(),
|
|
66
67
|
})
|
|
67
68
|
.strict();
|
|
@@ -186,7 +187,9 @@ const parseServerConfig = (config, functionName) => {
|
|
|
186
187
|
}
|
|
187
188
|
const [issue] = error.issues;
|
|
188
189
|
const message = issue.code === 'unrecognized_keys'
|
|
189
|
-
? `Netlify Server does not support the ${issue.keys
|
|
190
|
+
? `Netlify Server does not support the ${issue.keys
|
|
191
|
+
.map((key) => `'${[...issue.path, key].join('.')}'`)
|
|
192
|
+
.join(', ')} configuration ${issue.keys.length === 1 ? 'property' : 'properties'}`
|
|
190
193
|
: `Netlify Server has a configuration error on '${issue.path.join('.')}': ${issue.message}`;
|
|
191
194
|
throw new FunctionBundlingUserError(message, { functionName, runtime: RUNTIME.JAVASCRIPT });
|
|
192
195
|
};
|
package/dist/server.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
|
8
8
|
* none.
|
|
9
9
|
*/
|
|
10
10
|
export declare const findServerEntry: (directory: string) => Promise<string | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* How many instances the server runs.
|
|
13
|
+
*/
|
|
14
|
+
export type ServerScale = {
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
};
|
|
11
18
|
/**
|
|
12
19
|
* Server configuration from the `[server]` block of the Netlify configuration
|
|
13
20
|
* file. The server's in-source configuration takes precedence over it.
|
|
@@ -17,6 +24,7 @@ export interface NetlifyServerConfig {
|
|
|
17
24
|
includedFiles?: string[];
|
|
18
25
|
path?: string | string[];
|
|
19
26
|
region?: string;
|
|
27
|
+
scale?: ServerScale;
|
|
20
28
|
size?: string;
|
|
21
29
|
}
|
|
22
30
|
/**
|
|
@@ -36,6 +44,7 @@ export type ServerResult = {
|
|
|
36
44
|
routes?: ExtendedRoute[];
|
|
37
45
|
runtime: RuntimeName;
|
|
38
46
|
runtimeVersion?: string;
|
|
47
|
+
scale?: ServerScale;
|
|
39
48
|
size?: number;
|
|
40
49
|
};
|
|
41
50
|
/**
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import { extname, join, resolve } from 'path';
|
|
3
3
|
import { ARCHIVE_FORMAT } from './archive.js';
|
|
4
|
+
import { isValidRange } from './config.js';
|
|
4
5
|
import { getFunctionFromPath } from './runtimes/index.js';
|
|
5
6
|
import { parseFile, serverConfig } from './runtimes/node/in_source_config/index.js';
|
|
6
7
|
import { RUNTIME } from './runtimes/runtime.js';
|
|
@@ -50,10 +51,25 @@ const parseNetlifyServerConfig = (config = {}) => {
|
|
|
50
51
|
const location = issue.path.length === 0 ? '' : ` on '${issue.path.join('.')}'`;
|
|
51
52
|
throw new FunctionBundlingUserError(`Netlify Server has a configuration error in the [server] block${location}: ${issue.message}`, { functionName: SERVER_NAME, runtime: RUNTIME.JAVASCRIPT });
|
|
52
53
|
};
|
|
54
|
+
// `min` and `max` are merged separately, so each source can set one of them.
|
|
55
|
+
const mergeServerScale = (inSource = {}, fromNetlifyConfig = {}) => {
|
|
56
|
+
const scale = removeUndefined({
|
|
57
|
+
min: inSource.min ?? fromNetlifyConfig.min,
|
|
58
|
+
max: inSource.max ?? fromNetlifyConfig.max,
|
|
59
|
+
});
|
|
60
|
+
if (scale.min === undefined && scale.max === undefined) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
if (!isValidRange(scale)) {
|
|
64
|
+
throw new FunctionBundlingUserError(`Netlify Server has a configuration error on 'scale': 'min' (${String(scale.min)}) cannot be greater than 'max' (${String(scale.max)}) once the in-source configuration and the [server] block are combined`, { functionName: SERVER_NAME, runtime: RUNTIME.JAVASCRIPT });
|
|
65
|
+
}
|
|
66
|
+
return scale;
|
|
67
|
+
};
|
|
53
68
|
const mergeServerConfig = (inSource, fromNetlifyConfig) => ({
|
|
54
69
|
excludedPath: inSource.excludedPath ?? fromNetlifyConfig.excludedPath,
|
|
55
70
|
path: inSource.path ?? fromNetlifyConfig.path,
|
|
56
71
|
region: inSource.region ?? fromNetlifyConfig.region,
|
|
72
|
+
scale: mergeServerScale(inSource.scale, fromNetlifyConfig.scale),
|
|
57
73
|
size: inSource.size ?? fromNetlifyConfig.size,
|
|
58
74
|
});
|
|
59
75
|
/**
|
|
@@ -137,6 +153,7 @@ export const bundleServer = async (server, destFolder, { basePath, cache, featur
|
|
|
137
153
|
routes: toServerRoutes(config.path),
|
|
138
154
|
runtime: result.runtime,
|
|
139
155
|
runtimeVersion: result.runtimeVersion,
|
|
156
|
+
scale: config.scale,
|
|
140
157
|
size: result.size,
|
|
141
158
|
});
|
|
142
159
|
};
|
package/dist/zip.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArchiveFormat } from './archive.js';
|
|
2
2
|
import { Config } from './config.js';
|
|
3
3
|
import { FeatureFlags } from './feature_flags.js';
|
|
4
|
-
import { type NetlifyServerConfig, type ServerOptions, type ServerResult } from './server.js';
|
|
4
|
+
import { type NetlifyServerConfig, type ServerOptions, type ServerResult, type ServerScale } from './server.js';
|
|
5
5
|
import { type MixedPaths } from './paths.js';
|
|
6
6
|
import { FunctionResult } from './utils/format_result.js';
|
|
7
7
|
import { LogFunction } from './utils/logger.js';
|
|
@@ -38,7 +38,7 @@ export interface ZipServerOptions {
|
|
|
38
38
|
repositoryRoot?: string;
|
|
39
39
|
systemLog?: LogFunction;
|
|
40
40
|
}
|
|
41
|
-
export type { NetlifyServerConfig, ServerOptions, ServerResult };
|
|
41
|
+
export type { NetlifyServerConfig, ServerOptions, ServerResult, ServerScale };
|
|
42
42
|
export declare const zipFunctions: (input: MixedPaths, destFolder: string, { archiveFormat, basePath, branch, config, configFileDirectories, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, systemLog, debug, }?: ZipFunctionsOptions) => Promise<FunctionResult[]>;
|
|
43
43
|
export declare const zipServer: (srcPath: string, destFolder: string, { basePath, config, debug, featureFlags: inputFeatureFlags, manifest, repositoryRoot, systemLog, }?: ZipServerOptions) => Promise<ServerResult>;
|
|
44
44
|
export declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config: inputConfig, featureFlags: inputFeatureFlags, repositoryRoot, systemLog, debug, internalSrcFolder, }?: ZipFunctionOptions) => Promise<FunctionResult | undefined>;
|
package/dist/zip.js
CHANGED
|
@@ -5,7 +5,7 @@ import pMap from 'p-map';
|
|
|
5
5
|
import { ARCHIVE_FORMAT } from './archive.js';
|
|
6
6
|
import { getFlags } from './feature_flags.js';
|
|
7
7
|
import { createFunctionsManifest, createServerManifest } from './manifest.js';
|
|
8
|
-
import { bundleServer } from './server.js';
|
|
8
|
+
import { bundleServer, } from './server.js';
|
|
9
9
|
import { getFunctionsFromPaths } from './runtimes/index.js';
|
|
10
10
|
import { MODULE_FORMAT } from './runtimes/node/utils/module_format.js';
|
|
11
11
|
import { getFunctionsBag } from './paths.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.6.0",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"resolve": "^2.0.0-next.1",
|
|
70
70
|
"semver": "^7.3.8",
|
|
71
71
|
"tmp-promise": "^3.0.2",
|
|
72
|
-
"toml": "^
|
|
72
|
+
"toml": "^5.0.0",
|
|
73
73
|
"unixify": "^1.0.0",
|
|
74
74
|
"urlpattern-polyfill": "8.0.2",
|
|
75
75
|
"yargs": "^17.0.0",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"engines": {
|
|
100
100
|
"node": ">=22.12.0"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "a2dde99b2116c8dbea79e4ca18886d1466577a1c"
|
|
103
103
|
}
|