@netlify/zip-it-and-ship-it 5.9.1 → 5.10.1
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.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/bundler_target.d.ts +2 -2
- package/dist/runtimes/node/bundlers/esbuild/index.js +2 -1
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/src_files.js +7 -3
- package/dist/runtimes/node/bundlers/index.d.ts +5 -1
- package/dist/runtimes/node/bundlers/nft/es_modules.d.ts +2 -1
- package/dist/runtimes/node/bundlers/nft/es_modules.js +4 -4
- package/dist/runtimes/node/bundlers/nft/index.d.ts +1 -2
- package/dist/runtimes/node/bundlers/nft/index.js +17 -11
- package/dist/runtimes/node/bundlers/nft/transpile.d.ts +1 -1
- package/dist/runtimes/node/bundlers/nft/transpile.js +23 -12
- package/dist/runtimes/node/bundlers/zisi/index.js +2 -1
- package/dist/runtimes/node/bundlers/zisi/published.js +2 -7
- package/dist/runtimes/node/bundlers/zisi/src_files.js +7 -50
- package/dist/runtimes/node/bundlers/zisi/tree_files.d.ts +1 -1
- package/dist/runtimes/node/bundlers/zisi/tree_files.js +2 -7
- package/dist/runtimes/node/in_source_config/index.js +4 -2
- package/dist/runtimes/node/in_source_config/properties/schedule.d.ts +2 -1
- package/dist/runtimes/node/in_source_config/properties/schedule.js +8 -2
- package/dist/runtimes/node/index.js +4 -2
- package/dist/runtimes/node/parser/bindings.d.ts +5 -0
- package/dist/runtimes/node/parser/bindings.js +50 -0
- package/dist/runtimes/node/parser/exports.d.ts +3 -2
- package/dist/runtimes/node/parser/exports.js +36 -12
- package/dist/runtimes/node/utils/included_files.d.ts +3 -3
- package/dist/runtimes/node/utils/included_files.js +13 -18
- package/dist/runtimes/node/utils/node_version.d.ts +2 -2
- package/dist/runtimes/node/utils/package_json.js +3 -6
- package/dist/runtimes/runtime.d.ts +1 -0
- package/dist/utils/fs.d.ts +2 -0
- package/dist/utils/matching.d.ts +9 -0
- package/dist/utils/matching.js +32 -0
- package/package.json +9 -8
package/dist/config.js
CHANGED
|
@@ -5,14 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getConfigForFunction = void 0;
|
|
7
7
|
const merge_options_1 = __importDefault(require("merge-options"));
|
|
8
|
-
const
|
|
8
|
+
const matching_js_1 = require("./utils/matching.js");
|
|
9
9
|
const getConfigForFunction = ({ config, func, }) => {
|
|
10
10
|
if (!config) {
|
|
11
11
|
return {};
|
|
12
12
|
}
|
|
13
13
|
// It's safe to mutate the array because it's local to this function.
|
|
14
14
|
const matches = Object.keys(config)
|
|
15
|
-
.filter((expression) => (0,
|
|
15
|
+
.filter((expression) => (0, matching_js_1.minimatch)(func.name, expression))
|
|
16
16
|
.map((expression) => {
|
|
17
17
|
const wildcardCount = [...expression].filter((char) => char === '*').length;
|
|
18
18
|
// The weight increases with the number of hardcoded (i.e. non-wildcard)
|
|
@@ -8,8 +8,8 @@ declare const versionMap: {
|
|
|
8
8
|
};
|
|
9
9
|
declare type VersionKeys = keyof typeof versionMap;
|
|
10
10
|
declare type VersionValues = typeof versionMap[VersionKeys];
|
|
11
|
-
declare const getBundlerTarget: (suppliedVersion?: string
|
|
12
|
-
declare const getModuleFormat: (srcDir: string, featureFlags: FeatureFlags, configVersion?: string
|
|
11
|
+
declare const getBundlerTarget: (suppliedVersion?: string) => VersionValues;
|
|
12
|
+
declare const getModuleFormat: (srcDir: string, featureFlags: FeatureFlags, configVersion?: string) => Promise<{
|
|
13
13
|
includedFiles: string[];
|
|
14
14
|
moduleFormat: ModuleFormat;
|
|
15
15
|
}>;
|
|
@@ -42,7 +42,7 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
|
|
|
42
42
|
srcFile: mainFile,
|
|
43
43
|
});
|
|
44
44
|
const bundlerWarnings = warnings.length === 0 ? undefined : warnings;
|
|
45
|
-
const srcFiles = await (0, src_files_js_1.getSrcFiles)({
|
|
45
|
+
const { srcFiles, includedFiles } = await (0, src_files_js_1.getSrcFiles)({
|
|
46
46
|
basePath,
|
|
47
47
|
config: {
|
|
48
48
|
...config,
|
|
@@ -77,6 +77,7 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
|
|
|
77
77
|
cleanupFunction: cleanTempFiles,
|
|
78
78
|
basePath: functionBasePath,
|
|
79
79
|
bundlerWarnings,
|
|
80
|
+
includedFiles,
|
|
80
81
|
inputs,
|
|
81
82
|
mainFile: normalizedMainFile,
|
|
82
83
|
moduleFormat,
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getDynamicImportsPlugin = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const find_up_1 = __importDefault(require("find-up"));
|
|
9
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
9
10
|
const read_package_json_fast_1 = __importDefault(require("read-package-json-fast"));
|
|
10
|
-
const unixify_1 = __importDefault(require("unixify"));
|
|
11
11
|
const index_js_1 = require("../../parser/index.js");
|
|
12
12
|
// This plugin intercepts module imports using dynamic expressions and does a
|
|
13
13
|
// couple of things with them. First of all, it figures out whether the call
|
|
@@ -81,7 +81,7 @@ const getShimContents = ({ expressionType, resolveDir, srcDir, }) => {
|
|
|
81
81
|
// relative to the main bundle file, since esbuild will flatten everything
|
|
82
82
|
// into a single file.
|
|
83
83
|
const relativeResolveDir = (0, path_1.relative)(srcDir, resolveDir);
|
|
84
|
-
const requireArg = relativeResolveDir ? `\`./${(0,
|
|
84
|
+
const requireArg = relativeResolveDir ? `\`./${(0, normalize_path_1.default)(relativeResolveDir)}/$\{args}\`` : 'args';
|
|
85
85
|
if (expressionType === 'require') {
|
|
86
86
|
return `module.exports = args => require(${requireArg})`;
|
|
87
87
|
}
|
|
@@ -7,14 +7,18 @@ const traversal_cache_js_1 = require("../../utils/traversal_cache.js");
|
|
|
7
7
|
const traverse_js_1 = require("../zisi/traverse.js");
|
|
8
8
|
const getSrcFiles = async ({ config, mainFile, pluginsModulesPath, srcDir }) => {
|
|
9
9
|
const { externalNodeModules = [], includedFiles = [], includedFilesBasePath } = config;
|
|
10
|
-
const {
|
|
10
|
+
const { excludePatterns, paths: includedFilePaths } = await (0, included_files_js_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath);
|
|
11
11
|
const dependencyPaths = await getSrcFilesForDependencies({
|
|
12
12
|
dependencies: externalNodeModules,
|
|
13
13
|
basedir: srcDir,
|
|
14
14
|
pluginsModulesPath,
|
|
15
15
|
});
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const srcFiles = (0, included_files_js_1.filterExcludedPaths)(dependencyPaths, excludePatterns);
|
|
17
|
+
const includedPaths = (0, included_files_js_1.filterExcludedPaths)(includedFilePaths, excludePatterns);
|
|
18
|
+
return {
|
|
19
|
+
srcFiles: [...srcFiles, ...includedPaths, mainFile],
|
|
20
|
+
includedFiles: includedPaths,
|
|
21
|
+
};
|
|
18
22
|
};
|
|
19
23
|
exports.getSrcFiles = getSrcFiles;
|
|
20
24
|
const getSrcFilesForDependencies = async function ({ dependencies: dependencyNames, basedir, state = (0, traversal_cache_js_1.getNewCache)(), pluginsModulesPath, }) {
|
|
@@ -19,6 +19,7 @@ export declare type BundleFunction = (args: {
|
|
|
19
19
|
basePath: string;
|
|
20
20
|
bundlerWarnings?: BundlerWarning[];
|
|
21
21
|
cleanupFunction?: CleanupFunction;
|
|
22
|
+
includedFiles: string[];
|
|
22
23
|
inputs: string[];
|
|
23
24
|
mainFile: string;
|
|
24
25
|
moduleFormat: ModuleFormat;
|
|
@@ -32,7 +33,10 @@ export declare type GetSrcFilesFunction = (args: {
|
|
|
32
33
|
featureFlags: FeatureFlags;
|
|
33
34
|
pluginsModulesPath?: string;
|
|
34
35
|
repositoryRoot?: string;
|
|
35
|
-
} & FunctionSource) => Promise<
|
|
36
|
+
} & FunctionSource) => Promise<{
|
|
37
|
+
srcFiles: string[];
|
|
38
|
+
includedFiles: string[];
|
|
39
|
+
}>;
|
|
36
40
|
interface NodeBundler {
|
|
37
41
|
bundle: BundleFunction;
|
|
38
42
|
getSrcFiles: GetSrcFilesFunction;
|
|
@@ -3,7 +3,7 @@ import type { FunctionConfig } from '../../../../config.js';
|
|
|
3
3
|
import { FeatureFlags } from '../../../../feature_flags.js';
|
|
4
4
|
import { FsCache } from '../../../../utils/fs.js';
|
|
5
5
|
import { ModuleFormat } from '../../utils/module_format.js';
|
|
6
|
-
export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, }: {
|
|
6
|
+
export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, name, }: {
|
|
7
7
|
basePath: string | undefined;
|
|
8
8
|
config: FunctionConfig;
|
|
9
9
|
esmPaths: Set<string>;
|
|
@@ -11,6 +11,7 @@ export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fs
|
|
|
11
11
|
fsCache: FsCache;
|
|
12
12
|
mainFile: string;
|
|
13
13
|
reasons: NodeFileTraceReasons;
|
|
14
|
+
name: string;
|
|
14
15
|
}) => Promise<{
|
|
15
16
|
rewrites?: Map<string, string> | undefined;
|
|
16
17
|
moduleFormat: ModuleFormat;
|
|
@@ -28,7 +28,7 @@ const patchESMPackage = async (path, fsCache) => {
|
|
|
28
28
|
};
|
|
29
29
|
return JSON.stringify(patchedPackageJson);
|
|
30
30
|
};
|
|
31
|
-
const processESM = async ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, }) => {
|
|
31
|
+
const processESM = async ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, name, }) => {
|
|
32
32
|
const entrypointIsESM = isEntrypointESM({ basePath, esmPaths, mainFile });
|
|
33
33
|
if (!entrypointIsESM) {
|
|
34
34
|
return {
|
|
@@ -42,7 +42,7 @@ const processESM = async ({ basePath, config, esmPaths, featureFlags, fsCache, m
|
|
|
42
42
|
moduleFormat: 'esm',
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
const rewrites = await transpileESM({ basePath, config, esmPaths, fsCache, reasons });
|
|
45
|
+
const rewrites = await transpileESM({ basePath, config, esmPaths, fsCache, reasons, name });
|
|
46
46
|
return {
|
|
47
47
|
moduleFormat: 'cjs',
|
|
48
48
|
rewrites,
|
|
@@ -75,7 +75,7 @@ const shouldTranspile = (path, cache, esmPaths, reasons) => {
|
|
|
75
75
|
cache.set(path, shouldTranspilePath);
|
|
76
76
|
return shouldTranspilePath;
|
|
77
77
|
};
|
|
78
|
-
const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, }) => {
|
|
78
|
+
const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, name, }) => {
|
|
79
79
|
const cache = new Map();
|
|
80
80
|
const pathsToTranspile = [...esmPaths].filter((path) => shouldTranspile(path, cache, esmPaths, reasons));
|
|
81
81
|
const pathsToTranspileSet = new Set(pathsToTranspile);
|
|
@@ -91,7 +91,7 @@ const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, }) =
|
|
|
91
91
|
const rewrites = await getPatchedESMPackages(packageJsonPaths, fsCache);
|
|
92
92
|
await Promise.all(pathsToTranspile.map(async (path) => {
|
|
93
93
|
const absolutePath = resolvePath(path, basePath);
|
|
94
|
-
const transpiled = await (0, transpile_js_1.transpile)(absolutePath, config);
|
|
94
|
+
const transpiled = await (0, transpile_js_1.transpile)(absolutePath, config, name);
|
|
95
95
|
rewrites.set(absolutePath, transpiled);
|
|
96
96
|
}));
|
|
97
97
|
return rewrites;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { GetSrcFilesFunction } from '
|
|
2
|
-
import type { BundleFunction } from '../index.js';
|
|
1
|
+
import type { GetSrcFilesFunction, BundleFunction } from '../index.js';
|
|
3
2
|
declare const bundler: {
|
|
4
3
|
bundle: BundleFunction;
|
|
5
4
|
getSrcFiles: GetSrcFilesFunction;
|
|
@@ -6,31 +6,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const nft_1 = require("@vercel/nft");
|
|
8
8
|
const resolve_dependency_js_1 = __importDefault(require("@vercel/nft/out/resolve-dependency.js"));
|
|
9
|
-
const minimatch_1 = __importDefault(require("minimatch"));
|
|
10
|
-
const unixify_1 = __importDefault(require("unixify"));
|
|
11
9
|
const fs_js_1 = require("../../../../utils/fs.js");
|
|
10
|
+
const matching_js_1 = require("../../../../utils/matching.js");
|
|
12
11
|
const base_path_js_1 = require("../../utils/base_path.js");
|
|
13
12
|
const included_files_js_1 = require("../../utils/included_files.js");
|
|
14
13
|
const es_modules_js_1 = require("./es_modules.js");
|
|
15
14
|
// Paths that will be excluded from the tracing process.
|
|
16
15
|
const ignore = ['node_modules/aws-sdk/**'];
|
|
17
16
|
const appearsToBeModuleName = (name) => !name.startsWith('.');
|
|
18
|
-
const bundle = async ({ basePath, config, featureFlags, mainFile, pluginsModulesPath, repositoryRoot = basePath, }) => {
|
|
17
|
+
const bundle = async ({ basePath, config, featureFlags, mainFile, name, pluginsModulesPath, repositoryRoot = basePath, }) => {
|
|
19
18
|
const { includedFiles = [], includedFilesBasePath } = config;
|
|
20
|
-
const {
|
|
19
|
+
const { excludePatterns, paths: includedFilePaths } = await (0, included_files_js_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath || basePath);
|
|
21
20
|
const { moduleFormat, paths: dependencyPaths, rewrites, } = await traceFilesAndTranspile({
|
|
22
21
|
basePath: repositoryRoot,
|
|
23
22
|
config,
|
|
24
23
|
featureFlags,
|
|
25
24
|
mainFile,
|
|
26
25
|
pluginsModulesPath,
|
|
26
|
+
name,
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const includedPaths = (0, included_files_js_1.filterExcludedPaths)(includedFilePaths, excludePatterns);
|
|
29
|
+
const filteredIncludedPaths = [...(0, included_files_js_1.filterExcludedPaths)(dependencyPaths, excludePatterns), ...includedPaths];
|
|
29
30
|
const dirnames = filteredIncludedPaths.map((filePath) => (0, path_1.normalize)((0, path_1.dirname)(filePath))).sort();
|
|
30
31
|
// Sorting the array to make the checksum deterministic.
|
|
31
32
|
const srcFiles = [...filteredIncludedPaths].sort();
|
|
32
33
|
return {
|
|
33
34
|
basePath: (0, base_path_js_1.getBasePath)(dirnames),
|
|
35
|
+
includedFiles: includedPaths,
|
|
34
36
|
inputs: dependencyPaths,
|
|
35
37
|
mainFile,
|
|
36
38
|
moduleFormat,
|
|
@@ -39,11 +41,10 @@ const bundle = async ({ basePath, config, featureFlags, mainFile, pluginsModules
|
|
|
39
41
|
};
|
|
40
42
|
};
|
|
41
43
|
const ignoreFunction = (path) => {
|
|
42
|
-
const
|
|
43
|
-
const shouldIgnore = ignore.some((expression) => (0, minimatch_1.default)(normalizedPath, expression));
|
|
44
|
+
const shouldIgnore = ignore.some((expression) => (0, matching_js_1.minimatch)(path, expression));
|
|
44
45
|
return shouldIgnore;
|
|
45
46
|
};
|
|
46
|
-
const traceFilesAndTranspile = async function ({ basePath, config, featureFlags, mainFile, pluginsModulesPath, }) {
|
|
47
|
+
const traceFilesAndTranspile = async function ({ basePath, config, featureFlags, mainFile, pluginsModulesPath, name, }) {
|
|
47
48
|
const fsCache = {};
|
|
48
49
|
const { fileList: dependencyPaths, esmFileList, reasons, } = await (0, nft_1.nodeFileTrace)([mainFile], {
|
|
49
50
|
base: basePath,
|
|
@@ -85,6 +86,7 @@ const traceFilesAndTranspile = async function ({ basePath, config, featureFlags,
|
|
|
85
86
|
fsCache,
|
|
86
87
|
mainFile,
|
|
87
88
|
reasons,
|
|
89
|
+
name,
|
|
88
90
|
});
|
|
89
91
|
return {
|
|
90
92
|
moduleFormat,
|
|
@@ -94,11 +96,15 @@ const traceFilesAndTranspile = async function ({ basePath, config, featureFlags,
|
|
|
94
96
|
};
|
|
95
97
|
const getSrcFiles = async function ({ basePath, config, mainFile }) {
|
|
96
98
|
const { includedFiles = [], includedFilesBasePath } = config;
|
|
97
|
-
const {
|
|
99
|
+
const { excludePatterns, paths: includedFilePaths } = await (0, included_files_js_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath);
|
|
98
100
|
const { fileList: dependencyPaths } = await (0, nft_1.nodeFileTrace)([mainFile], { base: basePath, ignore: ignoreFunction });
|
|
99
101
|
const normalizedDependencyPaths = [...dependencyPaths].map((path) => basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path));
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
+
const srcFiles = (0, included_files_js_1.filterExcludedPaths)(normalizedDependencyPaths, excludePatterns);
|
|
103
|
+
const includedPaths = (0, included_files_js_1.filterExcludedPaths)(includedFilePaths, excludePatterns);
|
|
104
|
+
return {
|
|
105
|
+
srcFiles: [...srcFiles, ...includedPaths],
|
|
106
|
+
includedFiles: includedPaths,
|
|
107
|
+
};
|
|
102
108
|
};
|
|
103
109
|
const bundler = { bundle, getSrcFiles };
|
|
104
110
|
exports.default = bundler;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { FunctionConfig } from '../../../../config.js';
|
|
2
|
-
export declare const transpile: (path: string, config: FunctionConfig) => Promise<string>;
|
|
2
|
+
export declare const transpile: (path: string, config: FunctionConfig, functionName: string) => Promise<string>;
|
|
@@ -3,21 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transpile = void 0;
|
|
4
4
|
const esbuild_1 = require("@netlify/esbuild");
|
|
5
5
|
const bundler_target_js_1 = require("../esbuild/bundler_target.js");
|
|
6
|
-
const transpile = async (path, config) => {
|
|
6
|
+
const transpile = async (path, config, functionName) => {
|
|
7
7
|
// The version of ECMAScript to use as the build target. This will determine
|
|
8
8
|
// whether certain features are transpiled down or left untransformed.
|
|
9
9
|
const nodeTarget = (0, bundler_target_js_1.getBundlerTarget)(config.nodeVersion);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
try {
|
|
11
|
+
const transpiled = await (0, esbuild_1.build)({
|
|
12
|
+
bundle: false,
|
|
13
|
+
entryPoints: [path],
|
|
14
|
+
format: 'cjs',
|
|
15
|
+
logLevel: 'error',
|
|
16
|
+
platform: 'node',
|
|
17
|
+
sourcemap: Boolean(config.nodeSourcemap),
|
|
18
|
+
target: [nodeTarget],
|
|
19
|
+
write: false,
|
|
20
|
+
});
|
|
21
|
+
return transpiled.outputFiles[0].text;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const bundler = 'nft';
|
|
25
|
+
const runtime = 'js';
|
|
26
|
+
error.customErrorInfo = {
|
|
27
|
+
type: 'functionsBundling',
|
|
28
|
+
location: { bundler, functionName, runtime },
|
|
29
|
+
};
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
21
32
|
};
|
|
22
33
|
exports.transpile = transpile;
|
|
23
34
|
//# sourceMappingURL=transpile.js.map
|
|
@@ -4,7 +4,7 @@ const path_1 = require("path");
|
|
|
4
4
|
const base_path_js_1 = require("../../utils/base_path.js");
|
|
5
5
|
const src_files_js_1 = require("./src_files.js");
|
|
6
6
|
const bundle = async ({ basePath, config, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, runtime, srcDir, srcPath, stat, }) => {
|
|
7
|
-
const srcFiles = await (0, src_files_js_1.getSrcFiles)({
|
|
7
|
+
const { srcFiles, includedFiles } = await (0, src_files_js_1.getSrcFiles)({
|
|
8
8
|
basePath,
|
|
9
9
|
config: {
|
|
10
10
|
...config,
|
|
@@ -24,6 +24,7 @@ const bundle = async ({ basePath, config, extension, featureFlags, filename, mai
|
|
|
24
24
|
const dirnames = srcFiles.map((filePath) => (0, path_1.normalize)((0, path_1.dirname)(filePath)));
|
|
25
25
|
return {
|
|
26
26
|
basePath: (0, base_path_js_1.getBasePath)(dirnames),
|
|
27
|
+
includedFiles,
|
|
27
28
|
inputs: srcFiles,
|
|
28
29
|
mainFile,
|
|
29
30
|
moduleFormat: 'cjs',
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getPublishedFiles = void 0;
|
|
7
|
-
const
|
|
8
|
-
const glob_1 = __importDefault(require("glob"));
|
|
9
|
-
const pGlob = (0, util_1.promisify)(glob_1.default);
|
|
4
|
+
const matching_1 = require("../../../../utils/matching");
|
|
10
5
|
// We use all the files published by the Node.js except some that are not needed
|
|
11
6
|
const getPublishedFiles = async function (modulePath) {
|
|
12
7
|
const ignore = getIgnoredFiles(modulePath);
|
|
13
|
-
const publishedFiles = await
|
|
8
|
+
const publishedFiles = await (0, matching_1.glob)(`${modulePath}/**`, {
|
|
14
9
|
ignore,
|
|
15
10
|
nodir: true,
|
|
16
11
|
absolute: true,
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
@@ -29,10 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
6
|
exports.getSrcFiles = void 0;
|
|
30
7
|
/* eslint-disable max-lines */
|
|
31
8
|
const path_1 = require("path");
|
|
32
|
-
const process = __importStar(require("process"));
|
|
33
9
|
const junk_1 = require("junk");
|
|
34
10
|
const precinct_1 = __importDefault(require("precinct"));
|
|
35
|
-
const semver_1 = __importDefault(require("semver"));
|
|
36
11
|
const non_nullable_js_1 = require("../../../../utils/non_nullable.js");
|
|
37
12
|
const included_files_js_1 = require("../../utils/included_files.js");
|
|
38
13
|
const package_json_js_1 = require("../../utils/package_json.js");
|
|
@@ -47,7 +22,7 @@ const tree_shake_js_1 = require("./tree_shake.js");
|
|
|
47
22
|
// has a size limit for the zipped file. It also makes cold starts faster.
|
|
48
23
|
const getSrcFiles = async function ({ config, featureFlags, mainFile, name, pluginsModulesPath, srcDir, srcPath, stat, }) {
|
|
49
24
|
const { includedFiles = [], includedFilesBasePath } = config;
|
|
50
|
-
const {
|
|
25
|
+
const { excludePatterns, paths: includedFilePaths } = await (0, included_files_js_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath);
|
|
51
26
|
const [treeFiles, depFiles] = await Promise.all([
|
|
52
27
|
(0, tree_files_js_1.getTreeFiles)(srcPath, stat),
|
|
53
28
|
getDependencies({ featureFlags, functionName: name, mainFile, pluginsModulesPath, srcDir }),
|
|
@@ -57,8 +32,9 @@ const getSrcFiles = async function ({ config, featureFlags, mainFile, name, plug
|
|
|
57
32
|
// We sort so that the archive's checksum is deterministic.
|
|
58
33
|
// Mutating is fine since `Array.filter()` returns a shallow copy
|
|
59
34
|
const filteredFiles = uniqueFiles.filter(isNotJunk).sort();
|
|
60
|
-
const
|
|
61
|
-
|
|
35
|
+
const srcFiles = (0, included_files_js_1.filterExcludedPaths)(filteredFiles, excludePatterns);
|
|
36
|
+
const includedPaths = (0, included_files_js_1.filterExcludedPaths)(includedFilePaths, excludePatterns);
|
|
37
|
+
return { srcFiles: [...srcFiles, ...includedPaths], includedFiles: includedPaths };
|
|
62
38
|
};
|
|
63
39
|
exports.getSrcFiles = getSrcFiles;
|
|
64
40
|
// Remove temporary files like *~, *.swp, etc.
|
|
@@ -84,34 +60,15 @@ const getDependencies = async function ({ featureFlags, functionName, mainFile,
|
|
|
84
60
|
throw error;
|
|
85
61
|
}
|
|
86
62
|
};
|
|
87
|
-
const paperwork = async (path) => {
|
|
88
|
-
if (semver_1.default.lt(process.version, '18.0.0')) {
|
|
89
|
-
return await precinct_1.default.paperwork(path, { includeCore: false });
|
|
90
|
-
}
|
|
91
|
-
// for Node v18, we're temporarily using our own mechanism to filter out core dependencies, until
|
|
92
|
-
// https://github.com/dependents/node-precinct/pull/108 landed
|
|
93
|
-
const modules = await precinct_1.default.paperwork(path, { includeCore: true });
|
|
94
|
-
return modules.filter((moduleName) => {
|
|
95
|
-
if (moduleName.startsWith('node:')) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
// only require("node:test") refers to the
|
|
99
|
-
// builtin, require("test") doesn't
|
|
100
|
-
if (moduleName === 'test') {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
-
const isNativeModule = moduleName in process.binding('natives');
|
|
105
|
-
return !isNativeModule;
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
63
|
const getFileDependencies = async function ({ featureFlags, functionName, path, packageJson, pluginsModulesPath, state, treeShakeNext = false, }) {
|
|
109
64
|
if (state.localFiles.has(path)) {
|
|
110
65
|
return [];
|
|
111
66
|
}
|
|
112
67
|
state.localFiles.add(path);
|
|
113
68
|
const basedir = (0, path_1.dirname)(path);
|
|
114
|
-
const dependencies = featureFlags.parseWithEsbuild
|
|
69
|
+
const dependencies = featureFlags.parseWithEsbuild
|
|
70
|
+
? await (0, list_imports_js_1.listImports)({ functionName, path })
|
|
71
|
+
: await precinct_1.default.paperwork(path, { includeCore: false });
|
|
115
72
|
const depsPaths = await Promise.all(dependencies.filter(non_nullable_js_1.nonNullable).map((dependency) => getImportDependencies({
|
|
116
73
|
dependency,
|
|
117
74
|
basedir,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Stats } from 'fs';
|
|
1
|
+
import type { Stats } from 'fs';
|
|
2
2
|
export declare const getTreeFiles: (srcPath: string, stat: Stats) => Promise<string[]>;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getTreeFiles = void 0;
|
|
7
|
-
const
|
|
8
|
-
const glob_1 = __importDefault(require("glob"));
|
|
9
|
-
const pGlob = (0, util_1.promisify)(glob_1.default);
|
|
4
|
+
const matching_1 = require("../../../../utils/matching");
|
|
10
5
|
// When using a directory, we include all its descendants except `node_modules`
|
|
11
6
|
const getTreeFiles = async function (srcPath, stat) {
|
|
12
7
|
if (!stat.isDirectory()) {
|
|
13
8
|
return [srcPath];
|
|
14
9
|
}
|
|
15
|
-
return await
|
|
10
|
+
return await (0, matching_1.glob)(`${srcPath}/**`, {
|
|
16
11
|
ignore: `${srcPath}/**/node_modules/**`,
|
|
17
12
|
nodir: true,
|
|
18
13
|
absolute: true,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findISCDeclarationsInPath = exports.IN_SOURCE_CONFIG_MODULE = void 0;
|
|
4
4
|
const non_nullable_js_1 = require("../../../utils/non_nullable.js");
|
|
5
|
+
const bindings_js_1 = require("../parser/bindings.js");
|
|
5
6
|
const exports_js_1 = require("../parser/exports.js");
|
|
6
7
|
const imports_js_1 = require("../parser/imports.js");
|
|
7
8
|
const index_js_1 = require("../parser/index.js");
|
|
@@ -16,7 +17,8 @@ const findISCDeclarationsInPath = async (sourcePath) => {
|
|
|
16
17
|
return {};
|
|
17
18
|
}
|
|
18
19
|
const imports = ast.body.flatMap((node) => (0, imports_js_1.getImports)(node, exports.IN_SOURCE_CONFIG_MODULE));
|
|
19
|
-
const
|
|
20
|
+
const getAllBindings = (0, bindings_js_1.createBindingsMethod)(ast.body);
|
|
21
|
+
const mainExports = (0, exports_js_1.getMainExport)(ast.body, getAllBindings);
|
|
20
22
|
const iscExports = mainExports
|
|
21
23
|
.map(({ args, local: exportName }) => {
|
|
22
24
|
const matchingImport = imports.find(({ local: importName }) => importName === exportName);
|
|
@@ -25,7 +27,7 @@ const findISCDeclarationsInPath = async (sourcePath) => {
|
|
|
25
27
|
}
|
|
26
28
|
switch (matchingImport.imported) {
|
|
27
29
|
case 'schedule':
|
|
28
|
-
return (0, schedule_js_1.parse)({ args });
|
|
30
|
+
return (0, schedule_js_1.parse)({ args }, getAllBindings);
|
|
29
31
|
default:
|
|
30
32
|
// no-op
|
|
31
33
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { BindingMethod } from '../../parser/bindings.js';
|
|
1
2
|
import type { ISCHandlerArg } from '../index.js';
|
|
2
3
|
export declare const parse: ({ args }: {
|
|
3
4
|
args: ISCHandlerArg[];
|
|
4
|
-
}) => {
|
|
5
|
+
}, getAllBindings: BindingMethod) => {
|
|
5
6
|
schedule: string | undefined;
|
|
6
7
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parse = void 0;
|
|
4
|
-
const parse = ({ args }) => {
|
|
5
|
-
|
|
4
|
+
const parse = ({ args }, getAllBindings) => {
|
|
5
|
+
let [expression] = args;
|
|
6
|
+
if (expression.type === 'Identifier') {
|
|
7
|
+
const binding = getAllBindings().get(expression.name);
|
|
8
|
+
if (binding) {
|
|
9
|
+
expression = binding;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
6
12
|
const schedule = expression.type === 'StringLiteral' ? expression.value : undefined;
|
|
7
13
|
return {
|
|
8
14
|
schedule,
|
|
@@ -21,7 +21,8 @@ const getSrcFilesWithBundler = async (parameters) => {
|
|
|
21
21
|
mainFile: parameters.mainFile,
|
|
22
22
|
}));
|
|
23
23
|
const bundler = (0, index_js_1.getBundler)(bundlerName);
|
|
24
|
-
|
|
24
|
+
const result = await bundler.getSrcFiles({ ...parameters, pluginsModulesPath });
|
|
25
|
+
return result.srcFiles;
|
|
25
26
|
};
|
|
26
27
|
const zipFunction = async function ({ archiveFormat, basePath, config = {}, destFolder, extension, featureFlags, filename, mainFile, name, repositoryRoot, runtime, srcDir, srcPath, stat, }) {
|
|
27
28
|
const pluginsModulesPath = await (0, plugin_modules_path_js_1.getPluginsModulesPath)(srcDir);
|
|
@@ -34,7 +35,7 @@ const zipFunction = async function ({ archiveFormat, basePath, config = {}, dest
|
|
|
34
35
|
await (0, cp_file_1.default)(srcPath, destPath);
|
|
35
36
|
return { config, path: destPath };
|
|
36
37
|
}
|
|
37
|
-
const { aliases = new Map(), cleanupFunction, basePath: finalBasePath, bundlerWarnings, inputs, mainFile: finalMainFile = mainFile, moduleFormat, nativeNodeModules, nodeModulesWithDynamicImports, rewrites, srcFiles, } = await bundler.bundle({
|
|
38
|
+
const { aliases = new Map(), cleanupFunction, basePath: finalBasePath, bundlerWarnings, includedFiles, inputs, mainFile: finalMainFile = mainFile, moduleFormat, nativeNodeModules, nodeModulesWithDynamicImports, rewrites, srcFiles, } = await bundler.bundle({
|
|
38
39
|
basePath,
|
|
39
40
|
config,
|
|
40
41
|
extension,
|
|
@@ -69,6 +70,7 @@ const zipFunction = async function ({ archiveFormat, basePath, config = {}, dest
|
|
|
69
70
|
bundlerWarnings,
|
|
70
71
|
config,
|
|
71
72
|
inputs,
|
|
73
|
+
includedFiles,
|
|
72
74
|
inSourceConfig,
|
|
73
75
|
nativeNodeModules,
|
|
74
76
|
nodeModulesWithDynamicImports,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBindingsMethod = void 0;
|
|
4
|
+
const getBindingFromVariableDeclaration = function (node, bindings) {
|
|
5
|
+
node.declarations.forEach((declaration) => {
|
|
6
|
+
if (declaration.id.type === 'Identifier' && declaration.init) {
|
|
7
|
+
bindings.set(declaration.id.name, declaration.init);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
// eslint-disable-next-line complexity
|
|
12
|
+
const getBindingsFromNode = function (node, bindings) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (node.type === 'VariableDeclaration') {
|
|
15
|
+
// A variable was created, so create it and store the potential value
|
|
16
|
+
getBindingFromVariableDeclaration(node, bindings);
|
|
17
|
+
}
|
|
18
|
+
else if (node.type === 'ExpressionStatement' &&
|
|
19
|
+
node.expression.type === 'AssignmentExpression' &&
|
|
20
|
+
node.expression.left.type === 'Identifier') {
|
|
21
|
+
// The variable was reassigned, so let's store the new value
|
|
22
|
+
bindings.set(node.expression.left.name, node.expression.right);
|
|
23
|
+
}
|
|
24
|
+
else if (node.type === 'ExportNamedDeclaration' && ((_a = node.declaration) === null || _a === void 0 ? void 0 : _a.type) === 'VariableDeclaration') {
|
|
25
|
+
// A `export const|let ...` creates a binding that can later be referenced again
|
|
26
|
+
getBindingFromVariableDeclaration(node.declaration, bindings);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Goes through all relevant nodes and creates a map from binding name to assigned value/expression
|
|
31
|
+
*/
|
|
32
|
+
const getAllBindings = function (nodes) {
|
|
33
|
+
const bindings = new Map();
|
|
34
|
+
nodes.forEach((node) => {
|
|
35
|
+
getBindingsFromNode(node, bindings);
|
|
36
|
+
});
|
|
37
|
+
return bindings;
|
|
38
|
+
};
|
|
39
|
+
const createBindingsMethod = function (nodes) {
|
|
40
|
+
// memoize the result for these nodes
|
|
41
|
+
let result;
|
|
42
|
+
return () => {
|
|
43
|
+
if (!result) {
|
|
44
|
+
result = getAllBindings(nodes);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.createBindingsMethod = createBindingsMethod;
|
|
50
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Statement } from '@babel/types';
|
|
1
|
+
import type { Statement } from '@babel/types';
|
|
2
2
|
import type { ISCExport } from '../in_source_config/index.js';
|
|
3
|
-
|
|
3
|
+
import type { BindingMethod } from './bindings.js';
|
|
4
|
+
export declare const getMainExport: (nodes: Statement[], getAllBindings: BindingMethod) => ISCExport[];
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMainExport = void 0;
|
|
4
4
|
const helpers_js_1 = require("./helpers.js");
|
|
5
5
|
// Finds the main handler export in an AST.
|
|
6
|
-
const getMainExport = (nodes) => {
|
|
6
|
+
const getMainExport = (nodes, getAllBindings) => {
|
|
7
7
|
let handlerExport = [];
|
|
8
8
|
nodes.find((node) => {
|
|
9
|
-
const esmExports = getMainExportFromESM(node);
|
|
9
|
+
const esmExports = getMainExportFromESM(node, getAllBindings);
|
|
10
10
|
if (esmExports.length !== 0) {
|
|
11
11
|
handlerExport = esmExports;
|
|
12
12
|
return true;
|
|
@@ -28,34 +28,58 @@ const getMainExportFromCJS = (node) => {
|
|
|
28
28
|
['exports', 'handler'],
|
|
29
29
|
];
|
|
30
30
|
return handlerPaths.flatMap((handlerPath) => {
|
|
31
|
-
if (!(0, helpers_js_1.isModuleExports)(node, handlerPath)
|
|
31
|
+
if (!(0, helpers_js_1.isModuleExports)(node, handlerPath)) {
|
|
32
32
|
return [];
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return getExportsFromExpression(node.expression.right);
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
// Finds the main handler export in an ESM AST.
|
|
38
|
-
|
|
39
|
-
const getMainExportFromESM = (node) => {
|
|
40
|
-
var _a;
|
|
38
|
+
const getMainExportFromESM = (node, getAllBindings) => {
|
|
41
39
|
if (node.type !== 'ExportNamedDeclaration' || node.exportKind !== 'value') {
|
|
42
40
|
return [];
|
|
43
41
|
}
|
|
44
|
-
const { declaration } = node;
|
|
45
|
-
if (
|
|
42
|
+
const { declaration, specifiers } = node;
|
|
43
|
+
if ((specifiers === null || specifiers === void 0 ? void 0 : specifiers.length) > 0) {
|
|
44
|
+
return getExportsFromBindings(specifiers, getAllBindings);
|
|
45
|
+
}
|
|
46
|
+
if ((declaration === null || declaration === void 0 ? void 0 : declaration.type) !== 'VariableDeclaration') {
|
|
46
47
|
return [];
|
|
47
48
|
}
|
|
48
49
|
const handlerDeclaration = declaration.declarations.find((childDeclaration) => {
|
|
49
50
|
const { id, type } = childDeclaration;
|
|
50
51
|
return type === 'VariableDeclarator' && id.type === 'Identifier' && id.name === 'handler';
|
|
51
52
|
});
|
|
52
|
-
|
|
53
|
+
const exports = getExportsFromExpression(handlerDeclaration === null || handlerDeclaration === void 0 ? void 0 : handlerDeclaration.init);
|
|
54
|
+
return exports;
|
|
55
|
+
};
|
|
56
|
+
// Check if the Node is an ExportSpecifier that has a named export called `handler`
|
|
57
|
+
// either with Identifier `export { handler }`
|
|
58
|
+
// or with StringLiteral `export { x as "handler" }`
|
|
59
|
+
const isHandlerExport = (node) => {
|
|
60
|
+
const { type, exported } = node;
|
|
61
|
+
return (type === 'ExportSpecifier' &&
|
|
62
|
+
((exported.type === 'Identifier' && exported.name === 'handler') ||
|
|
63
|
+
(exported.type === 'StringLiteral' && exported.value === 'handler')));
|
|
64
|
+
};
|
|
65
|
+
// Tries to resolve the export from a binding (variable)
|
|
66
|
+
// for example `let handler; handler = () => {}; export { handler }` would
|
|
67
|
+
// resolve correctly to the handler function
|
|
68
|
+
const getExportsFromBindings = (specifiers, getAllBindings) => {
|
|
69
|
+
const specifier = specifiers.find(isHandlerExport);
|
|
70
|
+
if (!specifier) {
|
|
53
71
|
return [];
|
|
54
72
|
}
|
|
55
|
-
const
|
|
73
|
+
const binding = getAllBindings().get(specifier.local.name);
|
|
74
|
+
const exports = getExportsFromExpression(binding);
|
|
56
75
|
return exports;
|
|
57
76
|
};
|
|
58
|
-
const
|
|
77
|
+
const getExportsFromExpression = (node) => {
|
|
78
|
+
// We're only interested in expressions representing function calls, because
|
|
79
|
+
// the ISC patterns we implement at the moment are all helper functions.
|
|
80
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== 'CallExpression') {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
59
83
|
const { arguments: args, callee } = node;
|
|
60
84
|
if (callee.type !== 'Identifier') {
|
|
61
85
|
return [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const filterExcludedPaths: (paths: string[],
|
|
2
|
-
export declare const getPathsOfIncludedFiles: (includedFiles: string[], basePath?: string
|
|
3
|
-
|
|
1
|
+
export declare const filterExcludedPaths: (paths: string[], excludePattern?: string[]) => string[];
|
|
2
|
+
export declare const getPathsOfIncludedFiles: (includedFiles: string[], basePath?: string) => Promise<{
|
|
3
|
+
excludePatterns: string[];
|
|
4
4
|
paths: string[];
|
|
5
5
|
}>;
|
|
@@ -1,51 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getPathsOfIncludedFiles = exports.filterExcludedPaths = void 0;
|
|
7
4
|
const path_1 = require("path");
|
|
8
|
-
const
|
|
9
|
-
const glob_1 = __importDefault(require("glob"));
|
|
10
|
-
const minimatch_1 = __importDefault(require("minimatch"));
|
|
11
|
-
const pGlob = (0, util_1.promisify)(glob_1.default);
|
|
5
|
+
const matching_1 = require("../../../utils/matching");
|
|
12
6
|
// Returns the subset of `paths` that don't match any of the glob expressions
|
|
13
7
|
// from `exclude`.
|
|
14
|
-
const filterExcludedPaths = (paths,
|
|
15
|
-
if (
|
|
8
|
+
const filterExcludedPaths = (paths, excludePattern = []) => {
|
|
9
|
+
if (excludePattern.length === 0) {
|
|
16
10
|
return paths;
|
|
17
11
|
}
|
|
18
|
-
const excludedPaths = paths.filter((path) => !
|
|
12
|
+
const excludedPaths = paths.filter((path) => !excludePattern.some((pattern) => (0, matching_1.minimatch)(path, pattern)));
|
|
19
13
|
return excludedPaths;
|
|
20
14
|
};
|
|
21
15
|
exports.filterExcludedPaths = filterExcludedPaths;
|
|
22
16
|
const getPathsOfIncludedFiles = async (includedFiles, basePath) => {
|
|
23
17
|
if (basePath === undefined) {
|
|
24
|
-
return {
|
|
18
|
+
return { excludePatterns: [], paths: [] };
|
|
25
19
|
}
|
|
26
20
|
// Some of the globs in `includedFiles` might be exclusion patterns, which
|
|
27
21
|
// means paths that should NOT be included in the bundle. We need to treat
|
|
28
22
|
// these differently, so we iterate on the array and put those paths in a
|
|
29
23
|
// `exclude` array and the rest of the paths in an `include` array.
|
|
30
|
-
const { include,
|
|
24
|
+
const { include, excludePatterns } = includedFiles.reduce((acc, path) => {
|
|
31
25
|
if (path.startsWith('!')) {
|
|
32
|
-
|
|
26
|
+
// convert to unix paths, as minimatch does not support windows paths in patterns
|
|
27
|
+
const excludePattern = (0, path_1.resolve)(basePath, path.slice(1));
|
|
33
28
|
return {
|
|
34
29
|
include: acc.include,
|
|
35
|
-
|
|
30
|
+
excludePatterns: [...acc.excludePatterns, excludePattern],
|
|
36
31
|
};
|
|
37
32
|
}
|
|
38
33
|
return {
|
|
39
34
|
include: [...acc.include, path],
|
|
40
|
-
|
|
35
|
+
excludePatterns: acc.excludePatterns,
|
|
41
36
|
};
|
|
42
|
-
}, { include: [],
|
|
43
|
-
const pathGroups = await Promise.all(include.map((expression) =>
|
|
37
|
+
}, { include: [], excludePatterns: [] });
|
|
38
|
+
const pathGroups = await Promise.all(include.map((expression) => (0, matching_1.glob)(expression, { absolute: true, cwd: basePath, ignore: excludePatterns, nodir: true })));
|
|
44
39
|
// `pathGroups` is an array containing the paths for each expression in the
|
|
45
40
|
// `include` array. We flatten it into a single dimension.
|
|
46
41
|
const paths = pathGroups.flat();
|
|
47
42
|
const normalizedPaths = paths.map(path_1.normalize);
|
|
48
|
-
return {
|
|
43
|
+
return { excludePatterns, paths: [...new Set(normalizedPaths)] };
|
|
49
44
|
};
|
|
50
45
|
exports.getPathsOfIncludedFiles = getPathsOfIncludedFiles;
|
|
51
46
|
//# sourceMappingURL=included_files.js.map
|
|
@@ -4,7 +4,7 @@ export interface NodeVersionSupport {
|
|
|
4
4
|
esm: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare const DEFAULT_NODE_VERSION = 14;
|
|
7
|
-
export declare const getNodeVersion: (configVersion?: string
|
|
8
|
-
export declare const getNodeSupportMatrix: (configVersion?: string
|
|
7
|
+
export declare const getNodeVersion: (configVersion?: string) => number;
|
|
8
|
+
export declare const getNodeSupportMatrix: (configVersion?: string) => NodeVersionSupport;
|
|
9
9
|
export declare const parseVersion: (input: string | undefined) => number | undefined;
|
|
10
10
|
export {};
|
|
@@ -7,7 +7,6 @@ exports.sanitisePackageJson = exports.getPackageJsonIfAvailable = exports.getPac
|
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const find_up_1 = __importDefault(require("find-up"));
|
|
10
|
-
const pkg_dir_1 = __importDefault(require("pkg-dir"));
|
|
11
10
|
const getClosestPackageJson = async (resolveDir) => {
|
|
12
11
|
const packageJsonPath = await (0, find_up_1.default)(async (directory) => {
|
|
13
12
|
// We stop traversing if we're about to leave the boundaries of any
|
|
@@ -31,11 +30,9 @@ const getClosestPackageJson = async (resolveDir) => {
|
|
|
31
30
|
exports.getClosestPackageJson = getClosestPackageJson;
|
|
32
31
|
// Retrieve the `package.json` of a specific project or module
|
|
33
32
|
const getPackageJson = async function (srcDir) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return readPackageJson(`${packageRoot}/package.json`);
|
|
33
|
+
var _a;
|
|
34
|
+
const result = await (0, exports.getClosestPackageJson)(srcDir);
|
|
35
|
+
return (_a = result === null || result === void 0 ? void 0 : result.contents) !== null && _a !== void 0 ? _a : {};
|
|
39
36
|
};
|
|
40
37
|
exports.getPackageJson = getPackageJson;
|
|
41
38
|
const getPackageJsonIfAvailable = async (srcDir) => {
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import { promises as fs } from 'fs';
|
|
3
5
|
export declare type FsCache = Record<string, unknown>;
|
|
4
6
|
export declare const cachedLstat: (cache: FsCache, path: string, opts?: import("fs").StatOptions | undefined) => Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import globFunction from 'glob';
|
|
2
|
+
import minimatchFunction from 'minimatch';
|
|
3
|
+
/**
|
|
4
|
+
* Both glob and minimatch only support unix style slashes in patterns
|
|
5
|
+
* For this reason we wrap them and ensure all patters are always unixified
|
|
6
|
+
* We use `normalize-path` here instead of `unixify` because we do not want to remove drive letters
|
|
7
|
+
*/
|
|
8
|
+
export declare const glob: (pattern: string, options: globFunction.IOptions) => Promise<string[]>;
|
|
9
|
+
export declare const minimatch: (target: string, pattern: string, options?: minimatchFunction.IOptions) => boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.minimatch = exports.glob = void 0;
|
|
7
|
+
const util_1 = require("util");
|
|
8
|
+
const glob_1 = __importDefault(require("glob"));
|
|
9
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
10
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
11
|
+
const pGlob = (0, util_1.promisify)(glob_1.default);
|
|
12
|
+
/**
|
|
13
|
+
* Both glob and minimatch only support unix style slashes in patterns
|
|
14
|
+
* For this reason we wrap them and ensure all patters are always unixified
|
|
15
|
+
* We use `normalize-path` here instead of `unixify` because we do not want to remove drive letters
|
|
16
|
+
*/
|
|
17
|
+
const glob = function (pattern, options) {
|
|
18
|
+
let normalizedIgnore;
|
|
19
|
+
if (options.ignore) {
|
|
20
|
+
normalizedIgnore =
|
|
21
|
+
typeof options.ignore === 'string'
|
|
22
|
+
? (0, normalize_path_1.default)(options.ignore)
|
|
23
|
+
: options.ignore.map((expression) => (0, normalize_path_1.default)(expression));
|
|
24
|
+
}
|
|
25
|
+
return pGlob((0, normalize_path_1.default)(pattern), { ...options, ignore: normalizedIgnore });
|
|
26
|
+
};
|
|
27
|
+
exports.glob = glob;
|
|
28
|
+
const minimatch = function (target, pattern, options) {
|
|
29
|
+
return (0, minimatch_1.default)(target, (0, normalize_path_1.default)(pattern), options);
|
|
30
|
+
};
|
|
31
|
+
exports.minimatch = minimatch;
|
|
32
|
+
//# sourceMappingURL=matching.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.10.1",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/parser": "7.16.8",
|
|
56
|
-
"@netlify/esbuild": "0.14.
|
|
57
|
-
"@vercel/nft": "^0.
|
|
56
|
+
"@netlify/esbuild": "0.14.25",
|
|
57
|
+
"@vercel/nft": "^0.19.0",
|
|
58
58
|
"archiver": "^5.3.0",
|
|
59
59
|
"common-path-prefix": "^3.0.0",
|
|
60
60
|
"cp-file": "^9.0.0",
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
"execa": "^5.0.0",
|
|
66
66
|
"filter-obj": "^2.0.1",
|
|
67
67
|
"find-up": "^5.0.0",
|
|
68
|
-
"glob": "^
|
|
68
|
+
"glob": "^8.0.3",
|
|
69
69
|
"is-builtin-module": "^3.1.0",
|
|
70
70
|
"junk": "^3.1.0",
|
|
71
71
|
"locate-path": "^6.0.0",
|
|
72
72
|
"merge-options": "^3.0.4",
|
|
73
|
-
"minimatch": "^
|
|
73
|
+
"minimatch": "^5.0.0",
|
|
74
|
+
"normalize-path": "^3.0.0",
|
|
74
75
|
"p-map": "^4.0.0",
|
|
75
76
|
"path-exists": "^4.0.0",
|
|
76
|
-
"
|
|
77
|
-
"precinct": "^8.2.0",
|
|
77
|
+
"precinct": "^9.0.1",
|
|
78
78
|
"read-package-json-fast": "^2.0.2",
|
|
79
79
|
"require-package-name": "^2.0.1",
|
|
80
80
|
"resolve": "^2.0.0-next.1",
|
|
@@ -82,13 +82,14 @@
|
|
|
82
82
|
"tmp-promise": "^3.0.2",
|
|
83
83
|
"toml": "^3.0.0",
|
|
84
84
|
"unixify": "^1.0.0",
|
|
85
|
-
"yargs": "^
|
|
85
|
+
"yargs": "^17.0.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@babel/types": "^7.15.6",
|
|
89
89
|
"@netlify/eslint-config-node": "^6.0.0",
|
|
90
90
|
"@types/archiver": "^5.1.1",
|
|
91
91
|
"@types/end-of-stream": "^1.4.1",
|
|
92
|
+
"@types/normalize-path": "^3.0.0",
|
|
92
93
|
"@types/resolve": "^1.20.1",
|
|
93
94
|
"@types/semver": "^7.3.8",
|
|
94
95
|
"@types/unixify": "^1.0.0",
|