@vercel/nestjs
Advanced tools
+17
-148
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -20,10 +18,2 @@ var __export = (target, all) => { | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -45,141 +35,20 @@ | ||
| // src/build.ts | ||
| var import_node = require("@vercel/node"); | ||
| var import_build_utils = require("@vercel/build-utils"); | ||
| var import_node = require("@vercel/node"); | ||
| var import_module = require("module"); | ||
| var import_path = require("path"); | ||
| var import_fs = __toESM(require("fs")); | ||
| var frameworkName = "nestjs"; | ||
| var REGEX = /(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g; | ||
| var validFilenames = ["src/app", "src/main"]; | ||
| var require_ = (0, import_module.createRequire)(__filename); | ||
| var validExtensions = ["js", "cjs", "mjs", "ts", "cts", "mts"]; | ||
| var entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n"); | ||
| var build = async (args) => { | ||
| process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1"; | ||
| const includeFiles = ["views/**/*"]; | ||
| const includeFilesFromConfig = args.config.includeFiles; | ||
| if (includeFilesFromConfig) { | ||
| includeFiles.push(...includeFilesFromConfig); | ||
| } | ||
| const res = await (0, import_node.build)({ | ||
| ...args, | ||
| config: { | ||
| ...args.config, | ||
| includeFiles | ||
| }, | ||
| // this is package.json, but we'll replace it with the return value of the entrypointCallback | ||
| // after install and build scripts have had a chance to run | ||
| entrypoint: "package.json", | ||
| considerBuildCommand: true, | ||
| entrypointCallback: async () => { | ||
| return entrypointCallback(args); | ||
| } | ||
| }); | ||
| res.output.framework = { slug: frameworkName }; | ||
| return res; | ||
| }; | ||
| var entrypointCallback = async (args) => { | ||
| const mainPackageEntrypoint = findMainPackageEntrypoint(args.files); | ||
| const entrypointGlob = `{${validFilenames.map((entrypoint) => `${entrypoint}`).join(",")}}.{${validExtensions.join(",")}}`; | ||
| const dir = args.config.projectSettings?.outputDirectory?.replace( | ||
| /^\/+|\/+$/g, | ||
| "" | ||
| ); | ||
| if (dir) { | ||
| const { entrypoint: entrypointFromOutputDir, entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2 } = findEntrypoint(await (0, import_build_utils.glob)(entrypointGlob, (0, import_path.join)(args.workPath, dir))); | ||
| if (entrypointFromOutputDir) { | ||
| return (0, import_path.join)(dir, entrypointFromOutputDir); | ||
| } | ||
| if (entrypointsNotMatchingRegex2.length > 0) { | ||
| throw new Error( | ||
| `No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex2.length)}: ${entrypointsNotMatchingRegex2.join(", ")}` | ||
| ); | ||
| } | ||
| throw new Error( | ||
| `No entrypoint found in output directory: "${dir}". Searched for: | ||
| ${entrypointsForMessage}` | ||
| ); | ||
| } | ||
| const files = await (0, import_build_utils.glob)(entrypointGlob, args.workPath); | ||
| const { entrypoint: entrypointFromRoot, entrypointsNotMatchingRegex } = findEntrypoint(files); | ||
| if (entrypointFromRoot) { | ||
| return entrypointFromRoot; | ||
| } | ||
| if (mainPackageEntrypoint) { | ||
| const entrypointFromPackageJson = await (0, import_build_utils.glob)( | ||
| mainPackageEntrypoint, | ||
| args.workPath | ||
| ); | ||
| if (entrypointFromPackageJson[mainPackageEntrypoint]) { | ||
| if (checkMatchesRegex(entrypointFromPackageJson[mainPackageEntrypoint])) { | ||
| return mainPackageEntrypoint; | ||
| } | ||
| } | ||
| } | ||
| if (entrypointsNotMatchingRegex.length > 0) { | ||
| throw new Error( | ||
| `No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex.length)}: ${entrypointsNotMatchingRegex.join(", ")}` | ||
| ); | ||
| } | ||
| throw new Error( | ||
| `No entrypoint found. Searched for: | ||
| ${entrypointsForMessage}` | ||
| ); | ||
| }; | ||
| function pluralize(word, count) { | ||
| return count === 1 ? word : `${word}s`; | ||
| } | ||
| var findEntrypoint = (files) => { | ||
| const allEntrypoints = validFilenames.flatMap( | ||
| (filename) => validExtensions.map((extension) => `${filename}.${extension}`) | ||
| ); | ||
| const possibleEntrypointsInFiles = allEntrypoints.filter((entrypoint2) => { | ||
| return files[entrypoint2] !== void 0; | ||
| }); | ||
| const entrypointsMatchingRegex = possibleEntrypointsInFiles.filter( | ||
| (entrypoint2) => { | ||
| const file = files[entrypoint2]; | ||
| return checkMatchesRegex(file); | ||
| } | ||
| ); | ||
| const entrypointsNotMatchingRegex = possibleEntrypointsInFiles.filter( | ||
| (entrypoint2) => { | ||
| const file = files[entrypoint2]; | ||
| return !checkMatchesRegex(file); | ||
| } | ||
| ); | ||
| const entrypoint = entrypointsMatchingRegex[0]; | ||
| if (entrypointsMatchingRegex.length > 1) { | ||
| console.warn( | ||
| `Multiple entrypoints found: ${entrypointsMatchingRegex.join(", ")}. Using ${entrypoint}.` | ||
| ); | ||
| } | ||
| return { | ||
| entrypoint, | ||
| entrypointsNotMatchingRegex | ||
| }; | ||
| }; | ||
| var checkMatchesRegex = (file) => { | ||
| const content = import_fs.default.readFileSync(file.fsPath, "utf-8"); | ||
| const matchesContent = content.match(REGEX); | ||
| return matchesContent !== null; | ||
| }; | ||
| var findMainPackageEntrypoint = (files) => { | ||
| const packageJson = files["package.json"]; | ||
| if (packageJson) { | ||
| if (packageJson.type === "FileFsRef") { | ||
| const packageJsonContent = import_fs.default.readFileSync(packageJson.fsPath, "utf-8"); | ||
| let packageJsonJson; | ||
| try { | ||
| packageJsonJson = JSON.parse(packageJsonContent); | ||
| } catch (_e) { | ||
| packageJsonJson = {}; | ||
| } | ||
| if ("main" in packageJsonJson && typeof packageJsonJson.main === "string") { | ||
| return packageJsonJson.main; | ||
| } | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| var { build, entrypointCallback, findEntrypoint, require_ } = (0, import_build_utils.generateNodeBuilderFunctions)( | ||
| "nestjs", | ||
| /(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g, | ||
| [ | ||
| "src/main", | ||
| // default, so most common | ||
| "app", | ||
| "index", | ||
| "server", | ||
| "src/app", | ||
| "src/index", | ||
| "src/server" | ||
| ], | ||
| ["js", "cjs", "mjs", "ts", "cts", "mts"], | ||
| import_node.build | ||
| ); | ||
@@ -186,0 +55,0 @@ // src/index.ts |
+17
-148
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -20,10 +18,2 @@ var __export = (target, all) => { | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -45,141 +35,20 @@ | ||
| // src/build.ts | ||
| var import_node = require("@vercel/node"); | ||
| var import_build_utils = require("@vercel/build-utils"); | ||
| var import_node = require("@vercel/node"); | ||
| var import_module = require("module"); | ||
| var import_path = require("path"); | ||
| var import_fs = __toESM(require("fs")); | ||
| var frameworkName = "nestjs"; | ||
| var REGEX = /(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g; | ||
| var validFilenames = ["src/app", "src/main"]; | ||
| var require_ = (0, import_module.createRequire)(__filename); | ||
| var validExtensions = ["js", "cjs", "mjs", "ts", "cts", "mts"]; | ||
| var entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n"); | ||
| var build = async (args) => { | ||
| process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1"; | ||
| const includeFiles = ["views/**/*"]; | ||
| const includeFilesFromConfig = args.config.includeFiles; | ||
| if (includeFilesFromConfig) { | ||
| includeFiles.push(...includeFilesFromConfig); | ||
| } | ||
| const res = await (0, import_node.build)({ | ||
| ...args, | ||
| config: { | ||
| ...args.config, | ||
| includeFiles | ||
| }, | ||
| // this is package.json, but we'll replace it with the return value of the entrypointCallback | ||
| // after install and build scripts have had a chance to run | ||
| entrypoint: "package.json", | ||
| considerBuildCommand: true, | ||
| entrypointCallback: async () => { | ||
| return entrypointCallback(args); | ||
| } | ||
| }); | ||
| res.output.framework = { slug: frameworkName }; | ||
| return res; | ||
| }; | ||
| var entrypointCallback = async (args) => { | ||
| const mainPackageEntrypoint = findMainPackageEntrypoint(args.files); | ||
| const entrypointGlob = `{${validFilenames.map((entrypoint) => `${entrypoint}`).join(",")}}.{${validExtensions.join(",")}}`; | ||
| const dir = args.config.projectSettings?.outputDirectory?.replace( | ||
| /^\/+|\/+$/g, | ||
| "" | ||
| ); | ||
| if (dir) { | ||
| const { entrypoint: entrypointFromOutputDir, entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2 } = findEntrypoint(await (0, import_build_utils.glob)(entrypointGlob, (0, import_path.join)(args.workPath, dir))); | ||
| if (entrypointFromOutputDir) { | ||
| return (0, import_path.join)(dir, entrypointFromOutputDir); | ||
| } | ||
| if (entrypointsNotMatchingRegex2.length > 0) { | ||
| throw new Error( | ||
| `No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex2.length)}: ${entrypointsNotMatchingRegex2.join(", ")}` | ||
| ); | ||
| } | ||
| throw new Error( | ||
| `No entrypoint found in output directory: "${dir}". Searched for: | ||
| ${entrypointsForMessage}` | ||
| ); | ||
| } | ||
| const files = await (0, import_build_utils.glob)(entrypointGlob, args.workPath); | ||
| const { entrypoint: entrypointFromRoot, entrypointsNotMatchingRegex } = findEntrypoint(files); | ||
| if (entrypointFromRoot) { | ||
| return entrypointFromRoot; | ||
| } | ||
| if (mainPackageEntrypoint) { | ||
| const entrypointFromPackageJson = await (0, import_build_utils.glob)( | ||
| mainPackageEntrypoint, | ||
| args.workPath | ||
| ); | ||
| if (entrypointFromPackageJson[mainPackageEntrypoint]) { | ||
| if (checkMatchesRegex(entrypointFromPackageJson[mainPackageEntrypoint])) { | ||
| return mainPackageEntrypoint; | ||
| } | ||
| } | ||
| } | ||
| if (entrypointsNotMatchingRegex.length > 0) { | ||
| throw new Error( | ||
| `No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex.length)}: ${entrypointsNotMatchingRegex.join(", ")}` | ||
| ); | ||
| } | ||
| throw new Error( | ||
| `No entrypoint found. Searched for: | ||
| ${entrypointsForMessage}` | ||
| ); | ||
| }; | ||
| function pluralize(word, count) { | ||
| return count === 1 ? word : `${word}s`; | ||
| } | ||
| var findEntrypoint = (files) => { | ||
| const allEntrypoints = validFilenames.flatMap( | ||
| (filename) => validExtensions.map((extension) => `${filename}.${extension}`) | ||
| ); | ||
| const possibleEntrypointsInFiles = allEntrypoints.filter((entrypoint2) => { | ||
| return files[entrypoint2] !== void 0; | ||
| }); | ||
| const entrypointsMatchingRegex = possibleEntrypointsInFiles.filter( | ||
| (entrypoint2) => { | ||
| const file = files[entrypoint2]; | ||
| return checkMatchesRegex(file); | ||
| } | ||
| ); | ||
| const entrypointsNotMatchingRegex = possibleEntrypointsInFiles.filter( | ||
| (entrypoint2) => { | ||
| const file = files[entrypoint2]; | ||
| return !checkMatchesRegex(file); | ||
| } | ||
| ); | ||
| const entrypoint = entrypointsMatchingRegex[0]; | ||
| if (entrypointsMatchingRegex.length > 1) { | ||
| console.warn( | ||
| `Multiple entrypoints found: ${entrypointsMatchingRegex.join(", ")}. Using ${entrypoint}.` | ||
| ); | ||
| } | ||
| return { | ||
| entrypoint, | ||
| entrypointsNotMatchingRegex | ||
| }; | ||
| }; | ||
| var checkMatchesRegex = (file) => { | ||
| const content = import_fs.default.readFileSync(file.fsPath, "utf-8"); | ||
| const matchesContent = content.match(REGEX); | ||
| return matchesContent !== null; | ||
| }; | ||
| var findMainPackageEntrypoint = (files) => { | ||
| const packageJson = files["package.json"]; | ||
| if (packageJson) { | ||
| if (packageJson.type === "FileFsRef") { | ||
| const packageJsonContent = import_fs.default.readFileSync(packageJson.fsPath, "utf-8"); | ||
| let packageJsonJson; | ||
| try { | ||
| packageJsonJson = JSON.parse(packageJsonContent); | ||
| } catch (_e) { | ||
| packageJsonJson = {}; | ||
| } | ||
| if ("main" in packageJsonJson && typeof packageJsonJson.main === "string") { | ||
| return packageJsonJson.main; | ||
| } | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| var { build, entrypointCallback, findEntrypoint, require_ } = (0, import_build_utils.generateNodeBuilderFunctions)( | ||
| "nestjs", | ||
| /(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g, | ||
| [ | ||
| "src/main", | ||
| // default, so most common | ||
| "app", | ||
| "index", | ||
| "server", | ||
| "src/app", | ||
| "src/index", | ||
| "src/server" | ||
| ], | ||
| ["js", "cjs", "mjs", "ts", "cts", "mts"], | ||
| import_node.build | ||
| ); | ||
@@ -186,0 +55,0 @@ // src/index.ts |
+3
-3
| { | ||
| "name": "@vercel/nestjs", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "license": "Apache-2.0", | ||
@@ -21,3 +21,3 @@ "main": "./dist/index.js", | ||
| "@vercel/static-config": "3.1.2", | ||
| "@vercel/node": "5.3.25" | ||
| "@vercel/node": "5.3.26" | ||
| }, | ||
@@ -27,3 +27,3 @@ "devDependencies": { | ||
| "@types/node": "14.18.33", | ||
| "@vercel/build-utils": "12.1.1", | ||
| "@vercel/build-utils": "12.1.2", | ||
| "execa": "3.2.0", | ||
@@ -30,0 +30,0 @@ "fs-extra": "11.1.0", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
-75%17049
-38.33%154
-62.98%1
Infinity%+ Added
+ Added
- Removed
- Removed
Updated