From ee8fd36124156194bf24184ed827007e8e0c0136 Mon Sep 17 00:00:00 2001 From: 0x5459 <0x5459@protonmail.com> Date: Wed, 9 Aug 2023 11:22:56 +0800 Subject: [PATCH] test ci --- .github/workflows/publish.yaml | 2 + docs/.vuepress/config.js | 321 +++++++++++++++++---------------- 2 files changed, 171 insertions(+), 152 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 05129d3..b321c08 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + schedule: - cron: '0 0 1/2 * *' workflow_dispatch: @@ -22,6 +23,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 + registry-url: "https://registry.npmjs.org" - name: Install and Build run: | diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index bac0846..fe6f2f5 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,56 +1,73 @@ +var path = require('path') +var url = require('node:url') + +const docsUrlMappings = { + 'en': { + '04.damocles-manager-config.md': ['damocles-manager-config.md', 'damocles-manager config'], + '03.damocles-worker-config.md': ['damocles-worker-config.md', 'damocles-worker config'], + '10.damocles-worker-task-management.md': ['task-management.md', 'Task management'], + '11.task-status-flow.md': ['task-flow.md', 'Task flow'], + '09.poster-node.md': ['poster.md', 'Dedicated PoSt node'], + '12.damocles-worker-util.md': ['worker-util.md', 'Worker utils'], + '06.migrate-sectors-to-damocles.md': ['migrate-sectors.md', 'Import existing sectors'], + }, + 'zh': { + '05.%E5%BF%AB%E9%80%9F%E5%90%AF%E7%94%A8.md': ['quick-start.md', '快速上手'], + '04.damocles-manager%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md': ['damocles-manager-config.md', 'damocles-manager 配置'], + '03.damocles-worker%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md': ['damocles-worker-config.md', 'damocles-worker 配置'], + '07.damocles-worker%E5%A4%96%E9%83%A8%E6%89%A7%E8%A1%8C%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE%E8%8C%83%E4%BE%8B.md': ['processors-config-example.md', '外部执行器配置范例'], + '10.venus-worker%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86.md': ['task-management.md', 'worker 任务管理'], + '11.%E4%BB%BB%E5%8A%A1%E7%8A%B6%E6%80%81%E6%B5%81%E8%BD%AC.md': ['task-flow.md', '任务状态流转'], + '09.%E7%8B%AC%E7%AB%8B%E8%BF%90%E8%A1%8C%E7%9A%84poster%E8%8A%82%E7%82%B9.md': ['poster.md', '独立 Poster'], + '08.snapdeal%E7%9A%84%E6%94%AF%E6%8C%81.md': ['snapup.md', 'snapdeal 支持'], + '12.damocles-worker-util.md': ['worker-util.md', 'damocles-worker-util'], + '13.%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AE%97%E6%B3%95%E5%92%8C%E5%AD%98%E5%82%A8%E6%96%B9%E6%A1%88.md': ['custom-algo.md', '自定义算法/存储方案'], + '14.damocles-manager%E7%9A%84mertics%E4%BD%BF%E7%94%A8.md': ['metrics.md', 'damocles-manager metrics 使用'], + '15.damocles-worker_PC1_HugeTLB_Pages_%E6%94%AF%E6%8C%81.md': ['hugeTLB.md', 'PC1 hugeTLB 支持'], + '16.%E6%89%87%E5%8C%BA%E9%87%8D%E5%BB%BA%E7%9A%84%E6%94%AF%E6%8C%81.md': ['sector-rebuild.md', '扇区重建支持'], + '18.Unseal%E4%BB%BB%E5%8A%A1%E7%9A%84%E6%94%AF%E6%8C%81.md': ['unseal.md', 'unseal 反封装'], + '06.%E5%AF%BC%E5%85%A5%E5%B7%B2%E5%AD%98%E5%9C%A8%E7%9A%84%E6%89%87%E5%8C%BA%E6%95%B0%E6%8D%AE.md': ['migrate-sectors.md', '导入已有扇区'], + '17.%20damocles%E4%B8%8Elotus-miner%E5%88%87%E6%8D%A2%E6%B5%81%E7%A8%8B.md': ['migrate-miner.md', 'lotus-miner 与 damocles 切换流程'], + 'QA.md': ['faq.md', '常见问题'], + '02.%E6%A6%82%E5%BF%B5%E5%92%8C%E5%9F%BA%E7%A1%80%E8%AE%BE%E6%96%BD.md': ['concept.md', '概念和基础设施'], + } +} + +function U(githubUrl) { + try { + let lang = githubUrl.match(/docs\/(zh|en)/g)[0].substr('docs/'.length) + let basename = path.basename(githubUrl) + return [...docsUrlMappings[lang][basename], githubUrl] + } catch (e) { + return [] + } +} + module.exports = { title: 'Damocles', description: 'Damocles, formerly known as Venus Power Service, is THE Filecoin storage power solution.', base: '/', - markdown: { - extendMarkdown: md => { - // why ci is not happy? - md.use(require('markdown-it-replace-link'), { - processHTML: true, // defaults to false for backwards compatibility - replaceLink: function (link, env, token, htmlToken) { - if (link === './04.damocles-manager%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md') { - return 'damocles-manager-config'; - } - if (link === './03.damocles-worker%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md')) { - return 'damocles-worker-config'; - } - if (link === './15.damocles-worker_PC1_HugeTLB_Pages_%E6%94%AF%E6%8C%81.md#damocles-worker-pc1-hugetlb-pages-%E6%94%AF%E6%8C%81') { - return 'hugeTLB'; - } - if (link === 'https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/03.damocles-worker%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md#sealing') { - return '#sealing'; - } - if (link === './16.%E6%89%87%E5%8C%BA%E9%87%8D%E5%BB%BA%E7%9A%84%E6%94%AF%E6%8C%81.md') { - return 'sector-rebuild'; - } - if (link === './15.damocles-worker_PC1_HugeTLB_Pages_%E6%94%AF%E6%8C%81.md') { - return 'hugeTLB'; - } - if (link === './12.damocles-worker-util.md#hwinfo') { - return 'worker-util'; + extendMarkdown: md => { + md.use(require('markdown-it-replace-link'), { + processHTML: true, // defaults to false for backwards compatibility + replaceLink: function (link, env, token, htmlToken) { + try { + let u = url.parse(link) + let filename = path.basename(u.pathname) + for (let m of Object.values(docsUrlMappings)) { + if (filename in m) { + u.pathname = m[filename][0] + return u.format() + } } - if (link === '../example/Example-1.md') { - return 'https://github.com/ipfs-force-community/damocles/blob/main/docs/example/Example-1.md'; - } - if (link === '../example/Example-2.md') { - return 'https://github.com/ipfs-force-community/damocles/blob/main/docs/example/Example-2.md'; - } - if (link === '../example/Example-3.md') { - return 'https://github.com/ipfs-force-community/damocles/blob/main/docs/example/Example-3.md'; - } - if (link === '../example/Example-4.md') { - return 'https://github.com/ipfs-force-community/damocles/blob/main/docs/example/Example-4.md'; - } - if (link === 'https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/04.damocles-manager%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md#commonpersiststores') { - return 'damocles-manager-config#commonpersiststores'; - } - if (link === 'https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/07.damocles-worker%E5%A4%96%E9%83%A8%E6%89%A7%E8%A1%8C%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE%E8%8C%83%E4%BE%8B.md') { - return 'processors-config-example'; - } - return '1'; + } catch (_) { } - }) - }, + + return link; + } + }) + }, + markdown: { config: md => { md.set({ linkify: true @@ -60,7 +77,7 @@ module.exports = { md.use(require('markdown-it-footnote')) md.use(require('markdown-it-deflist')) md.use(require('markdown-it-task-lists')) - }, + }, }, plugins: [ 'vuepress-plugin-check-md', @@ -106,7 +123,7 @@ module.exports = { themeConfig: { logo: '/assets/damocles-icon.png', lastUpdated: 'Last Updated', - // Optional options for generating "Edit this page" link + // Optional options for generating 'Edit this page' link // if your docs are in a different repo from your main project: docsRepo: 'ipfs-force-community/damocles-docs', // if your docs are not at the root of the repo: @@ -148,38 +165,38 @@ module.exports = { }, ], '/operation/': [ - { - title: 'Deployment', - collapsable: false, - children: [ - ['', 'Getting started'], - ] - }, - { - title: 'Configurations', - collapsable: false, - children: [ - ['damocles-manager-config.md', 'damocles-manager config', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/04.damocles-manager-config.md'], - ['damocles-worker-config.md', 'damocles-worker config', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/03.damocles-worker-config.md'], - ] - }, - { - title: 'Operations', - collapsable: false, - children: [ - ['task-management.md', 'Task management', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/10.damocles-worker-task-management.md'], - ['task-flow.md', 'Task flow', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/11.task-status-flow.md'], - ['poster.md', 'Dedicated PoSt node', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/09.poster-node.md'], - ['worker-util.md', 'Worker utils', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/12.damocles-worker-util.md'], - ] - }, - { - title: 'Migration', - collapsable: false, - children: [ - ['migrate-sectors.md', 'Import existing sectors', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/en/06.migrate-sectors-to-damocles.md'], - ] - }, + { + title: 'Deployment', + collapsable: false, + children: [ + ['', 'Getting started'], + ] + }, + { + title: 'Configurations', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/04.damocles-manager-config.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/03.damocles-worker-config.md') + ] + }, + { + title: 'Operations', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/10.damocles-worker-task-management.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/11.task-status-flow.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/09.poster-node.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/12.damocles-worker-util.md'), + ] + }, + { + title: 'Migration', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/en/06.migrate-sectors-to-damocles.md'), + ] + }, ], '/about/': [{ title: '', @@ -197,91 +214,91 @@ module.exports = { title: '执剑人', description: '执剑人(原Venus算力服务)是一个Filecoin存储算力解决方案', nav: [ - { - text: '功能介绍', - link: '/zh/intro/' - }, - { - text: '部署/运维', - link: '/zh/operation/' - }, - { - text: '研发/设计', - link: '/zh/developer/' - }, - { - text: '关于', - link: '/zh/about/' - }, - ], - sidebar: { - '/zh/intro/': [{ - title: '功能特性', - collapsable: false, - children: [ - ['', '概要'], - ['architecture.md', '架构'], - ] - }, - ], - '/zh/operation/': [ { - title: '部署', - collapsable: false, - children: [ - ['quick-start.md', '快速上手','https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/05.%E5%BF%AB%E9%80%9F%E5%90%AF%E7%94%A8.md'], - ] + text: '功能介绍', + link: '/zh/intro/' }, { - title: '配置', - collapsable: false, - children: [ - ['damocles-manager-config.md', 'damocles-manager 配置', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/04.damocles-manager%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md"], - ['damocles-worker-config.md', 'damocles-worker 配置', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/03.damocles-worker%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md"], - ['processors-config-example.md', '外部执行器配置范例', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/07.damocles-worker%E5%A4%96%E9%83%A8%E6%89%A7%E8%A1%8C%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE%E8%8C%83%E4%BE%8B.md"], - ] + text: '部署/运维', + link: '/zh/operation/' }, { - title: '运维', - collapsable: false, - children: [ - ['task-management.md', 'worker 任务管理', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/10.venus-worker%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86.md"], - ['task-flow.md', '任务状态流转', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/11.%E4%BB%BB%E5%8A%A1%E7%8A%B6%E6%80%81%E6%B5%81%E8%BD%AC.md"], - ['poster.md', '独立 Poster', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/09.%E7%8B%AC%E7%AB%8B%E8%BF%90%E8%A1%8C%E7%9A%84poster%E8%8A%82%E7%82%B9.md"], - ['snapup.md', 'snapdeal 支持', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/08.snapdeal%E7%9A%84%E6%94%AF%E6%8C%81.md"], - ['worker-util.md', 'damocles-worker-util', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/12.damocles-worker-util.md"], - ['custom-algo.md', '自定义算法/存储方案', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/13.%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AE%97%E6%B3%95%E5%92%8C%E5%AD%98%E5%82%A8%E6%96%B9%E6%A1%88.md"], - ['metrics.md', 'damocles-manager metrics 使用', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/14.damocles-manager%E7%9A%84mertics%E4%BD%BF%E7%94%A8.md"], - ['hugeTLB.md', 'PC1 hugeTLB 支持', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/15.damocles-worker_PC1_HugeTLB_Pages_%E6%94%AF%E6%8C%81.md"], - ['sector-rebuild.md', '扇区重建支持', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/16.%E6%89%87%E5%8C%BA%E9%87%8D%E5%BB%BA%E7%9A%84%E6%94%AF%E6%8C%81.md"], - ['unseal.md', 'unseal 反封装', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/18.Unseal%E4%BB%BB%E5%8A%A1%E7%9A%84%E6%94%AF%E6%8C%81.md"], - ] + text: '研发/设计', + link: '/zh/developer/' }, { - title: '迁移', - collapsable: false, - children: [ - ['migrate-sectors.md', '导入已有扇区', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/06.%E5%AF%BC%E5%85%A5%E5%B7%B2%E5%AD%98%E5%9C%A8%E7%9A%84%E6%89%87%E5%8C%BA%E6%95%B0%E6%8D%AE.md"], - ['migrate-miner.md', 'lotus-miner 与 damocles 切换流程', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/17.%20damocles%E4%B8%8Elotus-miner%E5%88%87%E6%8D%A2%E6%B5%81%E7%A8%8B.md"], - ] + text: '关于', + link: '/zh/about/' }, - { - title: 'FAQ', + ], + sidebar: { + '/zh/intro/': [{ + title: '功能特性', collapsable: false, children: [ - ['faq.md', '常见问题', "https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/QA.md"], + ['', '概要'], + ['architecture.md', '架构'], ] }, ], + '/zh/operation/': [ + { + title: '部署', + collapsable: false, + children: [ + ['quick-start.md', '快速上手', 'https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/05.%E5%BF%AB%E9%80%9F%E5%90%AF%E7%94%A8.md'], + ] + }, + { + title: '配置', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/04.damocles-manager%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/03.damocles-worker%E7%9A%84%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/07.damocles-worker%E5%A4%96%E9%83%A8%E6%89%A7%E8%A1%8C%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE%E8%8C%83%E4%BE%8B.md'), + ] + }, + { + title: '运维', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/10.venus-worker%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/11.%E4%BB%BB%E5%8A%A1%E7%8A%B6%E6%80%81%E6%B5%81%E8%BD%AC.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/09.%E7%8B%AC%E7%AB%8B%E8%BF%90%E8%A1%8C%E7%9A%84poster%E8%8A%82%E7%82%B9.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/08.snapdeal%E7%9A%84%E6%94%AF%E6%8C%81.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/12.damocles-worker-util.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/13.%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AE%97%E6%B3%95%E5%92%8C%E5%AD%98%E5%82%A8%E6%96%B9%E6%A1%88.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/14.damocles-manager%E7%9A%84mertics%E4%BD%BF%E7%94%A8.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/15.damocles-worker_PC1_HugeTLB_Pages_%E6%94%AF%E6%8C%81.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/16.%E6%89%87%E5%8C%BA%E9%87%8D%E5%BB%BA%E7%9A%84%E6%94%AF%E6%8C%81.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/18.Unseal%E4%BB%BB%E5%8A%A1%E7%9A%84%E6%94%AF%E6%8C%81.md'), + ] + }, + { + title: '迁移', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/06.%E5%AF%BC%E5%85%A5%E5%B7%B2%E5%AD%98%E5%9C%A8%E7%9A%84%E6%89%87%E5%8C%BA%E6%95%B0%E6%8D%AE.md'), + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/17.%20damocles%E4%B8%8Elotus-miner%E5%88%87%E6%8D%A2%E6%B5%81%E7%A8%8B.md'), + ] + }, + { + title: 'FAQ', + collapsable: false, + children: [ + U('https://github.com/ipfs-force-community/damocles/blob/main/docs/zh/QA.md'), + ] + }, + ], '/zh/developer/': [ - { - title: '设计理念', - collapsable: false, - children: [ - ['', '简述'], - ['concept.md', '概念和基础设施', "https://github.com/ipfs-force-community/venus-cluster/blob/main/docs/zh/02.%E6%A6%82%E5%BF%B5%E5%92%8C%E5%9F%BA%E7%A1%80%E8%AE%BE%E6%96%BD.md"], - ] - }, + { + title: '设计理念', + collapsable: false, + children: [ + ['', '简述'], + U('https://github.com/ipfs-force-community/venus-cluster/blob/main/docs/zh/02.%E6%A6%82%E5%BF%B5%E5%92%8C%E5%9F%BA%E7%A1%80%E8%AE%BE%E6%96%BD.md'), + ] + }, ], '/zh/about/': [{ title: '',