@modernpoacher/deps 2.2.30 → 2.2.32
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/bash/deps.sh +0 -7
- package/bin/bash/head.sh +0 -7
- package/bin/bash/push.sh +0 -7
- package/bin/bash/wipe.sh +0 -7
- package/bin/common/index.mjs +36 -8
- package/bin/deps/deps.sh +0 -7
- package/bin/deps/execute.sh +0 -7
- package/bin/deps/head.sh +0 -7
- package/bin/deps/install.sh +0 -7
- package/bin/deps/push.sh +0 -7
- package/bin/deps/wipe.sh +0 -7
- package/bin/deps.sh +0 -7
- package/bin/node/execute.mjs +26 -1
- package/package.json +10 -10
- package/src/common/format/index.mjs +63 -0
- package/src/common/git/index.mjs +92 -4
- package/src/common/index.mjs +90 -29
- package/src/index.mjs +4 -0
- package/tsconfig.json +1 -1
package/bin/bash/deps.sh
CHANGED
package/bin/bash/head.sh
CHANGED
package/bin/bash/push.sh
CHANGED
package/bin/bash/wipe.sh
CHANGED
package/bin/common/index.mjs
CHANGED
|
@@ -83,19 +83,25 @@ const SP = String.fromCodePoint(32)
|
|
|
83
83
|
* @param {string} v
|
|
84
84
|
* @returns {string}
|
|
85
85
|
*/
|
|
86
|
-
export
|
|
86
|
+
export function trim (v) {
|
|
87
|
+
return v.split(LF).map(trimEnd).join(LF).trim()
|
|
88
|
+
}
|
|
87
89
|
|
|
88
90
|
/**
|
|
89
91
|
* @param {string} v
|
|
90
92
|
* @returns {string}
|
|
91
93
|
*/
|
|
92
|
-
export
|
|
94
|
+
export function trimEnd (v) {
|
|
95
|
+
return v.trimEnd()
|
|
96
|
+
}
|
|
93
97
|
|
|
94
98
|
/**
|
|
95
99
|
* @param {string} v
|
|
96
100
|
* @returns {string}
|
|
97
101
|
*/
|
|
98
|
-
export
|
|
102
|
+
export function tidy (v) {
|
|
103
|
+
return v.replace(/\n{2,}}/gm, LF).trim()
|
|
104
|
+
}
|
|
99
105
|
|
|
100
106
|
const getRmrfCommands = PLATFORM === 'win32'
|
|
101
107
|
? () => tidy(`
|
|
@@ -211,18 +217,40 @@ export function handleComplete (e) {
|
|
|
211
217
|
/**
|
|
212
218
|
* @param {{ code?: number, message?: string }} e
|
|
213
219
|
*/
|
|
214
|
-
|
|
220
|
+
function handlePackageError ({ message = MESSAGE }) {
|
|
221
|
+
info(`Package error: "${message}"`)
|
|
222
|
+
}
|
|
215
223
|
|
|
216
224
|
/**
|
|
217
225
|
* @param {{ code?: number, message?: string }} e
|
|
218
226
|
*/
|
|
219
|
-
|
|
227
|
+
function handleConfigurationError ({ message = MESSAGE }) {
|
|
228
|
+
info(`Configuration error: "${message}"`)
|
|
229
|
+
}
|
|
220
230
|
|
|
221
|
-
|
|
231
|
+
/**
|
|
232
|
+
*
|
|
233
|
+
* @param directory
|
|
234
|
+
*/
|
|
235
|
+
function getPackageJsonPath (directory = DIRECTORY) {
|
|
236
|
+
return resolve(join(directory, 'package.json'))
|
|
237
|
+
}
|
|
222
238
|
|
|
223
|
-
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
* @param directory
|
|
242
|
+
*/
|
|
243
|
+
function getDepsRcPath (directory = DIRECTORY) {
|
|
244
|
+
return resolve(join(directory, '.depsrc'))
|
|
245
|
+
}
|
|
224
246
|
|
|
225
|
-
|
|
247
|
+
/**
|
|
248
|
+
*
|
|
249
|
+
* @param directory
|
|
250
|
+
*/
|
|
251
|
+
function getDepsRcJsonPath (directory = DIRECTORY) {
|
|
252
|
+
return resolve(join(directory, '.depsrc.json'))
|
|
253
|
+
}
|
|
226
254
|
|
|
227
255
|
/**
|
|
228
256
|
* @param {string} directory
|
package/bin/deps/deps.sh
CHANGED
package/bin/deps/execute.sh
CHANGED
package/bin/deps/head.sh
CHANGED
package/bin/deps/install.sh
CHANGED
package/bin/deps/push.sh
CHANGED
package/bin/deps/wipe.sh
CHANGED
package/bin/deps.sh
CHANGED
package/bin/node/execute.mjs
CHANGED
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
MESSAGE,
|
|
27
27
|
AUTHOR,
|
|
28
|
+
gitConfigUserName,
|
|
29
|
+
gitConfigUserEmail,
|
|
28
30
|
catGitRefsRemotesOriginHead,
|
|
29
31
|
awkGitRemoteShowOriginHead,
|
|
30
32
|
gitRevParseShowTopLevel,
|
|
@@ -147,6 +149,26 @@ async function getAuthorFromConfiguration (directory) {
|
|
|
147
149
|
)
|
|
148
150
|
}
|
|
149
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @function getAuthorFromGit
|
|
154
|
+
* @description
|
|
155
|
+
* Interrogates Git config for the user name and email
|
|
156
|
+
* @param {string} directory
|
|
157
|
+
* @returns {Promise<string | null>}
|
|
158
|
+
*/
|
|
159
|
+
async function getAuthorFromGit (directory) {
|
|
160
|
+
log('getAuthorFromGitConfig')
|
|
161
|
+
|
|
162
|
+
const GIT = {
|
|
163
|
+
name: await gitConfigUserName(directory),
|
|
164
|
+
email: await gitConfigUserEmail(directory)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
getAuthor(GIT)
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
150
172
|
/**
|
|
151
173
|
* @function getAuthorFromPackage
|
|
152
174
|
* @description
|
|
@@ -201,7 +223,7 @@ async function getMessageFromConfiguration (directory) {
|
|
|
201
223
|
* @returns {Promise<string | { name: string; email: string }>}
|
|
202
224
|
*/
|
|
203
225
|
async function toAuthor (author, directory) {
|
|
204
|
-
return author || await getAuthorFromConfiguration(directory) || await getAuthorFromPackage(directory) || AUTHOR
|
|
226
|
+
return author || await getAuthorFromConfiguration(directory) || await getAuthorFromGit(directory) || await getAuthorFromPackage(directory) || AUTHOR
|
|
205
227
|
}
|
|
206
228
|
|
|
207
229
|
/**
|
|
@@ -336,8 +358,10 @@ async function iterate (directory, registry, force, message, author) {
|
|
|
336
358
|
try {
|
|
337
359
|
if (D === await gitRevParseShowTopLevel(D)) {
|
|
338
360
|
const B = await isHeadDefaultBranch(D)
|
|
361
|
+
|
|
339
362
|
if (B) {
|
|
340
363
|
const ignore = await getIgnoreFromConfiguration(D)
|
|
364
|
+
|
|
341
365
|
if (!ignore) {
|
|
342
366
|
await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
|
|
343
367
|
}
|
|
@@ -355,6 +379,7 @@ async function iterate (directory, registry, force, message, author) {
|
|
|
355
379
|
* @param {boolean} force
|
|
356
380
|
* @param {string} message
|
|
357
381
|
* @param {string | { name: string; email: string }} author
|
|
382
|
+
* @returns {Promise<void>}
|
|
358
383
|
*/
|
|
359
384
|
async function iteratePath (directory, registry, force, message, author) {
|
|
360
385
|
log('iteratePath')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.32",
|
|
4
4
|
"description": "Update NPM package dependencies from the command line",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deps",
|
|
@@ -54,26 +54,26 @@
|
|
|
54
54
|
"deps-wipe": "bin/deps/wipe.sh"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@sequencemedia/write": "^0.2.
|
|
57
|
+
"@sequencemedia/write": "^0.2.9",
|
|
58
58
|
"commander": "^14.0.1",
|
|
59
|
-
"debug": "^4.4.
|
|
59
|
+
"debug": "^4.4.3",
|
|
60
60
|
"glob": "^11.0.3",
|
|
61
61
|
"strip-ansi": "^7.1.2",
|
|
62
62
|
"supports-color": "^10.2.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@sequencemedia/eslint-config-standard": "^0.2.
|
|
66
|
-
"@sequencemedia/eslint-config-typescript": "^0.1.
|
|
67
|
-
"@sequencemedia/eslint-merge": "^0.0.
|
|
65
|
+
"@sequencemedia/eslint-config-standard": "^0.2.85",
|
|
66
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.146",
|
|
67
|
+
"@sequencemedia/eslint-merge": "^0.0.52",
|
|
68
68
|
"@types/chai": "^5.2.2",
|
|
69
69
|
"@types/debug": "^4.1.12",
|
|
70
70
|
"@types/mocha": "^10.0.10",
|
|
71
|
-
"@types/node": "^24.
|
|
72
|
-
"@typescript-eslint/parser": "^8.
|
|
71
|
+
"@types/node": "^24.5.2",
|
|
72
|
+
"@typescript-eslint/parser": "^8.44.1",
|
|
73
73
|
"chai": "^6.0.1",
|
|
74
74
|
"cross-env": "^10.0.0",
|
|
75
|
-
"eslint": "^9.
|
|
76
|
-
"eslint-plugin-jsdoc": "^
|
|
75
|
+
"eslint": "^9.36.0",
|
|
76
|
+
"eslint-plugin-jsdoc": "^60.1.1",
|
|
77
77
|
"globals": "^16.4.0",
|
|
78
78
|
"husky": "^9.1.7",
|
|
79
79
|
"mocha": "^11.7.2"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import debug from 'debug'
|
|
2
|
+
|
|
3
|
+
import stripAnsi from 'strip-ansi'
|
|
4
|
+
|
|
5
|
+
const LF = String.fromCodePoint(32)
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} v
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
export function tidy (v) {
|
|
12
|
+
return v.replace(/\n{2,}}/gm, LF).trim()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} v
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
export function trimEnd (v) {
|
|
20
|
+
return v.trimEnd()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} v
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
export function trim (v) {
|
|
28
|
+
return v.split(LF).map(trimEnd).join(LF).trim()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} v
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
function filter (v) {
|
|
36
|
+
return Boolean(stripAnsi(v).trim())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} key
|
|
41
|
+
* @returns {(value: string) => void}
|
|
42
|
+
*/
|
|
43
|
+
export function use (key) {
|
|
44
|
+
const log = debug(`@modernpoacher/deps:${key}`)
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} v
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
function write (v) {
|
|
51
|
+
log(v.trimEnd())
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} value
|
|
56
|
+
* @returns {void}
|
|
57
|
+
*/
|
|
58
|
+
return function use (value) {
|
|
59
|
+
value.split(LF)
|
|
60
|
+
.filter(filter)
|
|
61
|
+
.forEach(write)
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/common/git/index.mjs
CHANGED
|
@@ -77,13 +77,25 @@ const LF = String.fromCodePoint(10)
|
|
|
77
77
|
* @param {string} v
|
|
78
78
|
* @returns {string}
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
export function trim (v) {
|
|
81
|
+
return v.split(LF).map(trimEnd).join(LF).trim()
|
|
82
|
+
}
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* @param {string} v
|
|
84
86
|
* @returns {string}
|
|
85
87
|
*/
|
|
86
|
-
|
|
88
|
+
export function trimEnd (v) {
|
|
89
|
+
return v.trimEnd()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {string} v
|
|
94
|
+
* @returns {string}
|
|
95
|
+
*/
|
|
96
|
+
export function tidy (v) {
|
|
97
|
+
return v.replace(/\n{2,}}/gm, LF).trim()
|
|
98
|
+
}
|
|
87
99
|
|
|
88
100
|
/**
|
|
89
101
|
* @param {string} v
|
|
@@ -126,6 +138,10 @@ export function use (key) {
|
|
|
126
138
|
log(v.trimEnd())
|
|
127
139
|
}
|
|
128
140
|
|
|
141
|
+
/**
|
|
142
|
+
* @param {string} value
|
|
143
|
+
* @returns {void}
|
|
144
|
+
*/
|
|
129
145
|
return function use (value) {
|
|
130
146
|
value.split(LF)
|
|
131
147
|
.filter(filter)
|
|
@@ -214,7 +230,7 @@ export function err (key, directory) {
|
|
|
214
230
|
* @param {{code?: number, message?: string}} e
|
|
215
231
|
* @returns {number}
|
|
216
232
|
*/
|
|
217
|
-
const getErrorCode = ({ code = 0 }
|
|
233
|
+
const getErrorCode = ({ code = 0 }) => code
|
|
218
234
|
|
|
219
235
|
/**
|
|
220
236
|
* @function getErrorMessage
|
|
@@ -223,7 +239,7 @@ const getErrorCode = ({ code = 0 } = {}) => code
|
|
|
223
239
|
* @param {{code?: number, message?: string}} e
|
|
224
240
|
* @returns {string}
|
|
225
241
|
*/
|
|
226
|
-
const getErrorMessage = ({ message = '' }
|
|
242
|
+
const getErrorMessage = ({ message = '' }) => message
|
|
227
243
|
|
|
228
244
|
/**
|
|
229
245
|
* @function isCommandError
|
|
@@ -241,6 +257,78 @@ function isCommandError (e) {
|
|
|
241
257
|
)
|
|
242
258
|
}
|
|
243
259
|
|
|
260
|
+
/**
|
|
261
|
+
* @function gitConfigUserName
|
|
262
|
+
* @description
|
|
263
|
+
* Get the user email from Git config
|
|
264
|
+
* @param {string} d - A directory configured for Git
|
|
265
|
+
* @returns {Promise<string>}
|
|
266
|
+
*/
|
|
267
|
+
export function gitConfigUserName (d = DIRECTORY) {
|
|
268
|
+
const directory = normalize(d.trim())
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
new Promise((resolve, reject) => {
|
|
272
|
+
const commands = 'git config user.name'
|
|
273
|
+
const options = getOptions(directory)
|
|
274
|
+
/**
|
|
275
|
+
* @type {HandleComplete}
|
|
276
|
+
*/
|
|
277
|
+
function handleComplete (e, v) {
|
|
278
|
+
if (!e) {
|
|
279
|
+
resolve(trim(v))
|
|
280
|
+
} else {
|
|
281
|
+
reject(e)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const {
|
|
286
|
+
stdout,
|
|
287
|
+
stderr
|
|
288
|
+
} = exec(commands, options, handleComplete)
|
|
289
|
+
|
|
290
|
+
if (stdout) stdout.on('data', out('git-config-user-name', directory))
|
|
291
|
+
if (stderr) stderr.on('data', err('git-config-user-name', directory))
|
|
292
|
+
})
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @function gitConfigUserEmail
|
|
298
|
+
* @description
|
|
299
|
+
* Get the user email from Git config
|
|
300
|
+
* @param {string} d - A directory configured for Git
|
|
301
|
+
* @returns {Promise<string>}
|
|
302
|
+
*/
|
|
303
|
+
export function gitConfigUserEmail (d = DIRECTORY) {
|
|
304
|
+
const directory = normalize(d.trim())
|
|
305
|
+
|
|
306
|
+
return (
|
|
307
|
+
new Promise((resolve, reject) => {
|
|
308
|
+
const commands = 'git config user.email'
|
|
309
|
+
const options = getOptions(directory)
|
|
310
|
+
/**
|
|
311
|
+
* @type {HandleComplete}
|
|
312
|
+
*/
|
|
313
|
+
function handleComplete (e, v) {
|
|
314
|
+
if (!e) {
|
|
315
|
+
resolve(trim(v))
|
|
316
|
+
} else {
|
|
317
|
+
reject(e)
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const {
|
|
322
|
+
stdout,
|
|
323
|
+
stderr
|
|
324
|
+
} = exec(commands, options, handleComplete)
|
|
325
|
+
|
|
326
|
+
if (stdout) stdout.on('data', out('git-config-user-email', directory))
|
|
327
|
+
if (stderr) stderr.on('data', err('git-config-user-email', directory))
|
|
328
|
+
})
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
|
|
244
332
|
/**
|
|
245
333
|
* @function catGitRefsRemotesOriginHead
|
|
246
334
|
* @description
|
package/src/common/index.mjs
CHANGED
|
@@ -37,19 +37,25 @@ const SP = String.fromCodePoint(32)
|
|
|
37
37
|
* @param {string} v
|
|
38
38
|
* @returns {string}
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export function trim (v) {
|
|
41
|
+
return v.split(LF).map(trimEnd).join(LF).trim()
|
|
42
|
+
}
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* @param {string} v
|
|
44
46
|
* @returns {string}
|
|
45
47
|
*/
|
|
46
|
-
export
|
|
48
|
+
export function trimEnd (v) {
|
|
49
|
+
return v.trimEnd()
|
|
50
|
+
}
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
53
|
* @param {string} v
|
|
50
54
|
* @returns {string}
|
|
51
55
|
*/
|
|
52
|
-
export
|
|
56
|
+
export function tidy (v) {
|
|
57
|
+
return v.replace(/\n{2,}}/gm, LF).trim()
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
55
61
|
* @function getSaveProdParameter
|
|
@@ -58,7 +64,9 @@ export const trim = (v) => v.split(LF).map(trimEnd).join(LF).trim()
|
|
|
58
64
|
* @param {string} commands commands string
|
|
59
65
|
* @returns {string}
|
|
60
66
|
*/
|
|
61
|
-
export
|
|
67
|
+
export function getSaveProdParameter (commands) {
|
|
68
|
+
return commands.concat(' --save-prod')
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
/**
|
|
64
72
|
* @function getSaveDevParameter
|
|
@@ -67,7 +75,9 @@ export const getSaveProdParameter = (commands) => commands.concat(' --save-prod'
|
|
|
67
75
|
* @param {string} commands commands string
|
|
68
76
|
* @returns {string}
|
|
69
77
|
*/
|
|
70
|
-
export
|
|
78
|
+
export function getSaveDevParameter (commands) {
|
|
79
|
+
return commands.concat(' --save-dev')
|
|
80
|
+
}
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
83
|
* @function getSaveBundleParameter
|
|
@@ -76,7 +86,9 @@ export const getSaveDevParameter = (commands) => commands.concat(' --save-dev')
|
|
|
76
86
|
* @param {string} commands - Current commands string
|
|
77
87
|
* @returns {string}
|
|
78
88
|
*/
|
|
79
|
-
export
|
|
89
|
+
export function getSaveBundleParameter (commands) {
|
|
90
|
+
return commands.concat(' --save-bundle')
|
|
91
|
+
}
|
|
80
92
|
|
|
81
93
|
/**
|
|
82
94
|
* @function getSaveOptionalParameter
|
|
@@ -85,7 +97,9 @@ export const getSaveBundleParameter = (commands) => commands.concat(' --save-bun
|
|
|
85
97
|
* @param {string} commands - Current commands string
|
|
86
98
|
* @returns {string}
|
|
87
99
|
*/
|
|
88
|
-
export
|
|
100
|
+
export function getSaveOptionalParameter (commands) {
|
|
101
|
+
return commands.concat(' --save-optional')
|
|
102
|
+
}
|
|
89
103
|
|
|
90
104
|
/**
|
|
91
105
|
* @function getRegistryParameter
|
|
@@ -95,7 +109,9 @@ export const getSaveOptionalParameter = (commands) => commands.concat(' --save-o
|
|
|
95
109
|
* @param {string} commands - Current commands string
|
|
96
110
|
* @returns {string}
|
|
97
111
|
*/
|
|
98
|
-
export
|
|
112
|
+
export function getRegistryParameter (r, commands) {
|
|
113
|
+
return r ? commands.concat(` --registry ${r}`) : commands
|
|
114
|
+
}
|
|
99
115
|
|
|
100
116
|
/**
|
|
101
117
|
* @function getForceParameter
|
|
@@ -105,7 +121,9 @@ export const getRegistryParameter = (r, commands) => r ? commands.concat(` --reg
|
|
|
105
121
|
* @param {string} commands - Current commands string
|
|
106
122
|
* @returns {string}
|
|
107
123
|
*/
|
|
108
|
-
export
|
|
124
|
+
export function getForceParameter (f, commands) {
|
|
125
|
+
return f ? commands.concat(' --force') : commands
|
|
126
|
+
}
|
|
109
127
|
|
|
110
128
|
/**
|
|
111
129
|
* @function getNoSaveParameter
|
|
@@ -115,7 +133,9 @@ export const getForceParameter = (f, commands) => f ? commands.concat(' --force'
|
|
|
115
133
|
* @param {string} commands - Current commands string
|
|
116
134
|
* @returns {string}
|
|
117
135
|
*/
|
|
118
|
-
export
|
|
136
|
+
export function getNoSaveParameter (s, commands) {
|
|
137
|
+
return s ? commands : commands.concat(' --no-save')
|
|
138
|
+
}
|
|
119
139
|
|
|
120
140
|
/**
|
|
121
141
|
* @function getSaveExactParameter
|
|
@@ -124,7 +144,9 @@ export const getNoSaveParameter = (s, commands) => s ? commands : commands.conca
|
|
|
124
144
|
* @param {string} commands - Current commands string
|
|
125
145
|
* @returns {string}
|
|
126
146
|
*/
|
|
127
|
-
export
|
|
147
|
+
export function getSaveExactParameter (commands) {
|
|
148
|
+
return commands.concat(' --save-exact')
|
|
149
|
+
}
|
|
128
150
|
|
|
129
151
|
/**
|
|
130
152
|
* @function getExportPath
|
|
@@ -133,10 +155,12 @@ export const getSaveExactParameter = (commands) => commands.concat(' --save-exac
|
|
|
133
155
|
* @param {string} commands - Current commands string
|
|
134
156
|
* @returns {string}
|
|
135
157
|
*/
|
|
136
|
-
export
|
|
158
|
+
export function getExportPath (commands) {
|
|
159
|
+
return `
|
|
137
160
|
export PATH=/usr/local/bin:$PATH &> /dev/null
|
|
138
161
|
${commands}
|
|
139
162
|
`
|
|
163
|
+
}
|
|
140
164
|
|
|
141
165
|
/**
|
|
142
166
|
* @function getNvm
|
|
@@ -145,10 +169,12 @@ ${commands}
|
|
|
145
169
|
* @param {string} commands - Current commands string
|
|
146
170
|
* @returns {string}
|
|
147
171
|
*/
|
|
148
|
-
export
|
|
172
|
+
export function getNvm (commands) {
|
|
173
|
+
return `
|
|
149
174
|
bash "${NVM}" 2> /dev/null
|
|
150
175
|
${commands}
|
|
151
176
|
`
|
|
177
|
+
}
|
|
152
178
|
|
|
153
179
|
/**
|
|
154
180
|
* @function getCommands
|
|
@@ -168,7 +194,9 @@ export const getCommands = PLATFORM === 'win32'
|
|
|
168
194
|
* @param {Package | Configuration} deps
|
|
169
195
|
* @returns {Dependencies}
|
|
170
196
|
*/
|
|
171
|
-
export
|
|
197
|
+
export function getProdDependencies ({ dependencies = {} }) {
|
|
198
|
+
return dependencies
|
|
199
|
+
}
|
|
172
200
|
|
|
173
201
|
/**
|
|
174
202
|
* @function getDevDependencies
|
|
@@ -177,7 +205,9 @@ export const getProdDependencies = ({ dependencies = {} } = {}) => dependencies
|
|
|
177
205
|
* @param {Package | Configuration} deps
|
|
178
206
|
* @returns {Dependencies}
|
|
179
207
|
*/
|
|
180
|
-
export
|
|
208
|
+
export function getDevDependencies ({ devDependencies = {} }) {
|
|
209
|
+
return devDependencies
|
|
210
|
+
}
|
|
181
211
|
|
|
182
212
|
/**
|
|
183
213
|
* @function getOptionalDependencies
|
|
@@ -186,7 +216,9 @@ export const getDevDependencies = ({ devDependencies = {} } = {}) => devDependen
|
|
|
186
216
|
* @param {Package | Configuration} deps
|
|
187
217
|
* @returns {Dependencies}
|
|
188
218
|
*/
|
|
189
|
-
export
|
|
219
|
+
export function getOptionalDependencies ({ optionalDependencies = {} }) {
|
|
220
|
+
return optionalDependencies
|
|
221
|
+
}
|
|
190
222
|
|
|
191
223
|
/**
|
|
192
224
|
* @function getBundleDependencies
|
|
@@ -195,7 +227,9 @@ export const getOptionalDependencies = ({ optionalDependencies = {} } = {}) => o
|
|
|
195
227
|
* @param {Package | Configuration} deps
|
|
196
228
|
* @returns {Dependencies}
|
|
197
229
|
*/
|
|
198
|
-
export
|
|
230
|
+
export function getBundleDependencies ({ bundleDependencies = {} }) {
|
|
231
|
+
return bundleDependencies
|
|
232
|
+
}
|
|
199
233
|
|
|
200
234
|
/**
|
|
201
235
|
* @function getPeerDependencies
|
|
@@ -204,7 +238,9 @@ export const getBundleDependencies = ({ bundleDependencies = {} } = {}) => bundl
|
|
|
204
238
|
* @param {Package | Configuration} deps
|
|
205
239
|
* @returns {Dependencies}
|
|
206
240
|
*/
|
|
207
|
-
export
|
|
241
|
+
export function getPeerDependencies ({ peerDependencies = {} }) {
|
|
242
|
+
return peerDependencies
|
|
243
|
+
}
|
|
208
244
|
|
|
209
245
|
/**
|
|
210
246
|
* @function getIgnore
|
|
@@ -213,7 +249,9 @@ export const getPeerDependencies = ({ peerDependencies = {} } = {}) => peerDepen
|
|
|
213
249
|
* @param {Configuration} deps
|
|
214
250
|
* @returns {boolean}
|
|
215
251
|
*/
|
|
216
|
-
export
|
|
252
|
+
export function getIgnore ({ ignore = false }) {
|
|
253
|
+
return ignore === true
|
|
254
|
+
}
|
|
217
255
|
|
|
218
256
|
/**
|
|
219
257
|
* @function getAuthor
|
|
@@ -222,7 +260,7 @@ export const getIgnore = ({ ignore = false } = {}) => ignore === true
|
|
|
222
260
|
* @param {Package | Configuration} deps
|
|
223
261
|
* @returns {string | null}
|
|
224
262
|
*/
|
|
225
|
-
export
|
|
263
|
+
export function getAuthor ({ author = '' }) {
|
|
226
264
|
if (typeof author === 'string') return author
|
|
227
265
|
if (typeof (author || false) === 'object') {
|
|
228
266
|
const {
|
|
@@ -250,7 +288,9 @@ export const getAuthor = ({ author = '' } = {}) => {
|
|
|
250
288
|
* @param {Configuration} deps
|
|
251
289
|
* @returns {string | null}
|
|
252
290
|
*/
|
|
253
|
-
export
|
|
291
|
+
export function getMessage ({ message = '' }) {
|
|
292
|
+
return message || null
|
|
293
|
+
}
|
|
254
294
|
|
|
255
295
|
/**
|
|
256
296
|
* @function isPreRelease
|
|
@@ -259,7 +299,9 @@ export const getMessage = ({ message = '' } = {}) => message || null
|
|
|
259
299
|
* @param {string} v
|
|
260
300
|
* @returns {boolean}
|
|
261
301
|
*/
|
|
262
|
-
export
|
|
302
|
+
export function isPreRelease (v) {
|
|
303
|
+
return /-/.test(v)
|
|
304
|
+
}
|
|
263
305
|
|
|
264
306
|
/**
|
|
265
307
|
* @function isExact
|
|
@@ -268,10 +310,15 @@ export const isPreRelease = (v) => /-/.test(v)
|
|
|
268
310
|
* @param {string} v
|
|
269
311
|
* @returns {boolean}
|
|
270
312
|
*/
|
|
271
|
-
export
|
|
313
|
+
export function isExact (v) {
|
|
314
|
+
return /^\d/.test(v)
|
|
315
|
+
}
|
|
272
316
|
|
|
273
317
|
/**
|
|
274
|
-
* @param {[
|
|
318
|
+
* @param {[
|
|
319
|
+
* name: string,
|
|
320
|
+
* version: string
|
|
321
|
+
* ]} entry
|
|
275
322
|
* @returns {boolean}
|
|
276
323
|
*/
|
|
277
324
|
function includeVersionIsExact ([name, version]) {
|
|
@@ -279,7 +326,10 @@ function includeVersionIsExact ([name, version]) {
|
|
|
279
326
|
}
|
|
280
327
|
|
|
281
328
|
/**
|
|
282
|
-
* @param {[
|
|
329
|
+
* @param {[
|
|
330
|
+
* name: string,
|
|
331
|
+
* version: string
|
|
332
|
+
* ]} entry
|
|
283
333
|
* @returns {boolean}
|
|
284
334
|
*/
|
|
285
335
|
function excludeVersionIsExact ([name, version]) {
|
|
@@ -297,14 +347,20 @@ function excludeVersionIsExact ([name, version]) {
|
|
|
297
347
|
* Each entry is mapped to the same package name in `configurationDependencies` if it
|
|
298
348
|
* appears there. Otherwise, the `packageDependencies` version is used
|
|
299
349
|
* @param {Record<string, string>} configurationDependencies
|
|
300
|
-
* @returns {(entry: [
|
|
350
|
+
* @returns {(entry: [
|
|
351
|
+
* name: string,
|
|
352
|
+
* version: string
|
|
353
|
+
* ]) => {
|
|
301
354
|
* name: string,
|
|
302
355
|
* version: string
|
|
303
356
|
* }}
|
|
304
357
|
*/
|
|
305
358
|
function getMapToDepsExactVersionFromConfiguration (configurationDependencies) {
|
|
306
359
|
/**
|
|
307
|
-
* @param {[
|
|
360
|
+
* @param {[
|
|
361
|
+
* name: string,
|
|
362
|
+
* version: string
|
|
363
|
+
* ]} entry
|
|
308
364
|
* @returns {{
|
|
309
365
|
* name: string,
|
|
310
366
|
* version: string
|
|
@@ -335,7 +391,10 @@ function getMapToDepsExactVersionFromConfiguration (configurationDependencies) {
|
|
|
335
391
|
*
|
|
336
392
|
* Where the version is a pre-release, that version is used. Otherwise the version is
|
|
337
393
|
* set to `latest` to ensure that package is updated
|
|
338
|
-
* @param {[
|
|
394
|
+
* @param {[
|
|
395
|
+
* name: string,
|
|
396
|
+
* version: string
|
|
397
|
+
* ]} entry
|
|
339
398
|
* @returns {{
|
|
340
399
|
* name: string,
|
|
341
400
|
* version: string
|
|
@@ -421,7 +480,9 @@ export function normalizeCommands (commands) {
|
|
|
421
480
|
* @param {DependencyDescriptor | { name?: string, version?: string }} dependencyDescriptor
|
|
422
481
|
* @returns {string}
|
|
423
482
|
*/
|
|
424
|
-
export
|
|
483
|
+
export function transformDependency ({ name = '@modernpoacher/deps', version = 'latest' }) {
|
|
484
|
+
return `${name}@${version}`
|
|
485
|
+
}
|
|
425
486
|
|
|
426
487
|
/**
|
|
427
488
|
* @function transform
|
package/src/index.mjs
CHANGED