@@ -89,34 +89,72 @@ jobs:
8989
9090 root = pathlib.Path('./src/.vuepress')
9191
92+ def replace_or_fail(path: pathlib.Path, pattern: str, repl: str, flags: int = 0, *, must_change: bool = True):
93+ text = path.read_text(encoding='utf-8')
94+ new_text, count = re.subn(pattern, repl, text, flags=flags)
95+ if must_change and count == 0:
96+ raise SystemExit(f'CI patch 未命中: {path} / {pattern}')
97+ path.write_text(new_text, encoding='utf-8')
98+
99+ def remove_text(path: pathlib.Path, needle: str, *, must_change: bool = True):
100+ text = path.read_text(encoding='utf-8')
101+ if needle not in text:
102+ if must_change:
103+ raise SystemExit(f'CI patch 未命中: {path} / {needle}')
104+ return
105+ path.write_text(text.replace(needle, ''), encoding='utf-8')
106+
92107 config_plugins = root / 'config_plugins.ts'
93- text = config_plugins.read_text(encoding='utf-8')
94- text = text.replace('import anyblock from "./plugins/AnyBlock/node"\n', '')
95- text = text.replace('import relational_graph from "./plugins/BiGraph/node"\n', '')
96- text = text.replace('import myLayout from "./plugins/MyLayout/node" // 非通用的自定义布局,必须最后加载,便于覆盖其他插件的自定义布局行为\n', '')
97- text = text.replace(' anyblock,\n', '')
98- text = re.sub(r'\n\s*relational_graph\(\{.*?\}\),\n', '\n', text, flags=re.S)
99- text = re.sub(r'\n\s*myLayout,.*?\n', '\n', text)
100- config_plugins.write_text(text, encoding='utf-8')
108+ remove_text(config_plugins, 'import anyblock from "./plugins/AnyBlock/node"\n')
109+ remove_text(config_plugins, 'import nodeFlow from "./plugins/NodeFlow/node"\n')
110+ remove_text(config_plugins, 'import tikz from "./plugins/Tikz/node"\n')
111+ remove_text(config_plugins, 'import exFormat from "./plugins/ExFormat/node"\n')
112+ remove_text(config_plugins, 'import relational_graph from "./plugins/BiGraph/node"\n')
113+ remove_text(config_plugins, 'import myLayout from "./plugins/MyLayout/node" // 非通用的自定义布局,必须最后加载,便于覆盖其他插件的自定义布局行为\n')
114+ remove_text(config_plugins, ' anyblock,\n')
115+ remove_text(config_plugins, ' nodeFlow,\n')
116+ remove_text(config_plugins, ' tikz,\n')
117+ remove_text(config_plugins, ' exFormat,\n')
118+ replace_or_fail(config_plugins, r'\n\s*relational_graph\(\{.*?\}\),\n', '\n', re.S)
119+ replace_or_fail(config_plugins, r'\n\s*myLayout,.*?\n', '\n')
101120
102121 config_extends = root / 'config_extendsMarkdown.ts'
103- text = config_extends.read_text(encoding='utf-8')
104- text = text.replace('import chatview_mdit from "./plugins/ChatView/src/MarkdownIt/index_mdit.js"\n', '')
105- text = text.replace(' md.use(chatview_mdit) // 这里要虚拟dom,让前面的ab_mdit模块给解决一下\n', '')
106- config_extends.write_text(text, encoding='utf-8')
122+ remove_text(config_extends, 'import chatview_mdit from "./plugins/ChatView/src/MarkdownIt/index_mdit.js"\n')
123+ remove_text(config_extends, ' md.use(chatview_mdit) // 这里要虚拟dom,让前面的ab_mdit模块给解决一下\n')
124+
125+ config = root / 'config.ts'
126+ remove_text(config, ' "**/*.json", // "**/*.pdf",\n')
107127
108128 theme = root / 'theme.ts'
129+ remove_text(theme, ' slimsearch: true,', must_change=False)
109130 text = theme.read_text(encoding='utf-8')
110- text = text.replace(' slimsearch: true,', ' slimsearch: false,')
111- theme.write_text(text, encoding='utf-8')
131+ theme.write_text(text.replace(' slimsearch: true,', ' slimsearch: false,'), encoding='utf-8')
132+
133+ styles = root / 'styles/index.scss'
134+ remove_text(styles, "@import '../plugins/ChatView/styles.scss';\n")
135+ remove_text(styles, "@import '../plugins/NodeFlow/client/NodeFlow/style/vue_custom.scss';\n")
136+
137+ print('CI patch complete: disabled AnyBlock/ChatView/NodeFlow/Tikz/ExFormat/BiGraph/MyLayout/json pages/slimsearch')
112138 PY
113139
140+ - name : 配置 - CI 诊断输出
141+ working-directory : ./
142+ run : |
143+ echo '--- config_plugins.ts ---'
144+ sed -n '1,80p' ./src/.vuepress/config_plugins.ts
145+ echo '--- config_extendsMarkdown.ts ---'
146+ sed -n '1,40p' ./src/.vuepress/config_extendsMarkdown.ts
147+ echo '--- config.ts ---'
148+ sed -n '25,45p' ./src/.vuepress/config.ts
149+ echo '--- styles/index.scss ---'
150+ sed -n '1,20p' ./src/.vuepress/styles/index.scss
151+
114152 - name : 文档 - 构建
115153 env :
116154 NODE_OPTIONS : --max_old_space_size=20480
117155 run : |-
118- node -e 'console.log(v8.getHeapStatistics())'
119- pnpm run docs: build
156+ node -e 'const v8=require("v8"); console.log({heap_limit_mb: Math.round( v8.getHeapStatistics().heap_size_limit/1024/1024)} )'
157+ pnpm exec vuepress-vite build src
120158 > src/.vuepress/dist/.nojekyll
121159
122160 - name : 文档 - 部署
0 commit comments