@modernpoacher/deps 2.0.17 → 2.0.18

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.
@@ -77,6 +77,14 @@ function handleCommandError (e) {
77
77
  }
78
78
  }
79
79
 
80
+ /**
81
+ * @function getIgnoreFromConfiguration
82
+ *
83
+ * Interrogates `.depsrc` or `.depsrc.json` for an `ignore` value
84
+ *
85
+ * @param {string} directory
86
+ * @returns {Promise<boolean>}
87
+ */
80
88
  async function getIgnoreFromConfiguration (directory) {
81
89
  log('getIgnoreFromConfiguration')
82
90
 
@@ -91,6 +99,14 @@ async function getIgnoreFromConfiguration (directory) {
91
99
  )
92
100
  }
93
101
 
102
+ /**
103
+ * @function getAuthorFromConfiguration
104
+ *
105
+ * Interrogates `.depsrc` or `.depsrc.json` for an `author` value
106
+ *
107
+ * @param {string} directory
108
+ * @returns {Promise<string|null>}
109
+ */
94
110
  async function getAuthorFromConfiguration (directory) {
95
111
  log('getAuthorFromConfiguration')
96
112
 
@@ -105,6 +121,14 @@ async function getAuthorFromConfiguration (directory) {
105
121
  )
106
122
  }
107
123
 
124
+ /**
125
+ * @function getAuthorFromPackage
126
+ *
127
+ * Interrogates `package.json` for an `author` value
128
+ *
129
+ * @param {string} directory
130
+ * @returns {Promise<string|null>}
131
+ */
108
132
  async function getAuthorFromPackage (directory) {
109
133
  log('getAuthorFromPackage')
110
134
 
@@ -119,6 +143,22 @@ async function getAuthorFromPackage (directory) {
119
143
  )
120
144
  }
121
145
 
146
+ /**
147
+ * @function toAuthor
148
+ *
149
+ * Ensures that the `author` is set either from the command line,
150
+ * configuration, package, or a default
151
+ *
152
+ * Since it can be null `author` may not default in function arguments
153
+ *
154
+ * @param {string|null} author
155
+ * @param {string} directory
156
+ * @returns {Promise<string>}
157
+ */
158
+ async function toAuthor (author, directory) {
159
+ return author || await getAuthorFromConfiguration(directory) || await getAuthorFromPackage(directory) || AUTHOR
160
+ }
161
+
122
162
  const filterDeps = (v) => !!v // de-falsy
123
163
 
124
164
  const reduceDeps = (a, v) => a.includes(v) ? a : a.concat(v) // de-dupe
@@ -176,7 +216,7 @@ async function iterate ([directory, ...directories] = [], registry, force, messa
176
216
  if (D === await gitRevParse(D)) {
177
217
  const ignore = await getIgnoreFromConfiguration(D)
178
218
  if (!ignore) {
179
- await execute(D, registry, force, message, author || await getAuthorFromConfiguration(D) || await getAuthorFromPackage(D))
219
+ await execute(D, registry, force, message, toAuthor(author, D))
180
220
  }
181
221
  }
182
222
  } catch (e) {
@@ -219,7 +259,7 @@ async function executeFrom (directory, registry, force, message, author) {
219
259
  const ignore = await getIgnoreFromConfiguration(D)
220
260
  if (!ignore) {
221
261
  return (
222
- await execute(D, registry, force, message, author || await getAuthorFromConfiguration(D) || await getAuthorFromPackage(D))
262
+ await execute(D, registry, force, message, toAuthor(author, D))
223
263
  )
224
264
  }
225
265
  }
@@ -238,7 +278,7 @@ async function executeOnly (directory, registry, force, message, author) {
238
278
  const ignore = await getIgnoreFromConfiguration(D)
239
279
  if (!ignore) {
240
280
  return (
241
- await execute(D, registry, force, message, author || await getAuthorFromConfiguration(D) || await getAuthorFromPackage(D))
281
+ await execute(D, registry, force, message, toAuthor(author, D))
242
282
  )
243
283
  }
244
284
  }
@@ -257,7 +297,7 @@ async function executePath (directory, registry, force, message, author) {
257
297
  const ignore = await getIgnoreFromConfiguration(D)
258
298
  if (!ignore) {
259
299
  return (
260
- await execute(D, registry, force, message, author || await getAuthorFromConfiguration(D) || await getAuthorFromPackage(D))
300
+ await execute(D, registry, force, message, toAuthor(author, D))
261
301
  )
262
302
  }
263
303
  }
@@ -316,7 +356,9 @@ async function app () {
316
356
  ...(F ? { from: F } : {}),
317
357
  ...(O ? { only: O } : {}),
318
358
  ...(registry ? { registry } : {}),
319
- ...(force ? { force } : {})
359
+ ...(force ? { force } : {}),
360
+ ...(message ? { message } : {}),
361
+ ...(author ? { author } : {})
320
362
  })
