@@ -13,6 +13,8 @@ const { storage } = require('../../../datadog-core')
13
13
const { schemaDefinitions } = require ( '../../src/service-naming/schemas' )
14
14
const { getInstrumentation } = require ( './helpers/load-inst' )
15
15
16
+ const latestVersions = require ( '../../../datadog-instrumentations/src/helpers/latests.json' ) . latests
17
+
16
18
global . withVersions = withVersions
17
19
global . withExports = withExports
18
20
global . withNamingSchema = withNamingSchema
@@ -142,6 +144,15 @@ function withPeerService (tracer, pluginName, spanGenerationFn, service, service
142
144
} )
143
145
}
144
146
147
+ // function isVersionInRange(version, latestVersion) {
148
+ // if (!latestVersion) return true
149
+ // try {
150
+ // return semver.lte(version, latestVersion)
151
+ // } catch (e) {
152
+ // return true // TODO this is a bit of a hack, but I'm not sure what else to do
153
+ // }
154
+ // }
155
+
145
156
function withVersions ( plugin , modules , range , cb ) {
146
157
const instrumentations = typeof plugin === 'string' ? getInstrumentation ( plugin ) : [ ] . concat ( plugin )
147
158
const names = instrumentations . map ( instrumentation => instrumentation . name )
@@ -168,6 +179,8 @@ function withVersions (plugin, modules, range, cb) {
168
179
if ( ! packages . includes ( moduleName ) ) return
169
180
}
170
181
182
+ const latestVersion = latestVersions [ moduleName ] // TODO is moduleName correct?
183
+
171
184
const testVersions = new Map ( )
172
185
173
186
instrumentations
@@ -185,9 +198,13 @@ function withVersions (plugin, modules, range, cb) {
185
198
testVersions . set ( min , { range : version , test : min } )
186
199
}
187
200
188
- const max = require ( `../../../../versions/${ moduleName } @${ version } ` ) . version ( )
189
-
190
- testVersions . set ( max , { range : version , test : version } )
201
+ // TODO may run into issues with the latest version being greater than supported Node
202
+ if ( latestVersion ) {
203
+ testVersions . set ( latestVersion , { range : version , test : latestVersion } )
204
+ } else {
205
+ const max = require ( `../../../../versions/${ moduleName } @${ version } ` ) . version ( )
206
+ testVersions . set ( max , { range : version , test : version } )
207
+ }
191
208
} )
192
209
} )
193
210
0 commit comments