ci-fix-3
Some checks failed
deploy / test (push) Has been skipped
deploy / Update templates on Mailgun (push) Failing after 12s

This commit is contained in:
Untone 2024-02-08 02:23:18 +03:00
parent cf37edaeca
commit 5e2cec5b5d
3 changed files with 29 additions and 14 deletions

View File

@ -41,7 +41,7 @@ jobs:
with:
node-version: '18'
- name: Test production build
- name: Run templates build
run: npm run templates
- name: "authorizer_email_confirmation template"

View File

@ -16,6 +16,7 @@
"hygen": "HYGEN_TMPLS=gen hygen",
"postinstall": "npm run codegen",
"check:code": "npx @biomejs/biome check src --log-kind=compact --verbose",
"check:types": "tsc --noEmit",
"check:code:fix": "npx @biomejs/biome check src --log-kind=compact --verbose --apply-unsafe",
"lint": "npm run lint:code && stylelint **/*.{scss,css}",
"lint:code": "npx @biomejs/biome lint src --log-kind=compact --verbose",

View File

@ -1,22 +1,36 @@
const fs = require('fs');
const path = require('path');
const currentDir = process.cwd();
const templatePath = path.join(currentDir, 'templates', 'main.html');
const outputDir = path.join(currentDir, 'templates', 'dist');
const componentsDir = path.join(currentDir, 'templates', 'entries');
const components = ['email_confirmation', 'first_publication', 'new_comment', 'password_reset'];
const template = fs.readFileSync("templates/main.html", "utf-8");
const outputDir = 'templates/dist';
// Generate HTML files for each template
components.forEach(component => {
const filePath = path.join(outputDir, `authorizer_${component}.html`);
try {
// Read the template file
const template = fs.readFileSync(templatePath, 'utf-8');
// Read the component file
const componentContent = fs.readFileSync(`templates/entries/${component}.html`, 'utf-8');
// Generate HTML files for each template
components.forEach(component => {
const filePath = path.join(outputDir, `authorizer_${component}.html`);
const componentFilePath = path.join(componentsDir, `${component}.html`);
// Replace placeholder with compiled component code
const htmlContent = template.replace('<tbody id="#app"></tbody>', componentContent);
try {
// Read the component file
const componentContent = fs.readFileSync(componentFilePath, 'utf-8');
// Replace placeholder with compiled component code
const htmlContent = template.replace('<tbody id="#app"></tbody>', componentContent);
// Write formatted HTML file to disk
fs.writeFileSync(filePath, htmlContent);
console.log(`${filePath} was generated successfully`);
});
// Write formatted HTML file to disk
fs.writeFileSync(filePath, htmlContent);
console.log(`${filePath} was generated successfully`);
} catch (error) {
console.error(`Error reading component file ${componentFilePath}:`, error);
}
});
} catch (error) {
console.error(`Error reading template file ${templatePath}:`, error);
}