checkPlugin: Change `autocommit` to not push

pull/5323/head
Richard Hansen 2021-06-16 18:41:26 -04:00
parent 48222449b5
commit 34a4a74634
5 changed files with 29 additions and 14 deletions

View File

@ -21,12 +21,18 @@ node src/bin/plugins/checkPlugin.js ep_webrtc
node src/bin/plugins/checkPlugin.js ep_whatever autofix
```
## Autocommitting, push, npm minor patch and npm publish (highly dangerous)
## Autocommitting - fix issues and commit
```
node src/bin/plugins/checkPlugin.js ep_whatever autocommit
```
## Autopush - fix issues, commit, push, and publish (highly dangerous)
```
node src/bin/plugins/checkPlugin.js ep_whatever autopush
```
# All the plugins
Replace johnmclear with your github username

View File

@ -5,8 +5,9 @@
*
* Normal usage: node src/bin/plugins/checkPlugin.js ep_whatever
* Auto fix the things it can: node src/bin/plugins/checkPlugin.js ep_whatever autofix
* Auto commit, push and publish to npm (highly dangerous):
* node src/bin/plugins/checkPlugin.js ep_whatever autocommit
* Auto fix and commit: node src/bin/plugins/checkPlugin.js ep_whatever autocommit
* Auto fix, commit, push and publish to npm (highly dangerous):
* node src/bin/plugins/checkPlugin.js ep_whatever autopush
*/
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
@ -28,7 +29,8 @@ const pluginPath = `node_modules/${pluginName}`;
console.log(`Checking the plugin: ${pluginName}`);
const optArgs = process.argv.slice(3);
const autoCommit = optArgs.indexOf('autocommit') !== -1;
const autoPush = optArgs.indexOf('autopush') !== -1;
const autoCommit = autoPush || optArgs.indexOf('autocommit') !== -1;
const autoFix = autoCommit || optArgs.indexOf('autofix') !== -1;
const execSync = (cmd, opts = {}) => (childProcess.execSync(cmd, {
@ -124,8 +126,8 @@ const checkFile = (srcFn, dstFn) => {
}
};
if (autoCommit) {
console.warn('Auto commit is enabled, I hope you know what you are doing...');
if (autoPush) {
console.warn('Auto push is enabled, I hope you know what you are doing...');
}
fs.readdir(pluginPath, (err, rootFiles) => {
@ -379,17 +381,24 @@ fs.readdir(pluginPath, (err, rootFiles) => {
});
fs.unlinkSync(`${pluginPath}/.git/checkPlugin.index`);
const cmd = [
const commitCmd = [
'git add -A',
'git commit -m "autofixes from Etherpad checkPlugin.js"',
'git push',
].join(' && ');
if (autoCommit) {
console.log('Attempting autocommit and auto publish to npm');
execSync(cmd, {stdio: 'inherit'});
console.log('Committing changes...');
execSync(commitCmd, {stdio: 'inherit'});
} else {
console.log('Fixes applied. Check the above git diff then run the following command:');
console.log(`(cd node_modules/${pluginName} && ${cmd})`);
console.log(`(cd node_modules/${pluginName} && ${commitCmd})`);
}
const pushCmd = 'git push';
if (autoPush) {
console.log('Pushing new commit...');
execSync(pushCmd, {stdio: 'inherit'});
} else {
console.log('Changes committed. To push, run the following command:');
console.log(`(cd node_modules/${pluginName} && ${pushCmd})`);
}
} else {
console.log('No changes.');

View File

@ -4,7 +4,7 @@ do
echo $dir
if [[ $dir == *"ep_"* ]]; then
if [[ $dir != "ep_etherpad-lite" ]]; then
# node src/bin/plugins/checkPlugin.js $dir autofix autocommit autoupdate
# node src/bin/plugins/checkPlugin.js $dir autopush
cd node_modules/$dir
git commit -m "Automatic update: bump update to re-run latest Etherpad tests" --allow-empty
git push origin master

View File

@ -10,7 +10,7 @@ do
# echo $0
if [[ $dir == *"ep_"* ]]; then
if [[ $dir != "ep_etherpad-lite" ]]; then
node src/bin/plugins/checkPlugin.js $dir autofix autocommit autoupdate
node src/bin/plugins/checkPlugin.js $dir autopush
fi
fi
# echo $dir

View File

@ -5,5 +5,5 @@ set -e
for dir in node_modules/ep_*; do
dir=${dir#node_modules/}
[ "$dir" != ep_etherpad-lite ] || continue
node src/bin/plugins/checkPlugin.js "$dir" autofix autocommit autoupdate
node src/bin/plugins/checkPlugin.js "$dir" autopush
done