Skip to content

Commit

Permalink
Add prettier for formatting and style checking (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Apr 7, 2023
1 parent 367d2cc commit f60e2af
Show file tree
Hide file tree
Showing 33 changed files with 551 additions and 293 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
lib
5 changes: 4 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# https://jstools.dev/eslint-config/

root: true
extends: "@jsdevtools"

extends:
- "@jsdevtools"
- "prettier"

env:
node: true
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
lib
package-lock.json
Empty file added .prettierrc.yml
Empty file.
15 changes: 4 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@
"request": "launch",
"name": "Run Mocha",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--timeout=60000",
"--retries=0",
],
"outFiles": [
"${workspaceFolder}/lib/**/*.js"
],
"args": ["--timeout=60000", "--retries=0"],
"outFiles": ["${workspaceFolder}/lib/**/*.js"],
"smartStep": true,
"skipFiles": [
"<node_internals>/**/*.js"
],
"skipFiles": ["<node_internals>/**/*.js"],
"outputCapture": "std"
},
}
]
}
3 changes: 1 addition & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"problemMatcher": "$tsc"
},


{
"type": "npm",
"script": "test",
Expand All @@ -32,6 +31,6 @@
"isDefault": true
},
"problemMatcher": "$eslint-stylish"
},
}
]
}
29 changes: 7 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
Change Log
====================================================================================================
# Change Log

