@putout/plugin-package-json 7.2.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/lib/add-type/index.js +1 -4
- package/lib/appy-https-to-repository-url/index.js +37 -0
- package/lib/find-file/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/package-json.js +3 -3
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -13,10 +13,19 @@ npm i @putout/plugin-package-json -D
|
|
|
13
13
|
|
|
14
14
|
## Rules
|
|
15
15
|
|
|
16
|
+
- ✅ [add-type](#add-type);
|
|
17
|
+
- ✅ [apply-https-to-repository-url](#apply-https-to-repository-url);
|
|
18
|
+
- ✅ [find-file](#find-file);
|
|
19
|
+
- ✅ [remove-nyc](#remove-nyc);
|
|
20
|
+
- ✅ [remove-commit-type](#remove-commit-type);
|
|
21
|
+
|
|
22
|
+
## Config
|
|
23
|
+
|
|
16
24
|
```json
|
|
17
25
|
{
|
|
18
26
|
"rules": {
|
|
19
27
|
"package-json/add-type": "on",
|
|
28
|
+
"package-json/apply-https-to-repository-url": "on",
|
|
20
29
|
"package-json/remove-nyc": "on",
|
|
21
30
|
"package-json/remove-commit-type": "on",
|
|
22
31
|
"package-json/find-file": "off"
|
|
@@ -36,6 +45,21 @@ Add [`type`](https://nodejs.org/dist/latest-v17.x/docs/api/packages.html#type) f
|
|
|
36
45
|
}
|
|
37
46
|
```
|
|
38
47
|
|
|
48
|
+
## apply-https-to-repository-url
|
|
49
|
+
|
|
50
|
+
The `git://` protocol for GitHub repos should not be used due [security concerns](https://github.blog/security/application-security/improving-git-protocol-security-github/).
|
|
51
|
+
|
|
52
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/63ab077723e3ff368fa4e3472f9a36f3/048984adbf078a7d153ea44100d3f03676aa02d5).
|
|
53
|
+
|
|
54
|
+
```diff
|
|
55
|
+
{
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
- "url": "git://github.com/coderaiser/putout.git"
|
|
59
|
+
+ "url": "git+https://github.com/coderaiser/putout.git"
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
39
63
|
## remove-nyc
|
|
40
64
|
|
|
41
65
|
- additional fields in `package.json` produces more traffic then users of your package really need;
|
package/lib/add-type/index.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
getProperty,
|
|
5
|
+
__json,
|
|
6
|
+
setLiteralValue,
|
|
7
|
+
} = operator;
|
|
8
|
+
|
|
9
|
+
export const report = () => `Apply 'https' to repository.url`;
|
|
10
|
+
|
|
11
|
+
export const fix = (path) => {
|
|
12
|
+
const {value} = path.node;
|
|
13
|
+
setLiteralValue(path, value.replace('git:', 'git+https:'));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const traverse = ({push}) => ({
|
|
17
|
+
[__json](path) {
|
|
18
|
+
const arg = path.get('arguments.0');
|
|
19
|
+
const repository = getProperty(arg, 'repository');
|
|
20
|
+
|
|
21
|
+
if (!repository)
|
|
22
|
+
return;
|
|
23
|
+
|
|
24
|
+
const value = repository.get('value');
|
|
25
|
+
const urlPathProp = getProperty(value, 'url');
|
|
26
|
+
|
|
27
|
+
if (!urlPathProp)
|
|
28
|
+
return;
|
|
29
|
+
|
|
30
|
+
const urlPathValue = urlPathProp.get('value');
|
|
31
|
+
|
|
32
|
+
if (!urlPathValue.node.value.startsWith('git:'))
|
|
33
|
+
return;
|
|
34
|
+
|
|
35
|
+
push(urlPathValue);
|
|
36
|
+
},
|
|
37
|
+
});
|
package/lib/find-file/index.js
CHANGED
package/lib/index.js
CHANGED
package/lib/package-json.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as addType from './add-type/index.js';
|
|
2
2
|
import * as removeNyc from './remove-nyc/index.js';
|
|
3
3
|
import * as removeCommitType from './remove-commit-type/index.js';
|
|
4
|
+
import * as appyHttpsToRepositoryUrl from './appy-https-to-repository-url/index.js';
|
|
4
5
|
|
|
5
|
-
const rules = {
|
|
6
|
+
export const rules = {
|
|
6
7
|
'add-type': addType,
|
|
7
8
|
'remove-nyc': removeNyc,
|
|
8
9
|
'remove-commit-type': removeCommitType,
|
|
10
|
+
'appy-https-to-repository-url': appyHttpsToRepositoryUrl,
|
|
9
11
|
};
|
|
10
|
-
|
|
11
|
-
export default rules;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-package-json",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin for package.json",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"changelog": false,
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git://github.com/coderaiser/putout.git"
|
|
14
|
+
"url": "git+https://github.com/coderaiser/putout.git"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "madrun test",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"package-json"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@putout/test": "^
|
|
35
|
-
"c8": "^
|
|
36
|
-
"eslint": "^
|
|
37
|
-
"eslint-plugin-n": "^
|
|
38
|
-
"eslint-plugin-putout": "^
|
|
34
|
+
"@putout/test": "^11.0.0",
|
|
35
|
+
"c8": "^10.0.0",
|
|
36
|
+
"eslint": "^9.0.0",
|
|
37
|
+
"eslint-plugin-n": "^17.0.0",
|
|
38
|
+
"eslint-plugin-putout": "^23.0.0",
|
|
39
39
|
"lerna": "^6.0.1",
|
|
40
40
|
"madrun": "^10.0.0",
|
|
41
41
|
"nodemon": "^3.0.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"putout": ">=
|
|
44
|
+
"putout": ">=36"
|
|
45
45
|
},
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"engines": {
|