Skip to content

Commit 405256c

Browse files
committed
refactor: NPM project structure with GitHub Pages deployment
1 parent dfc15c0 commit 405256c

32 files changed

Lines changed: 2425 additions & 96 deletions

.github/workflows/deploy.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build
34+
run: npm run build
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: ./dist
40+
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
needs: build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
build/
7+
8+
# Environment variables
9+
.env
10+
.env.local
11+
.env.production
12+
13+
# IDE
14+
.idea/
15+
.vscode/
16+
*.swp
17+
*.swo
18+
19+
# OS
20+
.DS_Store
21+
Thumbs.db
22+
123
# Logs
2-
logs
324
*.log
425
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
pnpm-debug.log*
8-
lerna-debug.log*
926

10-
node_modules
11-
dist
12-
dist-ssr
13-
*.local
27+
# Testing
28+
coverage/
29+
.nyc_output/
1430

15-
# Editor directories and files
16-
.vscode/*
17-
!.vscode/extensions.json
18-
.idea
19-
.DS_Store
20-
*.suo
21-
*.ntvs*
22-
*.njsproj
23-
*.sln
24-
*.sw?
31+
# Temporary
32+
.tmp/
33+
.temp/

README.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,79 @@ PDF Toolkit Pro provides a range of tools to manage your PDF documents directly
1515
- **PDF to JPG**: Convert selected pages of your PDF into high-quality JPG images.
1616
- **PDF to Text**: Extract all text content from a PDF document for easy copying and editing.
1717

18-
## 🚀 Getting Started
18+
## 🚀 Quick Start
1919

20-
This is a client-side application and requires no backend. To run it locally, you can serve the project directory with any static file server.
20+
### Install Dependencies
2121

22-
1. **Download the project files.**
23-
2. **Serve the files.** A simple way is to use a VS Code extension like "Live Server" or a simple command-line server:
24-
```bash
25-
# If you have Python 3
26-
python -m http.server
22+
```bash
23+
npm install
24+
```
2725

28-
# If you have Node.js and the 'serve' package installed
29-
# npm install -g serve
30-
# serve .
31-
```
32-
3. **Open your browser** and navigate to the local server address (e.g., `http://localhost:8000`).
26+
### Development
27+
28+
```bash
29+
npm run dev
30+
```
31+
32+
Open [http://localhost:3000](http://localhost:3000) in your browser.
33+
34+
### Build for Production
35+
36+
```bash
37+
npm run build
38+
```
39+
40+
Preview the production build:
41+
42+
```bash
43+
npm run preview
44+
```
3345

3446
## 🛠️ Built With
3547

3648
- [React](https://reactjs.org/) - A JavaScript library for building user interfaces.
3749
- [TypeScript](https://www.typescriptlang.org/) - A typed superset of JavaScript that compiles to plain JavaScript.
50+
- [Vite](https://vitejs.dev/) - Next generation frontend tooling.
3851
- [Tailwind CSS](https://tailwindcss.com/) - A utility-first CSS framework for rapid UI development.
3952
- [pdf-lib](https://pdf-lib.js.org/) - A JavaScript library for creating and modifying PDF documents.
4053
- [pdf.js](https://mozilla.github.io/pdf.js/) - A Portable Document Format (PDF) viewer that is built with HTML5.
4154
- [JSZip](https://stuk.github.io/jszip/) - A JavaScript library for creating, reading and editing .zip files.
55+
56+
## 📁 Project Structure
57+
58+
```
59+
src/
60+
├── App.tsx # Main application component
61+
├── main.tsx # Application entry point
62+
├── components/ # React components
63+
│ ├── Splitter.tsx # PDF splitting tool
64+
│ ├── Merger.tsx # PDF merging tool
65+
│ ├── Compressor.tsx # PDF compression tool
66+
│ ├── Rotator.tsx # PDF rotation tool
67+
│ ├── PdfToJpg.tsx # PDF to JPG conversion
68+
│ ├── PdfToText.tsx # PDF to text extraction
69+
│ └── ...
70+
├── services/
71+
│ └── pdfUtils.ts # PDF processing utilities
72+
└── hooks/
73+
└── usePdfHandler.ts # PDF handling React hook
74+
```
75+
76+
## 🌐 Deployment
77+
78+
This project is configured for automatic deployment via GitHub Actions to GitHub Pages.
79+
80+
### GitHub Pages Deployment
81+
82+
1. Push this project to a GitHub repository.
83+
2. Go to repository **Settings****Pages**.
84+
3. Under **Source**, select **GitHub Actions**.
85+
4. Push to `main` branch - deployment starts automatically.
86+
87+
Or trigger manually from **Actions** tab → **Deploy to GitHub Pages****Run workflow**.
88+
89+
The live site will be available at: `https://[username].github.io/[repo-name]/`
90+
91+
## 📝 License
92+
93+
MIT License

eslint.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import tseslint from '@typescript-eslint/eslint-plugin';
6+
import tsParser from '@typescript-eslint/parser';
7+
8+
export default tseslint.config(
9+
{ ignores: ['dist', 'node_modules'] },
10+
{
11+
extends: [js.configs.recommended],
12+
files: ['**/*.{ts,tsx}'],
13+
languageOptions: {
14+
ecmaVersion: 2020,
15+
globals: globals.browser,
16+
parser: tsParser,
17+
parserOptions: {
18+
ecmaVersion: 'latest',
19+
sourceType: 'module',
20+
},
21+
},
22+
plugins: {
23+
'react-hooks': reactHooks,
24+
'react-refresh': reactRefresh,
25+
},
26+
rules: {
27+
...reactHooks.configs.recommended.rules,
28+
'react-refresh/only-export-components': [
29+
'warn',
30+
{ allowConstantExport: true },
31+
],
32+
'@typescript-eslint/no-explicit-any': 'warn',
33+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
34+
},
35+
},
36+
);

