You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sh...@apache.org on 2021/05/30 19:46:31 UTC

[apisix-website] branch master updated: feat: versioning Chinese docs (#357)

This is an automated email from the ASF dual-hosted git repository.

shuyangw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 20101e5  feat: versioning Chinese docs (#357)
20101e5 is described below

commit 20101e5992be907f104599f3c08c71313850a7ad
Author: qier222 <qi...@outlook.com>
AuthorDate: Mon May 31 03:46:21 2021 +0800

    feat: versioning Chinese docs (#357)
    
    Co-authored-by: 琚致远 <ju...@apache.org>
---
 .gitignore   |  3 +++
 sync-docs.js | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 7c3851c..f04d72d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,6 @@ yarn-debug.log*
 yarn-error.log*
 .vscode
 tmp/*
+
+# Local Netlify folder
+.netlify
diff --git a/sync-docs.js b/sync-docs.js
index 8550aee..c457d4a 100644
--- a/sync-docs.js
+++ b/sync-docs.js
@@ -98,6 +98,9 @@ const removeFolder = (tarDir) => {
 
 const copyFolder = (srcDir, tarDir) => {
   let files = fs.readdirSync(srcDir);
+  if (isFileExisted(tarDir) === false) {
+    fs.mkdirSync(tarDir, () => log(`create directory ${tarDir}`));
+  }
   files.forEach((file) => {
     let srcPath = path.join(srcDir, file);
     let tarPath = path.join(tarDir, file);
@@ -191,6 +194,14 @@ const setUp = () => {
 const cleanUp = () => {
   log("Delete tmp folder");
   removeFolder("tmp");
+
+  log("Delete npm related files");
+  removeFolder("node_modules");
+  ["package.json", "package-lock.json"].forEach((file) => {
+    if (fs.existsSync(file)) {
+      fs.unlinkSync(file);
+    }
+  });
 };
 
 const main = () => {
@@ -212,10 +223,18 @@ const main = () => {
       replaceMDElements(projectName, [`./tmp/${projectName}/docs`]);
 
       copyAllDocs(project);
+      // versioning English docs
       childProcess.execSync(
         `npm run docusaurus docs:version:docs-${projectName} ${version}`,
         { cwd: `./website` }
       );
+      // versioning Chinese docs
+      if (isFileExisted(`./tmp/${projectName}/docs/zh/latest`) !== false) {
+        copyFolder(
+          project.latestDocs.zh,
+          `./website/i18n/zh/docusaurus-plugin-content-docs-docs-${projectName}/version-${version}`
+        );
+      }
     });
   });
 
@@ -228,7 +247,6 @@ const main = () => {
 
     log("Replace elements inside MD files");
     replaceMDElements(projectName, [`./tmp/${projectName}/docs`]);
-
     copyAllDocs(project);
   });