Skip to content

Commit

Permalink
fix(docker): removed sprite and font script, not part of the process …
Browse files Browse the repository at this point in the history
…anymore
  • Loading branch information
fxi committed Feb 20, 2025
1 parent 55bf5be commit 892d27b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: bigproc
env:
SCHEDULED_BUILD: ${{ github.event_name == 'schedule' }}
PUSH_ENABLED: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
PUSH_ENABLED: ${{ github.event_name == 'push' }}

steps:
- name: Checkout
Expand Down
8 changes: 3 additions & 5 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
"init:ws": "cd src/js/ws_handler && npm install",
"init:event": "cd src/js/event_simple && npm install",
"init:is-test": "cd src/js/is_test && npm install",
"init:all": "npm run init:base && npm run init:el && npm run init:sdk && npm run init:search && npm run init:ws && npm run init:event && npm run init:is-test",
"init:all": "npm run init:base && npm run init:el && npm run init:sdk && npm run init:search && npm run init:ws && npm run init:event && npm run init:is-test",
"build:app": "webpack --config ./webpack/webpack.prod.js",
"build:dict": "node ./src/node/build_dict.js dict.config.json",
"build:fonts": "cd src/fonts && npm install && npm run build",
"build:sprites": "cd src/sprites && npm install && npm run build",
"build:sdk": "cd src/js/sdk && npm install && npm run build",
"build:all": "npm run build:sprites && npm run build:sdk && npm run build:dict && npm run build:app",
"build:sdk": "npm init:sdk && npm run build",
"build:all": "npm run build:sdk && npm run build:dict && npm run build:app",
"ci": "npm run init:all && npm run build:all && npm run test:build"
},
"author": "unepgrid.ch",
Expand Down
40 changes: 17 additions & 23 deletions app/src/sprites/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@ import fs from "fs/promises";
import glob from "glob";
import path from "path";
import SVGO from "svgo";
let config;
let dirOut, dirOutSvg, dirOutFonts, dirOutSprites, dirOutFontSvg;
let svgs;
const config = JSON.parse(fs.readFileSync("config.json"));

init().catch((e) => console.error(e));
const dirOut = path.resolve(process.cwd(), config.out);
const dirOutSvg = path.join(dirOut, "svg");
const dirOutFonts = path.join(dirOut, "fontstack");
const dirOutSprites = path.join(dirOut, "sprites");
const dirOutFontSvg = path.join(dirOutFonts, config.fontNameSvg);

async function init() {
const configData = await fs.readFile("config.json", 'utf8');
config = JSON.parse(configData);

dirOut = path.resolve(process.cwd(), config.out);
dirOutSvg = path.join(dirOut, "svg");
dirOutFonts = path.join(dirOut, "fontstack");
dirOutSprites = path.join(dirOut, "sprites");
dirOutFontSvg = path.join(dirOutFonts, config.fontNameSvg);
convert().catch((e) => console.error(e));

await initDirs(dirOutSvg, dirOutFonts, dirOutSprites, dirOutFontSvg);
async function convert() {
await init();
await optimizeSvg();
await makeSprites();
}

async function initDirs(...dirs) {
for (const dir of dirs) {
await mkdirSync(dir);
}
async function init() {
await mkdirSync(dirOutSvg);
await mkdirSync(dirOutFonts);
await mkdirSync(dirOutSprites);
await mkdirSync(dirOutFontSvg);
}

async function optimizeSvg() {
Expand All @@ -36,15 +32,13 @@ async function optimizeSvg() {
/**
* SVG optimisation
*/
const svgFiles = glob.sync(config.svgs);
svgs = await Promise.all(svgFiles.map(async (f) => {
const svg = await fs.readFile(f);
const svgs = glob.sync(config.svgs).map((f) => {
return {
svg,
svg: fs.readFileSync(f),
id: path.basename(f).replace(".svg", ""),
name: path.basename(f),
};
}));
});

for (const svg of svgs) {
const r = await svgo.optimize(svg.svg);
Expand Down

0 comments on commit 892d27b

Please # to comment.