Skip to content

Commit

Permalink
Revert "refactor!: migrate to esm and update dependencies (#256)" (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed May 1, 2022
1 parent 9ab64e0 commit 80648cd
Show file tree
Hide file tree
Showing 19 changed files with 11,305 additions and 9,202 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/pr.yml
Expand Up @@ -26,10 +26,6 @@ jobs:
with:
node-version: ${{ matrix.node_version }}

# https://github.com/bahmutov/npm-install/issues/103#issuecomment-931226602
- name: Update NPM
run: npm install --global npm

- name: Install Dependencies
run: npm ci

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Expand Up @@ -12,9 +12,6 @@ jobs:
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
# https://github.com/bahmutov/npm-install/issues/103#issuecomment-931226602
- name: Update NPM
run: npm install --global npm
- name: Install dependencies
run: npm ci
- name: Release
Expand Down
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -87,7 +87,7 @@ Pass a JSON string, return a new sorted JSON string.\
Pass a JSON object, return a new sorted JSON object.
```js
import sortPackageJson from 'sort-package-json'
const sortPackageJson = require('sort-package-json')

const packageJsonString = `{
"dependencies": {
Expand Down Expand Up @@ -228,7 +228,7 @@ Could be. I wanted this one because at the time of writing, nothing is:
### I would like this tool to be configurable with a config file or command line arguments.
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.
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.
Expand Down
8 changes: 4 additions & 4 deletions cli.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import fs from 'node:fs'
import { globbySync } from 'globby'
import sortPackageJson from './index.js'
const fs = require('fs')
const globby = require('globby')
const sortPackageJson = require('.')

const isCheckFlag = (argument) => argument === '--check' || argument === '-c'

Expand All @@ -14,7 +14,7 @@ if (!patterns.length) {
patterns[0] = 'package.json'
}

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

if (files.length === 0) {
console.log('No matching files.')
Expand Down
16 changes: 9 additions & 7 deletions index.js
@@ -1,8 +1,8 @@
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'
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')

const hasOwnProperty = (object, property) =>
Object.prototype.hasOwnProperty.call(object, property)
Expand Down Expand Up @@ -366,5 +366,7 @@ function sortPackageJson(jsonIsh, options = {}) {
)
}

export default sortPackageJson
export { defaultSortOrder as sortOrder }
module.exports = sortPackageJson
module.exports.sortPackageJson = sortPackageJson
module.exports.sortOrder = defaultSortOrder
module.exports.default = sortPackageJson

0 comments on commit 80648cd

Please sign in to comment.