@vercel/fs-detectors 7.7.3 → 7.8.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/detect-framework.d.ts +1 -0
- package/dist/detect-framework.js +46 -29
- package/package.json +6 -6
package/dist/detect-framework.js
CHANGED
|
@@ -63,7 +63,8 @@ async function matches(fs, framework) {
|
|
|
63
63
|
const check = async ({
|
|
64
64
|
path,
|
|
65
65
|
matchContent,
|
|
66
|
-
matchPackage
|
|
66
|
+
matchPackage,
|
|
67
|
+
fallback = false
|
|
67
68
|
}) => {
|
|
68
69
|
if (matchPackage && matchContent) {
|
|
69
70
|
throw new Error(
|
|
@@ -102,12 +103,14 @@ async function matches(fs, framework) {
|
|
|
102
103
|
if (matchPackage && match[3]) {
|
|
103
104
|
return {
|
|
104
105
|
framework,
|
|
105
|
-
detectedVersion: match[3]
|
|
106
|
+
detectedVersion: match[3],
|
|
107
|
+
fallback
|
|
106
108
|
};
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
return {
|
|
110
|
-
framework
|
|
112
|
+
framework,
|
|
113
|
+
fallback
|
|
111
114
|
};
|
|
112
115
|
};
|
|
113
116
|
const result = [];
|
|
@@ -134,7 +137,8 @@ async function matches(fs, framework) {
|
|
|
134
137
|
)?.detectedVersion;
|
|
135
138
|
return {
|
|
136
139
|
framework,
|
|
137
|
-
detectedVersion
|
|
140
|
+
detectedVersion,
|
|
141
|
+
fallback: result.some((match) => match?.fallback)
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
144
|
function removeSupersededFramework(matches2, slug) {
|
|
@@ -158,6 +162,31 @@ function removeSupersededFrameworks(matches2) {
|
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
}
|
|
165
|
+
function orderFrameworkMatches(matches2) {
|
|
166
|
+
const normalMatches = matches2.filter(
|
|
167
|
+
(match) => Boolean(match && !match.fallback)
|
|
168
|
+
);
|
|
169
|
+
const fallbackMatches = matches2.filter(
|
|
170
|
+
(match) => Boolean(match?.fallback)
|
|
171
|
+
);
|
|
172
|
+
const normalFrameworks = normalMatches.map((match) => match.framework);
|
|
173
|
+
removeSupersededFrameworks(normalFrameworks);
|
|
174
|
+
const fallbackFrameworks = fallbackMatches.map((match) => match.framework);
|
|
175
|
+
for (const framework of normalFrameworks) {
|
|
176
|
+
for (const slug of framework.supersedes ?? []) {
|
|
177
|
+
removeSupersededFramework(fallbackFrameworks, slug);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
removeSupersededFrameworks(fallbackFrameworks);
|
|
181
|
+
return [
|
|
182
|
+
...normalMatches.filter(
|
|
183
|
+
(match) => normalFrameworks.includes(match.framework)
|
|
184
|
+
),
|
|
185
|
+
...fallbackMatches.filter(
|
|
186
|
+
(match) => fallbackFrameworks.includes(match.framework)
|
|
187
|
+
)
|
|
188
|
+
];
|
|
189
|
+
}
|
|
161
190
|
async function detectFramework({
|
|
162
191
|
fs,
|
|
163
192
|
frameworkList,
|
|
@@ -168,15 +197,12 @@ async function detectFramework({
|
|
|
168
197
|
useExperimentalFrameworks
|
|
169
198
|
);
|
|
170
199
|
const result = await Promise.all(
|
|
171
|
-
filteredList.map(async (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
return null;
|
|
200
|
+
filteredList.map(async (framework) => {
|
|
201
|
+
const match = await matches(fs, framework);
|
|
202
|
+
return match ? { ...match, framework } : null;
|
|
176
203
|
})
|
|
177
204
|
);
|
|
178
|
-
|
|
179
|
-
return result.find((res) => res !== null)?.slug ?? null;
|
|
205
|
+
return orderFrameworkMatches(result)[0]?.framework.slug ?? null;
|
|
180
206
|
}
|
|
181
207
|
async function detectFrameworks({
|
|
182
208
|
fs,
|
|
@@ -188,15 +214,12 @@ async function detectFrameworks({
|
|
|
188
214
|
useExperimentalFrameworks
|
|
189
215
|
);
|
|
190
216
|
const result = await Promise.all(
|
|
191
|
-
filteredList.map(async (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
217
|
+
filteredList.map(async (framework) => {
|
|
218
|
+
const match = await matches(fs, framework);
|
|
219
|
+
return match ? { ...match, framework } : null;
|
|
196
220
|
})
|
|
197
221
|
);
|
|
198
|
-
|
|
199
|
-
return result.filter((res) => res !== null);
|
|
222
|
+
return orderFrameworkMatches(result).map((match) => match.framework);
|
|
200
223
|
}
|
|
201
224
|
async function detectFrameworkRecord({
|
|
202
225
|
fs,
|
|
@@ -208,19 +231,13 @@ async function detectFrameworkRecord({
|
|
|
208
231
|
useExperimentalFrameworks
|
|
209
232
|
);
|
|
210
233
|
const result = await Promise.all(
|
|
211
|
-
filteredList.map(async (
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
...frameworkMatch,
|
|
216
|
-
detectedVersion: matchResult?.detectedVersion
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
return null;
|
|
234
|
+
filteredList.map(async (framework) => {
|
|
235
|
+
const match2 = await matches(fs, framework);
|
|
236
|
+
return match2 ? { ...match2, framework } : null;
|
|
220
237
|
})
|
|
221
238
|
);
|
|
222
|
-
|
|
223
|
-
return
|
|
239
|
+
const match = orderFrameworkMatches(result)[0];
|
|
240
|
+
return match ? { ...match.framework, detectedVersion: match.detectedVersion } : null;
|
|
224
241
|
}
|
|
225
242
|
function detectFrameworkVersion(frameworkRecord) {
|
|
226
243
|
const allDetectors = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/fs-detectors",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "Vercel filesystem detectors",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"minimatch": "3.1.2",
|
|
21
21
|
"semver": "6.3.1",
|
|
22
22
|
"smol-toml": "1.5.2",
|
|
23
|
-
"@vercel/build-utils": "14.13.
|
|
24
|
-
"@vercel/
|
|
25
|
-
"@vercel/frameworks": "3.34.0",
|
|
23
|
+
"@vercel/build-utils": "14.13.2",
|
|
24
|
+
"@vercel/frameworks": "3.35.0",
|
|
26
25
|
"@vercel/python-analysis": "0.14.0",
|
|
27
|
-
"@vercel/routing-utils": "6.6.0"
|
|
26
|
+
"@vercel/routing-utils": "6.6.0",
|
|
27
|
+
"@vercel/error-utils": "2.2.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/glob": "7.2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/node": "20.11.0",
|
|
34
34
|
"@types/semver": "7.3.10",
|
|
35
35
|
"vitest": "4.1.10",
|
|
36
|
-
"@vercel-internals/runtimes": "1.1.
|
|
36
|
+
"@vercel-internals/runtimes": "1.1.6"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node build.mjs",
|