@modernpoacher/deps 2.2.17 → 2.2.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.2.17",
3
+ "version": "2.2.19",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "main": "./index.mjs",
14
14
  "type": "module",
15
+ "types": "./index.d.mts",
15
16
  "author": {
16
17
  "name": "Jonathan Perry for Modern Poacher Limited",
17
18
  "email": "modernpoacher@modernpoacher.com",
@@ -37,7 +38,7 @@
37
38
  "deps-install": "cross-env NODE_OPTIONS=--disable-warning=ExperimentalWarning DEBUG_COLORS=yes NODE_ENV=production node bin/deps/install.mjs",
38
39
  "deps-push": "cross-env NODE_OPTIONS=--disable-warning=ExperimentalWarning DEBUG_COLORS=yes NODE_ENV=production node bin/deps/push.mjs",
39
40
  "deps-wipe": "cross-env NODE_OPTIONS=--disable-warning=ExperimentalWarning DEBUG_COLORS=yes NODE_ENV=production node bin/deps/wipe.mjs",
40
- "lint": "cross-env NODE_OPTIONS=--disable-warning=ExperimentalWarning eslint . --ext .mjs,.cjs",
41
+ "lint": "eslint .",
41
42
  "lint:fix": "npm run lint -- --fix",
42
43
  "prepare": "husky",
43
44
  "start": "npm run deps",
@@ -60,15 +61,16 @@
60
61
  "supports-color": "^10.0.0"
61
62
  },
62
63
  "devDependencies": {
63
- "@babel/core": "^7.26.10",
64
- "@babel/eslint-parser": "^7.26.10",
65
- "@babel/preset-env": "^7.26.9",
66
- "@babel/register": "^7.25.9",
64
+ "@sequencemedia/eslint-config-standard": "^0.2.47",
65
+ "@sequencemedia/eslint-config-typescript": "^0.1.69",
66
+ "@types/chai": "^5.2.1",
67
+ "@types/debug": "^4.1.12",
68
+ "@types/mocha": "^10.0.10",
69
+ "@typescript-eslint/parser": "^8.28.0",
67
70
  "chai": "^5.2.0",
68
- "core-js": "^3.41.0",
69
71
  "cross-env": "^7.0.3",
70
- "eslint": "8.57.1",
71
- "eslint-config-standard": "^17.1.0",
72
+ "eslint": "^9.23.0",
73
+ "globals": "^16.0.0",
72
74
  "husky": "^9.1.7",
73
75
  "mocha": "^11.1.0"
74
76
  },
@@ -79,8 +81,8 @@
79
81
  "#deps/src": "./src/index.mjs",
80
82
  "#deps/src/*": "./src/*.mjs",
81
83
  "#deps/src/common": "./src/common/index.mjs",
82
- "#deps/src/common/debug": "./src/common/debug.mjs",
83
84
  "#deps/src/common/*": "./src/common/*/index.mjs",
85
+ "#deps/src/common/debug": "./src/common/debug.mjs",
84
86
  "#deps/src/install": "./src/install/index.mjs",
85
87
  "#where-am-i": "./where-am-i.mjs"
86
88
  }
@@ -17,7 +17,7 @@ import {
17
17
  const {
18
18
  name: NAME,
19
19
  version: VERSION
20
- } = JSON.parse(readFileSync(join(PATH, 'package.json')))
20
+ } = JSON.parse(readFileSync(join(PATH, 'package.json')).toString('utf8'))
21
21
 
22
22
  const PLATFORM = platform()
23
23
 
@@ -28,7 +28,7 @@ const ADD = 'package.json package-lock.json'
28
28
 
29
29
  export const MESSAGE = PLATFORM === 'win32'
30
30
  ? 'Updated `package.json` &/ `package-lock.json`'
31
- : 'Updated \\`package.json\\` &/ \\`package-lock.json\\`' /* eslint-disable-line no-useless-escape */
31
+ : 'Updated \\`package.json\\` &/ \\`package-lock.json\\`'
32
32
 
33
33
  export const AUTHOR = 'Modern Poacher Limited <modernpoacher@modernpoacher.com>'
34
34
 
@@ -40,25 +40,19 @@ echo "\${BASH_REMATCH[0]}"
40
40
 
41
41
  const GIT_PULL = `
42
42
  source "${BIN}/common.sh"
43
-
44
43
  source_home "${BIN}"
45
-
46
44
  git pull
47
45
  `
48
46
 
49
47
  const GIT_PUSH = `
50
48
  source "${BIN}/common.sh"
51
-
52
49
  source_home "${BIN}"
53
-
54
50
  git push
55
51
  `
56
52
 
57
53
  const GIT_PUSH_TAGS = `
58
54
  source "${BIN}/common.sh"
59
-
60
55
  source_home "${BIN}"
61
-
62
56
  git push --tags
63
57
  `
