@node-core/utils 5.3.1 → 5.4.0

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/lib/pr_checker.js CHANGED
@@ -29,6 +29,7 @@ const GITHUB_SUCCESS_CONCLUSIONS = ['SUCCESS', 'NEUTRAL', 'SKIPPED'];
29
29
  const FAST_TRACK_RE = /^Fast-track has been requested by @(.+?)\. Please 👍 to approve\.$/;
30
30
  const FAST_TRACK_MIN_APPROVALS = 2;
31
31
  const GIT_CONFIG_GUIDE_URL = 'https://github.com/nodejs/node/blob/99b1ada/doc/guides/contributing/pull-requests.md#step-1-fork';
32
+ const IGNORED_CHECK_SLUGS = ['dependabot', 'codecov'];
32
33
 
33
34
  // eslint-disable-next-line no-extend-native
34
35
  Array.prototype.findLastIndex ??= function findLastIndex(fn) {
@@ -373,9 +374,9 @@ export default class PRChecker {
373
374
 
374
375
  // GitHub new Check API
375
376
  for (const { status, conclusion, app } of checkSuites.nodes) {
376
- if (app && app.slug === 'dependabot') {
377
- // Ignore Dependabot check suites. They are expected to show up
378
- // sometimes and never complete.
377
+ if (app && IGNORED_CHECK_SLUGS.includes(app.slug)) {
378
+ // Ignore Dependabot and Codecov check suites.
379
+ // They are expected to show up sometimes and never complete.
379
380
  continue;
380
381
  }
381
382
 
@@ -6,7 +6,6 @@ import {
6
6
  NEXT_SECURITY_RELEASE_BRANCH,
7
7
  NEXT_SECURITY_RELEASE_FOLDER,
8
8
  NEXT_SECURITY_RELEASE_REPOSITORY,
9
- PLACEHOLDERS,
10
9
  checkoutOnSecurityReleaseBranch,
11
10
  commitAndPushVulnerabilitiesJSON,
12
11
  validateDate,
@@ -37,22 +36,15 @@ export default class PrepareSecurityRelease {
37
36
  const createVulnerabilitiesJSON = await this.promptVulnerabilitiesJSON();
38
37
 
39
38
  let securityReleasePRUrl;
39
+ const content = await this.buildDescription(releaseDate, securityReleasePRUrl);
40
40
  if (createVulnerabilitiesJSON) {
41
- securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate);
41
+ securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate, content);
42
42
  }
43
43
 
44
- const createIssue = await this.promptCreateRelaseIssue();
45
-
46
- if (createIssue) {
47
- const content = await this.buildIssue(releaseDate, securityReleasePRUrl);
48
- await createIssue(
49
- this.title, content, this.repository, { cli: this.cli, repository: this.repository });
50
- };
51
-
52
44
  this.cli.ok('Done!');
53
45
  }
54
46
 
55
- async startVulnerabilitiesJSONCreation(releaseDate) {
47
+ async startVulnerabilitiesJSONCreation(releaseDate, content) {
56
48
  // checkout on the next-security-release branch
57
49
  checkoutOnSecurityReleaseBranch(this.cli, this.repository);
58
50
 
@@ -87,7 +79,7 @@ export default class PrepareSecurityRelease {
87
79
  if (!createPr) return;
88
80
 
89
81
  // create pr on the security-release repo
90
- return this.createPullRequest();
82
+ return this.createPullRequest(content);
91
83
  }
92
84
 
93
85
  promptCreatePR() {
@@ -143,11 +135,9 @@ export default class PrepareSecurityRelease {
143
135
  { defaultAnswer: true });
144
136
  }
145
137
 
146
- async buildIssue(releaseDate, securityReleasePRUrl = PLACEHOLDERS.vulnerabilitiesPRURL) {
138
+ async buildDescription() {
147
139
  const template = await this.getSecurityIssueTemplate();
148
- const content = template.replace(PLACEHOLDERS.releaseDate, releaseDate)
149
- .replace(PLACEHOLDERS.vulnerabilitiesPRURL, securityReleasePRUrl);
150
- return content;
140
+ return template;
151
141
  }
152
142
 
153
143
  async chooseReports() {
@@ -185,11 +175,11 @@ export default class PrepareSecurityRelease {
185
175
  return fullPath;
186
176
  }
187
177
 
188
- async createPullRequest() {
178
+ async createPullRequest(content) {
189
179
  const { owner, repo } = this.repository;
190
180
  const response = await this.req.createPullRequest(
191
181
  this.title,
192
- 'List of vulnerabilities to be included in the next security release',
182
+ content ?? 'List of vulnerabilities to be included in the next security release',
193
183
  {
194
184
  owner,
195
185
  repo,
@@ -232,9 +232,10 @@ export default class SecurityBlog {
232
232
  }
233
233
 
234
234
  getDependencyUpdatesTemplate(dependencyUpdates) {
235
- if (!dependencyUpdates) return '';
236
- let template = 'This security release includes the following dependency' +
237
- ' updates to address public vulnerabilities:\n\n';
235
+ if (typeof dependencyUpdates !== 'object') return '';
236
+ if (Object.keys(dependencyUpdates).length === 0) return '';
237
+ let template = '\nThis security release includes the following dependency' +
238
+ ' updates to address public vulnerabilities:\n';
238
239
  for (const dependencyUpdate of Object.values(dependencyUpdates)) {
239
240
  for (const dependency of dependencyUpdate) {
240
241
  const title = dependency.title.substring(dependency.title.indexOf(':') + ':'.length).trim();
@@ -330,7 +331,12 @@ export default class SecurityBlog {
330
331
  affectedVersions.add(affectedVersion);
331
332
  }
332
333
  }
333
- return Array.from(affectedVersions).join(', ');
334
+ const parseToNumber = str => +(str.match(/[\d.]+/g)[0]);
335
+ return Array.from(affectedVersions)
336
+ .sort((a, b) => {
337
+ return parseToNumber(a) > parseToNumber(b) ? -1 : 1;
338
+ })
339
+ .join(', ');
334
340
  }
335
341
 
336
342
  getSecurityPreReleaseTemplate() {
@@ -1,7 +1,5 @@
1
1
  import path from 'node:path';
2
2
 
3
- import { Listr } from 'listr2';
4
-
5
3
  import {
6
4
  getNodeV8Version,
7
5
  filterForVersion,
@@ -19,10 +17,10 @@ const nodeChanges = [
19
17
  export default function applyNodeChanges() {
20
18
  return {
21
19
  title: 'Apply Node-specific changes',
22
- task: async(ctx) => {
20
+ task: async(ctx, task) => {
23
21
  const v8Version = await getNodeV8Version(ctx.nodeDir);
24
22
  const list = filterForVersion(nodeChanges, v8Version);
25
- return new Listr(list.map((change) => change.task()));
23
+ return task.newListr(list.map((change) => change.task()));
26
24
  }
27
25
  };
28
26
  }
@@ -4,7 +4,6 @@ import {
4
4
  } from 'node:fs';
5
5
 
6
6
  import inquirer from 'inquirer';
7
- import { Listr } from 'listr2';
8
7
  import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer';
9
8
 
10
9
  import { shortSha } from '../utils.js';
@@ -50,8 +49,8 @@ export function doBackport(options) {
50
49
 
51
50
  return {
52
51
  title: 'V8 commit backport',
53
- task: () => {
54
- return new Listr(todo);
52
+ task: (ctx, task) => {
53
+ return task.newListr(todo);
55
54
  }
56
55
  };
57
56
  };
@@ -164,8 +163,8 @@ function applyPatches() {
164
163
  function applyAndCommitPatches() {
165
164
  return {
166
165
  title: 'Apply and commit patches to deps/v8',
167
- task: (ctx) => {
168
- return new Listr(ctx.patches.map(applyPatchTask));
166
+ task: (ctx, task) => {
167
+ return task.newListr(ctx.patches.map(applyPatchTask));
169
168
  }
170
169
  };
171
170
  }
@@ -173,7 +172,7 @@ function applyAndCommitPatches() {
173
172
  function applyPatchTask(patch) {
174
173
  return {
175
174
  title: `Commit ${shortSha(patch.sha)}`,
176
- task: (ctx) => {
175
+ task: (ctx, task) => {
177
176
  const todo = [
178
177
  {
179
178
  title: 'Apply patch',
@@ -188,7 +187,7 @@ function applyPatchTask(patch) {
188
187
  }
189
188
  }
190
189
  todo.push(commitPatch(patch));
191
- return new Listr(todo);
190
+ return task.newListr(todo);
192
191
  }
193
192
  };
194
193
  }
@@ -1,8 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { promises as fs } from 'node:fs';
3
3
 
4
- import { Listr } from 'listr2';
5
-
6
4
  import { getCurrentV8Version } from './common.js';
7
5
  import {
8
6
  getNodeV8Version,
@@ -19,8 +17,8 @@ import { forceRunAsync } from '../run.js';
19
17
  export default function majorUpdate() {
20
18
  return {
21
19
  title: 'Major V8 update',
22
- task: () => {
23
- return new Listr([
20
+ task: (ctx, task) => {
21
+ return task.newListr([
24
22
  getCurrentV8Version(),
25
23
  checkoutBranch(),
26
24
  removeDepsV8(),
@@ -2,8 +2,6 @@ import { spawn } from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import { promises as fs } from 'node:fs';
4
4
 
5
- import { Listr } from 'listr2';
6
-
7
5
  import { getCurrentV8Version } from './common.js';
8
6
  import { isVersionString } from './util.js';
9
7
  import { forceRunAsync } from '../run.js';
@@ -11,8 +9,8 @@ import { forceRunAsync } from '../run.js';
11
9
  export default function minorUpdate() {
12
10
  return {
13
11
  title: 'Minor V8 update',
14
- task: () => {
15
- return new Listr([
12
+ task: (ctx, task) => {
13
+ return task.newListr([
16
14
  getCurrentV8Version(),
17
15
  getLatestV8Version(),
18
16
  doMinorUpdate()
@@ -1,15 +1,13 @@
1
1
  import { promises as fs } from 'node:fs';
2
2
 
3
- import { Listr } from 'listr2';
4
-
5
3
  import { v8Git } from './constants.js';
6
4
  import { forceRunAsync } from '../run.js';
7
5
 
8
6
  export default function updateV8Clone() {
9
7
  return {
10
8
  title: 'Update local V8 clone',
11
- task: () => {
12
- return new Listr([fetchOrigin(), createClone()]);
9
+ task: (ctx, task) => {
10
+ return task.newListr([fetchOrigin(), createClone()]);
13
11
  }
14
12
  };
15
13
  };
@@ -1,15 +1,13 @@
1
1
  import path from 'node:path';
2
2
  import { promises as fs } from 'node:fs';
3
3
 
4
- import { Listr } from 'listr2';
5
-
6
4
  import { getNodeV8Version } from './util.js';
7
5
 
8
6
  export default function updateVersionNumbers() {
9
7
  return {
10
8
  title: 'Update version numbers',
11
- task: () => {
12
- return new Listr([resetEmbedderString(), bumpNodeModule()]);
9
+ task: (ctx, task) => {
10
+ return task.newListr([resetEmbedderString(), bumpNodeModule()]);
13
11
  }
14
12
  };
15
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-core/utils",
3
- "version": "5.3.1",
3
+ "version": "5.4.0",
4
4
  "description": "Utilities for Node.js core collaborators",
5
5
  "type": "module",
6
6
  "engines": {