Skip to content

Commit

Permalink
chore(*): upgrade mermaid@10.2.4 (#520)
Browse files Browse the repository at this point in the history
* chore(*): upgrade mermaid@10.2.4

Close #510

* chore(*): upgrade rollup and outdated plugins

* feat(*): drop node 12 support

BREAKING CHANGE: @tencent/cherry-markdown no longer supports node < 14

* chore(*): track dist files with lfs

* chore(*): fix styles output path & update docs
  • Loading branch information
lyngai authored Aug 3, 2023
1 parent 0712486 commit c842448
Show file tree
Hide file tree
Showing 45 changed files with 1,677 additions and 101,231 deletions.
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have LF line endings on checkout.
* text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Expand All @@ -13,4 +11,6 @@
*.ttf binary
*.woff binary
*.woff2 binary
*.ico binary
*.ico binary

dist/** filter=lfs diff=lfs merge=lfs -text
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
3 changes: 3 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
git lfs post-checkout "$@"
3 changes: 3 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
git lfs post-commit "$@"
3 changes: 3 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
git lfs post-merge "$@"
3 changes: 3 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
git lfs pre-push "$@"
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.20.1
4 changes: 2 additions & 2 deletions README.CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ npm install cherry-markdown --save

如果需要开启 `mermaid` 画图、表格自动转图表功能,需要同时添加`mermaid``echarts`包。

目前**Cherry**推荐的插件版本为`echarts@4.6.0``mermaid@8.11.1`
目前**Cherry**推荐的插件版本为`echarts@4.6.0``mermaid@9.4.3`

```bash
# 安装mermaid依赖开启mermaid画图功能
yarn add mermaid@8.11.1
yarn add mermaid@9.4.3
# 安装echarts依赖开启表格自动转图表功能
yarn add echarts@4.6.0
```
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ npm install cherry-markdown --save

If you need to enable the functions of `mermaid` drawing and table-to-chart, you need to add `mermaid` and `echarts` packages at the same time.

Currently, the plug-in version **Cherry** recommend is `echarts@4.6.0` `mermaid@8.11.1`.
Currently, the plug-in version **Cherry** recommend is `echarts@4.6.0` `mermaid@9.4.3`.

```bash
# Install mermaid, enable mermaid and drawing function
yarn add mermaid@8.11.1
yarn add mermaid@9.4.3
# Install echarts, turn on the table-to-chart function
yarn add echarts@4.6.0
```
Expand Down
6 changes: 2 additions & 4 deletions build/addons.build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const babel = require('@rollup/plugin-babel').default;
// node-resolve升级会导致出现新问题
const resolve = require('rollup-plugin-node-resolve');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const eslint = require('@rollup/plugin-eslint');
const alias = require('@rollup/plugin-alias');
Expand Down Expand Up @@ -28,7 +27,7 @@ glob(
);

const rollup = require('rollup');
const { terser } = require('rollup-plugin-terser');
const terser = require('@rollup/plugin-terser').default;

/**
*
Expand Down Expand Up @@ -66,7 +65,6 @@ function buildAddons(entries) {
],
}),
resolve({
ignoreGlobal: false,
browser: true,
}),
typescript({
Expand Down
2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import baseConfig from './rollup.base.config';

const terserPlugin = (options = {}) =>
Expand Down
23 changes: 12 additions & 11 deletions build/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
import path from 'path';
import babel from '@rollup/plugin-babel';
// node-resolve升级会导致出现新问题
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import scss from 'rollup-plugin-scss';
import eslint from '@rollup/plugin-eslint';
Expand Down Expand Up @@ -52,6 +51,8 @@ export default {
globals: {
jsdom: 'jsdom',
},
// disable code splitting
manualChunks: () => 'cherry',
},
plugins: [
eslint({
Expand All @@ -61,13 +62,14 @@ export default {
envReplacePlugin(),
alias(aliasPluginOptions),
resolve({
ignoreGlobal: false,
// ignoreGlobal: false,
browser: true,
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: [/node_modules/, /src[\\/]libs/], // Default: undefined
exclude: [/node_modules[\\/](lodash-es|d3-.*[\\/]src|d3[\\/]src|dagre-d3-es)/],
// exclude: [/src\/(?!libs)/],
// exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ], // Default: undefined
// these values can also be regular expressions
Expand Down Expand Up @@ -95,7 +97,7 @@ export default {
}),
scss({
// Filename to write all styles to
output: IS_PRODUCTION ? 'dist/cherry-markdown.min.css' : 'dist/cherry-markdown.css',
fileName: IS_PRODUCTION ? 'cherry-markdown.min.css' : 'cherry-markdown.css',

// Determine if node process should be terminated on error (default: false)
failOnError: true,
Expand All @@ -106,7 +108,7 @@ export default {
}),
babel({
babelHelpers: 'runtime',
exclude: [/node_modules[\\/](?!codemirror[\\/]src[\\/]|parse5)/],
exclude: [/node_modules[\\/](?!codemirror[\\/]src[\\/]|parse5|lodash-es|d3-.*[\\/]src|d3[\\/]src|dagre-d3-es)/],
}),
// TODO: 重构抽出为独立的插件
{
Expand Down Expand Up @@ -138,16 +140,15 @@ export default {
},
],
onwarn(warning, warn) {
// 忽略 mermaid 的 eval
if (warning.code === 'EVAL' && warning.id.indexOf('mermaid') !== -1) {
return;
}
// 忽略 juice 的 circular dependency
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.importer.includes('node_modules/juice')) {
if (
warning.code === 'CIRCULAR_DEPENDENCY' &&
(warning.importer.includes('node_modules/juice') || warning.importer.includes('node_modules/d3-'))
) {
return;
}
warn(warning);
},
external: [/@babel[\\/]runtime/, 'jsdom'],
external: ['jsdom'],
// external: ['echarts']
};
3 changes: 2 additions & 1 deletion build/rollup.core.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import baseConfig from './rollup.base.config';

const terserPlugin = (options = {}) =>
Expand All @@ -40,6 +40,7 @@ const options = {
sourcemap: false,
compact: true,
plugins: [terserPlugin()],
manualChunks: () => 'main',
},
};

Expand Down
2 changes: 1 addition & 1 deletion build/rollup.engine.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import baseConfig from './rollup.base.config';

// TODO: 新增完整版引擎构建, 目前引擎构建仅支持核心构建
Expand Down
35 changes: 3 additions & 32 deletions dist/addons/cherry-code-block-mermaid-plugin.d.ts
Git LFS file not shown
4 changes: 3 additions & 1 deletion dist/addons/cherry-code-block-mermaid-plugin.js

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions dist/addons/cherry-code-block-plantuml-plugin.d.ts
Git LFS file not shown
4 changes: 3 additions & 1 deletion dist/addons/cherry-code-block-plantuml-plugin.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/cherry-markdown.core.common.d.ts
Git LFS file not shown
4 changes: 3 additions & 1 deletion dist/cherry-markdown.core.common.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/cherry-markdown.core.d.ts
Git LFS file not shown
4 changes: 3 additions & 1 deletion dist/cherry-markdown.core.js

Large diffs are not rendered by default.

Loading

0 comments on commit c842448

Please sign in to comment.