64
58
 
@@ -66,25 +60,49 @@ const log = debug('@modernpoacher/deps')
66
60
 
67
61
  log(`\`common/git\` (${VERSION} - ${PLATFORM}) is awake`)
68
62
 
63
+ /**
64
+ * @param {string} v
65
+ * @returns {string}
66
+ */
69
67
  const trim = (v) => v.split(String.fromCharCode(10)).map((v) => v.trimEnd()).join(String.fromCharCode(10)).trim()
70
68
 
69
+ /**
70
+ * @param {string} v
71
+ * @returns {boolean}
72
+ */
71
73
  function filter (v) {
72
74
  return Boolean(stripAnsi(v).trim())
73
75
  }
74
76
 
77
+ /**
78
+ * @param {string} directory
79
+ * @returns {(s: string) => boolean}
80
+ */
75
81
  function getIsDirectory (directory) {
76
82
  return function isDirectory (s) {
77
83
  return directory === s
78
84
  }
79
85
  }
80
86
 
81
- function isFatal (s) {
82
- return s.toLowerCase().startsWith('fatal: not a git repository')
87
+ /**
88
+ * @param {string} v
89
+ * @returns {boolean}
90
+ */
91
+ function isFatal (v) {
92
+ return v.toLowerCase().startsWith('fatal: not a git repository')
83
93
  }
84
94
 
95
+ /**
96
+ * @param {string} key
97
+ * @returns {(value: string) => void}
98
+ */
85
99
  export function use (key) {
86
100
  const log = debug(`@modernpoacher/deps:${key}`)
87
101
 
102
+ /**
103
+ * @param {string} v
104
+ * @returns {void}
105
+ */
88
106
  function write (v) {
89
107
  log(v.trimEnd())
90
108
  }
@@ -96,11 +114,20 @@ export function use (key) {
96
114
  }
97
115
  }
98
116
 
117
+ /**
118
+ * @param {string} key
119
+ * @param {string} directory
120
+ * @returns {(value: string) => void}
121
+ */
99
122
  export function out (key, directory) {
100
123
  const log = debug(`@modernpoacher/deps:${key}`)
101
124
 
102
125
  const isDirectory = getIsDirectory(directory)
103
126
 
127
+ /**
128
+ * @param {string} v
129
+ * @returns {boolean}
130
+ */
104
131
  function filterOut (v) {
105
132
  const s = v.trim()
106
133
 
@@ -109,6 +136,10 @@ export function out (key, directory) {
109
136
  )
110
137
  }
111
138
 
139
+ /**
140
+ * @param {string} v
141
+ * @returns {void}
142
+ */
112
143
  function write (v) {
113
144
  if (v.trim()) log(v.trimEnd())
114
145
  }
@@ -120,11 +151,20 @@ export function out (key, directory) {
120
151
  }
121
152
  }
122
153
 
154
+ /**
155
+ * @param {string} key
156
+ * @param {string} directory
157
+ * @returns {(value: string) => void}
158
+ */
123
159
  export function err (key, directory) {
124
160
  const log = debug(`@modernpoacher/deps:${key}`)
125
161
 
126
162
  const isDirectory = getIsDirectory(directory)
127
163
 
164
+ /**
165
+ * @param {string} v
166
+ * @returns {boolean}
167
+ */
128
168
  function filterErr (v) {
129
169
  const s = v.trim()
130
170
 
@@ -133,6 +173,10 @@ export function err (key, directory) {
133
173
  )
134
174
  }
135
175
 
176
+ /**
177
+ * @param {string} v
178
+ * @returns {void}
179
+ */
136
180
  function write (v) {
137
181
  if (v.trim()) log(v.trimEnd())
138
182
  }
@@ -149,7 +193,7 @@ export function err (key, directory) {
149
193
  *
150
194
  * Get an error code from an error
151
195
  *
152
- * @param {Error}
196
+ * @param {{code?: number, message?: string}} e
153
197
  * @returns {number}
154
198
  */
155
199
  const getErrorCode = ({ code = 0 } = {}) => code
@@ -159,7 +203,7 @@ const getErrorCode = ({ code = 0 } = {}) => code
159
203
  *
160
204
  * Get an error message from an error
161
205
  *
162
- * @param {Error}
206
+ * @param {{code?: number, message?: string}} e
163
207
  * @returns {string}
164
208
  */
165
209
  const getErrorMessage = ({ message = '' } = {}) => message
@@ -169,7 +213,7 @@ const getErrorMessage = ({ message = '' } = {}) => message
169
213
  *
170
214
  * Determine whether an error is a safe non-zero exit from a Git command
171
215
  *
172
- * @param {Error}
216
+ * @param {{code?: number, message?: string}} e
173
217
  * @returns {boolean}
174
218
  */
175
219
  function isCommandError (e) {
@@ -202,14 +246,12 @@ export function catGitRefsRemotesOriginHead (d = DIRECTORY) {
202
246
  const {
203
247
  stdout,
204
248
  stderr
205
- } = exec(commands, options, (e, v = '') => {
206
- (!e)
207
- ? resolve(trim(v))
208
- : reject(e)
249
+ } = exec(commands, options, (e = null, v = '') => {
250
+ return (!e) ? resolve(trim(v)) : reject(e)
209
251
  })
210
252
 
211
- stdout.on('data', out('cat-git-refs-remotes-origin-head', directory))
212
- stderr.on('data', err('cat-git-refs-remotes-origin-head', directory))
253
+ if (stdout) stdout.on('data', out('cat-git-refs-remotes-origin-head', directory))
254
+ if (stderr) stderr.on('data', err('cat-git-refs-remotes-origin-head', directory))
213
255
  })
214
256
  )
215
257
  }
@@ -235,14 +277,12 @@ export function awkGitRemoteShowOriginHead (d = DIRECTORY) {
235
277
  const {
236
278
  stdout,
237
279
  stderr
238
- } = exec(commands, options, (e, v = '') => {
239
- (!e)
240
- ? resolve(trim(v))
241
- : reject(e)
280
+ } = exec(commands, options, (e = null, v = '') => {
281
+ return (!e) ? resolve(trim(v)) : reject(e)
242
282
  })
243
283
 
244
- stdout.on('data', out('git-remote-show-origin-head', directory))
245
- stderr.on('data', err('git-remote-show-origin-head', directory))
284
+ if (stdout) stdout.on('data', out('git-remote-show-origin-head', directory))
285
+ if (stderr) stderr.on('data', err('git-remote-show-origin-head', directory))
246
286
  })
247
287
  )
248
288
  }
