Skip to content

Commit

Permalink
feat: add initialize config feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lekterable committed Apr 23, 2020
1 parent b910880 commit 187e920
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 56 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Latest

- feat: add package version b9108801
- feat: prepend the CHANGELOG file instead of rewriting it 960ea6f5
- feat: add update version feature fdef971e

## 0.2.0
Expand Down
7 changes: 6 additions & 1 deletion bin/perfekt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

const { program } = require('commander')
const { changelog, release } = require('../dist')
const { changelog, release, initialize } = require('../dist')
const { version } = require('../package.json')

program
Expand All @@ -10,6 +10,11 @@ program
.option('--write', 'write the output to file')
.action((version, options) => changelog(version, options))

program
.command('init')
.description('initialize config')
.action(() => initialize())

program
.command('release <version>')
.description('execute a new release')
Expand Down
74 changes: 19 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"license": "MIT",
"dependencies": {
"commander": "^5.0.0",
"inquirer": "^7.1.0",
"semver": "^7.3.2"
},
"devDependencies": {
Expand Down
22 changes: 22 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { writeFileSync } from 'fs'
import inquirer from 'inquirer'
import semver from 'semver'
import {
commitRelease,
Expand Down Expand Up @@ -36,6 +37,27 @@ export const changelog = async (version, options) => {
return writeFileSync('CHANGELOG.md', newChangelog)
}

const questions = [
{
type: 'list',
name: 'configFormat',
message: 'What format do you want to use for your your config?',
choices: [
'.perfektrc',
'perfekt.config.js',
'perfekt.yaml',
'perfekt.json'
],
default: '.perfektrc'
}
]

export const initialize = async () => {
const { configFormat } = await inquirer.prompt(questions)

writeFileSync(configFormat, '')
}

export const release = async version => {
const newVersion = semver.valid(semver.coerce(version))
if (!newVersion) {
Expand Down

0 comments on commit 187e920

Please sign in to comment.