Detalhes do pacote

finepack

Kikobeats6.5kMIT2.12.7

Organizes and maintains your JSON files readable

clean, cleanup, cli, deterministic

readme (leia-me)

finepack

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status

Organizes and maintains your JSON files readable.

Finepack is a tool to keep your JSON files organized, especially if you are creating an open source project and want to be sure that your files have all the information that is required or recommended by the main package management systems (like bower or npm). This is what it can do:

  • Lints the JSON to be sure that it is in a valid format.
  • Validates the keys to make sure of the existence of required keys such as name or version, and other important keys such as homepage, main, license...
  • Organizes the JSON by moving the most important properties to the top.
  • Sorts the rest of the keys alphabetically and recursively using the JavaScript sort function (elements are sorted by converting them to strings and comparing strings in Unicode code point order).
  • Can be configured not to sort the arrays or objects at one or more user specified keys.
  • Can use a user-provided compare function to define the sort order.

You can use Finepack as a CLI tool or from NodeJS as a library. Based on fixpack but with a little more ♥.

Install

npm install finepack -g

Usage

CLI

$ finepack

  Organizes and maintains your JSON files readable.

  Usage
    $ finepack <fileJSON> [options]

    options:
     --no-validate             disable validation mode.
     --no-color                disable colors in the output.
     --sort-ignore-object-at   don't sort object(s) at these comma separated key(s).
     --sort-ignore-array-at    don't sort array(s) at these comma separated key(s).
     --version                 output the current version.

    examples:
     finepack package.json
     finepack bower.json --no-validate

API

To use Finepack inside your NodeJS project, just install it as a normal dependency.

const fs = require('fs')
const path = require('path')
const finepack = require('finepack')
const filepath = path.resolve('./package.json')
const filename = path.basename(filepath)
const filedata = fs.readFileSync(filepath, { encoding: 'utf8' })

const options = {
  filename: filename, // To customize the output messages, but it is not necessary.
  validate: false, // To enable (or not) keys validation (false by default).
  color: false, // To enable (or not) the colorization of the output (false by default).
  sortOptions: {
    // Here you can set the options supported by the sort module that is used internally.
    // SEE: https://github.com/Kikobeats/sort-keys-recursive#options
  }
}

finepack(filedata, options, function (err, output, messages) {
  if (err) throw err
  // if your JSON is malformed then you have an err
})

License

MIT © Kiko Beats

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.12.7 (2024-05-07)

2.12.6 (2024-05-06)

2.12.5 (2024-05-06)

2.12.4 (2024-04-02)

2.12.3 (2024-04-01)

2.12.2 (2023-11-02)

Bug Fixes

2.12.1 (2023-11-02)

Bug Fixes

2.12.0 (2023-11-02)

Bug Fixes

2.11.4 (2023-11-02)

2.11.3 (2023-10-24)

2.11.2 (2023-09-05)

2.11.1 (2023-09-05)

2.11.0 (2023-09-03)

Features

2.10.15 (2022-04-25)

2.10.14 (2022-04-12)

2.10.13 (2022-04-01)

2.10.12 (2022-03-15)

2.10.11 (2021-01-08)

2.10.10 (2020-12-25)

2.10.9 (2020-10-30)

2.10.8 (2020-10-15)

2.10.7 (2020-10-14)

2.10.6 (2020-09-30)

2.10.5 (2020-08-11)

2.10.4 (2020-08-11)

2.10.3 (2020-06-10)

2.10.2 (2020-05-07)

Bug Fixes

  • package: update chalk to version 2.2.0 (d7c7e2c)
  • package: update chalk to version 2.3.0 (8f76a1e)
  • package: update chalk to version 2.4.0 (c53c4e9)
  • package: update meow to version 4.0.0 (10795c9)
  • package: update meow to version 5.0.0 (ad78097)
  • package: update normalize-package-data to version 2.5.0 (66454cf)
  • package: update update-notifier to version 2.3.0 (fdd33e2)
  • package: update update-notifier to version 2.4.0 (8c81cbd)
  • package: update update-notifier to version 2.5.0 (e90d7cb)
  • package: update update-notifier to version 2.6.0 (abf0a65)

2.10.0 (2019-12-09)

  • build: migrate cofeescript & mocha (7b1fded)

2.9.2 (2019-12-09)

  • build: update dependencies (db3cf37)

2.9.1 (2019-07-02)

  • build: update dependencies (28759b3)
  • Update README.md (adb57b1)
  • fix(package): update normalize-package-data to version 2.5.0 (66454cf)
  • fix(package): update update-notifier to version 2.6.0 (abf0a65)

2.9.0 (2019-01-13)

  • Add package.json as fallback (536420d)

2.8.2 (2018-11-05)

2.8.1 (2018-07-03)

  • Remove private warning fields (5d0e842)

2.8.0 (2018-07-03)

2.7.2 (2018-04-26)

2.7.1 (2018-04-26)

  • Avoid validate private packages (e8835c2)
  • fix(package): update chalk to version 2.4.0 (c53c4e9)
  • fix(package): update meow to version 5.0.0 (ad78097)
  • fix(package): update update-notifier to version 2.4.0 (8c81cbd)
  • fix(package): update update-notifier to version 2.5.0 (e90d7cb)

