@samitouri / QOS-React-2 / commits / 07e58658c9

Add script to generate DevTools changelog text (#22077)

Brian Vaughn committed Aug 12, 2021 at 10:43 UTC 07e58658c9bb182eab436c5fe9e1e66078ea0b19
2 files changed +67
package.json
+1
@@ -116,6 +116,7 @@
116 "extract-errors": "yarn build --type=dev --extract-errors",
117 "postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json && node ./scripts/flow/createFlowConfigs.js && node ./scripts/yarn/downloadReactIsForPrettyFormat.js",
118 "debug-test": "yarn test --deprecated 'yarn test --debug'",
119 + "generate-devtools-changelog": "node packages/react-devtools/get-commit-list.js",
120 "test": "node ./scripts/jest/jest-cli.js",
121 "test-stable": "node ./scripts/jest/jest-cli.js --release-channel=stable",
122 "test-www": "node ./scripts/jest/jest-cli.js --release-channel=www-modern",
packages/react-devtools/get-commit-list.js new
+66
@@ -0,0 +1,66 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +const {execSync} = require('child_process');
9 +const readline = require('readline');
10 +
11 +const PULL_REQUEST_BASE_URL = 'https://github.com/facebook/react/pull/';
12 +
13 +const hashes = [];
14 +const lines = execSync(`
15 + git log --max-count=5 --topo-order --pretty=format:'%H:::%s:::%as' HEAD -- packages/react-devtools-core/package.json
16 +`)
17 + .toString()
18 + .trim()
19 + .split('\n');
20 +lines.forEach((line, index) => {
21 + const [hash, message, date] = line.split(':::');
22 + hashes.push(hash);
23 + console.log(
24 + `\x1b[1m(${index + 1})\x1b[0m ${message} \x1b[2m(${date})\x1b[0m`,
25 + );
26 +});
27 +
28 +const prompt = readline.createInterface({
29 + input: process.stdin,
30 + output: process.stdout,
31 +});
32 +prompt.question(
33 + '\n' +
34 + '\x1b[1m' +
35 + 'Which of the commits above marks the last DevTools release?' +
36 + '\x1b[0m ',
37 + numberString => {
38 + const hashIndex = parseInt(numberString, 10) - 1;
39 + const hash = hashes[hashIndex];
40 +
41 + let formattedLog = '';
42 +
43 + const rawLog = execSync(`
44 + git log --topo-order --pretty=format:'%s' ${hash}...HEAD -- packages/react-devtools*
45 + `)
46 + .toString()
47 + .trim();
48 + rawLog.split('\n').forEach(line => {
49 + line = line.replace('[DevTools] ', '');
50 +
51 + const match = line.match(/(.+) \(#([0-9]+)\)/);
52 + if (match !== null) {
53 + const title = match[1];
54 + const pr = match[2];
55 +
56 + formattedLog += `\n* ${title} \x1b[31m([USERNAME](https://github.com/USERNAME)\x1b[0m in [#${pr}](\x1b[4m\x1b[34m${PULL_REQUEST_BASE_URL}${pr}\x1b[0m))`;
57 + } else {
58 + formattedLog += `\n* ${line}`;
59 + }
60 + });
61 +
62 + console.log(formattedLog);
63 +
64 + prompt.close();
65 + },
66 +);