Skip to content

Commit 56d34e1

Browse files
authored
Merge pull request #1 from kyleaupton/develop
feat: add ability to define multiple PDF variants
2 parents 84403e9 + 89f8b59 commit 56d34e1

File tree

123 files changed

+1852
-726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1852
-726
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = {
2727
project: './tsconfig.json',
2828
},
2929
rules: {
30+
'import/extensions': 0,
3031
'@typescript-eslint/explicit-function-return-type': 0,
3132
'@typescript-eslint/strict-boolean-expressions': 0,
3233
'@typescript-eslint/ban-ts-comment': 0,

.github/workflows/build.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ jobs:
2222
env:
2323
NODE_ENV: development
2424

25-
- name: Build PDF
26-
run: yarn build
27-
28-
- name: Upload PDF
29-
run: yarn upload
25+
- name: Build + Upload PDFs
26+
run: npm run build --deploy
3027
env:
3128
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
3229
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
# Professional Resume of Kyle Upton
1+
# Resume of Kyle Upton
22

33
[![Build Status](https://github.com/kyleaupton/resume/actions/workflows/build.yml/badge.svg)](https://github.com/kyleaupton/resume/actions/workflows/build.yml)
44

55
## Introduction
66

7-
Welcome to the repository that hosts the source code for my professional resume. This project, built using React, compiles into a PDF file for easy distribution and printing. The PDF generation is handled by a package known as [`react-pdf/renderer`](https://www.npmjs.com/package/@react-pdf/renderer).
8-
9-
## User Interface
10-
11-
Despite being a React-based project, it's important to note that not all HTML and CSS can be directly translated into a PDF. The `react-pdf/renderer` package necessitates that all template code adheres to the [`React primitives`](https://github.com/lelandrichardson/react-primitives) specification.
7+
This is the repository that hosts the source code for my resume. This project, built using React, renders to a PDF file for easy distribution and printing. The PDF generation is done by [`react-pdf/renderer`](https://www.npmjs.com/package/@react-pdf/renderer).
128

139
## Continuous Deployment
1410

15-
The project is set up with a continuous deployment pipeline. Upon every commit to the `main` branch, a GitHub action is triggered. This action builds the PDF and subsequently uploads it to a publicly accessible AWS S3 bucket, from where it can be downloaded.
11+
The project is set up with a continuous deployment pipeline. Upon every commit to the `main` branch, a GitHub action is triggered. This action builds the PDF and uploads it to a publicly accessible AWS S3 bucket, from where it can be downloaded.
1612

17-
## Development Server Configuration
13+
## Development Server
1814

1915
To set up the development server, execute the following commands:
2016

@@ -23,3 +19,17 @@ yarn install
2319

2420
yarn dev
2521
```
22+
23+
## Deploy PDFs
24+
25+
```bash
26+
yarn build --deploy
27+
```
28+
29+
## Build PDFs
30+
31+
Sometimes it is helpful to build the PDFs and not deploy them. You can do that with the following:
32+
33+
```bash
34+
yarn build
35+
```

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite --open",
8-
"build": "npx tsx src/build.ts",
9-
"upload": "node scripts/upload.mjs"
8+
"checkTypes": "tsc --noEmit",
9+
"build": "tsx scripts/build.ts",
10+
"deploy": "tsx scripts/build.ts --deploy"
1011
},
1112
"dependencies": {
1213
"@react-pdf/renderer": "^3.1.13",
@@ -35,7 +36,7 @@
3536
"eslint-plugin-react-hooks": "^4.3.0",
3637
"eslint-plugin-react-refresh": "^0.4.3",
3738
"tsx": "^4.1.3",
38-
"typescript": "*",
39+
"typescript": "^5.6.2",
3940
"vite": "^4.4.5"
4041
}
4142
}

public/attempt-2-min.png

-1.01 MB
Binary file not shown.

scripts/build.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import fs from 'node:fs/promises';
2+
import { createReadStream } from 'node:fs';
3+
import path from 'node:path';
4+
import url from 'node:url';
5+
import { renderToFile } from '@react-pdf/renderer';
6+
import { S3Client, PutObjectCommand, HeadObjectCommand } from '@aws-sdk/client-s3'
7+
import 'dotenv/config'
8+
9+
const BUCKET = 'upton-public-assets';
10+
const PREFIX = 'resumes';
11+
12+
// Env validation
13+
const requiredEnv = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']
14+
for (const item of requiredEnv) {
15+
if (!process.env[item]) {
16+
throw Error(`Missing env item ${item}`)
17+
}
18+
}
19+
20+
// Create S3 client
21+
const client = new S3Client({
22+
region: 'us-east-1',
23+
})
24+
25+
//
26+
// Helpers
27+
//
28+
const key = (pdfName: string) => {
29+
return `${PREFIX}/${pdfName}`;
30+
}
31+
32+
//
33+
// Main
34+
//
35+
const __project = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..');
36+
const __pdfs = path.join(__project, 'src', 'variants');
37+
const __dist = path.join(__project, 'dist');
38+
39+
// Ensure dist directory exists
40+
await fs.mkdir(__dist, { recursive: true });
41+
42+
// Get list of PDFs to render
43+
const pdfs = await fs.readdir(__pdfs);
44+
45+
for (const pdf of pdfs) {
46+
const name = `${pdf}.pdf`
47+
console.log('Processing', name);
48+
49+
const __out = path.join(__project, 'dist', name);
50+
const PDF = (await import(path.join(__pdfs, pdf))).default;
51+
await renderToFile(PDF(), __out);
52+
53+
console.log('Rendered', __out);
54+
55+
if (process.argv.includes('--deploy')) {
56+
console.log('Uploading', name);
57+
await client.send(
58+
new PutObjectCommand({
59+
Bucket: BUCKET,
60+
Key: key(name),
61+
ContentDisposition: 'inline',
62+
ContentType: 'application/pdf',
63+
Body: createReadStream(__out)
64+
})
65+
);
66+
}
67+
68+
console.log('Done', name);
69+
console.log('-'.repeat(80));
70+
}

scripts/upload.mjs

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/build.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/components/Divider.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)