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