@modernpoacher/deps 2.2.29 → 2.2.31
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 +35 -55
- package/bin/node/deps.mjs +3 -2
- package/bin/node/execute.mjs +26 -1
- package/bin/node/head.mjs +4 -1
- package/bin/node/push.mjs +4 -1
- package/bin/node/wipe.mjs +4 -1
- package/package.json +10 -10
- package/src/common/format/index.mjs +63 -0
- package/src/common/git/index.mjs +82 -35
- package/src/common/index.mjs +85 -45
- package/src/common/write.mjs +5 -4
- package/src/index.mjs +4 -34
- package/tsconfig.json +1 -1
package/bin/common/index.mjs
CHANGED
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
* @returns {void}
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import stripAnsi from 'strip-ansi'
|
|
20
|
-
|
|
21
19
|
import {
|
|
22
20
|
argv
|
|
23
21
|
} from 'node:process'
|
|
@@ -43,6 +41,11 @@ import {
|
|
|
43
41
|
|
|
44
42
|
import debug from '#deps/src/common/debug'
|
|
45
43
|
|
|
44
|
+
import {
|
|
45
|
+
use,
|
|
46
|
+
tidy
|
|
47
|
+
} from '#deps/src/common/format'
|
|
48
|
+
|
|
46
49
|
import {
|
|
47
50
|
VERSION,
|
|
48
51
|
PLATFORM,
|
|
@@ -76,26 +79,15 @@ const CODE = 0
|
|
|
76
79
|
|
|
77
80
|
const MESSAGE = 'Either no error message has been defined or no error has been supplied'
|
|
78
81
|
|
|
79
|
-
const LF = String.fromCodePoint(10)
|
|
80
82
|
const SP = String.fromCodePoint(32)
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* @param {string} v
|
|
84
86
|
* @returns {string}
|
|
85
87
|
*/
|
|
86
|
-
export
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
* @param {string} v
|
|
90
|
-
* @returns {string}
|
|
91
|
-
*/
|
|
92
|
-
export const tidy = (v) => v.replace(/\n{2,}}/gm, LF).trim()
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @param {string} v
|
|
96
|
-
* @returns {string}
|
|
97
|
-
*/
|
|
98
|
-
export const trim = (v) => v.split(LF).map(trimEnd).join(LF).trim()
|
|
88
|
+
export {
|
|
89
|
+
tidy
|
|
90
|
+
}
|
|
99
91
|
|
|
100
92
|
const getRmrfCommands = PLATFORM === 'win32'
|
|
101
93
|
? () => tidy(`
|
|
@@ -149,40 +141,6 @@ export const ARGS = PLATFORM === 'win32'
|
|
|
149
141
|
? ARGV.map(toDouble).join(SP)
|
|
150
142
|
: ARGV.map(toSingle).join(SP)
|
|
151
143
|
|
|
152
|
-
/**
|
|
153
|
-
* @param {string} v
|
|
154
|
-
* @returns {boolean}
|
|
155
|
-
*/
|
|
156
|
-
function filter (v) {
|
|
157
|
-
return Boolean(stripAnsi(v).trim())
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @param {string} key
|
|
162
|
-
* @returns {(value: string) => void}
|
|
163
|
-
*/
|
|
164
|
-
export function use (key) {
|
|
165
|
-
const log = debug(`@modernpoacher/deps:${key}`)
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @param {string} v
|
|
169
|
-
* @returns {void}
|
|
170
|
-
*/
|
|
171
|
-
function write (v) {
|
|
172
|
-
log(v.trimEnd())
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* @param {string} value
|
|
177
|
-
* @returns {void}
|
|
178
|
-
*/
|
|
179
|
-
return function use (value) {
|
|
180
|
-
value.split(LF)
|
|
181
|
-
.filter(filter)
|
|
182
|
-
.forEach(write)
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
144
|
/**
|
|
187
145
|
* @param {{ code?: number, message?: string }} [e]
|
|
188
146
|
*/
|
|
@@ -211,18 +169,40 @@ export function handleComplete (e) {
|
|
|
211
169
|
/**
|
|
212
170
|
* @param {{ code?: number, message?: string }} e
|
|
213
171
|
*/
|
|
214
|
-
|
|
172
|
+
function handlePackageError ({ message = MESSAGE }) {
|
|
173
|
+
info(`Package error: "${message}"`)
|
|
174
|
+
}
|
|
215
175
|
|
|
216
176
|
/**
|
|
217
177
|
* @param {{ code?: number, message?: string }} e
|
|
218
178
|
*/
|
|
219
|
-
|
|
179
|
+
function handleConfigurationError ({ message = MESSAGE }) {
|
|
180
|
+
info(`Configuration error: "${message}"`)
|
|
181
|
+
}
|
|
220
182
|
|
|
221
|
-
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
* @param directory
|
|
186
|
+
*/
|
|
187
|
+
function getPackageJsonPath (directory = DIRECTORY) {
|
|
188
|
+
return resolve(join(directory, 'package.json'))
|
|
189
|
+
}
|
|
222
190
|
|
|
223
|
-
|
|
191
|
+
/**
|
|
192
|
+
*
|
|
193
|
+
* @param directory
|
|
194
|
+
*/
|
|
195
|
+
function getDepsRcPath (directory = DIRECTORY) {
|
|
196
|
+
return resolve(join(directory, '.depsrc'))
|
|
197
|
+
}
|
|
224
198
|
|
|
225
|
-
|
|
199
|
+
/**
|
|
200
|
+
*
|
|
201
|
+
* @param directory
|
|
202
|
+
*/
|
|
203
|
+
function getDepsRcJsonPath (directory = DIRECTORY) {
|
|
204
|
+
return resolve(join(directory, '.depsrc.json'))
|
|
205
|
+
}
|
|
226
206
|
|
|
227
207
|
/**
|
|
228
208
|
* @param {string} directory
|
package/bin/node/deps.mjs
CHANGED
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import '#deps/src/common/write'
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
use
|
|
11
|
+
} from '#deps/src/common/format'
|
|
10
12
|
|
|
11
13
|
import {
|
|
12
14
|
getOptions
|
|
@@ -15,7 +17,6 @@ import {
|
|
|
15
17
|
import {
|
|
16
18
|
DEPS,
|
|
17
19
|
ARGS,
|
|
18
|
-
use,
|
|
19
20
|
handleComplete
|
|
20
21
|
} from '#deps/bin/common'
|
|
21
22
|
|
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/bin/node/head.mjs
CHANGED
|
@@ -8,6 +8,10 @@ import '#deps/src/common/write'
|
|
|
8
8
|
|
|
9
9
|
import '#deps/src/common/debug'
|
|
10
10
|
|
|
11
|
+
import {
|
|
12
|
+
use
|
|
13
|
+
} from '#deps/src/common/format'
|
|
14
|
+
|
|
11
15
|
import {
|
|
12
16
|
getOptions
|
|
13
17
|
} from '#deps/src/common/options'
|
|
@@ -15,7 +19,6 @@ import {
|
|
|
15
19
|
import {
|
|
16
20
|
HEAD,
|
|
17
21
|
ARGS,
|
|
18
|
-
use,
|
|
19
22
|
handleComplete
|
|
20
23
|
} from '#deps/bin/common'
|
|
21
24
|
|
package/bin/node/push.mjs
CHANGED
|
@@ -8,6 +8,10 @@ import '#deps/src/common/write'
|
|
|
8
8
|
|
|
9
9
|
import '#deps/src/common/debug'
|
|
10
10
|
|
|
11
|
+
import {
|
|
12
|
+
use
|
|
13
|
+
} from '#deps/src/common/format'
|
|
14
|
+
|
|
11
15
|
import {
|
|
12
16
|
getOptions
|
|
13
17
|
} from '#deps/src/common/options'
|
|
@@ -15,7 +19,6 @@ import {
|
|
|
15
19
|
import {
|
|
16
20
|
PUSH,
|
|
17
21
|
ARGS,
|
|
18
|
-
use,
|
|
19
22
|
handleComplete
|
|
20
23
|
} from '#deps/bin/common'
|
|
21
24
|
|
package/bin/node/wipe.mjs
CHANGED
|
@@ -8,6 +8,10 @@ import '#deps/src/common/write'
|
|
|
8
8
|
|
|
9
9
|
import '#deps/src/common/debug'
|
|
10
10
|
|
|
11
|
+
import {
|
|
12
|
+
use
|
|
13
|
+
} from '#deps/src/common/format'
|
|
14
|
+
|
|
11
15
|
import {
|
|
12
16
|
getOptions
|
|
13
17
|
} from '#deps/src/common/options'
|
|
@@ -15,7 +19,6 @@ import {
|
|
|
15
19
|
import {
|
|
16
20
|
WIPE,
|
|
17
21
|
ARGS,
|
|
18
|
-
use,
|
|
19
22
|
handleComplete
|
|
20
23
|
} from '#deps/bin/common'
|
|
21
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.31",
|
|
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.8",
|
|
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.145",
|
|
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
|
@@ -21,6 +21,11 @@ import {
|
|
|
21
21
|
|
|
22
22
|
import debug from '#deps/src/common/debug'
|
|
23
23
|
|
|
24
|
+
import {
|
|
25
|
+
use,
|
|
26
|
+
trim
|
|
27
|
+
} from '#deps/src/common/format'
|
|
28
|
+
|
|
24
29
|
import {
|
|
25
30
|
BIN,
|
|
26
31
|
VERSION,
|
|
@@ -73,17 +78,9 @@ log(`\`common/git\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
|
73
78
|
|
|
74
79
|
const LF = String.fromCodePoint(10)
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*/
|
|
80
|
-
const trimEnd = (v) => v.trimEnd()
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @param {string} v
|
|
84
|
-
* @returns {string}
|
|
85
|
-
*/
|
|
86
|
-
const trim = (v) => v.split(LF).map(trimEnd).join(LF).trim()
|
|
81
|
+
export {
|
|
82
|
+
trim
|
|
83
|
+
}
|
|
87
84
|
|
|
88
85
|
/**
|
|
89
86
|
* @param {string} v
|
|
@@ -111,28 +108,6 @@ function isFatal (v) {
|
|
|
111
108
|
return v.toLowerCase().startsWith('fatal: not a git repository')
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
/**
|
|
115
|
-
* @param {string} key
|
|
116
|
-
* @returns {(value: string) => void}
|
|
117
|
-
*/
|
|
118
|
-
export function use (key) {
|
|
119
|
-
const log = debug(`@modernpoacher/deps:${key}`)
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} v
|
|
123
|
-
* @returns {void}
|
|
124
|
-
*/
|
|
125
|
-
function write (v) {
|
|
126
|
-
log(v.trimEnd())
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return function use (value) {
|
|
130
|
-
value.split(LF)
|
|
131
|
-
.filter(filter)
|
|
132
|
-
.forEach(write)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
111
|
/**
|
|
137
112
|
* @param {string} key
|
|
138
113
|
* @param {string} directory
|
|
@@ -214,7 +189,7 @@ export function err (key, directory) {
|
|
|
214
189
|
* @param {{code?: number, message?: string}} e
|
|
215
190
|
* @returns {number}
|
|
216
191
|
*/
|
|
217
|
-
const getErrorCode = ({ code = 0 }
|
|
192
|
+
const getErrorCode = ({ code = 0 }) => code
|
|
218
193
|
|
|
219
194
|
/**
|
|
220
195
|
* @function getErrorMessage
|
|
@@ -223,7 +198,7 @@ const getErrorCode = ({ code = 0 } = {}) => code
|
|
|
223
198
|
* @param {{code?: number, message?: string}} e
|
|
224
199
|
* @returns {string}
|
|
225
200
|
*/
|
|
226
|
-
const getErrorMessage = ({ message = '' }
|
|
201
|
+
const getErrorMessage = ({ message = '' }) => message
|
|
227
202
|
|
|
228
203
|
/**
|
|
229
204
|
* @function isCommandError
|
|
@@ -241,6 +216,78 @@ function isCommandError (e) {
|
|
|
241
216
|
)
|
|
242
217
|
}
|
|
243
218
|
|
|
219
|
+
/**
|
|
220
|
+
* @function gitConfigUserName
|
|
221
|
+
* @description
|
|
222
|
+
* Get the user email from Git config
|
|
223
|
+
* @param {string} d - A directory configured for Git
|
|
224
|
+
* @returns {Promise<string>}
|
|
225
|
+
*/
|
|
226
|
+
export function gitConfigUserName (d = DIRECTORY) {
|
|
227
|
+
const directory = normalize(d.trim())
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
new Promise((resolve, reject) => {
|
|
231
|
+
const commands = 'git config user.name'
|
|
232
|
+
const options = getOptions(directory)
|
|
233
|
+
/**
|
|
234
|
+
* @type {HandleComplete}
|
|
235
|
+
*/
|
|
236
|
+
function handleComplete (e, v) {
|
|
237
|
+
if (!e) {
|
|
238
|
+
resolve(trim(v))
|
|
239
|
+
} else {
|
|
240
|
+
reject(e)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const {
|
|
245
|
+
stdout,
|
|
246
|
+
stderr
|
|
247
|
+
} = exec(commands, options, handleComplete)
|
|
248
|
+
|
|
249
|
+
if (stdout) stdout.on('data', out('git-config-user-name', directory))
|
|
250
|
+
if (stderr) stderr.on('data', err('git-config-user-name', directory))
|
|
251
|
+
})
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @function gitConfigUserEmail
|
|
257
|
+
* @description
|
|
258
|
+
* Get the user email from Git config
|
|
259
|
+
* @param {string} d - A directory configured for Git
|
|
260
|
+
* @returns {Promise<string>}
|
|
261
|
+
*/
|
|
262
|
+
export function gitConfigUserEmail (d = DIRECTORY) {
|
|
263
|
+
const directory = normalize(d.trim())
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
new Promise((resolve, reject) => {
|
|
267
|
+
const commands = 'git config user.email'
|
|
268
|
+
const options = getOptions(directory)
|
|
269
|
+
/**
|
|
270
|
+
* @type {HandleComplete}
|
|
271
|
+
*/
|
|
272
|
+
function handleComplete (e, v) {
|
|
273
|
+
if (!e) {
|
|
274
|
+
resolve(trim(v))
|
|
275
|
+
} else {
|
|
276
|
+
reject(e)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const {
|
|
281
|
+
stdout,
|
|
282
|
+
stderr
|
|
283
|
+
} = exec(commands, options, handleComplete)
|
|
284
|
+
|
|
285
|
+
if (stdout) stdout.on('data', out('git-config-user-email', directory))
|
|
286
|
+
if (stderr) stderr.on('data', err('git-config-user-email', directory))
|
|
287
|
+
})
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
244
291
|
/**
|
|
245
292
|
* @function catGitRefsRemotesOriginHead
|
|
246
293
|
* @description
|
package/src/common/index.mjs
CHANGED
|
@@ -13,6 +13,10 @@ import PATH from '#where-am-i'
|
|
|
13
13
|
|
|
14
14
|
import debug from '#deps/src/common/debug'
|
|
15
15
|
|
|
16
|
+
import {
|
|
17
|
+
tidy
|
|
18
|
+
} from '#deps/src/common/format'
|
|
19
|
+
|
|
16
20
|
import {
|
|
17
21
|
VERSION,
|
|
18
22
|
PLATFORM
|
|
@@ -30,27 +34,8 @@ const log = debug('@modernpoacher/deps')
|
|
|
30
34
|
|
|
31
35
|
log(`\`common\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
32
36
|
|
|
33
|
-
const LF = String.fromCodePoint(10)
|
|
34
37
|
const SP = String.fromCodePoint(32)
|
|
35
38
|
|
|
36
|
-
/**
|
|
37
|
-
* @param {string} v
|
|
38
|
-
* @returns {string}
|
|
39
|
-
*/
|
|
40
|
-
export const tidy = (v) => v.replace(/\n{2,}}/gm, LF).trim()
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {string} v
|
|
44
|
-
* @returns {string}
|
|
45
|
-
*/
|
|
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()
|
|
53
|
-
|
|
54
39
|
/**
|
|
55
40
|
* @function getSaveProdParameter
|
|
56
41
|
* @description
|
|
@@ -58,7 +43,9 @@ export const trim = (v) => v.split(LF).map(trimEnd).join(LF).trim()
|
|
|
58
43
|
* @param {string} commands commands string
|
|
59
44
|
* @returns {string}
|
|
60
45
|
*/
|
|
61
|
-
export
|
|
46
|
+
export function getSaveProdParameter (commands) {
|
|
47
|
+
return commands.concat(' --save-prod')
|
|
48
|
+
}
|
|
62
49
|
|
|
63
50
|
/**
|
|
64
51
|
* @function getSaveDevParameter
|
|
@@ -67,7 +54,9 @@ export const getSaveProdParameter = (commands) => commands.concat(' --save-prod'
|
|
|
67
54
|
* @param {string} commands commands string
|
|
68
55
|
* @returns {string}
|
|
69
56
|
*/
|
|
70
|
-
export
|
|
57
|
+
export function getSaveDevParameter (commands) {
|
|
58
|
+
return commands.concat(' --save-dev')
|
|
59
|
+
}
|
|
71
60
|
|
|
72
61
|
/**
|
|
73
62
|
* @function getSaveBundleParameter
|
|
@@ -76,7 +65,9 @@ export const getSaveDevParameter = (commands) => commands.concat(' --save-dev')
|
|
|
76
65
|
* @param {string} commands - Current commands string
|
|
77
66
|
* @returns {string}
|
|
78
67
|
*/
|
|
79
|
-
export
|
|
68
|
+
export function getSaveBundleParameter (commands) {
|
|
69
|
+
return commands.concat(' --save-bundle')
|
|
70
|
+
}
|
|
80
71
|
|
|
81
72
|
/**
|
|
82
73
|
* @function getSaveOptionalParameter
|
|
@@ -85,7 +76,9 @@ export const getSaveBundleParameter = (commands) => commands.concat(' --save-bun
|
|
|
85
76
|
* @param {string} commands - Current commands string
|
|
86
77
|
* @returns {string}
|
|
87
78
|
*/
|
|
88
|
-
export
|
|
79
|
+
export function getSaveOptionalParameter (commands) {
|
|
80
|
+
return commands.concat(' --save-optional')
|
|
81
|
+
}
|
|
89
82
|
|
|
90
83
|
/**
|
|
91
84
|
* @function getRegistryParameter
|
|
@@ -95,7 +88,9 @@ export const getSaveOptionalParameter = (commands) => commands.concat(' --save-o
|
|
|
95
88
|
* @param {string} commands - Current commands string
|
|
96
89
|
* @returns {string}
|
|
97
90
|
*/
|
|
98
|
-
export
|
|
91
|
+
export function getRegistryParameter (r, commands) {
|
|
92
|
+
return r ? commands.concat(` --registry ${r}`) : commands
|
|
93
|
+
}
|
|
99
94
|
|
|
100
95
|
/**
|
|
101
96
|
* @function getForceParameter
|
|
@@ -105,7 +100,9 @@ export const getRegistryParameter = (r, commands) => r ? commands.concat(` --reg
|
|
|
105
100
|
* @param {string} commands - Current commands string
|
|
106
101
|
* @returns {string}
|
|
107
102
|
*/
|
|
108
|
-
export
|
|
103
|
+
export function getForceParameter (f, commands) {
|
|
104
|
+
return f ? commands.concat(' --force') : commands
|
|
105
|
+
}
|
|
109
106
|
|
|
110
107
|
/**
|
|
111
108
|
* @function getNoSaveParameter
|
|
@@ -115,7 +112,9 @@ export const getForceParameter = (f, commands) => f ? commands.concat(' --force'
|
|
|
115
112
|
* @param {string} commands - Current commands string
|
|
116
113
|
* @returns {string}
|
|
117
114
|
*/
|
|
118
|
-
export
|
|
115
|
+
export function getNoSaveParameter (s, commands) {
|
|
116
|
+
return s ? commands : commands.concat(' --no-save')
|
|
117
|
+
}
|
|
119
118
|
|
|
120
119
|
/**
|
|
121
120
|
* @function getSaveExactParameter
|
|
@@ -124,7 +123,9 @@ export const getNoSaveParameter = (s, commands) => s ? commands : commands.conca
|
|
|
124
123
|
* @param {string} commands - Current commands string
|
|
125
124
|
* @returns {string}
|
|
126
125
|
*/
|
|
127
|
-
export
|
|
126
|
+
export function getSaveExactParameter (commands) {
|
|
127
|
+
return commands.concat(' --save-exact')
|
|
128
|
+
}
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
131
|
* @function getExportPath
|
|
@@ -133,10 +134,12 @@ export const getSaveExactParameter = (commands) => commands.concat(' --save-exac
|
|
|
133
134
|
* @param {string} commands - Current commands string
|
|
134
135
|
* @returns {string}
|
|
135
136
|
*/
|
|
136
|
-
export
|
|
137
|
+
export function getExportPath (commands) {
|
|
138
|
+
return `
|
|
137
139
|
export PATH=/usr/local/bin:$PATH &> /dev/null
|
|
138
140
|
${commands}
|
|
139
141
|
`
|
|
142
|
+
}
|
|
140
143
|
|
|
141
144
|
/**
|
|
142
145
|
* @function getNvm
|
|
@@ -145,10 +148,12 @@ ${commands}
|
|
|
145
148
|
* @param {string} commands - Current commands string
|
|
146
149
|
* @returns {string}
|
|
147
150
|
*/
|
|
148
|
-
export
|
|
151
|
+
export function getNvm (commands) {
|
|
152
|
+
return `
|
|
149
153
|
bash "${NVM}" 2> /dev/null
|
|
150
154
|
${commands}
|
|
151
155
|
`
|
|
156
|
+
}
|
|
152
157
|
|
|
153
158
|
/**
|
|
154
159
|
* @function getCommands
|
|
@@ -168,7 +173,9 @@ export const getCommands = PLATFORM === 'win32'
|
|
|
168
173
|
* @param {Package | Configuration} deps
|
|
169
174
|
* @returns {Dependencies}
|
|
170
175
|
*/
|
|
171
|
-
export
|
|
176
|
+
export function getProdDependencies ({ dependencies = {} }) {
|
|
177
|
+
return dependencies
|
|
178
|
+
}
|
|
172
179
|
|
|
173
180
|
/**
|
|
174
181
|
* @function getDevDependencies
|
|
@@ -177,7 +184,9 @@ export const getProdDependencies = ({ dependencies = {} } = {}) => dependencies
|
|
|
177
184
|
* @param {Package | Configuration} deps
|
|
178
185
|
* @returns {Dependencies}
|
|
179
186
|
*/
|
|
180
|
-
export
|
|
187
|
+
export function getDevDependencies ({ devDependencies = {} }) {
|
|
188
|
+
return devDependencies
|
|
189
|
+
}
|
|
181
190
|
|
|
182
191
|
/**
|
|
183
192
|
* @function getOptionalDependencies
|
|
@@ -186,7 +195,9 @@ export const getDevDependencies = ({ devDependencies = {} } = {}) => devDependen
|
|
|
186
195
|
* @param {Package | Configuration} deps
|
|
187
196
|
* @returns {Dependencies}
|
|
188
197
|
*/
|
|
189
|
-
export
|
|
198
|
+
export function getOptionalDependencies ({ optionalDependencies = {} }) {
|
|
199
|
+
return optionalDependencies
|
|
200
|
+
}
|
|
190
201
|
|
|
191
202
|
/**
|
|
192
203
|
* @function getBundleDependencies
|
|
@@ -195,7 +206,9 @@ export const getOptionalDependencies = ({ optionalDependencies = {} } = {}) => o
|
|
|
195
206
|
* @param {Package | Configuration} deps
|
|
196
207
|
* @returns {Dependencies}
|
|
197
208
|
*/
|
|
198
|
-
export
|
|
209
|
+
export function getBundleDependencies ({ bundleDependencies = {} }) {
|
|
210
|
+
return bundleDependencies
|
|
211
|
+
}
|
|
199
212
|
|
|
200
213
|
/**
|
|
201
214
|
* @function getPeerDependencies
|
|
@@ -204,7 +217,9 @@ export const getBundleDependencies = ({ bundleDependencies = {} } = {}) => bundl
|
|
|
204
217
|
* @param {Package | Configuration} deps
|
|
205
218
|
* @returns {Dependencies}
|
|
206
219
|
*/
|
|
207
|
-
export
|
|
220
|
+
export function getPeerDependencies ({ peerDependencies = {} }) {
|
|
221
|
+
return peerDependencies
|
|
222
|
+
}
|
|
208
223
|
|
|
209
224
|
/**
|
|
210
225
|
* @function getIgnore
|
|
@@ -213,7 +228,9 @@ export const getPeerDependencies = ({ peerDependencies = {} } = {}) => peerDepen
|
|
|
213
228
|
* @param {Configuration} deps
|
|
214
229
|
* @returns {boolean}
|
|
215
230
|
*/
|
|
216
|
-
export
|
|
231
|
+
export function getIgnore ({ ignore = false }) {
|
|
232
|
+
return ignore === true
|
|
233
|
+
}
|
|
217
234
|
|
|
218
235
|
/**
|
|
219
236
|
* @function getAuthor
|
|
@@ -222,7 +239,7 @@ export const getIgnore = ({ ignore = false } = {}) => ignore === true
|
|
|
222
239
|
* @param {Package | Configuration} deps
|
|
223
240
|
* @returns {string | null}
|
|
224
241
|
*/
|
|
225
|
-
export
|
|
242
|
+
export function getAuthor ({ author = '' }) {
|
|
226
243
|
if (typeof author === 'string') return author
|
|
227
244
|
if (typeof (author || false) === 'object') {
|
|
228
245
|
const {
|
|
@@ -250,7 +267,9 @@ export const getAuthor = ({ author = '' } = {}) => {
|
|
|
250
267
|
* @param {Configuration} deps
|
|
251
268
|
* @returns {string | null}
|
|
252
269
|
*/
|
|
253
|
-
export
|
|
270
|
+
export function getMessage ({ message = '' }) {
|
|
271
|
+
return message || null
|
|
272
|
+
}
|
|
254
273
|
|
|
255
274
|
/**
|
|
256
275
|
* @function isPreRelease
|
|
@@ -259,7 +278,9 @@ export const getMessage = ({ message = '' } = {}) => message || null
|
|
|
259
278
|
* @param {string} v
|
|
260
279
|
* @returns {boolean}
|
|
261
280
|
*/
|
|
262
|
-
export
|
|
281
|
+
export function isPreRelease (v) {
|
|
282
|
+
return /-/.test(v)
|
|
283
|
+
}
|
|
263
284
|
|
|
264
285
|
/**
|
|
265
286
|
* @function isExact
|
|
@@ -268,10 +289,15 @@ export const isPreRelease = (v) => /-/.test(v)
|
|
|
268
289
|
* @param {string} v
|
|
269
290
|
* @returns {boolean}
|
|
270
291
|
*/
|
|
271
|
-
export
|
|
292
|
+
export function isExact (v) {
|
|
293
|
+
return /^\d/.test(v)
|
|
294
|
+
}
|
|
272
295
|
|
|
273
296
|
/**
|
|
274
|
-
* @param {[
|
|
297
|
+
* @param {[
|
|
298
|
+
* name: string,
|
|
299
|
+
* version: string
|
|
300
|
+
* ]} entry
|
|
275
301
|
* @returns {boolean}
|
|
276
302
|
*/
|
|
277
303
|
function includeVersionIsExact ([name, version]) {
|
|
@@ -279,7 +305,10 @@ function includeVersionIsExact ([name, version]) {
|
|
|
279
305
|
}
|
|
280
306
|
|
|
281
307
|
/**
|
|
282
|
-
* @param {[
|
|
308
|
+
* @param {[
|
|
309
|
+
* name: string,
|
|
310
|
+
* version: string
|
|
311
|
+
* ]} entry
|
|
283
312
|
* @returns {boolean}
|
|
284
313
|
*/
|
|
285
314
|
function excludeVersionIsExact ([name, version]) {
|
|
@@ -297,14 +326,20 @@ function excludeVersionIsExact ([name, version]) {
|
|
|
297
326
|
* Each entry is mapped to the same package name in `configurationDependencies` if it
|
|
298
327
|
* appears there. Otherwise, the `packageDependencies` version is used
|
|
299
328
|
* @param {Record<string, string>} configurationDependencies
|
|
300
|
-
* @returns {(entry: [
|
|
329
|
+
* @returns {(entry: [
|
|
330
|
+
* name: string,
|
|
331
|
+
* version: string
|
|
332
|
+
* ]) => {
|
|
301
333
|
* name: string,
|
|
302
334
|
* version: string
|
|
303
335
|
* }}
|
|
304
336
|
*/
|
|
305
337
|
function getMapToDepsExactVersionFromConfiguration (configurationDependencies) {
|
|
306
338
|
/**
|
|
307
|
-
* @param {[
|
|
339
|
+
* @param {[
|
|
340
|
+
* name: string,
|
|
341
|
+
* version: string
|
|
342
|
+
* ]} entry
|
|
308
343
|
* @returns {{
|
|
309
344
|
* name: string,
|
|
310
345
|
* version: string
|
|
@@ -335,7 +370,10 @@ function getMapToDepsExactVersionFromConfiguration (configurationDependencies) {
|
|
|
335
370
|
*
|
|
336
371
|
* Where the version is a pre-release, that version is used. Otherwise the version is
|
|
337
372
|
* set to `latest` to ensure that package is updated
|
|
338
|
-
* @param {[
|
|
373
|
+
* @param {[
|
|
374
|
+
* name: string,
|
|
375
|
+
* version: string
|
|
376
|
+
* ]} entry
|
|
339
377
|
* @returns {{
|
|
340
378
|
* name: string,
|
|
341
379
|
* version: string
|
|
@@ -421,7 +459,9 @@ export function normalizeCommands (commands) {
|
|
|
421
459
|
* @param {DependencyDescriptor | { name?: string, version?: string }} dependencyDescriptor
|
|
422
460
|
* @returns {string}
|
|
423
461
|
*/
|
|
424
|
-
export
|
|
462
|
+
export function transformDependency ({ name = '@modernpoacher/deps', version = 'latest' }) {
|
|
463
|
+
return `${name}@${version}`
|
|
464
|
+
}
|
|
425
465
|
|
|
426
466
|
/**
|
|
427
467
|
* @function transform
|
package/src/common/write.mjs
CHANGED
|
@@ -11,10 +11,11 @@ import write from '@sequencemedia/write'
|
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
13
|
env: {
|
|
14
|
-
|
|
15
|
-
STDERR
|
|
14
|
+
WRITE
|
|
16
15
|
}
|
|
17
16
|
} = process
|
|
18
17
|
|
|
19
|
-
if (
|
|
20
|
-
|
|
18
|
+
if (WRITE) {
|
|
19
|
+
stdout.write = write(stdout, createWriteStream(WRITE))
|
|
20
|
+
stderr.write = write(stderr, createWriteStream(WRITE))
|
|
21
|
+
}
|
package/src/index.mjs
CHANGED
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
* @returns {void}
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import stripAnsi from 'strip-ansi'
|
|
23
|
-
|
|
24
22
|
import {
|
|
25
23
|
normalize
|
|
26
24
|
} from 'node:path'
|
|
@@ -31,6 +29,10 @@ import {
|
|
|
31
29
|
|
|
32
30
|
import debug from '#deps/src/common/debug'
|
|
33
31
|
|
|
32
|
+
import {
|
|
33
|
+
use
|
|
34
|
+
} from '#deps/src/common/format'
|
|
35
|
+
|
|
34
36
|
import {
|
|
35
37
|
VERSION,
|
|
36
38
|
PLATFORM
|
|
@@ -62,38 +64,6 @@ const info = debug('@modernpoacher/deps:info')
|
|
|
62
64
|
|
|
63
65
|
log(`\`deps\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
64
66
|
|
|
65
|
-
const LF = String.fromCodePoint(10)
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @param {string} v
|
|
69
|
-
* @returns {boolean}
|
|
70
|
-
*/
|
|
71
|
-
function filter (v) {
|
|
72
|
-
return Boolean(stripAnsi(v).trim())
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @param {string} key
|
|
77
|
-
* @returns {(value: string) => void}
|
|
78
|
-
*/
|
|
79
|
-
export function use (key) {
|
|
80
|
-
const log = debug(`@modernpoacher/deps:${key}`)
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @param {string} v
|
|
84
|
-
* @returns {void}
|
|
85
|
-
*/
|
|
86
|
-
function write (v) {
|
|
87
|
-
log(v.trimEnd())
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return function use (value) {
|
|
91
|
-
value.split(LF)
|
|
92
|
-
.filter(filter)
|
|
93
|
-
.forEach(write)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
67
|
/**
|
|
98
68
|
* @function getInstallSaveExactCommands
|
|
99
69
|
* @description
|