@netlify/zip-it-and-ship-it 4.30.0 → 5.3.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/feature_flags.js +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -1
- package/dist/runtimes/node/bundlers/nft/index.js +3 -6
- package/dist/runtimes/node/bundlers/zisi/traverse.js +1 -3
- package/dist/runtimes/node/in_source_config/index.d.ts +12 -0
- package/dist/runtimes/node/in_source_config/index.js +49 -0
- package/dist/runtimes/node/in_source_config/properties/schedule.d.ts +6 -0
- package/dist/runtimes/node/in_source_config/properties/schedule.js +12 -0
- package/dist/runtimes/node/index.js +3 -0
- package/dist/runtimes/node/parser/exports.d.ts +4 -0
- package/dist/runtimes/node/parser/exports.js +66 -0
- package/dist/runtimes/node/parser/helpers.d.ts +7 -0
- package/dist/runtimes/node/parser/helpers.js +38 -0
- package/dist/runtimes/node/parser/imports.d.ts +6 -0
- package/dist/runtimes/node/parser/imports.js +60 -0
- package/dist/runtimes/node/parser/index.d.ts +2 -1
- package/dist/runtimes/node/parser/index.js +36 -1
- package/dist/runtimes/runtime.d.ts +2 -0
- package/dist/utils/format_result.js +2 -2
- package/dist/zip.d.ts +4 -1
- package/package.json +4 -4
- package/dist/utils/polyfills.d.ts +0 -1
- package/dist/utils/polyfills.js +0 -6
package/dist/feature_flags.js
CHANGED
|
@@ -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
|
-
nftTranspile: false,
|
|
10
9
|
parseWithEsbuild: false,
|
|
11
10
|
traceWithNft: false,
|
|
12
11
|
};
|
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -22,7 +22,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.zipFunctions = exports.zipFunction = exports.listFunctionsFiles = exports.listFunctions = void 0;
|
|
24
24
|
const path_1 = require("path");
|
|
25
|
-
require("./utils/polyfills");
|
|
26
25
|
const feature_flags_1 = require("./feature_flags");
|
|
27
26
|
const runtimes_1 = require("./runtimes");
|
|
28
27
|
const fs_1 = require("./utils/fs");
|
|
@@ -24,7 +24,7 @@ const es_modules_1 = require("./es_modules");
|
|
|
24
24
|
// Paths that will be excluded from the tracing process.
|
|
25
25
|
const ignore = ['node_modules/aws-sdk/**'];
|
|
26
26
|
const appearsToBeModuleName = (name) => !name.startsWith('.');
|
|
27
|
-
const bundle = ({ basePath, config,
|
|
27
|
+
const bundle = ({ basePath, config, mainFile, pluginsModulesPath, repositoryRoot = basePath, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
const { includedFiles = [], includedFilesBasePath } = config;
|
|
29
29
|
const { exclude: excludedPaths, paths: includedFilePaths } = yield (0, included_files_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath || basePath);
|
|
30
30
|
const { paths: dependencyPaths, rewrites } = yield traceFilesAndTranspile({
|
|
@@ -32,7 +32,6 @@ const bundle = ({ basePath, config, featureFlags, mainFile, pluginsModulesPath,
|
|
|
32
32
|
config,
|
|
33
33
|
mainFile,
|
|
34
34
|
pluginsModulesPath,
|
|
35
|
-
transpile: featureFlags.nftTranspile,
|
|
36
35
|
});
|
|
37
36
|
const filteredIncludedPaths = (0, included_files_1.filterExcludedPaths)([...dependencyPaths, ...includedFilePaths], excludedPaths);
|
|
38
37
|
const dirnames = filteredIncludedPaths.map((filePath) => (0, path_1.normalize)((0, path_1.dirname)(filePath))).sort();
|
|
@@ -51,7 +50,7 @@ const ignoreFunction = (path) => {
|
|
|
51
50
|
const shouldIgnore = ignore.some((expression) => (0, minimatch_1.default)(normalizedPath, expression));
|
|
52
51
|
return shouldIgnore;
|
|
53
52
|
};
|
|
54
|
-
const traceFilesAndTranspile = function ({ basePath, config, mainFile, pluginsModulesPath,
|
|
53
|
+
const traceFilesAndTranspile = function ({ basePath, config, mainFile, pluginsModulesPath, }) {
|
|
55
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
55
|
const fsCache = {};
|
|
57
56
|
const { fileList: dependencyPaths, esmFileList, reasons, } = yield (0, nft_1.nodeFileTrace)([mainFile], {
|
|
@@ -86,9 +85,7 @@ const traceFilesAndTranspile = function ({ basePath, config, mainFile, pluginsMo
|
|
|
86
85
|
}),
|
|
87
86
|
});
|
|
88
87
|
const normalizedDependencyPaths = [...dependencyPaths].map((path) => basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path));
|
|
89
|
-
const rewrites =
|
|
90
|
-
? yield (0, es_modules_1.transpileESM)({ basePath, config, esmPaths: esmFileList, fsCache, reasons })
|
|
91
|
-
: undefined;
|
|
88
|
+
const rewrites = yield (0, es_modules_1.transpileESM)({ basePath, config, esmPaths: esmFileList, fsCache, reasons });
|
|
92
89
|
return {
|
|
93
90
|
paths: normalizedDependencyPaths,
|
|
94
91
|
rewrites,
|
|
@@ -71,9 +71,7 @@ const getNestedModules = function ({ modulePath, state, packageJson, pluginsModu
|
|
|
71
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
72
|
const dependencies = (0, nested_1.getNestedDependencies)(packageJson);
|
|
73
73
|
const depsPaths = yield Promise.all(dependencies.map((dependency) => getDependencyPathsForDependency({ dependency, basedir: modulePath, state, packageJson, pluginsModulesPath })));
|
|
74
|
-
|
|
75
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
76
|
-
return [].concat(...depsPaths);
|
|
74
|
+
return depsPaths.flat();
|
|
77
75
|
});
|
|
78
76
|
};
|
|
79
77
|
//# sourceMappingURL=traverse.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArgumentPlaceholder, Expression, SpreadElement, JSXNamespacedName } from '@babel/types';
|
|
2
|
+
import { parse as parseSchedule } from './properties/schedule';
|
|
3
|
+
declare const IN_SOURCE_CONFIG_MODULE = "@netlify/functions";
|
|
4
|
+
declare type ISCValues = Partial<ReturnType<typeof parseSchedule>>;
|
|
5
|
+
declare const findISCDeclarationsInPath: (sourcePath: string) => Promise<ISCValues>;
|
|
6
|
+
declare type ISCHandlerArg = ArgumentPlaceholder | Expression | SpreadElement | JSXNamespacedName;
|
|
7
|
+
interface ISCExport {
|
|
8
|
+
local: string;
|
|
9
|
+
args: ISCHandlerArg[];
|
|
10
|
+
}
|
|
11
|
+
export { findISCDeclarationsInPath, IN_SOURCE_CONFIG_MODULE };
|
|
12
|
+
export type { ISCExport, ISCHandlerArg, ISCValues };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IN_SOURCE_CONFIG_MODULE = exports.findISCDeclarationsInPath = void 0;
|
|
13
|
+
const non_nullable_1 = require("../../../utils/non_nullable");
|
|
14
|
+
const parser_1 = require("../parser");
|
|
15
|
+
const exports_1 = require("../parser/exports");
|
|
16
|
+
const imports_1 = require("../parser/imports");
|
|
17
|
+
const schedule_1 = require("./properties/schedule");
|
|
18
|
+
const IN_SOURCE_CONFIG_MODULE = '@netlify/functions';
|
|
19
|
+
exports.IN_SOURCE_CONFIG_MODULE = IN_SOURCE_CONFIG_MODULE;
|
|
20
|
+
// Parses a JS/TS file and looks for in-source config declarations. It returns
|
|
21
|
+
// an array of all declarations found, with `property` indicating the name of
|
|
22
|
+
// the property and `data` its value.
|
|
23
|
+
const findISCDeclarationsInPath = (sourcePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const ast = yield (0, parser_1.safelyParseFile)(sourcePath);
|
|
25
|
+
if (ast === null) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
const imports = ast.body.map((node) => (0, imports_1.getImports)(node, IN_SOURCE_CONFIG_MODULE)).flat();
|
|
29
|
+
const exports = (0, exports_1.getMainExport)(ast.body);
|
|
30
|
+
const iscExports = exports
|
|
31
|
+
.map(({ args, local: exportName }) => {
|
|
32
|
+
const matchingImport = imports.find(({ local: importName }) => importName === exportName);
|
|
33
|
+
if (matchingImport === undefined) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
switch (matchingImport.imported) {
|
|
37
|
+
case 'schedule':
|
|
38
|
+
return (0, schedule_1.parse)({ args });
|
|
39
|
+
default:
|
|
40
|
+
// no-op
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
})
|
|
44
|
+
.filter(non_nullable_1.nonNullable);
|
|
45
|
+
const mergedExports = iscExports.reduce((acc, obj) => (Object.assign(Object.assign({}, acc), obj)), {});
|
|
46
|
+
return mergedExports;
|
|
47
|
+
});
|
|
48
|
+
exports.findISCDeclarationsInPath = findISCDeclarationsInPath;
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse = void 0;
|
|
4
|
+
const parse = ({ args }) => {
|
|
5
|
+
const [expression] = args;
|
|
6
|
+
const schedule = expression.type === 'StringLiteral' ? expression.value : undefined;
|
|
7
|
+
return {
|
|
8
|
+
schedule,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.parse = parse;
|
|
12
|
+
//# sourceMappingURL=schedule.js.map
|
|
@@ -27,6 +27,7 @@ const path_1 = require("path");
|
|
|
27
27
|
const cp_file_1 = __importDefault(require("cp-file"));
|
|
28
28
|
const bundlers_1 = require("./bundlers");
|
|
29
29
|
const finder_1 = require("./finder");
|
|
30
|
+
const in_source_config_1 = require("./in_source_config");
|
|
30
31
|
const detect_es_module_1 = require("./utils/detect_es_module");
|
|
31
32
|
const plugin_modules_path_1 = require("./utils/plugin_modules_path");
|
|
32
33
|
const zip_1 = require("./utils/zip");
|
|
@@ -88,6 +89,7 @@ const zipFunction = function ({ archiveFormat, basePath, config = {}, destFolder
|
|
|
88
89
|
srcPath,
|
|
89
90
|
stat,
|
|
90
91
|
});
|
|
92
|
+
const inSourceConfig = yield (0, in_source_config_1.findISCDeclarationsInPath)(mainFile);
|
|
91
93
|
(0, plugin_modules_path_1.createAliases)(srcFiles, pluginsModulesPath, aliases, finalBasePath);
|
|
92
94
|
const zipPath = yield (0, zip_1.zipNodeJs)({
|
|
93
95
|
aliases,
|
|
@@ -106,6 +108,7 @@ const zipFunction = function ({ archiveFormat, basePath, config = {}, destFolder
|
|
|
106
108
|
bundlerWarnings,
|
|
107
109
|
config,
|
|
108
110
|
inputs,
|
|
111
|
+
inSourceConfig,
|
|
109
112
|
nativeNodeModules,
|
|
110
113
|
nodeModulesWithDynamicImports,
|
|
111
114
|
path: zipPath,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMainExport = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
// Finds the main handler export in an AST.
|
|
6
|
+
const getMainExport = (nodes) => {
|
|
7
|
+
let handlerExport = [];
|
|
8
|
+
nodes.find((node) => {
|
|
9
|
+
const esmExports = getMainExportFromESM(node);
|
|
10
|
+
if (esmExports.length !== 0) {
|
|
11
|
+
handlerExport = esmExports;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
const cjsExports = getMainExportFromCJS(node);
|
|
15
|
+
if (cjsExports.length !== 0) {
|
|
16
|
+
handlerExport = cjsExports;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
});
|
|
21
|
+
return handlerExport;
|
|
22
|
+
};
|
|
23
|
+
exports.getMainExport = getMainExport;
|
|
24
|
+
// Finds the main handler export in a CJS AST.
|
|
25
|
+
const getMainExportFromCJS = (node) => {
|
|
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
|
+
});
|
|
36
|
+
};
|
|
37
|
+
// Finds the main handler export in an ESM AST.
|
|
38
|
+
// eslint-disable-next-line complexity
|
|
39
|
+
const getMainExportFromESM = (node) => {
|
|
40
|
+
var _a;
|
|
41
|
+
if (node.type !== 'ExportNamedDeclaration' || node.exportKind !== 'value') {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const { declaration } = node;
|
|
45
|
+
if (!declaration || declaration.type !== 'VariableDeclaration') {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const handlerDeclaration = declaration.declarations.find((childDeclaration) => {
|
|
49
|
+
const { id, type } = childDeclaration;
|
|
50
|
+
return type === 'VariableDeclarator' && id.type === 'Identifier' && id.name === 'handler';
|
|
51
|
+
});
|
|
52
|
+
if (((_a = handlerDeclaration === null || handlerDeclaration === void 0 ? void 0 : handlerDeclaration.init) === null || _a === void 0 ? void 0 : _a.type) !== 'CallExpression') {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
const exports = getExportsFromCallExpression(handlerDeclaration.init);
|
|
56
|
+
return exports;
|
|
57
|
+
};
|
|
58
|
+
const getExportsFromCallExpression = (node) => {
|
|
59
|
+
const { arguments: args, callee } = node;
|
|
60
|
+
if (callee.type !== 'Identifier') {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const exports = [{ local: callee.name, args }];
|
|
64
|
+
return exports;
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=exports.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AssignmentExpression, Expression, ExpressionStatement, ImportDeclaration, Statement } from '@babel/types';
|
|
2
|
+
declare const isImport: (node: Statement, importPath: string) => node is ImportDeclaration;
|
|
3
|
+
declare const isModuleExports: (node: Statement, dotExpression?: string[]) => node is ExpressionStatement & {
|
|
4
|
+
expression: AssignmentExpression;
|
|
5
|
+
};
|
|
6
|
+
declare const isRequire: (node: Expression | undefined | null, requirePath: string) => boolean;
|
|
7
|
+
export { isImport, isModuleExports, isRequire };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRequire = exports.isModuleExports = exports.isImport = void 0;
|
|
4
|
+
// eslint-disable-next-line complexity
|
|
5
|
+
const isDotExpression = (node, expression) => {
|
|
6
|
+
if (node.type !== 'MemberExpression') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const object = expression.slice(0, -1);
|
|
10
|
+
const [property] = expression.slice(-1);
|
|
11
|
+
if (node.property.type !== 'Identifier' || node.property.name !== property) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (object.length > 1) {
|
|
15
|
+
return isDotExpression(node.object, object);
|
|
16
|
+
}
|
|
17
|
+
return node.object.type === 'Identifier' && object[0] === node.object.name && property === node.property.name;
|
|
18
|
+
};
|
|
19
|
+
const isImport = (node, importPath) => node.type === 'ImportDeclaration' && node.source.value === importPath;
|
|
20
|
+
exports.isImport = isImport;
|
|
21
|
+
const isModuleExports = (node, dotExpression = ['module', 'exports']) => node.type === 'ExpressionStatement' &&
|
|
22
|
+
node.expression.type === 'AssignmentExpression' &&
|
|
23
|
+
node.expression.left.type === 'MemberExpression' &&
|
|
24
|
+
isDotExpression(node.expression.left, dotExpression);
|
|
25
|
+
exports.isModuleExports = isModuleExports;
|
|
26
|
+
const isRequire = (node, requirePath) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (!node || node.type !== 'CallExpression') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const { arguments: args, callee } = node;
|
|
32
|
+
const isRequiredModule = ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.type) === 'StringLiteral' && isRequirePath(args[0], requirePath);
|
|
33
|
+
return isRequireCall(callee) && isRequiredModule;
|
|
34
|
+
};
|
|
35
|
+
exports.isRequire = isRequire;
|
|
36
|
+
const isRequireCall = (node) => node.type === 'Identifier' && node.name === 'require';
|
|
37
|
+
const isRequirePath = (node, path) => node.type === 'StringLiteral' && node.value === path;
|
|
38
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImports = void 0;
|
|
4
|
+
const non_nullable_1 = require("../../../utils/non_nullable");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
// Finds import/require statements of a given path in an AST.
|
|
7
|
+
const getImports = (node, importPath) => {
|
|
8
|
+
const esmImports = getImportsFromESM(node, importPath);
|
|
9
|
+
if (esmImports.length !== 0) {
|
|
10
|
+
return esmImports;
|
|
11
|
+
}
|
|
12
|
+
const cjsImports = getImportsFromCJS(node, importPath);
|
|
13
|
+
return cjsImports;
|
|
14
|
+
};
|
|
15
|
+
exports.getImports = getImports;
|
|
16
|
+
// Finds import/require statements of a given path in a CJS AST.
|
|
17
|
+
const getImportsFromCJS = (node, importPath) => {
|
|
18
|
+
if (node.type !== 'VariableDeclaration') {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const { declarations } = node;
|
|
22
|
+
const requireDeclaration = declarations.find((declaration) => declaration.type === 'VariableDeclarator' && (0, helpers_1.isRequire)(declaration.init, importPath));
|
|
23
|
+
if (requireDeclaration === undefined || requireDeclaration.id.type !== 'ObjectPattern') {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const imports = requireDeclaration.id.properties
|
|
27
|
+
.map((property) => {
|
|
28
|
+
if (property.type !== 'ObjectProperty') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { key, value } = property;
|
|
32
|
+
if (key.type !== 'Identifier' || value.type !== 'Identifier') {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
return { imported: key.name, local: value.name };
|
|
36
|
+
})
|
|
37
|
+
.filter(non_nullable_1.nonNullable);
|
|
38
|
+
return imports;
|
|
39
|
+
};
|
|
40
|
+
// Finds import/require statements of a given path in an ESM AST.
|
|
41
|
+
const getImportsFromESM = (node, importPath) => {
|
|
42
|
+
if (!(0, helpers_1.isImport)(node, importPath)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const { specifiers } = node;
|
|
46
|
+
const imports = specifiers
|
|
47
|
+
.map((specifier) => {
|
|
48
|
+
if (specifier.type !== 'ImportSpecifier') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const { imported, local } = specifier;
|
|
52
|
+
if (imported.type !== 'Identifier' || local.type !== 'Identifier') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return { imported: imported.name, local: local.name };
|
|
56
|
+
})
|
|
57
|
+
.filter(non_nullable_1.nonNullable);
|
|
58
|
+
return imports;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -6,4 +6,5 @@ declare const parseExpression: ({ basePath, expression: rawExpression, resolveDi
|
|
|
6
6
|
includedPathsGlob: string | null | undefined;
|
|
7
7
|
type: string;
|
|
8
8
|
} | undefined;
|
|
9
|
-
|
|
9
|
+
declare const safelyParseFile: (path: string) => Promise<import("@babel/types").Program | null>;
|
|
10
|
+
export { parseExpression, safelyParseFile };
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseExpression = void 0;
|
|
12
|
+
exports.safelyParseFile = exports.parseExpression = void 0;
|
|
13
|
+
/* eslint-disable max-lines */
|
|
4
14
|
const path_1 = require("path");
|
|
5
15
|
const parser_1 = require("@babel/parser");
|
|
16
|
+
const fs_1 = require("../../../utils/fs");
|
|
6
17
|
const non_nullable_1 = require("../../../utils/non_nullable");
|
|
7
18
|
const GLOB_WILDCARD = '**';
|
|
8
19
|
// Transforms an array of glob nodes into a glob string including an absolute
|
|
@@ -75,6 +86,29 @@ const parseExpression = ({ basePath, expression: rawExpression, resolveDir, }) =
|
|
|
75
86
|
}
|
|
76
87
|
};
|
|
77
88
|
exports.parseExpression = parseExpression;
|
|
89
|
+
// Parses a JS/TS file and returns the resulting AST.
|
|
90
|
+
const parseFile = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
const code = yield (0, fs_1.readFile)(path, 'utf8');
|
|
92
|
+
const ast = (0, parser_1.parse)(code, {
|
|
93
|
+
plugins: ['typescript'],
|
|
94
|
+
sourceType: 'module',
|
|
95
|
+
});
|
|
96
|
+
return ast.program;
|
|
97
|
+
});
|
|
98
|
+
// Attemps to parse a JS/TS file at the given path, returning its AST if
|
|
99
|
+
// successful, or `null` if not.
|
|
100
|
+
const safelyParseFile = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
if (!path) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return yield parseFile(path);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
exports.safelyParseFile = safelyParseFile;
|
|
78
112
|
// Parses a `require()` and returns a glob string with an absolute path.
|
|
79
113
|
const parseRequire = ({ basePath, expression, resolveDir, }) => {
|
|
80
114
|
const { arguments: args = [] } = expression;
|
|
@@ -146,4 +180,5 @@ const validateGlobNodes = (globNodes) => {
|
|
|
146
180
|
const hasStaticHead = globNodes[0] !== GLOB_WILDCARD;
|
|
147
181
|
return hasStrings && hasStaticHead;
|
|
148
182
|
};
|
|
183
|
+
/* eslint-enable max-lines */
|
|
149
184
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,6 +4,7 @@ import { FeatureFlags } from '../feature_flags';
|
|
|
4
4
|
import { FunctionSource, SourceFile } from '../function';
|
|
5
5
|
import { FsCache } from '../utils/fs';
|
|
6
6
|
import type { NodeBundlerName } from './node';
|
|
7
|
+
import type { ISCValues } from './node/in_source_config';
|
|
7
8
|
declare type RuntimeName = 'go' | 'js' | 'rs';
|
|
8
9
|
declare type FindFunctionsInPathsFunction = (args: {
|
|
9
10
|
featureFlags: FeatureFlags;
|
|
@@ -22,6 +23,7 @@ interface ZipFunctionResult {
|
|
|
22
23
|
bundlerWarnings?: object[];
|
|
23
24
|
config: FunctionConfig;
|
|
24
25
|
inputs?: string[];
|
|
26
|
+
inSourceConfig?: ISCValues;
|
|
25
27
|
nativeNodeModules?: object;
|
|
26
28
|
nodeModulesWithDynamicImports?: string[];
|
|
27
29
|
path: string;
|
|
@@ -4,8 +4,8 @@ exports.formatZipResult = void 0;
|
|
|
4
4
|
const remove_undefined_1 = require("./remove_undefined");
|
|
5
5
|
// Takes the result of zipping a function and formats it for output.
|
|
6
6
|
const formatZipResult = (archive) => {
|
|
7
|
-
var _a;
|
|
8
|
-
const functionResult = Object.assign(Object.assign({}, archive), { runtime: archive.runtime.name, schedule: (_a = archive === null || archive === void 0 ? void 0 : archive.config) === null ||
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const functionResult = Object.assign(Object.assign({}, archive), { inSourceConfig: undefined, runtime: archive.runtime.name, 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 });
|
|
9
9
|
return (0, remove_undefined_1.removeUndefined)(functionResult);
|
|
10
10
|
};
|
|
11
11
|
exports.formatZipResult = formatZipResult;
|
package/dist/zip.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ declare type ZipFunctionsOptions = ZipFunctionOptions & {
|
|
|
12
12
|
manifest?: string;
|
|
13
13
|
parallelLimit?: number;
|
|
14
14
|
};
|
|
15
|
-
declare const zipFunctions: (relativeSrcFolders: string | string[], destFolder: string, { archiveFormat, basePath, config, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, }?: ZipFunctionsOptions) => Promise<import("./
|
|
15
|
+
declare const zipFunctions: (relativeSrcFolders: string | string[], destFolder: string, { archiveFormat, basePath, config, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, }?: ZipFunctionsOptions) => Promise<(Omit<import("./function").FunctionArchive, "runtime"> & {
|
|
16
|
+
runtime: import("./runtimes/runtime").RuntimeName;
|
|
17
|
+
schedule?: string | undefined;
|
|
18
|
+
})[]>;
|
|
16
19
|
declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config: inputConfig, featureFlags: inputFeatureFlags, repositoryRoot, }?: ZipFunctionOptions) => Promise<import("./utils/format_result").FunctionResult | undefined>;
|
|
17
20
|
export { zipFunction, zipFunctions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"@netlify/esbuild": "^0.13.6",
|
|
62
62
|
"@vercel/nft": "^0.17.0",
|
|
63
63
|
"archiver": "^5.3.0",
|
|
64
|
-
"array-flat-polyfill": "^1.0.1",
|
|
65
64
|
"common-path-prefix": "^3.0.0",
|
|
66
65
|
"cp-file": "^9.0.0",
|
|
67
66
|
"del": "^6.0.0",
|
|
@@ -94,7 +93,7 @@
|
|
|
94
93
|
},
|
|
95
94
|
"devDependencies": {
|
|
96
95
|
"@babel/types": "^7.15.6",
|
|
97
|
-
"@netlify/eslint-config-node": "^
|
|
96
|
+
"@netlify/eslint-config-node": "^4.0.0",
|
|
98
97
|
"@types/archiver": "^5.1.1",
|
|
99
98
|
"@types/end-of-stream": "^1.4.1",
|
|
100
99
|
"@types/resolve": "^1.20.1",
|
|
@@ -109,6 +108,7 @@
|
|
|
109
108
|
"husky": "^4.3.8",
|
|
110
109
|
"npm-run-all": "^4.1.5",
|
|
111
110
|
"nyc": "^15.0.0",
|
|
111
|
+
"p-every": "^2.0.0",
|
|
112
112
|
"sinon": "^12.0.0",
|
|
113
113
|
"sort-on": "^4.1.1",
|
|
114
114
|
"source-map-support": "^0.5.20",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"typescript": "^4.4.3"
|
|
117
117
|
},
|
|
118
118
|
"engines": {
|
|
119
|
-
"node": ">=
|
|
119
|
+
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
120
120
|
},
|
|
121
121
|
"ava": {
|
|
122
122
|
"files": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'array-flat-polyfill';
|
package/dist/utils/polyfills.js
DELETED