Files
twenty/packages/twenty-website/scripts/convert-png-to-webp.mjs
T
Félix Malfait 658bdf3e57 chore(website): rename twenty-website-new → twenty-website (#20745)
## Summary
Follow-up to the Cloudflare/OpenNext migration (#20741). Now that the
legacy `twenty-website` package was already removed in #20270, the
`-new` suffix on the marketing site package is no longer meaningful.

## What changes
- **Directory rename**: `git mv packages/twenty-website-new
packages/twenty-website` (1213 files moved, no content change)
- **Package + nx config**: `package.json` and `project.json` name fields
updated, `sourceRoot` repointed
- **Source refs**: `load-local-articles.ts` and
`load-local-release-notes.ts` had a hardcoded `'twenty-website-new'`
segment in their monorepo-root fallback path;
`app/[locale]/releases/page.tsx` had display strings showing where to
add content
- **External refs**: root `package.json` workspaces, root `CLAUDE.md` /
`README.md`, `twenty-sdk` + `create-twenty-app` READMEs,
`.vscode/twenty.code-workspace`, `.cursor/rules/changelog-process.mdc`,
Crowdin config + the three `website-i18n-*` CI workflows +
`ci-website.yaml`
- **Docker cleanup**:
`packages/twenty-docker/twenty-website-new/Dockerfile` deleted; the two
Makefile targets (`prod-website-new-build` / `prod-website-new-run`)
that referenced it removed — EKS deploy was retired in the Cloudflare
migration
- **`yarn.lock`** regenerated against the new workspace path

## What's deliberately not in this PR
The dev hostname `website-new.twenty-main.com` in `wrangler.jsonc` stays
for now. Migrating it to `website.twenty-main.com` needs coordinated DNS
deletion (current CNAME points at the legacy Docusaurus NLB and serves
503s) and removal of the matching legacy `website` Helm chart in
`twenty-infra`. Flagged as a separate cleanup.

Companion infra PR: https://github.com/twentyhq/twenty-infra/pull/682
(workflow paths + Terraform ECR + docs)

## Test plan
- [x] `yarn install --immutable` resolves clean against the new path
- [x] `npx nx typecheck twenty-website` passes
- [x] `npx nx lint twenty-website` passes
- [ ] CI on this PR confirms the same on a fresh checkout
- [ ] After merge: trigger `Deploy Website` workflow against
`environment=dev` to confirm the renamed working-directory deploys
correctly
2026-05-19 23:42:09 +02:00

57 lines
1.6 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import sharp from 'sharp';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const imagesRoot = path.join(__dirname, '..', 'public', 'images');
const CONVERTIBLE_EXTENSIONS = /\.(png|jpe?g)$/i;
let totalBefore = 0;
let totalAfter = 0;
let count = 0;
async function walkAndConvert(directoryPath) {
for (const entry of fs.readdirSync(directoryPath, { withFileTypes: true })) {
const fullPath = path.join(directoryPath, entry.name);
if (entry.isDirectory()) {
await walkAndConvert(fullPath);
continue;
}
if (!CONVERTIBLE_EXTENSIONS.test(entry.name)) {
continue;
}
const outputPath = fullPath.replace(CONVERTIBLE_EXTENSIONS, '.webp');
const beforeSize = fs.statSync(fullPath).size;
await sharp(fullPath).webp({ quality: 92 }).toFile(outputPath);
const afterSize = fs.statSync(outputPath).size;
fs.unlinkSync(fullPath);
totalBefore += beforeSize;
totalAfter += afterSize;
count++;
const saved = (((beforeSize - afterSize) / beforeSize) * 100).toFixed(1);
const rel = path.relative(imagesRoot, outputPath);
console.log(
`${rel} ${(beforeSize / 1024).toFixed(0)} KB -> ${(afterSize / 1024).toFixed(0)} KB (${saved}% saved)`,
);
}
}
await walkAndConvert(imagesRoot);
console.log('');
console.log(`Converted ${count} files`);
console.log(
`Total: ${(totalBefore / 1048576).toFixed(2)} MiB -> ${(totalAfter / 1048576).toFixed(2)} MiB (${(((totalBefore - totalAfter) / totalBefore) * 100).toFixed(1)}% saved)`,
);