-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nikolai Dorofeev
committed
Jun 15, 2024
1 parent
9a6d6a3
commit 94cb7cb
Showing
16 changed files
with
148 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { TypeOf } from "zod"; | ||
import { ofetch } from "ofetch"; | ||
import { ResumeListSchema } from "../../models/ResumeList"; | ||
import { TypeOf } from 'zod' | ||
import { ofetch } from 'ofetch' | ||
import { ResumeListSchema } from '../../models/ResumeList' | ||
|
||
export async function collectResumeList() { | ||
const response = await ofetch<TypeOf<typeof ResumeListSchema>>("https://d0rich.me/api/resume/list"); | ||
return ResumeListSchema.parse(response); | ||
const response = await ofetch<TypeOf<typeof ResumeListSchema>>( | ||
'https://d0rich.me/api/resume/list' | ||
) | ||
return ResumeListSchema.parse(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import {z} from 'zod'; | ||
import { z } from 'zod' | ||
|
||
export const ResumeSchema = z.object({ | ||
title: z.string(), | ||
path: z.string() | ||
}); | ||
}) | ||
|
||
export const ResumeListSchema = z.array(ResumeSchema); | ||
export const ResumeListSchema = z.array(ResumeSchema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { launch, type Browser } from "puppeteer"; | ||
import { launch, type Browser } from 'puppeteer' | ||
|
||
export class BrowserStore { | ||
private static browser: Browser | Promise<Browser> = launch(); | ||
private static browser: Browser | Promise<Browser> = launch() | ||
|
||
private constructor() {} | ||
|
||
static async getBrowser(): Promise<Browser> { | ||
if (BrowserStore.browser instanceof Promise) { | ||
BrowserStore.browser = await BrowserStore.browser; | ||
BrowserStore.browser = await BrowserStore.browser | ||
} | ||
return BrowserStore.browser; | ||
return BrowserStore.browser | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { createStorage } from "unstorage"; | ||
import fsDriver from "unstorage/drivers/fs"; | ||
import { createStorage } from 'unstorage' | ||
import fsDriver from 'unstorage/drivers/fs' | ||
|
||
export const dist = createStorage({ | ||
driver: fsDriver({ base: "./dist" }), | ||
}); | ||
driver: fsDriver({ base: './dist' }) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,63 @@ | ||
#!/usr/bin/env node | ||
import fs from "fs"; | ||
import path from 'path'; | ||
import { runWebGenerator } from './webApp'; | ||
import { workingStorage } from "./storage.js"; | ||
import { getFaviconIco, getOgImageJpeg } from "./generators/index.js"; | ||
import { program } from "commander"; | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { runWebGenerator } from './webApp' | ||
import { workingStorage } from './storage.js' | ||
import { getFaviconIco, getOgImageJpeg } from './generators/index.js' | ||
import chalk from 'chalk' | ||
import { program } from 'commander' | ||
|
||
const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json/"), 'utf8')); | ||
const packageJson = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, '../package.json/'), 'utf8') | ||
) | ||
|
||
program | ||
.version(packageJson.version) | ||
.description(packageJson.description) | ||
program.version(packageJson.version).description(packageJson.description) | ||
|
||
interface GenOptions { | ||
title?: string; | ||
description?: string; | ||
title?: string | ||
description?: string | ||
} | ||
|
||
program.command('gen', { isDefault: true }) | ||
program | ||
.command('gen', { isDefault: true }) | ||
.description('Generate images') | ||
.option('-t, --title <title>', 'Title', undefined) | ||
.option('-d, --description <description>', 'Description', undefined) | ||
.action(async (options: GenOptions) => { | ||
const { default: inquirer } = await import('inquirer'); | ||
const title: string = options.title || (await inquirer.prompt({ | ||
type: 'input', | ||
name: 'title', | ||
message: 'Title' | ||
})).title; | ||
const { default: inquirer } = await import('inquirer') | ||
const title: string = | ||
options.title || | ||
( | ||
await inquirer.prompt({ | ||
type: 'input', | ||
name: 'title', | ||
message: 'Title' | ||
}) | ||
).title | ||
console.log(`🐶 Title: ${title}`) | ||
const description: string = options.description || (await inquirer.prompt({ | ||
type: 'input', | ||
name: 'description', | ||
message: 'Description' | ||
})).description; | ||
const description: string = | ||
options.description || | ||
( | ||
await inquirer.prompt({ | ||
type: 'input', | ||
name: 'description', | ||
message: 'Description' | ||
}) | ||
).description | ||
console.log(`🐶 Description: ${description}`) | ||
console.log('🐶 Generating images...') | ||
const favicon = await getFaviconIco({ title }) | ||
const ogImage = await getOgImageJpeg({ title, description }) | ||
await workingStorage.setItemRaw('favicon.ico', favicon) | ||
await workingStorage.setItemRaw('og:image.jpg', ogImage) | ||
console.log('🐶 Done, wuaff! Check out \'.dog\' directory') | ||
console.log(`🐶 Done, wuaff! Check out ${chalk.yellow('.dog')} directory`) | ||
}) | ||
|
||
program.command('web') | ||
program | ||
.command('web') | ||
.description('Run web generator') | ||
.action(() => { | ||
runWebGenerator(); | ||
runWebGenerator() | ||
}) | ||
|
||
program.parse(); | ||
program.parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './favicon.js'; | ||
export * from './og-image.js'; | ||
export * from './favicon.js' | ||
export * from './og-image.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { runWebGenerator } from './webApp'; | ||
import { runWebGenerator } from './webApp' | ||
|
||
runWebGenerator(); | ||
runWebGenerator() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import path from 'path'; | ||
import { createStorage } from "unstorage"; | ||
import fsDriver from "unstorage/drivers/fs"; | ||
import path from 'path' | ||
import { createStorage } from 'unstorage' | ||
import fsDriver from 'unstorage/drivers/fs' | ||
|
||
export const assetsStorage = createStorage({ | ||
driver: fsDriver({ base: path.resolve(__dirname, "../assets/") }), | ||
}); | ||
driver: fsDriver({ base: path.resolve(__dirname, '../assets/') }) | ||
}) | ||
|
||
export const tmpStorage = createStorage({ | ||
driver: fsDriver({ base: path.resolve(__dirname, "../.tmp/") }), | ||
}); | ||
driver: fsDriver({ base: path.resolve(__dirname, '../.tmp/') }) | ||
}) | ||
|
||
export const workingStorage = createStorage({ | ||
driver: fsDriver({ base: '.dog' }), | ||
}); | ||
driver: fsDriver({ base: '.dog' }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export function bufferToImgSrc(buffer: Buffer, ext: 'png' | 'ico' = 'png'): string { | ||
const str = `data:image/${ext};base64, ` + buffer.toString('base64'); | ||
return str; | ||
export function bufferToImgSrc( | ||
buffer: Buffer, | ||
ext: 'png' | 'ico' = 'png' | ||
): string { | ||
const str = `data:image/${ext};base64, ` + buffer.toString('base64') | ||
return str | ||
} |
Oops, something went wrong.