Socket
Socket
Sign inDemoInstall

sort-package-json

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-package-json - npm Package Compare versions

Comparing version 1.55.0 to 1.56.0

8

cli.js
#!/usr/bin/env node
const fs = require('fs')
const globby = require('globby')
const sortPackageJson = require('.')
import fs from 'node:fs'
import { globbySync } from 'globby'
import sortPackageJson from './index.js'

@@ -17,3 +17,3 @@ const isCheckFlag = (argument) => argument === '--check' || argument === '-c'

const files = globby.sync(patterns)
const files = globbySync(patterns)

@@ -20,0 +20,0 @@ if (files.length === 0) {

@@ -1,6 +0,6 @@

const sortObjectKeys = require('sort-object-keys')
const detectIndent = require('detect-indent')
const detectNewline = require('detect-newline').graceful
const gitHooks = require('git-hooks-list')
const isPlainObject = require('is-plain-obj')
import sortObjectKeys from 'sort-object-keys'
import detectIndent from 'detect-indent'
import { detectNewlineGraceful as detectNewline } from 'detect-newline'
import gitHooks from 'git-hooks-list'
import isPlainObject from 'is-plain-obj'

@@ -127,2 +127,4 @@ const hasOwnProperty = (object, property) =>

const sortVolta = sortObjectBy(['node', 'npm', 'yarn'])
// See https://docs.npmjs.com/misc/scripts

@@ -294,2 +296,3 @@ const defaultNpmScripts = new Set([

{ key: 'engineStrict', over: sortObject },
{ key: 'volta', over: sortVolta },
{ key: 'languageName' },

@@ -368,5 +371,3 @@ { key: 'os' },

module.exports = sortPackageJson
module.exports.sortPackageJson = sortPackageJson
module.exports.sortOrder = defaultSortOrder
module.exports.default = sortPackageJson
export default sortPackageJson
export { defaultSortOrder as sortOrder }
{
"name": "sort-package-json",
"version": "1.55.0",
"version": "1.56.0",
"description": "Sort an Object or package.json based on the well-known package.json keys",

@@ -20,3 +20,4 @@ "keywords": [

"author": "Keith Cirkel <npm@keithcirkel.co.uk> (http://keithcirkel.co.uk/)",
"main": "index.js",
"type": "module",
"exports": "./index.js",
"types": "index.d.ts",

@@ -31,2 +32,3 @@ "bin": "cli.js",

"lint": "eslint .",
"prepare": "husky install",
"semantic-release": "semantic-release",

@@ -38,8 +40,2 @@ "sort-package-json": "node cli.js package.json --check",

},
"husky": {
"hooks": {
"pre-commit": "npm t && lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"commitlint": {

@@ -69,4 +65,3 @@ "extends": [

"standard",
"plugin:prettier/recommended",
"prettier/standard"
"plugin:prettier/recommended"
]

@@ -78,33 +73,33 @@ },

"dependencies": {
"detect-indent": "^6.0.0",
"detect-newline": "3.1.0",
"git-hooks-list": "1.0.3",
"globby": "10.0.0",
"is-plain-obj": "2.1.0",
"detect-indent": "^7.0.0",
"detect-newline": "^4.0.0",
"git-hooks-list": "^3.0.0",
"globby": "^13.1.1",
"is-plain-obj": "^4.0.0",
"sort-object-keys": "^1.1.3"
},
"devDependencies": {
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"ava": "3.5.1",
"del": "5.1.0",
"dot-prop": "^5.2.0",
"dtslint": "^4.0.5",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"husky": "^4.2.3",
"lint-staged": "^10.0.8",
"make-dir": "3.0.2",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"ava": "^4.1.0",
"del": "^6.0.0",
"dot-prop": "^7.2.0",
"dtslint": "^3.4.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-n": "^15.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.2.0",
"husky": "^7.0.0",
"lint-staged": "^12.3.7",
"make-dir": "^3.1.0",
"nyc": "^15.0.0",
"prettier": "^2.0.4",
"semantic-release": "17.0.5",
"tempy": "0.4.0",
"typescript": "^4.0.5"
"prettier": "^2.6.2",
"resolve": "^1.22.0",
"semantic-release": "^19.0.2",
"tempy": "^2.0.0",
"typescript": "^4.6.3"
}
}

@@ -90,3 +90,3 @@ # Sort Package.json

```js
const sortPackageJson = require('sort-package-json')
import sortPackageJson from 'sort-package-json'

@@ -232,3 +232,3 @@ const packageJsonString = `{

The lack of configuration here is a feature, not a bug. The intent of this tool is that a user can open a package json and always expect to see keys in a particular order. If we add a configuration for this tool, then that promise is broken, as users will first need to look at the configuration for each project to learn the ways in which this tool will change the `package.json`. The structure of the `package.json` should always be predictable & deterministic from project to project. I think the _reason_ why this project is well used is because it is not another "tool" you have to set up with yet another JSON file and more cruft in your project to support it. You run a command and it does what it says on the tin.
The lack of configuration here is a feature, not a bug. The intent of this tool is that a user can open a package json and always expect to see keys in a particular order. If we add a configuration for this tool, then that promise is broken, as users will first need to look at the configuration for each project to learn the ways in which this tool will change the `package.json`. The structure of the `package.json` should always be predictable & deterministic from project to project. I think the _reason_ why this project is well used is because it is not another "tool" you have to set up with yet another JSON file and more cruft in your project to support it. You run a command and it does what it says on the tin.

@@ -235,0 +235,0 @@ A lot of people who ask for configuration cite the use case that they simply don't like the given order that exists and want to make sweeping changes. To me this seems far better suited to simply making a fork of this project as then you can go far further than specifying configuration.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc