Show FB-internal announcements only in internal changelog (#1544)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1544 Added Facebook changelog file Reviewed By: nikoant Differential Revision: D23930322 fbshipit-source-id: bb6be359d36188f142d342604e50010170086610
This commit is contained in:
committed by
Facebook GitHub Bot
parent
95ae7a8bce
commit
5e979403a0
@@ -12,7 +12,7 @@ import {readFileSync} from 'fs';
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {reportUsage} from '../utils/metrics';
|
import {reportUsage} from '../utils/metrics';
|
||||||
import {getStaticPath} from '../utils/pathUtils';
|
import {getChangelogPath} from '../utils/pathUtils';
|
||||||
|
|
||||||
const changelogKey = 'FlipperChangelogStatus';
|
const changelogKey = 'FlipperChangelogStatus';
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ type ChangelogStatus = {
|
|||||||
|
|
||||||
let getChangelogFromDisk = (): string => {
|
let getChangelogFromDisk = (): string => {
|
||||||
const changelogFromDisk: string = readFileSync(
|
const changelogFromDisk: string = readFileSync(
|
||||||
path.join(getStaticPath(), 'CHANGELOG.md'),
|
path.join(getChangelogPath(), 'CHANGELOG.md'),
|
||||||
'utf8',
|
'utf8',
|
||||||
).trim();
|
).trim();
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {remote} from 'electron';
|
import {remote} from 'electron';
|
||||||
|
import config from '../fb-stubs/config';
|
||||||
|
|
||||||
let _staticPath = '';
|
let _staticPath = '';
|
||||||
|
|
||||||
@@ -29,3 +30,23 @@ export function getStaticPath() {
|
|||||||
}
|
}
|
||||||
return _staticPath;
|
return _staticPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getChangelogPath() {
|
||||||
|
const staticPath = getStaticPath();
|
||||||
|
let changelogPath = '';
|
||||||
|
|
||||||
|
if (config.isFBBuild) {
|
||||||
|
changelogPath = path.resolve(staticPath, 'facebook');
|
||||||
|
} else {
|
||||||
|
changelogPath = staticPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync(changelogPath)) {
|
||||||
|
return changelogPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs.existsSync(changelogPath)) {
|
||||||
|
throw new Error('Changelog path path does not exist: ' + changelogPath);
|
||||||
|
}
|
||||||
|
return changelogPath;
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const cp = require('child_process');
|
|||||||
const desktopRoot = path.resolve(__dirname, '..');
|
const desktopRoot = path.resolve(__dirname, '..');
|
||||||
const root = path.resolve(desktopRoot, '..');
|
const root = path.resolve(desktopRoot, '..');
|
||||||
const staticDir = path.join(desktopRoot, 'static');
|
const staticDir = path.join(desktopRoot, 'static');
|
||||||
|
const staticFacebookDir = path.join(staticDir, 'facebook');
|
||||||
|
|
||||||
const version = JSON.parse(
|
const version = JSON.parse(
|
||||||
fs.readFileSync(path.join(desktopRoot, 'package.json'), 'utf8'),
|
fs.readFileSync(path.join(desktopRoot, 'package.json'), 'utf8'),
|
||||||
@@ -29,6 +30,7 @@ const now = new Date();
|
|||||||
const date = `${now.getDate()}/${now.getMonth() + 1}/${now.getFullYear()}`;
|
const date = `${now.getDate()}/${now.getMonth() + 1}/${now.getFullYear()}`;
|
||||||
const newlineMarker = '__NEWLINE_MARKER__';
|
const newlineMarker = '__NEWLINE_MARKER__';
|
||||||
const fChangelog = path.resolve(staticDir, 'CHANGELOG.md');
|
const fChangelog = path.resolve(staticDir, 'CHANGELOG.md');
|
||||||
|
const fChangelogFacebook = path.resolve(staticFacebookDir, 'CHANGELOG.md');
|
||||||
|
|
||||||
const lastCommit = cp
|
const lastCommit = cp
|
||||||
.execSync(`hg log --limit 1 --template '{node}'`, {cwd: root})
|
.execSync(`hg log --limit 1 --template '{node}'`, {cwd: root})
|
||||||
@@ -50,8 +52,10 @@ const hgLog = cp.execSync(hgLogCommand, {cwd: __dirname}).toString();
|
|||||||
|
|
||||||
const diffRe = /^D\d+/;
|
const diffRe = /^D\d+/;
|
||||||
const changeLogLineRe = /(^changelog:\s*?)(.*?)$/i;
|
const changeLogLineRe = /(^changelog:\s*?)(.*?)$/i;
|
||||||
|
const changeLogFacebookLineRe = /(^Facebook changelog:\s*?)(.*?)$/i;
|
||||||
|
|
||||||
let contents = `# ${version} (${date})\n\n`;
|
let contents = `# ${version} (${date})\n\n`;
|
||||||
|
let contentsFacebook = `# ${version} (${date})\n\n`;
|
||||||
let changes = 0;
|
let changes = 0;
|
||||||
|
|
||||||
hgLog
|
hgLog
|
||||||
@@ -64,9 +68,14 @@ hgLog
|
|||||||
line.split(newlineMarker).forEach(diffline => {
|
line.split(newlineMarker).forEach(diffline => {
|
||||||
// if a line starts with changelog:, grab the rest of the text and add it to the changelog
|
// if a line starts with changelog:, grab the rest of the text and add it to the changelog
|
||||||
const match = diffline.match(changeLogLineRe);
|
const match = diffline.match(changeLogLineRe);
|
||||||
if (match) {
|
const matchFacebook = diffline.match(changeLogFacebookLineRe);
|
||||||
|
if (matchFacebook) {
|
||||||
|
changes++;
|
||||||
|
contentsFacebook += ` * [${diff}](https://github.com/facebook/flipper/search?q=${diff}&type=Commits) - ${matchFacebook[2]}\n`;
|
||||||
|
} else if (match) {
|
||||||
changes++;
|
changes++;
|
||||||
contents += ` * [${diff}](https://github.com/facebook/flipper/search?q=${diff}&type=Commits) - ${match[2]}\n`;
|
contents += ` * [${diff}](https://github.com/facebook/flipper/search?q=${diff}&type=Commits) - ${match[2]}\n`;
|
||||||
|
contentsFacebook += ` * [${diff}](https://github.com/facebook/flipper/search?q=${diff}&type=Commits) - ${match[2]}\n`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -75,5 +84,7 @@ if (!changes) {
|
|||||||
console.log('No diffs with changelog items found in this release');
|
console.log('No diffs with changelog items found in this release');
|
||||||
} else {
|
} else {
|
||||||
contents += '\n\n' + fs.readFileSync(fChangelog, 'utf8');
|
contents += '\n\n' + fs.readFileSync(fChangelog, 'utf8');
|
||||||
|
contentsFacebook += '\n\n' + fs.readFileSync(fChangelogFacebook, 'utf8');
|
||||||
fs.writeFileSync(fChangelog, contents);
|
fs.writeFileSync(fChangelog, contents);
|
||||||
|
fs.writeFileSync(fChangelogFacebook, contentsFacebook);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user