@node-core/utils 5.5.0 → 5.6.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/bin/ncu-ci.js CHANGED
@@ -77,12 +77,13 @@ const args = yargs(hideBin(process.argv))
77
77
  })
78
78
  .option('stats', {
79
79
  default: false,
80
+ type: 'boolean',
80
81
  describe: 'Aggregate the results'
81
82
  })
82
83
  .option('cache', {
83
84
  default: false,
84
- describe: 'Cache the responses from Jenkins in .ncu/cache/ under' +
85
- ' the node-core-utils installation directory'
85
+ type: 'boolean',
86
+ describe: 'Cache the responses from Jenkins in $tmpdir/ncu/cache for testing'
86
87
  })
87
88
  .option('limit', {
88
89
  default: 99,
@@ -199,13 +200,14 @@ const args = yargs(hideBin(process.argv))
199
200
  builder: (yargs) => {
200
201
  yargs
201
202
  .option('stats', {
203
+ type: 'boolean',
202
204
  default: false,
203
205
  describe: 'Aggregate the results'
204
206
  })
205
207
  .option('cache', {
208
+ type: 'boolean',
206
209
  default: false,
207
- describe: 'Cache the responses from Jenkins in .ncu/cache/ under' +
208
- ' the node-core-utils installation directory'
210
+ describe: 'Cache the responses from Jenkins in $tmpdir/ncu/cache for testing'
209
211
  })
210
212
  .option('limit', {
211
213
  default: 15,
@@ -17,6 +17,10 @@ const releaseOptions = {
17
17
  describe: 'Promote new release of Node.js',
18
18
  type: 'boolean'
19
19
  },
20
+ releaseDate: {
21
+ describe: 'Default relase date when --prepare is used. It must be YYYY-MM-DD',
22
+ type: 'string'
23
+ },
20
24
  security: {
21
25
  describe: 'Demarcate the new security release as a security release',
22
26
  type: 'boolean'
@@ -32,6 +36,11 @@ const releaseOptions = {
32
36
  startLTS: {
33
37
  describe: 'Mark the release as the transition from Current to LTS',
34
38
  type: 'boolean'
39
+ },
40
+ yes: {
41
+ type: 'boolean',
42
+ default: false,
43
+ describe: 'Skip all prompts and run non-interactively'
35
44
  }
36
45
  };
37
46
 
@@ -66,6 +75,10 @@ function release(state, argv) {
66
75
  const cli = new CLI(logStream);
67
76
  const dir = process.cwd();
68
77
 
78
+ if (argv.yes) {
79
+ cli.setAssumeYes();
80
+ }
81
+
69
82
  return runPromise(main(state, argv, cli, dir)).catch((err) => {
70
83
  if (cli.spinner.enabled) {
71
84
  cli.spinner.fail();
@@ -22,6 +22,7 @@ export function builder(yargs) {
22
22
  default: 'lkgr'
23
23
  });
24
24
  yargs.option('version-bump', {
25
+ type: 'boolean',
25
26
  describe: 'Bump the NODE_MODULE_VERSION constant',
26
27
  default: true
27
28
  });
@@ -39,10 +40,12 @@ export function builder(yargs) {
39
40
  builder: (yargs) => {
40
41
  yargs
41
42
  .option('bump', {
43
+ type: 'boolean',
42
44
  describe: 'Bump V8 embedder version number or patch version',
43
45
  default: true
44
46
  })
45
47
  .option('squash', {
48
+ type: 'boolean',
46
49
  describe:
47
50
  'If multiple commits are backported, squash them into one',
48
51
  default: false
@@ -62,8 +65,8 @@ export function builder(yargs) {
62
65
  describe: 'Directory of an existing V8 clone'
63
66
  })
64
67
  .option('verbose', {
68
+ type: 'boolean',
65
69
  describe: 'Enable verbose output',
66
- boolean: true,
67
70
  default: false
68
71
  });
69
72
  }
package/lib/cache.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs';
3
- import { fileURLToPath } from 'node:url';
3
+ import os from 'node:os';
4
4
 
5
5
  import { writeJson, readJson, writeFile, readFile } from './file.js';
6
6
 
@@ -8,17 +8,15 @@ function isAsync(fn) {
8
8
  return fn[Symbol.toStringTag] === 'AsyncFunction';
9
9
  }
10
10
 
11
- const parentDir = fileURLToPath(new URL('..', import.meta.url));
12
-
13
11
  export default class Cache {
14
12
  constructor(dir) {
15
- this.dir = dir || this.computeCacheDir(parentDir);
13
+ this.dir = dir || this.computeCacheDir(os.tmpdir());
16
14
  this.originals = {};
17
15
  this.disabled = true;
18
16
  }
19
17
 
20
18
  computeCacheDir(base) {
21
- return path.join(base, '.ncu', 'cache');
19
+ return path.join(base, 'ncu', 'cache');
22
20
  }
23
21
 
24
22
  disable() {
package/lib/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import ora from 'ora';
2
2
  import chalk from 'chalk';
3
- import inquirer from 'inquirer';
3
+ import * as inquirer from '@inquirer/prompts';
4
4
 
5
5
  import { warning, error, info, success } from './figures.js';
6
6
 
@@ -81,12 +81,10 @@ export default class CLI {
81
81
  return defaultAnswer;
82
82
  }
83
83
 
84
- const { answer } = await inquirer.prompt([{
85
- type: questionType,
86
- name: 'answer',
84
+ const answer = await inquirer[questionType]({
87
85
  message: question,
88
86
  default: defaultAnswer
89
- }]);
87
+ });
90
88
 
91
89
  if (isSpinning) {
92
90
  this.spinner.start(spinningMessage);
@@ -35,7 +35,16 @@ export default class GitHubTree {
35
35
  branch,
36
36
  path
37
37
  });
38
- return data.repository.ref.target.history.nodes[0].oid;
38
+
39
+ const targetHistoryNodes = data.repository.ref.target.history.nodes;
40
+ if (!targetHistoryNodes.length) {
41
+ this.cli.stopSpinner(
42
+ `Cannot find commit for "${path}". Please check the path name.`,
43
+ this.cli.SPINNER_STATUS.FAILED
44
+ );
45
+ throw new Error(`Cannot find commit for "${path}"`);
46
+ }
47
+ return targetHistoryNodes[0].oid;
39
48
  }
40
49
 
41
50
  /**
package/lib/pr_checker.js CHANGED
@@ -29,7 +29,6 @@ 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'];
33
32
 
34
33
  // eslint-disable-next-line no-extend-native
35
34
  Array.prototype.findLastIndex ??= function findLastIndex(fn) {
@@ -374,9 +373,10 @@ export default class PRChecker {
374
373
 
375
374
  // GitHub new Check API
376
375
  for (const { status, conclusion, app } of checkSuites.nodes) {
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.
376
+ if (app.slug !== 'github-actions') {
377
+ // Ignore all non-github check suites, such as Dependabot and Codecov.
378
+ // They are expected to show up on PRs whose head branch is not on a
379
+ // fork and never complete.
380
380
  continue;
381
381
  }
382
382
 
@@ -25,6 +25,7 @@ export default class ReleasePreparation extends Session {
25
25
  this.isLTS = false;
26
26
  this.isLTSTransition = argv.startLTS;
27
27
  this.runBranchDiff = !argv.skipBranchDiff;
28
+ this.defaultReleaseDate = argv.releaseDate ?? new Date().toISOString().slice(0, 10);
28
29
  this.ltsCodename = '';
29
30
  this.date = '';
30
31
  this.filterLabels = argv.filterLabel && argv.filterLabel.split(',');
@@ -241,9 +242,8 @@ export default class ReleasePreparation extends Session {
241
242
  cli.stopSpinner('Updated REPLACEME items in docs');
242
243
 
243
244
  // Fetch date to use in release commit & changelogs.
244
- const todayDate = new Date().toISOString().split('T')[0];
245
245
  this.date = await cli.prompt('Enter release date in YYYY-MM-DD format:',
246
- { questionType: 'input', defaultAnswer: todayDate });
246
+ { questionType: 'input', defaultAnswer: this.defaultReleaseDate });
247
247
 
248
248
  cli.startSpinner('Updating CHANGELOG.md');
249
249
  await this.updateMainChangelog();
@@ -253,9 +253,6 @@ export default class ReleasePreparation extends Session {
253
253
  await this.updateMajorChangelog();
254
254
  cli.stopSpinner(`Updated CHANGELOG_V${versionComponents.major}.md`);
255
255
 
256
- await cli.prompt('Finished editing the changelogs?',
257
- { defaultAnswer: false });
258
-
259
256
  // Create release commit.
260
257
  const shouldCreateReleaseCommit = await cli.prompt(
261
258
  'Create release commit?');
@@ -272,9 +269,7 @@ export default class ReleasePreparation extends Session {
272
269
  cli.warn(`Please manually edit commit ${lastCommitSha} by running ` +
273
270
  '`git commit --amend` before proceeding.');
274
271
 
275
- await cli.prompt(
276
- 'Finished editing the release commit?',
277
- { defaultAnswer: false });
272
+ await cli.prompt('Finished editing the release commit?');
278
273
  }
279
274
 
280
275
  cli.separator();
@@ -625,8 +620,7 @@ export default class ReleasePreparation extends Session {
625
620
  ]);
626
621
 
627
622
  cli.log(`${messageTitle}\n\n${messageBody.join('')}`);
628
- const useMessage = await cli.prompt(
629
- 'Continue with this commit message?', { defaultAnswer: false });
623
+ const useMessage = await cli.prompt('Continue with this commit message?');
630
624
  return useMessage;
631
625
  }
632
626
 
package/lib/request.js CHANGED
@@ -158,7 +158,13 @@ export default class Request {
158
158
  Accept: 'application/json'
159
159
  }
160
160
  };
161
- return this.json(url, options);
161
+ const data = await this.json(url, options);
162
+ if (data?.errors) {
163
+ throw new Error(
164
+ `Request to fetch triaged reports failed with: ${JSON.stringify(data.errors)}`
165
+ );
166
+ }
167
+ return data;
162
168
  }
163
169
 
164
170
  async getPrograms() {
@@ -3,7 +3,7 @@ import {
3
3
  promises as fs
4
4
  } from 'node:fs';
5
5
 
6
- import inquirer from 'inquirer';
6
+ import { confirm } from '@inquirer/prompts';
7
7
  import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer';
8
8
 
9
9
  import { shortSha } from '../utils.js';
@@ -12,14 +12,12 @@ import { getCurrentV8Version } from './common.js';
12
12
 
13
13
  export async function checkOptions(options) {
14
14
  if (options.sha.length > 1 && options.squash) {
15
- const { wantSquash } = await inquirer.prompt([{
16
- type: 'confirm',
17
- name: 'wantSquash',
15
+ const wantSquash = await confirm({
18
16
  message: 'Squashing commits should be avoided if possible, because it ' +
19
17
  'can make git bisection difficult. Only squash commits if they would ' +
20
18
  'break the build when applied individually. Are you sure?',
21
19
  default: false
22
- }]);
20
+ });
23
21
 
24
22
  if (!wantSquash) {
25
23
  return true;
@@ -1,4 +1,3 @@
1
- import { spawn } from 'node:child_process';
2
1
  import path from 'node:path';
3
2
  import { promises as fs } from 'node:fs';
4
3
 
@@ -61,30 +60,22 @@ function doMinorUpdate() {
61
60
  }
62
61
 
63
62
  async function applyPatch(ctx, latestStr) {
64
- const diff = spawn(
63
+ const diff = await forceRunAsync(
65
64
  'git',
66
65
  ['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`],
67
- { cwd: ctx.v8Dir, stdio: ['ignore', 'pipe', 'ignore'] }
66
+ { captureStdout: true, ignoreFailure: false, spawnArgs: { cwd: ctx.v8Dir } }
68
67
  );
69
68
  try {
70
69
  await forceRunAsync('git', ['apply', '--directory', 'deps/v8'], {
70
+ input: diff,
71
71
  ignoreFailure: false,
72
- spawnArgs: {
73
- cwd: ctx.nodeDir,
74
- stdio: [diff.stdout, 'ignore', 'ignore']
75
- }
72
+ spawnArgs: { cwd: ctx.nodeDir }
76
73
  });
77
74
  } catch (e) {
78
75
  const file = path.join(ctx.nodeDir, `${latestStr}.diff`);
79
76
  await fs.writeFile(file, diff);
80
77
  throw new Error(`Could not apply patch.\n${e}\nDiff was stored in ${file}`);
81
78
  }
82
- if (diff.exitCode !== 0) {
83
- const err = new Error(`git format-patch failed: ${diff.exitCode}`);
84
- err.code = diff.exitCode;
85
- err.messageOnly = true;
86
- throw err;
87
- }
88
79
  }
89
80
 
90
81
  function filterAndSortTags(tags) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-core/utils",
3
- "version": "5.5.0",
3
+ "version": "5.6.0",
4
4
  "description": "Utilities for Node.js core collaborators",
5
5
  "type": "module",
6
6
  "engines": {
@@ -34,36 +34,36 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@listr2/prompt-adapter-enquirer": "^2.0.10",
37
+ "@inquirer/prompts": "^6.0.1",
38
+ "@listr2/prompt-adapter-enquirer": "^2.0.11",
38
39
  "@node-core/caritat": "^1.6.0",
39
40
  "@pkgjs/nv": "^0.2.2",
40
- "branch-diff": "^3.0.4",
41
+ "branch-diff": "^3.1.1",
41
42
  "chalk": "^5.3.0",
42
43
  "changelog-maker": "^4.1.1",
43
- "cheerio": "^1.0.0-rc.12",
44
+ "cheerio": "^1.0.0",
44
45
  "clipboardy": "^4.0.0",
45
- "core-validate-commit": "^4.0.0",
46
+ "core-validate-commit": "^4.1.0",
46
47
  "figures": "^6.1.0",
47
- "ghauth": "^6.0.5",
48
- "inquirer": "^9.3.2",
48
+ "ghauth": "^6.0.7",
49
49
  "js-yaml": "^4.1.0",
50
- "listr2": "^8.2.3",
50
+ "listr2": "^8.2.4",
51
51
  "lodash": "^4.17.21",
52
- "log-symbols": "^6.0.0",
53
- "ora": "^8.0.1",
54
- "replace-in-file": "^8.0.2",
55
- "undici": "^6.19.2",
52
+ "log-symbols": "^7.0.0",
53
+ "ora": "^8.1.0",
54
+ "replace-in-file": "^8.2.0",
55
+ "undici": "^6.19.8",
56
56
  "which": "^4.0.0",
57
57
  "yargs": "^17.7.2"
58
58
  },
59
59
  "devDependencies": {
60
- "@reporters/github": "^1.7.0",
60
+ "@reporters/github": "^1.7.1",
61
61
  "c8": "^10.1.2",
62
- "eslint": "^8.57.0",
62
+ "eslint": "^8.57.1",
63
63
  "eslint-config-standard": "^17.1.0",
64
- "eslint-plugin-import": "^2.29.1",
64
+ "eslint-plugin-import": "^2.30.0",
65
65
  "eslint-plugin-n": "^16.6.2",
66
- "eslint-plugin-promise": "^6.4.0",
67
- "sinon": "^18.0.0"
66
+ "eslint-plugin-promise": "^6.6.0",
67
+ "sinon": "^19.0.2"
68
68
  }
69
69
  }