@@ -12,6 +12,8 @@ const Nomenclature = require('../../src/service-naming')
12
12
const { storage } = require ( '../../../datadog-core' )
13
13
const { schemaDefinitions } = require ( '../../src/service-naming/schemas' )
14
14
15
+ const latestVersions = require ( '../../../datadog-instrumentations/src/helpers/latests.json' ) . latests
16
+
15
17
global . withVersions = withVersions
16
18
global . withExports = withExports
17
19
global . withNamingSchema = withNamingSchema
@@ -173,6 +175,15 @@ function withPeerService (tracer, pluginName, spanGenerationFn, service, service
173
175
} )
174
176
}
175
177
178
+ // function isVersionInRange(version, latestVersion) {
179
+ // if (!latestVersion) return true
180
+ // try {
181
+ // return semver.lte(version, latestVersion)
182
+ // } catch (e) {
183
+ // return true // TODO this is a bit of a hack, but I'm not sure what else to do
184
+ // }
185
+ // }
186
+
176
187
function withVersions ( plugin , modules , range , cb ) {
177
188
const instrumentations = typeof plugin === 'string' ? loadInst ( plugin ) : [ ] . concat ( plugin )
178
189
const names = instrumentations . map ( instrumentation => instrumentation . name )
@@ -199,6 +210,8 @@ function withVersions (plugin, modules, range, cb) {
199
210
if ( ! packages . includes ( moduleName ) ) return
200
211
}
201
212
213
+ const latestVersion = latestVersions [ moduleName ] // TODO is moduleName correct?
214
+
202
215
const testVersions = new Map ( )
203
216
204
217
instrumentations
@@ -216,9 +229,13 @@ function withVersions (plugin, modules, range, cb) {
216
229
testVersions . set ( min , { range : version , test : min } )
217
230
}
218
231
219
- const max = require ( `../../../../versions/${ moduleName } @${ version } ` ) . version ( )
220
-
221
- testVersions . set ( max , { range : version , test : version } )
232
+ // TODO may run into issues with the latest version being greater than supported Node
233
+ if ( latestVersion ) {
234
+ testVersions . set ( latestVersion , { range : version , test : latestVersion } )
235
+ } else {
236
+ const max = require ( `../../../../versions/${ moduleName } @${ version } ` ) . version ( )
237
+ testVersions . set ( max , { range : version , test : version } )
238
+ }
222
239
} )
223
240
} )
224
241
0 commit comments