keithamus / sort-package-json

Sort an Object or package.json based on the well-known package.json keys
MIT License
806 stars 87 forks source link

feat: show diff after sorting #268

Open miwashutaro0611 opened 2 years ago

miwashutaro0611 commented 2 years ago

Fixes #48

Changes

https://user-images.githubusercontent.com/26462659/192388126-a57bb8c6-bb26-4932-9ee9-7a60d777b0f5.mov

miwashutaro0611 commented 2 years ago

When I resolve the conflict in https://github.com/keithamus/sort-package-json/pull/269 and commit, I get an error that there is no eslint configuration file and I can't commit, should I mention it issues?

error log

❯ git commit -m 'chore: conflict resolution'
npm WARN config init.author.name Use `--init-author-name` instead.
npm WARN config init.author.email Use `--init-author-email` instead.
npm WARN config init.author.url Use `--init-author-url` instead.

> sort-package-json@0.0.0-development test
> ava && dtslint --localTs node_modules/typescript/lib

(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 1ms
  ✔ eslint › eslintIgnoretiming config:load:flatten Completed in 1ms
  ✔ eslint › eslintConfig
  ✔ eslint › eslintConfig.rules
  ✔ eslint › eslintConfig.env
  ✔ eslint › eslintConfig.globals
  ✔ eslint › eslintConfig.parserOptions
  ✔ eslint › eslintConfig.settings
  ✔ eslint › eslintConfig.parser
  ✔ eslint › eslintConfig.plugins
  ✔ eslint › eslintConfig.extends
  ✔ eslint › eslintConfig.processor
  ✔ eslint › eslintConfig.noInlineConfig
  ✔ eslint › eslintConfig.reportUnusedDisableDirectives
  ✔ eslint › eslintConfig.override[]
  ✔ options › options.sortOrder
  ✔ options › options.sortOrder prepend
  ✔ options › options.sortOrder effect
  ✔ options › options.sortOrder function
  ✔ options › options.sortOrder with private key
  ✔ prettier › prettier
  ✔ prettier › prettier.overrides[]
  ✔ prettier › prettier.overrides[].options
  ✔ deps › resolutions
  ✔ deps › dependencies
  ✔ deps › devDependencies
  ✔ deps › peerDependencies
  ✔ deps › optionalDependencies
  ✔ deps › bundledDependencies
  ✔ deps › bundleDependencies
  ✔ deps › extensionPack
  ✔ deps › extensionDependencies
  ✔ deps › peerDependenciesMeta
  ✔ deps › dependenciesMeta
  ✔ main › main⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 1ms
  ✔ main › default sortOrder
  ✔ main › private keys
  ✔ scripts › scripts when npm-run-all is not a dev dependencyin 1ms
  ✔ scripts › scripts when npm-run-all is a dev dependency
  ✔ scripts › betterScripts when npm-run-all is not a dev dependency
  ✔ scripts › betterScripts when npm-run-all is a dev dependency
  ✔ fields › $schema ⠇ : timing config:load:flatten Completed in 1ms
  ✔ fields › name
  ✔ fields › displayName
  ✔ fields › version
  ✔ fields › description
  ✔ fields › sideEffects
  ✔ fields › qna
  ✔ fields › publisher
  ✔ fields › type
  ✔ fields › main
  ✔ fields › svelte
  ✔ fields › umd:main
  ✔ fields › jsdelivr
  ✔ fields › unpkg
  ✔ fields › module
  ✔ fields › source
  ✔ fields › jsnext:main
  ✔ fields › browser
  ✔ fields › react-nativetiming config:load:flatten Completed in 1ms
  ✔ fields › types
  ✔ fields › typesVersions
  ✔ fields › typings
  ✔ fields › style
  ✔ fields › example
  ✔ fields › examplestyle
  ✔ fields › assets
  ✔ fields › man
  ✔ fields › workspaces
  ✔ fields › pre-commit
  ✔ fields › browserslist
  ✔ fields › stylelint
  ✔ fields › flat
  ✔ fields › packageManager
  ✔ fields › os
  ✔ fields › cpu
  ✔ fields › icon
  ✔ fields › preview
  ✔ fields › markdown
  ✔ fields › bin
  ✔ fields › contributes
  ✔ fields › commitlint
  ✔ fields › config
  ✔ fields › nodemonConfigiming config:load:flatten Completed in 1ms
  ✔ fields › browserify
  ✔ fields › babel
  ✔ fields › xo
  ✔ fields › ava
  ✔ fields › jest
  ✔ fields › mocha
  ✔ fields › nyc
  ✔ fields › c8
  ✔ fields › engines
  ✔ fields › engineStrict
  ✔ fields › preferGlobal
  ✔ fields › publishConfig
  ✔ fields › galleryBanner
  ✔ fields › remarkConfig
  ✔ fields › release
  ✔ fields › npmpkgjsonlint
  ✔ fields › npmPackageJsonLintConfig
  ✔ fields › npmpackagejsonlint
  ✔ fields › keywords
  ✔ fields › files
  ✔ fields › activationEvents
  ✔ fields › categories
  ✔ fields › husky
  ✔ fields › binary
  ✔ fields › bugs
  ✔ fields › repository
  ✔ fields › funding
  ✔ fields › license
  ✔ fields › author
  ✔ fields › directories
  ✔ fields › volta
  ✔ fields › contributors
  ✔ fields › badges
  ✔ cli › cli (233ms)
  ✔ cli › run `cli` on 2 bad files (195ms)
  ✔ cli › run `cli --check` on 1 bad file (206ms)
  ✔ cli › run `cli` on 1 bad file (214ms)
  ✔ cli › run `cli -c` with no patterns (223ms)
  ✔ cli › run `cli --check` with no patterns (238ms)
  ✔ cli › run `cli` with no patterns (252ms)
  ✔ cli › run `cli --check` on 2 bad files (223ms)n Completed in 1ms
  ✔ cli › run `cli` on duplicate patterns (109ms)en Completed in 1ms
  ✔ cli › run `cli --check` on duplicate patterns (106ms)
  ✔ cli › run `cli` on 2 good files and 2 bad files (218ms)
  ✔ cli › run `cli` on none exists file (132ms)
  ✔ cli › run `cli --check` on none exists file (123ms)
  ✔ cli › run `cli --check` on 2 good files and 2 bad files (193ms)
  ✔ white-space › white space
  ─⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 1ms

  131 tests passed
npm WARN config init.author.name Use `--init-author-name` instead.
npm WARN config init.author.email Use `--init-author-email` instead.
npm WARN config init.author.url Use `--init-author-url` instead.
✔ Preparing lint-staged...
✔ Hiding unstaged changes to partially staged files...
⚠ Running tasks for staged files...
  ❯ package.json — 21 files
    ❯ *.js — 12 files
      ✖ eslint --fix [FAILED]
    ↓ *.ts — no files [SKIPPED]
    ✔ package.json — 1 file
↓ Skipped because of errors from tasks. [SKIPPED]
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ eslint --fix:

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:

    eslint --init

ESLint looked for configuration files in /filepath/sort-package-json and its ancestors. If it found none, it then looked in your home directory.

If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://eslint.org/chat/help

husky - pre-commit hook exited with code 1 (error)
fisker commented 2 years ago

Something wrong in husky script, I guess. I'll fix it.

miwashutaro0611 commented 2 years ago

Conflicts have been corrected.

fisker commented 2 years ago

@miwashutaro0611 Tests are failing.

miwashutaro0611 commented 2 years ago

@fisker Thanks for calling. Regarding the ci error, I cannot reproduce it in my local environment and would like to know if there is any way to reproduce it.

The following is the result of a local demonstration.

Git status

❯ git status
On branch feature/chore-install-jsdiff
nothing to commit, working tree clean

❯ git log -n 1
commit 113ab6e5ca4c620f750ecfe5fad08a8ea6d2edd6 (HEAD -> feature/chore-install-jsdiff, origin/feature/chore-install-jsdiff)
Merge: 885ad4b c1e1a14
Author: miwashutaro0611 <jacksumiwa0061@gmail.com>
Date:   Sat Oct 1 12:57:46 2022 +0900

    chore: conflict resolution

Node version

❯ node -v
v16.15.1

Local npm test command results

Result `npm run test` ```sh ❯ npm run test npm WARN config init.author.name Use `--init-author-name` instead. npm WARN config init.author.email Use `--init-author-email` instead. npm WARN config init.author.url Use `--init-author-url` instead. > sort-package-json@0.0.0-development test > ava && dtslint --localTs node_modules/typescript/lib (⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 2ms ✔ options › options.sortOrder config:load:flatten Completed in 2ms ✔ options › options.sortOrder prepend ✔ options › options.sortOrder effect ✔ options › options.sortOrder function ✔ options › options.sortOrder with private key ✔ main › main⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 2ms ✔ main › default sortOrder ✔ main › private keys ✔ scripts › scripts when npm-run-all is not a dev dependency ✔ scripts › scripts when npm-run-all is a dev dependency ✔ scripts › betterScripts when npm-run-all is not a dev dependency ✔ scripts › betterScripts when npm-run-all is a dev dependency ✔ eslint › eslintIgnore ✔ eslint › eslintConfig ✔ eslint › eslintConfig.rules ✔ eslint › eslintConfig.env ✔ eslint › eslintConfig.globals ✔ eslint › eslintConfig.parserOptions ✔ eslint › eslintConfig.settings ✔ eslint › eslintConfig.parser ✔ eslint › eslintConfig.plugins ✔ eslint › eslintConfig.extends ✔ eslint › eslintConfig.processor ✔ eslint › eslintConfig.noInlineConfig ✔ eslint › eslintConfig.reportUnusedDisableDirectives ✔ eslint › eslintConfig.override[] ✔ deps › resolutions ✔ deps › dependencies ✔ deps › devDependencies ✔ deps › peerDependencies ✔ deps › optionalDependencies ✔ deps › bundledDependencies ✔ deps › bundleDependencies ✔ deps › extensionPack ✔ deps › extensionDependencies ✔ deps › peerDependenciesMeta ✔ deps › dependenciesMeta ✔ fields › $schema ✔ fields › name ✔ fields › displayName ✔ fields › version ✔ fields › description ✔ fields › sideEffects ✔ fields › qna ✔ fields › publisher : timing config:load:flatten Completed in 2ms ✔ fields › type ✔ fields › main ✔ fields › svelte ✔ fields › umd:main ✔ fields › jsdelivr ✔ fields › unpkg ✔ fields › module ✔ fields › source ✔ fields › jsnext:main ✔ fields › browser ✔ fields › react-native ✔ fields › types ✔ fields › typesVersions ✔ fields › typings ✔ fields › style ✔ fields › example ✔ fields › examplestyle ✔ fields › assets ✔ fields › man ✔ fields › workspaces ✔ fields › pre-commit ✔ fields › browserslist ✔ fields › stylelint ✔ fields › flat ✔ fields › packageManager ✔ fields › os ✔ fields › cpu ✔ fields › icon ✔ fields › preview ✔ fields › markdown ✔ fields › bin ✔ fields › contributes ✔ fields › commitlint ✔ fields › config ✔ fields › nodemonConfig ✔ fields › browserify ✔ fields › babel ✔ fields › xo ✔ fields › ava ✔ fields › jest ✔ fields › mocha ✔ fields › nyc ✔ fields › c8 ✔ fields › engines ✔ fields › engineStrict ✔ fields › preferGlobal ✔ fields › publishConfig ✔ fields › galleryBanner ✔ fields › remarkConfig ✔ fields › release ✔ fields › npmpkgjsonlint ✔ fields › npmPackageJsonLintConfig ✔ fields › npmpackagejsonlint ✔ fields › keywords ✔ fields › files ✔ fields › activationEvents ✔ fields › categories ✔ fields › husky ✔ fields › binary ✔ fields › bugs ✔ fields › repository ✔ fields › funding ✔ fields › license ✔ fields › author ✔ fields › directories ✔ fields › volta ✔ fields › contributors ✔ fields › badges ✔ prettier › prettier ✔ prettier › prettier.overrides[] ✔ prettier › prettier.overrides[].options ✔ cli › cli (203ms)⠇ : timing config:load:flatten Completed in 2ms ✔ white-space › white spaceng config:load:flatten Completed in 2ms ✔ cli › run `cli --check` on 1 bad file (223ms) ✔ cli › run `cli` on 1 bad file (233ms) ✔ cli › run `cli -c` with no patterns (243ms) ✔ cli › run `cli --check` with no patterns (252ms) ✔ cli › run `cli` with no patterns (264ms) ✔ cli › run `cli` on 2 bad files (223ms) ✔ cli › run `cli --check` on 2 bad files (184ms) ✔ cli › run `cli` on 2 good files and 2 bad files (161ms)ed in 2ms ✔ cli › run `cli` on none exists file (128ms) ✔ cli › run `cli --check` on 2 good files and 2 bad files (158ms) ✔ cli › run `cli --check` on none exists file (111ms) ✔ cli › run `cli` on duplicate patterns (119ms) ✔ cli › run `cli --check` on duplicate patterns (115ms) ─⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 2ms 131 tests passed ```
Result `npm run test-coverage` ```sh ❯ npm run test-coverage npm WARN config init.author.name Use `--init-author-name` instead. npm WARN config init.author.email Use `--init-author-email` instead. npm WARN config init.author.url Use `--init-author-url` instead. > sort-package-json@0.0.0-development test-coverage > nyc ava (⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 3ms ✔ eslint › eslintIgnoretiming config:load:flatten Completed in 3ms ✔ eslint › eslintConfig ✔ eslint › eslintConfig.rules ✔ eslint › eslintConfig.env ✔ eslint › eslintConfig.globals ✔ eslint › eslintConfig.parserOptions ✔ eslint › eslintConfig.settings ✔ eslint › eslintConfig.parser ✔ eslint › eslintConfig.plugins ✔ eslint › eslintConfig.extends ✔ eslint › eslintConfig.processor ✔ eslint › eslintConfig.noInlineConfig ✔ eslint › eslintConfig.reportUnusedDisableDirectives ✔ eslint › eslintConfig.override[] ✔ scripts › scripts when npm-run-all is not a dev dependencyin 3ms ✔ scripts › scripts when npm-run-all is a dev dependency ✔ scripts › betterScripts when npm-run-all is not a dev dependency ✔ scripts › betterScripts when npm-run-all is a dev dependency ✔ cli › cli (378ms) ✔ prettier › prettier: timing config:load:flatten Completed in 3ms ✔ prettier › prettier.overrides[] ✔ prettier › prettier.overrides[].options ✔ main › main ✔ main › default sortOrder ✔ main › private keys ✔ cli › run `cli` with no patterns (597ms)flatten Completed in 3ms ✔ deps › resolutions : timing config:load:flatten Completed in 3ms ✔ deps › dependencies ✔ deps › devDependencies ✔ deps › peerDependencies ✔ deps › optionalDependencies ✔ deps › bundledDependencies ✔ deps › bundleDependencies ✔ deps › extensionPack ✔ deps › extensionDependencies ✔ deps › peerDependenciesMeta ✔ deps › dependenciesMeta ✔ cli › run `cli --check` with no patterns (627ms) ✔ cli › run `cli --check` on 2 good files and 2 bad files (439ms)s ✔ cli › run `cli -c` with no patterns (652ms) ✔ options › options.sortOrder config:load:flatten Completed in 3ms ✔ options › options.sortOrder prepend ✔ options › options.sortOrder effect ✔ options › options.sortOrder function ✔ options › options.sortOrder with private key ✔ cli › run `cli` on 1 bad file (800ms)ad:flatten Completed in 3ms ✔ fields › $schema ⠇ : timing config:load:flatten Completed in 3ms ✔ fields › name ✔ fields › displayName ✔ fields › version ✔ fields › description ✔ fields › sideEffects ✔ fields › qna ✔ fields › publisher ✔ fields › type ✔ fields › main ✔ fields › svelte ✔ fields › umd:main ✔ fields › jsdelivr ✔ fields › unpkg ✔ fields › module ✔ fields › source ✔ fields › jsnext:main ✔ fields › browser ✔ fields › react-native ✔ fields › types ✔ fields › typesVersions ✔ fields › typings ✔ fields › style ✔ fields › example ✔ fields › examplestyle ✔ fields › assets ✔ fields › man ✔ fields › workspaces ✔ fields › pre-commit ✔ fields › browserslist ✔ fields › stylelint ✔ fields › flat ✔ fields › packageManager ✔ fields › os ✔ fields › cpu ✔ fields › icon ✔ fields › preview ✔ fields › markdown ✔ fields › bin ✔ fields › contributes ✔ fields › commitlint ✔ fields › config ✔ fields › nodemonConfig ✔ fields › browserify ✔ fields › babel ✔ fields › xo ✔ fields › ava ✔ fields › jest ✔ fields › mocha ✔ fields › nyc ✔ fields › c8 ✔ fields › engines ✔ fields › engineStrict ✔ fields › preferGlobal ✔ fields › publishConfig ✔ fields › galleryBanner ✔ fields › remarkConfig ✔ fields › release ✔ fields › npmpkgjsonlint ✔ fields › npmPackageJsonLintConfig ✔ fields › npmpackagejsonlint ✔ fields › keywords ✔ fields › files ✔ fields › activationEvents ✔ fields › categories ✔ fields › husky ✔ fields › binary ✔ fields › bugs ✔ fields › repository ✔ fields › funding ✔ fields › license ✔ fields › author ✔ fields › directories ✔ fields › volta ✔ fields › contributors ✔ fields › badges ✔ cli › run `cli` on none exists file (703ms)tten Completed in 3ms ✔ cli › run `cli` on duplicate patterns (658ms) ✔ cli › run `cli --check` on 1 bad file (906ms)en Completed in 3ms ✔ cli › run `cli` on 2 good files and 2 bad files (757ms) ✔ cli › run `cli` on 2 bad files (780ms) ✔ cli › run `cli --check` on 2 bad files (777ms) ✔ cli › run `cli --check` on none exists file (744ms) ✔ cli › run `cli --check` on duplicate patterns (665ms)eted in 3ms ✔ white-space › white spaceng config:load:flatten Completed in 3ms ─⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ : timing config:load:flatten Completed in 3ms 131 tests passed ----------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ----------|---------|----------|---------|---------|------------------- All files | 0 | 0 | 0 | 0 | ----------|---------|----------|---------|---------|------------------- ```
fisker commented 2 years ago

Strange, but fixed https://github.com/keithamus/sort-package-json/pull/268/commits/8f437e656fef8f96dcf6499302035eced4ef8aaa