Repository navigation
Expand file tree
/
Copy pathcreate_cv.js
More file actions
316 lines (288 loc) · 14.5 KB
/
Copy pathcreate_cv.js
File metadata and controls
316 lines (288 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
Header, Footer, AlignmentType, LevelFormat, BorderStyle, WidthType,
TabStopType, ShadingType, VerticalAlign, PageNumber, PageBreak, ImageRun, ExternalHyperlink } = require('docx');
const fs = require('fs');
const path = require('path');
// Usage: node create_cv.js <de|en|es|pt> [--personal]
const LANGUAGES = ['de', 'en', 'es', 'pt'];
const lang = process.argv[2];
if (!LANGUAGES.includes(lang)) {
console.error(`Usage: node create_cv.js <${LANGUAGES.join('|')}> [--personal]`);
process.exit(1);
}
const LANG = lang.toUpperCase();
// --personal: no twiceD branding/intro, output Daniel_Deusing_*.docx
const personal = process.argv.includes('--personal');
const data = JSON.parse(fs.readFileSync(path.join(__dirname, 'data', `cv.${lang}.json`), 'utf8'));
// twiceD Brand Colors
const BRAND = {
primary: "1E3A5F",
accent: "D0520F",
dark: "2D4A6F",
gray: "666666",
lightGray: "F5F5F5"
};
const noBorder = { style: BorderStyle.NONE, size: 0, color: "FFFFFF" };
const noBorders = { top: noBorder, bottom: noBorder, left: noBorder, right: noBorder };
const formatPeriod = (entry) => entry.to ? `${entry.from} – ${entry.to}` : entry.from;
const socialLinks = data.person.socials.flatMap((social, index) => [
...(index > 0 ? [new TextRun({ text: " | ", color: BRAND.gray, size: 18, font: "Nunito" })] : []),
new ImageRun({ data: fs.readFileSync(path.join(__dirname, 'logo', social.icon)), transformation: { width: 9, height: 9 }, type: 'png' }),
new TextRun({ text: " ", size: 18 }),
new ExternalHyperlink({ link: social.url, children: [
new TextRun({ text: social.network, color: BRAND.primary, size: 18, font: "Nunito" })
]})
]);
const skillsRows = data.skills.map((skill, index) => {
const shading = index % 2 === 1 ? { fill: BRAND.lightGray, type: ShadingType.CLEAR } : undefined;
return new TableRow({ children: [
new TableCell({ borders: noBorders, width: { size: 2800, type: WidthType.DXA }, shading, children: [
new Paragraph({ spacing: { before: 40, after: 40 }, children: [new TextRun({ text: skill.category, bold: true, color: BRAND.primary, font: "Nunito", size: 20 })] })
]}),
new TableCell({ borders: noBorders, width: { size: 7200, type: WidthType.DXA }, shading, children: [
new Paragraph({ spacing: { before: 40, after: 40 }, children: [new TextRun({ text: skill.items.join(", "), font: "Nunito", size: 20 })] })
]})
]});
});
const projectBlocks = data.projects.flatMap(project => [
new Paragraph({ style: "ProjectTitle", children: [new TextRun(project.title)] }),
new Paragraph({ style: "CompanyRole", children: [new TextRun(`${project.client} | ${project.role} | ${formatPeriod(project)}`)] }),
new Paragraph({ children: [new TextRun({ text: project.description, font: "Nunito", size: 20 })] }),
...project.bullets.map(bullet =>
new Paragraph({ numbering: { reference: "project-bullets", level: 0 }, children: [new TextRun({ text: bullet, font: "Nunito", size: 20 })] })
),
new Paragraph({ spacing: { after: 40 }, children: [
new TextRun({ text: data.labels.techPrefix, bold: true, color: BRAND.gray, font: "Nunito", size: 18 }),
new TextRun({ text: project.technologies.join(", "), color: BRAND.gray, font: "Nunito", size: 18 })
]})
]);
const strengthBlocks = data.strengths.map(strength =>
new Paragraph({ numbering: { reference: "project-bullets", level: 0 }, children: [
new TextRun({ text: `${strength.title} – `, bold: true, color: BRAND.primary, font: "Nunito", size: 20 }),
new TextRun({ text: strength.text, font: "Nunito", size: 20 })
]})
);
const employmentRows = data.employment.map(job =>
new TableRow({ children: [
new TableCell({ borders: noBorders, width: { size: 2000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: formatPeriod(job), bold: true, color: BRAND.primary, font: "Nunito", size: 20 })] })
]}),
new TableCell({ borders: noBorders, width: { size: 8000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: job.role, bold: true, font: "Nunito" })] }),
new Paragraph({ children: [new TextRun({ text: job.company, color: BRAND.accent, font: "Nunito", size: 20 })] })
]})
]})
);
const educationRows = data.education.map(entry =>
new TableRow({ children: [
new TableCell({ borders: noBorders, width: { size: 2000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: entry.year, bold: true, color: BRAND.primary, font: "Nunito", size: 20 })] })
]}),
new TableCell({ borders: noBorders, width: { size: 8000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: entry.degree, bold: true, font: "Nunito" })] }),
new Paragraph({ children: [new TextRun({ text: entry.institution, color: BRAND.accent, font: "Nunito", size: 20 })] }),
new Paragraph({ children: [new TextRun({ text: entry.thesis, italics: true, color: BRAND.gray, font: "Nunito", size: 18 })] })
]})
]})
);
const certificateRows = data.certificates.map(certificate =>
new TableRow({ children: [
new TableCell({ borders: noBorders, width: { size: 2000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: certificate.year, bold: true, color: BRAND.primary, font: "Nunito", size: 20 })] })
]}),
new TableCell({ borders: noBorders, width: { size: 8000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: certificate.title, bold: true, font: "Nunito" })] }),
...(certificate.details ? [new Paragraph({ children: [new TextRun({ text: certificate.details, color: BRAND.gray, font: "Nunito", size: 20 })] })] : [])
]})
]})
);
const awardRows = data.awards.map(award =>
new TableRow({ children: [
new TableCell({ borders: noBorders, width: { size: 2000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: award.year, bold: true, color: BRAND.primary, font: "Nunito", size: 20 })] })
]}),
new TableCell({ borders: noBorders, width: { size: 8000, type: WidthType.DXA }, children: [
new Paragraph({ children: [new TextRun({ text: award.title, bold: true, font: "Nunito" })] }),
new Paragraph({ children: [new TextRun({ text: award.details, color: BRAND.gray, font: "Nunito", size: 20 })] })
]})
]})
);
const languageCells = data.languages.map(entry =>
new TableCell({ borders: noBorders, width: { size: 2000, type: WidthType.DXA }, children: [
new Paragraph({ alignment: AlignmentType.LEFT, children: [new TextRun({ text: entry.language, bold: true, font: "Nunito" })] }),
new Paragraph({ alignment: AlignmentType.LEFT, children: [new TextRun({ text: entry.level, color: entry.muted ? BRAND.gray : BRAND.accent, font: "Nunito", size: 20 })] })
]})
);
const doc = new Document({
styles: {
default: { document: { run: { font: "Nunito", size: 22 } } },
paragraphStyles: [
{ id: "Name", name: "Name", basedOn: "Normal",
run: { size: 56, bold: true, color: BRAND.primary, font: "Nunito" },
paragraph: { spacing: { after: 60 } } },
{ id: "Title", name: "Title", basedOn: "Normal",
run: { size: 28, color: BRAND.accent, font: "Nunito" },
paragraph: { spacing: { after: 200 } } },
{ id: "SectionHeader", name: "SectionHeader", basedOn: "Normal",
run: { size: 26, bold: true, color: BRAND.primary, font: "Nunito", allCaps: true },
paragraph: { spacing: { before: 400, after: 150 } } },
{ id: "ProjectTitle", name: "ProjectTitle", basedOn: "Normal",
run: { size: 24, bold: true, color: BRAND.dark, font: "Nunito" },
paragraph: { spacing: { before: 340, after: 60 } } },
{ id: "CompanyRole", name: "CompanyRole", basedOn: "Normal",
run: { size: 22, color: BRAND.accent, font: "Nunito" },
paragraph: { spacing: { after: 60 } } },
{ id: "Normal", name: "Normal",
run: { size: 22, color: "333333", font: "Nunito" },
paragraph: { spacing: { after: 60 } } }
]
},
numbering: {
config: [
{ reference: "project-bullets",
levels: [{ level: 0, format: LevelFormat.BULLET, text: "•", alignment: AlignmentType.LEFT,
style: { paragraph: { indent: { left: 360, hanging: 200 } } } }] }
]
},
sections: [{
properties: {
page: { margin: { top: 720, right: 720, bottom: 720, left: 720 } }
},
headers: {
default: new Header({ children: [] })
},
footers: {
default: new Footer({ children: [
new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun({ text: data.labels.footerPagePrefix, color: BRAND.gray, size: 18, font: "Nunito" }),
new TextRun({ children: [PageNumber.CURRENT], color: BRAND.gray, size: 18, font: "Nunito" }),
...(personal ? [] : [new TextRun({ text: ` | ${data.company.email} | ${data.company.phone}`, color: BRAND.gray, size: 18, font: "Nunito" })])
]
})
]})
},
children: [
// === HEADER SECTION ===
new Table({
columnWidths: [6500, 3500],
rows: [
new TableRow({
children: [
new TableCell({
borders: noBorders,
width: { size: 6500, type: WidthType.DXA },
verticalAlign: VerticalAlign.CENTER,
children: [
new Paragraph({ style: "Name", children: [new TextRun(data.person.name)] }),
new Paragraph({ style: "Title", children: [new TextRun(data.person.title)] }),
new Paragraph({ children: [
new TextRun({ text: data.person.location, color: BRAND.gray, size: 20, font: "Nunito" })
]}),
new Paragraph({ spacing: { before: 60 }, children: socialLinks })
]
}),
new TableCell({
borders: noBorders,
width: { size: 3500, type: WidthType.DXA },
verticalAlign: VerticalAlign.TOP,
children: personal ? [new Paragraph({ children: [] })] : [
new Paragraph({ alignment: AlignmentType.RIGHT, spacing: { before: 160 }, children: [
new ImageRun({
data: fs.readFileSync(path.join(__dirname, 'logo', 'blue_D_1E3A5F.png')),
transformation: { width: 46, height: 46 },
type: 'png'
})
]}),
new Paragraph({ alignment: AlignmentType.RIGHT, spacing: { before: 40 }, children: [
new TextRun({ text: data.company.brandName, bold: true, color: BRAND.primary, size: 20, font: "Nunito" }),
new TextRun({ text: data.company.brandSuffix, color: BRAND.gray, size: 20, font: "Nunito" })
]})
]
})
]
})
]
}),
// Divider
new Paragraph({
spacing: { before: 200, after: 200 },
border: { bottom: { style: BorderStyle.SINGLE, size: 8, color: BRAND.accent } },
children: []
}),
// === TWICED (omitted in personal variant) ===
...(personal ? [] : [
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.company.name)] }),
...data.company.intro.map(paragraph => new Paragraph({ children: [
new TextRun({ text: paragraph, font: "Nunito", size: 22 })
]})),
new Paragraph({ spacing: { after: 60 }, children: [
new TextRun({ text: data.company.overviewNote.prefix, font: "Nunito", size: 22 }),
new ExternalHyperlink({ link: data.company.overviewNote.url, children: [
new TextRun({ text: data.company.overviewNote.linkText, font: "Nunito", color: BRAND.primary, size: 22 })
]}),
new TextRun({ text: data.company.overviewNote.suffix, font: "Nunito", size: 22 })
]})
]),
// === PROFILE ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(personal ? data.labels.sections.profilePersonal : data.labels.sections.profile)] }),
...data.profile.map(runs => new Paragraph({
children: runs.map(run => new TextRun({ text: run.text, bold: run.bold, font: "Nunito" }))
})),
// === KEY STRENGTHS ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.strengths)] }),
...strengthBlocks,
// === TECHNICAL SKILLS ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.skills)] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
columnWidths: [2800, 7200],
rows: skillsRows
}),
// === SELECTED PROJECTS ===
new Paragraph({ children: [new PageBreak()] }),
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.projects)] }),
new Paragraph({ spacing: { after: 200 }, children: [
new TextRun({ text: personal ? data.projectsNotePersonal : data.projectsNote, font: "Nunito", color: BRAND.gray, size: 20 })
]}),
...projectBlocks,
// === EMPLOYMENT ===
new Paragraph({ children: [new PageBreak()] }),
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.employment)] }),
new Table({
columnWidths: [2000, 8000],
rows: employmentRows
}),
// === EDUCATION ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.education)] }),
new Table({
columnWidths: [2000, 8000],
rows: educationRows
}),
// === CERTIFICATIONS ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.certificates)] }),
new Table({
columnWidths: [2000, 8000],
rows: certificateRows
}),
// === AWARDS ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.awards)] }),
new Table({
columnWidths: [2000, 8000],
rows: awardRows
}),
// === LANGUAGES ===
new Paragraph({ style: "SectionHeader", children: [new TextRun(data.labels.sections.languages)] }),
new Table({
columnWidths: [2000, 2000, 2000, 2000, 2000],
rows: [new TableRow({ children: languageCells })]
})
]
}]
});
const outputFile = `${personal ? "" : "TD_"}Daniel_Deusing_${LANG}.docx`;
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync(path.join(__dirname, outputFile), buffer);
console.log(`${LANG} CV created: ${outputFile}`);
});