@@ -268,14 +308,12 @@ export function gitRevParseShowTopLevel (d = DIRECTORY) {
268
308
  const {
269
309
  stdout,
270
310
  stderr
271
- } = exec(commands, options, (e, v = '') => {
272
- (!e)
273
- ? resolve(trim(v))
274
- : reject(e)
311
+ } = exec(commands, options, (e = null, v = '') => {
312
+ return (!e) ? resolve(trim(v)) : reject(e)
275
313
  })
276
314
 
277
- stdout.on('data', out('git-rev-parse-show-toplevel', directory))
278
- stderr.on('data', err('git-rev-parse-show-toplevel', directory))
315
+ if (stdout) stdout.on('data', out('git-rev-parse-show-toplevel', directory))
316
+ if (stderr) stderr.on('data', err('git-rev-parse-show-toplevel', directory))
279
317
  })
280
318
  )
281
319
  }
@@ -301,14 +339,12 @@ export function gitRevParseAbbrevRefHead (d = DIRECTORY) {
301
339
  const {
302
340
  stdout,
303
341
  stderr
304
- } = exec(commands, options, (e, v = '') => {
305
- (!e)
306
- ? resolve(trim(v))
307
- : reject(e)
342
+ } = exec(commands, options, (e = null, v = '') => {
343
+ return (!e) ? resolve(trim(v)) : reject(e)
308
344
  })
309
345
 
310
- stdout.on('data', out('git-rev-parse-abbrev-ref-head', directory))
311
- stderr.on('data', err('git-rev-parse-abbrev-ref-head', directory))
346
+ if (stdout) stdout.on('data', out('git-rev-parse-abbrev-ref-head', directory))
347
+ if (stderr) stderr.on('data', err('git-rev-parse-abbrev-ref-head', directory))
312
348
  })
313
349
  )
314
350
  }
