@modernpoacher/deps 2.2.38 → 2.2.40

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.
@@ -49,7 +49,7 @@ import {
49
49
  } from '#deps/src/common/env'
50
50
 
51
51
  import {
52
- toHomeDir,
52
+ formatDirectory,
53
53
  use,
54
54
  tidy
55
55
  } from '#deps/src/common/format'
@@ -241,7 +241,7 @@ async function getDepsRcJson (directory = DIRECTORY) {
241
241
  async function hasPackage (directory = DIRECTORY) {
242
242
  log('hasPackage')
243
243
 
244
- info(`Directory is "${toHomeDir(directory)}"`)
244
+ info(`Directory is "${formatDirectory(directory)}"`)
245
245
 
246
246
  try {
247
247
  await access(getPackageJsonPath(directory), constants.R_OK)
@@ -261,7 +261,7 @@ async function hasPackage (directory = DIRECTORY) {
261
261
  async function getPackage (directory = DIRECTORY) {
262
262
  log('getPackage')
263
263
 
264
- info(`Directory is "${toHomeDir(directory)}"`)
264
+ info(`Directory is "${formatDirectory(directory)}"`)
265
265
 
266
266
  try {
267
267
  return await getPackageJson(directory)
@@ -278,7 +278,7 @@ async function getPackage (directory = DIRECTORY) {
278
278
  async function hasConfiguration (directory = DIRECTORY) {
279
279
  log('hasConfiguration')
280
280
 
281
- info(`Directory is "${toHomeDir(directory)}"`)
281
+ info(`Directory is "${formatDirectory(directory)}"`)
282
282
 
283
283
  try {
284
284
  await access(getDepsRcPath(directory), constants.R_OK)
@@ -321,7 +321,7 @@ async function hasConfiguration (directory = DIRECTORY) {
321
321
  async function getConfiguration (directory = DIRECTORY) {
322
322
  log('getConfiguration')
323
323
 
324
- info(`Directory is "${toHomeDir(directory)}"`)
324
+ info(`Directory is "${formatDirectory(directory)}"`)
325
325
 
326
326
  try {
327
327
  return await getDepsRc(directory)
@@ -24,7 +24,8 @@ import {
24
24
  } from '#deps/src/common/env'
25
25
 
26
26
  import {
27
- toHomeDir
27
+ formatDirectory,
28
+ formatAuthor
28
29
  } from '#deps/src/common/format'
29
30
 
30
31
  import {
@@ -126,15 +127,15 @@ async function isHeadDefaultBranch (directory) {
126
127
  async function getIgnoreFromConfiguration (directory) {
127
128
  log('getIgnoreFromConfiguration')
128
129
 
129
- const CONFIGURATION = (
130
- await hasConfiguration(directory)
131
- ? await getConfiguration(directory)
132
- : {}
133
- )
130
+ if (await hasConfiguration(directory)) {
131
+ return (
132
+ getIgnore(
133
+ await getConfiguration(directory)
134
+ )
135
+ )
136
+ }
134
137
 
135
- return (
136
- getIgnore(CONFIGURATION)
137
- )
138
+ return false
138
139
  }
139
140
 
140
141
  /**
@@ -147,15 +148,15 @@ async function getIgnoreFromConfiguration (directory) {
147
148
  async function getAuthorFromConfiguration (directory) {
148
149
  log('getAuthorFromConfiguration')
149
150
 
150
- const CONFIGURATION = (
151
- await hasConfiguration(directory)
152
- ? await getConfiguration(directory)
153
- : {}
154
- )
151
+ if (await hasConfiguration(directory)) {
152
+ return (
153
+ getAuthor(
154
+ await getConfiguration(directory)
155
+ )
156
+ )
157
+ }
155
158
 
156
- return (
157
- getAuthor(CONFIGURATION)
158
- )
159
+ return null
159
160
  }
160
161
 
161
162
  /**
@@ -168,13 +169,11 @@ async function getAuthorFromConfiguration (directory) {
168
169
  async function getAuthorFromGit (directory) {
169
170
  log('getAuthorFromGitConfig')
170
171
 
171
- const GIT = {
172
- name: await gitConfigUserName(directory),
173
- email: await gitConfigUserEmail(directory)
174
- }
175
-
176
172
  return (
177
- getAuthor(GIT)
173
+ formatAuthor(
174
+ await gitConfigUserName(directory) ?? '',
175
+ await gitConfigUserEmail(directory) ?? ''
176
+ )
178
177
  )
179
178
  }
180
179
 
@@ -188,15 +187,15 @@ async function getAuthorFromGit (directory) {
188
187
  async function getAuthorFromPackage (directory) {
189
188
  log('getAuthorFromPackage')
190
189
 
191
- const PACKAGE = (
192
- await hasPackage(directory)
193
- ? await getPackage(directory)
194
- : {}
195
- )
190
+ if (await hasPackage(directory)) {
191
+ return (
192
+ getAuthor(
193
+ await getPackage(directory)
194
+ )
195
+ )
196
+ }
196
197
 
197
- return (
198
- getAuthor(PACKAGE)
199
- )
198
+ return null
200
199
  }
201
200
 
202
201
  /**
@@ -209,15 +208,15 @@ async function getAuthorFromPackage (directory) {
209
208
  async function getMessageFromConfiguration (directory) {
210
209
  log('getMessageFromConfiguration')
211
210
 
212
- const CONFIGURATION = (
213
- await hasConfiguration(directory)
214
- ? await getConfiguration(directory)
215
- : {}
216
- )
211
+ if (await hasConfiguration(directory)) {
212
+ return (
213
+ getMessage(
214
+ await getConfiguration(directory)
215
+ )
216
+ )
217
+ }
217
218
 
218
- return (
219
- getMessage(CONFIGURATION)
220
- )
219
+ return null
221
220
  }
222
221
 
223
222
  /**
@@ -226,7 +225,7 @@ async function getMessageFromConfiguration (directory) {
226
225
  * Ensures that the `author` is set either from the command line,
227
226
  * configuration, package, or a default
228
227
  *
229
- * Since it can be null `author` may not default in function arguments
228
+ * Since it can be null `author` will not default in function arguments
230
229
  * @param {string | { name: string; email: string }} author
231
230
  * @param {string} directory
232
231
  * @returns {Promise<string | { name: string; email: string }>}
@@ -241,7 +240,7 @@ async function toAuthor (author, directory) {
241
240
  * Ensures that the `message` is set either from the command line,
242
241
  * configuration, or a default
243
242
  *
244
- * Since it can be null `message` may not default in function arguments
243
+ * Since it can be null `message` will not default in function arguments
245
244
  * @param {string | null} message
246
245
  * @param {string} directory
247
246
  * @returns {Promise<string>}
@@ -251,21 +250,21 @@ async function toMessage (message, directory) {
251
250
  }
252
251
 
253
252
  /**
253
+ * @type {(v: string | undefined) => v is string}
254
254
  * @param {string | undefined} v
255
255
  * @returns {boolean}
256
256
  */
257
- export function filterDeps (v) { // de-falsy
257
+ function filter (v) { // de-falsy
258
258
  return Boolean(v)
259
259
  }
260
260
 
261
261
  /**
262
- * @param {string[]} a
263
- * @param {string} v
264
- * @returns {string[]}
262
+ * @param {string} alpha
263
+ * @param {string} omega
264
+ * @returns {number}
265
265
  */
266
- export function reduceDeps (a, v = '') { // de-dupe
267
- if (!a.includes(v)) a.push(v)
268
- return a
266
+ function sort (alpha, omega) {
267
+ return alpha.localeCompare(omega)
269
268
  }
270
269
 
271
270
  /**
@@ -288,21 +287,12 @@ async function getPathList (directory) {
288
287
  return (
289
288
  array
290
289
  .map(dirname)
291
- .sort()
290
+ .sort(sort)
292
291
  )
293
292
  }
294
293
 
295
294
  /**
296
- * @param {string} alpha
297
- * @param {string} omega
298
- * @returns {number}
299
- */
300
- function sort (alpha, omega) {
301
- return alpha.localeCompare(omega)
302
- }
303
-
304
- /**
305
- * @param {Array<string | undefined>} [directories]
295
+ * @param {(string | undefined)[]} [directories]
306
296
  * @returns {Promise<string[]>}
307
297
  */
308
298
  async function getDepsList (directories = []) {
@@ -313,16 +303,15 @@ async function getDepsList (directories = []) {
313
303
  * @type {string[]}
314
304
  */
315
305
  const alpha = (
316
- directories
317
- .filter(Boolean)
318
- .reduce(reduceDeps, [])
306
+ Array.from(new Set(directories))
307
+ .filter(filter)
319
308
  .sort(sort)
320
309
  )
321
310
 
322
311
  try {
323
312
  /**
324
313
  * Recreate `directories` from `alpha`
325
- * @type {Array<string | undefined>}
314
+ * @type {(string | undefined)[]}
326
315
  */
327
316
  const directories = (
328
317
  await Promise.all(
@@ -336,9 +325,8 @@ async function getDepsList (directories = []) {
336
325
  * @type {string[]}
337
326
  */
338
327
  const omega = (
339
- directories
340
- .filter(Boolean)
341
- .reduce(reduceDeps, [])
328
+ Array.from(new Set(directories))
329
+ .filter(filter)
342
330
  .sort(sort)
343
331
  )
344
332
 
@@ -436,7 +424,7 @@ async function execute (directory = DIRECTORY, registry = REGISTRY, force = fals
436
424
  log('execute')
437
425
 
438
426
  try {
439
- info(`Directory is "${toHomeDir(directory)}"`)
427
+ info(`Directory is "${formatDirectory(directory)}"`)
440
428
  info(`Registry is "${registry}"`)
441
429
  info(`Force is "${force}"`)
442
430
  info(`Message is "${message}"`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.2.38",
3
+ "version": "2.2.40",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -54,7 +54,7 @@
54
54
  "deps-wipe": "bin/deps/wipe.sh"
55
55
  },
56
56
  "dependencies": {
57
- "@sequencemedia/write": "^0.2.14",
57
+ "@sequencemedia/write": "^0.2.16",
58
58
  "commander": "^14.0.1",
59
59
  "debug": "^4.4.3",
60
60
  "glob": "^11.0.3",
@@ -62,8 +62,8 @@
62
62
  "supports-color": "^10.2.2"
63
63
  },
64
64
  "devDependencies": {
65
- "@sequencemedia/eslint-config-standard": "^0.2.88",
66
- "@sequencemedia/eslint-config-typescript": "^0.1.150",
65
+ "@sequencemedia/eslint-config-standard": "^0.2.89",
66
+ "@sequencemedia/eslint-config-typescript": "^0.1.152",
67
67
  "@sequencemedia/eslint-merge": "^0.0.54",
68
68
  "@types/chai": "^5.2.2",
69
69
  "@types/debug": "^4.1.12",
@@ -73,7 +73,7 @@
73
73
  "chai": "^6.2.0",
74
74
  "cross-env": "^10.1.0",
75
75
  "eslint": "^9.37.0",
76
- "eslint-plugin-jsdoc": "^60.7.1",
76
+ "eslint-plugin-jsdoc": "^60.8.0",
77
77
  "globals": "^16.4.0",
78
78
  "husky": "^9.1.7",
79
79
  "mocha": "^11.7.4"
@@ -21,7 +21,6 @@ const {
21
21
  } = JSON.parse(readFileSync(join(PATH, 'package.json')).toString('utf8'))
22
22
 
23
23
  const PLATFORM = platform()
24
-
25
24
  const HOMEDIR = homedir()
26
25
 
27
26
  const {
@@ -14,10 +14,25 @@ const log = debug('@modernpoacher/deps')
14
14
  log(`\`common/format\` (${NAME} - ${VERSION} - ${PLATFORM}) is awake`)
15
15
 
16
16
  /**
17
- * @function toHomeDir
17
+ * @function formatAuthor
18
+ * @type {(name: string, email: string) => string | null}
19
+ */
20
+ export function formatAuthor (name, email) {
21
+ const n = name.trim()
22
+ const e = email.trim()
23
+
24
+ return (
25
+ n && e
26
+ ? `${n} <${e}>`
27
+ : null
28
+ )
29
+ }
30
+
31
+ /**
32
+ * @function formatDirectory
18
33
  * @type {(directory: string) => string}
19
34
  */
20
- export const toHomeDir = PLATFORM === 'win32'
35
+ export const formatDirectory = PLATFORM === 'win32'
21
36
  ? (directory) => directory
22
37
  : (directory) => directory.includes(HOMEDIR) ? directory.replace(HOMEDIR, '~') : directory
23
38
 
@@ -20,6 +20,7 @@ import {
20
20
  } from '#deps/src/common/env'
21
21
 
22
22
  import {
23
+ formatAuthor,
23
24
  tidy
24
25
  } from '#deps/src/common/format'
25
26
 
@@ -243,24 +244,39 @@ export function getIgnore ({ ignore = false }) {
243
244
  export function getAuthor ({ author = '' }) {
244
245
  if (typeof author === 'string') return author
245
246
  if (typeof (author || false) === 'object') {
246
- const {
247
- name: NAME = '',
248
- email: EMAIL = ''
249
- } = author
250
-
251
- const name = String(NAME).trim()
252
- const email = String(EMAIL).trim()
253
-
254
247
  return (
255
- name && email
256
- ? `${name} <${email}>`
257
- : null
248
+ formatAuthor(
249
+ String(getName(author) ?? ''),
250
+ String(getEmail(author) ?? '')
251
+ )
258
252
  )
259
253
  }
260
254
 
261
255
  return null
262
256
  }
263
257
 
258
+ /**
259
+ * @function getName
260
+ * @description
261
+ * Get the name by destructuring the configuration `author`
262
+ * @param {Configuration} author
263
+ * @returns {string}
264
+ */
265
+ export function getName ({ name = '' }) {
266
+ return name
267
+ }
268
+
269
+ /**
270
+ * @function getEmail
271
+ * @description
272
+ * Get the email by destructuring the configuration `author`
273
+ * @param {Configuration} author
274
+ * @returns {string}
275
+ */
276
+ export function getEmail ({ email = '' }) {
277
+ return email
278
+ }
279
+
264
280
  /**
265
281
  * @function getMessage
266
282
  * @description
package/src/index.mjs CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  } from '#deps/src/common/env'
37
37
 
38
38
  import {
39
- toHomeDir,
39
+ formatDirectory,
40
40
  use
41
41
  } from '#deps/src/common/format'
42
42
 
@@ -251,7 +251,7 @@ export function installSaveBundleSaveExact (d, deps, r, f) {
251
251
 
252
252
  const directory = normalize(d.trim())
253
253
 
254
- info(`Directory is "${toHomeDir(directory)}"`)
254
+ info(`Directory is "${formatDirectory(directory)}"`)
255
255
 
256
256
  return (
257
257
  new Promise((resolve, reject) => {
@@ -298,7 +298,7 @@ export function installSaveBundle (d, deps, r, f) {
298
298
 
299
299
  const directory = normalize(d.trim())
300
300
 
301
- info(`Directory is "${toHomeDir(directory)}"`)
301
+ info(`Directory is "${formatDirectory(directory)}"`)
302
302
 
303
303
  return (
304
304
  new Promise((resolve, reject) => {
@@ -345,7 +345,7 @@ export function installSaveOptionalSaveExact (d, deps, r, f) {
345
345
 
346
346
  const directory = normalize(d.trim())
347
347
 
348
- info(`Directory is "${toHomeDir(directory)}"`)
348
+ info(`Directory is "${formatDirectory(directory)}"`)
349
349
 
350
350
  return (
351
351
  new Promise((resolve, reject) => {
@@ -392,7 +392,7 @@ export function installSaveOptional (d, deps, r, f) {
392
392
 
393
393
  const directory = normalize(d.trim())
394
394
 
395
- info(`Directory is "${toHomeDir(directory)}"`)
395
+ info(`Directory is "${formatDirectory(directory)}"`)
396
396
 
397
397
  return (
398
398
  new Promise((resolve, reject) => {
@@ -439,7 +439,7 @@ export function installSaveDevSaveExact (d, deps, r, f) {
439
439
 
440
440
  const directory = normalize(d.trim())
441
441
 
442
- info(`Directory is "${toHomeDir(directory)}"`)
442
+ info(`Directory is "${formatDirectory(directory)}"`)
443
443
 
444
444
  return (
445
445
  new Promise((resolve, reject) => {
@@ -486,7 +486,7 @@ export function installSaveDev (d, deps, r, f) {
486
486
 
487
487
  const directory = normalize(d.trim())
488
488
 
489
- info(`Directory is "${toHomeDir(directory)}"`)
489
+ info(`Directory is "${formatDirectory(directory)}"`)
490
490
 
491
491
  return (
492
492
  new Promise((resolve, reject) => {
@@ -533,7 +533,7 @@ export function installSaveProdSaveExact (d, deps, r, f) {
533
533
 
534
534
  const directory = normalize(d.trim())
535
535
 
536
- info(`Directory is "${toHomeDir(directory)}"`)
536
+ info(`Directory is "${formatDirectory(directory)}"`)
537
537
 
538
538
  return (
539
539
  new Promise((resolve, reject) => {
@@ -580,7 +580,7 @@ export function installSaveProd (d, deps, r, f) {
580
580
 
581
581
  const directory = normalize(d.trim())
582
582
 
583
- info(`Directory is "${toHomeDir(directory)}"`)
583
+ info(`Directory is "${formatDirectory(directory)}"`)
584
584
 
585
585
  return (
586
586
  new Promise((resolve, reject) => {
@@ -29,7 +29,7 @@ import {
29
29
  } from '#deps/src/common/env'
30
30
 
31
31
  import {
32
- toHomeDir
32
+ formatDirectory
33
33
  } from '#deps/src/common/format'
34
34
 
35
35
  import {
@@ -107,7 +107,7 @@ export function installSaveExact (d, p, s, r, f) {
107
107
 
108
108
  const directory = normalize(d.trim())
109
109
 
110
- info(`Directory is "${toHomeDir(directory)}"`)
110
+ info(`Directory is "${formatDirectory(directory)}"`)
111
111
 
112
112
  return (
113
113
  new Promise((resolve, reject) => {
@@ -153,7 +153,7 @@ export function install (d, p, s, r, f) {
153
153
 
154
154
  const directory = normalize(d.trim())
155
155
 
156
- info(`Directory is "${toHomeDir(directory)}"`)
156
+ info(`Directory is "${formatDirectory(directory)}"`)
157
157
 
158
158
  return (
159
159
  new Promise((resolve, reject) => {