Skip to content

Commit f60e2af

Browse files
authoredApr 7, 2023
Add prettier for formatting and style checking (#72)
1 parent 367d2cc commit f60e2af

33 files changed

+551
-293
lines changed
 

‎.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
lib

‎.eslintrc.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
# https://jstools.dev/eslint-config/
44

55
root: true
6-
extends: "@jsdevtools"
6+
7+
extends:
8+
- "@jsdevtools"
9+
- "prettier"
710

811
env:
912
node: true

‎.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
lib
3+
package-lock.json

‎.prettierrc.yml

Whitespace-only changes.

‎.vscode/launch.json

+4-11
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@
1717
"request": "launch",
1818
"name": "Run Mocha",
1919
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
20-
"args": [
21-
"--timeout=60000",
22-
"--retries=0",
23-
],
24-
"outFiles": [
25-
"${workspaceFolder}/lib/**/*.js"
26-
],
20+
"args": ["--timeout=60000", "--retries=0"],
21+
"outFiles": ["${workspaceFolder}/lib/**/*.js"],
2722
"smartStep": true,
28-
"skipFiles": [
29-
"<node_internals>/**/*.js"
30-
],
23+
"skipFiles": ["<node_internals>/**/*.js"],
3124
"outputCapture": "std"
32-
},
25+
}
3326
]
3427
}

‎.vscode/tasks.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"problemMatcher": "$tsc"
2424
},
2525

26-
2726
{
2827
"type": "npm",
2928
"script": "test",
@@ -32,6 +31,6 @@
3231
"isDefault": true
3332
},
3433
"problemMatcher": "$eslint-stylish"
35-
},
34+
}
3635
]
3736
}

‎CHANGELOG.md

