@netlify/zip-it-and-ship-it 5.2.0 → 5.4.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/archive.js CHANGED
@@ -28,8 +28,19 @@ const startZip = function (destPath) {
28
28
  exports.startZip = startZip;
29
29
  // Add new file to zip
30
30
  const addZipFile = function (archive, file, name, stat) {
31
- // Ensure sha256 stability regardless of mtime
32
- archive.file(file, { name, mode: stat.mode, date: new Date(0), stats: stat });
31
+ if (stat.isSymbolicLink()) {
32
+ const linkContent = (0, fs_1.readlinkSync)(file);
33
+ archive.symlink(name, linkContent, stat.mode);
34
+ }
35
+ else {
36
+ archive.file(file, {
37
+ name,
38
+ mode: stat.mode,
39
+ // Ensure sha256 stability regardless of mtime
40
+ date: new Date(0),
41
+ stats: stat,
42
+ });
43
+ }
33
44
  };
34
45
  exports.addZipFile = addZipFile;
35
46
  // Add new file content to zip
@@ -6,7 +6,6 @@ const FLAGS = {
6
6
  buildGoSource: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_BUILD_GO_SOURCE),
7
7
  buildRustSource: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE),
8
8
  defaultEsModulesToEsbuild: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_DEFAULT_ES_MODULES_TO_ESBUILD),
9
- parseISC: false,
10
9
  parseWithEsbuild: false,
11
10
  traceWithNft: false,
12
11
  };
package/dist/main.d.ts CHANGED
@@ -6,6 +6,7 @@ interface ListedFunction {
6
6
  mainFile: string;
7
7
  runtime: RuntimeName;
8
8
  extension: string;
9
+ schedule?: string;
9
10
  }
10
11
  declare type ListedFunctionFile = ListedFunction & {
11
12
  srcFile: string;
@@ -14,10 +15,18 @@ interface ListFunctionsOptions {
14
15
  basePath?: string;
15
16
  config?: Config;
16
17
  featureFlags?: FeatureFlags;
18
+ parseISC?: boolean;
17
19
  }
18
- declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags }?: {
19
- featureFlags?: FeatureFlags;
20
+ declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
21
+ featureFlags?: FeatureFlags | undefined;
22
+ config?: Config | undefined;
23
+ parseISC?: boolean | undefined;
20
24
  }) => Promise<ListedFunction[]>;
21
- declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
22
- export { listFunctions, listFunctionsFiles };
25
+ declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
26
+ featureFlags?: FeatureFlags | undefined;
27
+ config?: Config | undefined;
28
+ parseISC?: boolean | undefined;
29
+ }) => Promise<ListedFunction | undefined>;
30
+ declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
31
+ export { listFunctions, listFunction, listFunctionsFiles };
23
32
  export { zipFunction, zipFunctions } from './zip';
package/dist/main.js CHANGED
@@ -20,43 +20,68 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.zipFunctions = exports.zipFunction = exports.listFunctionsFiles = exports.listFunctions = void 0;
23
+ exports.zipFunctions = exports.zipFunction = exports.listFunctionsFiles = exports.listFunction = exports.listFunctions = void 0;
24
24
  const path_1 = require("path");
25
25
  const feature_flags_1 = require("./feature_flags");
26
26
  const runtimes_1 = require("./runtimes");
27
+ const in_source_config_1 = require("./runtimes/node/in_source_config");
27
28
  const fs_1 = require("./utils/fs");
29
+ const augmentWithISC = (func) => __awaiter(void 0, void 0, void 0, function* () {
30
+ // ISC is currently only supported in JavaScript and TypeScript functions.
31
+ if (func.runtime.name !== 'js') {
32
+ return func;
33
+ }
34
+ const inSourceConfig = yield (0, in_source_config_1.findISCDeclarationsInPath)(func.mainFile);
35
+ return Object.assign(Object.assign({}, func), { inSourceConfig });
36
+ });
28
37
  // List all Netlify Functions main entry files for a specific directory