All notable changes will be documented in this file.
NPM Publish adheres to [Semantic Versioning](http://semver.org/).



[v1.4.0](https://github.com/JS-DevTools/npm-publish/tree/v1.4.0) (2020-10-02)
----------------------------------------------------------------------------------------------------
## [v1.4.0](https://github.com/JS-DevTools/npm-publish/tree/v1.4.0) (2020-10-02)

- Added support NPM's `--tag` argument, which allows packages to be published to a named tag that can then be installed using `npm install <package-name>@<tag>`

- Added support for NPM's `--access` argument, which controls whether scoped packages are publicly accessible, or restricted to members of your NPM organization

[Full Changelog](https://github.com/JS-DevTools/npm-publish/compare/v1.3.0...v1.4.0)



[v1.3.0](https://github.com/JS-DevTools/npm-publish/tree/v1.3.0) (2020-10-01)
----------------------------------------------------------------------------------------------------
## [v1.3.0](https://github.com/JS-DevTools/npm-publish/tree/v1.3.0) (2020-10-01)

- NPM-Publish can now successfully publish a brand-new package to NPM. Previously it failed because it couldn't determine the previous package version. ([PR #12](https://github.com/JS-DevTools/npm-publish/pull/12) from [@ZitRos](https://github.com/ZitRos))

[Full Changelog](https://github.com/JS-DevTools/npm-publish/compare/v1.2.0...v1.3.0)



[v1.2.0](https://github.com/JS-DevTools/npm-publish/tree/v1.2.0) (2020-07-23)
----------------------------------------------------------------------------------------------------
## [v1.2.0](https://github.com/JS-DevTools/npm-publish/tree/v1.2.0) (2020-07-23)

- Added support for running NPM in "dry run" mode, which doesn't actually publish, but reports details of what _would_ have been published.

[Full Changelog](https://github.com/JS-DevTools/npm-publish/compare/v1.1.2...v1.2.0)



[v1.1.0](https://github.com/JS-DevTools/npm-publish/tree/v1.1.0) (2020-03-29)
----------------------------------------------------------------------------------------------------
## [v1.1.0](https://github.com/JS-DevTools/npm-publish/tree/v1.1.0) (2020-03-29)

- FIX: The configured NPM registry and token are now used _all_ NPM commands, not just for publishing. This ensures that npm-publish works with private packages and custom registries

[Full Changelog](https://github.com/JS-DevTools/npm-publish/compare/v1.0.13...v1.1.0)



[v1.0.0](https://github.com/JS-DevTools/npm-publish/tree/v1.0.0) (2020-01-21)
----------------------------------------------------------------------------------------------------
## [v1.0.0](https://github.com/JS-DevTools/npm-publish/tree/v1.0.0) (2020-01-21)

Initial release 🎉
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contributing Guide

Contributions, enhancements, and bug-fixes are welcome! [Open an issue](https://github.com/JS-DevTools/npm-publish/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/npm-publish/pulls).

## Building Locally

You should be using Node.js v16 or later to build this project locally

```shell
# Clone this repository
git clone https://github.com/JS-DevTools/npm-publish.git

# Install dependencies*
npm install

# Build the code
npm run build

# Run the tests
npm test
```

There are also various code quality checks and tests you can run:

```shell
# Autoformat the code
npm run format

# Lint the code
npm run lint
```
41 changes: 10 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ jobs:
You can set any or all of the following input parameters:
|Name |Type |Default |Description
|----------------------|-------- |----------------------------|------------------------------------
|`token` |string |**required** |The NPM auth token to use for publishing
|`registry` |string |https://registry.npmjs.org/ |The NPM registry URL to use
|`package` |string |./package.json |The path of your package.json file
|`tag` |string |"latest" |The tag to publish to. This allows people to install the package using `npm install <package-name>@<tag>`.
|`access` |string |"public" for non-scoped packages. "restricted" for scoped packages.|Determines whether the published package should be publicly visible, or restricted to members of your NPM organization.
|`dry-run` |boolean |false |Run NPM publish with the `--dry-run` flag to prevent publication
|`check-version` |boolean |true |Only publish to NPM if the version number in `package.json` differs from the latest on NPM
|`greater-version-only`|boolean |false |Only publish to NPM if the version number in `package.json` is greater than the latest on NPM |

| Name | Type | Default | Description |
| ---------------------- | ------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `token` | string | **required** | The NPM auth token to use for publishing |
| `registry` | string | https://registry.npmjs.org/ | The NPM registry URL to use |
| `package` | string | ./package.json | The path of your package.json file |
| `tag` | string | "latest" | The tag to publish to. This allows people to install the package using `npm install <package-name>@<tag>`. |
| `access` | string | "public" for non-scoped packages. "restricted" for scoped packages. | Determines whether the published package should be publicly visible, or restricted to members of your NPM organization. |
| `dry-run` | boolean | false | Run NPM publish with the `--dry-run` flag to prevent publication |
| `check-version` | boolean | true | Only publish to NPM if the version number in `package.json` differs from the latest on NPM |
| `greater-version-only` | boolean | false | Only publish to NPM if the version number in `package.json` is greater than the latest on NPM |

## Output Variables

Expand Down Expand Up @@ -211,26 +210,6 @@ package_path The absolute or relative path of the NPM package to publis
Defaults to the current directory.
```
## Contributing
Contributions, enhancements, and bug-fixes are welcome! [Open an issue](https://github.com/JS-DevTools/npm-publish/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/npm-publish/pulls).
#### Building
To build the project locally on your computer:
1. **Clone this repo**<br>
`git clone https://github.com/JS-DevTools/npm-publish.git`
2. **Install dependencies**<br>
`npm install`
3. **Build the code**<br>
`npm run build`
4. **Run the tests**<br>
`npm test`
## License
npm-publish is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
Expand Down
20 changes: 17 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
],
"scripts": {
"clean": "shx rm -rf .nyc_output coverage lib dist",
"lint": "eslint src test",
"lint": "npm run _eslint && npm run _prettier -- --check",
"format": "npm run _eslint -- --fix && npm run _prettier -- --write",
"build": "npm run build:typescript && npm run build:ncc && npm run build:node_modules",
"build:typescript": "tsc --declaration",
"build:ncc": "ncc build src/action/index.ts --source-map --external semver",
Expand All @@ -40,7 +41,9 @@
"coverage": "nyc -x test -x dist/sourcemap-register.js node_modules/mocha/bin/mocha",
"upgrade": "npm-check -u && npm audit fix",
"bump": "bump --tag --push --all && git tag -afm v1 v1 && git push --tags --force",
"release": "npm run clean && npm run build && npm test && npm run bump"
"release": "npm run clean && npm run build && npm test && npm run bump",
"_eslint": "eslint \"**/*.@(js|ts)\"",
"_prettier": "prettier \"**/*.@(js|ts|json|md|yml)\""
},
"engines": {
"node": ">=16"
Expand All @@ -59,9 +62,11 @@
"@vercel/ncc": "^0.36.1",
"chai": "^4.2.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^8.8.0",
"mocha": "^8.2.1",
"npm-check": "^5.9.0",
"nyc": "^15.1.0",
"prettier": "^2.8.7",
"shx": "^0.3.3",
"typescript": "^4.1.3"
},
Expand Down
Loading

0 comments on commit f60e2af

Please sign in to comment.