mirror of
https://github.com/Dokploy/templates
synced 2025-06-26 18:16:07 +00:00
chore: add yaml and toml dependencies, and create script for converting YAML to TOML
- Added 'yaml' and '@iarna/toml' dependencies in package.json. - Created a new script.js file to process YAML files and convert them to TOML format. - Added template.toml files for various blueprints in the blueprints directory.
This commit is contained in:
36
app/script.js
Normal file
36
app/script.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import yaml from "yaml";
|
||||
import toml from "@iarna/toml";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
function convertYamlToToml(yamlContent) {
|
||||
const parsedYaml = yaml.parse(yamlContent);
|
||||
return toml.stringify(parsedYaml);
|
||||
}
|
||||
|
||||
function processDirectory(dirPath) {
|
||||
const files = fs.readdirSync(dirPath);
|
||||
|
||||
files.forEach((file) => {
|
||||
const filePath = path.join(dirPath, file);
|
||||
const stat = fs.statSync(filePath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
processDirectory(filePath);
|
||||
} else if (file === "template.yml") {
|
||||
console.log(`Converting ${filePath}`);
|
||||
const yamlContent = fs.readFileSync(filePath, "utf8");
|
||||
const tomlContent = convertYamlToToml(yamlContent);
|
||||
const tomlPath = path.join(dirPath, "template.toml");
|
||||
fs.writeFileSync(tomlPath, tomlContent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Ruta al directorio blueprints relativa al script
|
||||
const blueprintsPath = path.join(__dirname, "..", "blueprints");
|
||||
processDirectory(blueprintsPath);
|
||||
Reference in New Issue
Block a user