29
- const listFunctions = function (relativeSrcFolders, { featureFlags: inputFeatureFlags } = {}) {
38
+ const listFunctions = function (relativeSrcFolders, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
30
39
  return __awaiter(this, void 0, void 0, function* () {
31
40
  const featureFlags = (0, feature_flags_1.getFlags)(inputFeatureFlags);
32
41
  const srcFolders = (0, fs_1.resolveFunctionsDirectories)(relativeSrcFolders);
33
42
  const paths = yield (0, fs_1.listFunctionsDirectories)(srcFolders);
34
- const functions = yield (0, runtimes_1.getFunctionsFromPaths)(paths, { featureFlags });
35
- const listedFunctions = [...functions.values()].map(getListedFunction);
36
- return listedFunctions;
43
+ const functionsMap = yield (0, runtimes_1.getFunctionsFromPaths)(paths, { featureFlags, config });
44
+ const functions = [...functionsMap.values()];
45
+ const augmentedFunctions = parseISC ? yield Promise.all(functions.map(augmentWithISC)) : functions;
46
+ return augmentedFunctions.map(getListedFunction);
37
47
  });
38
48
  };
39
49
  exports.listFunctions = listFunctions;
50
+ // Finds a function at a specific path.
51
+ const listFunction = function (path, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const featureFlags = (0, feature_flags_1.getFlags)(inputFeatureFlags);
54
+ const func = yield (0, runtimes_1.getFunctionFromPath)(path, { featureFlags, config });
55
+ if (!func) {
56
+ return;
57
+ }
58
+ const augmentedFunction = parseISC ? yield augmentWithISC(func) : func;
59
+ return getListedFunction(augmentedFunction);
60
+ });
61
+ };
62
+ exports.listFunction = listFunction;
40
63
  // List all Netlify Functions files for a specific directory
41
- const listFunctionsFiles = function (relativeSrcFolders, { basePath, config, featureFlags: inputFeatureFlags } = {}) {
64
+ const listFunctionsFiles = function (relativeSrcFolders, { basePath, config, featureFlags: inputFeatureFlags, parseISC = false } = {}) {
42
65
  return __awaiter(this, void 0, void 0, function* () {
43
66
  const featureFlags = (0, feature_flags_1.getFlags)(inputFeatureFlags);
44
67
  const srcFolders = (0, fs_1.resolveFunctionsDirectories)(relativeSrcFolders);
45
68
  const paths = yield (0, fs_1.listFunctionsDirectories)(srcFolders);
46
- const functions = yield (0, runtimes_1.getFunctionsFromPaths)(paths, { config, featureFlags });
47
- const listedFunctionsFiles = yield Promise.all([...functions.values()].map((func) => getListedFunctionFiles(func, { basePath, featureFlags })));
69
+ const functionsMap = yield (0, runtimes_1.getFunctionsFromPaths)(paths, { config, featureFlags });
70
+ const functions = [...functionsMap.values()];
71
+ const augmentedFunctions = parseISC ? yield Promise.all(functions.map(augmentWithISC)) : functions;
72
+ const listedFunctionsFiles = yield Promise.all(augmentedFunctions.map((func) => getListedFunctionFiles(func, { basePath, featureFlags })));
48
73
  return listedFunctionsFiles.flat();
49
74
  });
50
75
  };
51
76
  exports.listFunctionsFiles = listFunctionsFiles;
52
- const getListedFunction = function ({ runtime, name, mainFile, extension }) {
53
- return { name, mainFile, runtime: runtime.name, extension };
77
+ const getListedFunction = function ({ runtime, name, mainFile, extension, config, inSourceConfig, }) {
78
+ var _a;
79
+ return { name, mainFile, runtime: runtime.name, extension, schedule: (_a = inSourceConfig === null || inSourceConfig === void 0 ? void 0 : inSourceConfig.schedule) !== null && _a !== void 0 ? _a : config.schedule };
54
80
  };
55
81
  const getListedFunctionFiles = function (func, options) {
56
82
  return __awaiter(this, void 0, void 0, function* () {
57
83
  const srcFiles = yield getSrcFiles(Object.assign(Object.assign({}, func), options));
58
- const { name, mainFile, runtime } = func;
59
- return srcFiles.map((srcFile) => ({ srcFile, name, mainFile, runtime: runtime.name, extension: (0, path_1.extname)(srcFile) }));
84
+ return srcFiles.map((srcFile) => (Object.assign(Object.assign({}, getListedFunction(func)), { srcFile, extension: (0, path_1.extname)(srcFile) })));
60
85
  });
61
86
  };
62
87
  const getSrcFiles = function (_a) {
@@ -35,22 +35,25 @@ const detectGoFunction = ({ fsCache, path }) => __awaiter(void 0, void 0, void 0
35
35
  });
36
36
  const findFunctionsInPaths = function ({ featureFlags, fsCache, paths }) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const functions = yield Promise.all(paths.map((path) => __awaiter(this, void 0, void 0, function* () {
39
- const runtime = yield (0, detect_runtime_1.detectBinaryRuntime)({ fsCache, path });
40
- if (runtime === 'go') {
41
- return processBinary({ fsCache, path });
42
- }
43
- if (featureFlags.buildGoSource !== true) {
44
- return;
45
- }
46
- const goSourceFile = yield detectGoFunction({ fsCache, path });
47
- if (goSourceFile) {
48
- return processSource({ fsCache, mainFile: goSourceFile, path });
49
- }
50
- })));
38
+ const functions = yield Promise.all(paths.map((path) => findFunctionInPath({ featureFlags, fsCache, path })));
51
39
  return functions.filter(non_nullable_1.nonNullable);
52
40
  });
