@netlify/zip-it-and-ship-it 16.0.0 → 16.2.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/main.d.ts +5 -3
- package/dist/main.js +2 -1
- package/dist/manifest.d.ts +36 -3
- package/dist/manifest.js +29 -1
- package/dist/runtimes/node/index.js +2 -1
- package/dist/runtimes/node/utils/entry_file.d.ts +1 -0
- package/dist/runtimes/node/utils/entry_file.js +1 -0
- package/dist/runtimes/node/utils/zip.d.ts +1 -0
- package/dist/runtimes/node/utils/zip.js +6 -3
- package/dist/runtimes/runtime.d.ts +1 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.js +106 -0
- package/dist/zip.d.ts +14 -0
- package/dist/zip.js +21 -2
- package/package.json +2 -2
package/dist/main.d.ts
CHANGED
|
@@ -5,15 +5,17 @@ import { ModuleFormat } from './runtimes/node/utils/module_format.js';
|
|
|
5
5
|
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
|
-
export { zipFunction, zipFunctions, ZipFunctionOptions, ZipFunctionsOptions } from './zip.js';
|
|
9
|
-
export type {
|
|
8
|
+
export { zipFunction, zipFunctions, zipServer, ZipFunctionOptions, ZipFunctionsOptions } from './zip.js';
|
|
9
|
+
export type { ServerOptions, ServerResult, ZipServerOptions } from './zip.js';
|
|
10
|
+
export { findServerEntry } from './server.js';
|
|
11
|
+
export type { FunctionsBag, MixedPaths } from './paths.js';
|
|
10
12
|
export { ArchiveFormat, ARCHIVE_FORMAT } from './archive.js';
|
|
11
13
|
export type { TrafficRules } from './rate_limit.js';
|
|
12
14
|
export type { ExtendedRoute, Route } from './utils/routes.js';
|
|
13
15
|
export { NodeBundlerName, NODE_BUNDLER } from './runtimes/node/bundlers/types.js';
|
|
14
16
|
export { RuntimeName, RUNTIME } from './runtimes/runtime.js';
|
|
15
17
|
export { ModuleFormat, MODULE_FORMAT } from './runtimes/node/utils/module_format.js';
|
|
16
|
-
export { Manifest } from './manifest.js';
|
|
18
|
+
export type { FunctionsManifest, Manifest, ServerManifest } from './manifest.js';
|
|
17
19
|
export { FunctionResult } from './utils/format_result.js';
|
|
18
20
|
export interface ListedFunction {
|
|
19
21
|
name: string;
|
package/dist/main.js
CHANGED
|
@@ -6,7 +6,8 @@ import { parseFile } from './runtimes/node/in_source_config/index.js';
|
|
|
6
6
|
import { RUNTIME } from './runtimes/runtime.js';
|
|
7
7
|
import { RuntimeCache } from './utils/cache.js';
|
|
8
8
|
import { listFunctionsDirectories, resolveFunctionsDirectories } from './utils/fs.js';
|
|
9
|
-
export { zipFunction, zipFunctions } from './zip.js';
|
|
9
|
+
export { zipFunction, zipFunctions, zipServer } from './zip.js';
|
|
10
|
+
export { findServerEntry } from './server.js';
|
|
10
11
|
export { ARCHIVE_FORMAT } from './archive.js';
|
|
11
12
|
export { NODE_BUNDLER } from './runtimes/node/bundlers/types.js';
|
|
12
13
|
export { RUNTIME } from './runtimes/runtime.js';
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,5 +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
4
|
import type { FunctionResult } from './utils/format_result.js';
|
|
4
5
|
import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
5
6
|
interface ManifestFunction {
|
|
@@ -24,8 +25,19 @@ interface ManifestFunction {
|
|
|
24
25
|
trafficRules?: TrafficRules;
|
|
25
26
|
vcpu?: number;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
interface ManifestServer {
|
|
29
|
+
bundler?: string;
|
|
30
|
+
excludedRoutes?: Route[];
|
|
31
|
+
mainFile: string;
|
|
32
|
+
memory?: number;
|
|
33
|
+
path: string;
|
|
34
|
+
region?: string;
|
|
35
|
+
routes?: ExtendedRoute[];
|
|
36
|
+
runtime: string;
|
|
37
|
+
runtimeVersion?: string;
|
|
38
|
+
vcpu?: number;
|
|
39
|
+
}
|
|
40
|
+
interface ManifestBase {
|
|
29
41
|
system: {
|
|
30
42
|
arch: string;
|
|
31
43
|
platform: string;
|
|
@@ -33,8 +45,29 @@ export interface Manifest {
|
|
|
33
45
|
timestamp: number;
|
|
34
46
|
version: number;
|
|
35
47
|
}
|
|
36
|
-
export
|
|
48
|
+
export interface FunctionsManifest extends ManifestBase {
|
|
49
|
+
functions: ManifestFunction[];
|
|
50
|
+
/**
|
|
51
|
+
* A server is described by its own manifest now. Nothing writes this any
|
|
52
|
+
* more; it is kept so that readers of manifests written before the split
|
|
53
|
+
* still compile.
|
|
54
|
+
*/
|
|
55
|
+
server?: ManifestServer;
|
|
56
|
+
}
|
|
57
|
+
export interface ServerManifest extends ManifestBase {
|
|
58
|
+
server: ManifestServer;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The functions manifest, under the name it had before the server manifest was
|
|
62
|
+
* introduced, for backwards compatibility.
|
|
63
|
+
*/
|
|
64
|
+
export type Manifest = FunctionsManifest;
|
|
65
|
+
export declare const createFunctionsManifest: ({ functions, path }: {
|
|
37
66
|
functions: FunctionResult[];
|
|
38
67
|
path: string;
|
|
39
68
|
}) => Promise<void>;
|
|
69
|
+
export declare const createServerManifest: ({ path, server }: {
|
|
70
|
+
path: string;
|
|
71
|
+
server: ServerResult;
|
|
72
|
+
}) => Promise<void>;
|
|
40
73
|
export {};
|
package/dist/manifest.js
CHANGED
|
@@ -2,7 +2,7 @@ import { promises as fs } from 'fs';
|
|
|
2
2
|
import { resolve } from 'path';
|
|
3
3
|
import { arch, platform } from 'process';
|
|
4
4
|
const MANIFEST_VERSION = 1;
|
|
5
|
-
export const
|
|
5
|
+
export const createFunctionsManifest = async ({ functions, path }) => {
|
|
6
6
|
const formattedFunctions = functions.map((func) => formatFunctionForManifest(func));
|
|
7
7
|
const payload = {
|
|
8
8
|
functions: formattedFunctions,
|
|
@@ -12,6 +12,34 @@ export const createManifest = async ({ functions, path }) => {
|
|
|
12
12
|
};
|
|
13
13
|
await fs.writeFile(path, JSON.stringify(payload));
|
|
14
14
|
};
|
|
15
|
+
export const createServerManifest = async ({ path, server }) => {
|
|
16
|
+
const payload = {
|
|
17
|
+
server: formatServerForManifest(server),
|
|
18
|
+
system: { arch, platform },
|
|
19
|
+
timestamp: Date.now(),
|
|
20
|
+
version: MANIFEST_VERSION,
|
|
21
|
+
};
|
|
22
|
+
await fs.writeFile(path, JSON.stringify(payload));
|
|
23
|
+
};
|
|
24
|
+
const formatServerForManifest = ({ bundler, excludedRoutes, mainFile, memory, path, region, routes, runtime, runtimeVersion, vcpu, }) => {
|
|
25
|
+
const server = {
|
|
26
|
+
bundler,
|
|
27
|
+
mainFile,
|
|
28
|
+
memory,
|
|
29
|
+
path: resolve(path),
|
|
30
|
+
region,
|
|
31
|
+
runtime,
|
|
32
|
+
runtimeVersion,
|
|
33
|
+
vcpu,
|
|
34
|
+
};
|
|
35
|
+
if (routes?.length) {
|
|
36
|
+
server.routes = routes;
|
|
37
|
+
}
|
|
38
|
+
if (excludedRoutes?.length) {
|
|
39
|
+
server.excludedRoutes = excludedRoutes;
|
|
40
|
+
}
|
|
41
|
+
return server;
|
|
42
|
+
};
|
|
15
43
|
const formatFunctionForManifest = ({ bootstrapVersion, bundler, displayName, eventSubscriptions, excludedRoutes, generator, invocationMode, mainFile, memory, name, path, priority, region, trafficRules, routes, runtime, runtimeVersion, runtimeAPIVersion, schedule, timeout, vcpu, }) => {
|
|
16
44
|
const manifestFunction = {
|
|
17
45
|
bundler,
|
|
@@ -32,7 +32,7 @@ const getSrcFilesWithBundler = async (parameters) => {
|
|
|
32
32
|
const result = await bundler.getSrcFiles({ ...parameters, pluginsModulesPath });
|
|
33
33
|
return result.srcFiles;
|
|
34
34
|
};
|
|
35
|
-
const zipFunction = async function ({ archiveFormat, basePath, branch, cache, config = {}, destFolder, extension, featureFlags, filename, isInternal, logger, mainFile, name, repositoryRoot, runtime, span, srcDir, srcPath, stat, }) {
|
|
35
|
+
const zipFunction = async function ({ archiveFormat, basePath, branch, cache, config = {}, destFolder, extension, featureFlags, filename, isInternal, isServer, logger, mainFile, name, repositoryRoot, runtime, span, srcDir, srcPath, stat, }) {
|
|
36
36
|
// If the file is a zip, we assume the function is bundled and ready to go.
|
|
37
37
|
// We simply copy it to the destination path with no further processing.
|
|
38
38
|
if (extension === '.zip') {
|
|
@@ -106,6 +106,7 @@ const zipFunction = async function ({ archiveFormat, basePath, branch, cache, co
|
|
|
106
106
|
extension,
|
|
107
107
|
featureFlags,
|
|
108
108
|
filename,
|
|
109
|
+
isServer,
|
|
109
110
|
mainFile: finalMainFile,
|
|
110
111
|
moduleFormat,
|
|
111
112
|
name,
|
|
@@ -4,6 +4,7 @@ export declare const ENTRY_FILE_NAME = "___netlify-entry-point";
|
|
|
4
4
|
export declare const BOOTSTRAP_FILE_NAME = "___netlify-bootstrap.mjs";
|
|
5
5
|
export declare const METADATA_FILE_NAME = "___netlify-metadata.json";
|
|
6
6
|
export declare const TELEMETRY_FILE_NAME = "___netlify-telemetry.mjs";
|
|
7
|
+
export declare const SERVER_MARKER_FILENAME = "___netlify-server.json";
|
|
7
8
|
export interface EntryFile {
|
|
8
9
|
contents: string;
|
|
9
10
|
filename: string;
|
|
@@ -9,6 +9,7 @@ export const ENTRY_FILE_NAME = '___netlify-entry-point';
|
|
|
9
9
|
export const BOOTSTRAP_FILE_NAME = '___netlify-bootstrap.mjs';
|
|
10
10
|
export const METADATA_FILE_NAME = '___netlify-metadata.json';
|
|
11
11
|
export const TELEMETRY_FILE_NAME = '___netlify-telemetry.mjs';
|
|
12
|
+
export const SERVER_MARKER_FILENAME = '___netlify-server.json';
|
|
12
13
|
const require = createRequire(import.meta.url);
|
|
13
14
|
/**
|
|
14
15
|
* A minimal implementation of kebab-case.
|
|
@@ -7,7 +7,7 @@ import { copyFile } from 'copy-file';
|
|
|
7
7
|
import pMap from 'p-map';
|
|
8
8
|
import { addZipContent, addZipFile, ARCHIVE_FORMAT, endZip, startTar, startZip, } from '../../../archive.js';
|
|
9
9
|
import { cachedLstat, mkdirAndWriteFile } from '../../../utils/fs.js';
|
|
10
|
-
import { BOOTSTRAP_FILE_NAME, METADATA_FILE_NAME, conflictsWithEntryFile, getEntryFile, getTelemetryFile, isNamedLikeEntryFile, } from './entry_file.js';
|
|
10
|
+
import { BOOTSTRAP_FILE_NAME, METADATA_FILE_NAME, conflictsWithEntryFile, getEntryFile, getTelemetryFile, isNamedLikeEntryFile, SERVER_MARKER_FILENAME, } from './entry_file.js';
|
|
11
11
|
import { NETLIFY_PLAY_BOOTSTRAP_VERSION, useNetlifyPlay } from './play.js';
|
|
12
12
|
import { getMetadataFile } from './metadata_file.js';
|
|
13
13
|
import { normalizeFilePath } from './normalize_path.js';
|
|
@@ -101,8 +101,8 @@ const createDirectory = async function ({ aliases = new Map(), basePath, cache,
|
|
|
101
101
|
});
|
|
102
102
|
return { path: functionFolder, entryFilename };
|
|
103
103
|
};
|
|
104
|
-
const createZipArchive = async function ({ aliases = new Map(), basePath, branch, cache, destFolder, extension, featureFlags, filename, mainFile, moduleFormat, rewrites, runtimeAPIVersion, srcFiles, generator, }) {
|
|
105
|
-
const isPlay = useNetlifyPlay(featureFlags, mainFile);
|
|
104
|
+
const createZipArchive = async function ({ aliases = new Map(), basePath, branch, cache, destFolder, extension, featureFlags, filename, isServer, mainFile, moduleFormat, rewrites, runtimeAPIVersion, srcFiles, generator, }) {
|
|
105
|
+
const isPlay = isServer === true || useNetlifyPlay(featureFlags, mainFile);
|
|
106
106
|
const format = isPlay ? ARCHIVE_FORMAT.TAR : ARCHIVE_FORMAT.ZIP;
|
|
107
107
|
const archiveExtension = format === ARCHIVE_FORMAT.TAR ? '.tgz' : '.zip';
|
|
108
108
|
const destPath = join(destFolder, `${basename(filename, extension)}${archiveExtension}`);
|
|
@@ -141,6 +141,9 @@ const createZipArchive = async function ({ aliases = new Map(), basePath, branch
|
|
|
141
141
|
entryFilename = entryFile.filename;
|
|
142
142
|
addEntryFileToZip(archive, entryFile);
|
|
143
143
|
}
|
|
144
|
+
if (isServer === true) {
|
|
145
|
+
addEntryFileToZip(archive, { contents: '{}', filename: SERVER_MARKER_FILENAME });
|
|
146
|
+
}
|
|
144
147
|
const telemetryFile = getTelemetryFile(generator);
|
|
145
148
|
if (featureFlags.zisi_add_instrumentation_loader === true) {
|
|
146
149
|
addEntryFileToZip(archive, telemetryFile);
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FeatureFlags } from './feature_flags.js';
|
|
2
|
+
import { type RuntimeName } from './runtimes/runtime.js';
|
|
3
|
+
import type { RuntimeCache } from './utils/cache.js';
|
|
4
|
+
import type { getLogger } from './utils/logger.js';
|
|
5
|
+
import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the server entrypoint inside `directory`, or undefined when there is
|
|
8
|
+
* none.
|
|
9
|
+
*/
|
|
10
|
+
export declare const findServerEntry: (directory: string) => Promise<string | undefined>;
|
|
11
|
+
export type ServerResult = {
|
|
12
|
+
bundler?: string;
|
|
13
|
+
excludedRoutes?: Route[];
|
|
14
|
+
mainFile: string;
|
|
15
|
+
memory?: number;
|
|
16
|
+
path: string;
|
|
17
|
+
region?: string;
|
|
18
|
+
routes?: ExtendedRoute[];
|
|
19
|
+
runtime: RuntimeName;
|
|
20
|
+
runtimeVersion?: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
vcpu?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The deploy's Netlify Server, and how to bundle it.
|
|
26
|
+
*/
|
|
27
|
+
export interface ServerOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Path of the user's server entry file.
|
|
30
|
+
*/
|
|
31
|
+
path: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const bundleServer: (server: ServerOptions, destFolder: string, { basePath, cache, featureFlags, logger, repositoryRoot, }: {
|
|
34
|
+
basePath?: string;
|
|
35
|
+
cache: RuntimeCache;
|
|
36
|
+
featureFlags: FeatureFlags;
|
|
37
|
+
logger: ReturnType<typeof getLogger>;
|
|
38
|
+
repositoryRoot?: string;
|
|
39
|
+
}) => Promise<ServerResult>;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import { extname, join, resolve } from 'path';
|
|
3
|
+
import { ARCHIVE_FORMAT } from './archive.js';
|
|
4
|
+
import { NODE_BUNDLER } from './runtimes/node/bundlers/types.js';
|
|
5
|
+
import { getFunctionFromPath } from './runtimes/index.js';
|
|
6
|
+
import { RUNTIME } from './runtimes/runtime.js';
|
|
7
|
+
import { FunctionBundlingUserError } from './utils/error.js';
|
|
8
|
+
import { formatZipResult } from './utils/format_result.js';
|
|
9
|
+
import { removeUndefined } from './utils/remove_undefined.js';
|
|
10
|
+
import { getRoutes } from './utils/routes.js';
|
|
11
|
+
// A server claims every path the rest of the deploy does not.
|
|
12
|
+
const SERVER_ROUTE = '/*';
|
|
13
|
+
// Names the server's archive. Everywhere else it is only a label, identifying
|
|
14
|
+
// the server in bundling errors, since a server has no name of its own.
|
|
15
|
+
const SERVER_NAME = 'server';
|
|
16
|
+
const SERVER_ENTRY_BASENAMES = new Set(['index.js', 'index.mjs', 'index.ts', 'index.mts']);
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the server entrypoint inside `directory`, or undefined when there is
|
|
19
|
+
* none.
|
|
20
|
+
*/
|
|
21
|
+
export const findServerEntry = async (directory) => {
|
|
22
|
+
let entries;
|
|
23
|
+
try {
|
|
24
|
+
entries = await fs.readdir(directory);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const { code } = error;
|
|
28
|
+
if (code === 'ENOENT' || code === 'ENOTDIR') {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
const candidates = entries.filter((name) => SERVER_ENTRY_BASENAMES.has(name)).sort();
|
|
34
|
+
if (candidates.length === 0) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (candidates.length > 1) {
|
|
38
|
+
throw new Error(`Found multiple server entrypoints in ${directory} (${candidates.join(', ')}). A site can have one server only.`);
|
|
39
|
+
}
|
|
40
|
+
return join(directory, candidates[0]);
|
|
41
|
+
};
|
|
42
|
+
const readServerSource = async (srcPath, { cache, featureFlags }) => {
|
|
43
|
+
let source;
|
|
44
|
+
// A server that cannot be read is the user's file being wrong, so it is
|
|
45
|
+
// reported as a bundling failure rather than an internal error.
|
|
46
|
+
const unreadable = (detail) => new FunctionBundlingUserError(`Could not read the Netlify Server at ${srcPath}${detail ? `: ${detail}` : ''}`, {
|
|
47
|
+
functionName: SERVER_NAME,
|
|
48
|
+
runtime: RUNTIME.JAVASCRIPT,
|
|
49
|
+
});
|
|
50
|
+
try {
|
|
51
|
+
source = await getFunctionFromPath(srcPath, { cache, featureFlags });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw unreadable(error.message);
|
|
55
|
+
}
|
|
56
|
+
if (source === undefined) {
|
|
57
|
+
throw unreadable();
|
|
58
|
+
}
|
|
59
|
+
return source;
|
|
60
|
+
};
|
|
61
|
+
export const bundleServer = async (server, destFolder, { basePath, cache, featureFlags, logger, repositoryRoot, }) => {
|
|
62
|
+
const srcPath = resolve(server.path);
|
|
63
|
+
const source = await readServerSource(srcPath, { cache, featureFlags });
|
|
64
|
+
const zipResult = await source.runtime.zipFunction({
|
|
65
|
+
archiveFormat: ARCHIVE_FORMAT.ZIP,
|
|
66
|
+
basePath,
|
|
67
|
+
cache,
|
|
68
|
+
config: { ...source.config, nodeBundler: NODE_BUNDLER.NFT },
|
|
69
|
+
destFolder,
|
|
70
|
+
extension: source.extension,
|
|
71
|
+
featureFlags,
|
|
72
|
+
filename: source.filename,
|
|
73
|
+
isInternal: true,
|
|
74
|
+
isServer: true,
|
|
75
|
+
logger,
|
|
76
|
+
mainFile: source.mainFile,
|
|
77
|
+
name: SERVER_NAME,
|
|
78
|
+
repositoryRoot,
|
|
79
|
+
runtime: source.runtime,
|
|
80
|
+
srcDir: source.srcDir,
|
|
81
|
+
srcPath,
|
|
82
|
+
stat: source.stat,
|
|
83
|
+
});
|
|
84
|
+
const path = join(destFolder, `${SERVER_NAME}${extname(zipResult.path)}`);
|
|
85
|
+
await fs.rename(zipResult.path, path);
|
|
86
|
+
const result = formatZipResult({
|
|
87
|
+
...zipResult,
|
|
88
|
+
mainFile: source.mainFile,
|
|
89
|
+
name: SERVER_NAME,
|
|
90
|
+
path,
|
|
91
|
+
runtime: source.runtime,
|
|
92
|
+
});
|
|
93
|
+
return removeUndefined({
|
|
94
|
+
bundler: result.bundler,
|
|
95
|
+
excludedRoutes: result.excludedRoutes,
|
|
96
|
+
mainFile: result.mainFile,
|
|
97
|
+
memory: result.memory,
|
|
98
|
+
path: result.path,
|
|
99
|
+
region: result.region,
|
|
100
|
+
routes: getRoutes(SERVER_NAME, SERVER_ROUTE).map((route) => ({ ...route, prefer_static: true })),
|
|
101
|
+
runtime: result.runtime,
|
|
102
|
+
runtimeVersion: result.runtimeVersion,
|
|
103
|
+
size: result.size,
|
|
104
|
+
vcpu: result.vcpu,
|
|
105
|
+
});
|
|
106
|
+
};
|
package/dist/zip.d.ts
CHANGED
|
@@ -1,6 +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 ServerOptions, type ServerResult } from './server.js';
|
|
4
5
|
import { type MixedPaths } from './paths.js';
|
|
5
6
|
import { FunctionResult } from './utils/format_result.js';
|
|
6
7
|
import { LogFunction } from './utils/logger.js';
|
|
@@ -21,5 +22,18 @@ export type ZipFunctionsOptions = ZipFunctionOptions & {
|
|
|
21
22
|
manifest?: string;
|
|
22
23
|
parallelLimit?: number;
|
|
23
24
|
};
|
|
25
|
+
export interface ZipServerOptions {
|
|
26
|
+
basePath?: string;
|
|
27
|
+
debug?: boolean;
|
|
28
|
+
featureFlags?: FeatureFlags;
|
|
29
|
+
/**
|
|
30
|
+
* Path of the manifest file. Defaults to `manifest.json` inside `destFolder`.
|
|
31
|
+
*/
|
|
32
|
+
manifest?: string;
|
|
33
|
+
repositoryRoot?: string;
|
|
34
|
+
systemLog?: LogFunction;
|
|
35
|
+
}
|
|
36
|
+
export type { ServerOptions, ServerResult };
|
|
24
37
|
export declare const zipFunctions: (input: MixedPaths, destFolder: string, { archiveFormat, basePath, branch, config, configFileDirectories, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, systemLog, debug, }?: ZipFunctionsOptions) => Promise<FunctionResult[]>;
|
|
38
|
+
export declare const zipServer: (srcPath: string, destFolder: string, { basePath, debug, featureFlags: inputFeatureFlags, manifest, repositoryRoot, systemLog, }?: ZipServerOptions) => Promise<ServerResult>;
|
|
25
39
|
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
|
@@ -4,7 +4,8 @@ import isPathInside from 'is-path-inside';
|
|
|
4
4
|
import pMap from 'p-map';
|
|
5
5
|
import { ARCHIVE_FORMAT } from './archive.js';
|
|
6
6
|
import { getFlags } from './feature_flags.js';
|
|
7
|
-
import {
|
|
7
|
+
import { createFunctionsManifest, createServerManifest } from './manifest.js';
|
|
8
|
+
import { bundleServer } from './server.js';
|
|
8
9
|
import { getFunctionsFromPaths } from './runtimes/index.js';
|
|
9
10
|
import { MODULE_FORMAT } from './runtimes/node/utils/module_format.js';
|
|
10
11
|
import { getFunctionsBag } from './paths.js';
|
|
@@ -74,9 +75,27 @@ export const zipFunctions = async function (input, destFolder, { archiveFormat =
|
|
|
74
75
|
const resultWithSize = await addArchiveSize(result);
|
|
75
76
|
return formatZipResult(resultWithSize);
|
|
76
77
|
}));
|
|
77
|
-
await
|
|
78
|
+
await createFunctionsManifest({
|
|
79
|
+
functions: formattedResults,
|
|
80
|
+
path: resolve(manifest || join(destFolder, 'manifest.json')),
|
|
81
|
+
});
|
|
78
82
|
return formattedResults;
|
|
79
83
|
};
|
|
84
|
+
export const zipServer = async function (srcPath, destFolder, { basePath, debug, featureFlags: inputFeatureFlags, manifest, repositoryRoot = basePath, systemLog, } = {}) {
|
|
85
|
+
const logger = getLogger(systemLog, debug);
|
|
86
|
+
const cache = new RuntimeCache();
|
|
87
|
+
const featureFlags = getFlags(inputFeatureFlags);
|
|
88
|
+
await fs.mkdir(destFolder, { recursive: true });
|
|
89
|
+
const result = await bundleServer({ path: srcPath }, destFolder, {
|
|
90
|
+
basePath,
|
|
91
|
+
cache,
|
|
92
|
+
featureFlags,
|
|
93
|
+
logger,
|
|
94
|
+
repositoryRoot,
|
|
95
|
+
});
|
|
96
|
+
await createServerManifest({ path: resolve(manifest || join(destFolder, 'manifest.json')), server: result });
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
80
99
|
export const zipFunction = async function (relativeSrcPath, destFolder, { archiveFormat = ARCHIVE_FORMAT.ZIP, basePath, config: inputConfig = {}, featureFlags: inputFeatureFlags, repositoryRoot = basePath, systemLog, debug, internalSrcFolder, } = {}) {
|
|
81
100
|
validateArchiveFormat(archiveFormat);
|
|
82
101
|
const logger = getLogger(systemLog, debug);
|
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.2.0",
|
|
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": "b1c3e6b1ed61a7be7bc06e4a8e4b2e48f5882de3"
|
|
104
104
|
}
|