Browse Source

chore: add preview (#23128)

* chore: add preview

* update template

* update ignore lint

* update template

* support quota analysis

* comment it

* trigger build

* trigger build

* force trigger
pull/23149/head
二货机器人 5 years ago
committed by GitHub
parent
commit
ff30366d22
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .eslintignore
  2. 1
      .gitignore
  3. 2
      package.json
  4. 26
      scripts/previewEditor/template.html
  5. 13461
      scripts/previewEditor/umi.css
  6. 57114
      scripts/previewEditor/umi.js
  7. 61
      scripts/print-changelog.js

2
.eslintignore

@ -24,3 +24,5 @@ node_modules
_site _site
dist dist
**/*.d.ts **/*.d.ts
# Scripts
scripts/previewEditor/**/*

1
.gitignore

@ -55,3 +55,4 @@ site/theme/template/Content/EditButton.jsx
site/theme/template/Resources/*.jsx site/theme/template/Resources/*.jsx
site/theme/template/Resources/**/*.jsx site/theme/template/Resources/**/*.jsx
site/theme/template/NotFound.jsx site/theme/template/NotFound.jsx
scripts/previewEditor/index.html

2
package.json

@ -193,6 +193,7 @@
"eslint-plugin-unicorn": "^18.0.1", "eslint-plugin-unicorn": "^18.0.1",
"eslint-tinker": "^0.5.0", "eslint-tinker": "^0.5.0",
"fetch-jsonp": "^1.1.3", "fetch-jsonp": "^1.1.3",
"fs-extra": "^9.0.0",
"full-icu": "^1.3.0", "full-icu": "^1.3.0",
"glob": "^7.1.4", "glob": "^7.1.4",
"http-server": "^0.12.0", "http-server": "^0.12.0",
@ -210,6 +211,7 @@
"lz-string": "^1.4.4", "lz-string": "^1.4.4",
"mockdate": "^2.0.2", "mockdate": "^2.0.2",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"open": "^7.0.3",
"preact": "^10.0.0", "preact": "^10.0.0",
"preact-compat": "^3.18.5", "preact-compat": "^3.18.5",
"prettier": "^2.0.1", "prettier": "^2.0.1",

26
scripts/previewEditor/template.html

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<title>antd changelog</title>
<script>
// [Replacement]
</script>
<link rel="stylesheet" href="/umi.css" />
<script>
window.routerBase = '/';
</script>
<script>
//! umi version: 3.1.1
</script>
</head>
<body>
<div id="root"></div>
<script src="/umi.js"></script>
</body>
</html>

13461
scripts/previewEditor/umi.css

File diff suppressed because it is too large

57114
scripts/previewEditor/umi.js

File diff suppressed because it is too large

61
scripts/print-changelog.js

@ -1,9 +1,13 @@
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
/* eslint-disable no-console */ /* eslint-disable no-console */
const chalk = require('chalk'); const chalk = require('chalk');
const { spawn } = require('child_process');
const jsdom = require('jsdom'); const jsdom = require('jsdom');
const jQuery = require('jquery'); const jQuery = require('jquery');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const open = require('open');
const fs = require('fs-extra');
const path = require('path');
const simpleGit = require('simple-git/promise'); const simpleGit = require('simple-git/promise');
const { JSDOM } = jsdom; const { JSDOM } = jsdom;
@ -25,12 +29,11 @@ const toVersion = process.argv[process.argv.length - 1];
const cwd = process.cwd(); const cwd = process.cwd();
const git = simpleGit(cwd); const git = simpleGit(cwd);
function getDescription(row = '') { function getDescription(entity) {
return row const descEle = entity.element.find('td:last');
.trim() let htmlContent = descEle.html();
.replace('🇺🇸 English', '') htmlContent = htmlContent.replace(/<code>([^<]*)<\/code>/g, '`$1`');
.replace('🇨🇳 Chinese', '') return htmlContent.trim();
.trim();
} }
async function printLog() { async function printLog() {
@ -74,27 +77,20 @@ async function printLog() {
const $html = $(html); const $html = $(html);
const prTitle = $html const prTitle = $html.find(QUERY_TITLE).text().trim();
.find(QUERY_TITLE) const prAuthor = $html.find(QUERY_AUTHOR).text().trim();
.text()
.trim();
const prAuthor = $html
.find(QUERY_AUTHOR)
.text()
.trim();
const prLines = $html.find(QUERY_DESCRIPTION_LINES); const prLines = $html.find(QUERY_DESCRIPTION_LINES);
const lines = []; const lines = [];
prLines.each(function getDesc() { prLines.each(function getDesc() {
lines.push( lines.push({
$(this) text: $(this).text().trim(),
.text() element: $(this),
.trim(), });
);
}); });
const english = getDescription(lines.find(line => line.includes('🇺🇸 English'))); const english = getDescription(lines.find(line => line.text.includes('🇺🇸 English')));
const chinese = getDescription(lines.find(line => line.includes('🇨🇳 Chinese'))); const chinese = getDescription(lines.find(line => line.text.includes('🇨🇳 Chinese')));
validatePRs.push({ validatePRs.push({
pr, pr,
@ -163,6 +159,29 @@ async function printLog() {
} }
return `${english} `; return `${english} `;
}); });
// Preview editor generate
// Web source: https://github.com/ant-design/antd-changelog-editor
let html = fs.readFileSync(path.join(__dirname, 'previewEditor', 'template.html'), 'utf8');
html = html.replace('// [Replacement]', `window.changelog = ${JSON.stringify(prList)};`);
fs.writeFileSync(path.join(__dirname, 'previewEditor', 'index.html'), html, 'utf8');
// Start preview
const ls = spawn('npx', [
'http-server',
path.join(__dirname, 'previewEditor'),
'-c-1',
'-p',
'2893',
]);
ls.stdout.on('data', data => {
console.log(data.toString());
});
console.log(chalk.green('Start preview editor...'));
setTimeout(function openPreview() {
open('http://localhost:2893/');
}, 1000);
} }
printLog(); printLog();

Loading…
Cancel
Save