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. 3
      .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
dist
**/*.d.ts
# Scripts
scripts/previewEditor/**/*

3
.gitignore

@ -54,4 +54,5 @@ site/theme/template/Content/Article.jsx
site/theme/template/Content/EditButton.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-tinker": "^0.5.0",
"fetch-jsonp": "^1.1.3",
"fs-extra": "^9.0.0",
"full-icu": "^1.3.0",
"glob": "^7.1.4",
"http-server": "^0.12.0",
@ -210,6 +211,7 @@
"lz-string": "^1.4.4",
"mockdate": "^2.0.2",
"node-fetch": "^2.6.0",
"open": "^7.0.3",
"preact": "^10.0.0",
"preact-compat": "^3.18.5",
"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-console */
const chalk = require('chalk');
const { spawn } = require('child_process');
const jsdom = require('jsdom');
const jQuery = require('jquery');
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 { JSDOM } = jsdom;
@ -25,12 +29,11 @@ const toVersion = process.argv[process.argv.length - 1];
const cwd = process.cwd();
const git = simpleGit(cwd);
function getDescription(row = '') {
return row
.trim()
.replace('🇺🇸 English', '')
.replace('🇨🇳 Chinese', '')
.trim();
function getDescription(entity) {
const descEle = entity.element.find('td:last');
let htmlContent = descEle.html();
htmlContent = htmlContent.replace(/<code>([^<]*)<\/code>/g, '`$1`');
return htmlContent.trim();
}
async function printLog() {
@ -74,27 +77,20 @@ async function printLog() {
const $html = $(html);
const prTitle = $html
.find(QUERY_TITLE)
.text()
.trim();
const prAuthor = $html
.find(QUERY_AUTHOR)
.text()
.trim();
const prTitle = $html.find(QUERY_TITLE).text().trim();
const prAuthor = $html.find(QUERY_AUTHOR).text().trim();
const prLines = $html.find(QUERY_DESCRIPTION_LINES);
const lines = [];
prLines.each(function getDesc() {
lines.push(
$(this)
.text()
.trim(),
);
lines.push({
text: $(this).text().trim(),
element: $(this),
});
});
const english = getDescription(lines.find(line => line.includes('🇺🇸 English')));
const chinese = getDescription(lines.find(line => line.includes('🇨🇳 Chinese')));
const english = getDescription(lines.find(line => line.text.includes('🇺🇸 English')));
const chinese = getDescription(lines.find(line => line.text.includes('🇨🇳 Chinese')));
validatePRs.push({
pr,
@ -163,6 +159,29 @@ async function printLog() {
}
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();

Loading…
Cancel
Save