thomvaill / log4brains

✍️ Log and publish your architecture decisions (ADR)
Apache License 2.0
1.13k stars 95 forks source link

--from flag is ignored when no template is present #55

Open BearAlliance opened 2 years ago

BearAlliance commented 2 years ago

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

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.

BearAlliance commented 2 years ago

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