@netlify/zip-it-and-ship-it 4.29.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -1
- package/dist/manifest.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_node_builtin.js +1 -1
- package/dist/runtimes/node/bundlers/nft/es_modules.js +10 -9
- package/dist/runtimes/node/bundlers/nft/transpile.js +1 -0
- package/dist/runtimes/node/bundlers/zisi/traverse.js +1 -3
- package/dist/runtimes/node/utils/zip.js +2 -1
- package/dist/utils/format_result.d.ts +1 -0
- package/dist/utils/format_result.js +2 -1
- package/dist/utils/fs.d.ts +2 -1
- package/dist/utils/fs.js +13 -1
- package/dist/zip.d.ts +4 -1
- package/package.json +5 -4
- package/dist/utils/polyfills.d.ts +0 -1
- package/dist/utils/polyfills.js +0 -6
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");
|
package/dist/manifest.js
CHANGED
|
@@ -25,11 +25,11 @@ const createManifest = ({ functions, path }) => __awaiter(void 0, void 0, void 0
|
|
|
25
25
|
yield (0, fs_1.writeFile)(path, JSON.stringify(payload));
|
|
26
26
|
});
|
|
27
27
|
exports.createManifest = createManifest;
|
|
28
|
-
const formatFunctionForManifest = ({
|
|
28
|
+
const formatFunctionForManifest = ({ mainFile, name, path, runtime, schedule }) => ({
|
|
29
29
|
mainFile,
|
|
30
30
|
name,
|
|
31
31
|
path: (0, path_1.resolve)(path),
|
|
32
32
|
runtime,
|
|
33
|
-
schedule
|
|
33
|
+
schedule,
|
|
34
34
|
});
|
|
35
35
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -4,7 +4,7 @@ exports.getNodeBuiltinPlugin = void 0;
|
|
|
4
4
|
const getNodeBuiltinPlugin = () => ({
|
|
5
5
|
name: 'builtin-modules',
|
|
6
6
|
setup(build) {
|
|
7
|
-
build.onResolve({ filter: /^node:/ }, () => ({ external: true }));
|
|
7
|
+
build.onResolve({ filter: /^node:/ }, (args) => ({ path: args.path.slice('node:'.length), external: true }));
|
|
8
8
|
},
|
|
9
9
|
});
|
|
10
10
|
exports.getNodeBuiltinPlugin = getNodeBuiltinPlugin;
|
|
@@ -27,7 +27,7 @@ const patchESMPackage = (path, fsCache) => __awaiter(void 0, void 0, void 0, fun
|
|
|
27
27
|
const patchedPackageJson = Object.assign(Object.assign({}, packageJson), { type: 'commonjs' });
|
|
28
28
|
return JSON.stringify(patchedPackageJson);
|
|
29
29
|
});
|
|
30
|
-
const shouldTranspile = (path, cache, reasons) => {
|
|
30
|
+
const shouldTranspile = (path, cache, esmPaths, reasons) => {
|
|
31
31
|
if (cache.has(path)) {
|
|
32
32
|
return cache.get(path);
|
|
33
33
|
}
|
|
@@ -39,32 +39,33 @@ const shouldTranspile = (path, cache, reasons) => {
|
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
41
|
const { parents } = reason;
|
|
42
|
-
// If the path
|
|
42
|
+
// If the path is an entrypoint, we transpile it only if it's an ESM file.
|
|
43
43
|
if (parents.size === 0) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const isESM = esmPaths.has(path);
|
|
45
|
+
cache.set(path, isESM);
|
|
46
|
+
return isESM;
|
|
46
47
|
}
|
|
47
48
|
// The path should be transpiled if every parent will also be transpiled, or
|
|
48
49
|
// if there is no parent.
|
|
49
|
-
const shouldTranspilePath = [...parents].every((parentPath) => shouldTranspile(parentPath, cache, reasons));
|
|
50
|
+
const shouldTranspilePath = [...parents].every((parentPath) => shouldTranspile(parentPath, cache, esmPaths, reasons));
|
|
50
51
|
cache.set(path, shouldTranspilePath);
|
|
51
52
|
return shouldTranspilePath;
|
|
52
53
|
};
|
|
53
54
|
const transpileESM = ({ basePath, config, esmPaths, fsCache, reasons, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
55
|
const cache = new Map();
|
|
55
|
-
const
|
|
56
|
-
const
|
|
56
|
+
const pathsToTranspile = [...esmPaths].filter((path) => shouldTranspile(path, cache, esmPaths, reasons));
|
|
57
|
+
const pathsToTranspileSet = new Set(pathsToTranspile);
|
|
57
58
|
const packageJsonPaths = [...reasons.entries()]
|
|
58
59
|
.filter(([path, reason]) => {
|
|
59
60
|
if ((0, path_1.basename)(path) !== 'package.json') {
|
|
60
61
|
return false;
|
|
61
62
|
}
|
|
62
|
-
const needsPatch = [...reason.parents].some((parentPath) =>
|
|
63
|
+
const needsPatch = [...reason.parents].some((parentPath) => pathsToTranspileSet.has(parentPath));
|
|
63
64
|
return needsPatch;
|
|
64
65
|
})
|
|
65
66
|
.map(([path]) => (basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path)));
|
|
66
67
|
const rewrites = yield getPatchedESMPackages(packageJsonPaths, fsCache);
|
|
67
|
-
yield Promise.all(
|
|
68
|
+
yield Promise.all(pathsToTranspile.map((path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
69
|
const absolutePath = basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path);
|
|
69
70
|
const transpiled = yield (0, transpile_1.transpile)(absolutePath, config);
|
|
70
71
|
rewrites.set(absolutePath, transpiled);
|
|
@@ -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
|
|
@@ -36,6 +36,7 @@ const make_dir_1 = __importDefault(require("make-dir"));
|
|
|
36
36
|
const p_map_1 = __importDefault(require("p-map"));
|
|
37
37
|
const unixify_1 = __importDefault(require("unixify"));
|
|
38
38
|
const archive_1 = require("../../../archive");
|
|
39
|
+
const fs_2 = require("../../../utils/fs");
|
|
39
40
|
const pStat = (0, util_1.promisify)(fs_1.default.stat);
|
|
40
41
|
const pWriteFile = (0, util_1.promisify)(fs_1.default.writeFile);
|
|
41
42
|
// Taken from https://www.npmjs.com/package/cpy.
|
|
@@ -67,7 +68,7 @@ const createDirectory = function ({ aliases = new Map(), basePath, destFolder, e
|
|
|
67
68
|
});
|
|
68
69
|
const absoluteDestPath = (0, path_1.join)(functionFolder, normalizedDestPath);
|
|
69
70
|
if (rewrites.has(srcFile)) {
|
|
70
|
-
return
|
|
71
|
+
return (0, fs_2.mkdirAndWriteFile)(absoluteDestPath, rewrites.get(srcFile));
|
|
71
72
|
}
|
|
72
73
|
return (0, cp_file_1.default)(srcFile, absoluteDestPath);
|
|
73
74
|
}, { concurrency: COPY_FILE_CONCURRENCY });
|
|
@@ -2,6 +2,7 @@ import { FunctionArchive } from '../function';
|
|
|
2
2
|
import { RuntimeName } from '../runtimes/runtime';
|
|
3
3
|
declare type FunctionResult = Omit<FunctionArchive, 'runtime'> & {
|
|
4
4
|
runtime: RuntimeName;
|
|
5
|
+
schedule?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const formatZipResult: (archive: FunctionArchive) => FunctionResult;
|
|
7
8
|
export { formatZipResult };
|
|
@@ -4,7 +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
|
-
|
|
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 || _a === void 0 ? void 0 : _a.schedule });
|
|
8
9
|
return (0, remove_undefined_1.removeUndefined)(functionResult);
|
|
9
10
|
};
|
|
10
11
|
exports.formatZipResult = formatZipResult;
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ declare const safeUnlink: (path: string) => Promise<void>;
|
|
|
17
17
|
declare const listFunctionsDirectories: (srcFolders: string[]) => Promise<string[]>;
|
|
18
18
|
declare const listFunctionsDirectory: (srcFolder: string) => Promise<string[]>;
|
|
19
19
|
declare const resolveFunctionsDirectories: (input: string | string[]) => string[];
|
|
20
|
-
|
|
20
|
+
declare const mkdirAndWriteFile: typeof pWriteFile;
|
|
21
|
+
export { cachedLstat, cachedReaddir, cachedReadFile, pLstat as lstat, getPathWithExtension, listFunctionsDirectories, listFunctionsDirectory, resolveFunctionsDirectories, safeUnlink, pStat as stat, pWriteFile as writeFile, pReadFile as readFile, mkdirAndWriteFile, };
|
|
21
22
|
export type { FsCache };
|
package/dist/utils/fs.js
CHANGED
|
@@ -8,11 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.readFile = exports.writeFile = exports.stat = exports.safeUnlink = exports.resolveFunctionsDirectories = exports.listFunctionsDirectory = exports.listFunctionsDirectories = exports.getPathWithExtension = exports.lstat = exports.cachedReadFile = exports.cachedReaddir = exports.cachedLstat = void 0;
|
|
15
|
+
exports.mkdirAndWriteFile = exports.readFile = exports.writeFile = exports.stat = exports.safeUnlink = exports.resolveFunctionsDirectories = exports.listFunctionsDirectory = exports.listFunctionsDirectories = exports.getPathWithExtension = exports.lstat = exports.cachedReadFile = exports.cachedReaddir = exports.cachedLstat = void 0;
|
|
13
16
|
const fs_1 = require("fs");
|
|
14
17
|
const path_1 = require("path");
|
|
15
18
|
const util_1 = require("util");
|
|
19
|
+
const make_dir_1 = __importDefault(require("make-dir"));
|
|
16
20
|
const non_nullable_1 = require("./non_nullable");
|
|
17
21
|
const pLstat = (0, util_1.promisify)(fs_1.lstat);
|
|
18
22
|
exports.lstat = pLstat;
|
|
@@ -93,4 +97,12 @@ const resolveFunctionsDirectories = (input) => {
|
|
|
93
97
|
return absoluteDirectories;
|
|
94
98
|
};
|
|
95
99
|
exports.resolveFunctionsDirectories = resolveFunctionsDirectories;
|
|
100
|
+
const mkdirAndWriteFile = (path, ...params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
if (typeof path === 'string') {
|
|
102
|
+
const directory = (0, path_1.dirname)(path);
|
|
103
|
+
yield (0, make_dir_1.default)(directory);
|
|
104
|
+
}
|
|
105
|
+
return pWriteFile(path, ...params);
|
|
106
|
+
});
|
|
107
|
+
exports.mkdirAndWriteFile = mkdirAndWriteFile;
|
|
96
108
|
//# sourceMappingURL=fs.js.map
|
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.0.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": "^3.3.
|
|
96
|
+
"@netlify/eslint-config-node": "^3.3.8",
|
|
98
97
|
"@types/archiver": "^5.1.1",
|
|
99
98
|
"@types/end-of-stream": "^1.4.1",
|
|
100
99
|
"@types/resolve": "^1.20.1",
|
|
@@ -109,13 +108,15 @@
|
|
|
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
|
+
"source-map-support": "^0.5.20",
|
|
114
115
|
"throat": "^6.0.1",
|
|
115
116
|
"typescript": "^4.4.3"
|
|
116
117
|
},
|
|
117
118
|
"engines": {
|
|
118
|
-
"node": ">=
|
|
119
|
+
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
119
120
|
},
|
|
120
121
|
"ava": {
|
|
121
122
|
"files": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'array-flat-polyfill';
|
package/dist/utils/polyfills.js
DELETED