@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/common/index.mjs
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* @typedef {DepsTypes.Configuration} Configuration
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import debug from 'debug'
|
|
9
|
-
|
|
10
|
-
import PATH from '#where-am-i'
|
|
11
|
-
|
|
12
8
|
import {
|
|
13
9
|
join
|
|
14
10
|
} from 'node:path'
|
|
15
11
|
|
|
12
|
+
import PATH from '#where-am-i'
|
|
13
|
+
|
|
14
|
+
import debug from '#deps/src/common/debug'
|
|
15
|
+
|
|
16
16
|
import {
|
|
17
17
|
VERSION,
|
|
18
18
|
PLATFORM
|
|
@@ -30,23 +30,31 @@ const log = debug('@modernpoacher/deps')
|
|
|
30
30
|
|
|
31
31
|
log(`\`common\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
32
32
|
|
|
33
|
+
const LF = String.fromCharCode(10)
|
|
34
|
+
const SP = String.fromCharCode(32)
|
|
35
|
+
|
|
33
36
|
/**
|
|
34
37
|
* @param {string} v
|
|
35
38
|
* @returns {string}
|
|
36
39
|
*/
|
|
37
|
-
export const tidy = (v) => v.replace(/\n{2,}}/gm,
|
|
40
|
+
export const tidy = (v) => v.replace(/\n{2,}}/gm, LF).trim()
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
* @param {string} v
|
|
41
44
|
* @returns {string}
|
|
42
45
|
*/
|
|
43
|
-
export const
|
|
46
|
+
export const trimEnd = (v) => v.trimEnd()
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {string} v
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
export const trim = (v) => v.split(LF).map(trimEnd).join(LF).trim()
|
|
44
53
|
|
|
45
54
|
/**
|
|
46
55
|
* @function getSaveProdParameter
|
|
47
|
-
*
|
|
56
|
+
* @description
|
|
48
57
|
* Get the `--save-prod` parameter
|
|
49
|
-
*
|
|
50
58
|
* @param {string} commands commands string
|
|
51
59
|
* @returns {string}
|
|
52
60
|
*/
|
|
@@ -54,9 +62,8 @@ export const getSaveProdParameter = (commands) => commands.concat(' --save-prod'
|
|
|
54
62
|
|
|
55
63
|
/**
|
|
56
64
|
* @function getSaveDevParameter
|
|
57
|
-
*
|
|
65
|
+
* @description
|
|
58
66
|
* Get the `--save-dev` parameter
|
|
59
|
-
*
|
|
60
67
|
* @param {string} commands commands string
|
|
61
68
|
* @returns {string}
|
|
62
69
|
*/
|
|
@@ -64,9 +71,8 @@ export const getSaveDevParameter = (commands) => commands.concat(' --save-dev')
|
|
|
64
71
|
|
|
65
72
|
/**
|
|
66
73
|
* @function getSaveBundleParameter
|
|
67
|
-
*
|
|
74
|
+
* @description
|
|
68
75
|
* Get the "save bundle" parameter
|
|
69
|
-
*
|
|
70
76
|
* @param {string} commands - Current commands string
|
|
71
77
|
* @returns {string}
|
|
72
78
|
*/
|
|
@@ -74,9 +80,8 @@ export const getSaveBundleParameter = (commands) => commands.concat(' --save-bun
|
|
|
74
80
|
|
|
75
81
|
/**
|
|
76
82
|
* @function getSaveOptionalParameter
|
|
77
|
-
*
|
|
83
|
+
* @description
|
|
78
84
|
* Get the `--save-optional` parameter
|
|
79
|
-
*
|
|
80
85
|
* @param {string} commands - Current commands string
|
|
81
86
|
* @returns {string}
|
|
82
87
|
*/
|
|
@@ -84,9 +89,8 @@ export const getSaveOptionalParameter = (commands) => commands.concat(' --save-o
|
|
|
84
89
|
|
|
85
90
|
/**
|
|
86
91
|
* @function getRegistryParameter
|
|
87
|
-
*
|
|
92
|
+
* @description
|
|
88
93
|
* Get the "registry" parameter and argument
|
|
89
|
-
*
|
|
90
94
|
* @param {string} r - Registry
|
|
91
95
|
* @param {string} commands - Current commands string
|
|
92
96
|
* @returns {string}
|
|
@@ -95,9 +99,8 @@ export const getRegistryParameter = (r, commands) => r ? commands.concat(` --reg
|
|
|
95
99
|
|
|
96
100
|
/**
|
|
97
101
|
* @function getForceParameter
|
|
98
|
-
*
|
|
102
|
+
* @description
|
|
99
103
|
* Get the "force" parameter and argument
|
|
100
|
-
*
|
|
101
104
|
* @param {boolean} f - Force
|
|
102
105
|
* @param {string} commands - Current commands string
|
|
103
106
|
* @returns {string}
|
|
@@ -106,9 +109,8 @@ export const getForceParameter = (f, commands) => f ? commands.concat(' --force'
|
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* @function getNoSaveParameter
|
|
109
|
-
*
|
|
112
|
+
* @description
|
|
110
113
|
* Get the `--no-save` parameter
|
|
111
|
-
*
|
|
112
114
|
* @param {boolean} s - Save
|
|
113
115
|
* @param {string} commands - Current commands string
|
|
114
116
|
* @returns {string}
|
|
@@ -117,9 +119,8 @@ export const getNoSaveParameter = (s, commands) => s ? commands : commands.conca
|
|
|
117
119
|
|
|
118
120
|
/**
|
|
119
121
|
* @function getSaveExactParameter
|
|
120
|
-
*
|
|
122
|
+
* @description
|
|
121
123
|
* Get the `--save-exact` parameter
|
|
122
|
-
*
|
|
123
124
|
* @param {string} commands - Current commands string
|
|
124
125
|
* @returns {string}
|
|
125
126
|
*/
|
|
@@ -127,9 +128,8 @@ export const getSaveExactParameter = (commands) => commands.concat(' --save-exac
|
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
130
|
* @function getExportPath
|
|
130
|
-
*
|
|
131
|
+
* @description
|
|
131
132
|
* Get the export PATH shell script
|
|
132
|
-
*
|
|
133
133
|
* @param {string} commands - Current commands string
|
|
134
134
|
* @returns {string}
|
|
135
135
|
*/
|
|
@@ -140,9 +140,8 @@ ${commands}
|
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
142
|
* @function getNvm
|
|
143
|
-
*
|
|
143
|
+
* @description
|
|
144
144
|
* Get the NVM shell script
|
|
145
|
-
*
|
|
146
145
|
* @param {string} commands - Current commands string
|
|
147
146
|
* @returns {string}
|
|
148
147
|
*/
|
|
@@ -153,9 +152,8 @@ ${commands}
|
|
|
153
152
|
|
|
154
153
|
/**
|
|
155
154
|
* @function getCommands
|
|
156
|
-
*
|
|
155
|
+
* @description
|
|
157
156
|
* Get the installation shell script
|
|
158
|
-
*
|
|
159
157
|
* @param {string} commands - Current commands string
|
|
160
158
|
* @returns {string}
|
|
161
159
|
*/
|
|
@@ -165,9 +163,8 @@ export const getCommands = PLATFORM === 'win32'
|
|
|
165
163
|
|
|
166
164
|
/**
|
|
167
165
|
* @function getProdDependencies
|
|
168
|
-
*
|
|
166
|
+
* @description
|
|
169
167
|
* Get the production dependencies by destructuring the package or configuration
|
|
170
|
-
*
|
|
171
168
|
* @param {Package | Configuration} deps
|
|
172
169
|
* @returns {Dependencies}
|
|
173
170
|
*/
|
|
@@ -175,9 +172,8 @@ export const getProdDependencies = ({ dependencies = {} } = {}) => dependencies
|
|
|
175
172
|
|
|
176
173
|
/**
|
|
177
174
|
* @function getDevDependencies
|
|
178
|
-
*
|
|
175
|
+
* @description
|
|
179
176
|
* Get the development dependencies by destructuring the package or configuration
|
|
180
|
-
*
|
|
181
177
|
* @param {Package | Configuration} deps
|
|
182
178
|
* @returns {Dependencies}
|
|
183
179
|
*/
|
|
@@ -185,9 +181,8 @@ export const getDevDependencies = ({ devDependencies = {} } = {}) => devDependen
|
|
|
185
181
|
|
|
186
182
|
/**
|
|
187
183
|
* @function getOptionalDependencies
|
|
188
|
-
*
|
|
184
|
+
* @description
|
|
189
185
|
* Get the optional dependencies by destructuring the package or configuration
|
|
190
|
-
*
|
|
191
186
|
* @param {Package | Configuration} deps
|
|
192
187
|
* @returns {Dependencies}
|
|
193
188
|
*/
|
|
@@ -195,9 +190,8 @@ export const getOptionalDependencies = ({ optionalDependencies = {} } = {}) => o
|
|
|
195
190
|
|
|
196
191
|
/**
|
|
197
192
|
* @function getBundleDependencies
|
|
198
|
-
*
|
|
193
|
+
* @description
|
|
199
194
|
* Get the bundle dependencies by destructuring the package or configuration
|
|
200
|
-
*
|
|
201
195
|
* @param {Package | Configuration} deps
|
|
202
196
|
* @returns {Dependencies}
|
|
203
197
|
*/
|
|
@@ -205,9 +199,8 @@ export const getBundleDependencies = ({ bundleDependencies = {} } = {}) => bundl
|
|
|
205
199
|
|
|
206
200
|
/**
|
|
207
201
|
* @function getPeerDependencies
|
|
208
|
-
*
|
|
202
|
+
* @description
|
|
209
203
|
* Get the peer dependencies by destructuring the package or configuration
|
|
210
|
-
*
|
|
211
204
|
* @param {Package | Configuration} deps
|
|
212
205
|
* @returns {Dependencies}
|
|
213
206
|
*/
|
|
@@ -215,9 +208,8 @@ export const getPeerDependencies = ({ peerDependencies = {} } = {}) => peerDepen
|
|
|
215
208
|
|
|
216
209
|
/**
|
|
217
210
|
* @function getIgnore
|
|
218
|
-
*
|
|
211
|
+
* @description
|
|
219
212
|
* Get the ignore flag by destructuring the configuration
|
|
220
|
-
*
|
|
221
213
|
* @param {Configuration} deps
|
|
222
214
|
* @returns {boolean}
|
|
223
215
|
*/
|
|
@@ -225,9 +217,8 @@ export const getIgnore = ({ ignore = false } = {}) => ignore === true
|
|
|
225
217
|
|
|
226
218
|
/**
|
|
227
219
|
* @function getAuthor
|
|
228
|
-
*
|
|
220
|
+
* @description
|
|
229
221
|
* Get the author by destructuring the package or configuration
|
|
230
|
-
*
|
|
231
222
|
* @param {Package | Configuration} deps
|
|
232
223
|
* @returns {string | null}
|
|
233
224
|
*/
|
|
@@ -254,9 +245,8 @@ export const getAuthor = ({ author = '' } = {}) => {
|
|
|
254
245
|
|
|
255
246
|
/**
|
|
256
247
|
* @function getMessage
|
|
257
|
-
*
|
|
248
|
+
* @description
|
|
258
249
|
* Get the message by destructuring the configuration
|
|
259
|
-
*
|
|
260
250
|
* @param {Configuration} deps
|
|
261
251
|
* @returns {string | null}
|
|
262
252
|
*/
|
|
@@ -264,9 +254,8 @@ export const getMessage = ({ message = '' } = {}) => message || null
|
|
|
264
254
|
|
|
265
255
|
/**
|
|
266
256
|
* @function isPreRelease
|
|
267
|
-
*
|
|
257
|
+
* @description
|
|
268
258
|
* Determine whether the dependency is a pre-release with a Regular Expression
|
|
269
|
-
*
|
|
270
259
|
* @param {string} v
|
|
271
260
|
* @returns {boolean}
|
|
272
261
|
*/
|
|
@@ -274,9 +263,8 @@ export const isPreRelease = (v) => /-/.test(v)
|
|
|
274
263
|
|
|
275
264
|
/**
|
|
276
265
|
* @function isExact
|
|
277
|
-
*
|
|
266
|
+
* @description
|
|
278
267
|
* Determine whether the dependency is exact with a Regular Expression
|
|
279
|
-
*
|
|
280
268
|
* @param {string} v
|
|
281
269
|
* @returns {boolean}
|
|
282
270
|
*/
|
|
@@ -300,7 +288,7 @@ function excludeVersionIsExact ([name, version]) {
|
|
|
300
288
|
|
|
301
289
|
/**
|
|
302
290
|
* @function getMapToDepsExactVersionFromConfiguration
|
|
303
|
-
*
|
|
291
|
+
* @description
|
|
304
292
|
* Produces an array of objects from the entries of `packageDependencies` which have
|
|
305
293
|
* exact versions
|
|
306
294
|
*
|
|
@@ -308,7 +296,6 @@ function excludeVersionIsExact ([name, version]) {
|
|
|
308
296
|
*
|
|
309
297
|
* Each entry is mapped to the same package name in `configurationDependencies` if it
|
|
310
298
|
* appears there. Otherwise, the `packageDependencies` version is used
|
|
311
|
-
*
|
|
312
299
|
* @param {Record<string, string>} configurationDependencies
|
|
313
300
|
* @returns {(entry: [name: string, version: string]) => {
|
|
314
301
|
* name: string,
|
|
@@ -342,13 +329,12 @@ function getMapToDepsExactVersionFromConfiguration (configurationDependencies) {
|
|
|
342
329
|
|
|
343
330
|
/**
|
|
344
331
|
* @function mapToDepsVersion
|
|
345
|
-
*
|
|
332
|
+
* @description
|
|
346
333
|
* Produces an array of objects from the entries of `packageDependencies` which do not have
|
|
347
334
|
* exact versions
|
|
348
335
|
*
|
|
349
336
|
* Where the version is a pre-release, that version is used. Otherwise the version is
|
|
350
337
|
* set to `latest` to ensure that package is updated
|
|
351
|
-
*
|
|
352
338
|
* @param {[name: string, version: string]} entry
|
|
353
339
|
* @returns {{
|
|
354
340
|
* name: string,
|
|
@@ -376,9 +362,8 @@ function mapToDepsVersion (entry) {
|
|
|
376
362
|
|
|
377
363
|
/**
|
|
378
364
|
* @function getDepsExact
|
|
379
|
-
*
|
|
365
|
+
* @description
|
|
380
366
|
* Get an array of dependencies to be installed with the `--save-exact` parameter
|
|
381
|
-
*
|
|
382
367
|
* @param {Dependencies} packageDependencies - Package dependencies
|
|
383
368
|
* @param {Dependencies} configurationDependencies - Configuration dependencies
|
|
384
369
|
* @returns {DependencyDescriptor[]}
|
|
@@ -395,9 +380,8 @@ export function getDepsExact (packageDependencies, configurationDependencies) {
|
|
|
395
380
|
|
|
396
381
|
/**
|
|
397
382
|
* @function getDeps
|
|
398
|
-
*
|
|
383
|
+
* @description
|
|
399
384
|
* Get an array of dependencies to be installed
|
|
400
|
-
*
|
|
401
385
|
* @param {Dependencies} packageDependencies - Package dependencies
|
|
402
386
|
* @returns {DependencyDescriptor[]}
|
|
403
387
|
*/
|
|
@@ -413,29 +397,27 @@ export function getDeps (packageDependencies) {
|
|
|
413
397
|
|
|
414
398
|
/**
|
|
415
399
|
* @function normalizeCommands
|
|
416
|
-
*
|
|
400
|
+
* @description
|
|
417
401
|
* Normalise the commands string
|
|
418
|
-
*
|
|
419
402
|
* @param {string} commands
|
|
420
403
|
* @returns {string}
|
|
421
404
|
*/
|
|
422
405
|
export function normalizeCommands (commands) {
|
|
423
|
-
|
|
406
|
+
let c = commands
|
|
424
407
|
|
|
425
|
-
while (/\s{2,} | \n+/.test(
|
|
426
|
-
|
|
408
|
+
while (/\s{2,} | \n+/.test(c)) {
|
|
409
|
+
c = c.replace(/\s{2,}/gm, SP).replace(/\n+/gm, SP)
|
|
427
410
|
}
|
|
428
411
|
|
|
429
412
|
return (
|
|
430
|
-
|
|
413
|
+
c.trim()
|
|
431
414
|
)
|
|
432
415
|
}
|
|
433
416
|
|
|
434
417
|
/**
|
|
435
418
|
* @function transformDependency
|
|
436
|
-
*
|
|
419
|
+
* @description
|
|
437
420
|
* Transform by destructuring the value
|
|
438
|
-
*
|
|
439
421
|
* @param {DependencyDescriptor | { name?: string, version?: string }} dependencyDescriptor
|
|
440
422
|
* @returns {string}
|
|
441
423
|
*/
|
|
@@ -443,9 +425,8 @@ export const transformDependency = ({ name = '@modernpoacher/deps', version = 'l
|
|
|
443
425
|
|
|
444
426
|
/**
|
|
445
427
|
* @function transform
|
|
446
|
-
*
|
|
428
|
+
* @description
|
|
447
429
|
* Transform the parameter to a string
|
|
448
|
-
*
|
|
449
430
|
* @param {DependencyDescriptor | DependencyDescriptor[]} value
|
|
450
431
|
* @returns {string}
|
|
451
432
|
*/
|
|
@@ -454,7 +435,7 @@ export function transform (value) {
|
|
|
454
435
|
|
|
455
436
|
return (
|
|
456
437
|
Array.isArray(value)
|
|
457
|
-
? value.map(transformDependency).join(
|
|
438
|
+
? value.map(transformDependency).join(SP).trim()
|
|
458
439
|
: transformDependency(value)
|
|
459
440
|
)
|
|
460
441
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {DepsTypes.Options} Options
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import debug from 'debug'
|
|
5
|
+
import debug from '#deps/src/common/debug'
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
VERSION,
|
|
@@ -42,7 +42,8 @@ log(`\`common/options\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* @function getOptions
|
|
45
|
-
*
|
|
45
|
+
* @description
|
|
46
|
+
* `exec` shell options
|
|
46
47
|
* @param {string} [cwd] normalized directory
|
|
47
48
|
* @returns {Options & { cwd?: string }}
|
|
48
49
|
*/
|