You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2019/12/31 20:07:43 UTC
[incubator-echarts-doc] branch release updated: enable build target
both echartsjs and asf
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-doc.git
The following commit(s) were added to refs/heads/release by this push:
new e5737cb enable build target both echartsjs and asf
e5737cb is described below
commit e5737cbc01b0a5e0c995d718b5d3f4e8ce67358b
Author: 100pah <su...@gmail.com>
AuthorDate: Wed Jan 1 04:07:26 2020 +0800
enable build target both echartsjs and asf
---
build.js | 222 ++++++++++++++++++++++++++++++++----------------
config/env.asf.js | 7 +-
config/env.dev.js | 7 +-
config/env.echartsjs.js | 7 +-
config/env.github.js | 10 ---
package.json | 1 +
release.sh | 29 +------
7 files changed, 172 insertions(+), 111 deletions(-)
diff --git a/build.js b/build.js
index 7f836b4..84440c0 100644
--- a/build.js
+++ b/build.js
@@ -17,8 +17,13 @@ const fs = require('fs');
const fse = require('fs-extra');
const marked = require('marked');
const copydir = require('copy-dir');
+const chalk = require('chalk');
// const MarkDownTOCRenderer = require('./tool/MarkDownTOCRenderer');
const argv = require('yargs').argv;
+const path = require('path');
+const assert = require('assert');
+
+const projectDir = __dirname;
function initEnv() {
let envType = argv.env;
@@ -35,7 +40,13 @@ function initEnv() {
throw new Error('--env MUST be specified');
}
- return require('./config/env.' + envType);
+ let config = require('./config/env.' + envType);
+
+ assert(path.isAbsolute(config.releaseDestDir) && path.isAbsolute(config.ecWWWGeneratedDir));
+
+ config.envType = envType;
+
+ return config;
}
const config = initEnv();
@@ -49,68 +60,59 @@ for (let key in config) {
}
}
-function run() {
- languages.forEach(function (language) {
- fse.ensureDirSync(`public/${language}/documents`);
- md2json(
- {
- path: language + '/option/**/*.md',
- sectionsAnyOf: ['visualMap', 'dataZoom', 'series', 'graphic.elements'],
- entry: 'option',
- tplEnv: config,
- imageRoot: config.imagePath
- },
- function (schema) {
- // Always print single option.html file for some third part usage (e.g., dataV).
- writeSingleSchema(schema, language, 'option', false);
- writeSingleSchemaPartioned(schema, language, 'option', false);
- }
- );
- md2json(
- {
- path: language + '/tutorial/**/*.md',
- entry: 'tutorial',
- tplEnv: config,
- maxDepth: 1,
- imageRoot: config.imagePath
- },
- function (schema) {
- writeSingleSchema(schema, language, 'tutorial');
- writeSingleSchemaPartioned(schema, language, 'tutorial', false);
- }
- );
- md2json(
- {
- path: language + '/api/**/*.md',
- entry: 'api',
- tplEnv: config,
- imageRoot: config.imagePath
- },
- function (schema) {
- writeSingleSchema(schema, language, 'api');
- writeSingleSchemaPartioned(schema, language, 'api', false);
- }
- );
+async function md2jsonAsync(opt) {
+ return await new Promise((resolve, reject) => {
+ md2json(opt, schema => {
+ resolve(schema);
+ });
+ });
+}
- md2json(
- {
- path: language + '/option-gl/**/*.md',
- sectionsAnyOf: ['series'],
- entry: 'option-gl',
- tplEnv: config.gl,
- imageRoot: config.gl.imagePath
- },
- function (schema) {
- writeSingleSchema(schema, language, 'option-gl');
- writeSingleSchemaPartioned(schema, language, 'option-gl', false);
- }
- );
+async function run() {
+
+ for (let language of languages) {
+ let schema;
+
+ schema = await md2jsonAsync({
+ path: language + '/option/**/*.md',
+ sectionsAnyOf: ['visualMap', 'dataZoom', 'series', 'graphic.elements'],
+ entry: 'option',
+ tplEnv: config,
+ imageRoot: config.imagePath
+ });
+ // Always print single option.html file for some third part usage (e.g., dataV).
+ writeSingleSchema(schema, language, 'option', false);
+ writeSingleSchemaPartioned(schema, language, 'option', false);
+
+ schema = await md2jsonAsync({
+ path: language + '/tutorial/**/*.md',
+ entry: 'tutorial',
+ tplEnv: config,
+ maxDepth: 1,
+ imageRoot: config.imagePath
+ });
+ writeSingleSchema(schema, language, 'tutorial');
+ writeSingleSchemaPartioned(schema, language, 'tutorial', false);
+
+ schema = await md2jsonAsync({
+ path: language + '/api/**/*.md',
+ entry: 'api',
+ tplEnv: config,
+ imageRoot: config.imagePath
+ });
+ writeSingleSchema(schema, language, 'api');
+ writeSingleSchemaPartioned(schema, language, 'api', false);
+
+ schema = await md2jsonAsync({
+ path: language + '/option-gl/**/*.md',
+ sectionsAnyOf: ['series'],
+ entry: 'option-gl',
+ tplEnv: config.gl,
+ imageRoot: config.gl.imagePath
+ });
+ writeSingleSchema(schema, language, 'option-gl');
+ writeSingleSchemaPartioned(schema, language, 'option-gl', false);
- fse.outputFileSync(
- 'public/' + language + '/documents/' + '/changelog.html',
- marked(fs.readFileSync(language + '/changelog.md', 'utf-8')),
- 'utf-8'
- );
// let plainMarkDownTpl = fs.readFileSync('tool/plain-md.tpl', 'utf-8');
@@ -124,49 +126,123 @@ function run() {
// .replace('{{content}}', codingStandardContent),
// 'utf-8'
// );
- });
+ }
+
+ console.log('Build doc done.');
+
+ buildChangelog();
+
+ buildCodeStandard();
+
+ copyAsset();
+
+ copySite();
- console.log('Please visit:');
- console.log('echarts-doc/public/zh/');
- console.log('echarts-doc/public/en/');
+ // copyBlog();
+ console.log('All done.');
+}
+
+function buildChangelog() {
+ for (let lang of languages) {
+ const srcPath = path.resolve(projectDir, `${lang}/changelog.md`);
+ const destPath = path.resolve(config.ecWWWGeneratedDir, `${lang}/documents/changelog-content.html`);
+ fse.outputFileSync(
+ destPath,
+ marked(fs.readFileSync(srcPath, 'utf-8')),
+ 'utf-8'
+ );
+ console.log(chalk.green('generated: ' + destPath));
+ }
+ console.log('Build changelog done.');
+}
+
+function buildCodeStandard() {
+ const codeStandardDestPath = path.resolve(config.ecWWWGeneratedDir, 'coding-standard-content.html');
+ fse.ensureDirSync(path.dirname(codeStandardDestPath));
fse.outputFileSync(
- 'public/en/documents/coding-standard.html',
+ codeStandardDestPath,
marked(fs.readFileSync('en/coding-standard.md', 'utf-8')),
'utf-8'
);
+ console.log(chalk.green('generated: ' + codeStandardDestPath));
+
+ console.log('Build code standard done.');
+}
+
+function copyAsset() {
+ for (let lang of languages) {
+ const assetSrcDir = path.resolve(projectDir, 'asset');
+ const assetDestDir = path.resolve(config.releaseDestDir, `${lang}/documents/asset`);
+ copydir.sync(assetSrcDir, assetDestDir);
+ }
+ console.log('Copy asset done.');
+}
+
+function copySite() {
+ // `npm run build:site` have generated the boundle files to `public/`
+ if (config.envType === 'dev') {
+ return;
+ }
+
+ // Copy js and css of doc site.
+ for (let lang of languages) {
+ const jsSrcPath = path.resolve(projectDir, 'public/js/doc-bundle.js')
+ const jsDestPath = path.resolve(config.releaseDestDir, `${lang}/js/doc-bundle.js`);
+ fse.copySync(jsSrcPath, jsDestPath);
+ console.log(chalk.green(`js copied to: ${jsDestPath}`));
+
+ const cssSrcDir = path.resolve(projectDir, 'public/css');
+ const cssDestDir = path.resolve(config.releaseDestDir, `${lang}/css`);
+ fse.copySync(cssSrcDir, cssDestDir);
+ console.log(chalk.green(`css copied to: ${cssDestDir}`));
+ }
+
+ console.log('Copy site done.');
+}
- copydir.sync('./asset', './public/en/documents/asset');
- copydir.sync('./asset', './public/zh/documents/asset');
+function copyBlog() {
+ const blogSrcDir = path.resolve(projectDir, 'blog');
+ const blogDestDir = path.resolve(config.releaseDestDir, 'blog');
+ fse.copySync(blogSrcDir, blogDestDir);
+ console.log(chalk.green(`blog copied to: ${blogDestDir}`));
+ console.log('Copy blog done.');
}
function writeSingleSchema(schema, language, docName, format) {
- let path = `public/${language}/documents/${docName}.json`;
- console.log('output: ' + path);
+ const destPath = path.resolve(config.releaseDestDir, `${language}/documents/${docName}.json`);
+ fse.ensureDirSync(path.dirname(destPath));
fse.outputFileSync(
- path,
+ destPath,
format ? JSON.stringify(schema, null, 2) : JSON.stringify(schema),
'utf-8'
);
+ console.log(chalk.green('generated: ' + destPath));
}
function writeSingleSchemaPartioned(schema, language, docName, format) {
const {outline, descriptions} = extractDesc(schema, docName);
+ const outlineDestPath = path.resolve(config.releaseDestDir, `${language}/documents/${docName}-parts/${docName}-outline.json`);
+ fse.ensureDirSync(path.dirname(outlineDestPath));
fse.outputFile(
- `public/${language}/documents/${docName}-parts/${docName}-outline.json`,
+ outlineDestPath,
format ? JSON.stringify(outline, null, 2) : JSON.stringify(outline),
'utf-8'
);
+ console.log(chalk.green('generated: ' + outlineDestPath));
for (let partKey in descriptions) {
let partDescriptions = descriptions[partKey];
+ let descDestPath = path.resolve(config.releaseDestDir, `${language}/documents/${docName}-parts/${partKey}.json`);
+ fse.ensureDirSync(path.dirname(descDestPath));
fse.outputFile(
- `public/${language}/documents/${docName}-parts/${partKey}.json`,
+ descDestPath,
// format ? JSON.stringify(partDescriptions, null, 2) : JSON.stringify(partDescriptions),
JSON.stringify(partDescriptions, null, 2),
'utf-8'
);
+ console.log(chalk.green('generated: ' + descDestPath));
}
};
diff --git a/config/env.asf.js b/config/env.asf.js
index eb771bc..a324c7d 100644
--- a/config/env.asf.js
+++ b/config/env.asf.js
@@ -1,3 +1,5 @@
+const path = require('path');
+
module.exports = {
galleryViewPath: 'https://echarts.apache.org/examples/zh/view.html?c=',
galleryEditorPath: 'https://echarts.apache.org/examples/zh/editor.html?c=',
@@ -6,5 +8,8 @@ module.exports = {
imagePath: 'asset/img/',
gl: {
imagePath: 'asset/gl/img/',
- }
+ },
+
+ releaseDestDir: path.resolve(__dirname, '../../incubator-echarts-website'),
+ ecWWWGeneratedDir: path.resolve(__dirname, '../../echarts-www/_generated')
};
diff --git a/config/env.dev.js b/config/env.dev.js
index 26f9ffd..74bc11d 100644
--- a/config/env.dev.js
+++ b/config/env.dev.js
@@ -1,3 +1,5 @@
+const path = require('path');
+
module.exports = {
galleryViewPath: 'https://www.echartsjs.com/examples/zh/view.html?c=',
galleryEditorPath: 'https://www.echartsjs.com/examples/zh/editor.html?c=',
@@ -6,5 +8,8 @@ module.exports = {
imagePath: 'asset/img/',
gl: {
imagePath: 'asset/gl/img/'
- }
+ },
+
+ releaseDestDir: path.resolve(__dirname, '../public'),
+ ecWWWGeneratedDir: path.resolve(__dirname, '../../echarts-www/_generated')
};
\ No newline at end of file
diff --git a/config/env.echartsjs.js b/config/env.echartsjs.js
index e379b04..0da1425 100644
--- a/config/env.echartsjs.js
+++ b/config/env.echartsjs.js
@@ -1,3 +1,5 @@
+const path = require('path');
+
module.exports = {
galleryViewPath: 'https://www.echartsjs.com/examples/en/view.html?c=',
galleryEditorPath: 'https://www.echartsjs.com/examples/en/editor.html?c=',
@@ -6,5 +8,8 @@ module.exports = {
imagePath: 'asset/img/',
gl: {
imagePath: 'asset/gl/img/',
- }
+ },
+
+ releaseDestDir: path.resolve(__dirname, '../../echarts-www/release'),
+ ecWWWGeneratedDir: path.resolve(__dirname, '../../echarts-www/_generated')
};
diff --git a/config/env.github.js b/config/env.github.js
deleted file mode 100644
index 77b65aa..0000000
--- a/config/env.github.js
+++ /dev/null
@@ -1,10 +0,0 @@
-module.exports = {
- galleryViewPath: 'https://ecomfe.github.io/echarts-examples/public/view.html?c=',
- galleryEditorPath: 'https://ecomfe.github.io/echarts-examples/public/editor.html?c=',
- websitePath: 'https://ecomfe.github.io',
-
- imagePath: 'asset/img/',
- gl: {
- imagePath: 'asset/gl/img/'
- }
-};
\ No newline at end of file
diff --git a/package.json b/package.json
index 0684de7..b6d88df 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"@babel/preset-env": "^7.7.1",
"babel-loader": "^8.0.6",
"babel-plugin-component": "^1.1.1",
+ "chalk": "^3.0.0",
"concurrently": "^5.0.2",
"copy-dir": "^0.3.0",
"css-loader": "^3.2.0",
diff --git a/release.sh b/release.sh
index 05d300f..64e5c27 100644
--- a/release.sh
+++ b/release.sh
@@ -24,34 +24,13 @@ basepath=$(cd `dirname $0`; pwd)
currPath=$(pwd)
-# Build zh doc for www.echartsjs.com.
cd ${basepath}
-node ./build.js --env ${envType}
+
# Build doc site
npm run build:site
-cd ${currPath}
-# Do not rm, keep option3.json.
-mkdir -p ${basepath}/../echarts-www/release/ \
- ${basepath}/../echarts-www/release/zh \
- ${basepath}/../echarts-www/release/zh/js \
- ${basepath}/../echarts-www/release/zh/css \
- ${basepath}/../echarts-www/release/en \
- ${basepath}/../echarts-www/release/en/js \
- ${basepath}/../echarts-www/release/en/css
-
-cp -R ${basepath}/public/zh/documents/ ${basepath}/../echarts-www/release/zh/documents/
-cp -R ${basepath}/public/en/documents/ ${basepath}/../echarts-www/release/en/documents/
-cp ${basepath}/public/js/doc-bundle.js ${basepath}/../echarts-www/release/zh/js/doc-bundle.js
-cp ${basepath}/public/js/doc-bundle.js ${basepath}/../echarts-www/release/en/js/doc-bundle.js
-
-cp -R ${basepath}/public/css/ ${basepath}/../echarts-www/release/zh/css/
-cp -R ${basepath}/public/css/ ${basepath}/../echarts-www/release/en/css/
-
-cp ${basepath}/public/en/documents/changelog.html ${basepath}/../echarts-www/release/en/documents/
-cp ${basepath}/public/zh/documents/changelog.html ${basepath}/../echarts-www/release/zh/documents/
+node ./build.js --env ${envType}
+cd ${currPath}
+# Do not rm, keep option3.json.
-# Copy blog.
-rm -r ${basepath}/../echarts-www/blog
-cp -R ${basepath}/blog ${basepath}/../echarts-www/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org