@@ -335,8 +371,8 @@ export function gitCheckout (d = DIRECTORY, branch = BRANCH) {
335
371
  const {
336
372
  stdout,
337
373
  stderr
338
- } = exec(commands, options, (e, v) => {
339
- (!e)
374
+ } = exec(commands, options, (e = null, v = '') => {
375
+ return (!e)
340
376
  ? resolve(v)
341
377
  : isCommandError(e)
342
378
  ? resolve(v)
@@ -345,8 +381,8 @@ export function gitCheckout (d = DIRECTORY, branch = BRANCH) {
345
381
 
346
382
  const log = use('git-checkout')
347
383
 
348
- stdout.on('data', log)
349
- stderr.on('data', log)
384
+ if (stdout) stdout.on('data', log)
385
+ if (stderr) stderr.on('data', log)
350
386
  })
351
387
  )
352
388
  }
@@ -372,8 +408,8 @@ export function gitPull (d = DIRECTORY) {
372
408
  const {
373
409
  stdout,
374
410
  stderr
375
- } = exec(commands, options, (e, v) => {
376
- (!e)
411
+ } = exec(commands, options, (e = null, v = '') => {
412
+ return (!e)
377
413
  ? resolve(v)
378
414
  : isCommandError(e)
379
415
  ? resolve(v)
@@ -382,8 +418,8 @@ export function gitPull (d = DIRECTORY) {
382
418
 
383
419
  const log = use('git-pull')
384
420
 
385
- stdout.on('data', log)
386
- stderr.on('data', log)
421
+ if (stdout) stdout.on('data', log)
422
+ if (stderr) stderr.on('data', log)
387
423
  })
388
424
  )
389
425
  }
@@ -409,8 +445,8 @@ export function gitPush (d = DIRECTORY) {
409
445
  const {
410
446
  stdout,
411
447
  stderr
412
- } = exec(commands, options, (e, v) => {
413
- (!e)
448
+ } = exec(commands, options, (e = null, v = '') => {
449
+ return (!e)
414
450
  ? resolve(v)
415
451
  : isCommandError(e)
416
452
  ? resolve(v)
@@ -419,8 +455,8 @@ export function gitPush (d = DIRECTORY) {
419
455
 
420
456
  const log = use('git-push')
421
457
 
422
- stdout.on('data', log)
423
- stderr.on('data', log)
458
+ if (stdout) stdout.on('data', log)
459
+ if (stderr) stderr.on('data', log)
424
460
  })
425
461
  )
426
462
  }
@@ -446,8 +482,8 @@ export function gitPushTags (d = DIRECTORY) {
446
482
  const {
447
483
  stdout,
448
484
  stderr
449
- } = exec(commands, options, (e, v) => {
450
- (!e)
485
+ } = exec(commands, options, (e = null, v = '') => {
486
+ return (!e)
451
487
  ? resolve(v)
452
488
  : isCommandError(e)
453
489
  ? resolve(v)
@@ -456,8 +492,8 @@ export function gitPushTags (d = DIRECTORY) {
456
492
 
457
493
  const log = use('git-push-tags')
458
494
 
459
- stdout.on('data', log)
460
- stderr.on('data', log)
495
+ if (stdout) stdout.on('data', log)
496
+ if (stderr) stderr.on('data', log)
461
497
  })
462
498
  )
463
499
  }
@@ -484,8 +520,8 @@ export function gitAdd (d = DIRECTORY, add = ADD) {
484
520
  const {
485
521
  stdout,
486
522
  stderr
487
- } = exec(commands, options, (e, v) => {
488
- (!e)
523
+ } = exec(commands, options, (e = null, v = '') => {
524
+ return (!e)
489
525
  ? resolve(v)
490
526
  : isCommandError(e)
491
527
  ? resolve(v)
@@ -494,8 +530,8 @@ export function gitAdd (d = DIRECTORY, add = ADD) {
494
530
 
495
531
  const log = use('git-add')
496
532
 
497
- stdout.on('data', log)
498
- stderr.on('data', log)
533
+ if (stdout) stdout.on('data', log)
534
+ if (stderr) stderr.on('data', log)
499
535
  })
500
536
  )
501
537
  }
@@ -505,9 +541,9 @@ export function gitAdd (d = DIRECTORY, add = ADD) {
505
541
  *
506
542
  * Commit changes to Git with a default value if none is supplied
507
543
  *
508
- * @param {string} c - A directory configured for Git
544
+ * @param {string} d - A directory configured for Git
509
545
  * @param {string} message - A commit message
510
- * @param {string} author - The commit author
546
+ * @param {string | { name: string; email: string }} author - The commit author
511
547
  * @returns {Promise<string>}
512
548
  */
513
549
  export function gitCommit (d = DIRECTORY, message = MESSAGE, author = AUTHOR) {
@@ -523,8 +559,8 @@ export function gitCommit (d = DIRECTORY, message = MESSAGE, author = AUTHOR) {
523
559
  const {
524
560
  stdout,
525
561
  stderr
526
- } = exec(commands, options, (e, v) => {
527
- (!e)
562
+ } = exec(commands, options, (e = null, v = '') => {
563
+ return (!e)
528
564
  ? resolve(v)
529
565
  : isCommandError(e)
530
566
  ? resolve(v)
@@ -533,8 +569,8 @@ export function gitCommit (d = DIRECTORY, message = MESSAGE, author = AUTHOR) {
533
569
 
534
570
  const log = use('git-commit')
535
571
 
536
- stdout.on('data', log)
537
- stderr.on('data', log)
572
+ if (stdout) stdout.on('data', log)
573
+ if (stderr) stderr.on('data', log)
538
574
  })
539
575
  )
540
576
  }