Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
update cli
Browse files Browse the repository at this point in the history
  • Loading branch information
keremciu committed Apr 14, 2021
1 parent 35175e1 commit 96b9ac9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ easy CLI for ADR docs
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/adr-tool.svg)](https://npmjs.org/package/adr-tool)
[![Downloads/week](https://img.shields.io/npm/dw/adr-tool.svg)](https://npmjs.org/package/adr-tool)
[![License](https://img.shields.io/npm/l/adr-tool.svg)](https://github.com/keremciu/adr-tool/blob/master/package.json)
[![License](https://img.shields.io/npm/l/adr-tool.svg)](https://github.com/keremciu/adr-tool/blob/main/package.json)

<!-- toc -->
* [Usage](#usage)
Expand Down Expand Up @@ -48,7 +48,7 @@ EXAMPLE
a decision created on ./docs/adr/0001-use-adr-tool.md
```

_See code: [src/commands/create.ts](https://github.com/keremciu/adr-tool/blob/v0.0.8/src/commands/create.ts)_
_See code: [src/commands/create.ts](https://github.com/keremciu/adr-tool/blob/v0.0.9/src/commands/create.ts)_

## `adr-tool help [COMMAND]`

Expand Down Expand Up @@ -83,7 +83,7 @@ EXAMPLE
./docs/adr folder is created!
```

_See code: [src/commands/init.ts](https://github.com/keremciu/adr-tool/blob/v0.0.8/src/commands/init.ts)_
_See code: [src/commands/init.ts](https://github.com/keremciu/adr-tool/blob/v0.0.9/src/commands/init.ts)_

## `adr-tool toc`

Expand All @@ -101,5 +101,5 @@ EXAMPLE
./docs/adr/README.md file is created!
```

_See code: [src/commands/toc.ts](https://github.com/keremciu/adr-tool/blob/v0.0.8/src/commands/toc.ts)_
_See code: [src/commands/toc.ts](https://github.com/keremciu/adr-tool/blob/v0.0.9/src/commands/toc.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adr-tool",
"description": "easy CLI for ADR docs",
"version": "0.0.8",
"version": "0.0.9",
"author": "Kerem Sevencan @keremciu",
"bin": {
"adr-tool": "./bin/run"
Expand Down
14 changes: 11 additions & 3 deletions src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ a decision created on ./docs/adr/0001-use-adr-tool.md
}
}

const decidersresponse: any = await inquirer.prompt([{
name: 'list',
message: 'list everyone involved in the decision',
type: 'input',
}])

const date = new Date().toLocaleString()

const raw = fs.readFileSync(templateFile, 'utf8')
Expand All @@ -120,15 +126,17 @@ a decision created on ./docs/adr/0001-use-adr-tool.md
const fileData = raw
.replace(/\[short title of solved problem and solution\]/g, newIndex + ' - ' + args.title)
.replace(/\[YYYY-MM-DD when the decision was last updated\]/g, date)
.replace(/\[proposed \| rejected \| accepted \| deprecated \| \| superseded by \[ADR-0005\]\(0005-example.md\)\]/g, status)
.replace(/\[description \| ticket\/issue URL\]/g, ticket)
.replace(/\[accepted \| deprecated \| superseded by \[ADR-0005\]\(0005-example.md\)\]/g, status)

if (ticket) raw.replace(/\[description \| ticket\/issue URL\]/g, ticket)
if (decidersresponse.list) raw.replace(/\[list everyone involved in the decision\]/g, decidersresponse.list)

const filePath = adrDir + filename + '.md'
fs.writeFileSync(filePath, fileData)

const tocFileRaw = fs.readFileSync(tocFilePath, 'utf8')
const tocFileArray = tocFileRaw.split('\n')
const tocString = `* [ADR-${fileIndex}](${filename}.md) - ${args.title}`
const tocString = `* [ADR-${fileIndex}](${filename}.md) - ${args.title} - [${status}]`
const tocStopIndex = tocFileArray.indexOf('<!-- tocstop -->')
tocFileArray.splice(tocStopIndex - 1, 0, tocString)

Expand Down

0 comments on commit 96b9ac9

Please sign in to comment.