plugins: Various checkPlugins.js and associated file fixes. (#4439)

This PR makes checkPlugins some what more useful for developers.  

It adds auto npm publish support and various travis improvements among other goodies.
This commit is contained in:
John McLear 2020-11-02 16:13:24 +00:00 committed by GitHub
parent 35f4c00dfb
commit cfc7e47db0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 495 additions and 389 deletions

View file

@ -1,46 +1,52 @@
The files in this folder are for Plugin developers. The files in this folder are for Plugin developers.
# Get suggestions to improve your Plugin # Get suggestions to improve your Plugin
This code will check your plugin for known usual issues and some suggestions for improvements. No changes will be made to your project. This code will check your plugin for known usual issues and some suggestions for improvements. No changes will be made to your project.
``` ```
node bin/plugins/checkPlugin.js $PLUGIN_NAME$ node bin/plugins/checkPlugin.js $PLUGIN_NAME$
``` ```
# Basic Example: # Basic Example:
``` ```
node bin/plugins/checkPlugin.js ep_webrtc node bin/plugins/checkPlugin.js ep_webrtc
``` ```
## Autofixing - will autofix any issues it can ## Autofixing - will autofix any issues it can
``` ```
node bin/plugins/checkPlugins.js ep_whatever autofix node bin/plugins/checkPlugins.js ep_whatever autofix
``` ```
## Autocommitting, push, npm minor patch and npm publish (highly dangerous) ## Autocommitting, push, npm minor patch and npm publish (highly dangerous)
``` ```
node bin/plugins/checkPlugins.js ep_whatever autofix autocommit node bin/plugins/checkPlugins.js ep_whatever autofix autocommit
``` ```
# All the plugins # All the plugins
Replace johnmclear with your github username Replace johnmclear with your github username
``` ```
# Clones # Clones
cd node_modules cd node_modules
GHUSER=johnmclear; curl "https://api.github.com/users/$GHUSER/repos?per_page=1000" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone GHUSER=johnmclear; curl "https://api.github.com/users/$GHUSER/repos?per_page=1000" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone
cd .. cd ..
# autofixes and autocommits /pushes & npm publishes # autofixes and autocommits /pushes & npm publishes
for dir in `ls node_modules`; for dir in `ls node_modules`;
do do
# echo $0 # echo $0
if [[ $dir == *"ep_"* ]]; then if [[ $dir == *"ep_"* ]]; then
if [[ $dir != "ep_etherpad-lite" ]]; then if [[ $dir != "ep_etherpad-lite" ]]; then
node bin/plugins/checkPlugin.js $dir autofix autocommit node bin/plugins/checkPlugin.js $dir autofix autocommit
fi fi
fi fi
# echo $dir # echo $dir
done done
``` ```
# Automating update of ether organization plugins
```
getCorePlugins.sh
updateCorePlugins.sh
```

View file

@ -1,247 +1,293 @@
// pro usage for all your plugins, replace johnmclear with your github username /*
/* *
cd node_modules * Usage -- see README.md
GHUSER=johnmclear; curl "https://api.github.com/users/$GHUSER/repos?per_page=1000" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone *
cd .. * Normal usage: node bin/plugins/checkPlugins.js ep_whatever
* Auto fix the things it can: node bin/plugins/checkPlugins.js ep_whatever autofix
for dir in `ls node_modules`; * Auto commit, push and publish(to npm) * highly dangerous:
do node bin/plugins/checkPlugins.js ep_whatever autofix autocommit
# echo $0
if [[ $dir == *"ep_"* ]]; then */
if [[ $dir != "ep_etherpad-lite" ]]; then
node bin/plugins/checkPlugin.js $dir autofix autocommit const fs = require("fs");
fi const { exec } = require("child_process");
fi
# echo $dir // get plugin name & path from user input
done const pluginName = process.argv[2];
*/
if(!pluginName){
/* console.error("no plugin name specified");
* process.exit(1);
* Usage }
*
* Normal usage: node bin/plugins/checkPlugins.js ep_whatever const pluginPath = "node_modules/"+pluginName;
* Auto fix the things it can: node bin/plugins/checkPlugins.js ep_whatever autofix
* Auto commit, push and publish(to npm) * highly dangerous: console.log("Checking the plugin: "+ pluginName)
node bin/plugins/checkPlugins.js ep_whatever autofix autocommit
// Should we autofix?
*/ if (process.argv[3] && process.argv[3] === "autofix") var autoFix = true;
const fs = require("fs"); // Should we update files where possible?
const { exec } = require("child_process"); if (process.argv[5] && process.argv[5] === "autoupdate") var autoUpdate = true;
// get plugin name & path from user input // Should we automcommit and npm publish?!
const pluginName = process.argv[2]; if (process.argv[4] && process.argv[4] === "autocommit") var autoCommit = true;
const pluginPath = "node_modules/"+pluginName;
console.log("Checking the plugin: "+ pluginName) if(autoCommit){
console.warn("Auto commit is enabled, I hope you know what you are doing...")
// Should we autofix? }
if (process.argv[3] && process.argv[3] === "autofix") var autoFix = true;
fs.readdir(pluginPath, function (err, rootFiles) {
// Should we update files where possible? //handling error
if (process.argv[5] && process.argv[5] === "autoupdate") var autoUpdate = true; if (err) {
return console.log('Unable to scan directory: ' + err);
// Should we automcommit and npm publish?! }
if (process.argv[4] && process.argv[4] === "autocommit") var autoCommit = true;
// rewriting files to lower case
var files = [];
if(autoCommit){
console.warn("Auto commit is enabled, I hope you know what you are doing...") // some files we need to know the actual file name. Not compulsory but might help in the future.
} var readMeFileName;
var repository;
fs.readdir(pluginPath, function (err, rootFiles) { var hasAutofixed = false;
//handling error
if (err) { for (var i = 0; i < rootFiles.length; i++) {
return console.log('Unable to scan directory: ' + err); if(rootFiles[i].toLowerCase().indexOf("readme") !== -1) readMeFileName = rootFiles[i];
} files.push(rootFiles[i].toLowerCase());
}
// rewriting files to lower case
var files = []; if(files.indexOf(".git") === -1){
console.error("No .git folder, aborting");
// some files we need to know the actual file name. Not compulsory but might help in the future. process.exit(1);
var readMeFileName; }
var repository;
var hasAutofixed = false; // do a git pull...
var child_process = require('child_process');
for (var i = 0; i < rootFiles.length; i++) { try{
if(rootFiles[i].toLowerCase().indexOf("readme") !== -1) readMeFileName = rootFiles[i]; child_process.execSync('git pull ',{"cwd":pluginPath+"/"});
files.push(rootFiles[i].toLowerCase()); }catch(e){
} console.error("Error git pull", e);
};
if(files.indexOf("package.json") === -1){
console.warn("no package.json, please create"); try {
} const path = pluginPath + '/.github/workflows/npmpublish.yml';
if (!fs.existsSync(path)) {
if(files.indexOf("package.json") !== -1){ console.log('no .github/workflows/npmpublish.yml, create one and set npm secret to auto publish to npm on commit');
let packageJSON = fs.readFileSync(pluginPath+"/package.json", {encoding:'utf8', flag:'r'}); if (autoFix) {
const npmpublish =
if(packageJSON.toLowerCase().indexOf("repository") === -1){ fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'});
console.warn("No repository in package.json"); fs.mkdirSync(pluginPath + '/.github/workflows', {recursive: true});
if(autoFix){ fs.writeFileSync(path, npmpublish);
console.warn("Repository not detected in package.json. Please add repository section manually.") console.log("If you haven't already, setup autopublish for this plugin https://github.com/ether/etherpad-lite/wiki/Plugins:-Automatically-publishing-to-npm-on-commit-to-Github-Repo");
} } else {
}else{ console.log('Setup autopublish for this plugin https://github.com/ether/etherpad-lite/wiki/Plugins:-Automatically-publishing-to-npm-on-commit-to-Github-Repo');
// useful for creating README later. }
repository = JSON.parse(packageJSON).repository.url; }
} } catch (err) {
console.error(err);
} }
if(files.indexOf("readme") === -1 && files.indexOf("readme.md") === -1){
console.warn("README.md file not found, please create"); if(files.indexOf("package.json") === -1){
if(autoFix){ console.warn("no package.json, please create");
console.log("Autofixing missing README.md file, please edit the README.md file further to include plugin specific details."); }
let readme = fs.readFileSync("bin/plugins/lib/README.md", {encoding:'utf8', flag:'r'})
readme = readme.replace(/\[plugin_name\]/g, pluginName); if(files.indexOf("package.json") !== -1){
if(repository){ let packageJSON = fs.readFileSync(pluginPath+"/package.json", {encoding:'utf8', flag:'r'});
let org = repository.split("/")[3]; let parsedPackageJSON = JSON.parse(packageJSON);
let name = repository.split("/")[4]; if(autoFix){
readme = readme.replace(/\[org_name\]/g, org); var updatedPackageJSON = false;
readme = readme.replace(/\[repo_url\]/g, name); if(!parsedPackageJSON.funding){
fs.writeFileSync(pluginPath+"/README.md", readme); updatedPackageJSON = true;
}else{ parsedPackageJSON.funding = {
console.warn("Unable to find repository in package.json, aborting.") "type": "individual",
} "url": "http://etherpad.org/"
} }
} }
if(updatedPackageJSON){
if(files.indexOf("readme") !== -1 && files.indexOf("readme.md") !== -1){ hasAutofixed = true;
let readme = fs.readFileSync(pluginPath+"/"+readMeFileName, {encoding:'utf8', flag:'r'}); fs.writeFileSync(pluginPath+"/package.json", JSON.stringify(parsedPackageJSON, null, 2));
if(readme.toLowerCase().indexOf("license") === -1){ }
console.warn("No license section in README"); }
if(autoFix){
console.warn("Please add License section to README manually.") if(packageJSON.toLowerCase().indexOf("repository") === -1){
} console.warn("No repository in package.json");
} if(autoFix){
} console.warn("Repository not detected in package.json. Please add repository section manually.")
}
if(files.indexOf("license") === -1 && files.indexOf("license.md") === -1){ }else{
console.warn("LICENSE.md file not found, please create"); // useful for creating README later.
if(autoFix){ repository = parsedPackageJSON.repository.url;
hasAutofixed = true; }
console.log("Autofixing missing LICENSE.md file, including Apache 2 license.");
exec("git config user.name", (error, name, stderr) => { }
if (error) {
console.log(`error: ${error.message}`); if(files.indexOf("package-lock.json") === -1){
return; console.warn("package-lock.json file not found. Please run npm install in the plugin folder and commit the package-lock.json file.")
} if(autoFix){
if (stderr) { var child_process = require('child_process');
console.log(`stderr: ${stderr}`); try{
return; child_process.execSync('npm install',{"cwd":pluginPath+"/"});
} console.log("Making package-lock.json");
let license = fs.readFileSync("bin/plugins/lib/LICENSE.md", {encoding:'utf8', flag:'r'}); hasAutofixed = true;
license = license.replace("[yyyy]", new Date().getFullYear()); }catch(e){
license = license.replace("[name of copyright owner]", name) console.error("Failed to create package-lock.json");
fs.writeFileSync(pluginPath+"/LICENSE.md", license); }
}); }
} }
}
if(files.indexOf("readme") === -1 && files.indexOf("readme.md") === -1){
var travisConfig = fs.readFileSync("bin/plugins/lib/travis.yml", {encoding:'utf8', flag:'r'}); console.warn("README.md file not found, please create");
travisConfig = travisConfig.replace(/\[plugin_name\]/g, pluginName); if(autoFix){
console.log("Autofixing missing README.md file, please edit the README.md file further to include plugin specific details.");
if(files.indexOf(".travis.yml") === -1){ let readme = fs.readFileSync("bin/plugins/lib/README.md", {encoding:'utf8', flag:'r'})
console.warn(".travis.yml file not found, please create. .travis.yml is used for automatically CI testing Etherpad. It is useful to know if your plugin breaks another feature for example.") readme = readme.replace(/\[plugin_name\]/g, pluginName);
// TODO: Make it check version of the .travis file to see if it needs an update. if(repository){
if(autoFix){ let org = repository.split("/")[3];
hasAutofixed = true; let name = repository.split("/")[4];
console.log("Autofixing missing .travis.yml file"); readme = readme.replace(/\[org_name\]/g, org);
fs.writeFileSync(pluginPath+"/.travis.yml", travisConfig); readme = readme.replace(/\[repo_url\]/g, name);
console.log("Travis file created, please sign into travis and enable this repository") fs.writeFileSync(pluginPath+"/README.md", readme);
} }else{
} console.warn("Unable to find repository in package.json, aborting.")
if(autoFix && autoUpdate){ }
// checks the file versioning of .travis and updates it to the latest. }
let existingConfig = fs.readFileSync(pluginPath + "/.travis.yml", {encoding:'utf8', flag:'r'}); }
let existingConfigLocation = existingConfig.indexOf("##ETHERPAD_TRAVIS_V=");
let existingValue = existingConfig.substr(existingConfigLocation+20, existingConfig.length); if(files.indexOf("readme") !== -1 && files.indexOf("readme.md") !== -1){
let readme = fs.readFileSync(pluginPath+"/"+readMeFileName, {encoding:'utf8', flag:'r'});
let newConfigLocation = travisConfig.indexOf("##ETHERPAD_TRAVIS_V="); if(readme.toLowerCase().indexOf("license") === -1){
let newValue = travisConfig.substr(newConfigLocation+20, travisConfig.length); console.warn("No license section in README");
if(autoFix){
if(existingConfigLocation === -1){ console.warn("Please add License section to README manually.")
console.warn("no previous .travis.yml version found so writing new.") }
// we will write the newTravisConfig to the location. }
fs.writeFileSync(pluginPath + "/.travis.yml", travisConfig); }
}else{
if(newValue > existingValue){ if(files.indexOf("license") === -1 && files.indexOf("license.md") === -1){
console.log("updating .travis.yml"); console.warn("LICENSE.md file not found, please create");
fs.writeFileSync(pluginPath + "/.travis.yml", travisConfig); if(autoFix){
hasAutofixed = true; hasAutofixed = true;
} console.log("Autofixing missing LICENSE.md file, including Apache 2 license.");
} exec("git config user.name", (error, name, stderr) => {
} if (error) {
console.log(`error: ${error.message}`);
if(files.indexOf(".gitignore") === -1){ return;
console.warn(".gitignore file not found, please create. .gitignore files are useful to ensure files aren't incorrectly commited to a repository.") }
if(autoFix){ if (stderr) {
hasAutofixed = true; console.log(`stderr: ${stderr}`);
console.log("Autofixing missing .gitignore file"); return;
let gitignore = fs.readFileSync("bin/plugins/lib/gitignore", {encoding:'utf8', flag:'r'}); }
fs.writeFileSync(pluginPath+"/.gitignore", gitignore); let license = fs.readFileSync("bin/plugins/lib/LICENSE.md", {encoding:'utf8', flag:'r'});
} license = license.replace("[yyyy]", new Date().getFullYear());
} license = license.replace("[name of copyright owner]", name)
fs.writeFileSync(pluginPath+"/LICENSE.md", license);
// if we include templates but don't have translations... });
if(files.indexOf("templates") !== -1 && files.indexOf("locales") === -1){ }
console.warn("Translations not found, please create. Translation files help with Etherpad accessibility."); }
}
var travisConfig = fs.readFileSync("bin/plugins/lib/travis.yml", {encoding:'utf8', flag:'r'});
travisConfig = travisConfig.replace(/\[plugin_name\]/g, pluginName);
if(files.indexOf(".ep_initialized") !== -1){
console.warn(".ep_initialized found, please remove. .ep_initialized should never be commited to git and should only exist once the plugin has been executed one time.") if(files.indexOf(".travis.yml") === -1){
if(autoFix){ console.warn(".travis.yml file not found, please create. .travis.yml is used for automatically CI testing Etherpad. It is useful to know if your plugin breaks another feature for example.")
hasAutofixed = true; // TODO: Make it check version of the .travis file to see if it needs an update.
console.log("Autofixing incorrectly existing .ep_initialized file"); if(autoFix){
fs.unlinkSync(pluginPath+"/.ep_initialized"); hasAutofixed = true;
} console.log("Autofixing missing .travis.yml file");
} fs.writeFileSync(pluginPath+"/.travis.yml", travisConfig);
console.log("Travis file created, please sign into travis and enable this repository")
if(files.indexOf("npm-debug.log") !== -1){ }
console.warn("npm-debug.log found, please remove. npm-debug.log should never be commited to your repository.") }
if(autoFix){ if(autoFix && autoUpdate){
hasAutofixed = true; // checks the file versioning of .travis and updates it to the latest.
console.log("Autofixing incorrectly existing npm-debug.log file"); let existingConfig = fs.readFileSync(pluginPath + "/.travis.yml", {encoding:'utf8', flag:'r'});
fs.unlinkSync(pluginPath+"/npm-debug.log"); let existingConfigLocation = existingConfig.indexOf("##ETHERPAD_TRAVIS_V=");
} let existingValue = parseInt(existingConfig.substr(existingConfigLocation+20, existingConfig.length));
}
let newConfigLocation = travisConfig.indexOf("##ETHERPAD_TRAVIS_V=");
if(files.indexOf("static") !== -1){ let newValue = parseInt(travisConfig.substr(newConfigLocation+20, travisConfig.length));
fs.readdir(pluginPath+"/static", function (errRead, staticFiles) { if(existingConfigLocation === -1){
if(staticFiles.indexOf("tests") === -1){ console.warn("no previous .travis.yml version found so writing new.")
console.warn("Test files not found, please create tests. https://github.com/ether/etherpad-lite/wiki/Creating-a-plugin#writing-and-running-front-end-tests-for-your-plugin") // we will write the newTravisConfig to the location.
} fs.writeFileSync(pluginPath + "/.travis.yml", travisConfig);
}) }else{
}else{ if(newValue > existingValue){
console.warn("Test files not found, please create tests. https://github.com/ether/etherpad-lite/wiki/Creating-a-plugin#writing-and-running-front-end-tests-for-your-plugin") console.log("updating .travis.yml");
} fs.writeFileSync(pluginPath + "/.travis.yml", travisConfig);
hasAutofixed = true;
if(hasAutofixed){ }
console.log("Fixes applied, please check git diff then run the following command:\n\n") }
// bump npm Version }
if(autoCommit){
// holy shit you brave. if(files.indexOf(".gitignore") === -1){
console.log("Attempting autocommit and auto publish to npm") console.warn(".gitignore file not found, please create. .gitignore files are useful to ensure files aren't incorrectly commited to a repository.")
exec("cd node_modules/"+ pluginName + " && git add -A && git commit --allow-empty -m 'autofixes from Etherpad checkPlugins.js' && npm version patch && git add package.json && git commit --allow-empty -m 'bump version' && git push && npm publish && cd ../..", (error, name, stderr) => { if(autoFix){
if (error) { hasAutofixed = true;
console.log(`error: ${error.message}`); console.log("Autofixing missing .gitignore file");
return; let gitignore = fs.readFileSync("bin/plugins/lib/gitignore", {encoding:'utf8', flag:'r'});
} fs.writeFileSync(pluginPath+"/.gitignore", gitignore);
if (stderr) { }
console.log(`stderr: ${stderr}`); }
return;
} // if we include templates but don't have translations...
console.log("I think she's got it! By George she's got it!") if(files.indexOf("templates") !== -1 && files.indexOf("locales") === -1){
process.exit(0) console.warn("Translations not found, please create. Translation files help with Etherpad accessibility.");
}); }
}else{
console.log("cd node_modules/"+ pluginName + " && git add -A && git commit --allow-empty -m 'autofixes from Etherpad checkPlugins.js' && npm version patch && git add package.json && git commit --allow-empty -m 'bump version' && git push && npm publish && cd ../..")
} if(files.indexOf(".ep_initialized") !== -1){
} console.warn(".ep_initialized found, please remove. .ep_initialized should never be commited to git and should only exist once the plugin has been executed one time.")
if(autoFix){
//listing all files using forEach hasAutofixed = true;
files.forEach(function (file) { console.log("Autofixing incorrectly existing .ep_initialized file");
// Do whatever you want to do with the file fs.unlinkSync(pluginPath+"/.ep_initialized");
// console.log(file.toLowerCase()); }
}); }
});
if(files.indexOf("npm-debug.log") !== -1){
console.warn("npm-debug.log found, please remove. npm-debug.log should never be commited to your repository.")
if(autoFix){
hasAutofixed = true;
console.log("Autofixing incorrectly existing npm-debug.log file");
fs.unlinkSync(pluginPath+"/npm-debug.log");
}
}
if(files.indexOf("static") !== -1){
fs.readdir(pluginPath+"/static", function (errRead, staticFiles) {
if(staticFiles.indexOf("tests") === -1){
console.warn("Test files not found, please create tests. https://github.com/ether/etherpad-lite/wiki/Creating-a-plugin#writing-and-running-front-end-tests-for-your-plugin")
}
})
}else{
console.warn("Test files not found, please create tests. https://github.com/ether/etherpad-lite/wiki/Creating-a-plugin#writing-and-running-front-end-tests-for-your-plugin")
}
if(hasAutofixed){
console.log("Fixes applied, please check git diff then run the following command:\n\n")
// bump npm Version
if(autoCommit){
// holy shit you brave.
console.log("Attempting autocommit and auto publish to npm")
// github should push to npm for us :)
exec("cd node_modules/"+ pluginName + " && git add -A && git commit --allow-empty -m 'autofixes from Etherpad checkPlugins.js' && git push && cd ../..", (error, name, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log("I think she's got it! By George she's got it!")
process.exit(0)
});
}else{
console.log("cd node_modules/"+ pluginName + " && git add -A && git commit --allow-empty -m 'autofixes from Etherpad checkPlugins.js' && npm version patch && git add package.json && git commit --allow-empty -m 'bump version' && git push && npm publish && cd ../..")
}
}
console.log("Finished");
});

2
bin/plugins/getCorePlugins.sh Executable file
View file

@ -0,0 +1,2 @@
cd node_modules/
GHUSER=ether; curl "https://api.github.com/users/$GHUSER/repos?per_page=1000" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone

View file

@ -1,28 +1,28 @@
[![Travis (.org)](https://api.travis-ci.org/[org_name]/[repo_url].svg?branch=develop)](https://travis-ci.org/github/[org_name]/[repo_url]) [![Travis (.com)](https://api.travis-ci.com/[org_name]/[repo_url].svg?branch=develop)](https://travis-ci.com/github/[org_name]/[repo_url])
# My awesome plugin README example # My awesome plugin README example
Explain what your plugin does and who it's useful for. Explain what your plugin does and who it's useful for.
## Example animated gif of usage if appropriate ## Example animated gif of usage if appropriate
## Installing ## Installing
npm install [plugin_name] npm install [plugin_name]
or Use the Etherpad ``/admin`` interface. or Use the Etherpad ``/admin`` interface.
## Settings ## Settings
Document settings if any Document settings if any
## Testing ## Testing
Document how to run backend / frontend tests. Document how to run backend / frontend tests.
### Frontend ### Frontend
Visit http://whatever/tests/frontend/ to run the frontend tests. Visit http://whatever/tests/frontend/ to run the frontend tests.
### backend ### backend
Type ``cd src && npm run test`` to run the backend tests. Type ``cd src && npm run test`` to run the backend tests.
## LICENSE ## LICENSE
Apache 2.0 Apache 2.0

View file

@ -0,0 +1,39 @@
# This workflow will run tests using node and then publish a package to the npm registry when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Node.js Package
on:
push:
branches:
- main
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: git config user.name 'github-actions[bot]'
- run: git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- run: npm ci
- run: npm version patch
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: git push --follow-tags

140
bin/plugins/lib/travis.yml Executable file → Normal file
View file

@ -1,68 +1,72 @@
language: node_js language: node_js
node_js: node_js:
- "lts/*" - "lts/*"
cache: false cache: false
before_install: services:
- sudo add-apt-repository -y ppa:libreoffice/ppa - docker
- sudo apt-get update
- sudo apt-get -y install libreoffice install:
- sudo apt-get -y install libreoffice-pdfimport - "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
services: #script:
- docker # - "tests/frontend/travis/runner.sh"
install: env:
- "bin/installDeps.sh" global:
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)" - secure: "WMGxFkOeTTlhWB+ChMucRtIqVmMbwzYdNHuHQjKCcj8HBEPdZLfCuK/kf4rG\nVLcLQiIsyllqzNhBGVHG1nyqWr0/LTm8JRqSCDDVIhpyzp9KpCJQQJG2Uwjk\n6/HIJJh/wbxsEdLNV2crYU/EiVO3A4Bq0YTHUlbhUqG3mSCr5Ec="
- secure: "gejXUAHYscbR6Bodw35XexpToqWkv2ifeECsbeEmjaLkYzXmUUNWJGknKSu7\nEUsSfQV8w+hxApr1Z+jNqk9aX3K1I4btL3cwk2trnNI8XRAvu1c1Iv60eerI\nkE82Rsd5lwUaMEh+/HoL8ztFCZamVndoNgX7HWp5J/NRZZMmh4g="
before_script:
- "tests/frontend/travis/sauce_tunnel.sh" jobs:
include:
script: - name: "Lint test package-lock"
- "tests/frontend/travis/runner.sh" install:
- "npm install lockfile-lint"
env: script:
global: - npx lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm
- secure: "WMGxFkOeTTlhWB+ChMucRtIqVmMbwzYdNHuHQjKCcj8HBEPdZLfCuK/kf4rG\nVLcLQiIsyllqzNhBGVHG1nyqWr0/LTm8JRqSCDDVIhpyzp9KpCJQQJG2Uwjk\n6/HIJJh/wbxsEdLNV2crYU/EiVO3A4Bq0YTHUlbhUqG3mSCr5Ec=" - name: "Run the Backend tests"
- secure: "gejXUAHYscbR6Bodw35XexpToqWkv2ifeECsbeEmjaLkYzXmUUNWJGknKSu7\nEUsSfQV8w+hxApr1Z+jNqk9aX3K1I4btL3cwk2trnNI8XRAvu1c1Iv60eerI\nkE82Rsd5lwUaMEh+/HoL8ztFCZamVndoNgX7HWp5J/NRZZMmh4g=" before_script:
- "tests/frontend/travis/sauce_tunnel.sh"
jobs: before_install:
include: - sudo add-apt-repository -y ppa:libreoffice/ppa
- name: "Run the Backend tests" - sudo apt-get update
install: - sudo apt-get -y install libreoffice
- "npm install" - sudo apt-get -y install libreoffice-pdfimport
- "mkdir [plugin_name]" install:
- "mv !([plugin_name]) [plugin_name]" - "npm install"
- "git clone https://github.com/ether/etherpad-lite.git etherpad" - "mkdir [plugin_name]"
- "cd etherpad" - "mv !([plugin_name]) [plugin_name]"
- "mkdir node_modules" - "git clone https://github.com/ether/etherpad-lite.git etherpad"
- "mv ../[plugin_name] node_modules" - "cd etherpad"
- "bin/installDeps.sh" - "mkdir node_modules"
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)" - "mv ../[plugin_name] node_modules"
- "cd src && npm install && cd -" - "bin/installDeps.sh"
script: - "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
- "tests/frontend/travis/runnerBackend.sh" - "cd src && npm install && cd -"
- name: "Test the Frontend" script:
install: - "tests/frontend/travis/runnerBackend.sh"
- "npm install" - name: "Test the Frontend"
- "mkdir [plugin_name]" before_script:
- "mv !([plugin_name]) [plugin_name]" - "tests/frontend/travis/sauce_tunnel.sh"
- "git clone https://github.com/ether/etherpad-lite.git etherpad" install:
- "cd etherpad" - "npm install"
- "mkdir node_modules" - "mkdir [plugin_name]"
- "mv ../[plugin_name] node_modules" - "mv !([plugin_name]) [plugin_name]"
- "bin/installDeps.sh" - "git clone https://github.com/ether/etherpad-lite.git etherpad"
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)" - "cd etherpad"
script: - "mkdir node_modules"
- "tests/frontend/travis/runner.sh" - "mv ../[plugin_name] node_modules"
- "bin/installDeps.sh"
notifications: - "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
irc: script:
channels: - "tests/frontend/travis/runner.sh"
- "irc.freenode.org#etherpad-lite-dev"
notifications:
##ETHERPAD_TRAVIS_V=3 irc:
## Travis configuration automatically created using bin/plugins/updateAllPluginsScript.sh channels:
- "irc.freenode.org#etherpad-lite-dev"
##ETHERPAD_TRAVIS_V=7
## Travis configuration automatically created using bin/plugins/updateAllPluginsScript.sh

View file

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