index.html

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>
54
<meta charset="UTF-8" />
65
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
76
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
87
<title>PDF Toolkit Pro</title>
9-
<script src="https://cdn.tailwindcss.com"></script>
10-
<script src="https://unpkg.com/pdf-lib@1.17.1/dist/pdf-lib.min.js"></script>
11-
<script src="https://unpkg.com/jszip@3.10.1/dist/jszip.min.js"></script>
12-
<script src="https://unpkg.com/downloadjs@1.4.7/download.js"></script>
13-
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
14-
<script>
15-
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js';
16-
</script>
178
<style>
189
body {
19-
font-family: 'Inter', sans-serif;
10+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
2011
}
21-
@import url('https://rsms.me/inter/inter.css');
2212

2313
@keyframes shake {
2414
10%, 90% { transform: translate3d(-1px, 0, 0); }
@@ -46,18 +36,9 @@
4636
animation: fade-in 0.5s ease-out forwards;
4737
}
4838
</style>
49-
<script type="importmap">
50-
{
51-
"imports": {
52-
"react/": "https://aistudiocdn.com/react@^19.2.0/",
53-
"react": "https://aistudiocdn.com/react@^19.2.0",
54-
"react-dom/": "https://aistudiocdn.com/react-dom@^19.2.0/"
55-
}
56-
}
57-
</script>
58-
</head>
39+
</head>
5940
<body class="bg-slate-50 text-slate-800">
6041
<div id="root"></div>
61-
<script type="module" src="/index.tsx"></script>
42+
<script type="module" src="/src/main.tsx"></script>
6243
</body>
63-
</html>
44+
</html>

