fix: use site favicon in HiCAD
This commit is contained in:
parent
957192cc5c
commit
c2bc6147c8
@ -30,6 +30,7 @@ const sourceRefFile = path.join(sourceDir, ".hicad-source-ref");
|
|||||||
const outputDir = path.join(root, "public/vendor/zoo-modeling-app");
|
const outputDir = path.join(root, "public/vendor/zoo-modeling-app");
|
||||||
const customizationDir = path.join(root, "vendor/zoo-modeling-app");
|
const customizationDir = path.join(root, "vendor/zoo-modeling-app");
|
||||||
const proxyToken = "hicad-session";
|
const proxyToken = "hicad-session";
|
||||||
|
const brandedFaviconUrl = "/api/favicon?surface=hicad";
|
||||||
|
|
||||||
function run(command, args, options = {}) {
|
function run(command, args, options = {}) {
|
||||||
const result = spawnSync(command, args, {
|
const result = spawnSync(command, args, {
|
||||||
@ -112,6 +113,22 @@ function replaceSource(relativePath, before, after) {
|
|||||||
writeFileSync(filePath, source.replace(before, after));
|
writeFileSync(filePath, source.replace(before, after));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function patchOfficialManifest() {
|
||||||
|
const manifestPath = path.join(sourceDir, "public/manifest.json");
|
||||||
|
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
||||||
|
|
||||||
|
manifest.short_name = "HiCAD";
|
||||||
|
manifest.name = "HiCAD";
|
||||||
|
manifest.icons = [
|
||||||
|
{
|
||||||
|
src: brandedFaviconUrl,
|
||||||
|
sizes: "any",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
function patchOfficialSource() {
|
function patchOfficialSource() {
|
||||||
copyFileSync(
|
copyFileSync(
|
||||||
path.join(customizationDir, "Logo.tsx"),
|
path.join(customizationDir, "Logo.tsx"),
|
||||||
@ -130,6 +147,17 @@ function patchOfficialSource() {
|
|||||||
' <meta name="description" content="An open-source CAD modeling tool from the future by Zoo." />',
|
' <meta name="description" content="An open-source CAD modeling tool from the future by Zoo." />',
|
||||||
' <meta name="description" content="HiCAD browser-based CAD workspace." />'
|
' <meta name="description" content="HiCAD browser-based CAD workspace." />'
|
||||||
);
|
);
|
||||||
|
replaceSource(
|
||||||
|
"index.html",
|
||||||
|
' <link rel="icon" href="/favicon.ico" />',
|
||||||
|
` <link rel="icon" href="${brandedFaviconUrl}" />`
|
||||||
|
);
|
||||||
|
replaceSource(
|
||||||
|
"index.html",
|
||||||
|
' <link rel="apple-touch-icon" href="/logo192.png" />',
|
||||||
|
` <link rel="apple-touch-icon" href="${brandedFaviconUrl}" />`
|
||||||
|
);
|
||||||
|
patchOfficialManifest();
|
||||||
replaceSource(
|
replaceSource(
|
||||||
"index.html",
|
"index.html",
|
||||||
' <script defer data-domain="app.zoo.dev" src="https://plausible.corp.zoo.dev/js/script.tagged-events.js"></script>\n',
|
' <script defer data-domain="app.zoo.dev" src="https://plausible.corp.zoo.dev/js/script.tagged-events.js"></script>\n',
|
||||||
|
|||||||
@ -16,6 +16,26 @@ test.describe("HiCAD embedded startup", () => {
|
|||||||
expect(vendorScript).toContain(latestReviewedOfficialCommit);
|
expect(vendorScript).toContain(latestReviewedOfficialCommit);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("uses the website favicon across embedded browser surfaces", () => {
|
||||||
|
const vendorScript = fs.readFileSync(
|
||||||
|
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
|
||||||
|
"utf8"
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(vendorScript).toContain(
|
||||||
|
'const brandedFaviconUrl = "/api/favicon?surface=hicad"'
|
||||||
|
);
|
||||||
|
expect(vendorScript).toContain(
|
||||||
|
'` <link rel="icon" href="${brandedFaviconUrl}" />`'
|
||||||
|
);
|
||||||
|
expect(vendorScript).toContain(
|
||||||
|
'` <link rel="apple-touch-icon" href="${brandedFaviconUrl}" />`'
|
||||||
|
);
|
||||||
|
expect(vendorScript).toMatch(
|
||||||
|
/manifest\.icons = \[\s*\{\s*src: brandedFaviconUrl,\s*sizes: "any",/
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("suppresses the upstream onboarding chooser in embedded mode", () => {
|
test("suppresses the upstream onboarding chooser in embedded mode", () => {
|
||||||
const vendorScript = fs.readFileSync(
|
const vendorScript = fs.readFileSync(
|
||||||
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
|
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user