-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: @putout/plugin-github: add set-add-and-commit (EndBug/add-an…
- Loading branch information
1 parent
f1fb139
commit be25fd2
Showing
11 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/plugin-github/lib/set-add-and-commit/fixture/latest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__putout_processor_json({ | ||
"jobs": { | ||
"build": { | ||
"runs-on": "ubuntu-latest", | ||
"steps": [ | ||
{ | ||
"uses": 'EndBug/add-and-commit@v9' | ||
}, | ||
] | ||
} | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/plugin-github/lib/set-add-and-commit/fixture/set-add-and-commit-fix.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__putout_processor_json({ | ||
"jobs": { | ||
"build": { | ||
"runs-on": "ubuntu-latest", | ||
"steps": [ | ||
{ | ||
"uses": 'EndBug/add-and-commit@v9' | ||
}, | ||
] | ||
} | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/plugin-github/lib/set-add-and-commit/fixture/set-add-and-commit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__putout_processor_json({ | ||
"jobs": { | ||
"build": { | ||
"runs-on": "ubuntu-latest", | ||
"steps": [ | ||
{ | ||
"uses": "EndBug/add-and-commit@v7" | ||
}, | ||
] | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const { | ||
types, | ||
operator, | ||
} = require('putout'); | ||
|
||
const {traverseProperty} = require('../traverse-property'); | ||
|
||
const { | ||
replaceWith, | ||
getTemplateValues, | ||
} = operator; | ||
|
||
const {StringLiteral} = types; | ||
const checkoutNode = StringLiteral('EndBug/add-and-commit@v9'); | ||
|
||
module.exports.report = () => 'Latest version of EndBug/add-and-commit is missing'; | ||
|
||
module.exports.fix = (path) => { | ||
replaceWith(path, checkoutNode); | ||
}; | ||
|
||
module.exports.traverse = ({push}) => ({ | ||
'__putout_processor_json(__a)'(path) { | ||
const {__a} = getTemplateValues(path, '__putout_processor_json(__a)'); | ||
|
||
for (const propertyPath of traverseProperty(__a, 'uses')) { | ||
const valuePath = propertyPath.get('value'); | ||
const {value} = valuePath.node; | ||
|
||
if (value === 'EndBug/add-and-commit@v9') | ||
continue; | ||
|
||
if (value === 'EndBug/add-and-commit@v7') | ||
push(valuePath); | ||
} | ||
}, | ||
}); | ||
|
23 changes: 23 additions & 0 deletions
23
packages/plugin-github/lib/set-add-and-commit/index.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const {createTest} = require('@putout/test'); | ||
const setAddAndCommit = require('.'); | ||
|
||
const test = createTest(__dirname, { | ||
'github/set-add-and-commit': setAddAndCommit, | ||
}); | ||
|
||
test('plugin-github: set-set-add-and-commit: report', (t) => { | ||
t.report('set-add-and-commit', 'Latest version of EndBug/add-and-commit is missing'); | ||
t.end(); | ||
}); | ||
|
||
test('plugin-github: set-set-add-and-commit: transform', (t) => { | ||
t.transform('set-add-and-commit'); | ||
t.end(); | ||
}); | ||
|
||
test('plugin-github: set-set-add-and-commit: no report: latest', (t) => { | ||
t.noReport('latest'); | ||
t.end(); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/plugin-github/test/fixture/set-add-and-commit-fix.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__putout_processor_json({ | ||
"jobs": { | ||
"build": { | ||
"runs-on": "ubuntu-latest", | ||
"steps": [ | ||
{ | ||
"uses": 'EndBug/add-and-commit@v9' | ||
}, | ||
] | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__putout_processor_json({ | ||
"jobs": { | ||
"build": { | ||
"runs-on": "ubuntu-latest", | ||
"steps": [ | ||
{ | ||
"uses": "EndBug/add-and-commit@v7" | ||
}, | ||
] | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters