@node-core/utils 5.5.0 → 5.5.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 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,
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() {
@@ -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
 
@@ -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.5.1",
4
4
  "description": "Utilities for Node.js core collaborators",
5
5
  "type": "module",
6
6
  "engines": {