Skip to content

Foppp/frontend-project-lvl2

Repository files navigation

Maintainability Test Coverage Node CI

Hexlet tests and linter status:

Actions Status

DESCRIPTION

CLI Utility that compares two configuration files (YAML / JSON) and shows a difference in comfortable formates. The main goal was to learn how to work with tree data structures and recursive algorithms.

  • Working with the file system with Node.js
  • Working with trees and tree recursion
  • Connection and working with third-party libraries: Commander, lodash
  • Automated testing (TDD): Jest
  • Working with command line parameters
  • Reading files, parsing incoming data

HELP

$ gendiff -h

   Usage: gendiff [options] <filepath1> <filepath2>

   Compares two configuration files and shows difference.

   Options:
      -V, --version        output the version number
      -f, --format [type]  output format (default: "stylish")
      -h, --help           display help for command

CLI USE

Simple structure
$ gendiff filepath1.json filepath2.json

{
  - follow: false
    host: hexlet.io
  - proxy: 123.234.53.22
  - timeout: 50
  + timeout: 20
  + verbose: true
}
Nested Structure
$ gendiff filepath1.json filepath2.json

{
    common: {
      + follow: false
        setting1: Value 1
      - setting2: 200
      - setting3: true
      + setting3: null
      + setting4: blah blah
      + setting5: {
            key5: value5
        }
        setting6: {
            doge: {
              - wow: 
              + wow: so much
            }
            key: value
          + ops: vops
        }
    }
    group1: {
      - baz: bas
      + baz: bars
        foo: bar
      - nest: {
            key: value
        }
      + nest: str
    }
  - group2: {
        abc: 12345
        deep: {
            id: 45
        }
    }
  + group3: {
        deep: {
            id: {
                number: 45
            }
        }
        fee: 100500
    }
}
Plain Format
$ gendiff --format plain filepath1.json filepath2.json

Property 'common.follow' was added with value: false
Property 'common.setting2' was removed
Property 'common.setting3' was updated. From true to null
Property 'common.setting4' was added with value: 'blah blah'
Property 'common.setting5' was added with value: [complex value]
Property 'common.setting6.doge.wow' was updated. From '' to 'so much'
Property 'common.setting6.ops' was added with value: 'vops'
Property 'group1.baz' was updated. From 'bas' to 'bars'
Property 'group1.nest' was updated. From [complex value] to 'str'
Property 'group2' was removed
Property 'group3' was added with value: [complex value]

Supported formats: JSON, YML

Formatters : stylish (default) , plain, json

EXAMPLES :

Simple .json file example

asciicast

Simple .yaml file example

asciicast

Nested .json and .yaml files example

asciicast

Nested .json and .yaml files with plain format example

asciicast

Nested .json and .yaml files with json format example

asciicast

INSTALLATION

$ make install

LINK

$ make link

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published