@modernpoacher/deps 2.2.18 → 2.2.20
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 +162 -48
- package/bin/deps.mjs +10 -9
- package/bin/node/deps.mjs +5 -21
- package/bin/node/execute.mjs +152 -40
- package/bin/node/head.mjs +5 -21
- package/bin/node/install.mjs +9 -8
- package/bin/node/push.mjs +5 -21
- package/bin/node/wipe.mjs +5 -21
- package/eslint.config.mjs +103 -0
- package/index.d.mts +50 -0
- package/package.json +24 -18
- package/src/common/debug.mjs +2 -0
- package/src/common/env/index.mjs +5 -5
- package/src/common/git/index.mjs +230 -131
- package/src/common/index.mjs +79 -121
- package/src/common/options/index.mjs +14 -20
- package/src/index.mjs +178 -113
- package/src/install/index.mjs +49 -34
- package/tsconfig.json +20 -0
package/src/install/index.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @typedef {
|
|
2
|
+
* @typedef {import('node:child_process').ExecException} ExecException
|
|
3
|
+
* @typedef {DepsTypes.DependencyDescriptor} DependencyDescriptor
|
|
4
|
+
* @typedef {DepsTypes.Package} Package
|
|
5
|
+
* @typedef {DepsTypes.Configuration} Configuration
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
+
* @callback HandleComplete
|
|
10
|
+
* @param {ExecException | null} e
|
|
11
|
+
* @param {string} v
|
|
12
|
+
* @returns {void}
|
|
9
13
|
*/
|
|
10
14
|
|
|
11
|
-
import debug from 'debug'
|
|
12
|
-
|
|
13
15
|
import {
|
|
14
16
|
normalize
|
|
15
17
|
} from 'node:path'
|
|
@@ -18,6 +20,8 @@ import {
|
|
|
18
20
|
exec
|
|
19
21
|
} from 'node:child_process'
|
|
20
22
|
|
|
23
|
+
import debug from '#deps/src/common/debug'
|
|
24
|
+
|
|
21
25
|
import {
|
|
22
26
|
VERSION,
|
|
23
27
|
PLATFORM
|
|
@@ -48,10 +52,9 @@ log(`\`install\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* @function getInstallSaveExactCommands
|
|
51
|
-
*
|
|
55
|
+
* @description
|
|
52
56
|
* Get the `install --save-exact` commands as a string
|
|
53
|
-
*
|
|
54
|
-
* @param {Package} p - Package
|
|
57
|
+
* @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
|
|
55
58
|
* @param {boolean} s - Save
|
|
56
59
|
* @param {string} r - Registry
|
|
57
60
|
* @param {boolean} f - Force
|
|
@@ -71,10 +74,9 @@ export function getInstallSaveExactCommands (p, s, r, f) {
|
|
|
71
74
|
|
|
72
75
|
/**
|
|
73
76
|
* @function getInstallCommands
|
|
74
|
-
*
|
|
77
|
+
* @description
|
|
75
78
|
* Get the `install` commands as a string
|
|
76
|
-
*
|
|
77
|
-
* @param {Package} p - Package
|
|
79
|
+
* @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
|
|
78
80
|
* @param {boolean} s - Save
|
|
79
81
|
* @param {string} r - Registry
|
|
80
82
|
* @param {boolean} f - Force
|
|
@@ -94,14 +96,13 @@ export function getInstallCommands (p, s, r, f) {
|
|
|
94
96
|
|
|
95
97
|
/**
|
|
96
98
|
* @function installSaveExact
|
|
97
|
-
*
|
|
99
|
+
* @description
|
|
98
100
|
* Spawn the `install --save-exact` commands
|
|
99
|
-
*
|
|
100
101
|
* @param {string} d - Directory
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {Configuration} c - Configuration
|
|
102
|
+
* @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
|
|
103
103
|
* @param {boolean} s - Save
|
|
104
104
|
* @param {string} r - Registry
|
|
105
|
+
* @param {boolean} f - Force
|
|
105
106
|
* @returns {Promise<string>}
|
|
106
107
|
*/
|
|
107
108
|
export function installSaveExact (d, p, s, r, f) {
|
|
@@ -109,36 +110,43 @@ export function installSaveExact (d, p, s, r, f) {
|
|
|
109
110
|
|
|
110
111
|
const directory = normalize(d.trim())
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
info(`Directory is "${directory}"`)
|
|
113
114
|
|
|
114
115
|
return (
|
|
115
116
|
new Promise((resolve, reject) => {
|
|
116
117
|
const commands = getCommands(getInstallSaveExactCommands(p, s, r, f))
|
|
117
118
|
const options = getOptions(directory)
|
|
119
|
+
/**
|
|
120
|
+
* @type {HandleComplete}
|
|
121
|
+
*/
|
|
122
|
+
function handleComplete (e, v) {
|
|
123
|
+
if (!e) {
|
|
124
|
+
resolve(v)
|
|
125
|
+
} else {
|
|
126
|
+
reject(e)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
118
129
|
|
|
119
130
|
const {
|
|
120
131
|
stdout,
|
|
121
132
|
stderr
|
|
122
|
-
} = exec(commands, options,
|
|
123
|
-
return (!e) ? resolve(v) : reject(e)
|
|
124
|
-
})
|
|
133
|
+
} = exec(commands, options, handleComplete)
|
|
125
134
|
|
|
126
|
-
stdout.on('data', log)
|
|
127
|
-
stderr.on('data', log)
|
|
135
|
+
if (stdout) stdout.on('data', log)
|
|
136
|
+
if (stderr) stderr.on('data', log)
|
|
128
137
|
})
|
|
129
138
|
)
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
/**
|
|
133
142
|
* @function install
|
|
134
|
-
*
|
|
143
|
+
* @description
|
|
135
144
|
* Spawn the `install` commands
|
|
136
|
-
*
|
|
137
145
|
* @param {string} d - Directory
|
|
138
|
-
* @param {
|
|
139
|
-
* @param {Configuration} c - Configuration
|
|
146
|
+
* @param {DependencyDescriptor | DependencyDescriptor[]} p - Package
|
|
140
147
|
* @param {boolean} s - Save
|
|
141
148
|
* @param {string} r - Registry
|
|
149
|
+
* @param {boolean} f - Force
|
|
142
150
|
* @returns {Promise<string>}
|
|
143
151
|
*/
|
|
144
152
|
export function install (d, p, s, r, f) {
|
|
@@ -146,31 +154,38 @@ export function install (d, p, s, r, f) {
|
|
|
146
154
|
|
|
147
155
|
const directory = normalize(d.trim())
|
|
148
156
|
|
|
149
|
-
|
|
157
|
+
info(`Directory is "${directory}"`)
|
|
150
158
|
|
|
151
159
|
return (
|
|
152
160
|
new Promise((resolve, reject) => {
|
|
153
161
|
const commands = getCommands(getInstallCommands(p, s, r, f))
|
|
154
162
|
const options = getOptions(directory)
|
|
163
|
+
/**
|
|
164
|
+
* @type {HandleComplete}
|
|
165
|
+
*/
|
|
166
|
+
function handleComplete (e, v) {
|
|
167
|
+
if (!e) {
|
|
168
|
+
resolve(v)
|
|
169
|
+
} else {
|
|
170
|
+
reject(e)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
155
173
|
|
|
156
174
|
const {
|
|
157
175
|
stdout,
|
|
158
176
|
stderr
|
|
159
|
-
} = exec(commands, options,
|
|
160
|
-
return (!e) ? resolve(v) : reject(e)
|
|
161
|
-
})
|
|
177
|
+
} = exec(commands, options, handleComplete)
|
|
162
178
|
|
|
163
|
-
stdout.on('data', log)
|
|
164
|
-
stderr.on('data', log)
|
|
179
|
+
if (stdout) stdout.on('data', log)
|
|
180
|
+
if (stderr) stderr.on('data', log)
|
|
165
181
|
})
|
|
166
182
|
)
|
|
167
183
|
}
|
|
168
184
|
|
|
169
185
|
/**
|
|
170
186
|
* @function execute
|
|
171
|
-
*
|
|
187
|
+
* @description
|
|
172
188
|
* Execute the `install --save-exact` and `install` commands
|
|
173
|
-
*
|
|
174
189
|
* @param {string} d - Directory
|
|
175
190
|
* @param {Package} p - Package
|
|
176
191
|
* @param {Configuration} c - Configuration
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"checkJs": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"baseUrl": "."
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"."
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"test",
|
|
16
|
+
".circleci",
|
|
17
|
+
".github",
|
|
18
|
+
".husky",
|
|
19
|
+
]
|
|
20
|
+
}
|