@modernpoacher/deps 2.2.15 → 2.2.17
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/package.json +2 -1
- package/src/common/index.mjs +82 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.17",
|
|
4
4
|
"description": "Update NPM package dependencies from the command line",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deps",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"#deps/src": "./src/index.mjs",
|
|
80
80
|
"#deps/src/*": "./src/*.mjs",
|
|
81
81
|
"#deps/src/common": "./src/common/index.mjs",
|
|
82
|
+
"#deps/src/common/debug": "./src/common/debug.mjs",
|
|
82
83
|
"#deps/src/common/*": "./src/common/*/index.mjs",
|
|
83
84
|
"#deps/src/install": "./src/install/index.mjs",
|
|
84
85
|
"#where-am-i": "./where-am-i.mjs"
|
package/src/common/index.mjs
CHANGED
|
@@ -305,6 +305,84 @@ export const isPreRelease = (v) => /-/.test(v)
|
|
|
305
305
|
*/
|
|
306
306
|
export const isExact = (v) => /^\d/.test(v)
|
|
307
307
|
|
|
308
|
+
/**
|
|
309
|
+
* @param {[name: string, version: string]} entry
|
|
310
|
+
* @returns {boolean}
|
|
311
|
+
*/
|
|
312
|
+
function includeVersionIsExact ([name, version]) {
|
|
313
|
+
return isExact(version)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @param {[name: string, version: string]} entry
|
|
318
|
+
* @returns {boolean}
|
|
319
|
+
*/
|
|
320
|
+
function excludeVersionIsExact ([name, version]) {
|
|
321
|
+
return !isExact(version)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* @param {Record<string, string>} configurationDependencies
|
|
326
|
+
* @returns {(entry: [name: string, version: string]) => {
|
|
327
|
+
* name: string,
|
|
328
|
+
* version: string
|
|
329
|
+
* }}
|
|
330
|
+
*/
|
|
331
|
+
function getMapToDepsExactVersionFromConfiguration (configurationDependencies) {
|
|
332
|
+
/**
|
|
333
|
+
* We are producing an array of objects from the entries of the `packageDependencies`
|
|
334
|
+
*
|
|
335
|
+
* Each object in the array represents an entry (key and value) from `packageDependencies`
|
|
336
|
+
*
|
|
337
|
+
* @param {[name: string, version: string]} entry
|
|
338
|
+
* @returns {{
|
|
339
|
+
* name: string,
|
|
340
|
+
* version: string
|
|
341
|
+
* }}
|
|
342
|
+
*/
|
|
343
|
+
return function mapToDepsExactVersionFromConfiguration (entry) {
|
|
344
|
+
const [
|
|
345
|
+
name,
|
|
346
|
+
version
|
|
347
|
+
] = entry
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
name,
|
|
351
|
+
version: (
|
|
352
|
+
name in configurationDependencies
|
|
353
|
+
? configurationDependencies[name]
|
|
354
|
+
: version
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @param {[name: string, version: string]} entry
|
|
362
|
+
* @returns {{
|
|
363
|
+
* name: string,
|
|
364
|
+
* version: string
|
|
365
|
+
* }}
|
|
366
|
+
*/
|
|
367
|
+
function mapToDepsVersion (entry) {
|
|
368
|
+
const [
|
|
369
|
+
name,
|
|
370
|
+
version
|
|
371
|
+
] = entry
|
|
372
|
+
|
|
373
|
+
if (isPreRelease(version)) {
|
|
374
|
+
return {
|
|
375
|
+
name,
|
|
376
|
+
version
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return {
|
|
381
|
+
name,
|
|
382
|
+
version: 'latest'
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
308
386
|
/**
|
|
309
387
|
* @function getDepsExact
|
|
310
388
|
*
|
|
@@ -319,11 +397,8 @@ export function getDepsExact (packageDependencies, configurationDependencies) {
|
|
|
319
397
|
|
|
320
398
|
return (
|
|
321
399
|
Object.entries(packageDependencies)
|
|
322
|
-
.
|
|
323
|
-
|
|
324
|
-
? accumulator.concat({ name, version: Reflect.has(configurationDependencies, name) ? Reflect.get(configurationDependencies, name) : version })
|
|
325
|
-
: accumulator
|
|
326
|
-
), [])
|
|
400
|
+
.filter(includeVersionIsExact)
|
|
401
|
+
.map(getMapToDepsExactVersionFromConfiguration(configurationDependencies))
|
|
327
402
|
)
|
|
328
403
|
}
|
|
329
404
|
|
|
@@ -340,13 +415,8 @@ export function getDeps (packageDependencies) {
|
|
|
340
415
|
|
|
341
416
|
return (
|
|
342
417
|
Object.entries(packageDependencies)
|
|
343
|
-
.
|
|
344
|
-
|
|
345
|
-
? accumulator
|
|
346
|
-
: isPreRelease(version)
|
|
347
|
-
? accumulator.concat({ name, version })
|
|
348
|
-
: accumulator.concat({ name, version: 'latest' })
|
|
349
|
-
), [])
|
|
418
|
+
.filter(excludeVersionIsExact)
|
|
419
|
+
.map(mapToDepsVersion)
|
|
350
420
|
)
|
|
351
421
|
}
|
|
352
422
|
|