Added pnpm (#6148)

* Added pnpm

* Removed cache for npm.

* Fixed.

* Added pnpm

* Fixed install script.

* Fixed windows script.

* Fixed.

* Fixed.

* Fixed install.

* Only install direct dependencies.

* Only install direct dependencies.

* Only install direct dependencies.

* Fixed windows build.

* fixed.

* fixed deploy.

* Fixed docker build.

* Fixed windows deploy

* Fixed docker build

* Fixed healthcheck.

* fixed.

* Fixed detection of live plugin managers dependencies.

* fixed.

* Remove Node 19 as it is not supported.

* Fixed.

* Fixed installDeps.sh

* Fixed.

* Fixed windows install.

* Fixed cypress path.

* Fixed.

* Run etherpad in background.

* Install cypress.
This commit is contained in:
SamTV12345 2024-02-11 09:51:42 +01:00 committed by GitHub
parent 96c81906cb
commit 361b38ae50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 5804 additions and 10007 deletions

1
src/.npmrc Normal file
View file

@ -0,0 +1 @@
auto-install-peers=false

View file

@ -33,7 +33,8 @@ try export GIT_WORK_TREE=${TMP_FOLDER}; git checkout HEAD -f \
|| fatal "failed to copy etherpad to temporary folder"
try mkdir "${TMP_FOLDER}"/.git
try git rev-parse HEAD >${TMP_FOLDER}/.git/HEAD
try cp -r ./src/node_modules "${TMP_FOLDER}"/src/node_modules
# Disable symlinks to avoid problems with Windows
#try pnpm i "${TMP_FOLDER}"/src/node_modules
try cd "${TMP_FOLDER}"
[ -f src/package.json ] || fatal "failed to copy etherpad to temporary folder"
@ -42,16 +43,19 @@ try cd "${TMP_FOLDER}"
# making the windows package smaller
export NODE_ENV=production
log "do a normal unix install first..."
try ./src/bin/installDeps.sh
rm -rf node_modules || true
rm -rf src/node_modules || true
#log "do a normal unix install first..."
#$(try cd src && ./bin/installDeps.sh)
log "copy the windows settings template..."
try cp settings.json.template settings.json
log "resolve symbolic links..."
try cp -rL node_modules node_modules_resolved
try rm -rf node_modules
try mv node_modules_resolved node_modules
#log "resolve symbolic links..."
#try cp -rL node_modules node_modules_resolved
#try rm -rf node_modules
#try mv node_modules_resolved node_modules
log "download windows node..."
try wget "https://nodejs.org/dist/latest-v20.x/win-x64/node.exe" -O node.exe

View file

@ -1,13 +0,0 @@
{
"name": "node-doc-generator",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"marked": {
"version": "12.0.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-12.0.0.tgz",
"integrity": "sha512-Vkwtq9rLqXryZnWaQc86+FHLC6tr/fycMfYAhiOIXkrNmeGAyhSxjqu0Rs1i0bBqw5u0S7+lV9fdH2ZSVaoa0w=="
}
}
}

View file

@ -1,15 +0,0 @@
{
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"name": "node-doc-generator",
"description": "Internal tool for generating Node.js API docs",
"version": "0.0.0",
"engines": {
"node": ">=12.17.0"
},
"dependencies": {
"marked": "^12.0.0"
},
"devDependencies": {},
"optionalDependencies": {},
"bin": "./generate.js"
}

View file

@ -8,17 +8,13 @@ cd "${MY_DIR}/../.." || exit 1
# Source constants and useful functions
. src/bin/functions.sh
is_cmd pnpm || npm install pnpm -g
# Is node installed?
# Not checking io.js, default installation creates a symbolic link to node
is_cmd node || fatal "Please install node.js ( https://nodejs.org )"
# Is npm installed?
is_cmd npm || fatal "Please install npm ( https://npmjs.org )"
# Check npm version
require_minimal_version "npm" "$(get_program_version "npm")" \
"$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
# Check node version
require_minimal_version "nodejs" "$(get_program_version "node")" \
"$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
@ -48,10 +44,10 @@ cd src
if [ -z "${ETHERPAD_PRODUCTION}" ]; then
log "Installing dev dependencies"
npm ci --no-optional --omit=optional --include=dev --lockfile-version 1 || exit 1
pnpm i || exit 1
else
log "Installing production dependencies"
npm ci --no-optional --omit=optional --omit=dev --lockfile-version 1 --production || exit 1
pnpm i --production || exit 1
fi
# Remove all minified data to force node creating it new

View file

@ -13,8 +13,8 @@ mkdir node_modules
cd /D node_modules
mklink /D "ep_etherpad-lite" "..\src"
cd /D "ep_etherpad-lite"
cmd /C npm ci --legacy-peer-deps || exit /B 1
cd /D ..\src
cmd /C pnpm i || exit /B 1
cd /D "%~dp0\..\.."

View file

@ -25,7 +25,7 @@ TODO
To run the backend tests, run the following from the Etherpad working directory:
```shell
(cd src && npm test)
(cd src && pnpm test)
```
To run the frontend tests, visit: http://localhost:9001/tests/frontend/

View file

@ -72,4 +72,4 @@ jobs:
run: src/bin/installDeps.sh
-
name: Run the backend tests
run: cd src && npm test
run: cd src && pnpm test

