@node-core/utils 6.2.1 → 6.3.1
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/ncu-ci.js +9 -1
- package/components/git/land.js +5 -9
- package/components/git/security.js +23 -40
- package/lib/auth.js +7 -11
- package/lib/ci/build-types/pr_build.js +1 -2
- package/lib/ci/run_ci.js +25 -6
- package/lib/landing_session.js +70 -43
- package/lib/metadata_gen.js +4 -12
- package/lib/prepare_release.js +28 -96
- package/lib/prepare_security.js +7 -11
- package/lib/request.js +15 -36
- package/lib/session.js +5 -2
- package/lib/voting_session.js +13 -18
- package/npm-shrinkwrap.json +463 -377
- package/package.json +4 -4
package/lib/prepare_security.js
CHANGED
|
@@ -203,23 +203,19 @@ export default class PrepareSecurityRelease extends SecurityRelease {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
async createVulnerabilitiesJSON(reports, dependencies, releaseDate) {
|
|
206
|
-
this.cli.
|
|
207
|
-
const
|
|
206
|
+
this.cli.startSpinner('Creating vulnerabilities.json...');
|
|
207
|
+
const fileContent = JSON.stringify({
|
|
208
208
|
releaseDate,
|
|
209
209
|
reports,
|
|
210
210
|
dependencies
|
|
211
|
-
}, null, 2);
|
|
211
|
+
}, null, 2) + '\n';
|
|
212
212
|
|
|
213
|
-
const folderPath = path.
|
|
214
|
-
|
|
215
|
-
fs.accessSync(folderPath);
|
|
216
|
-
} catch (error) {
|
|
217
|
-
fs.mkdirSync(folderPath, { recursive: true });
|
|
218
|
-
}
|
|
213
|
+
const folderPath = path.resolve(NEXT_SECURITY_RELEASE_FOLDER);
|
|
214
|
+
await fs.promises.mkdir(folderPath, { recursive: true });
|
|
219
215
|
|
|
220
216
|
const fullPath = path.join(folderPath, 'vulnerabilities.json');
|
|
221
|
-
fs.
|
|
222
|
-
this.cli.
|
|
217
|
+
await fs.promises.writeFile(fullPath, fileContent);
|
|
218
|
+
this.cli.stopSpinner(`Created ${fullPath}`);
|
|
223
219
|
|
|
224
220
|
return fullPath;
|
|
225
221
|
}
|
package/lib/request.js
CHANGED
|
@@ -32,6 +32,14 @@ export default class Request {
|
|
|
32
32
|
if (url.startsWith(`https://${CI_DOMAIN}`)) {
|
|
33
33
|
options.headers = options.headers || {};
|
|
34
34
|
Object.assign(options.headers, this.getJenkinsHeaders());
|
|
35
|
+
} else if (!url.startsWith('https://')) {
|
|
36
|
+
url = new URL(url, 'https://api.github.com/').href;
|
|
37
|
+
options.headers = {
|
|
38
|
+
Authorization: `Basic ${this.credentials.github}`,
|
|
39
|
+
'User-Agent': 'node-core-utils',
|
|
40
|
+
Accept: 'application/vnd.github+json',
|
|
41
|
+
...options.headers
|
|
42
|
+
};
|
|
35
43
|
}
|
|
36
44
|
return wrappedFetch(url, options);
|
|
37
45
|
}
|
|
@@ -65,14 +73,9 @@ export default class Request {
|
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
async createIssue(title, body, { owner, repo }) {
|
|
68
|
-
const url =
|
|
76
|
+
const url = `/repos/${owner}/${repo}/issues`;
|
|
69
77
|
const options = {
|
|
70
78
|
method: 'POST',
|
|
71
|
-
headers: {
|
|
72
|
-
Authorization: `Basic ${this.credentials.github}`,
|
|
73
|
-
'User-Agent': 'node-core-utils',
|
|
74
|
-
Accept: 'application/vnd.github+json'
|
|
75
|
-
},
|
|
76
79
|
body: JSON.stringify({
|
|
77
80
|
title,
|
|
78
81
|
body
|
|
@@ -82,15 +85,9 @@ export default class Request {
|
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
async commentIssue(fullUrl, comment) {
|
|
85
|
-
const commentUrl = fullUrl.replace('https://github.com/', '
|
|
86
|
-
'/comments';
|
|
88
|
+
const commentUrl = fullUrl.replace('https://github.com/', '/repos/') + '/comments';
|
|
87
89
|
const options = {
|
|
88
90
|
method: 'POST',
|
|
89
|
-
headers: {
|
|
90
|
-
Authorization: `Basic ${this.credentials.github}`,
|
|
91
|
-
'User-Agent': 'node-core-utils',
|
|
92
|
-
Accept: 'application/vnd.github+json'
|
|
93
|
-
},
|
|
94
91
|
body: JSON.stringify({
|
|
95
92
|
body: comment,
|
|
96
93
|
})
|
|
@@ -99,27 +96,14 @@ export default class Request {
|
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
async getPullRequest(fullUrl) {
|
|
102
|
-
const prUrl = fullUrl.replace('https://github.com/', '
|
|
103
|
-
|
|
104
|
-
method: 'GET',
|
|
105
|
-
headers: {
|
|
106
|
-
Authorization: `Basic ${this.credentials.github}`,
|
|
107
|
-
'User-Agent': 'node-core-utils',
|
|
108
|
-
Accept: 'application/vnd.github+json'
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
return this.json(prUrl, options);
|
|
99
|
+
const prUrl = fullUrl.replace('https://github.com/', '/repos/').replace('pull', 'pulls');
|
|
100
|
+
return this.json(prUrl);
|
|
112
101
|
}
|
|
113
102
|
|
|
114
103
|
async createPullRequest(title, body, { owner, repo, head, base }) {
|
|
115
|
-
const url =
|
|
104
|
+
const url = `/repos/${owner}/${repo}/pulls`;
|
|
116
105
|
const options = {
|
|
117
106
|
method: 'POST',
|
|
118
|
-
headers: {
|
|
119
|
-
Authorization: `Basic ${this.credentials.github}`,
|
|
120
|
-
'User-Agent': 'node-core-utils',
|
|
121
|
-
Accept: 'application/vnd.github+json'
|
|
122
|
-
},
|
|
123
107
|
body: JSON.stringify({
|
|
124
108
|
title,
|
|
125
109
|
body,
|
|
@@ -131,13 +115,10 @@ export default class Request {
|
|
|
131
115
|
}
|
|
132
116
|
|
|
133
117
|
async closePullRequest(id, { owner, repo }) {
|
|
134
|
-
const url =
|
|
118
|
+
const url = `/repos/${owner}/${repo}/pulls/${id}`;
|
|
135
119
|
const options = {
|
|
136
120
|
method: 'POST',
|
|
137
121
|
headers: {
|
|
138
|
-
Authorization: `Basic ${this.credentials.github}`,
|
|
139
|
-
'User-Agent': 'node-core-utils',
|
|
140
|
-
Accept: 'application/vnd.github+json',
|
|
141
122
|
'Content-Type': 'application/json'
|
|
142
123
|
},
|
|
143
124
|
body: JSON.stringify({
|
|
@@ -299,13 +280,11 @@ export default class Request {
|
|
|
299
280
|
throw new Error('The request has not been ' +
|
|
300
281
|
'authenticated with a GitHub token');
|
|
301
282
|
}
|
|
302
|
-
const url = '
|
|
283
|
+
const url = '/graphql';
|
|
303
284
|
const options = {
|
|
304
285
|
agent: this.proxyAgent,
|
|
305
286
|
method: 'POST',
|
|
306
287
|
headers: {
|
|
307
|
-
Authorization: `Basic ${githubCredentials}`,
|
|
308
|
-
'User-Agent': 'node-core-utils',
|
|
309
288
|
Accept: 'application/vnd.github.antiope-preview+json'
|
|
310
289
|
},
|
|
311
290
|
body: JSON.stringify({
|
package/lib/session.js
CHANGED
|
@@ -33,10 +33,11 @@ export default class Session {
|
|
|
33
33
|
const upstreamHref = runSync('git', [
|
|
34
34
|
'config', '--get',
|
|
35
35
|
`remote.${upstream}.url`]).trim();
|
|
36
|
-
if (!
|
|
36
|
+
if (!upstreamHref.endsWith(`${owner}/${repo}.git`) &&
|
|
37
|
+
!upstreamHref.endsWith(`${owner}/${repo}`)) {
|
|
37
38
|
cli.warn('Remote repository URL does not point to the expected ' +
|
|
38
39
|
`repository ${owner}/${repo}`);
|
|
39
|
-
|
|
40
|
+
this.crossRepoPR = true;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -126,6 +127,7 @@ export default class Session {
|
|
|
126
127
|
writeJson(this.sessionPath, {
|
|
127
128
|
state: STARTED,
|
|
128
129
|
prid: this.prid,
|
|
130
|
+
backport: this.backport,
|
|
129
131
|
// Filter out getters, those are likely encrypted data we don't need on the session.
|
|
130
132
|
config: Object.entries(Object.getOwnPropertyDescriptors(this.config))
|
|
131
133
|
.reduce((pv, [key, desc]) => {
|
|
@@ -270,6 +272,7 @@ export default class Session {
|
|
|
270
272
|
const sess = this.session;
|
|
271
273
|
if (sess.prid) {
|
|
272
274
|
this.prid = sess.prid;
|
|
275
|
+
this.backport = sess.backport;
|
|
273
276
|
this.config = sess.config;
|
|
274
277
|
}
|
|
275
278
|
return this;
|
package/lib/voting_session.js
CHANGED
|
@@ -72,14 +72,10 @@ export default class VotingSession extends Session {
|
|
|
72
72
|
const subPath = `${prInfo.headRef.name}/vote.yml`;
|
|
73
73
|
this.cli.startSpinner('Downloading vote file from remote...');
|
|
74
74
|
const yamlString = await this.req.text(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'User-Agent': 'node-core-utils',
|
|
80
|
-
Accept: 'application/vnd.github.raw'
|
|
81
|
-
}
|
|
82
|
-
});
|
|
75
|
+
`/repos/${this.owner}/${this.repo}/contents/${
|
|
76
|
+
encodeURIComponent(subPath)}?ref=${prInfo.commits.nodes[0].commit.oid}`,
|
|
77
|
+
{ agent: this.req.proxyAgent }
|
|
78
|
+
);
|
|
83
79
|
this.cli.stopSpinner('Download complete');
|
|
84
80
|
|
|
85
81
|
const { shares } = yaml.load(yamlString);
|
|
@@ -114,16 +110,15 @@ export default class VotingSession extends Session {
|
|
|
114
110
|
const body = 'I would like to close this vote, and for this effect, I\'m revealing my ' +
|
|
115
111
|
`key part:\n\n${'```'}\n${keyPart}\n${'```'}\n`;
|
|
116
112
|
if (this.postComment) {
|
|
117
|
-
const { message, html_url } = await this.req.json(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
});
|
|
113
|
+
const { message, html_url } = await this.req.json(
|
|
114
|
+
`/repos/${this.owner}/${this.repo}/issues/${this.prid}/comments`,
|
|
115
|
+
{
|
|
116
|
+
agent: this.req.proxyAgent,
|
|
117
|
+
method: 'POST',
|
|
118
|
+
headers: { Accept: 'application/vnd.github.antiope-preview+json' },
|
|
119
|
+
body: JSON.stringify({ body })
|
|
120
|
+
}
|
|
121
|
+
);
|
|
127
122
|
if (html_url) {
|
|
128
123
|
this.cli.log(`Comment posted at: ${html_url}`);
|
|
129
124
|
return;
|