From 34a4a74634481db11634374a93c0218b7410bca6 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 16 Jun 2021 18:41:26 -0400 Subject: [PATCH] checkPlugin: Change `autocommit` to not push --- src/bin/plugins/README.md | 8 ++++++- src/bin/plugins/checkPlugin.js | 29 +++++++++++++++-------- src/bin/plugins/reTestAllPlugins.sh | 2 +- src/bin/plugins/updateAllPluginsScript.sh | 2 +- src/bin/plugins/updateCorePlugins.sh | 2 +- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/bin/plugins/README.md b/src/bin/plugins/README.md index b14065821..10602f987 100755 --- a/src/bin/plugins/README.md +++ b/src/bin/plugins/README.md @@ -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 diff --git a/src/bin/plugins/checkPlugin.js b/src/bin/plugins/checkPlugin.js index 843c22964..697e339bc 100755 --- a/src/bin/plugins/checkPlugin.js +++ b/src/bin/plugins/checkPlugin.js @@ -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.'); diff --git a/src/bin/plugins/reTestAllPlugins.sh b/src/bin/plugins/reTestAllPlugins.sh index 58628bdb0..abe1bca80 100755 --- a/src/bin/plugins/reTestAllPlugins.sh +++ b/src/bin/plugins/reTestAllPlugins.sh @@ -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 diff --git a/src/bin/plugins/updateAllPluginsScript.sh b/src/bin/plugins/updateAllPluginsScript.sh index bf5280ee0..79be4bc47 100755 --- a/src/bin/plugins/updateAllPluginsScript.sh +++ b/src/bin/plugins/updateAllPluginsScript.sh @@ -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 diff --git a/src/bin/plugins/updateCorePlugins.sh b/src/bin/plugins/updateCorePlugins.sh index 402a080ec..3866b8444 100755 --- a/src/bin/plugins/updateCorePlugins.sh +++ b/src/bin/plugins/updateCorePlugins.sh @@ -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