@netlify/zip-it-and-ship-it 5.7.2 → 5.8.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/README.md +19 -38
- package/dist/archive.d.ts +6 -8
- package/dist/bin.js +2 -2
- package/dist/config.d.ts +7 -8
- package/dist/feature_flags.d.ts +4 -6
- package/dist/feature_flags.js +3 -4
- package/dist/function.d.ts +5 -6
- package/dist/main.d.ts +7 -8
- package/dist/main.js +19 -19
- package/dist/manifest.d.ts +4 -5
- package/dist/runtimes/detect_runtime.d.ts +3 -4
- package/dist/runtimes/detect_runtime.js +2 -2
- package/dist/runtimes/go/builder.d.ts +1 -2
- package/dist/runtimes/go/builder.js +2 -2
- package/dist/runtimes/go/index.d.ts +1 -1
- package/dist/runtimes/go/index.js +13 -13
- package/dist/runtimes/index.d.ts +6 -6
- package/dist/runtimes/index.js +10 -10
- package/dist/runtimes/node/bundlers/esbuild/bundler.d.ts +6 -4
- package/dist/runtimes/node/bundlers/esbuild/bundler.js +23 -17
- package/dist/runtimes/node/bundlers/esbuild/bundler_target.d.ts +7 -1
- package/dist/runtimes/node/bundlers/esbuild/bundler_target.js +19 -3
- package/dist/runtimes/node/bundlers/esbuild/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/esbuild/index.js +15 -14
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.d.ts +1 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.d.ts +2 -3
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_node_builtin.d.ts +1 -2
- package/dist/runtimes/node/bundlers/esbuild/special_cases.d.ts +1 -2
- package/dist/runtimes/node/bundlers/esbuild/special_cases.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/src_files.d.ts +2 -3
- package/dist/runtimes/node/bundlers/esbuild/src_files.js +10 -10
- package/dist/runtimes/node/bundlers/index.d.ts +10 -11
- package/dist/runtimes/node/bundlers/index.js +12 -13
- package/dist/runtimes/node/bundlers/nft/es_modules.d.ts +5 -6
- package/dist/runtimes/node/bundlers/nft/es_modules.js +8 -8
- package/dist/runtimes/node/bundlers/nft/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/nft/index.js +14 -14
- package/dist/runtimes/node/bundlers/nft/transpile.d.ts +2 -3
- package/dist/runtimes/node/bundlers/nft/transpile.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/zisi/index.js +5 -5
- package/dist/runtimes/node/bundlers/zisi/list_imports.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/list_imports.js +3 -3
- package/dist/runtimes/node/bundlers/zisi/nested.d.ts +3 -4
- package/dist/runtimes/node/bundlers/zisi/published.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/resolve.d.ts +2 -3
- package/dist/runtimes/node/bundlers/zisi/resolve.js +1 -1
- package/dist/runtimes/node/bundlers/zisi/side_files.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/side_files.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/src_files.d.ts +2 -3
- package/dist/runtimes/node/bundlers/zisi/src_files.js +19 -19
- package/dist/runtimes/node/bundlers/zisi/traverse.d.ts +3 -4
- package/dist/runtimes/node/bundlers/zisi/traverse.js +15 -15
- package/dist/runtimes/node/bundlers/zisi/tree_files.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/tree_shake.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/tree_shake.js +2 -2
- package/dist/runtimes/node/finder.d.ts +3 -4
- package/dist/runtimes/node/finder.js +3 -3
- package/dist/runtimes/node/in_source_config/index.d.ts +6 -8
- package/dist/runtimes/node/in_source_config/index.js +13 -14
- package/dist/runtimes/node/in_source_config/properties/schedule.d.ts +1 -1
- package/dist/runtimes/node/index.d.ts +2 -2
- package/dist/runtimes/node/index.js +16 -16
- package/dist/runtimes/node/parser/exports.d.ts +2 -3
- package/dist/runtimes/node/parser/exports.js +2 -2
- package/dist/runtimes/node/parser/helpers.d.ts +3 -4
- package/dist/runtimes/node/parser/imports.d.ts +1 -2
- package/dist/runtimes/node/parser/imports.js +6 -6
- package/dist/runtimes/node/parser/index.d.ts +2 -3
- package/dist/runtimes/node/parser/index.js +2 -2
- package/dist/runtimes/node/utils/base_path.d.ts +1 -2
- package/dist/runtimes/node/utils/detect_es_module.d.ts +1 -2
- package/dist/runtimes/node/utils/detect_native_module.d.ts +2 -3
- package/dist/runtimes/node/utils/entry_file.d.ts +3 -4
- package/dist/runtimes/node/utils/entry_file.js +2 -2
- package/dist/runtimes/node/utils/included_files.d.ts +2 -3
- package/dist/runtimes/node/utils/module.d.ts +1 -2
- package/dist/runtimes/node/utils/node_version.d.ts +7 -7
- package/dist/runtimes/node/utils/node_version.js +4 -5
- package/dist/runtimes/node/utils/normalize_path.d.ts +1 -2
- package/dist/runtimes/node/utils/package_json.d.ts +9 -5
- package/dist/runtimes/node/utils/package_json.js +46 -21
- package/dist/runtimes/node/utils/plugin_modules_path.d.ts +2 -3
- package/dist/runtimes/node/utils/traversal_cache.d.ts +2 -3
- package/dist/runtimes/node/utils/zip.d.ts +4 -4
- package/dist/runtimes/node/utils/zip.js +14 -14
- package/dist/runtimes/runtime.d.ts +14 -15
- package/dist/runtimes/rust/builder.d.ts +2 -3
- package/dist/runtimes/rust/builder.js +8 -8
- package/dist/runtimes/rust/cargo_manifest.d.ts +1 -2
- package/dist/runtimes/rust/constants.d.ts +2 -3
- package/dist/runtimes/rust/constants.js +2 -4
- package/dist/runtimes/rust/index.d.ts +1 -1
- package/dist/runtimes/rust/index.js +17 -17
- package/dist/utils/archive_size.d.ts +2 -3
- package/dist/utils/format_result.d.ts +4 -6
- package/dist/utils/format_result.js +2 -2
- package/dist/utils/fs.d.ts +10 -12
- package/dist/utils/fs.js +7 -10
- package/dist/utils/non_nullable.d.ts +1 -2
- package/dist/utils/remove_undefined.d.ts +1 -2
- package/dist/zip.d.ts +7 -7
- package/dist/zip.js +19 -19
- package/dist/zip_binary.d.ts +2 -3
- package/dist/zip_binary.js +5 -5
- package/package.json +4 -4
|
@@ -8,8 +8,8 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const tmp_promise_1 = __importDefault(require("tmp-promise"));
|
|
10
10
|
const toml_1 = __importDefault(require("toml"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const shell_js_1 = require("../../utils/shell.js");
|
|
12
|
+
const constants_js_1 = require("./constants.js");
|
|
13
13
|
const runtimeName = 'rs';
|
|
14
14
|
const build = async ({ config, name, srcDir }) => {
|
|
15
15
|
const functionName = (0, path_1.basename)(srcDir);
|
|
@@ -26,9 +26,9 @@ const build = async ({ config, name, srcDir }) => {
|
|
|
26
26
|
// way to override it (https://github.com/rust-lang/cargo/issues/1706). We
|
|
27
27
|
// must extract the crate name from the manifest and use it to form the path
|
|
28
28
|
// to the binary.
|
|
29
|
-
const manifest = await fs_1.promises.readFile((0, path_1.join)(srcDir,
|
|
29
|
+
const manifest = await fs_1.promises.readFile((0, path_1.join)(srcDir, constants_js_1.MANIFEST_NAME), 'utf8');
|
|
30
30
|
const { package: { name: packageName }, } = toml_1.default.parse(manifest);
|
|
31
|
-
const binaryPath = (0, path_1.join)(targetDirectory,
|
|
31
|
+
const binaryPath = (0, path_1.join)(targetDirectory, constants_js_1.BUILD_TARGET, 'release', packageName);
|
|
32
32
|
const stat = await fs_1.promises.lstat(binaryPath);
|
|
33
33
|
return {
|
|
34
34
|
path: binaryPath,
|
|
@@ -38,7 +38,7 @@ const build = async ({ config, name, srcDir }) => {
|
|
|
38
38
|
exports.build = build;
|
|
39
39
|
const cargoBuild = async ({ functionName, srcDir, targetDirectory, }) => {
|
|
40
40
|
try {
|
|
41
|
-
await
|
|
41
|
+
await shell_js_1.shellUtils.runCommand('cargo', ['build', '--target', constants_js_1.BUILD_TARGET, '--release'], {
|
|
42
42
|
cwd: srcDir,
|
|
43
43
|
env: {
|
|
44
44
|
CARGO_TARGET_DIR: targetDirectory,
|
|
@@ -60,7 +60,7 @@ const cargoBuild = async ({ functionName, srcDir, targetDirectory, }) => {
|
|
|
60
60
|
};
|
|
61
61
|
const checkRustToolchain = async () => {
|
|
62
62
|
try {
|
|
63
|
-
await
|
|
63
|
+
await shell_js_1.shellUtils.runCommand('cargo', ['-V']);
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
catch {
|
|
@@ -86,8 +86,8 @@ let toolchainInstallation;
|
|
|
86
86
|
// `BUILD_TARGET`. The Promise is saved to `toolchainInstallation`, so
|
|
87
87
|
// that we run the command just once for multiple Rust functions.
|
|
88
88
|
const installToolchain = async () => {
|
|
89
|
-
await
|
|
90
|
-
await
|
|
89
|
+
await shell_js_1.shellUtils.runCommand('rustup', ['default', 'stable']);
|
|
90
|
+
await shell_js_1.shellUtils.runCommand('rustup', ['target', 'add', constants_js_1.BUILD_TARGET]);
|
|
91
91
|
};
|
|
92
92
|
const installToolchainOnce = () => {
|
|
93
93
|
if (toolchainInstallation === undefined) {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare const BUILD_TARGET = "x86_64-unknown-linux-musl";
|
|
2
|
-
declare const MANIFEST_NAME = "Cargo.toml";
|
|
3
|
-
export { BUILD_TARGET, MANIFEST_NAME };
|
|
1
|
+
export declare const BUILD_TARGET = "x86_64-unknown-linux-musl";
|
|
2
|
+
export declare const MANIFEST_NAME = "Cargo.toml";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MANIFEST_NAME = exports.BUILD_TARGET = void 0;
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
const MANIFEST_NAME = 'Cargo.toml';
|
|
7
|
-
exports.MANIFEST_NAME = MANIFEST_NAME;
|
|
4
|
+
exports.BUILD_TARGET = 'x86_64-unknown-linux-musl';
|
|
5
|
+
exports.MANIFEST_NAME = 'Cargo.toml';
|
|
8
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path_1 = require("path");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
4
|
+
const fs_js_1 = require("../../utils/fs.js");
|
|
5
|
+
const non_nullable_js_1 = require("../../utils/non_nullable.js");
|
|
6
|
+
const zip_binary_js_1 = require("../../zip_binary.js");
|
|
7
|
+
const detect_runtime_js_1 = require("../detect_runtime.js");
|
|
8
|
+
const builder_js_1 = require("./builder.js");
|
|
9
|
+
const constants_js_1 = require("./constants.js");
|
|
10
10
|
const detectRustFunction = async ({ fsCache, path }) => {
|
|
11
|
-
const stat = await (0,
|
|
11
|
+
const stat = await (0, fs_js_1.cachedLstat)(fsCache, path);
|
|
12
12
|
if (!stat.isDirectory()) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
// @ts-expect-error TODO: The `makeCachedFunction` abstraction is causing the
|
|
16
16
|
// return value of `readdir` to be incorrectly typed.
|
|
17
|
-
const files = (await (0,
|
|
18
|
-
const hasCargoManifest = files.includes(
|
|
17
|
+
const files = (await (0, fs_js_1.cachedReaddir)(fsCache, path));
|
|
18
|
+
const hasCargoManifest = files.includes(constants_js_1.MANIFEST_NAME);
|
|
19
19
|
if (!hasCargoManifest) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
const mainFilePath = (0, path_1.join)(path, 'src', 'main.rs');
|
|
23
23
|
try {
|
|
24
|
-
const mainFile = await (0,
|
|
24
|
+
const mainFile = await (0, fs_js_1.cachedLstat)(fsCache, mainFilePath);
|
|
25
25
|
if (mainFile.isFile()) {
|
|
26
26
|
return mainFilePath;
|
|
27
27
|
}
|
|
@@ -32,10 +32,10 @@ const detectRustFunction = async ({ fsCache, path }) => {
|
|
|
32
32
|
};
|
|
33
33
|
const findFunctionsInPaths = async function ({ featureFlags, fsCache, paths, }) {
|
|
34
34
|
const functions = await Promise.all(paths.map((path) => findFunctionInPath({ path, featureFlags, fsCache })));
|
|
35
|
-
return functions.filter(
|
|
35
|
+
return functions.filter(non_nullable_js_1.nonNullable);
|
|
36
36
|
};
|
|
37
37
|
const findFunctionInPath = async function ({ path, featureFlags, fsCache }) {
|
|
38
|
-
const runtime = await (0,
|
|
38
|
+
const runtime = await (0, detect_runtime_js_1.detectBinaryRuntime)({ fsCache, path });
|
|
39
39
|
if (runtime === 'rs') {
|
|
40
40
|
return processBinary({ fsCache, path });
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ const findFunctionInPath = async function ({ path, featureFlags, fsCache }) {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
const processBinary = async ({ fsCache, path }) => {
|
|
51
|
-
const stat = (await (0,
|
|
51
|
+
const stat = (await (0, fs_js_1.cachedLstat)(fsCache, path));
|
|
52
52
|
const filename = (0, path_1.basename)(path);
|
|
53
53
|
const extension = (0, path_1.extname)(path);
|
|
54
54
|
const name = (0, path_1.basename)(path, extension);
|
|
@@ -67,7 +67,7 @@ const processSource = async ({ fsCache, mainFile, path, }) => {
|
|
|
67
67
|
// the `FunctionSource` interface. We should revisit whether `stat` should be
|
|
68
68
|
// part of that interface in the first place, or whether we could compute it
|
|
69
69
|
// downstream when needed (maybe using the FS cache as an optimisation).
|
|
70
|
-
const stat = (await (0,
|
|
70
|
+
const stat = (await (0, fs_js_1.cachedLstat)(fsCache, path));
|
|
71
71
|
const filename = (0, path_1.basename)(path);
|
|
72
72
|
const extension = (0, path_1.extname)(path);
|
|
73
73
|
const name = (0, path_1.basename)(path, extension);
|
|
@@ -96,11 +96,11 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, ru
|
|
|
96
96
|
// the resulting binary. Otherwise, we're dealing with a binary so we zip it
|
|
97
97
|
// directly.
|
|
98
98
|
if (isSource) {
|
|
99
|
-
const { path: binaryPath, stat: binaryStat } = await (0,
|
|
100
|
-
await (0,
|
|
99
|
+
const { path: binaryPath, stat: binaryStat } = await (0, builder_js_1.build)({ config, name: filename, srcDir });
|
|
100
|
+
await (0, zip_binary_js_1.zipBinary)({ ...zipOptions, srcPath: binaryPath, stat: binaryStat });
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
|
-
await (0,
|
|
103
|
+
await (0, zip_binary_js_1.zipBinary)({ ...zipOptions, srcPath, stat });
|
|
104
104
|
}
|
|
105
105
|
return { config, path: destPath };
|
|
106
106
|
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { FunctionArchive } from '../function';
|
|
2
|
-
declare const addArchiveSize: (result: FunctionArchive) => Promise<FunctionArchive>;
|
|
3
|
-
export { addArchiveSize };
|
|
1
|
+
import type { FunctionArchive } from '../function.js';
|
|
2
|
+
export declare const addArchiveSize: (result: FunctionArchive) => Promise<FunctionArchive>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { FunctionArchive } from '../function';
|
|
2
|
-
import { RuntimeName } from '../runtimes/runtime';
|
|
3
|
-
declare type FunctionResult = Omit<FunctionArchive, 'runtime'> & {
|
|
1
|
+
import { FunctionArchive } from '../function.js';
|
|
2
|
+
import { RuntimeName } from '../runtimes/runtime.js';
|
|
3
|
+
export declare type FunctionResult = Omit<FunctionArchive, 'runtime'> & {
|
|
4
4
|
runtime: RuntimeName;
|
|
5
5
|
schedule?: string;
|
|
6
6
|
};
|
|
7
|
-
declare const formatZipResult: (archive: FunctionArchive) => FunctionResult;
|
|
8
|
-
export { formatZipResult };
|
|
9
|
-
export type { FunctionResult };
|
|
7
|
+
export declare const formatZipResult: (archive: FunctionArchive) => FunctionResult;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatZipResult = void 0;
|
|
4
|
-
const
|
|
4
|
+
const remove_undefined_js_1 = require("./remove_undefined.js");
|
|
5
5
|
// Takes the result of zipping a function and formats it for output.
|
|
6
6
|
const formatZipResult = (archive) => {
|
|
7
7
|
var _a, _b, _c;
|
|
@@ -11,7 +11,7 @@ const formatZipResult = (archive) => {
|
|
|
11
11
|
runtime: archive.runtime.name,
|
|
12
12
|
schedule: (_b = (_a = archive.inSourceConfig) === null || _a === void 0 ? void 0 : _a.schedule) !== null && _b !== void 0 ? _b : (_c = archive === null || archive === void 0 ? void 0 : archive.config) === null || _c === void 0 ? void 0 : _c.schedule,
|
|
13
13
|
};
|
|
14
|
-
return (0,
|
|
14
|
+
return (0, remove_undefined_js_1.removeUndefined)(functionResult);
|
|
15
15
|
};
|
|
16
16
|
exports.formatZipResult = formatZipResult;
|
|
17
17
|
//# sourceMappingURL=format_result.js.map
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
|
-
declare type FsCache = Record<string, unknown>;
|
|
4
|
-
declare const cachedLstat: (cache: FsCache, path: string, opts?: import("fs").StatOptions | undefined) => Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
5
|
-
declare const cachedReaddir: (cache: FsCache, path: string, options: import("fs").ObjectEncodingOptions & {
|
|
3
|
+
export declare type FsCache = Record<string, unknown>;
|
|
4
|
+
export declare const cachedLstat: (cache: FsCache, path: string, opts?: import("fs").StatOptions | undefined) => Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
5
|
+
export declare const cachedReaddir: (cache: FsCache, path: string, options: import("fs").ObjectEncodingOptions & {
|
|
6
6
|
withFileTypes: true;
|
|
7
7
|
}) => Promise<import("fs").Dirent[]>;
|
|
8
|
-
declare const cachedReadFile: (cache: FsCache, path: string, options?: BufferEncoding | (import("fs").ObjectEncodingOptions & import("events").Abortable & {
|
|
8
|
+
export declare const cachedReadFile: (cache: FsCache, path: string, options?: BufferEncoding | (import("fs").ObjectEncodingOptions & import("events").Abortable & {
|
|
9
9
|
flag?: import("fs").OpenMode | undefined;
|
|
10
10
|
}) | null | undefined) => Promise<string | Buffer>;
|
|
11
|
-
declare const getPathWithExtension: (path: string, extension: string) => string;
|
|
12
|
-
declare const safeUnlink: (path: string) => Promise<void>;
|
|
13
|
-
declare const listFunctionsDirectories: (srcFolders: string[]) => Promise<string[]>;
|
|
14
|
-
declare const listFunctionsDirectory: (srcFolder: string) => Promise<string[]>;
|
|
15
|
-
declare const resolveFunctionsDirectories: (input: string | string[]) => string[];
|
|
16
|
-
declare const mkdirAndWriteFile: typeof fs.writeFile;
|
|
17
|
-
export { cachedLstat, cachedReaddir, cachedReadFile, getPathWithExtension, listFunctionsDirectories, listFunctionsDirectory, resolveFunctionsDirectories, safeUnlink, mkdirAndWriteFile, };
|
|
18
|
-
export type { FsCache };
|
|
11
|
+
export declare const getPathWithExtension: (path: string, extension: string) => string;
|
|
12
|
+
export declare const safeUnlink: (path: string) => Promise<void>;
|
|
13
|
+
export declare const listFunctionsDirectories: (srcFolders: string[]) => Promise<string[]>;
|
|
14
|
+
export declare const listFunctionsDirectory: (srcFolder: string) => Promise<string[]>;
|
|
15
|
+
export declare const resolveFunctionsDirectories: (input: string | string[]) => string[];
|
|
16
|
+
export declare const mkdirAndWriteFile: typeof fs.writeFile;
|
package/dist/utils/fs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mkdirAndWriteFile = exports.
|
|
3
|
+
exports.mkdirAndWriteFile = exports.resolveFunctionsDirectories = exports.listFunctionsDirectory = exports.listFunctionsDirectories = exports.safeUnlink = exports.getPathWithExtension = exports.cachedReadFile = exports.cachedReaddir = exports.cachedLstat = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
6
|
+
const non_nullable_js_1 = require("./non_nullable.js");
|
|
7
7
|
// This caches multiple FS calls to the same path. It creates a cache key with
|
|
8
8
|
// the name of the function and the path (e.g. "readdir:/some/directory").
|
|
9
9
|
//
|
|
@@ -18,12 +18,9 @@ const makeCachedFunction = (func) => (cache, path, ...args) => {
|
|
|
18
18
|
}
|
|
19
19
|
return cache[key];
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
exports.
|
|
23
|
-
|
|
24
|
-
exports.cachedReaddir = cachedReaddir;
|
|
25
|
-
const cachedReadFile = makeCachedFunction(fs_1.promises.readFile);
|
|
26
|
-
exports.cachedReadFile = cachedReadFile;
|
|
21
|
+
exports.cachedLstat = makeCachedFunction(fs_1.promises.lstat);
|
|
22
|
+
exports.cachedReaddir = makeCachedFunction(fs_1.promises.readdir);
|
|
23
|
+
exports.cachedReadFile = makeCachedFunction(fs_1.promises.readFile);
|
|
27
24
|
const getPathWithExtension = (path, extension) => (0, path_1.format)({ ...(0, path_1.parse)(path), base: undefined, ext: extension });
|
|
28
25
|
exports.getPathWithExtension = getPathWithExtension;
|
|
29
26
|
const safeUnlink = async (path) => {
|
|
@@ -39,14 +36,14 @@ exports.safeUnlink = safeUnlink;
|
|
|
39
36
|
const listFunctionsDirectories = async function (srcFolders) {
|
|
40
37
|
const filenamesByDirectory = await Promise.all(srcFolders.map(async (srcFolder) => {
|
|
41
38
|
try {
|
|
42
|
-
const filenames = await listFunctionsDirectory(srcFolder);
|
|
39
|
+
const filenames = await (0, exports.listFunctionsDirectory)(srcFolder);
|
|
43
40
|
return filenames;
|
|
44
41
|
}
|
|
45
42
|
catch {
|
|
46
43
|
return null;
|
|
47
44
|
}
|
|
48
45
|
}));
|
|
49
|
-
const validDirectories = filenamesByDirectory.filter(
|
|
46
|
+
const validDirectories = filenamesByDirectory.filter(non_nullable_js_1.nonNullable);
|
|
50
47
|
if (validDirectories.length === 0) {
|
|
51
48
|
throw new Error(`Functions folder does not exist: ${srcFolders.join(', ')}`);
|
|
52
49
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare const nonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
2
|
-
export { nonNullable };
|
|
1
|
+
export declare const nonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare const removeUndefined: <T>(obj: T) => T;
|
|
2
|
-
export { removeUndefined };
|
|
1
|
+
export declare const removeUndefined: <T>(obj: T) => T;
|
package/dist/zip.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ArchiveFormat } from './archive';
|
|
2
|
-
import { Config } from './config';
|
|
3
|
-
import { FeatureFlags } from './feature_flags';
|
|
1
|
+
import { ArchiveFormat } from './archive.js';
|
|
2
|
+
import { Config } from './config.js';
|
|
3
|
+
import { FeatureFlags } from './feature_flags.js';
|
|
4
4
|
interface ZipFunctionOptions {
|
|
5
5
|
archiveFormat?: ArchiveFormat;
|
|
6
6
|
basePath?: string;
|
|
@@ -13,9 +13,9 @@ declare type ZipFunctionsOptions = ZipFunctionOptions & {
|
|
|
13
13
|
manifest?: string;
|
|
14
14
|
parallelLimit?: number;
|
|
15
15
|
};
|
|
16
|
-
declare const zipFunctions: (relativeSrcFolders: string | string[], destFolder: string, { archiveFormat, basePath, config, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, }?: ZipFunctionsOptions) => Promise<(Omit<import("./function").FunctionArchive, "runtime"> & {
|
|
17
|
-
runtime: import("./runtimes/runtime").RuntimeName;
|
|
16
|
+
export declare const zipFunctions: (relativeSrcFolders: string | string[], destFolder: string, { archiveFormat, basePath, config, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, }?: ZipFunctionsOptions) => Promise<(Omit<import("./function.js").FunctionArchive, "runtime"> & {
|
|
17
|
+
runtime: import("./runtimes/runtime.js").RuntimeName;
|
|
18
18
|
schedule?: string | undefined;
|
|
19
19
|
})[]>;
|
|
20
|
-
declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config: inputConfig, featureFlags: inputFeatureFlags, repositoryRoot, }?: ZipFunctionOptions) => Promise<import("./utils/format_result").FunctionResult | undefined>;
|
|
21
|
-
export {
|
|
20
|
+
export declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config: inputConfig, featureFlags: inputFeatureFlags, repositoryRoot, }?: ZipFunctionOptions) => Promise<import("./utils/format_result.js").FunctionResult | undefined>;
|
|
21
|
+
export {};
|
package/dist/zip.js
CHANGED
|
@@ -3,17 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.zipFunction = exports.zipFunctions = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const p_map_1 = __importDefault(require("p-map"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
10
|
+
const feature_flags_js_1 = require("./feature_flags.js");
|
|
11
|
+
const manifest_js_1 = require("./manifest.js");
|
|
12
|
+
const index_js_1 = require("./runtimes/index.js");
|
|
13
|
+
const archive_size_js_1 = require("./utils/archive_size.js");
|
|
14
|
+
const format_result_js_1 = require("./utils/format_result.js");
|
|
15
|
+
const fs_js_1 = require("./utils/fs.js");
|
|
16
|
+
const non_nullable_js_1 = require("./utils/non_nullable.js");
|
|
17
17
|
const DEFAULT_PARALLEL_LIMIT = 5;
|
|
18
18
|
// TODO: now that we have types, do we still need runtime validation?
|
|
19
19
|
const validateArchiveFormat = (archiveFormat) => {
|
|
@@ -25,10 +25,10 @@ const validateArchiveFormat = (archiveFormat) => {
|
|
|
25
25
|
// used by AWS Lambda
|
|
26
26
|
const zipFunctions = async function (relativeSrcFolders, destFolder, { archiveFormat = 'zip', basePath, config = {}, featureFlags: inputFeatureFlags, manifest, parallelLimit = DEFAULT_PARALLEL_LIMIT, repositoryRoot = basePath, } = {}) {
|
|
27
27
|
validateArchiveFormat(archiveFormat);
|
|
28
|
-
const featureFlags = (0,
|
|
29
|
-
const srcFolders = (0,
|
|
30
|
-
const [paths] = await Promise.all([(0,
|
|
31
|
-
const functions = await (0,
|
|
28
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
29
|
+
const srcFolders = (0, fs_js_1.resolveFunctionsDirectories)(relativeSrcFolders);
|
|
30
|
+
const [paths] = await Promise.all([(0, fs_js_1.listFunctionsDirectories)(srcFolders), fs_1.promises.mkdir(destFolder, { recursive: true })]);
|
|
31
|
+
const functions = await (0, index_js_1.getFunctionsFromPaths)(paths, { config, dedupe: true, featureFlags });
|
|
32
32
|
const results = await (0, p_map_1.default)(functions.values(), async (func) => {
|
|
33
33
|
const zipResult = await func.runtime.zipFunction({
|
|
34
34
|
archiveFormat,
|
|
@@ -50,21 +50,21 @@ const zipFunctions = async function (relativeSrcFolders, destFolder, { archiveFo
|
|
|
50
50
|
}, {
|
|
51
51
|
concurrency: parallelLimit,
|
|
52
52
|
});
|
|
53
|
-
const formattedResults = await Promise.all(results.filter(
|
|
54
|
-
const resultWithSize = await (0,
|
|
55
|
-
return (0,
|
|
53
|
+
const formattedResults = await Promise.all(results.filter(non_nullable_js_1.nonNullable).map(async (result) => {
|
|
54
|
+
const resultWithSize = await (0, archive_size_js_1.addArchiveSize)(result);
|
|
55
|
+
return (0, format_result_js_1.formatZipResult)(resultWithSize);
|
|
56
56
|
}));
|
|
57
57
|
if (manifest !== undefined) {
|
|
58
|
-
await (0,
|
|
58
|
+
await (0, manifest_js_1.createManifest)({ functions: formattedResults, path: (0, path_1.resolve)(manifest) });
|
|
59
59
|
}
|
|
60
60
|
return formattedResults;
|
|
61
61
|
};
|
|
62
62
|
exports.zipFunctions = zipFunctions;
|
|
63
63
|
const zipFunction = async function (relativeSrcPath, destFolder, { archiveFormat = 'zip', basePath, config: inputConfig = {}, featureFlags: inputFeatureFlags, repositoryRoot = basePath, } = {}) {
|
|
64
64
|
validateArchiveFormat(archiveFormat);
|
|
65
|
-
const featureFlags = (0,
|
|
65
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
66
66
|
const srcPath = (0, path_1.resolve)(relativeSrcPath);
|
|
67
|
-
const functions = await (0,
|
|
67
|
+
const functions = await (0, index_js_1.getFunctionsFromPaths)([srcPath], { config: inputConfig, dedupe: true, featureFlags });
|
|
68
68
|
if (functions.size === 0) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
@@ -86,7 +86,7 @@ const zipFunction = async function (relativeSrcPath, destFolder, { archiveFormat
|
|
|
86
86
|
srcPath,
|
|
87
87
|
stat: stats,
|
|
88
88
|
});
|
|
89
|
-
return (0,
|
|
89
|
+
return (0, format_result_js_1.formatZipResult)({ ...zipResult, mainFile, name, runtime });
|
|
90
90
|
};
|
|
91
91
|
exports.zipFunction = zipFunction;
|
|
92
92
|
//# sourceMappingURL=zip.js.map
|
package/dist/zip_binary.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Stats } from 'fs';
|
|
2
|
-
import { Runtime } from './runtimes/runtime';
|
|
3
|
-
declare const zipBinary: ({ destPath, filename, runtime, srcPath, stat, }: {
|
|
2
|
+
import { Runtime } from './runtimes/runtime.js';
|
|
3
|
+
export declare const zipBinary: ({ destPath, filename, runtime, srcPath, stat, }: {
|
|
4
4
|
destPath: string;
|
|
5
5
|
filename: string;
|
|
6
6
|
runtime: Runtime;
|
|
7
7
|
srcPath: string;
|
|
8
8
|
stat: Stats;
|
|
9
9
|
}) => Promise<void>;
|
|
10
|
-
export { zipBinary };
|
package/dist/zip_binary.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zipBinary = void 0;
|
|
4
|
-
const
|
|
4
|
+
const archive_js_1 = require("./archive.js");
|
|
5
5
|
// Zip a binary function file
|
|
6
6
|
const zipBinary = async function ({ destPath, filename, runtime, srcPath, stat, }) {
|
|
7
|
-
const { archive, output } = (0,
|
|
8
|
-
(0,
|
|
9
|
-
(0,
|
|
10
|
-
await (0,
|
|
7
|
+
const { archive, output } = (0, archive_js_1.startZip)(destPath);
|
|
8
|
+
(0, archive_js_1.addZipFile)(archive, srcPath, filename, stat);
|
|
9
|
+
(0, archive_js_1.addZipContent)(archive, JSON.stringify({ runtime: runtime.name }), 'netlify-toolchain');
|
|
10
|
+
await (0, archive_js_1.endZip)(archive, output);
|
|
11
11
|
};
|
|
12
12
|
exports.zipBinary = zipBinary;
|
|
13
13
|
//# sourceMappingURL=zip_binary.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"junk": "^3.1.0",
|
|
71
71
|
"locate-path": "^6.0.0",
|
|
72
72
|
"merge-options": "^3.0.4",
|
|
73
|
-
"minimatch": "^
|
|
73
|
+
"minimatch": "^4.0.0",
|
|
74
74
|
"p-map": "^4.0.0",
|
|
75
75
|
"path-exists": "^4.0.0",
|
|
76
76
|
"pkg-dir": "^5.0.0",
|
|
@@ -81,7 +81,6 @@
|
|
|
81
81
|
"semver": "^7.0.0",
|
|
82
82
|
"tmp-promise": "^3.0.2",
|
|
83
83
|
"toml": "^3.0.0",
|
|
84
|
-
"typescript": "^4.6.0-beta",
|
|
85
84
|
"unixify": "^1.0.0",
|
|
86
85
|
"yargs": "^16.0.0"
|
|
87
86
|
},
|
|
@@ -105,7 +104,8 @@
|
|
|
105
104
|
"sinon": "^13.0.0",
|
|
106
105
|
"sort-on": "^4.1.1",
|
|
107
106
|
"source-map-support": "^0.5.20",
|
|
108
|
-
"throat": "^6.0.1"
|
|
107
|
+
"throat": "^6.0.1",
|
|
108
|
+
"typescript": "^4.6.0-beta"
|
|
109
109
|
},
|
|
110
110
|
"engines": {
|
|
111
111
|
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|