@node-core/utils 5.16.1 → 6.0.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/README.md +34 -26
- package/bin/ncu-config.js +24 -5
- package/components/git/v8.js +22 -2
- package/lib/auth.js +63 -40
- package/lib/config.js +77 -12
- package/lib/landing_session.js +2 -2
- package/lib/pr_checker.js +18 -18
- package/lib/promote_release.js +39 -24
- package/lib/session.js +19 -7
- package/lib/update-v8/deps.js +88 -0
- package/lib/update-v8/index.js +9 -0
- package/lib/update-v8/majorUpdate.js +1 -68
- package/lib/update-v8/util.js +7 -2
- package/lib/verbosity.js +3 -0
- package/lib/voting_session.js +0 -1
- package/npm-shrinkwrap.json +11696 -0
- package/package.json +9 -8
package/lib/session.js
CHANGED
|
@@ -19,7 +19,7 @@ export default class Session {
|
|
|
19
19
|
this.cli = cli;
|
|
20
20
|
this.dir = dir;
|
|
21
21
|
this.prid = prid;
|
|
22
|
-
this.config =
|
|
22
|
+
this.config = getMergedConfig(this.dir, undefined, argv);
|
|
23
23
|
this.gpgSign = argv?.['gpg-sign']
|
|
24
24
|
? (argv['gpg-sign'] === true ? ['-S'] : ['-S', argv['gpg-sign']])
|
|
25
25
|
: [];
|
|
@@ -126,7 +126,12 @@ export default class Session {
|
|
|
126
126
|
writeJson(this.sessionPath, {
|
|
127
127
|
state: STARTED,
|
|
128
128
|
prid: this.prid,
|
|
129
|
-
|
|
129
|
+
// Filter out getters, those are likely encrypted data we don't need on the session.
|
|
130
|
+
config: Object.entries(Object.getOwnPropertyDescriptors(this.config))
|
|
131
|
+
.reduce((pv, [key, desc]) => {
|
|
132
|
+
if (Object.hasOwn(desc, 'value')) pv[key] = desc.value;
|
|
133
|
+
return pv;
|
|
134
|
+
}, { __proto__: null }),
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
|
|
@@ -382,12 +387,19 @@ export default class Session {
|
|
|
382
387
|
cli.setExitCode(1);
|
|
383
388
|
}
|
|
384
389
|
if (!upstream) {
|
|
385
|
-
cli.warn('You have not told git-node
|
|
390
|
+
cli.warn('You have not told git-node what remote name you are trying to land commits on.');
|
|
386
391
|
cli.separator();
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
392
|
+
const remoteName = runSync('git', ['remote', '-v'])
|
|
393
|
+
.match(/^(\S+)\s+(?:https:\/\/github\.com\/|git@github\.com:)nodejs\/node\.git \(\S+\)\r?$/m)?.[1];
|
|
394
|
+
cli.info(remoteName
|
|
395
|
+
? `You likely want to run the following:\n\n $ ncu-config set upstream ${remoteName}`
|
|
396
|
+
: 'The expected repository does not seem to appear in your local config.\n' +
|
|
397
|
+
'1. First, add the Node.js core repository as a remote:\n' +
|
|
398
|
+
' $ git remote add upstream https://github.com/nodejs/node.git\n\n' +
|
|
399
|
+
'2. Then, tell git-node to use this remote for syncing:\n' +
|
|
400
|
+
' $ ncu-config set upstream upstream\n\n' +
|
|
401
|
+
'Note: Using "upstream" is recommended, but you can use any remote name.\n' +
|
|
402
|
+
'For security reasons, you need to add the remote manually.');
|
|
391
403
|
cli.separator();
|
|
392
404
|
cli.setExitCode(1);
|
|
393
405
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
import { chromiumGit, v8Deps } from './constants.js';
|
|
5
|
+
import { forceRunAsync } from '../run.js';
|
|
6
|
+
import {
|
|
7
|
+
addToGitignore,
|
|
8
|
+
filterForVersion,
|
|
9
|
+
getNodeV8Version,
|
|
10
|
+
removeDirectory,
|
|
11
|
+
replaceGitignore,
|
|
12
|
+
} from './util.js';
|
|
13
|
+
|
|
14
|
+
async function fetchFromGit(cwd, repo, commit) {
|
|
15
|
+
await removeDirectory(cwd);
|
|
16
|
+
await fs.mkdir(cwd, { recursive: true });
|
|
17
|
+
await exec('init');
|
|
18
|
+
await exec('remote', 'add', 'origin', repo);
|
|
19
|
+
await exec('fetch', 'origin', commit);
|
|
20
|
+
await exec('reset', '--hard', 'FETCH_HEAD');
|
|
21
|
+
await removeDirectory(path.join(cwd, '.git'));
|
|
22
|
+
|
|
23
|
+
function exec(...options) {
|
|
24
|
+
return forceRunAsync('git', options, {
|
|
25
|
+
ignoreFailure: false,
|
|
26
|
+
spawnArgs: { cwd, stdio: 'ignore' }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function readDeps(nodeDir) {
|
|
32
|
+
const depsStr = await fs.readFile(path.join(nodeDir, 'deps/v8/DEPS'), 'utf8');
|
|
33
|
+
const start = depsStr.indexOf('deps = {');
|
|
34
|
+
const end = depsStr.indexOf('\n}', start) + 2;
|
|
35
|
+
const depsDeclaration = depsStr.substring(start, end).replace(/^ *#.*/gm, '');
|
|
36
|
+
const Var = () => chromiumGit; // eslint-disable-line no-unused-vars
|
|
37
|
+
let deps;
|
|
38
|
+
eval(depsDeclaration); // eslint-disable-line no-eval
|
|
39
|
+
return deps;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function lookupDep(depsTable, depName) {
|
|
43
|
+
const dep = depsTable[depName];
|
|
44
|
+
if (!dep) {
|
|
45
|
+
throw new Error(`V8 dep "${depName}" not found in DEPS file`);
|
|
46
|
+
}
|
|
47
|
+
if (typeof dep === 'object') {
|
|
48
|
+
return dep.url.split('@');
|
|
49
|
+
}
|
|
50
|
+
return dep.split('@');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function updateV8Deps() {
|
|
54
|
+
return {
|
|
55
|
+
title: 'Update V8 DEPS',
|
|
56
|
+
task: async(ctx, task) => {
|
|
57
|
+
const newV8Version = await getNodeV8Version(ctx.nodeDir);
|
|
58
|
+
const repoPrefix = newV8Version.majorMinor >= 86 ? '' : 'v8/';
|
|
59
|
+
const deps = filterForVersion(v8Deps.map((v8Dep) => ({
|
|
60
|
+
...v8Dep,
|
|
61
|
+
repo: `${repoPrefix}${v8Dep.repo}`,
|
|
62
|
+
path: v8Dep.repo
|
|
63
|
+
})), newV8Version);
|
|
64
|
+
if (deps.length === 0) return;
|
|
65
|
+
const depsTable = await readDeps(ctx.nodeDir);
|
|
66
|
+
const subtasks = [];
|
|
67
|
+
for (const dep of deps) {
|
|
68
|
+
// Update .gitignore sequentially to avoid races
|
|
69
|
+
if (dep.gitignore) {
|
|
70
|
+
if (typeof dep.gitignore === 'string') {
|
|
71
|
+
await addToGitignore(ctx.nodeDir, dep.gitignore);
|
|
72
|
+
} else {
|
|
73
|
+
await replaceGitignore(ctx.nodeDir, dep.gitignore);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
subtasks.push({
|
|
77
|
+
title: `Update ${dep.path}`,
|
|
78
|
+
task: async(ctx) => {
|
|
79
|
+
const [repo, commit] = await lookupDep(depsTable, dep.repo);
|
|
80
|
+
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.path);
|
|
81
|
+
await fetchFromGit(thePath, repo, commit);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return task.newListr(subtasks, { concurrent: ctx.concurrent });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
package/lib/update-v8/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import updateVersionNumbers from './updateVersionNumbers.js';
|
|
|
5
5
|
import commitUpdate from './commitUpdate.js';
|
|
6
6
|
import majorUpdate from './majorUpdate.js';
|
|
7
7
|
import minorUpdate from './minorUpdate.js';
|
|
8
|
+
import updateDeps from './deps.js';
|
|
8
9
|
import updateV8Clone from './updateV8Clone.js';
|
|
9
10
|
|
|
10
11
|
export function major(options) {
|
|
@@ -34,6 +35,14 @@ export async function backport(options) {
|
|
|
34
35
|
return tasks.run(options);
|
|
35
36
|
};
|
|
36
37
|
|
|
38
|
+
export async function deps(options) {
|
|
39
|
+
const tasks = new Listr(
|
|
40
|
+
[updateDeps()],
|
|
41
|
+
getOptions(options)
|
|
42
|
+
);
|
|
43
|
+
return tasks.run(options);
|
|
44
|
+
};
|
|
45
|
+
|
|
37
46
|
/**
|
|
38
47
|
* Get the listr2 options.
|
|
39
48
|
* @param {{ verbose?: boolean }} options The original options.
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { promises as fs } from 'node:fs';
|
|
3
2
|
|
|
4
3
|
import { getCurrentV8Version } from './common.js';
|
|
4
|
+
import updateV8Deps from './deps.js';
|
|
5
5
|
import {
|
|
6
|
-
getNodeV8Version,
|
|
7
|
-
filterForVersion,
|
|
8
|
-
addToGitignore,
|
|
9
|
-
replaceGitignore,
|
|
10
6
|
removeDirectory,
|
|
11
7
|
isVersionString
|
|
12
8
|
} from './util.js';
|
|
13
9
|
import applyNodeChanges from './applyNodeChanges.js';
|
|
14
|
-
import { chromiumGit, v8Deps } from './constants.js';
|
|
15
10
|
import { forceRunAsync } from '../run.js';
|
|
16
11
|
|
|
17
12
|
export default function majorUpdate() {
|
|
@@ -106,65 +101,3 @@ function addDepsV8() {
|
|
|
106
101
|
})
|
|
107
102
|
};
|
|
108
103
|
}
|
|
109
|
-
|
|
110
|
-
function updateV8Deps() {
|
|
111
|
-
return {
|
|
112
|
-
title: 'Update V8 DEPS',
|
|
113
|
-
task: async(ctx) => {
|
|
114
|
-
const newV8Version = await getNodeV8Version(ctx.nodeDir);
|
|
115
|
-
const repoPrefix = newV8Version.majorMinor >= 86 ? '' : 'v8/';
|
|
116
|
-
const deps = filterForVersion(v8Deps.map((v8Dep) => ({
|
|
117
|
-
...v8Dep,
|
|
118
|
-
repo: `${repoPrefix}${v8Dep.repo}`,
|
|
119
|
-
path: v8Dep.repo
|
|
120
|
-
})), newV8Version);
|
|
121
|
-
if (deps.length === 0) return;
|
|
122
|
-
for (const dep of deps) {
|
|
123
|
-
if (dep.gitignore) {
|
|
124
|
-
if (typeof dep.gitignore === 'string') {
|
|
125
|
-
await addToGitignore(ctx.nodeDir, dep.gitignore);
|
|
126
|
-
} else {
|
|
127
|
-
await replaceGitignore(ctx.nodeDir, dep.gitignore);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const [repo, commit] = await readDeps(ctx.nodeDir, dep.repo);
|
|
131
|
-
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.path);
|
|
132
|
-
await fetchFromGit(thePath, repo, commit);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function readDeps(nodeDir, depName) {
|
|
139
|
-
const depsStr = await fs.readFile(path.join(nodeDir, 'deps/v8/DEPS'), 'utf8');
|
|
140
|
-
const start = depsStr.indexOf('deps = {');
|
|
141
|
-
const end = depsStr.indexOf('\n}', start) + 2;
|
|
142
|
-
const depsDeclaration = depsStr.substring(start, end).replace(/^ *#.*/gm, '');
|
|
143
|
-
const Var = () => chromiumGit; // eslint-disable-line no-unused-vars
|
|
144
|
-
let deps;
|
|
145
|
-
eval(depsDeclaration); // eslint-disable-line no-eval
|
|
146
|
-
const dep = deps[depName];
|
|
147
|
-
if (!dep) {
|
|
148
|
-
throw new Error(`V8 dep "${depName}" not found in DEPS file`);
|
|
149
|
-
}
|
|
150
|
-
if (typeof dep === 'object') {
|
|
151
|
-
return dep.url.split('@');
|
|
152
|
-
}
|
|
153
|
-
return dep.split('@');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async function fetchFromGit(cwd, repo, commit) {
|
|
157
|
-
await fs.mkdir(cwd, { recursive: true });
|
|
158
|
-
await exec('init');
|
|
159
|
-
await exec('remote', 'add', 'origin', repo);
|
|
160
|
-
await exec('fetch', 'origin', commit);
|
|
161
|
-
await exec('reset', '--hard', 'FETCH_HEAD');
|
|
162
|
-
await removeDirectory(path.join(cwd, '.git'));
|
|
163
|
-
|
|
164
|
-
function exec(...options) {
|
|
165
|
-
return forceRunAsync('git', options, {
|
|
166
|
-
ignoreFailure: false,
|
|
167
|
-
spawnArgs: { cwd, stdio: 'ignore' }
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
package/lib/update-v8/util.js
CHANGED
|
@@ -37,13 +37,18 @@ export function filterForVersion(list, version) {
|
|
|
37
37
|
|
|
38
38
|
export async function addToGitignore(nodeDir, value) {
|
|
39
39
|
const gitignorePath = path.join(nodeDir, 'deps/v8/.gitignore');
|
|
40
|
-
await fs.
|
|
40
|
+
const gitignore = await fs.readFile(gitignorePath, 'utf8');
|
|
41
|
+
if (!gitignore.includes(value)) {
|
|
42
|
+
await fs.appendFile(gitignorePath, `${value}\n`);
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export async function replaceGitignore(nodeDir, options) {
|
|
44
47
|
const gitignorePath = path.join(nodeDir, 'deps/v8/.gitignore');
|
|
45
48
|
let gitignore = await fs.readFile(gitignorePath, 'utf8');
|
|
46
|
-
|
|
49
|
+
if (!gitignore.includes(options.replace)) {
|
|
50
|
+
gitignore = gitignore.replace(options.match, options.replace);
|
|
51
|
+
}
|
|
47
52
|
await fs.writeFile(gitignorePath, gitignore);
|
|
48
53
|
}
|
|
49
54
|
|
package/lib/verbosity.js
CHANGED