Skip to content

Commit 2b6eb01

Browse files
committed
mod and scripts update
1 parent ae74894 commit 2b6eb01

6 files changed

Lines changed: 160 additions & 14 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ require (
88
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20400 // indirect
99
github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2 v2.21100.20000 // indirect
1010
github.com/hugolify/hugolify-admin v0.9.1 // indirect
11-
github.com/hugolify/hugolify-theme v1.26.27 // indirect
12-
github.com/midzer/tobii v3.1.1+incompatible // indirect
11+
github.com/hugolify/hugolify-theme v1.27.2 // indirect
12+
github.com/midzer/tobii v3.1.3+incompatible // indirect
1313
github.com/orestbida/cookieconsent v3.1.0+incompatible // indirect
1414
github.com/twbs/bootstrap v5.3.8+incompatible // indirect
1515
github.com/twbs/icons v1.13.1 // indirect

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2 v2.21100.20000 h1:GZxx4Hc+y
88
github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2 v2.21100.20000/go.mod h1:mFberT6ZtcchrsDtfvJM7aAH2bDKLdOnruUHl0hlapI=
99
github.com/hugolify/hugolify-admin v0.9.1 h1:8HPTBodME+MywUbFszNqubHNcGkFMKmy0yl2wO62nFY=
1010
github.com/hugolify/hugolify-admin v0.9.1/go.mod h1:qB7ndiuXR6XZu3r9UX3LtTHnrMF98U7vJHg6XXb6NvA=
11-
github.com/hugolify/hugolify-theme v1.26.27 h1:1lnyQ6q17aaKeswzKy4gIH0IHh9bpNqUWpI8pDAWul0=
12-
github.com/hugolify/hugolify-theme v1.26.27/go.mod h1:Rc64eJSSIWGeU6eHfSzUISNfL9UrJmy3Xs3H05Gz9rQ=
13-
github.com/midzer/tobii v3.1.1+incompatible h1:L5/7+mmfUgIMU3Bs0nVBNdqwwVUZ5M2CAnjFFb1HKak=
14-
github.com/midzer/tobii v3.1.1+incompatible/go.mod h1:ByXFkVm8ja2+TXT7L+lfkdEIeHW4IdWdsQO8zJ5mEqA=
11+
github.com/hugolify/hugolify-theme v1.27.2 h1:Ae+52EWNllPcaPHV9mruAUEfW+gA23V/H2gzGbE/Dlo=
12+
github.com/hugolify/hugolify-theme v1.27.2/go.mod h1:Rc64eJSSIWGeU6eHfSzUISNfL9UrJmy3Xs3H05Gz9rQ=
13+
github.com/midzer/tobii v3.1.3+incompatible h1:3h2eGycwcHuTWeBLg5bqCLx3EcPSV1rHT1btiu4A3k0=
14+
github.com/midzer/tobii v3.1.3+incompatible/go.mod h1:ByXFkVm8ja2+TXT7L+lfkdEIeHW4IdWdsQO8zJ5mEqA=
1515
github.com/orestbida/cookieconsent v3.1.0+incompatible h1:L2uj16SEL1bICkn6pJde9uc1qAPmTcEiFZO93zZKdQI=
1616
github.com/orestbida/cookieconsent v3.1.0+incompatible/go.mod h1:8N46VI/40AwvzASJDpiwfbu6zylSzKSDZRUVNmVXLxw=
17-
github.com/twbs/bootstrap v5.3.3+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
1817
github.com/twbs/bootstrap v5.3.8+incompatible h1:eK1fsXP7R/FWFt+sSNmmvUH9usPocf240nWVw7Dh02o=
1918
github.com/twbs/bootstrap v5.3.8+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
2019
github.com/twbs/icons v1.13.1 h1:6bmNXvoeIbvjFWjfbjXg5JGbelLD1haIsMaEIzE9UZI=

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"scripts": {
2727
"watch": "hugo server",
2828
"build": "hugo --noChmod --gc --minify",
29+
"build:config:cloudcannon": "node scripts/build-config-cloudcannon.js",
2930
"build:config:pagescms": "node scripts/build-config-pagescms.js",
3031
"build:icons": "yarn build:icons:bootstrap && yarn build",
3132
"build:icons:bootstrap": "node scripts/build-icons-bootstrap.js",
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/**
2+
* CloudCannon Configuration Build Script
3+
*
4+
* This script automates the generation of CloudCannon configuration for Hugolify.
5+
* It performs the following operations:
6+
*
7+
* 1. Executes the Hugo build command (yarn build)
8+
* 2. Generates archetypes from the archetypes.json file
9+
* - Creates .md files in the /archetypes folder with default fields
10+
* 3. Copies the generated configuration file to cloudcannon.config.yml
11+
*
12+
* Usage: node scripts/build-config-cloudcannon.js
13+
*
14+
* @requires child_process
15+
* @requires fs
16+
* @requires path
17+
*/
18+
19+
const { exec } = require('child_process');
20+
const fs = require('fs');
21+
const path = require('path');
22+
23+
// Function to execute a shell command
24+
function runCommand(command) {
25+
return new Promise((resolve, reject) => {
26+
console.log(`Executing: ${command}`);
27+
const process = exec(command);
28+
29+
process.stdout.on('data', (data) => {
30+
console.log(data.toString());
31+
});
32+
33+
process.stderr.on('data', (data) => {
34+
console.error(data.toString());
35+
});
36+
37+
process.on('close', (code) => {
38+
if (code === 0) {
39+
resolve();
40+
} else {
41+
reject(new Error(`Command failed with code ${code}`));
42+
}
43+
});
44+
});
45+
}
46+
47+
// Main function
48+
async function buildAndCopy() {
49+
try {
50+
// Step 1: Run the build
51+
console.log('📦 Starting build...');
52+
await runCommand('yarn build');
53+
console.log('✅ Build completed successfully');
54+
55+
const projectRoot = path.join(__dirname, '..');
56+
57+
// Step 2: Generate Archetypes
58+
console.log('\n🏗️ Generating archetypes...');
59+
const archetypesPath = path.join(projectRoot, 'public', 'admin', 'config', 'archetypes.json');
60+
if (fs.existsSync(archetypesPath)) {
61+
const archetypesData = JSON.parse(fs.readFileSync(archetypesPath, 'utf8'));
62+
const archetypesDir = path.join(projectRoot, 'archetypes');
63+
64+
if (!fs.existsSync(archetypesDir)) {
65+
fs.mkdirSync(archetypesDir, { recursive: true });
66+
}
67+
68+
for (const [collection, fields] of Object.entries(archetypesData)) {
69+
70+
const archetypeFile = path.join(archetypesDir, `${collection}.md`);
71+
let content = '---\n';
72+
fields.forEach(item => {
73+
if (item.default !== "") {
74+
content += `${item.field}: ${item.default}\n`;
75+
} else {
76+
content += `${item.field}:\n`;
77+
}
78+
});
79+
content += '---\n';
80+
81+
fs.writeFileSync(archetypeFile, content);
82+
console.log(`Created archetype: ${archetypeFile}`);
83+
}
84+
} else {
85+
console.warn(`⚠️ Archetypes JSON not found at ${archetypesPath}`);
86+
}
87+
88+
// Step 3: Copy the file
89+
console.log('\n📋 Copying config.yml file...');
90+
const sourcePath = path.join(projectRoot, 'public', 'admin', 'config.yml');
91+
const destPath = path.join(projectRoot, 'cloudcannon.config.yml');
92+
93+
if (!fs.existsSync(sourcePath)) {
94+
throw new Error(`Source file does not exist: ${sourcePath}`);
95+
}
96+
97+
fs.copyFileSync(sourcePath, destPath);
98+
console.log(`✅ File copied: ${sourcePath} -> ${destPath}`);
99+
100+
console.log('\n🎉 Process completed successfully!');
101+
} catch (error) {
102+
console.error('\n❌ Error:', error.message);
103+
process.exit(1);
104+
}
105+
}
106+
107+
// Run the script
108+
buildAndCopy();

scripts/build-config-pagescms.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* PagesCMS Configuration Build Script
3+
*
4+
* This script automates the generation of PagesCMS configuration for Hugolify.
5+
* It performs the following operations:
6+
*
7+
* 1. Executes the Hugo build command (yarn build)
8+
* 2. Copies the generated configuration file to .pages.yml
9+
*
10+
* Usage: node scripts/build-config-pagescms.js
11+
*
12+
* @requires child_process
13+
* @requires fs
14+
* @requires path
15+
*/
16+
117
const { exec } = require('child_process');
218
const fs = require('fs');
319
const path = require('path');

scripts/build-icons-bootstrap.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
#!/usr/bin/env node
22

3+
/**
4+
* Bootstrap Icons Subset Build Script
5+
*
6+
* This script optimizes the delivery of Bootstrap Icons by creating a custom font subset
7+
* containing only the icons actually used in the project.
8+
*
9+
* It performs the following operations:
10+
*
11+
* 1. Runs 'hugo mod vendor' to ensure all modules are available
12+
* 2. Checks and installs required dependencies (bootstrap-icons, subset-font, js-yaml)
13+
* 3. Scans multiple sources to extract used icon names:
14+
* - Markdown and HTML files in /content
15+
* - SASS files in /assets/sass and Hugo modules
16+
* - HTML template files in /layouts
17+
* - Social menu data in /data/menu/social.yml
18+
* 4. Extracts unicode mappings from the official Bootstrap Icons CSS
19+
* 5. Generates optimized WOFF2 and WOFF font subsets in /static/assets/fonts
20+
* 6. Generates a SASS map in /assets/scss/bootstrap-icons/bootstrap-icons.scss
21+
*
22+
* Usage: node scripts/build-icons-bootstrap.js
23+
*/
24+
325
import fs from "fs";
426
import path from "path";
527
import glob from "glob";
@@ -246,7 +268,7 @@ async function extractIconsFromSocialData() {
246268
const icons = new Set();
247269

248270
if (!fs.existsSync(socialFilePath)) {
249-
log("⚠️", "Aucun fichier social.yml trouvé");
271+
log("⚠️", "social.yml not found");
250272
return icons;
251273
}
252274

@@ -255,15 +277,15 @@ async function extractIconsFromSocialData() {
255277
const data = yaml.load(content);
256278

257279
if (!data || typeof data !== "object") {
258-
log("⚠️", "Fichier social.yml mal formé");
280+
log("⚠️", "Malformed social.yml file");
259281
return icons;
260282
}
261283

262-
// Parcours de toutes les clés racine
284+
// Tracing all root keys
263285
Object.keys(data).forEach((key) => {
264286
const node = data[key];
265287

266-
// Cas simple : key = "links"
288+
// Simple case : key = "links"
267289
if (key === "links" && Array.isArray(node)) {
268290
node.forEach((link) => {
269291
if (link.title && typeof link.title === "string") {
@@ -273,7 +295,7 @@ async function extractIconsFromSocialData() {
273295
});
274296
}
275297

276-
// Cas multilingue : key = "fr", "en", etc.
298+
// Multilingue case : key = "fr", "en",
277299
else if (node && typeof node === "object" && Array.isArray(node.links)) {
278300
node.links.forEach((link) => {
279301
if (link.title && typeof link.title === "string") {
@@ -284,9 +306,9 @@ async function extractIconsFromSocialData() {
284306
}
285307
});
286308

287-
log("📱", `Trouvé ${icons.size} icônes dans social.yml`);
309+
log("📱", `Found ${icons.size} icons in social.yml`);
288310
} catch (err) {
289-
console.warn(`⚠️ Erreur de lecture du fichier social.yml : ${err.message}`);
311+
console.warn(`⚠️ Error reading file social.yml: ${err.message}`);
290312
}
291313

292314
return icons;

0 commit comments

Comments
 (0)