PSA/ee/mobile/scripts/generate-assets.mjs
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

82 lines
3.0 KiB
JavaScript

import fs from "node:fs/promises";
import path from "node:path";
import sharp from "sharp";
const root = path.resolve(process.cwd(), "mobile");
const assetsDir = path.join(root, "assets");
const COLORS = {
bg: "#0B1220",
gradA: "#22C55E",
gradB: "#06B6D4",
white: "#FFFFFF",
};
function svgMonogram({ size, rounded = true, transparentBg = false }) {
const corner = rounded ? Math.round(size * 0.22) : 0;
const fontSize = Math.round(size * 0.52);
const y = Math.round(size * 0.595);
const background = transparentBg
? ""
: `<rect width="${size}" height="${size}" rx="${corner}" fill="${COLORS.bg}" />`;
return Buffer.from(
`<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="${COLORS.gradA}"/>
<stop offset="100%" stop-color="${COLORS.gradB}"/>
</linearGradient>
</defs>
${background}
<text x="${size / 2}" y="${y}" text-anchor="middle"
font-family="system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif"
font-size="${fontSize}" font-weight="800" fill="url(#g)">A</text>
</svg>`,
);
}
async function writePng({ svg, outPath }) {
await fs.mkdir(path.dirname(outPath), { recursive: true });
await sharp(svg).png({ compressionLevel: 9 }).toFile(outPath);
}
async function main() {
const iconSvg = svgMonogram({ size: 1024, rounded: true, transparentBg: false });
const splashSvg = svgMonogram({ size: 1024, rounded: true, transparentBg: false });
// Android adaptive icon foreground: transparent with extra padding
const fgSize = 1024;
const inner = 720;
const pad = Math.floor((fgSize - inner) / 2);
const adaptiveSvg = Buffer.from(
`<svg width="${fgSize}" height="${fgSize}" viewBox="0 0 ${fgSize} ${fgSize}" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="${COLORS.gradA}"/>
<stop offset="100%" stop-color="${COLORS.gradB}"/>
</linearGradient>
</defs>
<g transform="translate(${pad}, ${pad})">
<rect width="${inner}" height="${inner}" rx="${Math.round(inner * 0.22)}" fill="${COLORS.bg}" />
<text x="${inner / 2}" y="${Math.round(inner * 0.6)}" text-anchor="middle"
font-family="system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif"
font-size="${Math.round(inner * 0.52)}" font-weight="800" fill="url(#g)">A</text>
</g>
</svg>`,
);
const faviconSvg = svgMonogram({ size: 48, rounded: true, transparentBg: false });
await Promise.all([
writePng({ svg: iconSvg, outPath: path.join(assetsDir, "icon.png") }),
writePng({ svg: splashSvg, outPath: path.join(assetsDir, "splash-icon.png") }),
writePng({ svg: adaptiveSvg, outPath: path.join(assetsDir, "adaptive-icon.png") }),
writePng({ svg: faviconSvg, outPath: path.join(assetsDir, "favicon.png") }),
]);
}
await main();