diff --git a/.github/workflows/sync-h5.yml b/.github/workflows/sync-h5.yml deleted file mode 100644 index 6bd40aa9d8..0000000000 --- a/.github/workflows/sync-h5.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: sync to docs-h5 - -on: - push: - branches: - - feat_v3.x - paths: - - '.github/workflows/**' - - 'src/**' - - 'package.json' - -jobs: - copy: - if: github.repository == 'jdf2e/nutui-react' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install pnpm - run: npm i -g pnpm@10 - - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Generate doc files - run: node scripts/copy-docs-h5-or-taro.js - - - name : Sync - uses : JamesIves/github-pages-deploy-action@v4.5.0 - with : - branch : react3x/new-site # action 应该部署到的分支 。 - folder : site_docs #操作应该部署的文件夹 。 - clean: false - repository-name: jdf2e/nutui-docs - token: ${{ secrets.GIT_ACTION }} - target-folder: src/docs_react - - - diff --git a/.github/workflows/sync-migrate.yml b/.github/workflows/sync-migrate.yml deleted file mode 100644 index d84cdd21de..0000000000 --- a/.github/workflows/sync-migrate.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: sync to migrate - -on: - push: - branches: - - feat_v3.x - paths: - - '.github/workflows/**' - - 'src/**' - - migrate-from-v2.md - - 'package.json' - -jobs: - copy: - if: github.repository == 'jdf2e/nutui-react' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install pnpm - run: npm i -g pnpm@10 - - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Copy migrate from v2 - run: node scripts/copy-migrate-from-v2.js - - - name: Copy migrate from v1 - run: node scripts/copy-migrate-from-v1.js - - - name : Sync - uses : JamesIves/github-pages-deploy-action@v4.5.0 - with : - branch : react3x/new-site # action 应该部署到的分支 。 - folder : site_docs_migrate #操作应该部署的文件夹 。 - clean: false - repository-name: jdf2e/nutui-docs - token: ${{ secrets.GIT_ACTION }} - target-folder: src/docs - - - diff --git a/.github/workflows/sync-taro.yml b/.github/workflows/sync-taro.yml deleted file mode 100644 index 9f6377af30..0000000000 --- a/.github/workflows/sync-taro.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: sync to docs-taro - -on: - push: - branches: - - feat_v3.x - paths: - - '.github/workflows/**' - - 'src/**' - - 'package.json' - -jobs: - copy: - if: github.repository == 'jdf2e/nutui-react' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install pnpm - run: npm i -g pnpm@10 - - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Generate doc files - run: node scripts/copy-docs-h5-or-taro.js taro - - - name : Sync - uses : JamesIves/github-pages-deploy-action@v4.5.0 - with : - branch : react3x/new-site # action 应该部署到的分支 。 - folder : site_docs #操作应该部署的文件夹 。 - clean: false - repository-name: jdf2e/nutui-docs - token: ${{ secrets.GIT_ACTION }} - target-folder: src/docs_react_taro - - - diff --git a/scripts/copy-docs-h5-or-taro.js b/scripts/copy-docs-h5-or-taro.js deleted file mode 100644 index ddf91eb33c..0000000000 --- a/scripts/copy-docs-h5-or-taro.js +++ /dev/null @@ -1,126 +0,0 @@ -const targetBaseUrl = `${process.cwd()}/site_docs` -const fse = require('fs-extra') -const type = process.argv[2] || 'h5' -const path = require('path') - -function readTsxFile(package, path) { - const data = fse.readFileSync(`src/packages/${package}/demos/${path}`, 'utf8') - return data -} - -const copyFile = (from, to, package) => { - fse - .readFile(from, 'utf8') - .then((content) => { - const regex = /<\/CodeBlock>/g - let match = '' - while ((match = regex.exec(content))) { - let temp = readTsxFile(package, match[1]) // 读取src中的文件 - temp = temp.trim() - content = content.replace( - ``, - '```tsx\n' + temp + '\n```' - ) - } - return content - }) - .then((modifiedContent) => { - // 确保目标文件所在的目录存在,如果不存在就创建 - return fse.ensureDir(path.dirname(to)).then(() => modifiedContent) - }) - .then((modifiedContent) => { - // 将修改后的内容写入目标文件 - return fse.writeFile(to, modifiedContent) - }) - .then(() => { - console.log(`${from}>>${to} [success]`) - }) - .catch((err) => { - console.error('处理文件时发生错误:', err) - }) -} -const removeFile = async (url) => { - return new Promise((res, rej) => { - fse.remove(url, (err) => { - if (err) { - throw err - } - res(true) - }) - }) -} - -const copy = async () => { - let configPath = `src/config.json` - let configPkgPath = `package.json` - let nutuiDocsConfigPath = `${targetBaseUrl}/config.json` - - // 判断 site_docs 文件是否存在根路径中 - const existsRoot = await fse.pathExists(targetBaseUrl) - - if (existsRoot) await removeFile(targetBaseUrl) - // 复制所有组件 - const fromConfig = await fse.readJson(configPath) - fromConfig.nav.forEach(({ packages }) => { - packages.forEach((item) => { - if (item.show) { - let cmpName = item.name.toLowerCase() - // 拷贝 h5 文档 - if (type !== 'taro') { - let docpath = `src/packages/${cmpName}/doc.md` - let docENpath = `src/packages/${cmpName}/doc.en-US.md` - fse.readFile(docpath, (err, data) => { - if (!err) { - copyFile(docpath, `${targetBaseUrl}/docs/${cmpName}/doc.md`, cmpName) - } - }) - fse.readFile(docENpath, (err, data) => { - if (!err) { - copyFile( - docENpath, - `${targetBaseUrl}/docs/${cmpName}/doc.en-US.md`, - cmpName, - ) - } - }) - } - // 拷贝 taro 文档 - if (type === 'taro') { - let docTaropath = `src/packages/${cmpName}/doc.taro.md` - fse.readFile(docTaropath, (err, data) => { - if (!err) { - copyFile( - docTaropath, - `${targetBaseUrl}/docs/${cmpName}/doc.taro.md`, - cmpName, - ) - } - }) - } - } - }) - }) - - // 复制 config.json - const fromPkgConfig = await fse.readJson(configPkgPath) - - const obj = { - version: '', - nav: [], - docs: [], - } - fse.outputJSON(nutuiDocsConfigPath, obj, () => { - const docsConfig = fse.readJson(nutuiDocsConfigPath) - docsConfig.version = fromPkgConfig.version - docsConfig.nav = fromConfig.nav - docsConfig.docs = fromConfig.docs - fse - .writeJson(nutuiDocsConfigPath, docsConfig, { - spaces: 2, - }) - .then(() => { - console.log(`${fromPkgConfig.version} success!`) - }) - }) -} -copy() diff --git a/scripts/copy-migrate-from-v1.js b/scripts/copy-migrate-from-v1.js deleted file mode 100644 index 57b53c972c..0000000000 --- a/scripts/copy-migrate-from-v1.js +++ /dev/null @@ -1,37 +0,0 @@ -const targetBaseUrl = `${process.cwd()}/site_docs_migrate` -const fse = require('fs-extra') - -const copyFile = (from, to) => { - fse - .copy(from, to) - .then(() => { - console.log('success!>', to) - }) - .catch((err) => { - console.error(err) - }) -} -const removeFile = async (url) => { - return new Promise((res, rej) => { - fse.remove(url, (err) => { - if (err) { - throw err - } - res(true) - }) - }) -} - -const copy = async () => { - // 判断 site_docs_migrate 文件是否存在根路径中 - const existsRoot = await fse.pathExists(targetBaseUrl) - - if (existsRoot) await removeFile(targetBaseUrl) - - copyFile('migrate-from-v1.md', `${targetBaseUrl}/react/migrate-from-v1.md`) - copyFile( - 'migrate-from-v1.md', - `${targetBaseUrl}/react_taro/migrate-from-v1.md` - ) -} -copy() diff --git a/scripts/copy-migrate-from-v2.js b/scripts/copy-migrate-from-v2.js deleted file mode 100644 index f897769bfa..0000000000 --- a/scripts/copy-migrate-from-v2.js +++ /dev/null @@ -1,37 +0,0 @@ -const targetBaseUrl = `${process.cwd()}/site_docs_migrate` -const fse = require('fs-extra') - -const copyFile = (from, to) => { - fse - .copy(from, to) - .then(() => { - console.log('success!>', to) - }) - .catch((err) => { - console.error(err) - }) -} -const removeFile = async (url) => { - return new Promise((res, rej) => { - fse.remove(url, (err) => { - if (err) { - throw err - } - res(true) - }) - }) -} - -const copy = async () => { - // 判断 site_docs_migrate 文件是否存在根路径中 - const existsRoot = await fse.pathExists(targetBaseUrl) - - if (existsRoot) await removeFile(targetBaseUrl) - - copyFile('migrate-from-v2.md', `${targetBaseUrl}/react/migrate-from-v2.md`) - copyFile( - 'migrate-from-v2.md', - `${targetBaseUrl}/react_taro/migrate-from-v2.md` - ) -} -copy()