53
41
  };
42
+ const findFunctionInPath = function ({ featureFlags, fsCache, path }) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const runtime = yield (0, detect_runtime_1.detectBinaryRuntime)({ fsCache, path });
45
+ if (runtime === 'go') {
46
+ return processBinary({ fsCache, path });
47
+ }
48
+ if (featureFlags.buildGoSource !== true) {
49
+ return;
50
+ }
51
+ const goSourceFile = yield detectGoFunction({ fsCache, path });
52
+ if (goSourceFile) {
53
+ return processSource({ fsCache, mainFile: goSourceFile, path });
54
+ }
55
+ });
56
+ };
54
57
  const processBinary = ({ fsCache, path }) => __awaiter(void 0, void 0, void 0, function* () {
55
58
  const stat = (yield (0, fs_1.cachedLstat)(fsCache, path));
56
59
  const extension = (0, path_1.extname)(path);
@@ -96,6 +99,6 @@ const zipFunction = function ({ config, destFolder, filename, mainFile, srcDir,
96
99
  return { config, path: destPath };
97
100
  });
98
101
  };
99
- const runtime = { findFunctionsInPaths, name: 'go', zipFunction };
102
+ const runtime = { findFunctionsInPaths, findFunctionInPath, name: 'go', zipFunction };
100
103
  exports.default = runtime;
101
104
  //# sourceMappingURL=index.js.map
@@ -10,4 +10,11 @@ declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, feature
10
10
  dedupe?: boolean | undefined;
11
11
  featureFlags?: FeatureFlags | undefined;
12
12
  }) => Promise<FunctionMap>;
13
- export { getFunctionsFromPaths };
13
+ /**
14
+ * Gets a list of functions found in a list of paths.
15
+ */
16
+ declare const getFunctionFromPath: (path: string, { config, featureFlags }?: {
17
+ config?: Config | undefined;
18
+ featureFlags?: FeatureFlags | undefined;
19
+ }) => Promise<FunctionSource | undefined>;
20
+ export { getFunctionsFromPaths, getFunctionFromPath };
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getFunctionsFromPaths = void 0;
15
+ exports.getFunctionFromPath = exports.getFunctionsFromPaths = void 0;
16
16
  const path_1 = require("path");
17
17
  const config_1 = require("../config");
18
18
  const feature_flags_1 = require("../feature_flags");
@@ -42,23 +42,24 @@ const findFunctionsInRuntime = function ({ dedupe = false, featureFlags, fsCache
42
42
  return { functions: augmentedFunctions, remainingPaths };
43
43
  });
44
44
  };
45
+ // An object to cache filesystem operations. This allows different functions
46
+ // to perform IO operations on the same file (i.e. getting its stats or its
47
+ // contents) without duplicating work.
48
+ const makeFsCache = () => ({});
49
+ // The order of this array determines the priority of the runtimes. If a path
50
+ // is used by the first time, it won't be made available to the subsequent
51
+ // runtimes.
52
+ const RUNTIMES = [node_1.default, go_1.default, rust_1.default];
45
53
  /**
46
54
  * Gets a list of functions found in a list of paths.
47
55
  */
