@modernpoacher/deps 2.0.16 → 2.0.18
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/execute/app.mjs +47 -5
- package/package.json +7 -7
- package/src/common/git/index.mjs +50 -55
- package/src/common/index.mjs +111 -80
- package/src/index.mjs +210 -176
- package/src/install/index.mjs +56 -39
package/bin/execute/app.mjs
CHANGED
|
@@ -77,6 +77,14 @@ function handleCommandError (e) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @function getIgnoreFromConfiguration
|
|
82
|
+
*
|
|
83
|
+
* Interrogates `.depsrc` or `.depsrc.json` for an `ignore` value
|
|
84
|
+
*
|
|
85
|
+
* @param {string} directory
|
|
86
|
+
* @returns {Promise<boolean>}
|
|
87
|
+
*/
|
|
80
88
|
async function getIgnoreFromConfiguration (directory) {
|
|
81
89
|
log('getIgnoreFromConfiguration')
|
|
82
90
|
|
|
@@ -91,6 +99,14 @@ async function getIgnoreFromConfiguration (directory) {
|
|
|
91
99
|
)
|
|
92
100
|
}
|
|
93
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @function getAuthorFromConfiguration
|
|
104
|
+
*
|
|
105
|
+
* Interrogates `.depsrc` or `.depsrc.json` for an `author` value
|
|
106
|
+
*
|
|
107
|
+
* @param {string} directory
|
|
108
|
+
* @returns {Promise<string|null>}
|
|
109
|
+
*/
|
|
94
110
|
async function getAuthorFromConfiguration (directory) {
|
|
95
111
|
log('getAuthorFromConfiguration')
|
|
96
112
|
|
|
@@ -105,6 +121,14 @@ async function getAuthorFromConfiguration (directory) {
|
|
|
105
121
|
)
|
|
106
122
|
}
|
|
107
123
|
|
|
124
|
+
/**
|
|
125
|
+
* @function getAuthorFromPackage
|
|
126
|
+
*
|
|
127
|
+
* Interrogates `package.json` for an `author` value
|
|
128
|
+
*
|
|
129
|
+
* @param {string} directory
|
|
130
|
+
* @returns {Promise<string|null>}
|
|
131
|
+
*/
|
|
108
132
|
async function getAuthorFromPackage (directory) {
|
|
109
133
|
log('getAuthorFromPackage')
|
|
110
134
|
|
|
@@ -119,6 +143,22 @@ async function getAuthorFromPackage (directory) {
|
|
|
119
143
|
)
|
|
120
144
|
}
|
|
121
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @function toAuthor
|
|
148
|
+
*
|
|
149
|
+
* Ensures that the `author` is set either from the command line,
|
|
150
|
+
* configuration, package, or a default
|
|
151
|
+
*
|
|
152
|
+
* Since it can be null `author` may not default in function arguments
|
|
153
|
+
*
|
|
154
|
+
* @param {string|null} author
|
|
155
|
+
* @param {string} directory
|
|
156
|
+
* @returns {Promise<string>}
|
|
157
|
+
*/
|
|
158
|
+
async function toAuthor (author, directory) {
|
|
159
|
+
return author || await getAuthorFromConfiguration(directory) || await getAuthorFromPackage(directory) || AUTHOR
|
|
160
|
+
}
|
|
161
|
+
|
|
122
162
|
const filterDeps = (v) => !!v // de-falsy
|
|
123
163
|
|
|
124
164
|
const reduceDeps = (a, v) => a.includes(v) ? a : a.concat(v) // de-dupe
|
|
@@ -176,7 +216,7 @@ async function iterate ([directory, ...directories] = [], registry, force, messa
|
|
|
176
216
|
if (D === await gitRevParse(D)) {
|
|
177
217
|
const ignore = await getIgnoreFromConfiguration(D)
|
|
178
218
|
if (!ignore) {
|
|
179
|
-
await execute(D, registry, force, message, author
|
|
219
|
+
await execute(D, registry, force, message, toAuthor(author, D))
|
|
180
220
|
}
|
|
181
221
|
}
|
|
182
222
|
} catch (e) {
|
|
@@ -219,7 +259,7 @@ async function executeFrom (directory, registry, force, message, author) {
|
|
|
219
259
|
const ignore = await getIgnoreFromConfiguration(D)
|
|
220
260
|
if (!ignore) {
|
|
221
261
|
return (
|
|
222
|
-
await execute(D, registry, force, message, author
|
|
262
|
+
await execute(D, registry, force, message, toAuthor(author, D))
|
|
223
263
|
)
|
|
224
264
|
}
|
|
225
265
|
}
|
|
@@ -238,7 +278,7 @@ async function executeOnly (directory, registry, force, message, author) {
|
|
|
238
278
|
const ignore = await getIgnoreFromConfiguration(D)
|
|
239
279
|
if (!ignore) {
|
|
240
280
|
return (
|
|
241
|
-
await execute(D, registry, force, message, author
|
|
281
|
+
await execute(D, registry, force, message, toAuthor(author, D))
|
|
242
282
|
)
|
|
243
283
|
}
|
|
244
284
|
}
|
|
@@ -257,7 +297,7 @@ async function executePath (directory, registry, force, message, author) {
|
|
|
257
297
|
const ignore = await getIgnoreFromConfiguration(D)
|
|
258
298
|
if (!ignore) {
|
|
259
299
|
return (
|
|
260
|
-
await execute(D, registry, force, message, author
|
|
300
|
+
await execute(D, registry, force, message, toAuthor(author, D))
|
|
261
301
|
)
|
|
262
302
|
}
|
|
263
303
|
}
|
|
@@ -316,7 +356,9 @@ async function app () {
|
|
|
316
356
|
...(F ? { from: F } : {}),
|
|
317
357
|
...(O ? { only: O } : {}),
|
|
318
358
|
...(registry ? { registry } : {}),
|
|
319
|
-
...(force ? { force } : {})
|
|
359
|
+
...(force ? { force } : {}),
|
|
360
|
+
...(message ? { message } : {}),
|
|
361
|
+
...(author ? { author } : {})
|
|
320
362
|
})
|
|
321
363
|
|
|
322
364
|
if (P || (!F && !O)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
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.
|
|
62
|
-
"@babel/eslint-parser": "^7.
|
|
60
|
+
"@babel/cli": "^7.21.0",
|
|
61
|
+
"@babel/core": "^7.21.3",
|
|
62
|
+
"@babel/eslint-parser": "^7.21.3",
|
|
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.1",
|
|
67
67
|
"cross-env": "^7.0.3",
|
|
68
|
-
"eslint": "^8.
|
|
68
|
+
"eslint": "^8.36.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,16 +152,16 @@ 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
|
-
* @return {Promise}
|
|
157
|
+
* @return {Promise<string>}
|
|
151
158
|
*/
|
|
152
159
|
export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
|
|
153
160
|
log('catGitRefsRemotesOriginHead')
|
|
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,9 +183,9 @@ 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
|
-
* @return {Promise}
|
|
188
|
+
* @return {Promise<string>}
|
|
182
189
|
*/
|
|
183
190
|
export function gitRevParse (directory = DIRECTORY) {
|
|
184
191
|
log('gitRevParse')
|
|
@@ -207,10 +214,10 @@ 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
|
-
* @return {Promise}
|
|
220
|
+
* @return {Promise<string>}
|
|
214
221
|
*/
|
|
215
222
|
export function gitCheckout (directory = DIRECTORY, branch = BRANCH) {
|
|
216
223
|
log('gitCheckout')
|
|
@@ -243,20 +250,16 @@ 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
|
-
* @return {Promise}
|
|
255
|
+
* @return {Promise<string>}
|
|
249
256
|
*/
|
|
250
257
|
export function gitPull (directory = DIRECTORY) {
|
|
251
258
|
log('gitPull')
|
|
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,20 +285,16 @@ 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
|
-
* @return {Promise}
|
|
290
|
+
* @return {Promise<string>}
|
|
288
291
|
*/
|
|
289
292
|
export function gitPush (directory = DIRECTORY) {
|
|
290
293
|
log('gitPush')
|
|
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,20 +320,16 @@ 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
|
-
* @return {Promise}
|
|
325
|
+
* @return {Promise<string>}
|
|
327
326
|
*/
|
|
328
327
|
export function gitPushTags (directory = DIRECTORY) {
|
|
329
328
|
log('gitPushTags')
|
|
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,10 +355,10 @@ 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
|
-
* @return {Promise}
|
|
361
|
+
* @return {Promise<string>}
|
|
367
362
|
*/
|
|
368
363
|
export function gitAdd (directory = DIRECTORY, add = ADD) {
|
|
369
364
|
log('gitAdd')
|
|
@@ -396,10 +391,10 @@ 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
|
-
* @return {Promise}
|
|
397
|
+
* @return {Promise<string>}
|
|
403
398
|
*/
|
|
404
399
|
export function gitCommit (directory = DIRECTORY, message = MESSAGE, author = AUTHOR) {
|
|
405
400
|
log('gitCommit')
|