@modernpoacher/deps 2.2.48 → 2.3.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/bin/common/index.mjs +6 -5
- package/bin/deps.mjs +1 -1
- package/bin/node/execute.mjs +20 -101
- package/bin/node/install.mjs +1 -1
- package/eslint.config.mjs +2 -4
- package/package.json +15 -18
- package/src/common/env/index.mjs +4 -3
- package/src/common/format/index.mjs +5 -3
- package/src/common/index.mjs +5 -12
- package/tsconfig.json +4 -2
package/bin/common/index.mjs
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
import debug from '#deps/src/common/debug'
|
|
43
43
|
|
|
44
44
|
import {
|
|
45
|
+
NVM,
|
|
45
46
|
BIN,
|
|
46
47
|
PLATFORM
|
|
47
48
|
} from '#deps/src/common/env'
|
|
@@ -61,11 +62,10 @@ import {
|
|
|
61
62
|
DIRECTORY,
|
|
62
63
|
REGISTRY,
|
|
63
64
|
AUTHOR,
|
|
64
|
-
NVM,
|
|
65
65
|
getRegistryParameter,
|
|
66
66
|
getForceParameter,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
getNvm,
|
|
68
|
+
getBin
|
|
69
69
|
} from '#deps/src/common'
|
|
70
70
|
|
|
71
71
|
const log = debug('@modernpoacher/deps')
|
|
@@ -92,11 +92,11 @@ rm -rf node_modules package-lock.json
|
|
|
92
92
|
|
|
93
93
|
const getNpmiCommands = PLATFORM === 'win32'
|
|
94
94
|
? (registry = REGISTRY, force = false) => trim(tidy(getRegistryParameter(registry, getForceParameter(force, 'npm i'))))
|
|
95
|
-
: (registry = REGISTRY, force = false) => trim(tidy(
|
|
95
|
+
: (registry = REGISTRY, force = false) => trim(tidy(getBin(getNvm(getRegistryParameter(registry, getForceParameter(force, 'npm i'))))))
|
|
96
96
|
|
|
97
97
|
const getDepsCommands = PLATFORM === 'win32'
|
|
98
98
|
? (registry = REGISTRY, force = false) => trim(tidy(getRegistryParameter(registry, getForceParameter(force, 'deps'))))
|
|
99
|
-
: (registry = REGISTRY, force = false) => trim(tidy(
|
|
99
|
+
: (registry = REGISTRY, force = false) => trim(tidy(getBin(getNvm(getRegistryParameter(registry, getForceParameter(force, 'deps'))))))
|
|
100
100
|
|
|
101
101
|
export const DEPS = PLATFORM === 'win32'
|
|
102
102
|
? `bash "${join(BIN, '.\\bash\\deps.sh')}"`
|
|
@@ -143,6 +143,7 @@ export function handleError (e = {}) {
|
|
|
143
143
|
} = e
|
|
144
144
|
|
|
145
145
|
if (code > 1) error(code)
|
|
146
|
+
|
|
146
147
|
const {
|
|
147
148
|
message = MESSAGE
|
|
148
149
|
} = e
|
package/bin/deps.mjs
CHANGED
package/bin/node/execute.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
glob
|
|
10
|
-
} from '
|
|
10
|
+
} from 'node:fs/promises'
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
Command
|
|
@@ -248,109 +248,36 @@ async function toMessage (message, directory) {
|
|
|
248
248
|
return message || await getMessageFromConfiguration(directory) || MESSAGE
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
/**
|
|
252
|
-
* @type {(v: string | undefined) => v is string}
|
|
253
|
-
* @param {string | undefined} v
|
|
254
|
-
* @returns {boolean}
|
|
255
|
-
*/
|
|
256
|
-
function filter (v) { // de-falsy
|
|
257
|
-
return Boolean(v)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* @param {string} alpha
|
|
262
|
-
* @param {string} omega
|
|
263
|
-
* @returns {number}
|
|
264
|
-
*/
|
|
265
|
-
function sort (alpha, omega) {
|
|
266
|
-
return alpha.localeCompare(omega)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* @param {string[]} directories
|
|
271
|
-
* @yields {string | undefined}
|
|
272
|
-
*/
|
|
273
|
-
function * genDirsList (directories = []) {
|
|
274
|
-
while (directories.length) yield directories.shift()
|
|
275
|
-
}
|
|
276
|
-
|
|
277
251
|
/**
|
|
278
252
|
* @param {string} directory
|
|
279
|
-
* @returns {
|
|
253
|
+
* @returns {string[]}
|
|
280
254
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
array
|
|
288
|
-
.map(dirname)
|
|
289
|
-
.sort(sort)
|
|
290
|
-
)
|
|
255
|
+
function toPackagePatterns (directory) {
|
|
256
|
+
return [
|
|
257
|
+
`${directory}/package.json`,
|
|
258
|
+
`${directory}/**/package.json`
|
|
259
|
+
]
|
|
291
260
|
}
|
|
292
261
|
|
|
293
262
|
/**
|
|
294
|
-
* @param {
|
|
295
|
-
* @returns {
|
|
263
|
+
* @param {string} directory
|
|
264
|
+
* @returns {string[]}
|
|
296
265
|
*/
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
* @type {string[]}
|
|
303
|
-
*/
|
|
304
|
-
const alpha = (
|
|
305
|
-
Array.from(new Set(directories))
|
|
306
|
-
.filter(filter)
|
|
307
|
-
.sort(sort)
|
|
308
|
-
)
|
|
309
|
-
|
|
310
|
-
try {
|
|
311
|
-
/**
|
|
312
|
-
* Recreate `directories` from `alpha`
|
|
313
|
-
* @type {(string | undefined)[]}
|
|
314
|
-
*/
|
|
315
|
-
const directories = (
|
|
316
|
-
await Promise.all(
|
|
317
|
-
alpha
|
|
318
|
-
.map(mapRevParseShowTopLevel)
|
|
319
|
-
)
|
|
320
|
-
)
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Transform `directories` to create `omega`
|
|
324
|
-
* @type {string[]}
|
|
325
|
-
*/
|
|
326
|
-
const omega = (
|
|
327
|
-
Array.from(new Set(directories))
|
|
328
|
-
.filter(filter)
|
|
329
|
-
.sort(sort)
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
return omega
|
|
333
|
-
} catch (e) {
|
|
334
|
-
if (e instanceof Error) handleError(e)
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return []
|
|
266
|
+
function toExcludePatterns (directory) {
|
|
267
|
+
return [
|
|
268
|
+
`${directory}/node_modules`,
|
|
269
|
+
`${directory}/**/node_modules`
|
|
270
|
+
]
|
|
338
271
|
}
|
|
339
272
|
|
|
340
273
|
/**
|
|
341
274
|
* @param {string} directory
|
|
342
|
-
* @
|
|
275
|
+
* @yields {string}
|
|
343
276
|
*/
|
|
344
|
-
async function
|
|
345
|
-
log('
|
|
277
|
+
async function * genDirectory (directory) {
|
|
278
|
+
log('genDirectory')
|
|
346
279
|
|
|
347
|
-
|
|
348
|
-
return (
|
|
349
|
-
await gitRevParseShowTopLevel(directory)
|
|
350
|
-
)
|
|
351
|
-
} catch (e) {
|
|
352
|
-
if (e instanceof Error) handleCommandError(e)
|
|
353
|
-
}
|
|
280
|
+
for await (const packageJson of await glob(toPackagePatterns(directory), { exclude: toExcludePatterns (directory) })) yield dirname(packageJson)
|
|
354
281
|
}
|
|
355
282
|
|
|
356
283
|
/**
|
|
@@ -399,15 +326,7 @@ async function iteratePath (directory, registry, force, message, author) {
|
|
|
399
326
|
if (directory) {
|
|
400
327
|
const D = resolve(directory)
|
|
401
328
|
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
if (pathList.length) {
|
|
405
|
-
const depsList = await getDepsList(pathList)
|
|
406
|
-
|
|
407
|
-
if (depsList.length) {
|
|
408
|
-
for (const d of genDirsList(depsList)) if (d) await iterate(d, registry, force, message, author)
|
|
409
|
-
}
|
|
410
|
-
}
|
|
329
|
+
for await (const d of genDirectory(D)) await iterate(d, registry, force, message, author)
|
|
411
330
|
}
|
|
412
331
|
}
|
|
413
332
|
|
|
@@ -557,7 +476,7 @@ async function executePath (directory, registry, force, message, author) {
|
|
|
557
476
|
async function app () {
|
|
558
477
|
log('Deps')
|
|
559
478
|
|
|
560
|
-
const commander = new Command()
|
|
479
|
+
const commander = new Command(NAME)
|
|
561
480
|
|
|
562
481
|
const {
|
|
563
482
|
argv
|
package/bin/node/install.mjs
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -72,8 +72,7 @@ export default [
|
|
|
72
72
|
languageOptions: {
|
|
73
73
|
parser: typescriptParser,
|
|
74
74
|
parserOptions: {
|
|
75
|
-
projectService: true
|
|
76
|
-
project: 'tsconfig.json'
|
|
75
|
+
projectService: true
|
|
77
76
|
},
|
|
78
77
|
globals: {
|
|
79
78
|
...globals.node,
|
|
@@ -90,8 +89,7 @@ export default [
|
|
|
90
89
|
languageOptions: {
|
|
91
90
|
parser: typescriptParser,
|
|
92
91
|
parserOptions: {
|
|
93
|
-
projectService: true
|
|
94
|
-
project: 'tsconfig.json'
|
|
92
|
+
projectService: true
|
|
95
93
|
},
|
|
96
94
|
globals: {
|
|
97
95
|
...globals.browser,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Update NPM package dependencies from the command line",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deps",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"deps-wipe": "cross-env NODE_OPTIONS=--disable-warning=ExperimentalWarning DEBUG_COLORS=yes NODE_ENV=production node bin/deps/wipe.mjs",
|
|
41
41
|
"lint": "eslint .",
|
|
42
42
|
"lint:fix": "npm run lint -- --fix",
|
|
43
|
-
"prepare": "husky",
|
|
44
43
|
"start": "npm run deps",
|
|
45
44
|
"test": "cross-env NODE_OPTIONS=--disable-warning=ExperimentalWarning DEBUG_COLORS=yes NODE_ENV=test mocha test --recursive --verbose --color"
|
|
46
45
|
},
|
|
@@ -54,29 +53,27 @@
|
|
|
54
53
|
"deps-wipe": "bin/deps/wipe.sh"
|
|
55
54
|
},
|
|
56
55
|
"dependencies": {
|
|
57
|
-
"@sequencemedia/write": "^0.2.
|
|
58
|
-
"commander": "^
|
|
56
|
+
"@sequencemedia/write": "^0.2.46",
|
|
57
|
+
"commander": "^15.0.0",
|
|
59
58
|
"debug": "^4.4.3",
|
|
60
|
-
"glob": "^11.0.3",
|
|
61
|
-
"strip-ansi": "^7.1.2",
|
|
62
59
|
"supports-color": "^10.2.2"
|
|
63
60
|
},
|
|
64
61
|
"devDependencies": {
|
|
65
|
-
"@sequencemedia/eslint-config-standard": "^0.2.
|
|
66
|
-
"@sequencemedia/eslint-config-typescript": "^0.1.
|
|
67
|
-
"@sequencemedia/eslint-merge": "^0.0.
|
|
68
|
-
"@types/chai": "^5.2.
|
|
69
|
-
"@types/debug": "^4.1.
|
|
62
|
+
"@sequencemedia/eslint-config-standard": "^0.2.107",
|
|
63
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.182",
|
|
64
|
+
"@sequencemedia/eslint-merge": "^0.0.67",
|
|
65
|
+
"@types/chai": "^5.2.3",
|
|
66
|
+
"@types/debug": "^4.1.13",
|
|
70
67
|
"@types/mocha": "^10.0.10",
|
|
71
|
-
"@types/node": "^
|
|
72
|
-
"@typescript-eslint/parser": "^8.
|
|
73
|
-
"chai": "^6.2.
|
|
68
|
+
"@types/node": "^25.9.3",
|
|
69
|
+
"@typescript-eslint/parser": "^8.61.0",
|
|
70
|
+
"chai": "^6.2.2",
|
|
74
71
|
"cross-env": "^10.1.0",
|
|
75
|
-
"eslint": "
|
|
76
|
-
"eslint-plugin-jsdoc": "^
|
|
77
|
-
"globals": "^
|
|
72
|
+
"eslint": "9.38.0",
|
|
73
|
+
"eslint-plugin-jsdoc": "^63.0.2",
|
|
74
|
+
"globals": "^17.6.0",
|
|
78
75
|
"husky": "^9.1.7",
|
|
79
|
-
"mocha": "^11.7.
|
|
76
|
+
"mocha": "^11.7.6"
|
|
80
77
|
},
|
|
81
78
|
"imports": {
|
|
82
79
|
"#deps/bin": "./bin/index.mjs",
|
package/src/common/env/index.mjs
CHANGED
|
@@ -21,14 +21,15 @@ const {
|
|
|
21
21
|
} = JSON.parse(readFileSync(join(PATH, 'package.json')).toString('utf8'))
|
|
22
22
|
|
|
23
23
|
const PLATFORM = platform()
|
|
24
|
-
const HOMEDIR = homedir()
|
|
25
24
|
|
|
26
25
|
const {
|
|
27
26
|
env: {
|
|
28
|
-
HOME
|
|
27
|
+
HOME = homedir()
|
|
29
28
|
}
|
|
30
29
|
} = process
|
|
31
30
|
|
|
31
|
+
const NVM = join(PATH, 'nvm.sh')
|
|
32
|
+
|
|
32
33
|
const BIN = PLATFORM === 'win32'
|
|
33
34
|
? join(PATH, '.\\bin') // \\bash')
|
|
34
35
|
: join(PATH, './bin') // /bash')
|
|
@@ -41,7 +42,7 @@ export {
|
|
|
41
42
|
NAME,
|
|
42
43
|
VERSION,
|
|
43
44
|
PLATFORM,
|
|
44
|
-
HOMEDIR,
|
|
45
45
|
HOME,
|
|
46
|
+
NVM,
|
|
46
47
|
BIN
|
|
47
48
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
stripVTControlCharacters as stripAnsi
|
|
3
|
+
} from 'node:util'
|
|
2
4
|
|
|
3
5
|
import {
|
|
4
6
|
normalize,
|
|
@@ -9,7 +11,7 @@ import debug from '#deps/src/common/debug'
|
|
|
9
11
|
|
|
10
12
|
import {
|
|
11
13
|
PLATFORM,
|
|
12
|
-
|
|
14
|
+
HOME
|
|
13
15
|
} from '#deps/src/common/env'
|
|
14
16
|
|
|
15
17
|
const log = debug('@modernpoacher/deps')
|
|
@@ -39,7 +41,7 @@ export const formatDirectory = PLATFORM === 'win32'
|
|
|
39
41
|
? (directory) => resolve(normalize(directory)).trim()
|
|
40
42
|
: (directory) => {
|
|
41
43
|
const d = resolve(normalize(directory)).trim()
|
|
42
|
-
if (d.startsWith(
|
|
44
|
+
if (d.startsWith(HOME)) return d.replace(new RegExp('^' + HOME), '~')
|
|
43
45
|
return d
|
|
44
46
|
}
|
|
45
47
|
|
package/src/common/index.mjs
CHANGED
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
* @typedef {DepsTypes.Configuration} Configuration
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
join
|
|
10
|
-
} from 'node:path'
|
|
11
|
-
|
|
12
|
-
import PATH from '#where-am-i'
|
|
13
|
-
|
|
14
8
|
import debug from '#deps/src/common/debug'
|
|
15
9
|
|
|
16
10
|
import {
|
|
17
|
-
PLATFORM
|
|
11
|
+
PLATFORM,
|
|
12
|
+
NVM
|
|
18
13
|
} from '#deps/src/common/env'
|
|
19
14
|
|
|
20
15
|
import {
|
|
@@ -29,8 +24,6 @@ export const REGISTRY = 'https://registry.npmjs.org'
|
|
|
29
24
|
|
|
30
25
|
export const AUTHOR = 'Modern Poacher Limited <modernpoacher@modernpoacher.com>'
|
|
31
26
|
|
|
32
|
-
export const NVM = join(PATH, 'nvm.sh')
|
|
33
|
-
|
|
34
27
|
const log = debug('@modernpoacher/deps')
|
|
35
28
|
|
|
36
29
|
log('`common` is awake')
|
|
@@ -129,13 +122,13 @@ export function getSaveExactParameter (commands) {
|
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
/**
|
|
132
|
-
* @function
|
|
125
|
+
* @function getBin
|
|
133
126
|
* @description
|
|
134
127
|
* Get the export PATH shell script
|
|
135
128
|
* @param {string} commands - Current commands string
|
|
136
129
|
* @returns {string}
|
|
137
130
|
*/
|
|
138
|
-
export function
|
|
131
|
+
export function getBin (commands) {
|
|
139
132
|
return `
|
|
140
133
|
export PATH=/usr/local/bin:$PATH &> /dev/null
|
|
141
134
|
${commands}
|
|
@@ -165,7 +158,7 @@ ${commands}
|
|
|
165
158
|
*/
|
|
166
159
|
export const getCommands = PLATFORM === 'win32'
|
|
167
160
|
? (commands = 'npm i') => trim(tidy(commands))
|
|
168
|
-
: (commands = 'npm i') => trim(tidy(
|
|
161
|
+
: (commands = 'npm i') => trim(tidy(getBin(getNvm(commands))))
|
|
169
162
|
|
|
170
163
|
/**
|
|
171
164
|
* @function getProdDependencies
|
package/tsconfig.json
CHANGED