@vercel/nestjs 0.1.3 → 0.1.4
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/index.js +17 -148
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -41,145 +31,24 @@ __export(src_exports, {
|
|
|
41
31
|
module.exports = __toCommonJS(src_exports);
|
|
42
32
|
|
|
43
33
|
// src/build.ts
|
|
44
|
-
var import_build_utils = require("@vercel/build-utils");
|
|
45
34
|
var import_node = require("@vercel/node");
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
...args,
|
|
64
|
-
config: {
|
|
65
|
-
...args.config,
|
|
66
|
-
includeFiles
|
|
67
|
-
},
|
|
68
|
-
// this is package.json, but we'll replace it with the return value of the entrypointCallback
|
|
69
|
-
// after install and build scripts have had a chance to run
|
|
70
|
-
entrypoint: "package.json",
|
|
71
|
-
considerBuildCommand: true,
|
|
72
|
-
entrypointCallback: async () => {
|
|
73
|
-
return entrypointCallback(args);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
res.output.framework = { slug: frameworkName };
|
|
77
|
-
return res;
|
|
78
|
-
};
|
|
79
|
-
var entrypointCallback = async (args) => {
|
|
80
|
-
const mainPackageEntrypoint = findMainPackageEntrypoint(args.files);
|
|
81
|
-
const entrypointGlob = `{${validFilenames.map((entrypoint) => `${entrypoint}`).join(",")}}.{${validExtensions.join(",")}}`;
|
|
82
|
-
const dir = args.config.projectSettings?.outputDirectory?.replace(
|
|
83
|
-
/^\/+|\/+$/g,
|
|
84
|
-
""
|
|
85
|
-
);
|
|
86
|
-
if (dir) {
|
|
87
|
-
const { entrypoint: entrypointFromOutputDir, entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2 } = findEntrypoint(await (0, import_build_utils.glob)(entrypointGlob, (0, import_path.join)(args.workPath, dir)));
|
|
88
|
-
if (entrypointFromOutputDir) {
|
|
89
|
-
return (0, import_path.join)(dir, entrypointFromOutputDir);
|
|
90
|
-
}
|
|
91
|
-
if (entrypointsNotMatchingRegex2.length > 0) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex2.length)}: ${entrypointsNotMatchingRegex2.join(", ")}`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
throw new Error(
|
|
97
|
-
`No entrypoint found in output directory: "${dir}". Searched for:
|
|
98
|
-
${entrypointsForMessage}`
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
const files = await (0, import_build_utils.glob)(entrypointGlob, args.workPath);
|
|
102
|
-
const { entrypoint: entrypointFromRoot, entrypointsNotMatchingRegex } = findEntrypoint(files);
|
|
103
|
-
if (entrypointFromRoot) {
|
|
104
|
-
return entrypointFromRoot;
|
|
105
|
-
}
|
|
106
|
-
if (mainPackageEntrypoint) {
|
|
107
|
-
const entrypointFromPackageJson = await (0, import_build_utils.glob)(
|
|
108
|
-
mainPackageEntrypoint,
|
|
109
|
-
args.workPath
|
|
110
|
-
);
|
|
111
|
-
if (entrypointFromPackageJson[mainPackageEntrypoint]) {
|
|
112
|
-
if (checkMatchesRegex(entrypointFromPackageJson[mainPackageEntrypoint])) {
|
|
113
|
-
return mainPackageEntrypoint;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (entrypointsNotMatchingRegex.length > 0) {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`No entrypoint found which imports ${frameworkName}. Found possible ${pluralize("entrypoint", entrypointsNotMatchingRegex.length)}: ${entrypointsNotMatchingRegex.join(", ")}`
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
throw new Error(
|
|
123
|
-
`No entrypoint found. Searched for:
|
|
124
|
-
${entrypointsForMessage}`
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
function pluralize(word, count) {
|
|
128
|
-
return count === 1 ? word : `${word}s`;
|
|
129
|
-
}
|
|
130
|
-
var findEntrypoint = (files) => {
|
|
131
|
-
const allEntrypoints = validFilenames.flatMap(
|
|
132
|
-
(filename) => validExtensions.map((extension) => `${filename}.${extension}`)
|
|
133
|
-
);
|
|
134
|
-
const possibleEntrypointsInFiles = allEntrypoints.filter((entrypoint2) => {
|
|
135
|
-
return files[entrypoint2] !== void 0;
|
|
136
|
-
});
|
|
137
|
-
const entrypointsMatchingRegex = possibleEntrypointsInFiles.filter(
|
|
138
|
-
(entrypoint2) => {
|
|
139
|
-
const file = files[entrypoint2];
|
|
140
|
-
return checkMatchesRegex(file);
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
const entrypointsNotMatchingRegex = possibleEntrypointsInFiles.filter(
|
|
144
|
-
(entrypoint2) => {
|
|
145
|
-
const file = files[entrypoint2];
|
|
146
|
-
return !checkMatchesRegex(file);
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
const entrypoint = entrypointsMatchingRegex[0];
|
|
150
|
-
if (entrypointsMatchingRegex.length > 1) {
|
|
151
|
-
console.warn(
|
|
152
|
-
`Multiple entrypoints found: ${entrypointsMatchingRegex.join(", ")}. Using ${entrypoint}.`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
entrypoint,
|
|
157
|
-
entrypointsNotMatchingRegex
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
var checkMatchesRegex = (file) => {
|
|
161
|
-
const content = import_fs.default.readFileSync(file.fsPath, "utf-8");
|
|
162
|
-
const matchesContent = content.match(REGEX);
|
|
163
|
-
return matchesContent !== null;
|
|
164
|
-
};
|
|
165
|
-
var findMainPackageEntrypoint = (files) => {
|
|
166
|
-
const packageJson = files["package.json"];
|
|
167
|
-
if (packageJson) {
|
|
168
|
-
if (packageJson.type === "FileFsRef") {
|
|
169
|
-
const packageJsonContent = import_fs.default.readFileSync(packageJson.fsPath, "utf-8");
|
|
170
|
-
let packageJsonJson;
|
|
171
|
-
try {
|
|
172
|
-
packageJsonJson = JSON.parse(packageJsonContent);
|
|
173
|
-
} catch (_e) {
|
|
174
|
-
packageJsonJson = {};
|
|
175
|
-
}
|
|
176
|
-
if ("main" in packageJsonJson && typeof packageJsonJson.main === "string") {
|
|
177
|
-
return packageJsonJson.main;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return null;
|
|
182
|
-
};
|
|
35
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
36
|
+
var { build, entrypointCallback, findEntrypoint, require_ } = (0, import_build_utils.generateNodeBuilderFunctions)(
|
|
37
|
+
"nestjs",
|
|
38
|
+
/(?:from|require|import)\s*(?:\(\s*)?["']@nestjs\/core["']\s*(?:\))?/g,
|
|
39
|
+
[
|
|
40
|
+
"src/main",
|
|
41
|
+
// default, so most common
|
|
42
|
+
"app",
|
|
43
|
+
"index",
|
|
44
|
+
"server",
|
|
45
|
+
"src/app",
|
|
46
|
+
"src/index",
|
|
47
|
+
"src/server"
|
|
48
|
+
],
|
|
49
|
+
["js", "cjs", "mjs", "ts", "cts", "mts"],
|
|
50
|
+
import_node.build
|
|
51
|
+
);
|
|
183
52
|
|
|
184
53
|
// src/index.ts
|
|
185
54
|
var import_node2 = require("@vercel/node");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/nestjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@vercel/static-config": "3.1.2",
|
|
21
|
-
"@vercel/node": "5.3.
|
|
21
|
+
"@vercel/node": "5.3.26"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/jest": "27.5.1",
|
|
25
25
|
"@types/node": "14.18.33",
|
|
26
|
-
"@vercel/build-utils": "12.1.
|
|
26
|
+
"@vercel/build-utils": "12.1.2",
|
|
27
27
|
"execa": "3.2.0",
|
|
28
28
|
"fs-extra": "11.1.0",
|
|
29
29
|
"jest-junit": "16.0.0",
|