+7-22
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,34 @@
1-
Change Log
2-
====================================================================================================
1+
# Change Log
2+
33
All notable changes will be documented in this file.
44
NPM Publish adheres to [Semantic Versioning](http://semver.org/).
55

6-
7-
8-
[v1.4.0](https://github.com/JS-DevTools/npm-publish/tree/v1.4.0) (2020-10-02)
9-
----------------------------------------------------------------------------------------------------
6+
## [v1.4.0](https://github.com/JS-DevTools/npm-publish/tree/v1.4.0) (2020-10-02)
107

118
- 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>`
129

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

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

17-
18-
19-
[v1.3.0](https://github.com/JS-DevTools/npm-publish/tree/v1.3.0) (2020-10-01)
20-
----------------------------------------------------------------------------------------------------
14+
## [v1.3.0](https://github.com/JS-DevTools/npm-publish/tree/v1.3.0) (2020-10-01)
2115

2216
- 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))
2317

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

26-
27-
28-
[v1.2.0](https://github.com/JS-DevTools/npm-publish/tree/v1.2.0) (2020-07-23)
29-
----------------------------------------------------------------------------------------------------
20+
## [v1.2.0](https://github.com/JS-DevTools/npm-publish/tree/v1.2.0) (2020-07-23)
3021

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

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

35-
36-
37-
[v1.1.0](https://github.com/JS-DevTools/npm-publish/tree/v1.1.0) (2020-03-29)
38-
----------------------------------------------------------------------------------------------------
26+
## [v1.1.0](https://github.com/JS-DevTools/npm-publish/tree/v1.1.0) (2020-03-29)
3927

4028
- 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
4129

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

44-
45-
46-
[v1.0.0](https://github.com/JS-DevTools/npm-publish/tree/v1.0.0) (2020-01-21)
47-
----------------------------------------------------------------------------------------------------
32+
## [v1.0.0](https://github.com/JS-DevTools/npm-publish/tree/v1.0.0) (2020-01-21)
4833

4934
Initial release 🎉

‎CONTRIBUTING.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing Guide
2+
3+
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).
4+
5+
## Building Locally
6+
7+
You should be using Node.js v16 or later to build this project locally
8+
9+
```shell
10+
# Clone this repository
11+
git clone https://github.com/JS-DevTools/npm-publish.git
12+
13+
# Install dependencies*
14+
npm install
15+
16+
# Build the code
17+
npm run build
18+
19+
# Run the tests
20+
npm test
21+
```
22+
23+
There are also various code quality checks and tests you can run:
24+
25+
```shell
26+
# Autoformat the code
27+
npm run format
28+
29+
# Lint the code
30+
npm run lint
31+
```

‎README.md

+10-31
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,16 @@ jobs:
6363
6464
You can set any or all of the following input parameters:
6565
66-
|Name |Type |Default |Description
67-
|----------------------|-------- |----------------------------|------------------------------------
68-
|`token` |string |**required** |The NPM auth token to use for publishing
69-
|`registry` |string |https://registry.npmjs.org/ |The NPM registry URL to use
70-
|`package` |string |./package.json |The path of your package.json file
71-
|`tag` |string |"latest" |The tag to publish to. This allows people to install the package using `npm install <package-name>@<tag>`.
72-
|`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.
73-
|`dry-run` |boolean |false |Run NPM publish with the `--dry-run` flag to prevent publication
74-
|`check-version` |boolean |true |Only publish to NPM if the version number in `package.json` differs from the latest on NPM
75-
|`greater-version-only`|boolean |false |Only publish to NPM if the version number in `package.json` is greater than the latest on NPM |
76-
66+
| Name | Type | Default | Description |
67+
| ---------------------- | ------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
68+
| `token` | string | **required** | The NPM auth token to use for publishing |
69+
| `registry` | string | https://registry.npmjs.org/ | The NPM registry URL to use |
70+
| `package` | string | ./package.json | The path of your package.json file |
71+
| `tag` | string | "latest" | The tag to publish to. This allows people to install the package using `npm install <package-name>@<tag>`. |
72+
| `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. |
73+
| `dry-run` | boolean | false | Run NPM publish with the `--dry-run` flag to prevent publication |
74+
| `check-version` | boolean | true | Only publish to NPM if the version number in `package.json` differs from the latest on NPM |
75+
| `greater-version-only` | boolean | false | Only publish to NPM if the version number in `package.json` is greater than the latest on NPM |
7776

7877
## Output Variables
7978

@@ -211,26 +210,6 @@ package_path The absolute or relative path of the NPM package to publis
211210
Defaults to the current directory.
212211
```
213212
214-
## Contributing
215-
216-
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).
217-
218-
#### Building
219-
220-
To build the project locally on your computer:
221-
222-
1. **Clone this repo**<br>
223-
`git clone https://github.com/JS-DevTools/npm-publish.git`
224-
225-
2. **Install dependencies**<br>
226-
`npm install`
227-
228-
3. **Build the code**<br>
229-
`npm run build`
230-
231-
4. **Run the tests**<br>
232-
`npm test`
233-
234213
## License
235214
236215
npm-publish is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.

‎dist/index.js

+17-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package-lock.json

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
],
3131
"scripts": {
3232
"clean": "shx rm -rf .nyc_output coverage lib dist",
33-
"lint": "eslint src test",
33+
"lint": "npm run _eslint && npm run _prettier -- --check",
34+
"format": "npm run _eslint -- --fix && npm run _prettier -- --write",
3435
"build": "npm run build:typescript && npm run build:ncc && npm run build:node_modules",
3536
"build:typescript": "tsc --declaration",
3637
"build:ncc": "ncc build src/action/index.ts --source-map --external semver",
@@ -40,7 +41,9 @@
4041
"coverage": "nyc -x test -x dist/sourcemap-register.js node_modules/mocha/bin/mocha",
4142
"upgrade": "npm-check -u && npm audit fix",
4243
"bump": "bump --tag --push --all && git tag -afm v1 v1 && git push --tags --force",
43-
"release": "npm run clean && npm run build && npm test && npm run bump"
44+
"release": "npm run clean && npm run build && npm test && npm run bump",
45+
"_eslint": "eslint \"**/*.@(js|ts)\"",
46+
"_prettier": "prettier \"**/*.@(js|ts|json|md|yml)\""
4447
},
4548
"engines": {
4649
"node": ">=16"
@@ -59,9 +62,11 @@
5962
"@vercel/ncc": "^0.36.1",
6063
"chai": "^4.2.0",
6164
"eslint": "^7.17.0",
65+
"eslint-config-prettier": "^8.8.0",
6266
"mocha": "^8.2.1",
6367
"npm-check": "^5.9.0",
6468
"nyc": "^15.1.0",
69+
"prettier": "^2.8.7",
6570
"shx": "^0.3.3",
6671
"typescript": "^4.1.3"
6772
},

0 commit comments

Comments
 (0)
Failed to load comments.