@vercel/fs-detectors 5.3.11 → 5.4.1

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.
@@ -0,0 +1,5 @@
1
+ import { DetectorFilesystem } from './detectors/filesystem';
2
+ /**
3
+ * Detects if any OpenTelemetry dependencies are used and if they meet the required versions
4
+ */
5
+ export declare function detectInstrumentation(fs: DetectorFilesystem): Promise<boolean>;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var detect_instrumentation_exports = {};
30
+ __export(detect_instrumentation_exports, {
31
+ detectInstrumentation: () => detectInstrumentation
32
+ });
33
+ module.exports = __toCommonJS(detect_instrumentation_exports);
34
+ var import_semver = __toESM(require("semver"));
35
+ const VERCEL_OTEL = "@vercel/otel";
36
+ const OPENTELEMETRY_SDK_TRACE_NODE = "@opentelemetry/sdk-trace-node";
37
+ const OPENTELEMETRY_API = "@opentelemetry/api";
38
+ const tracingDependencies = [
39
+ { name: VERCEL_OTEL, minVersion: "1.11.0" },
40
+ { name: OPENTELEMETRY_SDK_TRACE_NODE, minVersion: "1.19.0" },
41
+ { name: OPENTELEMETRY_API, minVersion: "1.7.0" }
42
+ ];
43
+ async function detectInstrumentation(fs) {
44
+ if (await fs.hasPath("package.json") === false) {
45
+ return false;
46
+ }
47
+ if (await fs.isFile("package.json") === false) {
48
+ return false;
49
+ }
50
+ const content = await fs.readFile("package.json");
51
+ const packageJsonContent = content.toString();
52
+ let hasInstrumentation = false;
53
+ for (const dependency of tracingDependencies) {
54
+ const regex = new RegExp(
55
+ `"(dev)?(d|D)ependencies":\\s*{[^}]*"${dependency.name}":\\s*"(.+?)"[^}]*}`,
56
+ "m"
57
+ );
58
+ const match = packageJsonContent.match(regex);
59
+ if (match && match[3]) {
60
+ const detectedVersion = match[3];
61
+ const cleanVersion = detectedVersion.replace(/[\^~]/, "");
62
+ if (import_semver.default.valid(cleanVersion) && import_semver.default.gte(cleanVersion, dependency.minVersion)) {
63
+ console.log(
64
+ `Detected OpenTelemetry dependency: ${dependency.name}@${cleanVersion}, which meets the minimum version requirement of ${dependency.minVersion}`
65
+ );
66
+ hasInstrumentation = true;
67
+ break;
68
+ }
69
+ }
70
+ }
71
+ return hasInstrumentation;
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ detectInstrumentation
76
+ });
package/dist/index.d.ts CHANGED
@@ -12,3 +12,4 @@ export { isOfficialRuntime, isStaticRuntime } from './is-official-runtime';
12
12
  export { packageManagers } from './package-managers/package-managers';
13
13
  export * from './monorepos/get-monorepo-default-settings';
14
14
  export { REGEX_NON_VERCEL_PLATFORM_FILES } from './detect-builders';
15
+ export { detectInstrumentation } from './detect-instrumentation';
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __export(src_exports, {
34
34
  detectFrameworkRecord: () => import_detect_framework.detectFrameworkRecord,
35
35
  detectFrameworkVersion: () => import_detect_framework.detectFrameworkVersion,
36
36
  detectFrameworks: () => import_detect_framework.detectFrameworks,
37
+ detectInstrumentation: () => import_detect_instrumentation.detectInstrumentation,
37
38
  detectOutputDirectory: () => import_detect_builders.detectOutputDirectory,
38
39
  getProjectPaths: () => import_get_project_paths.getProjectPaths,
39
40
  getWorkspacePackagePaths: () => import_get_workspace_package_paths.getWorkspacePackagePaths,
@@ -59,6 +60,7 @@ var import_is_official_runtime = require("./is-official-runtime");
59
60
  var import_package_managers = require("./package-managers/package-managers");
60
61
  __reExport(src_exports, require("./monorepos/get-monorepo-default-settings"), module.exports);
61
62
  var import_detect_builders2 = require("./detect-builders");
63
+ var import_detect_instrumentation = require("./detect-instrumentation");
62
64
  // Annotate the CommonJS export names for ESM import in node:
63
65
  0 && (module.exports = {
64
66
  DetectorFilesystem,
@@ -76,6 +78,7 @@ var import_detect_builders2 = require("./detect-builders");
76
78
  detectFrameworkRecord,
77
79
  detectFrameworkVersion,
78
80
  detectFrameworks,
81
+ detectInstrumentation,
79
82
  detectOutputDirectory,
80
83
  getProjectPaths,
81
84
  getWorkspacePackagePaths,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/fs-detectors",
3
- "version": "5.3.11",
3
+ "version": "5.4.1",
4
4
  "description": "Vercel filesystem detectors",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "license": "Apache-2.0",
16
16
  "dependencies": {
17
17
  "@vercel/error-utils": "2.0.3",
18
- "@vercel/frameworks": "3.6.3",
18
+ "@vercel/frameworks": "3.6.4",
19
19
  "@vercel/routing-utils": "5.0.4",
20
20
  "glob": "8.0.3",
21
21
  "js-yaml": "4.1.0",