Skip to content

Commit

Permalink
Merge branch 'merge' into 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
syrk4web committed Jul 1, 2024
2 parents c88acff + 86cb619 commit 58288db
Show file tree
Hide file tree
Showing 1,066 changed files with 295,446 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
}
Empty file modified docs/diagrams/core-order.drawio
100755 → 100644
Empty file.
Empty file modified docs/json2md.py
100755 → 100644
Empty file.
230 changes: 230 additions & 0 deletions docs/vue2md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
const fs = require("fs");
const path = require("path");

// Merge all components md on this file name
const finalFile = "COMPONENTS.md";
// Where we have all SFC components
const inputFolder = path.join(__dirname, "components");
// Where we want to output md components file
const ouputFolder = path.join(__dirname, "output");

// Check that input folder exists
if (!fs.existsSync(inputFolder)) {
console.error("Input folder does not exist");
process.exit(1);
}

// Create the output folder if it doesn't exist
if (!fs.existsSync(ouputFolder)) {
fs.mkdirSync(ouputFolder);
}

// Remove previous content of the output folder
fs.readdirSync(ouputFolder).forEach((file) => {
fs.unlinkSync(path.join(ouputFolder, file));
});

// Allow to get all subfolders from inputFolder
function flatten(lists) {
return lists.reduce((a, b) => a.concat(b), []);
}

function getDirectories(srcpath) {
return fs
.readdirSync(srcpath)
.map((file) => path.join(srcpath, file))
.filter((path) => fs.statSync(path).isDirectory());
}

function getDirectoriesRecursive(srcpath) {
return [
srcpath,
...flatten(getDirectories(srcpath).map(getDirectoriesRecursive)),
];
}

// Get the script part of a Vue file and create a JS file
function vue2js() {
const folders = getDirectoriesRecursive(inputFolder);
// Read every subfolders from the input folder and get all files
folders.forEach((folder) => {
const files = fs.readdirSync(path.join(folder), {
withFileTypes: true,
});
files.forEach((file) => {
// Get only .vue file
if (file.isFile() && file.name.endsWith(".vue")) {
const src = path.join(folder, file.name);
const data = fs.readFileSync(src, "utf8");
// Get only the content between <script setup> and </script> tag
const script = data.match(/<script setup>([\s\S]*?)<\/script>/g);
// I want to remove the <script setup> and </script> tags
script[0] = script[0]
.replace("<script setup>", "")
.replace("</script>", "");
// Create a file on the output folder with the same name but with .js extension
const fileName = file.name.replace(".vue", ".js");
const dest = path.join(ouputFolder, fileName);
fs.writeFileSync(dest, script[0], "utf8");
}
});
});
}

// Run a command to render markdown from JS files
function js2md() {
// Get all files from the output folder
const files = fs.readdirSync(ouputFolder, { withFileTypes: true });
// Create a markdown file for each JS file
files.forEach((file) => {
// Run a process `documentation build <filename> -f md > <filename>.md
const command = `documentation build ${path.join(
ouputFolder,
file.name
)} -f md > ${path.join(ouputFolder, file.name.replace(".js", ".md"))}`;

// Run the command
const { execSync } = require("child_process");
execSync(command, (error, stdout, stderr) => {
if (error) {
// console.error(`exec error: ${error}`);
return;
}
// console.log(`stdout: ${stdout}`);
// console.error(`stderr: ${stderr}`);
});
});
// Remove all JS files when all processes are done
files.forEach((file) => {
fs.unlinkSync(path.join(ouputFolder, file.name));
});
}

// Format each md file to remove specific content
function mergeMd() {
// Get all files from the output folder
const files = fs.readdirSync(ouputFolder, { withFileTypes: true });
files.forEach((file, id) => {
let data = fs.readFileSync(path.join(ouputFolder, file.name), "utf8");
// In case we have "[1]:", remove everything after
data = data.replace(/\[\d+\]:[\s\S]*?$/g, "");
// Remove ### Table of contents
data = data.replace("### Table of Contents", "");
// Remove everything after the first ## tag
const index = data.indexOf("## ");
data = data.substring(index);
fs.writeFileSync(path.join(ouputFolder, file.name), data, "utf8");
});

// Create order using the tag title path of each file
// For example using Form/Input.vue
const order = [];
files.forEach((file, id) => {
// Get the title from first line
const data = fs.readFileSync(path.join(ouputFolder, file.name), "utf8");
const filePath = data.split("\n")[0].replace("## ", "");
order.push({ path: filePath, file: file });
});

// Sort by path
order.sort((a, b) => {
return a.path.localeCompare(b.path);
});

// Create the md file to merge
const merge = path.join(ouputFolder, finalFile);
fs.writeFileSync(merge, "", "utf8");
// Append each file in order
order.forEach((item) => {
let data = fs.readFileSync(path.join(ouputFolder, item.file.name), "utf8");
fs.appendFileSync(merge, data, "utf8");
});
}

