mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 07:35:05 -04:00
checkPlugins: remove lib/travis.yml and add github badges if they aren't present (#4731)
A future PR should remove all Travis badges and CI jobs.
This commit is contained in:
parent
ebdb2798ff
commit
94a65062c7
2 changed files with 18 additions and 109 deletions
|
@ -277,7 +277,6 @@ fs.readdir(pluginPath, (err, rootFiles) => {
|
|||
console.warn('Run npm install in the plugin folder and commit the package-lock.json file.');
|
||||
}
|
||||
}
|
||||
|
||||
if (files.indexOf('readme') === -1 && files.indexOf('readme.md') === -1) {
|
||||
console.warn('README.md file not found, please create');
|
||||
if (autoFix) {
|
||||
|
@ -310,8 +309,8 @@ fs.readdir(pluginPath, (err, rootFiles) => {
|
|||
}
|
||||
|
||||
|
||||
if (files.indexOf('readme') !== -1 && files.indexOf('readme.md') !== -1) {
|
||||
const readme =
|
||||
if (readMeFileName) {
|
||||
let readme =
|
||||
fs.readFileSync(`${pluginPath}/${readMeFileName}`, {encoding: 'utf8', flag: 'r'});
|
||||
if (readme.toLowerCase().indexOf('license') === -1) {
|
||||
console.warn('No license section in README');
|
||||
|
@ -319,6 +318,22 @@ fs.readdir(pluginPath, (err, rootFiles) => {
|
|||
console.warn('Please add License section to README manually.');
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line max-len
|
||||
const publishBadge = ``;
|
||||
// eslint-disable-next-line max-len
|
||||
const testBadge = ``;
|
||||
if (readme.toLowerCase().indexOf('travis') !== -1) {
|
||||
console.warn('Remove Travis badges');
|
||||
}
|
||||
if (readme.indexOf('workflows/Node.js%20Package/badge.svg') === -1) {
|
||||
console.warn('No Github workflow badge detected');
|
||||
if (autoFix) {
|
||||
readme = `${publishBadge} ${testBadge}\n\n${readme}`;
|
||||
// write readme to file system
|
||||
fs.writeFileSync(`${pluginPath}/${readMeFileName}`, readme);
|
||||
console.log('Wrote Github workflow badges to README');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (files.indexOf('license') === -1 && files.indexOf('license.md') === -1) {
|
||||
|
@ -333,41 +348,6 @@ fs.readdir(pluginPath, (err, rootFiles) => {
|
|||
}
|
||||
}
|
||||
|
||||
let travisConfig =
|
||||
fs.readFileSync('src/bin/plugins/lib/travis.yml', {encoding: 'utf8', flag: 'r'});
|
||||
travisConfig = travisConfig.replace(/\[plugin_name\]/g, pluginName);
|
||||
|
||||
if (files.indexOf('.travis.yml') === -1) {
|
||||
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.');
|
||||
// TODO: Make it check version of the .travis file to see if it needs an update.
|
||||
if (autoFix) {
|
||||
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 (autoFix) {
|
||||
// checks the file versioning of .travis and updates it to the latest.
|
||||
const existingConfig =
|
||||
fs.readFileSync(`${pluginPath}/.travis.yml`, {encoding: 'utf8', flag: 'r'});
|
||||
const existingConfigLocation = existingConfig.indexOf('##ETHERPAD_TRAVIS_V=');
|
||||
const existingValue =
|
||||
parseInt(existingConfig.substr(existingConfigLocation + 20, existingConfig.length));
|
||||
|
||||
const newConfigLocation = travisConfig.indexOf('##ETHERPAD_TRAVIS_V=');
|
||||
const newValue = parseInt(travisConfig.substr(newConfigLocation + 20, travisConfig.length));
|
||||
if (existingConfigLocation === -1) {
|
||||
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) {
|
||||
console.log('updating .travis.yml');
|
||||
fs.writeFileSync(`${pluginPath}/.travis.yml`, travisConfig);
|
||||
}//
|
||||
}
|
||||
|
||||
if (files.indexOf('.gitignore') === -1) {
|
||||
console.warn('.gitignore file not found, please create. .gitignore files are useful to ' +
|
||||
"ensure files aren't incorrectly commited to a repository.");
|
||||
|
@ -433,7 +413,6 @@ fs.readdir(pluginPath, (err, rootFiles) => {
|
|||
// absolute path to etherpad-lite/src is used here so that pluginPath can be a symlink.
|
||||
execSync(
|
||||
`${npmInstall} --no-save ep_etherpad-lite@file:${__dirname}/../../`, {stdio: 'inherit'});
|
||||
|
||||
// linting begins
|
||||
try {
|
||||
console.log('Linting...');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue