mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 07:35:05 -04:00
cleanup after workspace refactoring (#6174)
* fix bin folder and workflows as far its possible cleanup of dockerfile changed paths of scripts add lock file fix working directory for workflows fix windows bin fix travis (is travis used anyway?) fix package refs remove pnpm-lock file in root as these conflicts with the docker volume setup optimize comments use install again refactor prod image call to run fix --workspace can only be used inside a workspace correct comment try fix pipeline try fix pipeline for upgrade-from-latest-release install all deps smaller adjustments save update dockerfile remove workspace command fix run test command start repair latest release workflow start repair latest release workflow start repair latest release workflow further repairs * remove test plugin from docker compose
This commit is contained in:
parent
4f53142d7f
commit
04063d664b
75 changed files with 158 additions and 192 deletions
59
bin/plugins/README.md
Executable file
59
bin/plugins/README.md
Executable file
|
@ -0,0 +1,59 @@
|
|||
The files in this folder are for Plugin developers.
|
||||
|
||||
# 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.
|
||||
|
||||
```
|
||||
node src/bin/plugins/checkPlugin.js $PLUGIN_NAME$
|
||||
```
|
||||
|
||||
# Basic Example:
|
||||
|
||||
```
|
||||
node src/bin/plugins/checkPlugin.js ep_webrtc
|
||||
```
|
||||
|
||||
## Autofixing - will autofix any issues it can
|
||||
|
||||
```
|
||||
node src/bin/plugins/checkPlugin.js ep_whatever autofix
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
```
|
||||
# Clones
|
||||
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
|
||||
cd ..
|
||||
|
||||
# autofixes and autocommits /pushes & npm publishes
|
||||
for dir in node_modules/ep_*; do
|
||||
dir=${dir#node_modules/}
|
||||
[ "$dir" != ep_etherpad-lite ] || continue
|
||||
node src/bin/plugins/checkPlugin.js "$dir" autocommit
|
||||
done
|
||||
```
|
||||
|
||||
# Automating update of ether organization plugins
|
||||
|
||||
```
|
||||
getCorePlugins.sh
|
||||
updateCorePlugins.sh
|
||||
```
|
420
bin/plugins/checkPlugin.js
Executable file
420
bin/plugins/checkPlugin.js
Executable file
|
@ -0,0 +1,420 @@
|
|||
'use strict';
|
||||
|
||||
/*
|
||||
* Usage -- see README.md
|
||||
*
|
||||
* Normal usage: node bin/plugins/checkPlugin.js ep_whatever
|
||||
* Auto fix the things it can: node bin/plugins/checkPlugin.js ep_whatever autofix
|
||||
* Auto fix and commit: node bin/plugins/checkPlugin.js ep_whatever autocommit
|
||||
* Auto fix, commit, push and publish to npm (highly dangerous):
|
||||
* node bin/plugins/checkPlugin.js ep_whatever autopush
|
||||
*/
|
||||
|
||||
const process = require('process');
|
||||
|
||||
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
|
||||
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||
process.on('unhandledRejection', (err) => { throw err; });
|
||||
|
||||
const assert = require('assert').strict;
|
||||
const fs = require('fs');
|
||||
const fsp = fs.promises;
|
||||
const childProcess = require('child_process');
|
||||
const log4js = require('log4js');
|
||||
const path = require('path');
|
||||
|
||||
const logger = log4js.getLogger('checkPlugin');
|
||||
|
||||
(async () => {
|
||||
// get plugin name & path from user input
|
||||
const pluginName = process.argv[2];
|
||||
|
||||
if (!pluginName) throw new Error('no plugin name specified');
|
||||
logger.info(`Checking the plugin: ${pluginName}`);
|
||||
|
||||
const epRootDir = await fsp.realpath(path.join(await fsp.realpath(__dirname), '../..'));
|
||||
logger.info(`Etherpad root directory: ${epRootDir}`);
|
||||
process.chdir(epRootDir);
|
||||
const pluginPath = await fsp.realpath(`node_modules/${pluginName}`);
|
||||
logger.info(`Plugin directory: ${pluginPath}`);
|
||||
const epSrcDir = await fsp.realpath(path.join(epRootDir, 'src'));
|
||||
|
||||
const optArgs = process.argv.slice(3);
|
||||
const autoPush = optArgs.includes('autopush');
|
||||
const autoCommit = autoPush || optArgs.includes('autocommit');
|
||||
const autoFix = autoCommit || optArgs.includes('autofix');
|
||||
|
||||
const execSync = (cmd, opts = {}) => (childProcess.execSync(cmd, {
|
||||
cwd: `${pluginPath}/`,
|
||||
...opts,
|
||||
}) || '').toString().replace(/\n+$/, '');
|
||||
|
||||
const writePackageJson = async (obj) => {
|
||||
let s = JSON.stringify(obj, null, 2);
|
||||
if (s.length && s.slice(s.length - 1) !== '\n') s += '\n';
|
||||
return await fsp.writeFile(`${pluginPath}/package.json`, s);
|
||||
};
|
||||
|
||||
const checkEntries = (got, want) => {
|
||||
let changed = false;
|
||||
for (const [key, val] of Object.entries(want)) {
|
||||
try {
|
||||
assert.deepEqual(got[key], val);
|
||||
} catch (err) {
|
||||
logger.warn(`${key} possibly outdated.`);
|
||||
logger.warn(err.message);
|
||||
if (autoFix) {
|
||||
got[key] = val;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
};
|
||||
|
||||
const updateDeps = async (parsedPackageJson, key, wantDeps) => {
|
||||
const {[key]: deps = {}} = parsedPackageJson;
|
||||
let changed = false;
|
||||
for (const [pkg, verInfo] of Object.entries(wantDeps)) {
|
||||
const {ver, overwrite = true} =
|
||||
typeof verInfo === 'string' || verInfo == null ? {ver: verInfo} : verInfo;
|
||||
if (deps[pkg] === ver || (deps[pkg] == null && ver == null)) continue;
|
||||
if (deps[pkg] == null) {
|
||||
logger.warn(`Missing dependency in ${key}: '${pkg}': '${ver}'`);
|
||||
} else {
|
||||
if (!overwrite) continue;
|
||||
logger.warn(`Dependency mismatch in ${key}: '${pkg}': '${ver}' (current: ${deps[pkg]})`);
|
||||
}
|
||||
if (autoFix) {
|
||||
if (ver == null) delete deps[pkg];
|
||||
else deps[pkg] = ver;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
parsedPackageJson[key] = deps;
|
||||
await writePackageJson(parsedPackageJson);
|
||||
}
|
||||
};
|
||||
|
||||
const prepareRepo = () => {
|
||||
const modified = execSync('git diff-files --name-status');
|
||||
if (modified !== '') throw new Error(`working directory has modifications:\n${modified}`);
|
||||
const untracked = execSync('git ls-files -o --exclude-standard');
|
||||
if (untracked !== '') throw new Error(`working directory has untracked files:\n${untracked}`);
|
||||
const indexStatus = execSync('git diff-index --cached --name-status HEAD');
|
||||
if (indexStatus !== '') throw new Error(`uncommitted staged changes to files:\n${indexStatus}`);
|
||||
let br;
|
||||
if (autoCommit) {
|
||||
br = execSync('git symbolic-ref HEAD');
|
||||
if (!br.startsWith('refs/heads/')) throw new Error('detached HEAD');
|
||||
br = br.replace(/^refs\/heads\//, '');
|
||||
execSync('git rev-parse --verify -q HEAD^0 || ' +
|
||||
`{ echo "Error: no commits on ${br}" >&2; exit 1; }`);
|
||||
execSync('git config --get user.name');
|
||||
execSync('git config --get user.email');
|
||||
}
|
||||
if (autoPush) {
|
||||
if (!['master', 'main'].includes(br)) throw new Error('master/main not checked out');
|
||||
execSync('git rev-parse --verify @{u}');
|
||||
execSync('git pull --ff-only', {stdio: 'inherit'});
|
||||
if (execSync('git rev-list @{u}...') !== '') throw new Error('repo contains unpushed commits');
|
||||
}
|
||||
};
|
||||
|
||||
const checkFile = async (srcFn, dstFn, overwrite = true) => {
|
||||
const outFn = path.join(pluginPath, dstFn);
|
||||
const wantContents = await fsp.readFile(srcFn, {encoding: 'utf8'});
|
||||
let gotContents = null;
|
||||
try {
|
||||
gotContents = await fsp.readFile(outFn, {encoding: 'utf8'});
|
||||
} catch (err) { /* treat as if the file doesn't exist */ }
|
||||
try {
|
||||
assert.equal(gotContents, wantContents);
|
||||
} catch (err) {
|
||||
logger.warn(`File ${dstFn} does not match the default`);
|
||||
logger.warn(err.message);
|
||||
if (!overwrite && gotContents != null) {
|
||||
logger.warn('Leaving existing contents alone.');
|
||||
return;
|
||||
}
|
||||
if (autoFix) {
|
||||
await fsp.mkdir(path.dirname(outFn), {recursive: true});
|
||||
await fsp.writeFile(outFn, wantContents);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (autoPush) {
|
||||
logger.warn('Auto push is enabled, I hope you know what you are doing...');
|
||||
}
|
||||
|
||||
const files = await fsp.readdir(pluginPath);
|
||||
|
||||
// some files we need to know the actual file name. Not compulsory but might help in the future.
|
||||
const readMeFileName = files.filter((f) => f === 'README' || f === 'README.md')[0];
|
||||
|
||||
if (!files.includes('.git')) throw new Error('No .git folder, aborting');
|
||||
prepareRepo();
|
||||
|
||||
const workflows = ['backend-tests.yml', 'frontend-tests.yml', 'npmpublish.yml'];
|
||||
await Promise.all(workflows.map(async (fn) => {
|
||||
await checkFile(`bin/plugins/lib/${fn}`, `.github/workflows/${fn}`);
|
||||
}));
|
||||
await checkFile('bin/plugins/lib/dependabot.yml', '.github/dependabot.yml');
|
||||
|
||||
if (!files.includes('package.json')) {
|
||||
logger.warn('no package.json, please create');
|
||||
} else {
|
||||
const packageJSON =
|
||||
await fsp.readFile(`${pluginPath}/package.json`, {encoding: 'utf8', flag: 'r'});
|
||||
const parsedPackageJSON = JSON.parse(packageJSON);
|
||||
|
||||
await updateDeps(parsedPackageJSON, 'devDependencies', {
|
||||
'eslint': '^8.14.0',
|
||||
'eslint-config-etherpad': '^3.0.13',
|
||||
// Changing the TypeScript version can break plugin code, so leave it alone if present.
|
||||
'typescript': {ver: '^4.6.4', overwrite: false},
|
||||
// These were moved to eslint-config-etherpad's dependencies so they can be removed:
|
||||
'@typescript-eslint/eslint-plugin': null,
|
||||
'@typescript-eslint/parser': null,
|
||||
'eslint-import-resolver-typescript': null,
|
||||
'eslint-plugin-cypress': null,
|
||||
'eslint-plugin-eslint-comments': null,
|
||||
'eslint-plugin-import': null,
|
||||
'eslint-plugin-mocha': null,
|
||||
'eslint-plugin-node': null,
|
||||
'eslint-plugin-prefer-arrow': null,
|
||||
'eslint-plugin-promise': null,
|
||||
'eslint-plugin-you-dont-need-lodash-underscore': null,
|
||||
});
|
||||
|
||||
await updateDeps(parsedPackageJSON, 'peerDependencies', {
|
||||
// Some plugins require a newer version of Etherpad so don't overwrite if already set.
|
||||
'ep_etherpad-lite': {ver: '>=1.8.6', overwrite: false},
|
||||
});
|
||||
|
||||
await updateDeps(parsedPackageJSON, 'engines', {
|
||||
node: '>=12.17.0',
|
||||
});
|
||||
|
||||
if (parsedPackageJSON.eslintConfig != null && autoFix) {
|
||||
delete parsedPackageJSON.eslintConfig;
|
||||
await writePackageJson(parsedPackageJSON);
|
||||
}
|
||||
if (files.includes('.eslintrc.js')) {
|
||||
const [from, to] = [`${pluginPath}/.eslintrc.js`, `${pluginPath}/.eslintrc.cjs`];
|
||||
if (!files.includes('.eslintrc.cjs')) {
|
||||
if (autoFix) {
|
||||
await fsp.rename(from, to);
|
||||
} else {
|
||||
logger.warn(`please rename ${from} to ${to}`);
|
||||
}
|
||||
} else {
|
||||
logger.error(`both ${from} and ${to} exist; delete ${from}`);
|
||||
}
|
||||
} else {
|
||||
checkFile('bin/plugins/lib/eslintrc.cjs', '.eslintrc.cjs', false);
|
||||
}
|
||||
|
||||
if (checkEntries(parsedPackageJSON, {
|
||||
funding: {
|
||||
type: 'individual',
|
||||
url: 'https://etherpad.org/',
|
||||
},
|
||||
})) await writePackageJson(parsedPackageJSON);
|
||||
|
||||
if (parsedPackageJSON.scripts == null) parsedPackageJSON.scripts = {};
|
||||
if (checkEntries(parsedPackageJSON.scripts, {
|
||||
'lint': 'eslint .',
|
||||
'lint:fix': 'eslint --fix .',
|
||||
})) await writePackageJson(parsedPackageJSON);
|
||||
}
|
||||
|
||||
if (!files.includes('package-lock.json')) {
|
||||
logger.warn('package-lock.json not found');
|
||||
if (!autoFix) {
|
||||
logger.warn('Run npm install in the plugin folder and commit the package-lock.json file.');
|
||||
}
|
||||
}
|
||||
|
||||
const fillTemplate = async (templateFilename, outputFilename) => {
|
||||
const contents = (await fsp.readFile(templateFilename, 'utf8'))
|
||||
.replace(/\[name of copyright owner\]/g, execSync('git config user.name'))
|
||||
.replace(/\[plugin_name\]/g, pluginName)
|
||||
.replace(/\[yyyy\]/g, new Date().getFullYear());
|
||||
await fsp.writeFile(outputFilename, contents);
|
||||
};
|
||||
|
||||
if (!readMeFileName) {
|
||||
logger.warn('README.md file not found, please create');
|
||||
if (autoFix) {
|
||||
logger.info('Autofixing missing README.md file');
|
||||
logger.info('please edit the README.md file further to include plugin specific details.');
|
||||
await fillTemplate('bin/plugins/lib/README.md', `${pluginPath}/README.md`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!files.includes('CONTRIBUTING') && !files.includes('CONTRIBUTING.md')) {
|
||||
logger.warn('CONTRIBUTING.md file not found, please create');
|
||||
if (autoFix) {
|
||||
logger.info('Autofixing missing CONTRIBUTING.md file, please edit the CONTRIBUTING.md ' +
|
||||
'file further to include plugin specific details.');
|
||||
await fillTemplate('bin/plugins/lib/CONTRIBUTING.md', `${pluginPath}/CONTRIBUTING.md`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (readMeFileName) {
|
||||
let readme =
|
||||
await fsp.readFile(`${pluginPath}/${readMeFileName}`, {encoding: 'utf8', flag: 'r'});
|
||||
if (!readme.toLowerCase().includes('license')) {
|
||||
logger.warn('No license section in README');
|
||||
if (autoFix) {
|
||||
logger.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().includes('travis')) {
|
||||
logger.warn('Remove Travis badges');
|
||||
}
|
||||
if (!readme.includes('workflows/Node.js%20Package/badge.svg')) {
|
||||
logger.warn('No Github workflow badge detected');
|
||||
if (autoFix) {
|
||||
readme = `${publishBadge} ${testBadge}\n\n${readme}`;
|
||||
// write readme to file system
|
||||
await fsp.writeFile(`${pluginPath}/${readMeFileName}`, readme);
|
||||
logger.info('Wrote Github workflow badges to README');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!files.includes('LICENSE') && !files.includes('LICENSE.md')) {
|
||||
logger.warn('LICENSE file not found, please create');
|
||||
if (autoFix) {
|
||||
logger.info('Autofixing missing LICENSE file (Apache 2.0).');
|
||||
await fsp.copyFile('bin/plugins/lib/LICENSE', `${pluginPath}/LICENSE`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!files.includes('.gitignore')) {
|
||||
logger.warn('.gitignore file not found, please create. .gitignore files are useful to ' +
|
||||
"ensure files aren't incorrectly commited to a repository.");
|
||||
if (autoFix) {
|
||||
logger.info('Autofixing missing .gitignore file');
|
||||
const gitignore =
|
||||
await fsp.readFile('bin/plugins/lib/gitignore', {encoding: 'utf8', flag: 'r'});
|
||||
await fsp.writeFile(`${pluginPath}/.gitignore`, gitignore);
|
||||
}
|
||||
} else {
|
||||
let gitignore =
|
||||
await fsp.readFile(`${pluginPath}/.gitignore`, {encoding: 'utf8', flag: 'r'});
|
||||
if (!gitignore.includes('node_modules/')) {
|
||||
logger.warn('node_modules/ missing from .gitignore');
|
||||
if (autoFix) {
|
||||
gitignore += 'node_modules/';
|
||||
await fsp.writeFile(`${pluginPath}/.gitignore`, gitignore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we include templates but don't have translations...
|
||||
if (files.includes('templates') && !files.includes('locales')) {
|
||||
logger.warn('Translations not found, please create. ' +
|
||||
'Translation files help with Etherpad accessibility.');
|
||||
}
|
||||
|
||||
|
||||
if (files.includes('.ep_initialized')) {
|
||||
logger.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) {
|
||||
logger.info('Autofixing incorrectly existing .ep_initialized file');
|
||||
await fsp.unlink(`${pluginPath}/.ep_initialized`);
|
||||
}
|
||||
}
|
||||
|
||||
if (files.includes('npm-debug.log')) {
|
||||
logger.warn('npm-debug.log found, please remove. npm-debug.log should never be commited to ' +
|
||||
'your repository.');
|
||||
if (autoFix) {
|
||||
logger.info('Autofixing incorrectly existing npm-debug.log file');
|
||||
await fsp.unlink(`${pluginPath}/npm-debug.log`);
|
||||
}
|
||||
}
|
||||
|
||||
if (files.includes('static')) {
|
||||
const staticFiles = await fsp.readdir(`${pluginPath}/static`);
|
||||
if (!staticFiles.includes('tests')) {
|
||||
logger.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 {
|
||||
logger.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');
|
||||
}
|
||||
|
||||
// Install dependencies so we can run ESLint. This should also create or update package-lock.json
|
||||
// if autoFix is enabled.
|
||||
const npmInstall = `npm install${autoFix ? '' : ' --no-package-lock'}`;
|
||||
execSync(npmInstall, {stdio: 'inherit'});
|
||||
// Create the ep_etherpad-lite symlink if necessary. This must be done after running `npm install`
|
||||
// because that command nukes the symlink.
|
||||
try {
|
||||
const d = await fsp.realpath(path.join(pluginPath, 'node_modules/ep_etherpad-lite'));
|
||||
assert.equal(d, epSrcDir);
|
||||
} catch (err) {
|
||||
execSync(`${npmInstall} --no-save ep_etherpad-lite@file:${epSrcDir}`, {stdio: 'inherit'});
|
||||
}
|
||||
// linting begins
|
||||
try {
|
||||
logger.info('Linting...');
|
||||
const lintCmd = autoFix ? 'npx eslint --fix .' : 'npx eslint';
|
||||
execSync(lintCmd, {stdio: 'inherit'});
|
||||
} catch (e) {
|
||||
// it is gonna throw an error anyway
|
||||
logger.info('Manual linting probably required, check with: npm run lint');
|
||||
}
|
||||
// linting ends.
|
||||
|
||||
if (autoFix) {
|
||||
const unchanged = JSON.parse(execSync(
|
||||
'untracked=$(git ls-files -o --exclude-standard) || exit 1; ' +
|
||||
'git diff-files --quiet && [ -z "$untracked" ] && echo true || echo false'));
|
||||
if (!unchanged) {
|
||||
// Display a diff of changes. Git doesn't diff untracked files, so they must be added to the
|
||||
// index. Use a temporary index file to avoid modifying Git's default index file.
|
||||
execSync('git read-tree HEAD; git add -A && git diff-index -p --cached HEAD && echo ""', {
|
||||
env: {...process.env, GIT_INDEX_FILE: '.git/checkPlugin.index'},
|
||||
stdio: 'inherit',
|
||||
});
|
||||
await fsp.unlink(`${pluginPath}/.git/checkPlugin.index`);
|
||||
|
||||
const commitCmd = [
|
||||
'git add -A',
|
||||
'git commit -m "autofixes from Etherpad checkPlugin.js"',
|
||||
].join(' && ');
|
||||
if (autoCommit) {
|
||||
logger.info('Committing changes...');
|
||||
execSync(commitCmd, {stdio: 'inherit'});
|
||||
} else {
|
||||
logger.info('Fixes applied. Check the above git diff then run the following command:');
|
||||
logger.info(`(cd node_modules/${pluginName} && ${commitCmd})`);
|
||||
}
|
||||
const pushCmd = 'git push';
|
||||
if (autoPush) {
|
||||
logger.info('Pushing new commit...');
|
||||
execSync(pushCmd, {stdio: 'inherit'});
|
||||
} else {
|
||||
logger.info('Changes committed. To push, run the following command:');
|
||||
logger.info(`(cd node_modules/${pluginName} && ${pushCmd})`);
|
||||
}
|
||||
} else {
|
||||
logger.info('No changes.');
|
||||
}
|
||||
}
|
||||
|
||||
logger.info('Finished');
|
||||
})();
|
39
bin/plugins/getCorePlugins.sh
Executable file
39
bin/plugins/getCorePlugins.sh
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
newline='
|
||||
'
|
||||
|
||||
pecho () { printf %s\\n "$*"; }
|
||||
log () { pecho "$@"; }
|
||||
error () { log "ERROR: $@" >&2; }
|
||||
fatal () { error "$@"; exit 1; }
|
||||
|
||||
mydir=$(cd "${0%/*}" && pwd -P) || exit 1
|
||||
cd "${mydir}/../.."
|
||||
pdir=$(cd .. && pwd -P) || exit 1
|
||||
|
||||
plugins=$("${mydir}/listOfficialPlugins") || exit 1
|
||||
for d in ${plugins}; do
|
||||
log "============================================================"
|
||||
log "${d}"
|
||||
log "============================================================"
|
||||
fd=${pdir}/${d}
|
||||
repo=git@github.com:ether/${plugin}.git
|
||||
[ -d "${fd}" ] || {
|
||||
log "Cloning ${repo} to ${fd}..."
|
||||
(cd "${pdir}" && git clone "${repo}" "${d}") || exit 1
|
||||
} || exit 1
|
||||
log "Fetching latest commits..."
|
||||
(cd "${fd}" && git pull --ff-only) || exit 1
|
||||
log "Getting plugin name..."
|
||||
pn=$(cd "${fd}" && npx -c 'printf %s\\n "${npm_package_name}"') || exit 1
|
||||
[ -n "${pn}" ] || fatal "Unable to determine plugin name for ${d}"
|
||||
md=node_modules/${pn}
|
||||
[ -d "${md}" ] || {
|
||||
log "Installing plugin to ${md}..."
|
||||
ln -s ../../"${d}" "${md}"
|
||||
} || exit 1
|
||||
[ "${md}" -ef "${fd}" ] || fatal "${md} is not a symlink to ${fd}"
|
||||
done
|
135
bin/plugins/lib/CONTRIBUTING.md
Normal file
135
bin/plugins/lib/CONTRIBUTING.md
Normal file
|
@ -0,0 +1,135 @@
|
|||
# Contributor Guidelines
|
||||
(Please talk to people on the mailing list before you change this page, see our section on [how to get in touch](https://github.com/ether/etherpad-lite#get-in-touch))
|
||||
|
||||
## Pull requests
|
||||
|
||||
* the commit series in the PR should be _linear_ (it **should not contain merge commits**). This is necessary because we want to be able to [bisect](https://en.wikipedia.org/wiki/Bisection_(software_engineering)) bugs easily. Rewrite history/perform a rebase if necessary
|
||||
* PRs should be issued against the **develop** branch: we never pull directly into **master**
|
||||
* PRs **should not have conflicts** with develop. If there are, please resolve them rebasing and force-pushing
|
||||
* when preparing your PR, please make sure that you have included the relevant **changes to the documentation** (preferably with usage examples)
|
||||
* contain meaningful and detailed **commit messages** in the form:
|
||||
```
|
||||
submodule: description
|
||||
|
||||
longer description of the change you have made, eventually mentioning the
|
||||
number of the issue that is being fixed, in the form: Fixes #someIssueNumber
|
||||
```
|
||||
* if the PR is a **bug fix**:
|
||||
* the first commit in the series must be a test that shows the failure
|
||||
* subsequent commits will fix the bug and make the test pass
|
||||
* the final commit message should include the text `Fixes: #xxx` to link it to its bug report
|
||||
* think about stability: code has to be backwards compatible as much as possible. Always **assume your code will be run with an older version of the DB/config file**
|
||||
* if you want to remove a feature, **deprecate it instead**:
|
||||
* write an issue with your deprecation plan
|
||||
* output a `WARN` in the log informing that the feature is going to be removed
|
||||
* remove the feature in the next version
|
||||
* if you want to add a new feature, put it under a **feature flag**:
|
||||
* once the new feature has reached a minimal level of stability, do a PR for it, so it can be integrated early
|
||||
* expose a mechanism for enabling/disabling the feature
|
||||
* the new feature should be **disabled** by default. With the feature disabled, the code path should be exactly the same as before your contribution. This is a __necessary condition__ for early integration
|
||||
* think of the PR not as something that __you wrote__, but as something that __someone else is going to read__. The commit series in the PR should tell a novice developer the story of your thoughts when developing it
|
||||
|
||||
## How to write a bug report
|
||||
|
||||
* Please be polite, we all are humans and problems can occur.
|
||||
* Please add as much information as possible, for example
|
||||
* client os(s) and version(s)
|
||||
* browser(s) and version(s), is the problem reproducible on different clients
|
||||
* special environments like firewalls or antivirus
|
||||
* host os and version
|
||||
* npm and nodejs version
|
||||
* Logfiles if available
|
||||
* steps to reproduce
|
||||
* what you expected to happen
|
||||
* what actually happened
|
||||
* Please format logfiles and code examples with markdown see github Markdown help below the issue textarea for more information.
|
||||
|
||||
If you send logfiles, please set the loglevel switch DEBUG in your settings.json file:
|
||||
|
||||
```
|
||||
/* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
|
||||
"loglevel": "DEBUG",
|
||||
```
|
||||
|
||||
The logfile location is defined in startup script or the log is directly shown in the commandline after you have started etherpad.
|
||||
|
||||
## General goals of Etherpad
|
||||
To make sure everybody is going in the same direction:
|
||||
* easy to install for admins and easy to use for people
|
||||
* easy to integrate into other apps, but also usable as standalone
|
||||
* lightweight and scalable
|
||||
* extensible, as much functionality should be extendable with plugins so changes don't have to be done in core.
|
||||
Also, keep it maintainable. We don't wanna end up as the monster Etherpad was!
|
||||
|
||||
## How to work with git?
|
||||
* Don't work in your master branch.
|
||||
* Make a new branch for every feature you're working on. (This ensures that you can work you can do lots of small, independent pull requests instead of one big one with complete different features)
|
||||
* Don't use the online edit function of github (this only creates ugly and not working commits!)
|
||||
* Try to make clean commits that are easy readable (including descriptive commit messages!)
|
||||
* Test before you push. Sounds easy, it isn't!
|
||||
* Don't check in stuff that gets generated during build or runtime
|
||||
* Make small pull requests that are easy to review but make sure they do add value by themselves / individually
|
||||
|
||||
## Coding style
|
||||
* Do write comments. (You don't have to comment every line, but if you come up with something that's a bit complex/weird, just leave a comment. Bear in mind that you will probably leave the project at some point and that other people will read your code. Undocumented huge amounts of code are worthless!)
|
||||
* Never ever use tabs
|
||||
* Indentation: JS/CSS: 2 spaces; HTML: 4 spaces
|
||||
* Don't overengineer. Don't try to solve any possible problem in one step, but try to solve problems as easy as possible and improve the solution over time!
|
||||
* Do generalize sooner or later! (if an old solution, quickly hacked together, poses more problems than it solves today, refactor it!)
|
||||
* Keep it compatible. Do not introduce changes to the public API, db schema or configurations too lightly. Don't make incompatible changes without good reasons!
|
||||
* If you do make changes, document them! (see below)
|
||||
* Use protocol independent urls "//"
|
||||
|
||||
## Branching model / git workflow
|
||||
see git flow http://nvie.com/posts/a-successful-git-branching-model/
|
||||
|
||||
### `master` branch
|
||||
* the stable
|
||||
* This is the branch everyone should use for production stuff
|
||||
|
||||
### `develop`branch
|
||||
* everything that is READY to go into master at some point in time
|
||||
* This stuff is tested and ready to go out
|
||||
|
||||
### release branches
|
||||
* stuff that should go into master very soon
|
||||
* only bugfixes go into these (see http://nvie.com/posts/a-successful-git-branching-model/ for why)
|
||||
* we should not be blocking new features to develop, just because we feel that we should be releasing it to master soon. This is the situation that release branches solve/handle.
|
||||
|
||||
### hotfix branches
|
||||
* fixes for bugs in master
|
||||
|
||||
### feature branches (in your own repos)
|
||||
* these are the branches where you develop your features in
|
||||
* If it's ready to go out, it will be merged into develop
|
||||
|
||||
Over the time we pull features from feature branches into the develop branch. Every month we pull from develop into master. Bugs in master get fixed in hotfix branches. These branches will get merged into master AND develop. There should never be commits in master that aren't in develop
|
||||
|
||||
## Documentation
|
||||
The docs are in the `doc/` folder in the git repository, so people can easily find the suitable docs for the current git revision.
|
||||
|
||||
Documentation should be kept up-to-date. This means, whenever you add a new API method, add a new hook or change the database model, pack the relevant changes to the docs in the same pull request.
|
||||
|
||||
You can build the docs e.g. produce html, using `make docs`. At some point in the future we will provide an online documentation. The current documentation in the github wiki should always reflect the state of `master` (!), since there are no docs in master, yet.
|
||||
|
||||
## Testing
|
||||
|
||||
Front-end tests are found in the `src/tests/frontend/` folder in the repository.
|
||||
Run them by pointing your browser to `<yourdomainhere>/tests/frontend`.
|
||||
|
||||
Back-end tests can be run from the `src` directory, via `npm test`.
|
||||
|
||||
## Things you can help with
|
||||
Etherpad is much more than software. So if you aren't a developer then worry not, there is still a LOT you can do! A big part of what we do is community engagement. You can help in the following ways
|
||||
* Triage bugs (applying labels) and confirming their existence
|
||||
* Testing fixes (simply applying them and seeing if it fixes your issue or not) - Some git experience required
|
||||
* Notifying large site admins of new releases
|
||||
* Writing Changelogs for releases
|
||||
* Creating Windows packages
|
||||
* Creating releases
|
||||
* Bumping dependencies periodically and checking they don't break anything
|
||||
* Write proposals for grants
|
||||
* Co-Author and Publish CVEs
|
||||
* Work with SFC to maintain legal side of project
|
||||
* Maintain TODO page - https://github.com/ether/etherpad-lite/wiki/TODO#IMPORTANT_TODOS
|
||||
|
201
bin/plugins/lib/LICENSE
Normal file
201
bin/plugins/lib/LICENSE
Normal file
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
47
bin/plugins/lib/README.md
Executable file
47
bin/plugins/lib/README.md
Executable file
|
@ -0,0 +1,47 @@
|
|||
# [plugin_name]
|
||||
|
||||
TODO: Describe the plugin.
|
||||
|
||||
## Example animated gif of usage if appropriate
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
From the Etherpad working directory, run:
|
||||
|
||||
```shell
|
||||
npm install --no-save --legacy-peer-deps [plugin_name]
|
||||
```
|
||||
|
||||
Or, install from Etherpad's `/admin/plugins` page.
|
||||
|
||||
## Configuration
|
||||
|
||||
TODO
|
||||
|
||||
## Testing
|
||||
|
||||
To run the backend tests, run the following from the Etherpad working directory:
|
||||
|
||||
```shell
|
||||
(cd src && pnpm test)
|
||||
```
|
||||
|
||||
To run the frontend tests, visit: http://localhost:9001/tests/frontend/
|
||||
|
||||
## Copyright and License
|
||||
|
||||
Copyright © [yyyy] [name of copyright owner]
|
||||
and the [plugin_name] authors and contributors
|
||||
|
||||
Licensed under the [Apache License, Version 2.0](LICENSE) (the "License"); you
|
||||
may not use this file except in compliance with the License. You may obtain a
|
||||
copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations under the License.
|
75
bin/plugins/lib/backend-tests.yml
Normal file
75
bin/plugins/lib/backend-tests.yml
Normal file
|
@ -0,0 +1,75 @@
|
|||
name: "Backend tests"
|
||||
|
||||
# any branch is useful for testing before a PR is submitted
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
withplugins:
|
||||
# run on pushes to any branch
|
||||
# run on PRs from external forks
|
||||
if: |
|
||||
(github.event_name != 'pull_request')
|
||||
|| (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id)
|
||||
name: with Plugins
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
-
|
||||
name: Install libreoffice
|
||||
run: |
|
||||
sudo add-apt-repository -y ppa:libreoffice/ppa
|
||||
sudo apt update
|
||||
sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport
|
||||
-
|
||||
name: Install etherpad core
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ether/etherpad-lite
|
||||
-
|
||||
name: Checkout plugin repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: ./node_modules/__tmp
|
||||
-
|
||||
name: Determine plugin name
|
||||
id: plugin_name
|
||||
run: |
|
||||
cd ./node_modules/__tmp
|
||||
npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"'
|
||||
-
|
||||
name: Rename plugin directory
|
||||
run: |
|
||||
mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}"
|
||||
env:
|
||||
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
||||
-
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12
|
||||
cache: 'npm'
|
||||
cache-dependency-path: |
|
||||
src/package-lock.json
|
||||
bin/doc/package-lock.json
|
||||
node_modules/${{ steps.plugin_name.outputs.plugin_name }}/package-lock.json
|
||||
-
|
||||
name: Install plugin dependencies
|
||||
run: |
|
||||
cd ./node_modules/"${PLUGIN_NAME}"
|
||||
npm ci
|
||||
env:
|
||||
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
||||
# Etherpad core dependencies must be installed after installing the
|
||||
# plugin's dependencies, otherwise npm will try to hoist common
|
||||
# dependencies by removing them from src/node_modules and installing them
|
||||
# in the top-level node_modules. As of v6.14.10, npm's hoist logic appears
|
||||
# to be buggy, because it sometimes removes dependencies from
|
||||
# src/node_modules but fails to add them to the top-level node_modules.
|
||||
# Even if npm correctly hoists the dependencies, the hoisting seems to
|
||||
# confuse tools such as `npm outdated`, `npm update`, and some ESLint
|
||||
# rules.
|
||||
-
|
||||
name: Install Etherpad core dependencies
|
||||
run: bin/installDeps.sh
|
||||
-
|
||||
name: Run the backend tests
|
||||
run: cd src && pnpm test
|
11
bin/plugins/lib/dependabot.yml
Normal file
11
bin/plugins/lib/dependabot.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
versioning-strategy: "increase"
|
9
bin/plugins/lib/eslintrc.cjs
Normal file
9
bin/plugins/lib/eslintrc.cjs
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
// This is a workaround for https://github.com/eslint/eslint/issues/3458
|
||||
require('eslint-config-etherpad/patch/modern-module-resolution');
|
||||
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: 'etherpad/plugin',
|
||||
};
|
110
bin/plugins/lib/frontend-tests.yml
Normal file
110
bin/plugins/lib/frontend-tests.yml
Normal file
|
@ -0,0 +1,110 @@
|
|||
# Publicly credit Sauce Labs because they generously support open source
|
||||
# projects.
|
||||
name: "frontend tests powered by Sauce Labs"
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
-
|
||||
name: Fail if Dependabot
|
||||
if: github.actor == 'dependabot[bot]'
|
||||
run: |
|
||||
cat <<EOF >&2
|
||||
Frontend tests skipped because Dependabot can't access secrets.
|
||||
Manually re-run the jobs to run the frontend tests.
|
||||
For more information, see:
|
||||
https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/
|
||||
EOF
|
||||
exit 1
|
||||
-
|
||||
name: Generate Sauce Labs strings
|
||||
id: sauce_strings
|
||||
run: |
|
||||
printf %s\\n '::set-output name=name::${{github.event.repository.name}} ${{ github.workflow }} - ${{ github.job }}'
|
||||
printf %s\\n '::set-output name=tunnel_id::${{ github.run_id }}-${{ github.run_number }}-${{ github.job }}'
|
||||
-
|
||||
name: Check out Etherpad core
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ether/etherpad-lite
|
||||
-
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12
|
||||
cache: 'npm'
|
||||
cache-dependency-path: |
|
||||
src/package-lock.json
|
||||
bin/doc/package-lock.json
|
||||
-
|
||||
name: Check out the plugin
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: ./node_modules/__tmp
|
||||
-
|
||||
name: export GIT_HASH to env
|
||||
id: environment
|
||||
run: |
|
||||
cd ./node_modules/__tmp
|
||||
echo "::set-output name=sha_short::$(git rev-parse --short ${{ github.sha }})"
|
||||
-
|
||||
name: Determine plugin name
|
||||
id: plugin_name
|
||||
run: |
|
||||
cd ./node_modules/__tmp
|
||||
npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"'
|
||||
-
|
||||
name: Rename plugin directory
|
||||
env:
|
||||
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
||||
run: |
|
||||
mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}"
|
||||
-
|
||||
name: Install plugin dependencies
|
||||
env:
|
||||
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
||||
run: |
|
||||
cd ./node_modules/"${PLUGIN_NAME}"
|
||||
npm ci
|
||||
# Etherpad core dependencies must be installed after installing the
|
||||
# plugin's dependencies, otherwise npm will try to hoist common
|
||||
# dependencies by removing them from src/node_modules and installing them
|
||||
# in the top-level node_modules. As of v6.14.10, npm's hoist logic appears
|
||||
# to be buggy, because it sometimes removes dependencies from
|
||||
# src/node_modules but fails to add them to the top-level node_modules.
|
||||
# Even if npm correctly hoists the dependencies, the hoisting seems to
|
||||
# confuse tools such as `npm outdated`, `npm update`, and some ESLint
|
||||
# rules.
|
||||
-
|
||||
name: Install Etherpad core dependencies
|
||||
run: bin/installDeps.sh
|
||||
-
|
||||
name: Create settings.json
|
||||
run: cp settings.json.template settings.json
|
||||
-
|
||||
name: Disable import/export rate limiting
|
||||
run: |
|
||||
sed -e '/^ *"importExportRateLimiting":/,/^ *\}/ s/"max":.*/"max": 0/' -i settings.json
|
||||
-
|
||||
name: Remove standard frontend test files
|
||||
run: rm -rf src/tests/frontend/specs
|
||||
-
|
||||
uses: saucelabs/sauce-connect-action@v2.1.1
|
||||
with:
|
||||
username: ${{ secrets.SAUCE_USERNAME }}
|
||||
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
|
||||
tunnelIdentifier: ${{ steps.sauce_strings.outputs.tunnel_id }}
|
||||
-
|
||||
name: Run the frontend tests
|
||||
shell: bash
|
||||
env:
|
||||
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
|
||||
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
|
||||
SAUCE_NAME: ${{ steps.sauce_strings.outputs.name }}
|
||||
TRAVIS_JOB_NUMBER: ${{ steps.sauce_strings.outputs.tunnel_id }}
|
||||
GIT_HASH: ${{ steps.environment.outputs.sha_short }}
|
||||
run: |
|
||||
src/tests/frontend/travis/runner.sh
|
3
bin/plugins/lib/gitignore
Executable file
3
bin/plugins/lib/gitignore
Executable file
|
@ -0,0 +1,3 @@
|
|||
.DS_Store
|
||||
node_modules/
|
||||
npm-debug.log
|
122
bin/plugins/lib/npmpublish.yml
Normal file
122
bin/plugins/lib/npmpublish.yml
Normal file
|
@ -0,0 +1,122 @@
|
|||
# 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:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Clone ether/etherpad-lite to ../etherpad-lite so that ep_etherpad-lite
|
||||
# can be "installed" in this plugin's node_modules. The checkout v2 action
|
||||
# doesn't support cloning outside of $GITHUB_WORKSPACE (see
|
||||
# https://github.com/actions/checkout/issues/197), so the repo is first
|
||||
# cloned to etherpad-lite then moved to ../etherpad-lite. To avoid
|
||||
# conflicts with this plugin's clone, etherpad-lite must be cloned and
|
||||
# moved out before this plugin's repo is cloned to $GITHUB_WORKSPACE.
|
||||
-
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ether/etherpad-lite
|
||||
path: etherpad-lite
|
||||
-
|
||||
run: mv etherpad-lite ..
|
||||
# etherpad-lite has been moved outside of $GITHUB_WORKSPACE, so it is now
|
||||
# safe to clone this plugin's repo to $GITHUB_WORKSPACE.
|
||||
-
|
||||
uses: actions/checkout@v3
|
||||
# This is necessary for actions/setup-node because '..' can't be used in
|
||||
# cache-dependency-path.
|
||||
-
|
||||
name: Create ep_etherpad-lite symlink
|
||||
run: |
|
||||
mkdir -p node_modules
|
||||
ln -s ../../etherpad-lite/src node_modules/ep_etherpad-lite
|
||||
-
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12
|
||||
cache: 'npm'
|
||||
cache-dependency-path: |
|
||||
node_modules/ep_etherpad-lite/package-lock.json
|
||||
node_modules/ep_etherpad-lite/bin/doc/package-lock.json
|
||||
package-lock.json
|
||||
# All of ep_etherpad-lite's devDependencies are installed because the
|
||||
# plugin might do `require('ep_etherpad-lite/node_modules/${devDep}')`.
|
||||
# Eventually it would be nice to create an ESLint plugin that prohibits
|
||||
# Etherpad plugins from piggybacking off of ep_etherpad-lite's
|
||||
# devDependencies. If we had that, we could change this line to only
|
||||
# install production dependencies.
|
||||
-
|
||||
run: cd ../etherpad-lite/src && npm ci
|
||||
-
|
||||
run: npm ci
|
||||
# This runs some sanity checks and creates a symlink at
|
||||
# node_modules/ep_etherpad-lite that points to ../../etherpad-lite/src.
|
||||
# This step must be done after `npm ci` installs the plugin's dependencies
|
||||
# because npm "helpfully" cleans up such symlinks. :( Installing
|
||||
# ep_etherpad-lite in the plugin's node_modules prevents lint errors and
|
||||
# unit test failures if the plugin does `require('ep_etherpad-lite/foo')`.
|
||||
-
|
||||
run: npm install --no-save ep_etherpad-lite@file:../etherpad-lite/src
|
||||
-
|
||||
run: npm test
|
||||
-
|
||||
run: npm run lint
|
||||
|
||||
publish-npm:
|
||||
if: github.event_name == 'push'
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12
|
||||
registry-url: https://registry.npmjs.org/
|
||||
cache: 'npm'
|
||||
-
|
||||
name: Bump version (patch)
|
||||
run: |
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1
|
||||
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1
|
||||
[ "${NEW_COMMITS}" -gt 0 ] || exit 0
|
||||
git config user.name 'github-actions[bot]'
|
||||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||
npm ci
|
||||
npm version patch
|
||||
git push --follow-tags
|
||||
# This is required if the package has a prepare script that uses something
|
||||
# in dependencies or devDependencies.
|
||||
-
|
||||
run: npm ci
|
||||
# `npm publish` must come after `git push` otherwise there is a race
|
||||
# condition: If two PRs are merged back-to-back then master/main will be
|
||||
# updated with the commits from the second PR before the first PR's
|
||||
# workflow has a chance to push the commit generated by `npm version
|
||||
# patch`. This causes the first PR's `git push` step to fail after the
|
||||
# package has already been published, which in turn will cause all future
|
||||
# workflow runs to fail because they will all attempt to use the same
|
||||
# already-used version number. By running `npm publish` after `git push`,
|
||||
# back-to-back merges will cause the first merge's workflow to fail but
|
||||
# the second's will succeed.
|
||||
-
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
-
|
||||
name: Add package to etherpad organization
|
||||
run: npm access grant read-write etherpad:developers
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
14
bin/plugins/listOfficialPlugins
Executable file
14
bin/plugins/listOfficialPlugins
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
newline='
|
||||
'
|
||||
mydir=$(cd "${0%/*}" && pwd -P) || exit 1
|
||||
cd "${mydir}/../.."
|
||||
pdir=$(cd .. && pwd -P) || exit 1
|
||||
plugins=
|
||||
for p in "" "&page=2" "&page=3"; do
|
||||
curlOut=$(curl "https://api.github.com/users/ether/repos?per_page=100${p}") || exit 1
|
||||
plugins=${plugins}${newline}$(printf %s\\n "${curlOut}" \
|
||||
| sed -n -e 's;.*git@github.com:ether/\(ep_[^"]*\)\.git.*;\1;p');
|
||||
done
|
||||
printf %s\\n "${plugins}" | sort -u | grep -v '^[[:space:]]*$'
|
14
bin/plugins/reTestAllPlugins.sh
Executable file
14
bin/plugins/reTestAllPlugins.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
echo "herp";
|
||||
for dir in `ls node_modules`;
|
||||
do
|
||||
echo $dir
|
||||
if [[ $dir == *"ep_"* ]]; then
|
||||
if [[ $dir != "ep_etherpad-lite" ]]; then
|
||||
# node 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
|
||||
cd ../..
|
||||
fi
|
||||
fi
|
||||
done
|
20
bin/plugins/stalePlugins.js
Normal file
20
bin/plugins/stalePlugins.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
// Returns a list of stale plugins and their authors email
|
||||
|
||||
const superagent = require('superagent');
|
||||
const currentTime = new Date();
|
||||
|
||||
(async () => {
|
||||
const res = await superagent.get('https://static.etherpad.org/plugins.full.json');
|
||||
const plugins = JSON.parse(res.text);
|
||||
for (const plugin of Object.keys(plugins)) {
|
||||
const name = plugins[plugin].data.name;
|
||||
const date = new Date(plugins[plugin].time);
|
||||
const diffTime = Math.abs(currentTime - date);
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||
if (diffDays > (365 * 2)) {
|
||||
console.log(`${name}, ${plugins[plugin].data.maintainers[0].email}`);
|
||||
}
|
||||
}
|
||||
})();
|
17
bin/plugins/updateAllPluginsScript.sh
Executable file
17
bin/plugins/updateAllPluginsScript.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
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&page=2" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone
|
||||
GHUSER=johnmclear; curl "https://api.github.com/users/$GHUSER/repos?per_page=1000&page=3" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone
|
||||
GHUSER=johnmclear; curl "https://api.github.com/users/$GHUSER/repos?per_page=1000&page=4" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone
|
||||
cd ..
|
||||
|
||||
for dir in `ls node_modules`;
|
||||
do
|
||||
# echo $0
|
||||
if [[ $dir == *"ep_"* ]]; then
|
||||
if [[ $dir != "ep_etherpad-lite" ]]; then
|
||||
node bin/plugins/checkPlugin.js $dir autopush
|
||||
fi
|
||||
fi
|
||||
# echo $dir
|
||||
done
|
9
bin/plugins/updateCorePlugins.sh
Executable file
9
bin/plugins/updateCorePlugins.sh
Executable 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" autopush
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue