@modernpoacher/deps 2.0.15 → 2.0.17
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/deps.sh +2 -2
- package/bin/push.sh +2 -2
- package/bin/wipe.sh +2 -2
- package/package.json +6 -6
- package/src/common/git/index.mjs +42 -47
- package/src/common/index.mjs +104 -74
- package/src/index.mjs +198 -164
- package/src/install/index.mjs +47 -31
package/bin/deps.sh
CHANGED
|
@@ -7,7 +7,7 @@ export PATH=/usr/local/bin:$PATH
|
|
|
7
7
|
EXP="[-0-9a-zA-Z]*$"
|
|
8
8
|
|
|
9
9
|
function update {
|
|
10
|
-
eval $(ssh-agent 1> /dev/null
|
|
10
|
+
eval $(ssh-agent) 1> /dev/null
|
|
11
11
|
git checkout $default_branch
|
|
12
12
|
git pull
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ function update {
|
|
|
19
19
|
git commit -m "Updated \`package.json\` &/ \`package-lock.json\`"
|
|
20
20
|
git push
|
|
21
21
|
git push --tags
|
|
22
|
-
eval $(ssh-agent -k 1> /dev/null
|
|
22
|
+
eval $(ssh-agent -k) 1> /dev/null
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function can_update {
|
package/bin/push.sh
CHANGED
|
@@ -37,11 +37,11 @@ function checkout_default_branch {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function update {
|
|
40
|
-
eval $(ssh-agent 1> /dev/null
|
|
40
|
+
eval $(ssh-agent) 1> /dev/null
|
|
41
41
|
git pull
|
|
42
42
|
git push
|
|
43
43
|
git push --tags
|
|
44
|
-
eval $(ssh-agent -k 1> /dev/null
|
|
44
|
+
eval $(ssh-agent -k) 1> /dev/null
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function execute {
|
package/bin/wipe.sh
CHANGED
|
@@ -37,12 +37,12 @@ function checkout_default_branch {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function update {
|
|
40
|
-
eval $(ssh-agent 1> /dev/null
|
|
40
|
+
eval $(ssh-agent) 1> /dev/null
|
|
41
41
|
git pull
|
|
42
42
|
git branch --merged | egrep -v "(^\*|$default_branch)" | xargs git branch -d
|
|
43
43
|
git remote prune origin
|
|
44
44
|
git gc --aggressive --prune=now
|
|
45
|
-
eval $(ssh-agent -k 1> /dev/null
|
|
45
|
+
eval $(ssh-agent -k) 1> /dev/null
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function execute {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Update NPM package dependencies from the command line",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deps",
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
"supports-color": "8.1.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@babel/cli": "^7.
|
|
61
|
-
"@babel/core": "^7.
|
|
60
|
+
"@babel/cli": "^7.21.0",
|
|
61
|
+
"@babel/core": "^7.21.0",
|
|
62
62
|
"@babel/eslint-parser": "^7.19.1",
|
|
63
63
|
"@babel/preset-env": "^7.20.2",
|
|
64
|
-
"@babel/register": "^7.
|
|
64
|
+
"@babel/register": "^7.21.0",
|
|
65
65
|
"chai": "^4.3.7",
|
|
66
|
-
"core-js": "^3.
|
|
66
|
+
"core-js": "^3.29.0",
|
|
67
67
|
"cross-env": "^7.0.3",
|
|
68
|
-
"eslint": "^8.
|
|
68
|
+
"eslint": "^8.35.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",
|
package/src/common/git/index.mjs
CHANGED
|
@@ -25,6 +25,30 @@ export const MESSAGE = PLATFORM === 'win32'
|
|
|
25
25
|
|
|
26
26
|
export const AUTHOR = 'Modern Poacher Limited <modernpoacher@modernpoacher.com>'
|
|
27
27
|
|
|
28
|
+
const CAT_GIT_REFS_REMOTES_ORIGIN_HEAD = `
|
|
29
|
+
DIR=$(echo "./.git/refs/remotes/origin/HEAD'" | sed -e "s/\\//\\\\\\/g" -e "s/://" | cat 2> /dev/null)
|
|
30
|
+
[[ $DIR =~ "[-0-9a-zA-Z]*$" ]]
|
|
31
|
+
echo "\${BASH_REMATCH[0]}"
|
|
32
|
+
`
|
|
33
|
+
|
|
34
|
+
const GIT_PULL = `
|
|
35
|
+
eval $(ssh-agent) 1> /dev/null
|
|
36
|
+
git pull
|
|
37
|
+
eval $(ssh-agent -k) 1> /dev/null
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
const GIT_PUSH = `
|
|
41
|
+
eval $(ssh-agent) 1> /dev/null
|
|
42
|
+
git push
|
|
43
|
+
eval $(ssh-agent -k) 1> /dev/null
|
|
44
|
+
`
|
|
45
|
+
|
|
46
|
+
const GIT_PUSH_TAGS = `
|
|
47
|
+
eval $(ssh-agent) 1> /dev/null
|
|
48
|
+
git push --tags
|
|
49
|
+
eval $(ssh-agent -k) 1> /dev/null
|
|
50
|
+
`
|
|
51
|
+
|
|
28
52
|
const OPTIONS = {
|
|
29
53
|
maxBuffer: 1024 * 2000,
|
|
30
54
|
shell: true,
|
|
@@ -90,7 +114,7 @@ function err (key, directory) {
|
|
|
90
114
|
*
|
|
91
115
|
* @param {Error}
|
|
92
116
|
*
|
|
93
|
-
* @return {
|
|
117
|
+
* @return {number}
|
|
94
118
|
*/
|
|
95
119
|
const getErrorCode = ({ code = 0 } = {}) => code
|
|
96
120
|
|
|
@@ -101,27 +125,10 @@ const getErrorCode = ({ code = 0 } = {}) => code
|
|
|
101
125
|
*
|
|
102
126
|
* @param {Error}
|
|
103
127
|
*
|
|
104
|
-
* @return {
|
|
128
|
+
* @return {string}
|
|
105
129
|
*/
|
|
106
130
|
const getErrorMessage = ({ message = '' } = {}) => message
|
|
107
131
|
|
|
108
|
-
/**
|
|
109
|
-
* @function getCatGitRefsRemotesOriginHeadCommands
|
|
110
|
-
*
|
|
111
|
-
* Compatible with MacOS and Windows
|
|
112
|
-
*
|
|
113
|
-
* @return {String}
|
|
114
|
-
*/
|
|
115
|
-
function getCatGitRefsRemotesOriginHeadCommands () { /* eslint-disable no-useless-escape */
|
|
116
|
-
log('getCatGitRefsRemotesOriginHeadCommands')
|
|
117
|
-
|
|
118
|
-
return `
|
|
119
|
-
DIR=$(echo "./.git/refs/remotes/origin/HEAD'" | sed -e "s/\\//\\\\\\/g" -e "s/://" | cat 2> /dev/null)
|
|
120
|
-
[[ $DIR =~ "[-0-9a-zA-Z]*$" ]]
|
|
121
|
-
echo "\${BASH_REMATCH[0]}"
|
|
122
|
-
` /* eslint-enable no-useless-escape */
|
|
123
|
-
}
|
|
124
|
-
|
|
125
132
|
/**
|
|
126
133
|
* @function isCommandError
|
|
127
134
|
*
|
|
@@ -129,7 +136,7 @@ echo "\${BASH_REMATCH[0]}"
|
|
|
129
136
|
*
|
|
130
137
|
* @param {Error}
|
|
131
138
|
*
|
|
132
|
-
* @return {
|
|
139
|
+
* @return {boolean}
|
|
133
140
|
*/
|
|
134
141
|
function isCommandError (e) {
|
|
135
142
|
log('isCommandError')
|
|
@@ -145,7 +152,7 @@ function isCommandError (e) {
|
|
|
145
152
|
*
|
|
146
153
|
* Get the default branch from `.git/refs/remotes/origin/HEAD`
|
|
147
154
|
*
|
|
148
|
-
* @param {
|
|
155
|
+
* @param {string} directory - A directory configured for Git
|
|
149
156
|
*
|
|
150
157
|
* @return {Promise}
|
|
151
158
|
*/
|
|
@@ -154,7 +161,7 @@ export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
|
|
|
154
161
|
|
|
155
162
|
return (
|
|
156
163
|
new Promise((resolve, reject) => {
|
|
157
|
-
const commands =
|
|
164
|
+
const commands = CAT_GIT_REFS_REMOTES_ORIGIN_HEAD.trim()
|
|
158
165
|
|
|
159
166
|
const {
|
|
160
167
|
stdout,
|
|
@@ -176,7 +183,7 @@ export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
|
|
|
176
183
|
*
|
|
177
184
|
* Determine whether a directory is configured for Git
|
|
178
185
|
*
|
|
179
|
-
* @param {
|
|
186
|
+
* @param {string} directory - A directory
|
|
180
187
|
*
|
|
181
188
|
* @return {Promise}
|
|
182
189
|
*/
|
|
@@ -207,8 +214,8 @@ export function gitRevParse (directory = DIRECTORY) {
|
|
|
207
214
|
*
|
|
208
215
|
* Switch to the default value if none is supplied
|
|
209
216
|
*
|
|
210
|
-
* @param {
|
|
211
|
-
* @param {
|
|
217
|
+
* @param {string} directory - A directory configured for Git
|
|
218
|
+
* @param {string} branch - The Git branch
|
|
212
219
|
*
|
|
213
220
|
* @return {Promise}
|
|
214
221
|
*/
|
|
@@ -243,7 +250,7 @@ export function gitCheckout (directory = DIRECTORY, branch = BRANCH) {
|
|
|
243
250
|
*
|
|
244
251
|
* Pull changes from the Git remote
|
|
245
252
|
*
|
|
246
|
-
* @param {
|
|
253
|
+
* @param {string} directory - A directory configured for Git
|
|
247
254
|
*
|
|
248
255
|
* @return {Promise}
|
|
249
256
|
*/
|
|
@@ -252,11 +259,7 @@ export function gitPull (directory = DIRECTORY) {
|
|
|
252
259
|
|
|
253
260
|
return (
|
|
254
261
|
new Promise((resolve, reject) => {
|
|
255
|
-
const commands =
|
|
256
|
-
eval $(ssh-agent 1> /dev/null)
|
|
257
|
-
git pull
|
|
258
|
-
eval $(ssh-agent -k 1> /dev/null)
|
|
259
|
-
`.trim()
|
|
262
|
+
const commands = GIT_PULL.trim()
|
|
260
263
|
|
|
261
264
|
const {
|
|
262
265
|
stdout,
|
|
@@ -282,7 +285,7 @@ export function gitPull (directory = DIRECTORY) {
|
|
|
282
285
|
*
|
|
283
286
|
* Push changes to the Git remote
|
|
284
287
|
*
|
|
285
|
-
* @param {
|
|
288
|
+
* @param {string} directory - A directory configured for Git
|
|
286
289
|
*
|
|
287
290
|
* @return {Promise}
|
|
288
291
|
*/
|
|
@@ -291,11 +294,7 @@ export function gitPush (directory = DIRECTORY) {
|
|
|
291
294
|
|
|
292
295
|
return (
|
|
293
296
|
new Promise((resolve, reject) => {
|
|
294
|
-
const commands =
|
|
295
|
-
eval $(ssh-agent 1> /dev/null)
|
|
296
|
-
git push
|
|
297
|
-
eval $(ssh-agent -k 1> /dev/null)
|
|
298
|
-
`.trim()
|
|
297
|
+
const commands = GIT_PUSH.trim()
|
|
299
298
|
|
|
300
299
|
const {
|
|
301
300
|
stdout,
|
|
@@ -321,7 +320,7 @@ export function gitPush (directory = DIRECTORY) {
|
|
|
321
320
|
*
|
|
322
321
|
* Push tags changes to the Git remote
|
|
323
322
|
*
|
|
324
|
-
* @param {
|
|
323
|
+
* @param {string} directory - A directory configured for Git
|
|
325
324
|
*
|
|
326
325
|
* @return {Promise}
|
|
327
326
|
*/
|
|
@@ -330,11 +329,7 @@ export function gitPushTags (directory = DIRECTORY) {
|
|
|
330
329
|
|
|
331
330
|
return (
|
|
332
331
|
new Promise((resolve, reject) => {
|
|
333
|
-
const commands =
|
|
334
|
-
eval $(ssh-agent 1> /dev/null)
|
|
335
|
-
git push --tags
|
|
336
|
-
eval $(ssh-agent -k 1> /dev/null)
|
|
337
|
-
`.trim()
|
|
332
|
+
const commands = GIT_PUSH_TAGS.trim()
|
|
338
333
|
|
|
339
334
|
const {
|
|
340
335
|
stdout,
|
|
@@ -360,8 +355,8 @@ export function gitPushTags (directory = DIRECTORY) {
|
|
|
360
355
|
*
|
|
361
356
|
* Add changes to Git with a default value if none is supplied
|
|
362
357
|
*
|
|
363
|
-
* @param {
|
|
364
|
-
* @param {
|
|
358
|
+
* @param {string} directory - A directory configured for Git
|
|
359
|
+
* @param {string} add - An add parameter
|
|
365
360
|
*
|
|
366
361
|
* @return {Promise}
|
|
367
362
|
*/
|
|
@@ -396,8 +391,8 @@ export function gitAdd (directory = DIRECTORY, add = ADD) {
|
|
|
396
391
|
*
|
|
397
392
|
* Commit changes to Git with a default value if none is supplied
|
|
398
393
|
*
|
|
399
|
-
* @param {
|
|
400
|
-
* @param {
|
|
394
|
+
* @param {string} directory - A directory configured for Git
|
|
395
|
+
* @param {string} message - A commit message
|
|
401
396
|
*
|
|
402
397
|
* @return {Promise}
|
|
403
398
|
*/
|
package/src/common/index.mjs
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package or configuration dependencies
|
|
3
|
+
* @typedef {Object.<string, string>} Dependencies
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A dependency descriptor
|
|
8
|
+
* @typedef {Object} DependencyDescriptor
|
|
9
|
+
* @property {string} name - Dependency name in NPM.
|
|
10
|
+
* @property {string} version - Dependency version or "latest".
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A package
|
|
15
|
+
* @typedef {Object} Package
|
|
16
|
+
* @property {string|{name: string, email: string}} author
|
|
17
|
+
* @property {Dependencies} dependencies - Production dependencies.
|
|
18
|
+
* @property {Dependencies} devDependencies - Development dependencies.
|
|
19
|
+
* @property {Dependencies} optionalDependencies - Optional dependencies.
|
|
20
|
+
* @property {Dependencies} bundleDependencies - Bundle dependencies.
|
|
21
|
+
* @property {Dependencies} peerDependencies - Peer dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A configuration
|
|
26
|
+
* @typedef {Object} Configuration
|
|
27
|
+
* @property {string|{name: string, email: string}} author
|
|
28
|
+
* @property {boolean} ignore
|
|
29
|
+
* @property {Dependencies} dependencies - Production dependencies.
|
|
30
|
+
* @property {Dependencies} devDependencies - Development dependencies.
|
|
31
|
+
* @property {Dependencies} optionalDependencies - Optional dependencies.
|
|
32
|
+
* @property {Dependencies} bundleDependencies - Bundle dependencies.
|
|
33
|
+
* @property {Dependencies} peerDependencies - Peer dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
1
36
|
import debug from 'debug'
|
|
2
37
|
|
|
3
38
|
import PATH from '#where-am-i'
|
|
@@ -30,9 +65,9 @@ const tidy = (v) => v.replace(/\n\n/gm, String.fromCharCode(10)).trim()
|
|
|
30
65
|
*
|
|
31
66
|
* Get the `--save-prod` parameter
|
|
32
67
|
*
|
|
33
|
-
* @param {
|
|
68
|
+
* @param {string} current commands string
|
|
34
69
|
*
|
|
35
|
-
* @return {
|
|
70
|
+
* @return {string}
|
|
36
71
|
*/
|
|
37
72
|
export const getSaveProdParameter = (commands) => commands.concat(' --save-prod')
|
|
38
73
|
|
|
@@ -41,9 +76,9 @@ export const getSaveProdParameter = (commands) => commands.concat(' --save-prod'
|
|
|
41
76
|
*
|
|
42
77
|
* Get the `--save-dev` parameter
|
|
43
78
|
*
|
|
44
|
-
* @param {
|
|
79
|
+
* @param {string} current commands string
|
|
45
80
|
*
|
|
46
|
-
* @return {
|
|
81
|
+
* @return {string}
|
|
47
82
|
*/
|
|
48
83
|
export const getSaveDevParameter = (commands) => commands.concat(' --save-dev')
|
|
49
84
|
|
|
@@ -52,9 +87,9 @@ export const getSaveDevParameter = (commands) => commands.concat(' --save-dev')
|
|
|
52
87
|
*
|
|
53
88
|
* Get the "save bundle" parameter
|
|
54
89
|
*
|
|
55
|
-
* @param {
|
|
90
|
+
* @param {string} commands - Current commands string
|
|
56
91
|
*
|
|
57
|
-
* @return {
|
|
92
|
+
* @return {string}
|
|
58
93
|
*/
|
|
59
94
|
export const getSaveBundleParameter = (commands) => commands.concat(' --save-bundle')
|
|
60
95
|
|
|
@@ -63,9 +98,9 @@ export const getSaveBundleParameter = (commands) => commands.concat(' --save-bun
|
|
|
63
98
|
*
|
|
64
99
|
* Get the `--save-optional` parameter
|
|
65
100
|
*
|
|
66
|
-
* @param {
|
|
101
|
+
* @param {string} commands - Current commands string
|
|
67
102
|
*
|
|
68
|
-
* @return {
|
|
103
|
+
* @return {string}
|
|
69
104
|
*/
|
|
70
105
|
export const getSaveOptionalParameter = (commands) => commands.concat(' --save-optional')
|
|
71
106
|
|
|
@@ -74,10 +109,10 @@ export const getSaveOptionalParameter = (commands) => commands.concat(' --save-o
|
|
|
74
109
|
*
|
|
75
110
|
* Get the "registry" parameter and argument
|
|
76
111
|
*
|
|
77
|
-
* @param {
|
|
78
|
-
* @param {
|
|
112
|
+
* @param {string} r - Registry
|
|
113
|
+
* @param {string} commands - Current commands string
|
|
79
114
|
*
|
|
80
|
-
* @return {
|
|
115
|
+
* @return {string}
|
|
81
116
|
*/
|
|
82
117
|
export const getRegistryParameter = (r, commands) => r ? commands.concat(` --registry ${r}`) : commands
|
|
83
118
|
|
|
@@ -86,10 +121,10 @@ export const getRegistryParameter = (r, commands) => r ? commands.concat(` --reg
|
|
|
86
121
|
*
|
|
87
122
|
* Get the "force" parameter and argument
|
|
88
123
|
*
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
124
|
+
* @param {boolean} f - Force
|
|
125
|
+
* @param {string} commands - Current commands string
|
|
91
126
|
*
|
|
92
|
-
* @return {
|
|
127
|
+
* @return {string}
|
|
93
128
|
*/
|
|
94
129
|
export const getForceParameter = (f, commands) => f ? commands.concat(' --force') : commands
|
|
95
130
|
|
|
@@ -98,10 +133,10 @@ export const getForceParameter = (f, commands) => f ? commands.concat(' --force'
|
|
|
98
133
|
*
|
|
99
134
|
* Get the `--no-save` parameter
|
|
100
135
|
*
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {
|
|
136
|
+
* @param {boolean} s - Save
|
|
137
|
+
* @param {string} commands - Current commands string
|
|
103
138
|
*
|
|
104
|
-
* @return {
|
|
139
|
+
* @return {string}
|
|
105
140
|
*/
|
|
106
141
|
export const getNoSaveParameter = (s, commands) => s ? commands : commands.concat(' --no-save')
|
|
107
142
|
|
|
@@ -110,10 +145,9 @@ export const getNoSaveParameter = (s, commands) => s ? commands : commands.conca
|
|
|
110
145
|
*
|
|
111
146
|
* Get the `--save-exact` parameter
|
|
112
147
|
*
|
|
113
|
-
* @param {
|
|
114
|
-
* @param {String} current commands string
|
|
148
|
+
* @param {string} commands - Current commands string
|
|
115
149
|
*
|
|
116
|
-
* @return {
|
|
150
|
+
* @return {string}
|
|
117
151
|
*/
|
|
118
152
|
export const getSaveExactParameter = (commands) => commands.concat(' --save-exact')
|
|
119
153
|
|
|
@@ -122,9 +156,9 @@ export const getSaveExactParameter = (commands) => commands.concat(' --save-exac
|
|
|
122
156
|
*
|
|
123
157
|
* Get the export PATH shell script
|
|
124
158
|
*
|
|
125
|
-
* @param {
|
|
159
|
+
* @param {string} commands - Current commands string
|
|
126
160
|
*
|
|
127
|
-
* @return {
|
|
161
|
+
* @return {string}
|
|
128
162
|
*/
|
|
129
163
|
export const getExportPath = (commands) => `
|
|
130
164
|
export PATH=/usr/local/bin:$PATH &> /dev/null
|
|
@@ -136,9 +170,9 @@ ${commands}
|
|
|
136
170
|
*
|
|
137
171
|
* Get the NVM shell script
|
|
138
172
|
*
|
|
139
|
-
* @param {
|
|
173
|
+
* @param {string} commands - Current commands string
|
|
140
174
|
*
|
|
141
|
-
* @return {
|
|
175
|
+
* @return {string}
|
|
142
176
|
*/
|
|
143
177
|
export const getNvm = (commands) => `
|
|
144
178
|
. "${NVM}" 2> /dev/null
|
|
@@ -150,30 +184,23 @@ ${commands}
|
|
|
150
184
|
*
|
|
151
185
|
* Get the installation shell script
|
|
152
186
|
*
|
|
153
|
-
* @param {
|
|
154
|
-
* @param {String} commands
|
|
187
|
+
* @param {string} commands - Current commands string
|
|
155
188
|
*
|
|
156
|
-
* @return {
|
|
189
|
+
* @return {string}
|
|
157
190
|
*/
|
|
158
191
|
|
|
159
192
|
export const getCommands = PLATFORM === 'win32'
|
|
160
|
-
? (
|
|
161
|
-
|
|
162
|
-
${commands}
|
|
163
|
-
`)
|
|
164
|
-
: (directory = DIRECTORY, commands = 'npm i') => tidy(`
|
|
165
|
-
echo Directory is \\"${directory}\\"
|
|
166
|
-
${getExportPath(getNvm(commands))}
|
|
167
|
-
`)
|
|
193
|
+
? (commands = 'npm i') => tidy(commands)
|
|
194
|
+
: (commands = 'npm i') => tidy(getExportPath(getNvm(commands)))
|
|
168
195
|
|
|
169
196
|
/**
|
|
170
197
|
* @function getProdDependencies
|
|
171
198
|
*
|
|
172
199
|
* Get the production dependencies by destructuring the package or configuration
|
|
173
200
|
*
|
|
174
|
-
* @param {
|
|
201
|
+
* @param {Package|Configuration}
|
|
175
202
|
*
|
|
176
|
-
* @return {
|
|
203
|
+
* @return {Dependencies}
|
|
177
204
|
*/
|
|
178
205
|
export const getProdDependencies = ({ dependencies = {} } = {}) => dependencies
|
|
179
206
|
|
|
@@ -182,9 +209,9 @@ export const getProdDependencies = ({ dependencies = {} } = {}) => dependencies
|
|
|
182
209
|
*
|
|
183
210
|
* Get the development dependencies by destructuring the package or configuration
|
|
184
211
|
*
|
|
185
|
-
* @param {
|
|
212
|
+
* @param {Package|Configuration}
|
|
186
213
|
*
|
|
187
|
-
* @return {
|
|
214
|
+
* @return {Dependencies}
|
|
188
215
|
*/
|
|
189
216
|
export const getDevDependencies = ({ devDependencies = {} } = {}) => devDependencies
|
|
190
217
|
|
|
@@ -193,9 +220,9 @@ export const getDevDependencies = ({ devDependencies = {} } = {}) => devDependen
|
|
|
193
220
|
*
|
|
194
221
|
* Get the optional dependencies by destructuring the package or configuration
|
|
195
222
|
*
|
|
196
|
-
* @param {
|
|
223
|
+
* @param {Package|Configuration}
|
|
197
224
|
*
|
|
198
|
-
* @return {
|
|
225
|
+
* @return {Dependencies}
|
|
199
226
|
*/
|
|
200
227
|
export const getOptionalDependencies = ({ optionalDependencies = {} } = {}) => optionalDependencies
|
|
201
228
|
|
|
@@ -204,20 +231,20 @@ export const getOptionalDependencies = ({ optionalDependencies = {} } = {}) => o
|
|
|
204
231
|
*
|
|
205
232
|
* Get the bundle dependencies by destructuring the package or configuration
|
|
206
233
|
*
|
|
207
|
-
* @param {
|
|
234
|
+
* @param {Package|Configuration}
|
|
208
235
|
*
|
|
209
|
-
* @return {
|
|
236
|
+
* @return {Dependencies}
|
|
210
237
|
*/
|
|
211
|
-
export const getBundleDependencies = ({ bundleDependencies =
|
|
238
|
+
export const getBundleDependencies = ({ bundleDependencies = {} } = {}) => bundleDependencies
|
|
212
239
|
|
|
213
240
|
/**
|
|
214
241
|
* @function getPeerDependencies
|
|
215
242
|
*
|
|
216
243
|
* Get the peer dependencies by destructuring the package or configuration
|
|
217
244
|
*
|
|
218
|
-
* @param {
|
|
245
|
+
* @param {Package|Configuration}
|
|
219
246
|
*
|
|
220
|
-
* @return {
|
|
247
|
+
* @return {Dependencies}
|
|
221
248
|
*/
|
|
222
249
|
export const getPeerDependencies = ({ peerDependencies } = {}) => peerDependencies
|
|
223
250
|
|
|
@@ -226,9 +253,9 @@ export const getPeerDependencies = ({ peerDependencies } = {}) => peerDependenci
|
|
|
226
253
|
*
|
|
227
254
|
* Get the ignore flag by destructuring the package or configuration
|
|
228
255
|
*
|
|
229
|
-
* @param {
|
|
256
|
+
* @param {Package|Configuration}
|
|
230
257
|
*
|
|
231
|
-
* @return {
|
|
258
|
+
* @return {boolean}
|
|
232
259
|
*/
|
|
233
260
|
export const getIgnore = ({ ignore = false } = {}) => ignore === true
|
|
234
261
|
|
|
@@ -237,20 +264,23 @@ export const getIgnore = ({ ignore = false } = {}) => ignore === true
|
|
|
237
264
|
*
|
|
238
265
|
* Get the author by destructuring the package or configuration
|
|
239
266
|
*
|
|
240
|
-
* @param {
|
|
267
|
+
* @param {Package|Configuration}
|
|
241
268
|
*
|
|
242
|
-
* @return {
|
|
269
|
+
* @return {string|null}
|
|
243
270
|
*/
|
|
244
|
-
export const getAuthor = ({ author } = {}) => {
|
|
271
|
+
export const getAuthor = ({ author = '' } = {}) => {
|
|
245
272
|
if ((author || false) instanceof Object) {
|
|
246
273
|
const {
|
|
247
|
-
name = '',
|
|
248
|
-
email = ''
|
|
274
|
+
name: NAME = '',
|
|
275
|
+
email: EMAIL = ''
|
|
249
276
|
} = author
|
|
250
277
|
|
|
278
|
+
const name = String(NAME).trim()
|
|
279
|
+
const email = String(EMAIL).trim()
|
|
280
|
+
|
|
251
281
|
return (
|
|
252
282
|
name && email
|
|
253
|
-
? `${name} <${email}
|
|
283
|
+
? `${name} <${email}>`
|
|
254
284
|
: null
|
|
255
285
|
)
|
|
256
286
|
}
|
|
@@ -263,9 +293,9 @@ export const getAuthor = ({ author } = {}) => {
|
|
|
263
293
|
*
|
|
264
294
|
* Determine whether the dependency is a pre-release with a Regular Expression
|
|
265
295
|
*
|
|
266
|
-
* @param {
|
|
296
|
+
* @param {string} v
|
|
267
297
|
*
|
|
268
|
-
* @return {
|
|
298
|
+
* @return {boolean}
|
|
269
299
|
*/
|
|
270
300
|
export const isPreRelease = (v) => /-/.test(v)
|
|
271
301
|
|
|
@@ -274,9 +304,9 @@ export const isPreRelease = (v) => /-/.test(v)
|
|
|
274
304
|
*
|
|
275
305
|
* Determine whether the dependency is exact with a Regular Expression
|
|
276
306
|
*
|
|
277
|
-
* @param {
|
|
307
|
+
* @param {string} v
|
|
278
308
|
*
|
|
279
|
-
* @return {
|
|
309
|
+
* @return {boolean}
|
|
280
310
|
*/
|
|
281
311
|
export const isExact = (v) => /^\d/.test(v)
|
|
282
312
|
|
|
@@ -285,19 +315,19 @@ export const isExact = (v) => /^\d/.test(v)
|
|
|
285
315
|
*
|
|
286
316
|
* Get an array of dependencies to be installed with the `--save-exact` parameter
|
|
287
317
|
*
|
|
288
|
-
* @param {
|
|
289
|
-
* @param {
|
|
318
|
+
* @param {Dependencies} packageDependencies - Package dependencies
|
|
319
|
+
* @param {Dependencies} configurationDependencies - Configuration dependencies
|
|
290
320
|
*
|
|
291
|
-
* @return {
|
|
321
|
+
* @return {DependencyDescriptor[]}
|
|
292
322
|
*/
|
|
293
|
-
export function getDepsExact (
|
|
323
|
+
export function getDepsExact (packageDependencies, configurationDependencies) {
|
|
294
324
|
log('getDepsExact')
|
|
295
325
|
|
|
296
326
|
return (
|
|
297
|
-
Object.entries(
|
|
327
|
+
Object.entries(packageDependencies)
|
|
298
328
|
.reduce((accumulator, [name, version]) => (
|
|
299
329
|
isExact(version)
|
|
300
|
-
? accumulator.concat({ name, version: Reflect.has(
|
|
330
|
+
? accumulator.concat({ name, version: Reflect.has(configurationDependencies, name) ? Reflect.get(configurationDependencies, name) : version })
|
|
301
331
|
: accumulator
|
|
302
332
|
), [])
|
|
303
333
|
)
|
|
@@ -308,15 +338,15 @@ export function getDepsExact (values, configuration) {
|
|
|
308
338
|
*
|
|
309
339
|
* Get an array of dependencies to be installed
|
|
310
340
|
*
|
|
311
|
-
* @param {
|
|
341
|
+
* @param {Dependencies} packageDependencies - Package dependencies
|
|
312
342
|
*
|
|
313
|
-
* @return {
|
|
343
|
+
* @return {DependencyDescriptor[]}
|
|
314
344
|
*/
|
|
315
|
-
export function getDeps (
|
|
345
|
+
export function getDeps (packageDependencies) {
|
|
316
346
|
log('getDeps')
|
|
317
347
|
|
|
318
348
|
return (
|
|
319
|
-
Object.entries(
|
|
349
|
+
Object.entries(packageDependencies)
|
|
320
350
|
.reduce((accumulator, [name, version]) => (
|
|
321
351
|
isExact(version)
|
|
322
352
|
? accumulator
|
|
@@ -332,9 +362,9 @@ export function getDeps (values) {
|
|
|
332
362
|
*
|
|
333
363
|
* Normalise the commands string
|
|
334
364
|
*
|
|
335
|
-
* @param {
|
|
365
|
+
* @param {string} value
|
|
336
366
|
*
|
|
337
|
-
* @return {
|
|
367
|
+
* @return {string}
|
|
338
368
|
*/
|
|
339
369
|
export function normalizeCommands (value) {
|
|
340
370
|
while (/\s\s|\n/.test(value)) {
|
|
@@ -351,9 +381,9 @@ export function normalizeCommands (value) {
|
|
|
351
381
|
*
|
|
352
382
|
* Transform by destructuring the value
|
|
353
383
|
*
|
|
354
|
-
* @param {
|
|
384
|
+
* @param {DependencyDescriptor}
|
|
355
385
|
*
|
|
356
|
-
* @return {
|
|
386
|
+
* @return {string}
|
|
357
387
|
*/
|
|
358
388
|
export const transformDependency = ({ name = '@modernpoacher/deps', version = 'latest' } = {}) => `${name}@${version}`
|
|
359
389
|
|
|
@@ -362,9 +392,9 @@ export const transformDependency = ({ name = '@modernpoacher/deps', version = 'l
|
|
|
362
392
|
*
|
|
363
393
|
* Transform the parameter to a string
|
|
364
394
|
*
|
|
365
|
-
* @param {
|
|
395
|
+
* @param {DependencyDescriptor|DependencyDescriptor[]} value
|
|
366
396
|
*
|
|
367
|
-
* @return {
|
|
397
|
+
* @return {string}
|
|
368
398
|
*/
|
|
369
399
|
export function transform (value) {
|
|
370
400
|
log('transform')
|