- Introduce `fresh-npm-install.sh` to automate clean npm environment
setup.
- Revert workaround 924b326244, resolved
by updating Font Awesome.
- Remove `vue-template-compiler` and `@vue/test-utils` from
dependencies, they're obsolete in 2.7.
- Update anchor references to start with lower case in line with
MD051/link-fragments, introduced by updated `markdownlint`.
- Upgrade cypress to > 10, which includes:
- Change spec extensions from `*.spec.js` to `*.cy.js`.
- Change configuration file from `cypress.json` to
`cypress.config.ts`.
- Remove most configurations from `cypress/plugins/index.js`. These
configurations were initially generated by Vue CLI but obsoleted in
newer cypress versions.
- Lock Typescript version to 4.6.x due to lack of support in
unmaintained Vue CLI TypeScript plugin (see vuejs/vue-cli#7401).
- Use `setWindowOpenHandler` on Electron, replacing deprecated
`new-event` event.
- Document inability to upgrade `typescript-eslint` dependencies because
`@vue/eslint-config-typescript` does not support them. See
vuejs/eslint-config-typescript#60, vuejs/eslint-config-typescript#59,
vuejs/eslint-config-typescript#57.
- Fix `typescript` version to 4.6.X and `tslib` version to 2.4.x,
unit tests exit with a maximum call stack size exceeded error:
```
...
MOCHA Testing...
RUNTIME EXCEPTION Exception occurred while loading your tests
[=========================] 100% (completed)
RangeError: Maximum call stack size exceeded
at RegExp.exec (<anonymous>)
at retrieveSourceMapURL (/project/node_modules/source-map-support/source-map-support.js:174:21)
at Array.<anonymous> (/project/node_modules/source-map-support/source-map-support.js:186:26)
at /project/node_modules/source-map-support/source-map-support.js:85:24
at mapSourcePosition (/project/node_modules/source-map-support/source-map-support.js:216:21)
...
```
Issue has been reported but not fixed, suggested solutions did not
work, see evanw/node-source-map-support#252.
- Update `vue-cli-plugin-electron-builder` to latest alpha version. This
allows upgrading `ts-loader` to latest and using latest
`electron-builder`. Change `main` property value in `package.json` to
`index.js` for successful electron builds (see
nklayman/vue-cli-plugin-electron-builder#188).
96 lines
2.0 KiB
Bash
Executable File
96 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Description:
|
|
# This script ensures npm is available, removes existing node modules, optionally
|
|
# removes package-lock.json (when -n flag is used), installs dependencies and runs unit tests.
|
|
# Usage:
|
|
# ./fresh-npm-install.sh # Regular execution
|
|
# ./fresh-npm-install.sh -n # Non-deterministic mode (removes package-lock.json)
|
|
|
|
declare NON_DETERMINISTIC_FLAG=0
|
|
|
|
|
|
main() {
|
|
parse_args "$@"
|
|
ensure_npm_is_available
|
|
ensure_npm_root
|
|
remove_existing_modules
|
|
if [[ $NON_DETERMINISTIC_FLAG -eq 1 ]]; then
|
|
remove_package_lock_json
|
|
fi
|
|
install_dependencies
|
|
run_unit_tests
|
|
}
|
|
|
|
ensure_npm_is_available() {
|
|
if ! command -v npm &> /dev/null; then
|
|
log::fatal 'npm could not be found, please install it first.'
|
|
fi
|
|
}
|
|
|
|
ensure_npm_root() {
|
|
if [ ! -f package.json ]; then
|
|
log::fatal 'Current directory is not a npm root. Please run the script in a npm root directory.'
|
|
fi
|
|
}
|
|
|
|
remove_existing_modules() {
|
|
if [ -d ./node_modules ]; then
|
|
log::info 'Removing existing node modules...'
|
|
if ! rm -rf ./node_modules; then
|
|
log::fatal 'Could not remove existing node modules.'
|
|
fi
|
|
fi
|
|
}
|
|
|
|
install_dependencies() {
|
|
log::info 'Installing dependencies...'
|
|
if ! npm install; then
|
|
log::fatal 'Failed to install dependencies.'
|
|
fi
|
|
}
|
|
|
|
remove_package_lock_json() {
|
|
if [ -f ./package-lock.json ]; then
|
|
log::info 'Removing package-lock.json...'
|
|
if ! rm -rf ./package-lock.json; then
|
|
log::fatal 'Could not remove package-lock.json.'
|
|
fi
|
|
fi
|
|
}
|
|
|
|
run_unit_tests() {
|
|
log::info 'Running unit tests...'
|
|
if ! npm run test:unit; then
|
|
pwd
|
|
log::fatal 'Failed to run unit tests.'
|
|
fi
|
|
}
|
|
|
|
log::info() {
|
|
local -r message="$1"
|
|
echo "📣 ${message}"
|
|
}
|
|
|
|
log::fatal() {
|
|
local -r message="$1"
|
|
echo "❌ ${message}" >&2
|
|
exit 1
|
|
}
|
|
|
|
parse_args() {
|
|
while getopts "n" opt; do
|
|
case ${opt} in
|
|
n)
|
|
NON_DETERMINISTIC_FLAG=1
|
|
;;
|
|
\?)
|
|
echo "Invalid option: $OPTARG" 1>&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
main "$1"
|