1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-29 00:57:41 +02:00
portfolio/scripts/new.ts
Matthias Kretschmann 447cada700
Migrate to Next.js + TypeScript (#1038)
* next.js + typescript

* more testing

* script updates

* fixes

* favicon generation

* testing

* readme updates

* tweaks

* tweaks

* move tests

* image tweaks

* ci tweaks

* commit next-env.d.ts for ci

* migrations

* fixes

* fixes

* ci tweaks

* new animations

* project preview tweaks

* add codeclimate config

* dark mode refactor, test tweaks

* readme updates

* animation tweaks

* animate in loaded images

* test update

* update humans.txt
2022-11-15 23:14:59 +00:00

33 lines
856 B
TypeScript

#!/usr/bin/env ts-node
import fs from 'fs'
import path from 'path'
import prepend from 'prepend'
import slugify from 'slugify'
import ora from 'ora'
const templatePath = path.join(process.cwd(), 'scripts', 'new.yml')
const template = fs.readFileSync(templatePath).toString()
const spinner = ora('Adding new project').start()
if (!process.argv[2]) {
spinner.fail('Use the format `npm run new -- Title of project`')
}
const title = process.argv[2]
spinner.text = `Adding '${title}'.`
const titleSlug = slugify(title, { lower: true })
const projects = path.join(process.cwd(), '_content', 'projects.yml')
const newContents = template
.split('TITLE')
.join(title)
.split('SLUG')
.join(titleSlug)
prepend(projects, newContents, (error) => {
if (error) spinner.fail(error)
spinner.succeed(`Added '${title}' to top of projects.yml file.`)
})