mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 09:13:19 +01:00
Matthias Kretschmann
447cada700
* 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
33 lines
856 B
TypeScript
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.`)
|
|
})
|