2.7.0 (2018-01-27)

  • Drop node 4 support (f55a0aa)
  • Update README.md (ea76e3a)
  • Validate files as required field (0358b61), closes #57
  • fix(package): update chalk to version 2.2.0 (d7c7e2c)
  • fix(package): update chalk to version 2.3.0 (8f76a1e)
  • fix(package): update meow to version 4.0.0 (10795c9)
  • fix(package): update update-notifier to version 2.3.0 (fdd33e2)
  • docs(readme): add Greenkeeper badge (8739e12)

2.6.2 (2017-09-16)

2.6.1 (2017-09-16)

2.6.0 (2017-09-06)

  • Avoid mutate special inmutable keys (c87d380)

2.5.4 (2017-09-06)

  • Compare function should return number (not boolean) (8009f65)
  • Fix linter (3f4fa85)
  • Release 2.5.3 (f236aad)
  • Update README.md (d08196d)
  • fix(package): update chalk to version 2.1.0 (03cf16e)
  • docs(readme): add Greenkeeper badge (e89b748)
  • chore(package): update dependencies (82f49ee)

2.5.3 (2017-07-18)

  • Fix linter (3f4fa85)
  • Update README.md (d08196d)
  • docs(readme): add Greenkeeper badge (e89b748)
  • chore(package): update dependencies (82f49ee)

2.5.2 (2017-05-22)

  • Update deps (68667a3)
  • chore: add 'browser', 'module', 'jsnext:main' as special keywords (afef6f3)
  • chore(package): update acho to version 3.2.0 (f148c84)
  • chore(package): update acho to version 3.3.0 (c6bcf65)

2.5.1 (2017-03-04)

  • fix: sort keys in './lib/Keywords.coffee' > 'sort' before the other keys (092b504)

2.5.0 (2017-03-02)

  • Add clean script (e7cb529)
  • feat: update sort-keys-recursive to version 2.0.0 (0a05651)
  • docs: fix typos and rearrange some sentences (2c7bf38)
  • chore(package): update update-notifier to version 2.0.0 (361b6d6)
  • chore(package): update update-notifier to version 2.1.0 (def7b53)

2.4.0 (2017-01-06)

  • Tweaks (3a7c1ed)
  • Update coffeescript dep (e3c770a)
  • chore: drop support for Node.js 0.10 (70b92f5)
  • chore(package): update acho to version 3.1.0 (c30033b)
  • chore(package): update coffee-script to version 1.11.0 (b175817)

BREAKING CHANGE

  • This module no longer supports Node.js 0.10

2.3.1 (2016-09-03)

  • Replace sort-keys-recursive → sort-keys dep (8aef11d)

2.3.0 (2016-08-27)

2.2.4 (2016-08-26)

2.2.3 (2016-05-01)

  • Little testing scaffold refactor (0d7fb00)
  • Update to acho v3 (37fcc77)
  • chore(package): update acho to version 2.6.0 (8aad723)
  • chore(package): update acho to version 2.7.0 (05cfae9)
  • chore(package): update acho to version 2.8.0 (58b5f53)
  • chore(package): update existential-default to version 1.2.1 (cb30883)
  • chore(package): update existential-default to version 1.3.1 (d9ce0f1)

2.2.2 (2016-02-02)

2.2.1 (2016-01-26)

chore

  • chore(package): update acho to version 2.5.1 (fc742a9)

  • Merge pull request #16 from Kikobeats/greenkeeper-acho-2.5.1 (18c6f1f)

  • Release 2.2.1 (27929d6)
  • Using logger symbols (65eeb24)

2.2.0 (2016-01-25)

2.1.13 (2015-12-08)

  • 2.1.13 releases (7c6777b)
  • added missing dependency and adjust version (2373562)
  • standard rulz ✌️ (ff265eb)
  • updated node builds (09ac28d)

2.1.12 (2015-12-05)

2.1.11 (2015-12-02)

2.1.10 (2015-10-12)

2.1.9 (2015-07-31)

2.1.8 (2015-06-14)

  • first commit (33056e5)
  • improved sort. Updated acho interface (e69313c)

2.1.7 (2015-03-20)

2.1.6 (2015-03-19)

2.1.5 (2015-03-19)

2.1.4 (2015-03-17)

2.1.3 (2015-03-17)

2.1.2 (2015-03-16)

2.1.1 (2015-03-14)

2.1.0 (2015-03-10)

  • 2.1.0 releases (6a4a662)
  • added ability to enable/disable colors in the output (1d135e4)

2.0.2 (2015-03-09)

  • 2.0.2 releases (a2a06ea)
  • Changing missing message text to be a bit clearer (79767b8)
  • Merge pull request #7 from pdehaan/patch-1 (20db25a)
  • Merge pull request #8 from pdehaan/patch-2 (0a56655)
  • Merge pull request #9 from pdehaan/patch-3 (6a91565)
  • Setting messages to an Object instead of an Array (55e4714)
  • Updating README API example (698b536)

2.0.1 (2015-03-09)

2.0.0 (2015-03-09)

  • 2.0.0 releases (b8b889f)
  • refactor and separate CLI from the library (843365c)

1.0.2 (2015-03-08)

1.0.1 (2015-03-08)