// Format merge file
function formatMd() {
// Create a md file to merge
const merge = path.join(ouputFolder, finalFile);

// Get data from merge
let data = fs.readFileSync(merge, "utf8");
let isLevel = true;
let currAttemps = 0;
const maxAttemps = 6;
while (isLevel && currAttemps < maxAttemps) {
currAttemps++;
const titles = [];
let tag = "#";
for (let i = 0; i < currAttemps; i++) {
tag += "#";
}
tag += " ";

// Each time, get the first level title and add it to the titles array
data.split("\n").forEach((line) => {
if (line.startsWith(tag) && line.includes("/")) {
const firstLevel = line.split("/")[0];
if (!titles.includes(firstLevel.replace(tag, "").trim()))
titles.push(firstLevel.replace(tag, ""));
}
});
// Create a top title at the first occurrence
// And remove from component the first level string
titles.forEach((title) => {
let isTitleSet = false;
data.split("\n").forEach((line) => {
// For title
if (line.startsWith(tag) && line.includes("/")) {
// Add a top title before the current line
if (!isTitleSet && line.includes(`${title}/`)) {
data = data.replace(
line,
`${tag} ${title}\n\n${line
.replace(tag, "#" + tag)
.replace(`${title}/`, "")}`
);
isTitleSet = true;
return;
}

if (line.includes(`${title}/`)) {
data = data.replace(
line,
line.replace(tag, "#" + tag).replace(`${title}/`, "")
);
}
return;
}
});
});
}

// Update the child of .vue component title to keep title levels consistency
let componentTag = "";
let dataSplit = data.split("\n");
data.split("\n").forEach((line, id) => {
if (line.startsWith("#") && line.includes(".vue")) {
componentTag = line.split(" ")[0];
return;
}

if (
(line.startsWith("#") && line.includes("Parameters")) ||
(line.startsWith("#") && line.includes("Examples"))
) {
const elTag = line.split(" ")[0];
// get line per id
const updateLine = line.replace(elTag, `${componentTag}#`);
dataSplit[id] = updateLine;
}
});
// Update the data with split
data = dataSplit.join("\n");

fs.writeFileSync(merge, data, "utf8");
}

vue2js();
js2md();
mergeMd();
formatMd();
Empty file modified examples/authelia/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/behind-reverse-proxy/cleanup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/behind-reverse-proxy/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/cors/setup-autoconf.sh
100755 → 100644
Empty file.
Empty file modified examples/cors/setup-docker.sh
100755 → 100644
Empty file.
Empty file modified examples/cors/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/drupal/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/drupal/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/drupal/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/drupal/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/ghost/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/ghost/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/gogs/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/joomla/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/joomla/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/joomla/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/magento/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/magento/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/magento/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/mattermost/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/mattermost/setup-autoconf.sh
100755 → 100644
Empty file.
Empty file modified examples/mattermost/setup-docker.sh
100755 → 100644
Empty file.
Empty file modified examples/mattermost/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/mongo-express/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/moodle/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/moodle/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/moodle/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/nextcloud/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/nextcloud/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/nextcloud/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/nextcloud/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/php-cookie-flags/setup-docker.sh
100755 → 100644
Empty file.
Empty file modified examples/php-cookie-flags/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/php-multisite/setup-autoconf.sh
100755 → 100644
Empty file.
Empty file modified examples/php-multisite/setup-docker.sh
100755 → 100644
Empty file.
Empty file modified examples/php-multisite/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/php-singlesite/setup-docker.sh
100755 → 100644
Empty file.
Empty file modified examples/php-singlesite/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/prestashop/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/prestashop/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/proxy-protocol/cleanup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/proxy-protocol/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/redmine/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/redmine/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/reverse-proxy-singlesite/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/swarm-configs/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified examples/wordpress/cleanup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/wordpress/setup-kubernetes.sh
100755 → 100644
Empty file.
Empty file modified examples/wordpress/setup-linux.sh
100755 → 100644
Empty file.
Empty file modified examples/wordpress/setup-swarm.sh
100755 → 100644
Empty file.
Empty file modified misc/dev/configs/server-http/hello.conf
100755 → 100644
Empty file.
Empty file modified misc/format-jinja-files.sh
100755 → 100644
Empty file.
Empty file modified misc/update-mmdb.sh
100755 → 100644
Empty file.
Empty file modified misc/update-version.sh
100755 → 100644
Empty file.
Loading

0 comments on commit 58288db

Please sign in to comment.