mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
2ea8ea1275
Also add symlinks from the old `bin/` and `tests/` locations to avoid breaking scripts and other tools. Motivations: * Scripts and tests no longer have to do dubious things like: require('ep_etherpad-lite/node_modules/foo') to access packages installed as dependencies in `src/package.json`. * Plugins can access the backend test helper library in a non-hacky way: require('ep_etherpad-lite/tests/backend/common') * We can delete the top-level `package.json` without breaking our ability to lint the files in `bin/` and `tests/`. Deleting the top-level `package.json` has downsides: It will cause `npm` to print warnings whenever plugins are installed, npm will no longer be able to enforce a plugin's peer dependency on ep_etherpad-lite, and npm will keep deleting the `node_modules/ep_etherpad-lite` symlink that points to `../src`. But there are significant upsides to deleting the top-level `package.json`: It will drastically speed up plugin installation because `npm` doesn't have to recursively walk the dependencies in `src/package.json`. Also, deleting the top-level `package.json` avoids npm's horrible dependency hoisting behavior (where it moves stuff from `src/node_modules/` to the top-level `node_modules/` directory). Dependency hoisting causes numerous mysterious problems such as silent failures in `npm outdated` and `npm update`. Dependency hoisting also breaks plugins that do: require('ep_etherpad-lite/node_modules/foo')
74 lines
2.1 KiB
Bash
74 lines
2.1 KiB
Bash
# minimum required node version
|
|
REQUIRED_NODE_MAJOR=10
|
|
REQUIRED_NODE_MINOR=13
|
|
|
|
# minimum required npm version
|
|
REQUIRED_NPM_MAJOR=5
|
|
REQUIRED_NPM_MINOR=5
|
|
|
|
pecho() { printf %s\\n "$*"; }
|
|
log() { pecho "$@"; }
|
|
error() { log "ERROR: $@" >&2; }
|
|
fatal() { error "$@"; exit 1; }
|
|
is_cmd() { command -v "$@" >/dev/null 2>&1; }
|
|
|
|
|
|
get_program_version() {
|
|
PROGRAM="$1"
|
|
KIND="${2:-full}"
|
|
PROGRAM_VERSION_STRING=$($PROGRAM --version)
|
|
PROGRAM_VERSION_STRING=${PROGRAM_VERSION_STRING#"v"}
|
|
|
|
DETECTED_MAJOR=$(pecho "$PROGRAM_VERSION_STRING" | cut -s -d "." -f 1)
|
|
[ -n "$DETECTED_MAJOR" ] || fatal "Cannot extract $PROGRAM major version from version string \"$PROGRAM_VERSION_STRING\""
|
|
case "$DETECTED_MAJOR" in
|
|
''|*[!0-9]*)
|
|
fatal "$PROGRAM_LABEL major version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MAJOR\""
|
|
;;
|
|
esac
|
|
|
|
DETECTED_MINOR=$(pecho "$PROGRAM_VERSION_STRING" | cut -s -d "." -f 2)
|
|
[ -n "$DETECTED_MINOR" ] || fatal "Cannot extract $PROGRAM minor version from version string \"$PROGRAM_VERSION_STRING\""
|
|
case "$DETECTED_MINOR" in
|
|
''|*[!0-9]*)
|
|
fatal "$PROGRAM_LABEL minor version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MINOR\""
|
|
esac
|
|
|
|
case $KIND in
|
|
major)
|
|
echo $DETECTED_MAJOR
|
|
exit;;
|
|
minor)
|
|
echo $DETECTED_MINOR
|
|
exit;;
|
|
*)
|
|
echo $DETECTED_MAJOR.$DETECTED_MINOR
|
|
exit;;
|
|
esac
|
|
|
|
echo $VERSION
|
|
}
|
|
|
|
|
|
compute_node_args() {
|
|
ARGS=""
|
|
|
|
NODE_MAJOR=$(get_program_version "node" "major")
|
|
[ "$NODE_MAJOR" -eq "10" ] && ARGS="$ARGS --experimental-worker"
|
|
|
|
echo $ARGS
|
|
}
|
|
|
|
|
|
require_minimal_version() {
|
|
PROGRAM_LABEL="$1"
|
|
VERSION="$2"
|
|
REQUIRED_MAJOR="$3"
|
|
REQUIRED_MINOR="$4"
|
|
|
|
VERSION_MAJOR=$(pecho "$VERSION" | cut -s -d "." -f 1)
|
|
VERSION_MINOR=$(pecho "$VERSION" | cut -s -d "." -f 2)
|
|
|
|
[ "$VERSION_MAJOR" -gt "$REQUIRED_MAJOR" ] || ([ "$VERSION_MAJOR" -eq "$REQUIRED_MAJOR" ] && [ "$VERSION_MINOR" -ge "$REQUIRED_MINOR" ]) \
|
|
|| fatal "Your $PROGRAM_LABEL version \"$VERSION_MAJOR.$VERSION_MINOR\" is too old. $PROGRAM_LABEL $REQUIRED_MAJOR.$REQUIRED_MINOR.x or higher is required."
|
|
}
|