48
56
  const getFunctionsFromPaths = (paths, { config, dedupe = false, featureFlags = feature_flags_1.defaultFlags, } = {}) => __awaiter(void 0, void 0, void 0, function* () {
49
- // An object to cache filesystem operations. This allows different functions
50
- // to perform IO operations on the same file (i.e. getting its stats or its
51
- // contents) without duplicating work.
52
- const fsCache = {};
53
- // The order of this array determines the priority of the runtimes. If a path
54
- // is used by the first time, it won't be made available to the subsequent
55
- // runtimes.
56
- const runtimes = [node_1.default, go_1.default, rust_1.default];
57
+ const fsCache = makeFsCache();
57
58
  // We cycle through the ordered array of runtimes, passing each one of them
58
59
  // through `findFunctionsInRuntime`. For each iteration, we collect all the
59
60
  // functions found plus the list of paths that still need to be evaluated,
60
61
  // using them as the input for the next iteration until the last runtime.
61
- const { functions } = yield runtimes.reduce((aggregate, runtime) => __awaiter(void 0, void 0, void 0, function* () {
62
+ const { functions } = yield RUNTIMES.reduce((aggregate, runtime) => __awaiter(void 0, void 0, void 0, function* () {
62
63
  const { functions: aggregateFunctions, remainingPaths: aggregatePaths } = yield aggregate;
63
64
  const { functions: runtimeFunctions, remainingPaths: runtimePaths } = yield findFunctionsInRuntime({
64
65
  dedupe,
@@ -79,4 +80,19 @@ const getFunctionsFromPaths = (paths, { config, dedupe = false, featureFlags = f
79
80
  return new Map(functionsWithConfig);
80
81
  });
81
82
  exports.getFunctionsFromPaths = getFunctionsFromPaths;
83
+ /**
84
+ * Gets a list of functions found in a list of paths.
85
+ */
86
+ const getFunctionFromPath = (path, { config, featureFlags = feature_flags_1.defaultFlags } = {}) => __awaiter(void 0, void 0, void 0, function* () {
87
+ const fsCache = makeFsCache();
88
+ for (const runtime of RUNTIMES) {
89
+ // eslint-disable-next-line no-await-in-loop
90
+ const func = yield runtime.findFunctionInPath({ path, fsCache, featureFlags });
91
+ if (func) {
92
+ return Object.assign(Object.assign({}, func), { runtime, config: (0, config_1.getConfigForFunction)({ config, func: Object.assign(Object.assign({}, func), { runtime }) }) });
93
+ }
94
+ }
95
+ return undefined;
96
+ });
97
+ exports.getFunctionFromPath = getFunctionFromPath;
82
98
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,4 @@
1
- import { SourceFile } from '../../function';
2
- declare const findFunctionsInPaths: ({ paths }: {
3
- paths: string[];
4
- }) => Promise<SourceFile[]>;
5
- declare const getFunctionAtPath: (srcPath: string) => Promise<SourceFile | undefined>;
6
- export { findFunctionsInPaths, getFunctionAtPath };
1
+ import { FindFunctionsInPathsFunction, FindFunctionInPathFunction } from '../runtime';
2
+ declare const findFunctionsInPaths: FindFunctionsInPathsFunction;
3
+ declare const findFunctionInPath: FindFunctionInPathFunction;
4
+ export { findFunctionsInPaths, findFunctionInPath };
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getFunctionAtPath = exports.findFunctionsInPaths = void 0;
15
+ exports.findFunctionInPath = exports.findFunctionsInPaths = void 0;
16
16
  const fs_1 = require("fs");
17
17
  const path_1 = require("path");
18
18
  const util_1 = require("util");
@@ -30,9 +30,9 @@ const sortByExtension = (fA, fB) => {
30
30
  const indexB = allowedExtensions.indexOf(fB.extension);
31
31
  return indexB - indexA;
32
32
  };
33
- const findFunctionsInPaths = function ({ paths }) {
33
+ const findFunctionsInPaths = function ({ paths, fsCache, featureFlags }) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- const functions = yield Promise.all(paths.map(getFunctionAtPath));
35
+ const functions = yield Promise.all(paths.map((path) => findFunctionInPath({ path, fsCache, featureFlags })));
36
36
  // It's fine to mutate the array since its scope is local to this function.
37
37
  const sortedFunctions = functions.filter(non_nullable_1.nonNullable).sort((fA, fB) => {
38
38
  // We first sort the functions array to put directories first. This is so
@@ -52,7 +52,7 @@ const findFunctionsInPaths = function ({ paths }) {
52
52
  });
53
53
  };
54
54
  exports.findFunctionsInPaths = findFunctionsInPaths;
55
- const getFunctionAtPath = function (srcPath) {
55
+ const findFunctionInPath = function ({ path: srcPath }) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
57
  const filename = (0, path_1.basename)(srcPath);
58
58
  if (filename === 'node_modules') {
@@ -69,7 +69,7 @@ const getFunctionAtPath = function (srcPath) {
69
69
  return { extension, filename, mainFile, name, srcDir, srcPath, stat };
70
70
  });
71
71
  };
72
- exports.getFunctionAtPath = getFunctionAtPath;
72
+ exports.findFunctionInPath = findFunctionInPath;
73
73
  // Each `srcPath` can also be a directory with an `index` file or a file using
74
74
  // the same filename as its directory.
75
75
  const getMainFile = function (srcPath, filename, stat) {
@@ -89,10 +89,7 @@ const zipFunction = function ({ archiveFormat, basePath, config = {}, destFolder
89
89
  srcPath,
90
90
  stat,
91
91
  });
92
- let inSourceConfig = {};
93
- if (featureFlags.parseISC) {
94
- inSourceConfig = yield (0, in_source_config_1.findISCDeclarationsInPath)(mainFile);
95
- }
92
+ const inSourceConfig = yield (0, in_source_config_1.findISCDeclarationsInPath)(mainFile);
96
93
  (0, plugin_modules_path_1.createAliases)(srcFiles, pluginsModulesPath, aliases, finalBasePath);
97
94
  const zipPath = yield (0, zip_1.zipNodeJs)({
98
95
  aliases,
@@ -141,6 +138,7 @@ const zipWithFunctionWithFallback = (_a) => __awaiter(void 0, void 0, void 0, fu
141
138
  });
142
139
  const runtime = {
143
140
  findFunctionsInPaths: finder_1.findFunctionsInPaths,
141
+ findFunctionInPath: finder_1.findFunctionInPath,
144
142
  getSrcFiles: getSrcFilesWithBundler,
145
143
  name: 'js',
146
144
  zipFunction: zipWithFunctionWithFallback,
@@ -23,11 +23,16 @@ const getMainExport = (nodes) => {
23
23
  exports.getMainExport = getMainExport;
24
24
  // Finds the main handler export in a CJS AST.
25
25
  const getMainExportFromCJS = (node) => {
26
- const handlerPath = ['module', 'exports', 'handler'];
27
- if (!(0, helpers_1.isModuleExports)(node, handlerPath) || node.expression.right.type !== 'CallExpression') {
28
- return [];
29
- }
30
- return getExportsFromCallExpression(node.expression.right);
26
+ const handlerPaths = [
27
+ ['module', 'exports', 'handler'],
28
+ ['exports', 'handler'],
29
+ ];
30
+ return handlerPaths.flatMap((handlerPath) => {
31
+ if (!(0, helpers_1.isModuleExports)(node, handlerPath) || node.expression.right.type !== 'CallExpression') {
32
+ return [];
33
+ }
34
+ return getExportsFromCallExpression(node.expression.right);
35
+ });
31
36
  };
32
37
  // Finds the main handler export in an ESM AST.
33
38
  // eslint-disable-next-line complexity
@@ -37,7 +37,7 @@ const p_map_1 = __importDefault(require("p-map"));
37
37
  const unixify_1 = __importDefault(require("unixify"));
38
38
  const archive_1 = require("../../../archive");
39
39
  const fs_2 = require("../../../utils/fs");
40
- const pStat = (0, util_1.promisify)(fs_1.default.stat);
40
+ const pLstat = (0, util_1.promisify)(fs_1.default.lstat);
41
41
  const pWriteFile = (0, util_1.promisify)(fs_1.default.writeFile);
42
42
  // Taken from https://www.npmjs.com/package/cpy.
43
43
  const COPY_FILE_CONCURRENCY = os_1.default.cpus().length === 0 ? 2 : os_1.default.cpus().length * 2;
@@ -127,7 +127,7 @@ const addEntryFileToZip = function (archive, { contents, filename }) {
127
127
  };
128
128
  const addStat = function (srcFile) {
129
129
  return __awaiter(this, void 0, void 0, function* () {
130
- const stat = yield pStat(srcFile);
130
+ const stat = yield pLstat(srcFile);
131
131
  return { srcFile, stat };
132
132
  });
133
133
  };
@@ -11,6 +11,11 @@ declare type FindFunctionsInPathsFunction = (args: {
11
11
  fsCache: FsCache;
12
12
  paths: string[];
13
13
  }) => Promise<SourceFile[]>;
14
+ declare type FindFunctionInPathFunction = (args: {
15
+ featureFlags: FeatureFlags;
16
+ fsCache: FsCache;
17
+ path: string;
18
+ }) => Promise<SourceFile | undefined>;
14
19
  declare type GetSrcFilesFunction = (args: {
15
20
  basePath?: string;
16
21
  config: FunctionConfig;
@@ -38,8 +43,9 @@ declare type ZipFunction = (args: {
38
43
  } & FunctionSource) => Promise<ZipFunctionResult>;
39
44
  interface Runtime {
40
45
  findFunctionsInPaths: FindFunctionsInPathsFunction;
46
+ findFunctionInPath: FindFunctionInPathFunction;
41
47
  getSrcFiles?: GetSrcFilesFunction;
42
48
  name: RuntimeName;
43
49
  zipFunction: ZipFunction;
44
50
  }
45
- export { FindFunctionsInPathsFunction, GetSrcFilesFunction, Runtime, RuntimeName, ZipFunction, ZipFunctionResult };
51
+ export { FindFunctionInPathFunction, FindFunctionsInPathsFunction, GetSrcFilesFunction, Runtime, RuntimeName, ZipFunction, ZipFunctionResult, };
@@ -41,22 +41,25 @@ const detectRustFunction = ({ fsCache, path }) => __awaiter(void 0, void 0, void
41
41
  });
42
42
  const findFunctionsInPaths = function ({ featureFlags, fsCache, paths, }) {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
- const functions = yield Promise.all(paths.map((path) => __awaiter(this, void 0, void 0, function* () {
45
- const runtime = yield (0, detect_runtime_1.detectBinaryRuntime)({ fsCache, path });
46
- if (runtime === 'rs') {
47
- return processBinary({ fsCache, path });
48
- }
49
- if (featureFlags.buildRustSource !== true) {
50
- return;
51
- }
52
- const rustSourceFile = yield detectRustFunction({ fsCache, path });
53
- if (rustSourceFile) {
54
- return processSource({ fsCache, mainFile: rustSourceFile, path });
55
- }
56
- })));
44
+ const functions = yield Promise.all(paths.map((path) => findFunctionInPath({ path, featureFlags, fsCache })));
57
45
  return functions.filter(non_nullable_1.nonNullable);
58
46
  });
59
47
  };
48
+ const findFunctionInPath = function ({ path, featureFlags, fsCache }) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const runtime = yield (0, detect_runtime_1.detectBinaryRuntime)({ fsCache, path });
51
+ if (runtime === 'rs') {
52
+ return processBinary({ fsCache, path });
53
+ }
54
+ if (featureFlags.buildRustSource !== true) {
55
+ return;
56
+ }
57
+ const rustSourceFile = yield detectRustFunction({ fsCache, path });
58
+ if (rustSourceFile) {
59
+ return processSource({ fsCache, mainFile: rustSourceFile, path });
60
+ }
61
+ });
62
+ };
60
63
  const processBinary = ({ fsCache, path }) => __awaiter(void 0, void 0, void 0, function* () {
61
64
  const stat = (yield (0, fs_1.cachedLstat)(fsCache, path));
62
65
  const filename = (0, path_1.basename)(path);
@@ -116,6 +119,6 @@ const zipFunction = function ({ config, destFolder, filename, mainFile, runtime,
116
119
  return { config, path: destPath };
117
120
  });
118
121
  };
119
- const runtime = { findFunctionsInPaths, name: 'rs', zipFunction };
122
+ const runtime = { findFunctionsInPaths, findFunctionInPath, name: 'rs', zipFunction };
120
123
  exports.default = runtime;
121
124
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "bin": {
@@ -93,14 +93,13 @@
93
93
  },
94
94
  "devDependencies": {
95
95
  "@babel/types": "^7.15.6",
96
- "@netlify/eslint-config-node": "^3.3.10",
96
+ "@netlify/eslint-config-node": "^4.0.2",
97
97
  "@types/archiver": "^5.1.1",
98
98
  "@types/end-of-stream": "^1.4.1",
99
99
  "@types/resolve": "^1.20.1",
100
100
  "@types/semver": "^7.3.8",
101
101
  "@types/unixify": "^1.0.0",
102
102
  "@types/yargs": "^17.0.4",
103
- "adm-zip": "0.5.5",
104
103
  "ava": "^3.0.0",
105
104
  "cpy": "^8.0.0",
106
105
  "deepmerge": "^4.2.2",