9809
src/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -49,12 +49,11 @@
"jsdom": "^24.0.0",
"jsonminify": "0.4.2",
"languages4translatewiki": "0.1.3",
"live-plugin-manager": "^0.18.1",
"live-plugin-manager-pnpm": "^0.18.1",
"lodash.clonedeep": "4.5.0",
"log4js": "^6.9.1",
"measured-core": "^2.0.0",
"mime-types": "^2.1.35",
"npm": "^6.14.18",
"openapi-backend": "^5.10.6",
"proxy-addr": "^2.0.7",
"rate-limiter-flexible": "^4.0.1",
@ -100,7 +99,8 @@
},
"engines": {
"node": ">=18.18.2",
"npm": ">=6.14.0"
"npm": ">=6.14.0",
"pnpm": ">=8.3.0"
},
"repository": {
"type": "git",

5418
src/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,10 +6,10 @@ const hooks = require('./hooks');
const runCmd = require('../../../node/utils/run_cmd');
const settings = require('../../../node/utils/Settings');
const axios = require('axios');
const {PluginManager} = require("live-plugin-manager");
const {promises: fs} = require("fs");
const path = require("path");
const {findEtherpadRoot} = require("../../../node/utils/AbsolutePaths");
const {PluginManager} = require('live-plugin-manager-pnpm');
const {promises: fs} = require('fs');
const path = require('path');
const {findEtherpadRoot} = require('../../../node/utils/AbsolutePaths');
const logger = log4js.getLogger('plugins');
exports.manager = new PluginManager();
@ -25,8 +25,8 @@ const onAllTasksFinished = async () => {
};
const headers = {
'User-Agent': 'Etherpad/' + settings.getEpVersion(),
}
'User-Agent': `Etherpad/${settings.getEpVersion()}`,
};
let tasks = 0;
@ -41,24 +41,25 @@ const wrapTaskCb = (cb) => {
};
const migratePluginsFromNodeModules = async () => {
logger.info('start migration of plugins in node_modules')
logger.info('start migration of plugins in node_modules');
// Notes:
// * Do not pass `--prod` otherwise `npm ls` will fail if there is no `package.json`.
// * The `--no-production` flag is required (or the `NODE_ENV` environment variable must be
// unset or set to `development`) because otherwise `npm ls` will not mention any packages
// that are not included in `package.json` (which is expected to not exist).
const cmd = ['npm', 'ls', '--long', '--json', '--depth=0', '--no-production'];
const {dependencies = {}} = JSON.parse(await runCmd(cmd, {stdio: [null, 'string']}));
await Promise.all(Object.entries(dependencies).map(async ([pkg, info]) => {
if (pkg.startsWith(plugins.prefix) && pkg !== 'ep_etherpad-lite') {
if (!info._resolved) {
// Install from node_modules directory
await exports.manager.installFromPath(`${findEtherpadRoot()}/node_modules/${pkg}`);
} else {
await exports.manager.install(pkg);
}
}
}));
const cmd = ['pnpm', 'ls', '--long', '--json', '--depth=0', '--no-production'];
const [{dependencies = {}}] = JSON.parse(await runCmd(cmd,
{stdio: [null, 'string']}));
await Promise.all(Object.entries(dependencies)
.filter(([pkg, info]) => pkg.startsWith(plugins.prefix) && pkg !== 'ep_etherpad-lite')
.map(async ([pkg, info]) => {
if (!info._resolved) {
// Install from node_modules directory
await exports.manager.installFromPath(`${findEtherpadRoot()}/node_modules/${pkg}`);
} else {
await exports.manager.install(pkg);
}
}));
await persistInstalledPlugins();
};
@ -76,22 +77,22 @@ exports.checkForMigration = async () => {
for (const plugin of installedPlugins.plugins) {
if (plugin.name.startsWith(plugins.prefix) && plugin.name !== 'ep_etherpad-lite') {
await exports.manager.install(plugin.name, plugin.version)
await exports.manager.install(plugin.name, plugin.version);
}
}
};
const persistInstalledPlugins = async () => {
let installedPlugins = { plugins: []};
const installedPlugins = {plugins: []};
for (const pkg of Object.values(await plugins.getPackages())) {
installedPlugins.plugins.push({
name: pkg.name,
version: pkg.version,
})
});
}
installedPlugins.plugins = [...new Set(installedPlugins.plugins)];
await fs.writeFile(installedPluginsPath, JSON.stringify(installedPlugins));
}
};
exports.uninstall = async (pluginName, cb = null) => {
cb = wrapTaskCb(cb);
@ -123,14 +124,13 @@ exports.getAvailablePlugins = (maxCacheAge) => {
return resolve(exports.availablePlugins);
}
await axios.get('https://static.etherpad.org/plugins.json', {headers: headers})
await axios.get('https://static.etherpad.org/plugins.json', {headers})
.then((pluginsLoaded) => {
exports.availablePlugins = pluginsLoaded.data;
cacheTimestamp = nowTimestamp;
resolve(exports.availablePlugins);})
.catch(async err => {
return reject(err);
});
resolve(exports.availablePlugins);
})
.catch(async (err) => reject(err));
});
};

View file

@ -16,10 +16,10 @@ const logger = log4js.getLogger('plugins');
// Log the version of npm at startup.
(async () => {
try {
const version = await runCmd(['npm', '--version'], {stdio: [null, 'string']});
logger.info(`npm --version: ${version}`);
const version = await runCmd(['pnpm', '--version'], {stdio: [null, 'string']});
logger.info(`pnpm --version: ${version}`);
} catch (err) {
logger.error(`Failed to get npm version: ${err.stack || err}`);
logger.error(`Failed to get pnpm version: ${err.stack || err}`);
// This isn't a fatal error so don't re-throw.
}
})();