You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2021/06/23 14:18:59 UTC
[apisix-website] branch fix-docs created (now 5dabf04)
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a change to branch fix-docs
in repository https://gitbox.apache.org/repos/asf/apisix-website.git.
at 5dabf04 feat: support custom branch
This branch includes the following new commits:
new 5dabf04 feat: support custom branch
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[apisix-website] 01/01: feat: support custom branch
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch fix-docs
in repository https://gitbox.apache.org/repos/asf/apisix-website.git
commit 5dabf042a5726f30533b57f9ab2cb3606d6a3029
Author: juzhiyuan <ju...@apache.org>
AuthorDate: Wed Jun 23 22:18:38 2021 +0800
feat: support custom branch
---
common.js | 31 ++++++++++++++++++++++++++-----
sync-docs.js | 33 ++++++++++-----------------------
2 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/common.js b/common.js
index 57aeba6..cfb3dc9 100644
--- a/common.js
+++ b/common.js
@@ -1,4 +1,25 @@
-const projects = ["apisix-ingress-controller", "apisix", "apisix-dashboard", "apisix-docker", "apisix-helm-chart", "apisix-java-plugin-runner"];
+const projects = [
+ {
+ name: "apisix-ingress-controller",
+ branch: "master"
+ }, {
+ name: "apisix",
+ branch: "master"
+ }, {
+ name: "apisix-dashboard",
+ branch: "master"
+ }, {
+ name: "apisix-docker",
+ branch: "master"
+ }, {
+ name: "apisix-helm-chart",
+ branch: "master"
+ }, {
+ name: "apisix-java-plugin-runner",
+ branch: "main"
+ }
+];
+
const languages = ["en", "zh", "es"];
module.exports = {
@@ -6,11 +27,11 @@ module.exports = {
languages,
projectPaths: () => projects.map((project) => {
return {
- project: project,
- pluginId: `docs-${project}`,
+ name: project.name,
+ pluginId: `docs-${project.name}`,
paths: {
- en: `./website/docs/${project}`,
- zh: `./website/i18n/zh/docusaurus-plugin-content-docs-docs-${project}/current`,
+ en: `./website/docs/${project.name}`,
+ zh: `./website/i18n/zh/docusaurus-plugin-content-docs-docs-${project.name}/current`,
},
};
})
diff --git a/sync-docs.js b/sync-docs.js
index c457d4a..adcff34 100644
--- a/sync-docs.js
+++ b/sync-docs.js
@@ -9,25 +9,13 @@ const fs = require("fs");
const path = require("path");
const common = require("./common.js");
-const projects = common.projects;
-const langs = common.languages;
-
-const projectPaths = projects.map((project) => {
- return {
- project: project,
- pluginId: `docs-${project}`,
- latestDocs: {
- en: `./website/docs/${project}`,
- zh: `./website/i18n/zh/docusaurus-plugin-content-docs-docs-${project}/current`,
- },
- };
-});
+const { projects, langs, projectPaths } = common;
const isFileExisted = (path) => {
return fs.existsSync(path);
};
-const replaceMDElements = (project, path) => {
+const replaceMDElements = (project, path, branch = "master") => {
const replace = require("replace-in-file");
const allMDFilePaths = path.map((p) => `${p}/**/*.md`);
@@ -38,7 +26,7 @@ const replaceMDElements = (project, path) => {
from: /(\.\.\/)+assets\/images\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g,
to: (match) => {
const imgPath = match.replace(/\(|\)|\.\.\/*/g, "");
- const newUrl = `https://raw.githubusercontent.com/apache/${project}/master/docs/${imgPath}`;
+ const newUrl = `https://raw.githubusercontent.com/apache/${project}/${branch}/docs/${imgPath}`;
console.log(`${project}: ${match} 👉 ${newUrl}`);
return newUrl;
},
@@ -62,8 +50,7 @@ const replaceMDElements = (project, path) => {
project === "apisix" ? "apisix" : project.replace("apisix-", "");
let newUrl = match.replace(
/\]\(.*\)/g,
- `](https://apisix.apache.org${
- lang !== "en" ? "/" + lang : ""
+ `](https://apisix.apache.org${lang !== "en" ? "/" + lang : ""
}/docs/${projectNameWithoutPrefix}/${urlPath})`
);
log(`${project}: ${match} 👉 ${newUrl}`);
@@ -159,7 +146,7 @@ const copyAllDocs = (project) => {
const cloneRepos = () => {
log("Clone repos");
const gitCommand = projects
- .map((project) => `git clone https://github.com/apache/${project}.git`)
+ .map((project) => `git clone https://github.com/apache/${project.name}.git`)
.join(" & ");
childProcess.execSync(gitCommand, { cwd: "./tmp" });
};
@@ -211,7 +198,7 @@ const main = () => {
log("Versioning");
projectPaths.map((project) => {
- const projectName = project.project;
+ const projectName = project.name;
const versions = findReleaseVersions(projectName);
versions.map((version) => {
log(`Versioning for ${project} version: ${version}`);
@@ -220,7 +207,7 @@ const main = () => {
});
log("Replace elements inside MD files");
- replaceMDElements(projectName, [`./tmp/${projectName}/docs`]);
+ replaceMDElements(projectName, [`./tmp/${projectName}/docs`], project.branch);
copyAllDocs(project);
// versioning English docs
@@ -240,13 +227,13 @@ const main = () => {
log("Copy next version docs");
projectPaths.map((project) => {
- const projectName = project.project;
- childProcess.execSync(`git checkout -f master`, {
+ const projectName = project.name;
+ childProcess.execSync(`git checkout -f ${project.branch}`, {
cwd: `./tmp/${projectName}`,
});
log("Replace elements inside MD files");
- replaceMDElements(projectName, [`./tmp/${projectName}/docs`]);
+ replaceMDElements(projectName, [`./tmp/${projectName}/docs`], project.branch);
copyAllDocs(project);
});