mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 18:44:05 +02:00
## Move editor under `frontend/editor/`
Pure restructure: `frontend/` becomes the workspace, `frontend/editor/`
holds
the PDF editor. 1775 file renames + 40 wiring edits. No logic changes.
### Why
`frontend/` is currently the editor — its `src/`, `public/`,
`src-tauri/`,
config files all sit at the root. Promoting `frontend/` to a
workspace and putting the editor in a sibling folder leaves room for
future
apps to drop in alongside it, sharing one `package.json` /
`node_modules` /
lint config / Storybook.
### What moves
frontend/
├── editor/ ← NEW: everything editor-specific
│ ├── src/ ← was frontend/src/
│ ├── public/ ← was frontend/public/
│ ├── src-tauri/ ← was frontend/src-tauri/
│ ├── index.html, vite.config.ts, vitest.config.ts, playwright.config.ts
│ ├── tsconfig*.json, tailwind.config.js, postcss.config.js
│ ├── scripts/
│ ├── .env, .env.desktop, .env.saas
│ └── DeveloperGuide.md
├── package.json, package-lock.json, node_modules/ ← workspace install
├── eslint.config.mjs, .prettierrc, .prettierignore ← shared tooling
├── .gitignore
└── README.md
### Wiring edits (40 files)
- `.taskfiles/frontend.yml`, `desktop.yml`, `e2e.yml`
- `build.gradle`, `app/core/build.gradle`
- `eslint.config.mjs`, `frontend/package.json`, `.gitignore`,
`.prettierignore`
- `docker/frontend/Dockerfile`
- 8 `.github/workflows/*.yml`, plus `.github/dependabot.yml`,
`.github/config/.files.yaml`, `.github/labeler-config-srvaroa.yml`
- `scripts/translations/**`
- Docs: `AGENTS.md`, `CLAUDE.md`, `ADDING_TOOLS.md`,
`DeveloperGuide.md`,
`WINDOWS_SIGNING.md`, `devGuide/HowToAddNewLanguage.md`,
`frontend/README.md`,
`frontend/editor/DeveloperGuide.md`
Plus 3 renamed + edited: `editor/vite.config.ts` (env path +
node_modules
walk-up), `editor/scripts/setup-env.mts` (renamed from `.ts` for
`import.meta.url`), `editor/scripts/build-provisioner.mjs` (resolve
src-tauri
relative to script).
### Verification
| Check | Result |
|---|---|
| `task frontend:typecheck:all` (6 variants) | exit 0 |
| `task frontend:lint` (eslint + dpdm) | exit 0 |
| `task frontend:format:check` | exit 0 |
| `task frontend:test` | 657 tests pass, 50 files |
| `task frontend:build:{core,proprietary,saas,desktop,prototypes}` | all
green |
| `task desktop:build` | full Tauri pipeline →
`Stirling-PDF_2.11.0_x64_en-US.msi` |
| `playwright test --list --project=stubbed` | 172 tests discovered |
`task desktop:build` exercises the heaviest path — Rust + WiX + MSI
bundle
against the moved `editor/src-tauri/`. If anything in the restructure
was
wrong it wouldn't have built.
### Test plan
- [ ] `frontend-validation.yml` green
- [ ] `e2e-stubbed.yml` green
- [ ] `tauri-build.yml` green on at least one platform
- [ ] `check_toml.yml` runs on a translation-touching PR
---------
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
105 lines
2.9 KiB
JavaScript
Executable File
105 lines
2.9 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Stirling PDF Sample Document Generator
|
|
*
|
|
* This script uses Puppeteer to generate a sample PDF from a HTML template.
|
|
* The output is used in the onboarding tour and as a demo document
|
|
* for users to experiment with Stirling PDF's features.
|
|
*/
|
|
|
|
import puppeteer from "puppeteer";
|
|
import { fileURLToPath } from "url";
|
|
import { dirname, join } from "path";
|
|
import { existsSync, mkdirSync, statSync } from "fs";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
const TEMPLATE_PATH = join(__dirname, "template.html");
|
|
const OUTPUT_DIR = join(__dirname, "../../public/samples");
|
|
const OUTPUT_PATH = join(OUTPUT_DIR, "Sample.pdf");
|
|
|
|
async function generatePDF() {
|
|
console.log("🚀 Starting Stirling PDF sample document generation...\n");
|
|
|
|
// Ensure output directory exists
|
|
if (!existsSync(OUTPUT_DIR)) {
|
|
mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
console.log(`✅ Created output directory: ${OUTPUT_DIR}`);
|
|
}
|
|
|
|
// Check if template exists
|
|
if (!existsSync(TEMPLATE_PATH)) {
|
|
console.error(`❌ Template file not found: ${TEMPLATE_PATH}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`📄 Reading template: ${TEMPLATE_PATH}`);
|
|
|
|
let browser;
|
|
try {
|
|
// Launch Puppeteer
|
|
console.log("🌐 Launching browser...");
|
|
browser = await puppeteer.launch({
|
|
headless: "new",
|
|
args: ["--no-sandbox", "--disable-setuid-sandbox"],
|
|
});
|
|
|
|
const page = await browser.newPage();
|
|
|
|
// Set viewport to match A4 proportions
|
|
await page.setViewport({
|
|
width: 794, // A4 width in pixels at 96 DPI
|
|
height: 1123, // A4 height in pixels at 96 DPI
|
|
deviceScaleFactor: 2, // Higher quality rendering
|
|
});
|
|
|
|
// Navigate to the template file
|
|
const fileUrl = `file://${TEMPLATE_PATH}`;
|
|
console.log("📖 Loading HTML template...");
|
|
await page.goto(fileUrl, {
|
|
waitUntil: "networkidle0", // Wait for all resources to load
|
|
});
|
|
|
|
// Generate PDF with A4 dimensions
|
|
console.log("📝 Generating PDF...");
|
|
await page.pdf({
|
|
path: OUTPUT_PATH,
|
|
format: "A4",
|
|
printBackground: true,
|
|
margin: {
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
},
|
|
preferCSSPageSize: true,
|
|
});
|
|
|
|
console.log("\n✅ PDF generated successfully!");
|
|
console.log(`📦 Output: ${OUTPUT_PATH}`);
|
|
|
|
// Get file size
|
|
const stats = statSync(OUTPUT_PATH);
|
|
const fileSizeInKB = (stats.size / 1024).toFixed(2);
|
|
console.log(`📊 File size: ${fileSizeInKB} KB`);
|
|
} catch (error) {
|
|
console.error("\n❌ Error generating PDF:", error.message);
|
|
process.exit(1);
|
|
} finally {
|
|
if (browser) {
|
|
await browser.close();
|
|
console.log("🔒 Browser closed.");
|
|
}
|
|
}
|
|
|
|
console.log("\n🎉 Done! Sample PDF is ready for use in Stirling PDF.\n");
|
|
}
|
|
|
|
// Run the generator
|
|
generatePDF().catch((error) => {
|
|
console.error("Fatal error:", error);
|
|
process.exit(1);
|
|
});
|