geut / chan

A Changelog CLI based on http://keepachangelog.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

got an assertion error on `chan removed 'whatever'`

slashformotion opened this issue · comments

Every time i run a chan command (fixed, added, whatever) i get this error:

[chan] [removed] › ✖  error     The `identifier` of the release is required.

here is my CHANGELOG.md

# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.2.0] - 2021-11-03
### Fixed 
- Fixed Two deprecation warnings for _normalize-mixin.scss 

### Changed
- Replaced normalize.scss with a cdn link to normalize.css
## [0.1.2] - 2021-08-21
### Changed
- There is no css files anymore, all the css is generated from scss, except for the hugo-tufte-override.css of course (70c7b91) [#15](https://github.com/slashformotion/hugo-tufte/issues/15)

### Fixed
- An icon wasn't showing in the navbar menu (c8bc5f6) [#26](https://github.com/slashformotion/hugo-tufte/issues/26)

### Deprecated
- Some parts of Feather.js support remained in the code, they are now removed. (472bb3d) [#32](https://github.com/slashformotion/hugo-tufte/issues/32)
## [0.1.1] - 2021-08-15
### Added
- Markdown styling support in the following shortcodes 
    - `marginnote` (4e38a13) [#18](https://github.com/slashformotion/hugo-tufte/issues/18)
    - `blockquote` (628637b) [#20](https://github.com/slashformotion/hugo-tufte/issues/20)
    - `epigraph` (628637b) [#20](https://github.com/slashformotion/hugo-tufte/issues/20)
    - `newthought` (628637b) [#20](https://github.com/slashformotion/hugo-tufte/issues/20)
    - `sidenote` (628637b) [#20](https://github.com/slashformotion/hugo-tufte/issues/20)

### Note
- The link to the repo in the footer is now pointing at https://github.com/slashformotion/hugo-tufte (ccb1ac0) [#22](https://github.com/slashformotion/hugo-tufte/issues/22)
## [0.1.0] - 2021-08-14
### Added
- All of the [Tufte-css](https://github.com/edwardtufte/tufte-css) feature via [shortcodes](https://github.com/slashformotion/hugo-tufte#shortcodes). 
- Support out of the box for social media links( github, gitlab, twitter, patreon, youtube, medium, reddit, stackoverflow, instagram, mastodon, orcid, google_scholar).
- Support for custom navbar and footer links.
- Support for  mathematical typesetting (LaTex) support via [katex](https://katex.org/) or [MathJax](https://www.mathjax.org). 

[Unreleased]: https://github.com/slashformotion/hugo-tufte/compare/v0.2.0...HEAD
[0.1.2]: https://github.com/slashformotion/hugo-tufte/releases/tag/v0.2.0
[0.1.2]: https://github.com/slashformotion/hugo-tufte/releases/tag/v0.1.2
[0.1.1]: https://github.com/slashformotion/hugo-tufte/releases/tag/v0.1.1
[0.1.0]: https://github.com/slashformotion/hugo-tufte/releases/tag/v0.1.0

looks like it comes from here:

assert(identifier, 'The `identifier` of the release is required.')

I tried to understand what is going on but I don't know javascript, so...yeah..i'm stuck on this one

commented

Hi @slashformotion sorry for the delay.

Could you run the commands with the --verbose option to see if there is any additional info. Thanks.

I do have the same error message when running chan added text:

> chan added text --verbose
[chan] [added] › ✖  error     AssertionError [ERR_ASSERTION]: The `identifier` of the release is required. 
    at createRelease (file://.../@geut/chan/node_modules/@geut/chast/src/index.js:27:3)
    at file://.../@geut/chan/node_modules/@geut/remark-chan/src/index.js:49:12
    at Array.map (<anonymous>)
    at parseReleases (file://.../@geut/chan/node_modules/@geut/remark-chan/src/index.js:29:26)
    at file://.../@geut/chan/node_modules/@geut/remark-chan/src/index.js:8:50
    at wrapped (.../@geut/chan/node_modules/trough/wrap.js:25:19)
    at next (.../@geut/chan/node_modules/trough/index.js:57:24)
    at Object.run (.../@geut/chan/node_modules/trough/index.js:31:10)
    at executor (.../@geut/chan/node_modules/unified/index.js:292:20)
    at Function.run (.../@geut/chan/node_modules/unified/index.js:289:5)

I did run a bit through the parseHeadingRelease function. My heading is this:

{
  type: 'heading',
  depth: 2,
  children: [ { type: 'text', value: '[1.8.2] - 2021-12-03' } ]
}

This results in link being null, and text ending up as { type: 'text', value: '[1.8.2] - 2021-12-03' }. This means we end up in here:

} else {
const match = text.value.match(/\[(.*?)\]/)
if (match) {
const tag = match[1]
if (tag === 'Unreleased') {
identifier = 'unreleased'
version = tag
unreleased = true
}
if (tag === 'YANKED') {
const [first, rest] = text.value.trim().split(' - ')
const [second] = rest.split(' ')
identifier = first
version = identifier
date = second
yanked = true
}
} else {
// first release: 0.0.1 - 2014-05-31
([version, date] = text.value.trim().split(' - '))
identifier = version
}
}

The pattern does match, but the block only handle Unreleased and yanked tags. 1.8.2 is ignored. This results in identifier, version, date, url all being undefined when returned:

{
  identifier: undefined,
  version: undefined,
  url: undefined,
  date: undefined,
  unreleased: false,
  yanked: false
}

This then triggers the assertion in createRelease.

In my case, two link reference were missing at the bottom (1.8.1 and 1.8.2):

[Unreleased]: .../compare/v1.8.0...HEAD
[1.8.0]: .../compare/v1.7.0...v1.8.0

Adding them fixed the error. The sample above seems to miss the reference for 0.2.0.

I would appreciate it if chan could fix that automatically, if that is possible. It is a really nice tool I use fairly regularly. Thanks a lot!