321
363
 
322
364
  if (P || (!F && !O)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.0.17",
3
+ "version": "2.0.18",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -58,14 +58,14 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@babel/cli": "^7.21.0",
61
- "@babel/core": "^7.21.0",
62
- "@babel/eslint-parser": "^7.19.1",
61
+ "@babel/core": "^7.21.3",
62
+ "@babel/eslint-parser": "^7.21.3",
63
63
  "@babel/preset-env": "^7.20.2",
64
64
  "@babel/register": "^7.21.0",
65
65
  "chai": "^4.3.7",
66
- "core-js": "^3.29.0",
66
+ "core-js": "^3.29.1",
67
67
  "cross-env": "^7.0.3",
68
- "eslint": "^8.35.0",
68
+ "eslint": "^8.36.0",
69
69
  "eslint-config-standard": "^17.0.0",
70
70
  "eslint-plugin-import": "^2.27.5",
71
71
  "eslint-plugin-node": "^11.1.0",
@@ -154,7 +154,7 @@ function isCommandError (e) {
154
154
  *
155
155
  * @param {string} directory - A directory configured for Git
156
156
  *
157
- * @return {Promise}
157
+ * @return {Promise<string>}
158
158
  */
159
159
  export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
160
160
  log('catGitRefsRemotesOriginHead')
@@ -185,7 +185,7 @@ export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
185
185
  *
186
186
  * @param {string} directory - A directory
187
187
  *
188
- * @return {Promise}
188
+ * @return {Promise<string>}
189
189
  */
190
190
  export function gitRevParse (directory = DIRECTORY) {
191
191
  log('gitRevParse')
@@ -217,7 +217,7 @@ export function gitRevParse (directory = DIRECTORY) {
217
217
  * @param {string} directory - A directory configured for Git
218
218
  * @param {string} branch - The Git branch
219
219
  *
220
- * @return {Promise}
220
+ * @return {Promise<string>}
221
221
  */
222
222
  export function gitCheckout (directory = DIRECTORY, branch = BRANCH) {
223
223
  log('gitCheckout')
@@ -252,7 +252,7 @@ export function gitCheckout (directory = DIRECTORY, branch = BRANCH) {
252
252
  *
253
253
  * @param {string} directory - A directory configured for Git
254
254
  *
255
- * @return {Promise}
255
+ * @return {Promise<string>}
256
256
  */
257
257
  export function gitPull (directory = DIRECTORY) {
258
258
  log('gitPull')
@@ -287,7 +287,7 @@ export function gitPull (directory = DIRECTORY) {
287
287
  *
288
288
  * @param {string} directory - A directory configured for Git
289
289
  *
290
- * @return {Promise}
290
+ * @return {Promise<string>}
291
291
  */
292
292
  export function gitPush (directory = DIRECTORY) {
293
293
  log('gitPush')
@@ -322,7 +322,7 @@ export function gitPush (directory = DIRECTORY) {
322
322
  *
323
323
  * @param {string} directory - A directory configured for Git
324
324
  *
325
- * @return {Promise}
325
+ * @return {Promise<string>}
326
326
  */
327
327
  export function gitPushTags (directory = DIRECTORY) {
328
328
  log('gitPushTags')
@@ -358,7 +358,7 @@ export function gitPushTags (directory = DIRECTORY) {
358
358
  * @param {string} directory - A directory configured for Git
359
359
  * @param {string} add - An add parameter
360
360
  *
361
- * @return {Promise}
361
+ * @return {Promise<string>}
362
362
  */
363
363
  export function gitAdd (directory = DIRECTORY, add = ADD) {
364
364
  log('gitAdd')
@@ -394,7 +394,7 @@ export function gitAdd (directory = DIRECTORY, add = ADD) {
394
394
  * @param {string} directory - A directory configured for Git
395
395
  * @param {string} message - A commit message
396
396
  *
397
- * @return {Promise}
397
+ * @return {Promise<string>}
398
398
  */
399
399
  export function gitCommit (directory = DIRECTORY, message = MESSAGE, author = AUTHOR) {
400
400
  log('gitCommit')
@@ -58,7 +58,7 @@ const log = debug('@modernpoacher/deps')
58
58
 
59
59
  log(`\`common\` (${VERSION} - ${PLATFORM}) is awake at "${PATH}"`)
60
60
 
61
- const tidy = (v) => v.replace(/\n\n/gm, String.fromCharCode(10)).trim()
61
+ const tidy = (v) => v.replace(/\n{2,}}/gm, String.fromCharCode(10)).trim()
62
62
 
63
63
  /**
64
64
  * @function getSaveProdParameter
@@ -188,7 +188,6 @@ ${commands}
188
188
  *
189
189
  * @return {string}
190
190
  */
191
-
192
191
  export const getCommands = PLATFORM === 'win32'
193
192
  ? (commands = 'npm i') => tidy(commands)
194
193
  : (commands = 'npm i') => tidy(getExportPath(getNvm(commands)))
@@ -366,13 +365,15 @@ export function getDeps (packageDependencies) {
366
365
  *
367
366
  * @return {string}
368
367
  */
369
- export function normalizeCommands (value) {
370
- while (/\s\s|\n/.test(value)) {
371
- value = value.replace(/\s\s/gm, String.fromCharCode(32)).replace(/\n/gm, String.fromCharCode(32))
368
+ export function normalizeCommands (commands) {
369
+ const s = String.fromCharCode(32)
370
+
371
+ while (/\s{2,}|\n+/.test(commands)) {
372
+ commands = commands.replace(/\s{2,}/gm, s).replace(/\n+/gm, s)
372
373
  }
373
374
 
374
375
  return (
375
- value.trim()
376
+ commands.trim()
376
377
  )
377
378
  }
378
379
 
package/src/index.mjs CHANGED
@@ -292,7 +292,7 @@ export function getInstallSaveProdCommands (deps, r, f) {
292
292
  * @param {string} r - Registry
293
293
  * @param {boolean} f - Force
294
294
  *
295
- * @return {Promise}
295
+ * @return {Promise<string>}
296
296
  */
297
297
  export function installSaveBundleSaveExact (d, deps, r, f) {
298
298
  log('installSaveBundleSaveExact')
@@ -332,7 +332,7 @@ export function installSaveBundleSaveExact (d, deps, r, f) {
332
332
  * @param {string} r - Registry
333
333
  * @param {boolean} f - Force
334
334
  *
335
- * @return {Promise}
335
+ * @return {Promise<string>}
336
336
  */
337
337
  export function installSaveBundle (d, deps, r, f) {
338
338
  log('installSaveBundle')
@@ -372,7 +372,7 @@ export function installSaveBundle (d, deps, r, f) {
372
372
  * @param {string} r - Registry
373
373
  * @param {boolean} f - Force
374
374
  *
375
- * @return {Promise}
375
+ * @return {Promise<string>}
376
376
  */
377
377
  export function installSaveOptionalSaveExact (d, deps, r, f) {
378
378
  log('installSaveOptionalSaveExact')
@@ -412,7 +412,7 @@ export function installSaveOptionalSaveExact (d, deps, r, f) {
412
412
  * @param {string} r - Registry
413
413
  * @param {boolean} f - Force
414
414
  *
415
- * @return {Promise}
415
+ * @return {Promise<string>}
416
416
  */
417
417
  export function installSaveOptional (d, dependencies, r, f) {
418
418
  log('installSaveOptional')
@@ -452,7 +452,7 @@ export function installSaveOptional (d, dependencies, r, f) {
452
452
  * @param {string} r - Registry
453
453
  * @param {boolean} f - Force
454
454
  *
455
- * @return {Promise}
455
+ * @return {Promise<string>}
456
456
  */
457
457
  export function installSaveDevSaveExact (d, deps, r, f) {
458
458
  log('installSaveDevSaveExact')
@@ -492,7 +492,7 @@ export function installSaveDevSaveExact (d, deps, r, f) {
492
492
  * @param {string} r - Registry
493
493
  * @param {boolean} f - Force
494
494
  *
495
- * @return {Promise}
495
+ * @return {Promise<string>}
496
496
  */
497
497
  export function installSaveDev (d, deps, r, f) {
498
498
  log('installSaveDev')
@@ -532,7 +532,7 @@ export function installSaveDev (d, deps, r, f) {
532
532
  * @param {string} r - Registry
533
533
  * @param {boolean} f - Force
534
534
  *
535
- * @return {Promise}
535
+ * @return {Promise<string>}
536
536
  */
537
537
  export function installSaveProdSaveExact (d, deps, r, f) {
538
538
  log('installSaveProdSaveExact')
@@ -572,7 +572,7 @@ export function installSaveProdSaveExact (d, deps, r, f) {
572
572
  * @param {string} r - Registry
573
573
  * @param {boolean} f - Force
574
574
  *
575
- * @return {Promise}
575
+ * @return {Promise<string>}
576
576
  */
577
577
  export function installSaveProd (d, deps, r, f) {
578
578
  log('installSaveProd')
@@ -613,7 +613,7 @@ export function installSaveProd (d, deps, r, f) {
613
613
  * @param {string} r - Registry
614
614
  * @param {boolean} f - Force
615
615
  *
616
- * @return {Promise}
616
+ * @return {Promise<void>}
617
617
  */
618
618
  export async function executeBundle (d = DIRECTORY, packageDependencies = {}, configurationDependencies = {}, r = REGISTRY, f = false) {
619
619
  log('executeBundle')
@@ -638,7 +638,7 @@ export async function executeBundle (d = DIRECTORY, packageDependencies = {}, co
638
638
  * @param {string} r - Registry
639
639
  * @param {boolean} f - Force
640
640
  *
641
- * @return {Promise}
641
+ * @return {Promise<void>}
642
642
  */
643
643
  export async function executeOptional (d = DIRECTORY, packageDependencies = {}, configurationDependencies = {}, r = REGISTRY, f = false) {
644
644
  log('executeOptional')
@@ -663,7 +663,7 @@ export async function executeOptional (d = DIRECTORY, packageDependencies = {},
663
663
  * @param {string} r - Registry
664
664
  * @param {boolean} f - Force
665
665
  *
666
- * @return {Promise}
666
+ * @return {Promise<void>}
667
667
  */
668
668
  export async function executeDev (d = DIRECTORY, packageDependencies = {}, configurationDependencies = {}, r = REGISTRY, f = false) {
669
669
  log('executeDev')
@@ -688,7 +688,7 @@ export async function executeDev (d = DIRECTORY, packageDependencies = {}, confi
688
688
  * @param {string} r - Registry
689
689
  * @param {boolean} f - Force
690
690
  *
691
- * @return {Promise}
691
+ * @return {Promise<void>}
692
692
  */
693
693
  export async function executeProd (d = DIRECTORY, packageDependencies = {}, configurationDependencies = {}, r = REGISTRY, f = false) {
694
694
  log('executeProd')
@@ -110,7 +110,7 @@ export function getInstallCommands (p, s, r, f) {
110
110
  * @param {boolean} s - Save
111
111
  * @param {string} r - Registry
112
112
  *
113
- * @return {Promise}
113
+ * @return {Promise<string>}
114
114
  */
115
115
  export function installSaveExact (d, p, s, r, f) {
116
116
  log('installSaveExact')
@@ -145,7 +145,7 @@ export function installSaveExact (d, p, s, r, f) {
145
145
  * @param {boolean} s - Save
146
146
  * @param {string} r - Registry
147
147
  *
148
- * @return {Promise}
148
+ * @return {Promise<string>}
149
149
  */
150
150
  export function install (d, p, s, r, f) {
151
151
  log('install')
@@ -179,17 +179,18 @@ export function install (d, p, s, r, f) {
179
179
  * @param {Configuration} c - Configuration
180
180
  * @param {boolean} s - Save
181
181
  * @param {string} r - Registry
182
+ * @param {boolean} f - Force
182
183
  *
183
- * @return {Promise}
184
+ * @return {Promise<void>}
184
185
  */
185
- export async function execute (directory = DIRECTORY, packages = {}, configuration = {}, save = false, registry = REGISTRY, force = false) {
186
+ export async function execute (d = DIRECTORY, p = {}, c = {}, s = false, r = REGISTRY, f = false) {
186
187
  log('execute')
187
188
 
188
- const depsExact = getDepsExact(packages, configuration)
189
+ const depsExact = getDepsExact(p, c)
189
190
 
190
- if (depsExact.length) await installSaveExact(directory, depsExact, save, registry, force)
191
+ if (depsExact.length) await installSaveExact(d, depsExact, s, r, f)
191
192
 
192
- const deps = getDeps(packages)
193
+ const deps = getDeps(p)
193
194
 
194
- if (deps.length) await install(directory, deps, save, registry, force)
195
+ if (deps.length) await install(d, deps, s, r, f)
195
196
  }