checkPlugins: Support adaptive npmpublish.yml (#4509)

This commit is contained in:
John McLear 2020-11-23 16:34:26 +00:00 committed by GitHub
parent b167f97048
commit c702fdb488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 4 deletions

View file

@ -79,10 +79,29 @@ fs.readdir(pluginPath, function (err, rootFiles) {
fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'});
fs.mkdirSync(pluginPath + '/.github/workflows', {recursive: true}); fs.mkdirSync(pluginPath + '/.github/workflows', {recursive: true});
fs.writeFileSync(path, npmpublish); fs.writeFileSync(path, npmpublish);
hasAutoFixed = true;
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"); 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'); console.log('Setup autopublish for this plugin https://github.com/ether/etherpad-lite/wiki/Plugins:-Automatically-publishing-to-npm-on-commit-to-Github-Repo');
} }
}else{
// autopublish exists, we should check the version..
// checkVersion takes two file paths and checks for a version string in them.
const currVersionFile = fs.readFileSync(path, {encoding: 'utf8', flag: 'r'});
const existingConfigLocation = currVersionFile.indexOf("##ETHERPAD_NPM_V=");
const existingValue = parseInt(currVersionFile.substr(existingConfigLocation+17, existingConfigLocation.length));
const reqVersionFile = fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'});
const reqConfigLocation = reqVersionFile.indexOf("##ETHERPAD_NPM_V=");
const reqValue = parseInt(reqVersionFile.substr(reqConfigLocation+17, reqConfigLocation.length));
if(!existingValue || (reqValue > existingValue)){
const npmpublish =
fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'});
fs.mkdirSync(pluginPath + '/.github/workflows', {recursive: true});
fs.writeFileSync(path, npmpublish);
hasAutoFixed = true;
}
} }
} catch (err) { } catch (err) {
console.error(err); console.error(err);
@ -126,7 +145,7 @@ fs.readdir(pluginPath, function (err, rootFiles) {
if(autoFix){ if(autoFix){
let devDependencies = { let devDependencies = {
"eslint": "^7.14.0", "eslint": "^7.14.0",
"eslint-config-etherpad": "^1.0.8", "eslint-config-etherpad": "^1.0.10",
"eslint-plugin-mocha": "^8.0.0", "eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-arrow": "^1.2.2", "eslint-plugin-prefer-arrow": "^1.2.2",

View file

@ -1,2 +1,4 @@
cd node_modules/ 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 GHUSER=ether; curl "https://api.github.com/users/$GHUSER/repos?per_page=100" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone
GHUSER=ether; curl "https://api.github.com/users/$GHUSER/repos?per_page=100&page=2&" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone
GHUSER=ether; curl "https://api.github.com/users/$GHUSER/repos?per_page=100&page=3&" | grep -o 'git@[^"]*' | grep /ep_ | xargs -L1 git clone

View file

@ -4,6 +4,7 @@
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
![screenshot](https://user-images.githubusercontent.com/220864/99979953-97841d80-2d9f-11eb-9782-5f65817c58f4.PNG)
## Installing ## Installing
npm install [plugin_name] npm install [plugin_name]

View file

@ -4,24 +4,38 @@
name: Node.js Package name: Node.js Package
on: on:
pull_request:
push: push:
branches: branches:
- main - main
- master - master
jobs: jobs:
build: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2
with:
repository: ether/etherpad-lite
path: etherpad-lite
# Work around https://github.com/actions/checkout/issues/197:
- run: mv etherpad-lite ..
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: 12 node-version: 12
- run: cd ../etherpad-lite/src && npm ci
- run: npm ci - run: npm ci
- run: npm install ep_etherpad-lite@file:../etherpad-lite/src
- run: git diff
- run: ls -la node_modules
- run: ls -la node_modules/ep_etherpad-lite/node_modules
- run: npm test - run: npm test
- run: npm run lint
publish-npm: publish-npm:
needs: build if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -37,3 +51,6 @@ jobs:
env: env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: git push --follow-tags - run: git push --follow-tags
##ETHERPAD_NPM_V=1
## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh