thomvaill / log4brains

✍️ Log and publish your architecture decisions (ADR)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

--from flag is ignored when no template is present

BearAlliance opened this issue · comments

Bug Report

Description

When templates do not exist, the --from flag is ignored, and an error is thrown.

Steps to Reproduce

See the sample repository

  1. Delete the template from a boilerplate project
  2. Attempt to generate a new ADR with the --from flag

Expected Behavior

A new ADR is generated from the file specified by --from

Context

Didn't have a need for the base template. Only two packages are used, each with their own template.
Before I figured out that putting template.md in the adrFolder directory worked, I tried using the --from CLI argument.

Environment

  • Log4brains version: ^1.0.0-beta.11
  • Node.js version: v16.13.0
  • OS and its version: MacOS 12.0.1 (Apple M1)
  • Browser information: N/A

Possible Solution

The error is thrown from AdrTemplateRepository.ts. It would seem that this template check is done before checking the path provided with --from.

You can just define a template in any of the adrFolder directories to get around this, and the --from flag works just fine, but it would seem to me that that argument, and the presence of a template, are independent of one another.

Ah, just found this

// --from option (used by init-log4brains to create the starter ADRs)
// Since this is a private use case, we don't include it in CORE for now

Is the --from flag not meant to be used by the end user? That intention makes sense given the current behavior.
I found it using --help, not in the README.

npx log4brains adr new --help