Git Product home page Git Product logo

changelog-parser's Issues

accept input text instead of file

not sure why this library only supports passing a file path, I'm trying to parse a changelog I've fetched from GitHub instead of a file.

[feature request] write changelog

Is there any plan to implement the feature to write back into the changelog markdown file?

This feature is useful to programmatically update the changelog, for example in auto release job.

support for parsing a string

currently it appears that changelog-parser only works w/ file paths. however, i'd like to pass in a string (pulled from a github graphql query) rather than a file path. is this possible?

for example:

let md = "#some markdown in a changelog ... (versions, changes etc)";

let result = await parseChangelog(md);

console.log("the versions: ", result.versions) 

is this possible? I'm not super familiar w/ line-reader but maybe something like this would help? https://github.com/feross/string-to-stream

move instance variables into function

Just noticed log and current variables are declared at the module level and assigned at the function level, which is bad. Will refactor a bit to assign variables to be returned a little more intelligently.

Update `README.md` example to include 'date' keys

Parser output now includes a 'date' key on each version object, but this is not reflected in the README.md example.

Happy to submit a PR for this.

P.S. Apologies, I should have included this update with my original PR against #6 .

Add Promise support

Currently, parseChangelog() expects a callback argument, which allows the user to access the parsed changelog data with the body of the function. Eg.

// Callback functionality
parseChangelog( 'path/to/file', function( err, result ) {
    if ( err ) return;

    console.log( result );
} );

Proposed update would supplement the current functionality/behavior by returning a Promise in cases where parseChangelog is not invoked with a callback. Eg.

// Promise functionality
parseChangelog( 'path/to/file' )
    .then( function( result ) {
        console.log( result )
    } )
    .catch( function() {
        // Whoops, something went wrong!
    } );

This update would allow parseChangelog() to be easily inserted into 'Promise chain' procedures. Eg.

let result = getPath( 'CHANGELOG.md' )
                .then( parseChangelog )
                .then( getVersions );

Long term plans and support

Hey,

I've got a few questions regarding the future of this package:

  1. Is there any active development done?
  2. Are there any plans for updates? e.g. for browser support for parsing changelog etc.
  3. If the answers above are both no, is it ok to fork the project and revitalize its work under the same or new npm package? I've written a couple of projects and pipelines with this package and would love to bring it up to date with various improvements, but wouldn't want to do it without consent. What I see missing, but I've already done on couple of occasions on my own:
    • Browser support and general cross-environment functionalities (esm/cjs etc)
    • Modifiable regex patterns
    • Custom fields extracted from regex groups
    • Exports for useful functions
    • Entry post-processing (e.g. adding links to ticket numbers), filtering and grouping

If these don't align with the package vision, that's fine, but I'd love to have at least consent to reuse some of this code for my own public package.

`[]` in changelog isn't parsed correctly

My changelog is generated by Lerna and looks something like this


# [12.98.0](https://some-git-link) (2022-08-23)


### Features

* **jira-1234:** add some new stuff [incomplete] ([24b358b](https:git-some-link))

When parsed, I use the versions[0].parsed["_"], however the value is jira-1234: add some new stuff incomplete] ([24b358b).

It looks like the [] is confusing the parsing logic and outputs in the wrong place.

Library doesn't respect file changes

It appears that if you attempt to read the file after it has been read and modifed, changelog-parser is will still output the old information.

Here is a quick repro test case:

const changelogParser = require('changelog-parser');
const fs = require('fs');
const path = require('path');

const changelog = path.join(__dirname, 'CHANGELOG.md');

changelogParser(changelog, (err, result) => {
    // Print parsed result. Note: 0.2.3 is latest version
    console.log(result);

    // Read the changelog file
    fs.readFile(changelog, 'utf-8', (err, content) => {
        // Change version 0.2.3 to 1.0.0
        const newContent = content.replace('0.2.3', '1.0.0');
        fs.writeFile(changelog, newContent, 'utf-8', () => {
            console.log("FILE WRITTEN....");

            // Parse the file again
            changelogParser(changelog, (err, result) => {

                // BUG: Still says 0.2.3 even though file was written with new 1.0.0 version
                console.log(result);
            });
        });
    });
});

Inconsistent title and body across platforms

It seems that when parsing a change-log file across Linux and Windows, the output object is different.

When parsing a change-log on windows, the title field is filled but the body is empty, on Mac it's the opposite...

Windows Output

{ version: '15.5.1',
  title:
   '15.5.1\n\n### SUB-HEADING (Category)\n- Item 1\n- Item 2\n\n### SUB-HEADING (Category)\n- Item 3\n- Item 4\n\n## 15.5.0\n\n### SUB-HEADING (Category)\n- Item 6\n- Item 2\n\n### SUB-HEADING (Category)\n- Item 1\n- Item 4\n\n### SUB-HEADING (Category)\n- Item 7\n- Item 14',
  date: '15.5.0',
  body: '',
  parsed: { _: [] } }

Linux Output

{ version: '15.5.1',
  title: '',
  date: '15.5.0',
  body: '
   '15.5.1\n\n### SUB-HEADING (Category)\n- Item 1\n- Item 2\n\n### SUB-HEADING (Category)\n- Item 3\n- Item 4\n\n## 15.5.0\n\n### SUB-HEADING (Category)\n- Item 6\n- Item 2\n\n### SUB-HEADING (Category)\n- Item 1\n- Item 4\n\n### SUB-HEADING (Category)\n- Item 7\n- Item 14'',
  parsed: { _: [..] } }

https://github.com/hypermodules/changelog-parser/blob/ef3202f250019b46692c234d5c6d354795255e4a/index.js#L83 could possibly be a good place to investigate

Add parsed/sorted data to changelog entry objects

Currently, all markdown/data for a given entry is provided via the body key on the changelog object. This is perfect for many use cases, but I've bumped into a situation where I need access to the individual items of a specific type from a particular entry (eg. everything 'Added' as part of '1.0.0'). To achieve this, I'm parsing the markdown (provided via body) into a series of plain text arrays.

If possible, I would love to have this information made available 'out of the box' for each entry.

For example, the following entry...

## [1.0.0] - 2018-01-04
### Added
- Added `gh-release` to development dependencies.

### Changed
- Updated dependency version.
- Fixed broken tests.

...would be parsed to:

{
    version: '1.0.0',
    title: '[1.0.0] - 2018-01-04',
    date: '2018-01-04',
    body: '## [1.0.0] - 2018-01-04 ...',
    bodyParsed: {
        added: [
            'Added `gh-release` to development dependencies.',
        ],
        changed: [
            'Updated dependency version.',
            'Fixed broken tests.',
        ],
    },
}

If you approve, I'm happy to take a crack at building out/testing this functionality?

Cross-platform issues caused by different changelog line endings

When a changelog is produced on one platform (e.g. MacOS), with it's style of line endings (e.g. LF), when trying to run the changelog-parser on another platform (e.g. Windows), it tries to use the current OS'es line endings style (e.g. CRLF), and will parse the entire file as one 'line'.

An option should be added to be able to supply a custom line endings style (or automatically detect style from changelog file), so that this can be used in source-controlled projects across multiple platforms.

Ignore HTML comments

I have markdown comments in my changelog to remind me of the format. This module accidentally parses it as a release. I assume this behavior is unwanted.

changelog-parser doesn't parse my changelog correctly

My change is like this:

## [2.3.4]
### bugfix
- something 1
  - desc 1
  - desc 2
- something 2
  - desc 1
  - desc 2

But It is parsed like this:

## [2.3.4]
### bugfix
- something 1
- something 2

As you can see, it ignores subtitles and removes them!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.