@modernpoacher/deps 2.0.25 → 2.0.27
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 +83 -49
- package/nvm.sh +1 -1
- package/package.json +1 -1
- package/src/common/git/index.mjs +67 -5
package/bin/execute/app.mjs
CHANGED
|
@@ -21,8 +21,9 @@ import {
|
|
|
21
21
|
MESSAGE,
|
|
22
22
|
AUTHOR,
|
|
23
23
|
catGitRefsRemotesOriginHead,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
awkGitRemoteShowOriginHead,
|
|
25
|
+
gitRevParseShowTopLevel,
|
|
26
|
+
gitRevParseAbbrevRefHead,
|
|
26
27
|
gitPull,
|
|
27
28
|
gitPush,
|
|
28
29
|
gitPushTags,
|
|
@@ -78,6 +79,28 @@ function handleCommandError (e) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
async function getDefaultBranch (directory) {
|
|
83
|
+
const branch = await catGitRefsRemotesOriginHead(directory)
|
|
84
|
+
if (branch) return branch
|
|
85
|
+
return (
|
|
86
|
+
await awkGitRemoteShowOriginHead(directory)
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function getCurrentBranch (directory) {
|
|
91
|
+
return (
|
|
92
|
+
await gitRevParseAbbrevRefHead(directory)
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function isHeadDefaultBranch (directory) {
|
|
97
|
+
const defaultBranch = await getDefaultBranch(directory)
|
|
98
|
+
const currentBranch = await getCurrentBranch(directory)
|
|
99
|
+
return (
|
|
100
|
+
defaultBranch === currentBranch
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
/**
|
|
82
105
|
* @function getIgnoreFromConfiguration
|
|
83
106
|
*
|
|
@@ -220,7 +243,7 @@ async function getDepsList (directories) {
|
|
|
220
243
|
log('getDepsList')
|
|
221
244
|
|
|
222
245
|
try {
|
|
223
|
-
const array = await Promise.all(directories.map(
|
|
246
|
+
const array = await Promise.all(directories.map(mapRevParseShowTopLevel))
|
|
224
247
|
|
|
225
248
|
return (
|
|
226
249
|
array
|
|
@@ -233,12 +256,12 @@ async function getDepsList (directories) {
|
|
|
233
256
|
}
|
|
234
257
|
}
|
|
235
258
|
|
|
236
|
-
async function
|
|
237
|
-
log('
|
|
259
|
+
async function mapRevParseShowTopLevel (directory) {
|
|
260
|
+
log('mapRevParseShowTopLevel')
|
|
238
261
|
|
|
239
262
|
try {
|
|
240
263
|
return (
|
|
241
|
-
await
|
|
264
|
+
await gitRevParseShowTopLevel(directory)
|
|
242
265
|
)
|
|
243
266
|
} catch (e) {
|
|
244
267
|
handleCommandError(e)
|
|
@@ -252,10 +275,13 @@ async function iterate ([directory, ...directories] = [], registry, force, messa
|
|
|
252
275
|
const D = resolve(directory)
|
|
253
276
|
|
|
254
277
|
try {
|
|
255
|
-
if (D === await
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
258
|
-
|
|
278
|
+
if (D === await gitRevParseShowTopLevel(D)) {
|
|
279
|
+
const B = await isHeadDefaultBranch(D)
|
|
280
|
+
if (B) {
|
|
281
|
+
const ignore = await getIgnoreFromConfiguration(D)
|
|
282
|
+
if (!ignore) {
|
|
283
|
+
await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
|
|
284
|
+
}
|
|
259
285
|
}
|
|
260
286
|
}
|
|
261
287
|
} catch (e) {
|
|
@@ -274,7 +300,6 @@ async function execute (directory = DIRECTORY, registry = REGISTRY, force = fals
|
|
|
274
300
|
try {
|
|
275
301
|
log({ directory, registry, force, message, author })
|
|
276
302
|
|
|
277
|
-
await gitCheckout(directory, await catGitRefsRemotesOriginHead(directory))
|
|
278
303
|
await gitPull(directory)
|
|
279
304
|
await rmrf(directory)
|
|
280
305
|
await npmi(directory, registry, force)
|
|
@@ -291,68 +316,77 @@ async function execute (directory = DIRECTORY, registry = REGISTRY, force = fals
|
|
|
291
316
|
async function executeFrom (directory, registry, force, message, author) {
|
|
292
317
|
log('executeFrom')
|
|
293
318
|
|
|
294
|
-
|
|
319
|
+
if (directory) {
|
|
320
|
+
const D = resolve(directory)
|
|
295
321
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
322
|
+
try {
|
|
323
|
+
if (D === await gitRevParseShowTopLevel(D)) {
|
|
324
|
+
const B = await isHeadDefaultBranch(D)
|
|
325
|
+
if (B) {
|
|
326
|
+
const ignore = await getIgnoreFromConfiguration(D)
|
|
327
|
+
if (!ignore) {
|
|
328
|
+
await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
|
|
329
|
+
}
|
|
330
|
+
}
|
|
303
331
|
}
|
|
332
|
+
} catch (e) {
|
|
333
|
+
handleCommandError(e)
|
|
304
334
|
}
|
|
305
|
-
} catch (e) {
|
|
306
|
-
handleCommandError(e)
|
|
307
335
|
}
|
|
308
336
|
}
|
|
309
337
|
|
|
310
338
|
async function executeOnly (directory, registry, force, message, author) {
|
|
311
339
|
log('executeOnly')
|
|
312
340
|
|
|
313
|
-
|
|
341
|
+
if (directory) {
|
|
342
|
+
const D = resolve(directory)
|
|
314
343
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
344
|
+
try {
|
|
345
|
+
if (D === await gitRevParseShowTopLevel(D)) {
|
|
346
|
+
const B = await isHeadDefaultBranch(D)
|
|
347
|
+
if (B) {
|
|
348
|
+
const ignore = await getIgnoreFromConfiguration(D)
|
|
349
|
+
if (!ignore) {
|
|
350
|
+
await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
|
|
351
|
+
}
|
|
352
|
+
}
|
|
322
353
|
}
|
|
354
|
+
} catch (e) {
|
|
355
|
+
handleCommandError(e)
|
|
323
356
|
}
|
|
324
|
-
} catch (e) {
|
|
325
|
-
handleCommandError(e)
|
|
326
357
|
}
|
|
327
358
|
}
|
|
328
359
|
|
|
329
360
|
async function executePath (directory, registry, force, message, author) {
|
|
330
361
|
log('executePath')
|
|
331
362
|
|
|
332
|
-
|
|
363
|
+
if (directory) {
|
|
364
|
+
const D = resolve(directory)
|
|
333
365
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
366
|
+
try {
|
|
367
|
+
if (D === await gitRevParseShowTopLevel(D)) {
|
|
368
|
+
const B = await isHeadDefaultBranch(D)
|
|
369
|
+
if (B) {
|
|
370
|
+
const ignore = await getIgnoreFromConfiguration(D)
|
|
371
|
+
if (!ignore) {
|
|
372
|
+
await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
|
|
373
|
+
}
|
|
374
|
+
}
|
|
341
375
|
}
|
|
376
|
+
} catch (e) {
|
|
377
|
+
handleCommandError(e)
|
|
342
378
|
}
|
|
343
|
-
} catch (e) {
|
|
344
|
-
handleCommandError(e)
|
|
345
|
-
}
|
|
346
379
|
|
|
347
|
-
|
|
380
|
+
const pathList = await getPathList(D)
|
|
348
381
|
|
|
349
|
-
|
|
350
|
-
|
|
382
|
+
if (pathList.length) {
|
|
383
|
+
const depsList = await getDepsList(pathList)
|
|
351
384
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
385
|
+
if (depsList.length) {
|
|
386
|
+
return (
|
|
387
|
+
await iterate(depsList, registry, force, message, author)
|
|
388
|
+
)
|
|
389
|
+
}
|
|
356
390
|
}
|
|
357
391
|
}
|
|
358
392
|
}
|
package/nvm.sh
CHANGED
package/package.json
CHANGED
package/src/common/git/index.mjs
CHANGED
|
@@ -179,7 +179,38 @@ export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
* @function
|
|
182
|
+
* @function awkGitRemoteShowOriginHead
|
|
183
|
+
*
|
|
184
|
+
* Get the remote default branch
|
|
185
|
+
*
|
|
186
|
+
* @param {string} directory - A directory configured for Git
|
|
187
|
+
*
|
|
188
|
+
* @return {Promise<string>}
|
|
189
|
+
*/
|
|
190
|
+
export function awkGitRemoteShowOriginHead (directory = DIRECTORY) {
|
|
191
|
+
log('awkGitRemoteShowOriginHead')
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
new Promise((resolve, reject) => {
|
|
195
|
+
const command = 'git remote show origin | awk \'/HEAD branch/ {print $NF}\''
|
|
196
|
+
|
|
197
|
+
const {
|
|
198
|
+
stdout,
|
|
199
|
+
stderr
|
|
200
|
+
} = exec(command, { ...OPTIONS, cwd: normalize(directory) }, (e, v = '') => {
|
|
201
|
+
(!e)
|
|
202
|
+
? resolve(trim(v))
|
|
203
|
+
: reject(e)
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
stdout.on('data', out('git-remote-show-origin-head', directory.trim()))
|
|
207
|
+
stderr.on('data', err('git-remote-show-origin-head', directory.trim()))
|
|
208
|
+
})
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @function gitRevParseShowTopLevel
|
|
183
214
|
*
|
|
184
215
|
* Determine whether a directory is configured for Git
|
|
185
216
|
*
|
|
@@ -187,8 +218,8 @@ export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
|
|
|
187
218
|
*
|
|
188
219
|
* @return {Promise<string>}
|
|
189
220
|
*/
|
|
190
|
-
export function
|
|
191
|
-
log('
|
|
221
|
+
export function gitRevParseShowTopLevel (directory = DIRECTORY) {
|
|
222
|
+
log('gitRevParseShowTopLevel')
|
|
192
223
|
|
|
193
224
|
return (
|
|
194
225
|
new Promise((resolve, reject) => {
|
|
@@ -203,8 +234,39 @@ export function gitRevParse (directory = DIRECTORY) {
|
|
|
203
234
|
: reject(e)
|
|
204
235
|
})
|
|
205
236
|
|
|
206
|
-
stdout.on('data', out('git-rev-parse', directory.trim()))
|
|
207
|
-
stderr.on('data', err('git-rev-parse', directory.trim()))
|
|
237
|
+
stdout.on('data', out('git-rev-parse-show-toplevel', directory.trim()))
|
|
238
|
+
stderr.on('data', err('git-rev-parse-show-toplevel', directory.trim()))
|
|
239
|
+
})
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @function gitRevParseAbbrevRefHead
|
|
245
|
+
*
|
|
246
|
+
* Determine which branch is HEAD
|
|
247
|
+
*
|
|
248
|
+
* @param {string} directory - A directory
|
|
249
|
+
*
|
|
250
|
+
* @return {Promise<string>}
|
|
251
|
+
*/
|
|
252
|
+
export function gitRevParseAbbrevRefHead (directory = DIRECTORY) {
|
|
253
|
+
log('gitRevParseAbbrevRefHead')
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
new Promise((resolve, reject) => {
|
|
257
|
+
const command = 'git rev-parse --abbrev-ref HEAD'
|
|
258
|
+
|
|
259
|
+
const {
|
|
260
|
+
stdout,
|
|
261
|
+
stderr
|
|
262
|
+
} = exec(command, { ...OPTIONS, cwd: normalize(directory) }, (e, v = '') => {
|
|
263
|
+
(!e)
|
|
264
|
+
? resolve(trim(v))
|
|
265
|
+
: reject(e)
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
stdout.on('data', out('git-rev-parse-abbrev-ref-head', directory.trim()))
|
|
269
|
+
stderr.on('data', err('git-rev-parse-abbrev-ref-head', directory.trim()))
|
|
208
270
|
})
|
|
209
271
|
)
|
|
210
272
|
}
|