package.json

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
{
22
"name": "pdf-toolkit-pro",
33
"version": "1.0.0",
4-
"description": "A powerful and beautiful web application to split, merge, and edit PDF files with ease. Upload your files to get started with a suite of useful PDF tools.",
4+
"description": "A powerful and beautiful web application to split, merge, and edit PDF files with ease.",
5+
"type": "module",
56
"private": true,
67
"scripts": {
7-
"start": "echo \"Serve the project root folder with a static file server.\" && exit 1"
8+
"dev": "vite",
9+
"build": "tsc -b && vite build",
10+
"preview": "vite preview",
11+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
12+
"lint:fix": "eslint . --ext ts,tsx --fix",
13+
"test": "vitest run",
14+
"test:watch": "vitest",
15+
"test:coverage": "vitest run --coverage"
16+
},
17+
"dependencies": {
18+
"react": "^18.3.1",
19+
"react-dom": "^18.3.1",
20+
"pdf-lib": "^1.17.1",
21+
"pdfjs-dist": "^4.9.155",
22+
"jszip": "^3.10.1",
23+
"downloadjs": "^1.4.7"
24+
},
25+
"devDependencies": {
26+
"@types/react": "^18.3.12",
27+
"@types/react-dom": "^18.3.1",
28+
"@types/downloadjs": "^1.4.3",
29+
"@typescript-eslint/eslint-plugin": "^8.15.0",
30+
"@typescript-eslint/parser": "^8.15.0",
31+
"@vitejs/plugin-react": "^4.3.4",
32+
"autoprefixer": "^10.4.20",
33+
"eslint": "^9.15.0",
34+
"eslint-plugin-react-hooks": "^5.0.0",
35+
"eslint-plugin-react-refresh": "^0.4.14",
36+
"postcss": "^8.4.49",
37+
"tailwindcss": "^3.4.15",
38+
"typescript": "~5.6.2",
39+
"vite": "^6.0.1",
40+
"vitest": "^2.1.8"
841
},
942
"keywords": [
1043
"pdf",

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

src/App.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React, { useState } from 'react';
2+
import Header from './components/Header';
3+
import Splitter from './components/Splitter';
4+
import Merger from './components/Merger';
5+
import Compressor from './components/Compressor';
6+
import Rotator from './components/Rotator';
7+
import PdfToJpg from './components/PdfToJpg';
8+
import PdfToText from './components/PdfToText';
9+
10+
type Tool = 'split' | 'merge' | 'compress' | 'rotate' | 'pdf-to-jpg' | 'pdf-to-text';
11+
12+
const App: React.FC = () => {
13+
const [activeTool, setActiveTool] = useState<Tool>('split');
14+
15+
const renderTool = () => {
16+
switch (activeTool) {
17+
case 'split':
18+
return <Splitter />;
19+
case 'merge':
20+
return <Merger />;
21+
case 'compress':
22+
return <Compressor />;
23+
case 'rotate':
24+
return <Rotator />;
25+
case 'pdf-to-jpg':
26+
return <PdfToJpg />;
27+
case 'pdf-to-text':
28+
return <PdfToText />;
29+
default:
30+
return <Splitter />;
31+
}
32+
};
33+
34+
return (
35+
<div className="min-h-screen bg-slate-50 flex flex-col items-center">
36+
<main className="container mx-auto p-4 md:p-8 w-full max-w-6xl">
37+
<div className="text-center mb-8">
38+
<h1 className="text-4xl md:text-5xl font-extrabold text-slate-800">
39+
PDF Toolkit <span className="text-blue-600">Pro</span>
40+
</h1>
41+
<p className="mt-4 text-lg text-slate-500">
42+
Your one-stop solution for splitting, merging, and editing PDF documents effortlessly.
43+
</p>
44+
</div>
45+
46+
<div className="bg-white rounded-xl shadow-2xl shadow-slate-200 ring-1 ring-slate-100 p-2">
47+
<Header activeTool={activeTool} setActiveTool={setActiveTool} />
48+
<div className="p-4 sm:p-8">
49+
{renderTool()}
50+
</div>
51+
</div>
52+
53+
<footer className="text-center mt-12 text-slate-400 text-sm">
54+
<p>&copy; {new Date().getFullYear()} PDF Toolkit Pro. All Rights Reserved.</p>
55+
</footer>
56+
</main>
57+
</div>
58+
);
59+
};
60+
61+
export default App;

0 commit comments

Comments
 (0)