@putout/plugin-package-json 10.3.0 β†’ 10.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # @putout/plugin-package-json [![NPM version][NPMIMGURL]][NPMURL]
2
2
 
3
3
  [NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-package-json.svg?style=flat&longCache=true
4
- [NPMURL]: https://npmjs.org/package/@putout/plugin-package-json"npm"
4
+ [NPMURL]: https://npmjs.org/package/@putout/plugin-package-json "npm"
5
5
 
6
6
  🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps to automate fixing `package.json`.
7
7
 
@@ -7,11 +7,13 @@ const {
7
7
  setLiteralValue,
8
8
  } = operator;
9
9
 
10
- export const report = () => `Apply 'https' to repository.url`;
10
+ export const report = () => `Apply 'https' to 'repository.url'`;
11
11
 
12
12
  export const fix = (path) => {
13
13
  const {value} = path.node;
14
- setLiteralValue(path, value.replace('git:', 'git+https:'));
14
+ const newValue = value.replace(/^(git|https)/, 'git+https');
15
+
16
+ setLiteralValue(path, newValue);
15
17
  };
16
18
 
17
19
  export const traverse = ({push}) => ({
@@ -22,21 +24,24 @@ export const traverse = ({push}) => ({
22
24
  if (!repository)
23
25
  return;
24
26
 
25
- const value = repository.get('value');
27
+ const object = repository.get('value');
26
28
 
27
- if (!isObjectExpression(value))
29
+ if (!isObjectExpression(object))
28
30
  return;
29
31
 
30
- const urlPathProp = getProperty(value, 'url');
32
+ const urlPathProp = getProperty(object, 'url');
31
33
 
32
34
  if (!urlPathProp)
33
35
  return;
34
36
 
35
37
  const urlPathValue = urlPathProp.get('value');
36
38
 
37
- if (!urlPathValue.node.value.startsWith('git:'))
39
+ const {value} = urlPathValue.node;
40
+
41
+ if (value.startsWith('git+https'))
38
42
  return;
39
43
 
40
- push(urlPathValue);
44
+ if (/^(git|https)/.test(value))
45
+ push(urlPathValue);
41
46
  },
42
47
  });
@@ -1,7 +1,7 @@
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 applyHttpsToRepositoryUrl from './appy-https-to-repository-url/index.js';
4
+ import * as applyHttpsToRepositoryUrl from './apply-https-to-repository-url/index.js';
5
5
 
6
6
  export const rules = {
7
7
  'add-type': addType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-package-json",
3
- "version": "10.3.0",
3
+ "version": "10.4.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin for package.json",