From 5aaf9155ef21966bffc624f0e66cad4e23b6d14d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 12:06:11 +0000 Subject: [PATCH] fix(deps): update dependency minimatch to v5 (#1032) * fix(deps): update dependency minimatch to v5 * chore(deps): update glob to v8 * refactor: wrap glob and minimatch to support windows paths * refactor: ensure exclude patterns are unix paths Also rename `exclude` to `excludePatterns` to clarify these are not os paths Co-authored-by: Renovate Bot Co-authored-by: Daniel Tschinder <231804+danez@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- package-lock.json | 453 ++++++++++++++++-- package.json | 6 +- src/config.ts | 2 +- .../esbuild/plugin_dynamic_imports.ts | 4 +- .../node/bundlers/esbuild/src_files.ts | 6 +- src/runtimes/node/bundlers/nft/index.ts | 19 +- src/runtimes/node/bundlers/zisi/published.ts | 8 +- src/runtimes/node/bundlers/zisi/src_files.ts | 6 +- src/runtimes/node/bundlers/zisi/tree_files.ts | 9 +- src/runtimes/node/utils/included_files.ts | 34 +- src/utils/matching.ts | 29 ++ 11 files changed, 480 insertions(+), 96 deletions(-) create mode 100644 src/utils/matching.ts diff --git a/package-lock.json b/package-lock.json index d45fc319d..f23d38f4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,12 +22,13 @@ "execa": "^5.0.0", "filter-obj": "^2.0.1", "find-up": "^5.0.0", - "glob": "^7.1.6", + "glob": "^8.0.3", "is-builtin-module": "^3.1.0", "junk": "^3.1.0", "locate-path": "^6.0.0", "merge-options": "^3.0.4", - "minimatch": "^4.0.0", + "minimatch": "^5.0.0", + "normalize-path": "^3.0.0", "p-map": "^4.0.0", "path-exists": "^4.0.0", "pkg-dir": "^5.0.0", @@ -49,6 +50,7 @@ "@netlify/eslint-config-node": "^6.0.0", "@types/archiver": "^5.1.1", "@types/end-of-stream": "^1.4.1", + "@types/normalize-path": "^3.0.0", "@types/resolve": "^1.20.1", "@types/semver": "^7.3.8", "@types/unixify": "^1.0.0", @@ -1686,6 +1688,12 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, + "node_modules/@types/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-Nd8y/5t/7CRakPYiyPzr/IAfYusy1FkcZYFEAcoMZkwpJv2n4Wm+olW+e7xBdHEXhOnWdG9ddbar0gqZWS4x5Q==", + "dev": true + }, "node_modules/@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -1941,6 +1949,36 @@ "nft": "out/cli.js" } }, + "node_modules/@vercel/nft/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@vercel/nft/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -2101,11 +2139,41 @@ "node": ">= 6" } }, + "node_modules/archiver-utils/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/archiver-utils/node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, + "node_modules/archiver-utils/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/archiver-utils/node_modules/readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -3643,6 +3711,26 @@ "node": ">=0.10.0" } }, + "node_modules/cpy/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/cpy/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -3750,6 +3838,18 @@ "node": ">=0.10.0" } }, + "node_modules/cpy/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/cpy/node_modules/p-event": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/p-event/-/p-event-4.2.0.tgz", @@ -4828,6 +4928,38 @@ "eslint-plugin-import": "*" } }, + "node_modules/eslint-import-resolver-typescript/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/eslint-import-resolver-typescript/node_modules/resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", @@ -6270,19 +6402,18 @@ } }, "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": "*" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -6305,17 +6436,6 @@ "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", "dev": true }, - "node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", @@ -7894,16 +8014,24 @@ } }, "node_modules/minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" }, "engines": { "node": ">=10" } }, + "node_modules/minimatch/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", @@ -8217,6 +8345,25 @@ "wide-align": "^1.1.0" } }, + "node_modules/node-pre-gyp/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/node-pre-gyp/node_modules/is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", @@ -8233,6 +8380,17 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, + "node_modules/node-pre-gyp/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/node-pre-gyp/node_modules/minipass": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", @@ -9162,7 +9320,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "engines": { "node": ">=0.10.0" } @@ -10124,6 +10282,36 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -11124,6 +11312,26 @@ "node": ">=8" } }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/test-exclude/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -13107,6 +13315,12 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, + "@types/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-Nd8y/5t/7CRakPYiyPzr/IAfYusy1FkcZYFEAcoMZkwpJv2n4Wm+olW+e7xBdHEXhOnWdG9ddbar0gqZWS4x5Q==", + "dev": true + }, "@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -13267,6 +13481,29 @@ "node-pre-gyp": "^0.13.0", "resolve-from": "^5.0.0", "rollup-pluginutils": "^2.8.2" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + } } }, "abbrev": { @@ -13386,11 +13623,32 @@ "readable-stream": "^2.0.0" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -14527,6 +14785,20 @@ } } }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -14617,6 +14889,15 @@ "to-regex": "^3.0.2" } }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "p-event": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/p-event/-/p-event-4.2.0.tgz", @@ -15523,6 +15804,29 @@ "tsconfig-paths": "^3.14.1" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", @@ -16490,26 +16794,15 @@ } }, "glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "dependencies": { - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "requires": { - "brace-expansion": "^1.1.7" - } - } + "minimatch": "^5.0.1", + "once": "^1.3.0" } }, "glob-parent": { @@ -17656,11 +17949,21 @@ "dev": true }, "minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "requires": { + "balanced-match": "^1.0.0" + } + } } }, "minimist": { @@ -17908,6 +18211,19 @@ "wide-align": "^1.1.0" } }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", @@ -17921,6 +18237,14 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, "minipass": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", @@ -18622,7 +18946,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" }, "path-key": { "version": "3.1.1", @@ -19300,6 +19624,29 @@ "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "requires": { "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + } } }, "rollup-pluginutils": { @@ -20082,6 +20429,20 @@ "minimatch": "^3.0.4" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", diff --git a/package.json b/package.json index e4d951d25..421a02bfd 100644 --- a/package.json +++ b/package.json @@ -65,12 +65,13 @@ "execa": "^5.0.0", "filter-obj": "^2.0.1", "find-up": "^5.0.0", - "glob": "^7.1.6", + "glob": "^8.0.3", "is-builtin-module": "^3.1.0", "junk": "^3.1.0", "locate-path": "^6.0.0", "merge-options": "^3.0.4", - "minimatch": "^4.0.0", + "minimatch": "^5.0.0", + "normalize-path": "^3.0.0", "p-map": "^4.0.0", "path-exists": "^4.0.0", "pkg-dir": "^5.0.0", @@ -89,6 +90,7 @@ "@netlify/eslint-config-node": "^6.0.0", "@types/archiver": "^5.1.1", "@types/end-of-stream": "^1.4.1", + "@types/normalize-path": "^3.0.0", "@types/resolve": "^1.20.1", "@types/semver": "^7.3.8", "@types/unixify": "^1.0.0", diff --git a/src/config.ts b/src/config.ts index 03a1e8157..263175c2e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,9 +1,9 @@ import mergeOptions from 'merge-options' -import minimatch from 'minimatch' import { FunctionSource } from './function.js' import type { NodeBundlerName } from './runtimes/node/bundlers/index.js' import type { NodeVersionString } from './runtimes/node/index.js' +import { minimatch } from './utils/matching.js' export interface FunctionConfig { externalNodeModules?: string[] diff --git a/src/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.ts b/src/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.ts index 49e17f8c6..c691fc557 100644 --- a/src/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.ts +++ b/src/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.ts @@ -2,8 +2,8 @@ import { basename, join, relative } from 'path' import type { Plugin } from '@netlify/esbuild' import findUp from 'find-up' +import normalizePath from 'normalize-path' import readPackageJson from 'read-package-json-fast' -import unixify from 'unixify' import { parseExpression } from '../../parser/index.js' @@ -125,7 +125,7 @@ const getShimContents = ({ // relative to the main bundle file, since esbuild will flatten everything // into a single file. const relativeResolveDir = relative(srcDir, resolveDir) - const requireArg = relativeResolveDir ? `\`./${unixify(relativeResolveDir)}/$\{args}\`` : 'args' + const requireArg = relativeResolveDir ? `\`./${normalizePath(relativeResolveDir)}/$\{args}\`` : 'args' if (expressionType === 'require') { return `module.exports = args => require(${requireArg})` diff --git a/src/runtimes/node/bundlers/esbuild/src_files.ts b/src/runtimes/node/bundlers/esbuild/src_files.ts index 323b2d2ee..aae90c2aa 100644 --- a/src/runtimes/node/bundlers/esbuild/src_files.ts +++ b/src/runtimes/node/bundlers/esbuild/src_files.ts @@ -6,7 +6,7 @@ import { getDependencyPathsForDependency } from '../zisi/traverse.js' export const getSrcFiles: GetSrcFilesFunction = async ({ config, mainFile, pluginsModulesPath, srcDir }) => { const { externalNodeModules = [], includedFiles = [], includedFilesBasePath } = config - const { exclude: excludedPaths, paths: includedFilePaths } = await getPathsOfIncludedFiles( + const { excludePatterns, paths: includedFilePaths } = await getPathsOfIncludedFiles( includedFiles, includedFilesBasePath, ) @@ -15,8 +15,8 @@ export const getSrcFiles: GetSrcFilesFunction = async ({ config, mainFile, plugi basedir: srcDir, pluginsModulesPath, }) - const srcFiles = filterExcludedPaths(dependencyPaths, excludedPaths) - const includedPaths = filterExcludedPaths(includedFilePaths, excludedPaths) + const srcFiles = filterExcludedPaths(dependencyPaths, excludePatterns) + const includedPaths = filterExcludedPaths(includedFilePaths, excludePatterns) return { srcFiles: [...srcFiles, ...includedPaths, mainFile], diff --git a/src/runtimes/node/bundlers/nft/index.ts b/src/runtimes/node/bundlers/nft/index.ts index 994f6b1ce..1d85715bf 100644 --- a/src/runtimes/node/bundlers/nft/index.ts +++ b/src/runtimes/node/bundlers/nft/index.ts @@ -2,12 +2,11 @@ import { basename, dirname, join, normalize, resolve } from 'path' import { nodeFileTrace } from '@vercel/nft' import resolveDependency from '@vercel/nft/out/resolve-dependency.js' -import minimatch from 'minimatch' -import unixify from 'unixify' import type { FunctionConfig } from '../../../../config.js' import { FeatureFlags } from '../../../../feature_flags.js' import { cachedReadFile, FsCache } from '../../../../utils/fs.js' +import { minimatch } from '../../../../utils/matching.js' import { getBasePath } from '../../utils/base_path.js' import { filterExcludedPaths, getPathsOfIncludedFiles } from '../../utils/included_files.js' import type { GetSrcFilesFunction, BundleFunction } from '../index.js' @@ -29,7 +28,7 @@ const bundle: BundleFunction = async ({ repositoryRoot = basePath, }) => { const { includedFiles = [], includedFilesBasePath } = config - const { exclude: excludedPaths, paths: includedFilePaths } = await getPathsOfIncludedFiles( + const { excludePatterns, paths: includedFilePaths } = await getPathsOfIncludedFiles( includedFiles, includedFilesBasePath || basePath, ) @@ -45,7 +44,8 @@ const bundle: BundleFunction = async ({ pluginsModulesPath, name, }) - const filteredIncludedPaths = filterExcludedPaths([...dependencyPaths, ...includedFilePaths], excludedPaths) + const includedPaths = filterExcludedPaths(includedFilePaths, excludePatterns) + const filteredIncludedPaths = [...filterExcludedPaths(dependencyPaths, excludePatterns), ...includedPaths] const dirnames = filteredIncludedPaths.map((filePath) => normalize(dirname(filePath))).sort() // Sorting the array to make the checksum deterministic. @@ -53,7 +53,7 @@ const bundle: BundleFunction = async ({ return { basePath: getBasePath(dirnames), - includedFiles: filterExcludedPaths(includedFilePaths, excludedPaths), + includedFiles: includedPaths, inputs: dependencyPaths, mainFile, moduleFormat, @@ -63,8 +63,7 @@ const bundle: BundleFunction = async ({ } const ignoreFunction = (path: string) => { - const normalizedPath = unixify(path) - const shouldIgnore = ignore.some((expression) => minimatch(normalizedPath, expression)) + const shouldIgnore = ignore.some((expression) => minimatch(path, expression)) return shouldIgnore } @@ -145,7 +144,7 @@ const traceFilesAndTranspile = async function ({ const getSrcFiles: GetSrcFilesFunction = async function ({ basePath, config, mainFile }) { const { includedFiles = [], includedFilesBasePath } = config - const { exclude: excludedPaths, paths: includedFilePaths } = await getPathsOfIncludedFiles( + const { excludePatterns, paths: includedFilePaths } = await getPathsOfIncludedFiles( includedFiles, includedFilesBasePath, ) @@ -153,8 +152,8 @@ const getSrcFiles: GetSrcFilesFunction = async function ({ basePath, config, mai const normalizedDependencyPaths = [...dependencyPaths].map((path) => basePath ? resolve(basePath, path) : resolve(path), ) - const srcFiles = filterExcludedPaths(normalizedDependencyPaths, excludedPaths) - const includedPaths = filterExcludedPaths(includedFilePaths, excludedPaths) + const srcFiles = filterExcludedPaths(normalizedDependencyPaths, excludePatterns) + const includedPaths = filterExcludedPaths(includedFilePaths, excludePatterns) return { srcFiles: [...srcFiles, ...includedPaths], diff --git a/src/runtimes/node/bundlers/zisi/published.ts b/src/runtimes/node/bundlers/zisi/published.ts index a6e04e5e1..c87ff6952 100644 --- a/src/runtimes/node/bundlers/zisi/published.ts +++ b/src/runtimes/node/bundlers/zisi/published.ts @@ -1,13 +1,9 @@ -import { promisify } from 'util' - -import glob from 'glob' - -const pGlob = promisify(glob) +import { glob } from '../../../../utils/matching' // We use all the files published by the Node.js except some that are not needed export const getPublishedFiles = async function (modulePath: string): Promise { const ignore = getIgnoredFiles(modulePath) - const publishedFiles = await pGlob(`${modulePath}/**`, { + const publishedFiles = await glob(`${modulePath}/**`, { ignore, nodir: true, absolute: true, diff --git a/src/runtimes/node/bundlers/zisi/src_files.ts b/src/runtimes/node/bundlers/zisi/src_files.ts index b6da56579..93045983f 100644 --- a/src/runtimes/node/bundlers/zisi/src_files.ts +++ b/src/runtimes/node/bundlers/zisi/src_files.ts @@ -31,7 +31,7 @@ export const getSrcFiles: GetSrcFilesFunction = async function ({ stat, }) { const { includedFiles = [], includedFilesBasePath } = config - const { exclude: excludedPaths, paths: includedFilePaths } = await getPathsOfIncludedFiles( + const { excludePatterns, paths: includedFilePaths } = await getPathsOfIncludedFiles( includedFiles, includedFilesBasePath, ) @@ -45,8 +45,8 @@ export const getSrcFiles: GetSrcFilesFunction = async function ({ // We sort so that the archive's checksum is deterministic. // Mutating is fine since `Array.filter()` returns a shallow copy const filteredFiles = uniqueFiles.filter(isNotJunk).sort() - const srcFiles = filterExcludedPaths(filteredFiles, excludedPaths) - const includedPaths = filterExcludedPaths(includedFilePaths, excludedPaths) + const srcFiles = filterExcludedPaths(filteredFiles, excludePatterns) + const includedPaths = filterExcludedPaths(includedFilePaths, excludePatterns) return { srcFiles: [...srcFiles, ...includedPaths], includedFiles: includedPaths } } diff --git a/src/runtimes/node/bundlers/zisi/tree_files.ts b/src/runtimes/node/bundlers/zisi/tree_files.ts index 7c0705a55..4d24fefd7 100644 --- a/src/runtimes/node/bundlers/zisi/tree_files.ts +++ b/src/runtimes/node/bundlers/zisi/tree_files.ts @@ -1,9 +1,6 @@ -import { Stats } from 'fs' -import { promisify } from 'util' +import type { Stats } from 'fs' -import glob from 'glob' - -const pGlob = promisify(glob) +import { glob } from '../../../../utils/matching' // When using a directory, we include all its descendants except `node_modules` export const getTreeFiles = async function (srcPath: string, stat: Stats): Promise { @@ -11,7 +8,7 @@ export const getTreeFiles = async function (srcPath: string, stat: Stats): Promi return [srcPath] } - return await pGlob(`${srcPath}/**`, { + return await glob(`${srcPath}/**`, { ignore: `${srcPath}/**/node_modules/**`, nodir: true, absolute: true, diff --git a/src/runtimes/node/utils/included_files.ts b/src/runtimes/node/utils/included_files.ts index a5b1942c8..67e462c29 100644 --- a/src/runtimes/node/utils/included_files.ts +++ b/src/runtimes/node/utils/included_files.ts @@ -1,19 +1,15 @@ import { normalize, resolve } from 'path' -import { promisify } from 'util' -import glob from 'glob' -import minimatch from 'minimatch' - -const pGlob = promisify(glob) +import { minimatch, glob } from '../../../utils/matching' // Returns the subset of `paths` that don't match any of the glob expressions // from `exclude`. -export const filterExcludedPaths = (paths: string[], exclude: string[] = []) => { - if (exclude.length === 0) { +export const filterExcludedPaths = (paths: string[], excludePattern: string[] = []) => { + if (excludePattern.length === 0) { return paths } - const excludedPaths = paths.filter((path) => !exclude.some((pattern) => minimatch(path, pattern))) + const excludedPaths = paths.filter((path) => !excludePattern.some((pattern) => minimatch(path, pattern))) return excludedPaths } @@ -21,35 +17,39 @@ export const filterExcludedPaths = (paths: string[], exclude: string[] = []) => export const getPathsOfIncludedFiles = async ( includedFiles: string[], basePath?: string, -): Promise<{ exclude: string[]; paths: string[] }> => { +): Promise<{ excludePatterns: string[]; paths: string[] }> => { if (basePath === undefined) { - return { exclude: [], paths: [] } + return { excludePatterns: [], paths: [] } } // Some of the globs in `includedFiles` might be exclusion patterns, which // means paths that should NOT be included in the bundle. We need to treat // these differently, so we iterate on the array and put those paths in a // `exclude` array and the rest of the paths in an `include` array. - const { include, exclude } = includedFiles.reduce<{ include: string[]; exclude: string[] }>( + const { include, excludePatterns } = includedFiles.reduce<{ include: string[]; excludePatterns: string[] }>( (acc, path) => { if (path.startsWith('!')) { - const excludePath = resolve(basePath, path.slice(1)) + // convert to unix paths, as minimatch does not support windows paths in patterns + const excludePattern = resolve(basePath, path.slice(1)) return { include: acc.include, - exclude: [...acc.exclude, excludePath], + excludePatterns: [...acc.excludePatterns, excludePattern], } } return { include: [...acc.include, path], - exclude: acc.exclude, + excludePatterns: acc.excludePatterns, } }, - { include: [], exclude: [] }, + { include: [], excludePatterns: [] }, ) + const pathGroups = await Promise.all( - include.map((expression) => pGlob(expression, { absolute: true, cwd: basePath, ignore: exclude, nodir: true })), + include.map((expression) => + glob(expression, { absolute: true, cwd: basePath, ignore: excludePatterns, nodir: true }), + ), ) // `pathGroups` is an array containing the paths for each expression in the @@ -57,5 +57,5 @@ export const getPathsOfIncludedFiles = async ( const paths = pathGroups.flat() const normalizedPaths = paths.map(normalize) - return { exclude, paths: [...new Set(normalizedPaths)] } + return { excludePatterns, paths: [...new Set(normalizedPaths)] } } diff --git a/src/utils/matching.ts b/src/utils/matching.ts new file mode 100644 index 000000000..7ac10bb52 --- /dev/null +++ b/src/utils/matching.ts @@ -0,0 +1,29 @@ +import { promisify } from 'util' + +import globFunction from 'glob' +import minimatchFunction from 'minimatch' +import normalizePath from 'normalize-path' + +const pGlob = promisify(globFunction) + +/** + * Both glob and minimatch only support unix style slashes in patterns + * For this reason we wrap them and ensure all patters are always unixified + * We use `normalize-path` here instead of `unixify` because we do not want to remove drive letters + */ + +export const glob = function (pattern: string, options: globFunction.IOptions): Promise { + let normalizedIgnore + if (options.ignore) { + normalizedIgnore = + typeof options.ignore === 'string' + ? normalizePath(options.ignore) + : options.ignore.map((expression) => normalizePath(expression)) + } + + return pGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore }) +} + +export const minimatch = function (target: string, pattern: string, options?: minimatchFunction.IOptions): boolean { + return minimatchFunction(target, normalizePath(pattern), options) +}