@modernpoacher/deps 2.2.19 → 2.2.20

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/src/index.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @typedef {import('node:child_process').ExecException} ExecException
3
+ */
4
+
1
5
  /**
2
6
  * Package or configuration dependencies
3
7
  * @typedef {import('./common/index.mjs').Dependencies} Dependencies
@@ -8,7 +12,12 @@
8
12
  * @typedef {import('./common/index.mjs').DependencyDescriptor} DependencyDescriptor
9
13
  */
10
14
 
11
- import debug from 'debug'
15
+ /**
16
+ * @callback HandleComplete
17
+ * @param {ExecException | null} e
18
+ * @param {string} v
19
+ * @returns {void}
20
+ */
12
21
 
13
22
  import stripAnsi from 'strip-ansi'
14
23
 
@@ -20,6 +29,8 @@ import {
20
29
  exec
21
30
  } from 'node:child_process'
22
31
 
32
+ import debug from '#deps/src/common/debug'
33
+
23
34
  import {
24
35
  VERSION,
25
36
  PLATFORM
@@ -83,9 +94,8 @@ export function use (key) {
83
94
 
84
95
  /**
85
96
  * @function getInstallSaveExactCommands
86
- *
97
+ * @description
87
98
  * Get the `npm install --save-exact` commands as a string
88
- *
89
99
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
90
100
  * @param {string} r - Registry
91
101
  * @param {boolean} f - Force
@@ -101,9 +111,8 @@ export function getInstallSaveExactCommands (deps, r, f) {
101
111
 
102
112
  /**
103
113
  * @function getInstallCommands
104
- *
114
+ * @description
105
115
  * Get the `npm install` commands as a string
106
- *
107
116
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
108
117
  * @param {string} r - Registry
109
118
  * @param {boolean} f - Force
@@ -119,9 +128,8 @@ export function getInstallCommands (deps, r, f) {
119
128
 
120
129
  /**
121
130
  * @function getInstallSaveBundleSaveExactCommands
122
- *
131
+ * @description
123
132
  * Get the `npm install --save-bundle --save-exact` commands as a string
124
- *
125
133
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
126
134
  * @param {string} r - Registry
127
135
  * @param {boolean} f - Force
@@ -141,9 +149,8 @@ export function getInstallSaveBundleSaveExactCommands (deps, r, f) {
141
149
 
142
150
  /**
143
151
  * @function getInstallSaveBundleCommands
144
- *
152
+ * @description
145
153
  * Get the `npm install --save-bundle` commands as a string
146
- *
147
154
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
148
155
  * @param {string} r - Registry
149
156
  * @param {boolean} f - Force
@@ -163,9 +170,8 @@ export function getInstallSaveBundleCommands (deps, r, f) {
163
170
 
164
171
  /**
165
172
  * @function getInstallSaveOptionalSaveExactCommands
166
- *
173
+ * @description
167
174
  * Get the `npm install --save-optional --save-exact` commands as a string
168
- *
169
175
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
170
176
  * @param {string} r - Registry
171
177
  * @param {boolean} f - Force
@@ -185,9 +191,8 @@ export function getInstallSaveOptionalSaveExactCommands (deps, r, f) {
185
191
 
186
192
  /**
187
193
  * @function getInstallSaveOptionalCommands
188
- *
194
+ * @description
189
195
  * Get the `npm install --save-optional` commands as a string
190
- *
191
196
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
192
197
  * @param {string} r - Registry
193
198
  * @param {boolean} f - Force
@@ -207,9 +212,8 @@ export function getInstallSaveOptionalCommands (deps, r, f) {
207
212
 
208
213
  /**
209
214
  * @function getInstallSaveDevSaveExactCommands
210
- *
215
+ * @description
211
216
  * Get the `npm install --save-dev --save-exact` commands as a string
212
- *
213
217
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
214
218
  * @param {string} r - Registry
215
219
  * @param {boolean} f - Force
@@ -229,9 +233,8 @@ export function getInstallSaveDevSaveExactCommands (deps, r, f) {
229
233
 
230
234
  /**
231
235
  * @function getInstallSaveDevCommands
232
- *
236
+ * @description
233
237
  * Get the `npm install --save-dev` commands as a string
234
- *
235
238
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
236
239
  * @param {string} r - Registry
237
240
  * @param {boolean} f - Force
@@ -251,9 +254,8 @@ export function getInstallSaveDevCommands (deps, r, f) {
251
254
 
252
255
  /**
253
256
  * @function getInstallSaveProdSaveExactCommands
254
- *
257
+ * @description
255
258
  * Get the `npm install --save-prod --save-exact` commands as a string
256
- *
257
259
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
258
260
  * @param {string} r - Registry
259
261
  * @param {boolean} f - Force
@@ -273,9 +275,8 @@ export function getInstallSaveProdSaveExactCommands (deps, r, f) {
273
275
 
274
276
  /**
275
277
  * @function getInstallSaveProdCommands
276
- *
278
+ * @description
277
279
  * Get the `npm install --save-prod` commands as a string
278
- *
279
280
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
280
281
  * @param {string} r - Registry
281
282
  * @param {boolean} f - Force
@@ -295,9 +296,8 @@ export function getInstallSaveProdCommands (deps, r, f) {
295
296
 
296
297
  /**
297
298
  * @function installSaveBundleSaveExact
298
- *
299
+ * @description
299
300
  * Spawn the `npm install --save-bundle --save-exact` commands
300
- *
301
301
  * @param {string} d - Directory
302
302
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
303
303
  * @param {string} r - Registry
@@ -315,13 +315,21 @@ export function installSaveBundleSaveExact (d, deps, r, f) {
315
315
  new Promise((resolve, reject) => {
316
316
  const commands = getCommands(getInstallSaveBundleSaveExactCommands(deps, r, f))
317
317
  const options = getOptions(directory)
318
+ /**
319
+ * @type {HandleComplete}
320
+ */
321
+ function handleComplete (e, v) {
322
+ if (!e) {
323
+ resolve(v)
324
+ } else {
325
+ reject(e)
326
+ }
327
+ }
318
328
 
319
329
  const {
320
330
  stdout,
321
331
  stderr
322
- } = exec(commands, options, (e, v) => {
323
- return (!e) ? resolve(v) : reject(e)
324
- })
332
+ } = exec(commands, options, handleComplete)
325
333
 
326
334
  const log = use('install-save-bundle-save-exact')
327
335
 
@@ -333,9 +341,8 @@ export function installSaveBundleSaveExact (d, deps, r, f) {
333
341
 
334
342
  /**
335
343
  * @function installSaveBundle
336
- *
344
+ * @description
337
345
  * Spawn the `npm install --save-bundle` commands
338
- *
339
346
  * @param {string} d - Directory
340
347
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
341
348
  * @param {string} r - Registry
@@ -353,13 +360,21 @@ export function installSaveBundle (d, deps, r, f) {
353
360
  new Promise((resolve, reject) => {
354
361
  const commands = getCommands(getInstallSaveBundleCommands(deps, r, f))
355
362
  const options = getOptions(directory)
363
+ /**
364
+ * @type {HandleComplete}
365
+ */
366
+ function handleComplete (e, v) {
367
+ if (!e) {
368
+ resolve(v)
369
+ } else {
370
+ reject(e)
371
+ }
372
+ }
356
373
 
357
374
  const {
358
375
  stdout,
359
376
  stderr
360
- } = exec(commands, options, (e, v) => {
361
- return (!e) ? resolve(v) : reject(e)
362
- })
377
+ } = exec(commands, options, handleComplete)
363
378
 
364
379
  const log = use('install-save-bundle')
365
380
 
@@ -371,9 +386,8 @@ export function installSaveBundle (d, deps, r, f) {
371
386
 
372
387
  /**
373
388
  * @function installSaveOptionalSaveExact
374
- *
389
+ * @description
375
390
  * Spawn the `npm install --save-optional --save-exact` commands
376
- *
377
391
  * @param {string} d - Directory
378
392
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
379
393
  * @param {string} r - Registry
@@ -391,13 +405,21 @@ export function installSaveOptionalSaveExact (d, deps, r, f) {
391
405
  new Promise((resolve, reject) => {
392
406
  const commands = getCommands(getInstallSaveOptionalSaveExactCommands(deps, r, f))
393
407
  const options = getOptions(directory)
408
+ /**
409
+ * @type {HandleComplete}
410
+ */
411
+ function handleComplete (e, v) {
412
+ if (!e) {
413
+ resolve(v)
414
+ } else {
415
+ reject(e)
416
+ }
417
+ }
394
418
 
395
419
  const {
396
420
  stdout,
397
421
  stderr
398
- } = exec(commands, options, (e, v) => {
399
- return (!e) ? resolve(v) : reject(e)
400
- })
422
+ } = exec(commands, options, handleComplete)
401
423
 
402
424
  const log = use('install-save-otional-save-exact')
403
425
 
@@ -409,9 +431,8 @@ export function installSaveOptionalSaveExact (d, deps, r, f) {
409
431
 
410
432
  /**
411
433
  * @function installSaveOptional
412
- *
434
+ * @description
413
435
  * Spawn the `npm install --save-optional` commands
414
- *
415
436
  * @param {string} d - Directory
416
437
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependencies
417
438
  * @param {string} r - Registry
@@ -429,13 +450,21 @@ export function installSaveOptional (d, deps, r, f) {
429
450
  new Promise((resolve, reject) => {
430
451
  const commands = getCommands(getInstallSaveOptionalCommands(deps, r, f))
431
452
  const options = getOptions(directory)
453
+ /**
454
+ * @type {HandleComplete}
455
+ */
456
+ function handleComplete (e, v) {
457
+ if (!e) {
458
+ resolve(v)
459
+ } else {
460
+ reject(e)
461
+ }
462
+ }
432
463
 
433
464
  const {
434
465
  stdout,
435
466
  stderr
436
- } = exec(commands, options, (e, v) => {
437
- return (!e) ? resolve(v) : reject(e)
438
- })
467
+ } = exec(commands, options, handleComplete)
439
468
 
440
469
  const log = use('install-save-otional')
441
470
 
@@ -447,9 +476,8 @@ export function installSaveOptional (d, deps, r, f) {
447
476
 
448
477
  /**
449
478
  * @function installSaveDevSaveExact
450
- *
479
+ * @description
451
480
  * Spawn the `npm install --save-dev --save-exact` commands
452
- *
453
481
  * @param {string} d - Directory
454
482
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
455
483
  * @param {string} r - Registry
@@ -467,13 +495,21 @@ export function installSaveDevSaveExact (d, deps, r, f) {
467
495
  new Promise((resolve, reject) => {
468
496
  const commands = getCommands(getInstallSaveDevSaveExactCommands(deps, r, f))
469
497
  const options = getOptions(directory)
498
+ /**
499
+ * @type {HandleComplete}
500
+ */
501
+ function handleComplete (e, v) {
502
+ if (!e) {
503
+ resolve(v)
504
+ } else {
505
+ reject(e)
506
+ }
507
+ }
470
508
 
471
509
  const {
472
510
  stdout,
473
511
  stderr
474
- } = exec(commands, options, (e, v) => {
475
- return (!e) ? resolve(v) : reject(e)
476
- })
512
+ } = exec(commands, options, handleComplete)
477
513
 
478
514
  const log = use('install-save-dev-save-exact')
479
515
 
@@ -485,9 +521,8 @@ export function installSaveDevSaveExact (d, deps, r, f) {
485
521
 
486
522
  /**
487
523
  * @function installSaveDev
488
- *
524
+ * @description
489
525
  * Spawn the `npm install --save-dev` commands
490
- *
491
526
  * @param {string} d - Directory
492
527
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
493
528
  * @param {string} r - Registry
@@ -505,13 +540,21 @@ export function installSaveDev (d, deps, r, f) {
505
540
  new Promise((resolve, reject) => {
506
541
  const commands = getCommands(getInstallSaveDevCommands(deps, r, f))
507
542
  const options = getOptions(directory)
543
+ /**
544
+ * @type {HandleComplete}
545
+ */
546
+ function handleComplete (e, v) {
547
+ if (!e) {
548
+ resolve(v)
549
+ } else {
550
+ reject(e)
551
+ }
552
+ }
508
553
 
509
554
  const {
510
555
  stdout,
511
556
  stderr
512
- } = exec(commands, options, (e, v) => {
513
- return (!e) ? resolve(v) : reject(e)
514
- })
557
+ } = exec(commands, options, handleComplete)
515
558
 
516
559
  const log = use('install-save-dev')
517
560
 
@@ -523,9 +566,8 @@ export function installSaveDev (d, deps, r, f) {
523
566
 
524
567
  /**
525
568
  * @function installSaveProdSaveExact
526
- *
569
+ * @description
527
570
  * Spawn the `npm install --save-prod --save-exact` commands
528
- *
529
571
  * @param {string} d - Directory
530
572
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
531
573
  * @param {string} r - Registry
@@ -543,13 +585,21 @@ export function installSaveProdSaveExact (d, deps, r, f) {
543
585
  new Promise((resolve, reject) => {
544
586
  const commands = getCommands(getInstallSaveProdSaveExactCommands(deps, r, f))
545
587
  const options = getOptions(directory)
588
+ /**
589
+ * @type {HandleComplete}
590
+ */
591
+ function handleComplete (e, v) {
592
+ if (!e) {
593
+ resolve(v)
594
+ } else {
595
+ reject(e)
596
+ }
597
+ }
546
598
 
547
599
  const {
548
600
  stdout,
549
601
  stderr
550
- } = exec(commands, options, (e, v) => {
551
- return (!e) ? resolve(v) : reject(e)
552
- })
602
+ } = exec(commands, options, handleComplete)
553
603
 
554
604
  const log = use('install-save-prod-save-exact')
555
605
 
@@ -561,9 +611,8 @@ export function installSaveProdSaveExact (d, deps, r, f) {
561
611
 
562
612
  /**
563
613
  * @function installSaveProd
564
- *
614
+ * @description
565
615
  * Spawn the `npm install --save-prod` commands
566
- *
567
616
  * @param {string} d - Directory
568
617
  * @param {DependencyDescriptor | DependencyDescriptor[]} deps - Dependency descriptor(s)
569
618
  * @param {string} r - Registry
@@ -581,13 +630,21 @@ export function installSaveProd (d, deps, r, f) {
581
630
  new Promise((resolve, reject) => {
582
631
  const commands = getCommands(getInstallSaveProdCommands(deps, r, f))
583
632
  const options = getOptions(directory)
633
+ /**
634
+ * @type {HandleComplete}
635
+ */
636
+ function handleComplete (e, v) {
637
+ if (!e) {
638
+ resolve(v)
639
+ } else {
640
+ reject(e)
641
+ }
642
+ }
584
643
 
585
644
  const {
586
645
  stdout,
587
646
  stderr
588
- } = exec(commands, options, (e, v) => {
589
- return (!e) ? resolve(v) : reject(e)
590
- })
647
+ } = exec(commands, options, handleComplete)
591
648
 
592
649
  const log = use('install-save-prod')
593
650
 
@@ -599,9 +656,8 @@ export function installSaveProd (d, deps, r, f) {
599
656
 
600
657
  /**
601
658
  * @function executeBundle
602
- *
659
+ * @description
603
660
  * Execute the `npm install --save-bundle --save-exact` and `npm install --save-bundle` commands
604
- *
605
661
  * @param {string} d - Directory
606
662
  * @param {Dependencies} packageDependencies - Package dependencies
607
663
  * @param {Dependencies} configurationDependencies - Configuration dependencies
@@ -623,9 +679,8 @@ export async function executeBundle (d = DIRECTORY, packageDependencies = {}, co
623
679
 
624
680
  /**
625
681
  * @function executeOptional
626
- *
682
+ * @description
627
683
  * Execute the `npm install --save-optional --save-exact` and `npm install --save-optional` commands
628
- *
629
684
  * @param {string} d - Directory
630
685
  * @param {Dependencies} packageDependencies - Package dependencies
631
686
  * @param {Dependencies} configurationDependencies - Configuration dependencies
@@ -647,9 +702,8 @@ export async function executeOptional (d = DIRECTORY, packageDependencies = {},
647
702
 
648
703
  /**
649
704
  * @function executeDev
650
- *
705
+ * @description
651
706
  * Execute the `npm install --save-dev --save-exact` and `npm install --save-dev` commands
652
- *
653
707
  * @param {string} d - Directory
654
708
  * @param {Dependencies} packageDependencies - Package dependencies
655
709
  * @param {Dependencies} configurationDependencies - Configuration dependencies
@@ -671,9 +725,8 @@ export async function executeDev (d = DIRECTORY, packageDependencies = {}, confi
671
725
 
672
726
  /**
673
727
  * @function executeProd
674
- *
728
+ * @description
675
729
  * Execute the `npm install --save-prod --save-exact` and `npm install --save-prod` commands
676
- *
677
730
  * @param {string} d - Directory
678
731
  * @param {Dependencies} packageDependencies - Package dependencies
679
732
  * @param {Dependencies} configurationDependencies - Configuration dependencies
@@ -1,10 +1,16 @@
1
1
  /**
2
- * @typedef {DepsTypes.DependencyDescriptor} DependencyDescriptor
2
+ * @typedef {import('node:child_process').ExecException} ExecException
3
+ * @typedef {DepsTypes.DependencyDescriptor} DependencyDescriptor
3
4
  * @typedef {DepsTypes.Package} Package
4
5
  * @typedef {DepsTypes.Configuration} Configuration
5
6
  */
6
7
 
7
- import debug from 'debug'
8
+ /**
9
+ * @callback HandleComplete
10
+ * @param {ExecException | null} e
11
+ * @param {string} v
12
+ * @returns {void}
13
+ */
8
14
 
9
15
  import {
10
16
  normalize
@@ -14,6 +20,8 @@ import {
14
20
  exec
15
21
  } from 'node:child_process'
16
22
 
23
+ import debug from '#deps/src/common/debug'
24
+
17
25
  import {
18
26
  VERSION,
19
27
  PLATFORM
@@ -44,9 +52,8 @@ log(`\`install\` (${VERSION} - ${PLATFORM}) is awake`)
44
52
 
45
53
  /**
46
54
  * @function getInstallSaveExactCommands
47
- *
55
+ * @description
48
56
  * Get the `install --save-exact` commands as a string
49
- *
50
57
  * @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
51
58
  * @param {boolean} s - Save
52
59
  * @param {string} r - Registry
@@ -67,9 +74,8 @@ export function getInstallSaveExactCommands (p, s, r, f) {
67
74
 
68
75
  /**
69
76
  * @function getInstallCommands
70
- *
77
+ * @description
71
78
  * Get the `install` commands as a string
72
- *
73
79
  * @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
74
80
  * @param {boolean} s - Save
75
81
  * @param {string} r - Registry
@@ -90,9 +96,8 @@ export function getInstallCommands (p, s, r, f) {
90
96
 
91
97
  /**
92
98
  * @function installSaveExact
93
- *
99
+ * @description
94
100
  * Spawn the `install --save-exact` commands
95
- *
96
101
  * @param {string} d - Directory
97
102
  * @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
98
103
  * @param {boolean} s - Save
@@ -111,13 +116,21 @@ export function installSaveExact (d, p, s, r, f) {
111
116
  new Promise((resolve, reject) => {
112
117
  const commands = getCommands(getInstallSaveExactCommands(p, s, r, f))
113
118
  const options = getOptions(directory)
119
+ /**
120
+ * @type {HandleComplete}
121
+ */
122
+ function handleComplete (e, v) {
123
+ if (!e) {
124
+ resolve(v)
125
+ } else {
126
+ reject(e)
127
+ }
128
+ }
114
129
 
115
130
  const {
116
131
  stdout,
117
132
  stderr
118
- } = exec(commands, options, (e, v) => {
119
- return (!e) ? resolve(v) : reject(e)
120
- })
133
+ } = exec(commands, options, handleComplete)
121
134
 
122
135
  if (stdout) stdout.on('data', log)
123
136
  if (stderr) stderr.on('data', log)
@@ -127,9 +140,8 @@ export function installSaveExact (d, p, s, r, f) {
127
140
 
128
141
  /**
129
142
  * @function install
130
- *
143
+ * @description
131
144
  * Spawn the `install` commands
132
- *
133
145
  * @param {string} d - Directory
134
146
  * @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
135
147
  * @param {boolean} s - Save
@@ -148,13 +160,21 @@ export function install (d, p, s, r, f) {
148
160
  new Promise((resolve, reject) => {
149
161
  const commands = getCommands(getInstallCommands(p, s, r, f))
150
162
  const options = getOptions(directory)
163
+ /**
164
+ * @type {HandleComplete}
165
+ */
166
+ function handleComplete (e, v) {
167
+ if (!e) {
168
+ resolve(v)
169
+ } else {
170
+ reject(e)
171
+ }
172
+ }
151
173
 
152
174
  const {
153
175
  stdout,
154
176
  stderr
155
- } = exec(commands, options, (e, v) => {
156
- return (!e) ? resolve(v) : reject(e)
157
- })
177
+ } = exec(commands, options, handleComplete)
158
178
 
159
179
  if (stdout) stdout.on('data', log)
160
180
  if (stderr) stderr.on('data', log)
@@ -164,9 +184,8 @@ export function install (d, p, s, r, f) {
164
184
 
165
185
  /**
166
186
  * @function execute
167
- *
187
+ * @description
168
188
  * Execute the `install --save-exact` and `install` commands
169
- *
170
189
  * @param {string} d - Directory
171
190
  * @param {Package} p - Package
172
191
  * @param {Configuration} c - Configuration