mirror of
				https://github.com/Alfresco/alfresco-ng2-components.git
				synced 2025-10-29 15:21:39 +00:00 
			
		
		
		
	ACS-8610: cleanup demo shell protractor tests (#10148)
This commit is contained in:
		@@ -1,162 +0,0 @@
 | 
			
		||||
## Running a demo project
 | 
			
		||||
 | 
			
		||||
- [start demo shell](#Start-Demo-Shell)
 | 
			
		||||
 | 
			
		||||
The Alfresco application development framework comes with a demo project that you can run to get a
 | 
			
		||||
feel of what's available.
 | 
			
		||||
 | 
			
		||||
* Start by navigating into the app development framework source folder, and then the scripts folder:
 | 
			
		||||
 | 
			
		||||
```ssh
 | 
			
		||||
 cd alfresco-ng2-components
 | 
			
		||||
 cd scripts
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
***npm-check-bundles.sh*** check the bundles in the package npm are present
 | 
			
		||||
 | 
			
		||||
## Options
 | 
			
		||||
 | 
			
		||||
| Option | Description |
 | 
			
		||||
| --- | --- |
 | 
			
		||||
| -h or --help    | show the help  |
 | 
			
		||||
| -r or --registry   | against which register you want to do this check |
 | 
			
		||||
| -v or --version    | the version of the components to check |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# npm-add-pkg.sh
 | 
			
		||||
 | 
			
		||||
***npm-add-pkg.sh*** check the bundles in the package npm are present
 | 
			
		||||
 | 
			
		||||
Add a package across all the pacakge json in the project
 | 
			
		||||
 | 
			
		||||
## Options
 | 
			
		||||
 | 
			
		||||
| Option | Description |
 | 
			
		||||
| --- | --- |
 | 
			
		||||
| -h or --help    | show the help  |
 | 
			
		||||
| --save   | save it in dependencies |
 | 
			
		||||
| --save-dev   | save it in dev dependencies |
 | 
			
		||||
 | 
			
		||||
* Add a package in the project
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./npm-add-pkg.sh --save-dev NPM_NAME
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# extract-langs.sh
 | 
			
		||||
 | 
			
		||||
***extract-langs.sh*** 
 | 
			
		||||
 | 
			
		||||
Extract the i18n files from the repo and create a zip
 | 
			
		||||
 | 
			
		||||
## Options
 | 
			
		||||
 | 
			
		||||
| Option | Description |
 | 
			
		||||
| --- | --- |
 | 
			
		||||
| -h or --help    | show the help  |
 | 
			
		||||
| --output or o   | output folder otherwise will be 18n |
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./extract-langs.sh 
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# test-e2e-bc.sh
 | 
			
		||||
 | 
			
		||||
***test-e2e-bc.sh*** 
 | 
			
		||||
 | 
			
		||||
This script test that the update from 2.0.0 to 2.x.x is still smooth 
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./test-e2e-bc
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# test-e2e-bc.sh
 | 
			
		||||
 | 
			
		||||
***test-e2e-bc.sh*** 
 | 
			
		||||
 | 
			
		||||
This script test that the update from 2.0.0 to 2.x.x is still smooth 
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./test-e2e-bc
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# simulate-publish.sh
 | 
			
		||||
 | 
			
		||||
***simulate-publish.sh*** 
 | 
			
		||||
 | 
			
		||||
This script run a verdaccio server and simulate a publish on it 
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./simulate-publish
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# test-dist.sh
 | 
			
		||||
 | 
			
		||||
***test-dist.sh*** 
 | 
			
		||||
 | 
			
		||||
This script test the distribution of ADF against the demo shell 
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./test-dist
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# test-e2e-lib.sh
 | 
			
		||||
 | 
			
		||||
***test-e2e-lib.sh*** 
 | 
			
		||||
 | 
			
		||||
Script to run e2e test
 | 
			
		||||
 | 
			
		||||
| Option | Description |
 | 
			
		||||
| --- | --- |
 | 
			
		||||
|-u or --username |username to use|
 | 
			
		||||
|-p or --password|password to use|
 | 
			
		||||
|-e or --email |email user to use|
 | 
			
		||||
|-b or --browser |browser run the test in the browsrwer (No headless mode)|
 | 
			
		||||
|-s or --spec |spec run a single test file|
 | 
			
		||||
|-dev or --dev |run it against local development environment it will deploy on localhost:4200 the current version of your branch|
 | 
			
		||||
|-t or --timeout |override the timeout foe the wait utils|
 | 
			
		||||
|-host or --host | host against to run the test|
 | 
			
		||||
|-proxy or --proxy | proxy Back end URL to use |
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./scripts/test-e2e-lib.sh -host adf.domain.com -u admin -p admin -e admin
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Run on browser
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./scripts/test-e2e-lib.sh -host adf.domain.com -u admin -p admin -e admin --browser
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Run a single test
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./scripts/test-e2e-lib.sh -host adf.domain.com -u admin -p admin -e admin --spec filenam.e2e.ts
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
if the test in a subfolder in e2e you need to add the subfolder in the path:
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./scripts/test-e2e-lib.sh -host adf.domain.com -u admin -p admin -e admin --spec ./core/filenam.e2e.ts
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Use a different backend
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
./scripts/test-e2e-lib.sh -host localhost:42000 -proxy adf.domain.com  -u admin -p admin -e admin
 | 
			
		||||
```
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
// Protractor configuration file, see link for more information
 | 
			
		||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
 | 
			
		||||
 | 
			
		||||
require('dotenv').config({path: process.env.ENV_FILE});
 | 
			
		||||
const fs = require('fs');
 | 
			
		||||
 | 
			
		||||
const configPath = './dist/demo-shell/app.config.json';
 | 
			
		||||
 | 
			
		||||
fs.readFile(configPath, (err, appConfigString) => {
 | 
			
		||||
    if (err) throw err;
 | 
			
		||||
    let appConfig = JSON.parse(appConfigString);
 | 
			
		||||
    appConfig.providers = process.env.PROVIDERS || 'ALL';
 | 
			
		||||
    appConfig.bpmHost = (process.env.PROXY_HOST_ADF || process.env.URL_HOST_ADF);
 | 
			
		||||
    appConfig.ecmHost = (process.env.PROXY_HOST_ADF || process.env.URL_HOST_ADF);
 | 
			
		||||
    appConfig.identityHost = (process.env.HOST_SSO + '/auth/admin/realms/alfresco');
 | 
			
		||||
    appConfig.oauth2.host = (process.env.HOST_SSO + '/auth/realms/alfresco');
 | 
			
		||||
    appConfig.notificationDefaultDuration = process.env.NOTIFICATION_LAST || 8000;
 | 
			
		||||
    appConfig.authType = process.env.AUTH_TYPE || 'BASIC';
 | 
			
		||||
 | 
			
		||||
    let appConfigReplacedJson = JSON.stringify(appConfig,null,4);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    fs.writeFileSync(configPath, appConfigReplacedJson);
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
echo "Start e2e"
 | 
			
		||||
set -e
 | 
			
		||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 | 
			
		||||
 | 
			
		||||
cd $DIR/../../../
 | 
			
		||||
 | 
			
		||||
BASE_DIRECTORY=$(echo "$FOLDER" | cut -d "/" -f1)
 | 
			
		||||
verifyLib=$1;
 | 
			
		||||
deps=$2;
 | 
			
		||||
REGEX="(repository|workflow)_dispatch"
 | 
			
		||||
 | 
			
		||||
# set test-e2e params
 | 
			
		||||
if [ -n "$3" ]; then
 | 
			
		||||
      e2eParams="--$3"
 | 
			
		||||
else
 | 
			
		||||
      e2eParams=""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "Step1 - Verify if affected libs contains $verifyLib or if deps $deps are affected"
 | 
			
		||||
 | 
			
		||||
AFFECTED_LIB=$(./scripts/github/affected-contains.sh $verifyLib $deps)
 | 
			
		||||
 | 
			
		||||
if [ ${AFFECTED_LIB} == true ]; then
 | 
			
		||||
    echo "Step2 - $verifyLib OR deps $deps affected... will execute e2e"
 | 
			
		||||
 | 
			
		||||
    if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
 | 
			
		||||
        echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
 | 
			
		||||
        echo "npx nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain"
 | 
			
		||||
        AFFECTED_LIBS="$(npx nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain || exit 1)"
 | 
			
		||||
        echo "Affected libs ${AFFECTED_LIBS}"
 | 
			
		||||
        AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $GITHUB_BASE_REF -f "e2e/$FOLDER")";
 | 
			
		||||
        echo "Affected e2e ${AFFECTED_E2E}"
 | 
			
		||||
    fi;
 | 
			
		||||
 | 
			
		||||
    if [ "${GITHUB_EVENT_NAME}" == "schedule" ]; then
 | 
			
		||||
        echo "CRON running everything "
 | 
			
		||||
    fi;
 | 
			
		||||
 | 
			
		||||
    if [[  $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$BASE_DIRECTORY" ||  "${GITHUB_EVENT_NAME}" == "push" ||  "${GITHUB_EVENT_NAME}" == "$REGEX" ||  "${GITHUB_EVENT_NAME}" == "schedule" ]]; then
 | 
			
		||||
        echo "Run all e2e $FOLDER"
 | 
			
		||||
        ./scripts/test-e2e-lib.sh --use-dist $e2eParams
 | 
			
		||||
    else if [[ $AFFECTED_E2E  == "e2e/$FOLDER" ]]; then
 | 
			
		||||
            echo "Run affected e2e"
 | 
			
		||||
 | 
			
		||||
            HEAD_SHA_BRANCH="$(git merge-base origin/$GITHUB_HEAD_REF HEAD)"
 | 
			
		||||
            LIST_SPECS="$(git diff --name-only $HEAD_SHA_BRANCH HEAD | grep "^e2e/$FOLDER" | paste -sd , -)"
 | 
			
		||||
 | 
			
		||||
            echo "Run $FOLDER e2e based on the sha $HEAD_SHA_BRANCH with the specs: "$LIST_SPECS
 | 
			
		||||
 | 
			
		||||
            if [[ $LIST_SPECS != "" ]]; then
 | 
			
		||||
                ./scripts/test-e2e-lib.sh --use-dist $e2eParams
 | 
			
		||||
            fi
 | 
			
		||||
        fi
 | 
			
		||||
    fi;
 | 
			
		||||
 | 
			
		||||
else
 | 
			
		||||
    echo "Step2 - Lib $verifyLib OR deps $deps NOT affected. No need to run e2e"
 | 
			
		||||
    exit 0
 | 
			
		||||
fi
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 | 
			
		||||
cd $DIR/../../../
 | 
			
		||||
 | 
			
		||||
echo "ℹ️ demo-shell: Running the docker with tag" $TAGS
 | 
			
		||||
 | 
			
		||||
DOCKER_PROJECT_ARGS="PROJECT_NAME=demo-shell"
 | 
			
		||||
 | 
			
		||||
# Publish Image to docker
 | 
			
		||||
./node_modules/@alfresco/adf-cli/bin/adf-cli docker \
 | 
			
		||||
    --loginCheck \
 | 
			
		||||
    --loginUsername "$DOCKER_REPOSITORY_USER" \
 | 
			
		||||
    --loginPassword "$DOCKER_REPOSITORY_PASSWORD" \
 | 
			
		||||
    --loginRepo "$DOCKER_REPOSITORY_DOMAIN" \
 | 
			
		||||
    --dockerRepo "$DOCKER_REPOSITORY" \
 | 
			
		||||
    --buildArgs "$DOCKER_PROJECT_ARGS" \
 | 
			
		||||
    --dockerTags "$TAGS" \
 | 
			
		||||
    --pathProject "$(pwd)" \
 | 
			
		||||
    "$@"
 | 
			
		||||
@@ -29,7 +29,6 @@ COMPONENTS_ROOT="$DIR/../../lib"
 | 
			
		||||
 | 
			
		||||
# Find all directories in $COMPONENTS_ROOT called i18n and add the demo-shell manually
 | 
			
		||||
COMPONENTS=(`find $COMPONENTS_ROOT -type d -name i18n -not \( -name '*.*' -o -path '**/node_modules*'  -o -path '**/bundles*' \)`)
 | 
			
		||||
COMPONENTS+=("$DIR/../../demo-shell/resources/i18n")
 | 
			
		||||
 | 
			
		||||
# Loop the individual components
 | 
			
		||||
for COMPONENT_DIR in "${COMPONENTS[@]}"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,166 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 | 
			
		||||
 | 
			
		||||
cd "$DIR/../"
 | 
			
		||||
BROWSER_RUN=false
 | 
			
		||||
DEVELOPMENT=false
 | 
			
		||||
LITESERVER=false
 | 
			
		||||
EXEC_VERSION_JSAPI=false
 | 
			
		||||
DEBUG=false
 | 
			
		||||
 | 
			
		||||
show_help() {
 | 
			
		||||
    echo "Usage: ./scripts/test-e2e-lib.sh -host adf.domain.com -u admin -p admin -e admin"
 | 
			
		||||
    echo ""
 | 
			
		||||
    echo "--env"
 | 
			
		||||
    echo "-u or --username"
 | 
			
		||||
    echo "-p or --password"
 | 
			
		||||
    echo "-identity_admin_email"
 | 
			
		||||
    echo "-identity_admin_password"
 | 
			
		||||
    echo "-b or --browser run the test in the browser (No headless mode)"
 | 
			
		||||
    echo "-s or --spec run a single test file"
 | 
			
		||||
    echo "-f or --folder run a single folder test"
 | 
			
		||||
    echo "--seleniumServer configure a selenium server to use to run the e2e test"
 | 
			
		||||
    echo "-proxy or --proxy proxy Back end URL to use only possible to use with -dev option"
 | 
			
		||||
    echo "-dev or --dev run it against local development environment it will deploy on localhost:4200 the current version of your branch"
 | 
			
		||||
    echo "-host or --host URL of the Front end to test"
 | 
			
		||||
    echo "-host_sso the entire path including the name of the realm"
 | 
			
		||||
    echo "-save  save the error screenshot and report in the remote env"
 | 
			
		||||
    echo "-m --maxInstances max instances parallel for tests"
 | 
			
		||||
    echo "-log or --log print all the browser log"
 | 
			
		||||
    echo "-db or --debug run the debugger"
 | 
			
		||||
    echo "-ud run dist"
 | 
			
		||||
    echo "-h or --help"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_log(){
 | 
			
		||||
    export LOG=true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_username(){
 | 
			
		||||
    USERNAME=$1
 | 
			
		||||
    export USERNAME_ADF=$USERNAME
 | 
			
		||||
}
 | 
			
		||||
set_password(){
 | 
			
		||||
    PASSWORD=$1
 | 
			
		||||
    export PASSWORD_ADF=$PASSWORD
 | 
			
		||||
}
 | 
			
		||||
set_identity_admin_email(){
 | 
			
		||||
    IDENTITY_ADMIN_EMAIL=$1
 | 
			
		||||
    export IDENTITY_ADMIN_EMAIL=$IDENTITY_ADMIN_EMAIL
 | 
			
		||||
}
 | 
			
		||||
set_identity_admin_password(){
 | 
			
		||||
    IDENTITY_ADMIN_PASSWORD=$1
 | 
			
		||||
    export IDENTITY_ADMIN_PASSWORD=$IDENTITY_ADMIN_PASSWORD
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_host(){
 | 
			
		||||
    HOST=$1
 | 
			
		||||
    export URL_HOST_ADF=$HOST
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_host_sso(){
 | 
			
		||||
    HOST_SSO=$1
 | 
			
		||||
    export HOST_SSO=$HOST_SSO
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_specs(){
 | 
			
		||||
    LIST_SPECS=$1
 | 
			
		||||
    export LIST_SPECS=$LIST_SPECS
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_browser(){
 | 
			
		||||
    BROWSER_RUN=true
 | 
			
		||||
    export BROWSER_RUN=$BROWSER_RUN
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_proxy(){
 | 
			
		||||
    PROXY=$1
 | 
			
		||||
    export PROXY_HOST_ADF=$PROXY
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_save_screenshot(){
 | 
			
		||||
    mkdir -p ./e2e-output/junit-report
 | 
			
		||||
    export SAVE_SCREENSHOT=true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_development(){
 | 
			
		||||
    DEVELOPMENT=true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_test_folder(){
 | 
			
		||||
    FOLDER=$1
 | 
			
		||||
    export FOLDER=$FOLDER
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_selenium(){
 | 
			
		||||
    SELENIUM_SERVER=$1
 | 
			
		||||
    export SELENIUM_SERVER=$SELENIUM_SERVER
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set_env(){
 | 
			
		||||
    export ENV_FILE=$1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
debug(){
 | 
			
		||||
    export DEBUG=true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
lite_server(){
 | 
			
		||||
    LITESERVER=true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
max_instances(){
 | 
			
		||||
    export MAXINSTANCES=$1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
while [[ $1 == -* ]]; do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
      -h|--help|-\?) show_help; exit 0;;
 | 
			
		||||
      -u|--username)  set_username $2; shift 2;;
 | 
			
		||||
      -p|--password)  set_password $2; shift 2;;
 | 
			
		||||
      -identity_admin_email)  set_identity_admin_email $2; shift 2;;
 | 
			
		||||
      -identity_admin_password)  set_identity_admin_password $2; shift 2;;
 | 
			
		||||
      -f|--folder)  set_test_folder $2; shift 2;;
 | 
			
		||||
      -b|--browser)  set_browser; shift;;
 | 
			
		||||
      -env|--env)   set_env $2; shift 2;;
 | 
			
		||||
      -dev|--dev)  set_development; shift;;
 | 
			
		||||
      -s|--specs)  set_specs $2; shift 2;;
 | 
			
		||||
      -db|--debug) debug; shift;;
 | 
			
		||||
      -ud|--use-dist)  lite_server; shift;;
 | 
			
		||||
      -save)   set_save_screenshot; shift;;
 | 
			
		||||
      -proxy|--proxy)  set_proxy $2; shift 2;;
 | 
			
		||||
      --seleniumServer) set_selenium $2; shift 2;;
 | 
			
		||||
      -host|--host)  set_host $2; shift 2;;
 | 
			
		||||
      -log|--log)  set_log; shift ;;
 | 
			
		||||
      -host_sso|--host_sso) set_host_sso $2; shift 2;;
 | 
			
		||||
      -m|--maxInstances)  max_instances $2; shift 2;;
 | 
			
		||||
      -*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
rm -rf ./e2e/downloads/
 | 
			
		||||
rm -rf ./e2e-output/
 | 
			
		||||
echo "====== BROWSER_RUN: $BROWSER_RUN ======"
 | 
			
		||||
 | 
			
		||||
export DEBUG_OPTION=''
 | 
			
		||||
if [[  $DEBUG == "true" ]]; then
 | 
			
		||||
  DEBUG_OPTION=' node --inspect-brk '
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[  $DEVELOPMENT == "true" ]]; then
 | 
			
		||||
    echo "====== Run against local development  ====="
 | 
			
		||||
    npm run e2e-lib || exit 1
 | 
			
		||||
else
 | 
			
		||||
    if [[  $LITESERVER == "true" ]]; then
 | 
			
		||||
        echo "====== Run dist in lite-server ====="
 | 
			
		||||
 | 
			
		||||
        ls dist/demo-shell/ || exit 1
 | 
			
		||||
 | 
			
		||||
        npm run postbuild:ci  || exit 1
 | 
			
		||||
 | 
			
		||||
        npm run lite-server-e2e>/dev/null & $DEBUG_OPTION ./node_modules/protractor/bin/protractor ./e2e/protractor.conf.js || exit 1
 | 
			
		||||
     else
 | 
			
		||||
        echo "====== Run without lite-server  ====="
 | 
			
		||||
        $DEBUG_OPTION  ./node_modules/protractor/bin/protractor ./e2e/protractor.conf.js || exit 1
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
@@ -181,9 +181,3 @@ fi
 | 
			
		||||
 | 
			
		||||
# bump root package.json
 | 
			
		||||
npm version --allow-same-version --no-git-tag-version --force --loglevel=error $VERSION
 | 
			
		||||
 | 
			
		||||
echo "====== UPDATE DEMO SHELL ======"
 | 
			
		||||
 | 
			
		||||
DESTDIR="$DIR/../demo-shell/"
 | 
			
		||||
cd $DESTDIR
 | 
			
		||||
npm version --allow-same-version --no-git-tag-version --force --loglevel=error $VERSION
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
 | 
			
		||||
 | 
			
		||||
if ($env:CI -eq "true") {
 | 
			
		||||
    Write-Host "Updating webdriver-manager with chromedriver: $env:npm_package_config_chromeDriver."
 | 
			
		||||
    ./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=$(google-chrome --product-version)
 | 
			
		||||
} else {
 | 
			
		||||
    Write-Host "Updating webdriver-manager with latest chromedriver, be sure to use evergreen Chrome."
 | 
			
		||||
    npx webdriver-manager update --gecko=false
 | 
			
		||||
    if ($LASTEXITCODE -ne 0) {
 | 
			
		||||
        Write-Host "`n==============================================================="
 | 
			
		||||
        Write-Host "FAILED TO UPDATE WEBDRIVER-MANAGER, PLEASE DO IT MANUALLY!"
 | 
			
		||||
        Write-Host "Run the following command (sometimes needs more than one kick):"
 | 
			
		||||
        Write-Host ""
 | 
			
		||||
        Write-Host "npx webdriver-manager update --gecko=false"
 | 
			
		||||
        Write-Host ""
 | 
			
		||||
        Write-Host "==============================================================="
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
# Run protractor with newest webdriver locally
 | 
			
		||||
 | 
			
		||||
## Instruction
 | 
			
		||||
To download newest driver simply run script from its directory
 | 
			
		||||
`update-to-newest-webdriver.sh`
 | 
			
		||||
 | 
			
		||||
Command accepts one parameter to define what OS you are using. By default its set to `mac-x64`
 | 
			
		||||
Possible inputs `linux64, mac-arm64, mac-x64, win32, win64`
 | 
			
		||||
 | 
			
		||||
Example `./update-to-newest-webdriver.sh win64` - will set driver for windows
 | 
			
		||||
 | 
			
		||||
## How it works
 | 
			
		||||
1. The script removes your existing driver files from webdriver node_modules
 | 
			
		||||
2. Generates two new files (chrome_xml.js and update.js) that have updated methods needed to get the new driver
 | 
			
		||||
3. Replaces browser type depending on parameter
 | 
			
		||||
4. Copies and replaces the files to the webdriver node_modules
 | 
			
		||||
5. Executes command to to update-webdriver using updated code
 | 
			
		||||
 | 
			
		||||
## Troubleshooting
 | 
			
		||||
If the script fails for any reason. You can do some of these actions manually:
 | 
			
		||||
1. Find the two files (chrome_xml.js and update.js) in node_modules/webdriver-manager
 | 
			
		||||
2. Replace its contents with (chrome_xml_schema.js and update_schema.js) keep the original names.
 | 
			
		||||
3. Change version for specific OS in both files
 | 
			
		||||
    chrome_xml.js -> ['platform'] == 'mac-x64' e.g. ['platform'] == 'win64' Line 70
 | 
			
		||||
    update.js -> 'chromedriver-mac-x64' e.g 'chromedriver-win64' Line 240
 | 
			
		||||
4. Run standard command to update webdriver `./node_modules/webdriver-manager/bin/webdriver-manager update --gecko=false`
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Reason
 | 
			
		||||
Latest ChromeDriver Binaries https://googlechromelabs.github.io/chrome-for-testing/
 | 
			
		||||
 | 
			
		||||
Starting with M115 the latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available at the Chrome for Testing availability dashboard. For automated version downloading one can use the convenient JSON endpoints.
 | 
			
		||||
The older releases can be found at the Downloads page.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Note: Protractor is a depricated tool and this probably won't be fixed.
 | 
			
		||||
@@ -1,181 +0,0 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
Object.defineProperty(exports, '__esModule', { value: true });
 | 
			
		||||
const semver = require('semver');
 | 
			
		||||
const config_1 = require('../config');
 | 
			
		||||
const http_utils_1 = require('../http_utils');
 | 
			
		||||
const config_source_1 = require('./config_source');
 | 
			
		||||
class ChromeXml extends config_source_1.XmlConfigSource {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super('chrome', config_1.Config.cdnUrls()['chrome']);
 | 
			
		||||
        this.maxVersion = config_1.Config.binaryVersions().maxChrome;
 | 
			
		||||
    }
 | 
			
		||||
    getUrl(version) {
 | 
			
		||||
        if (version === 'latest') {
 | 
			
		||||
            return this.getLatestChromeDriverVersion();
 | 
			
		||||
        } else {
 | 
			
		||||
            return this.getSpecificChromeDriverVersion(version);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a list of chrome drivers paths available for the configuration OS type and architecture.
 | 
			
		||||
     */
 | 
			
		||||
    getVersionList() {
 | 
			
		||||
        return this.getXml().then((xml) => {
 | 
			
		||||
            let versionPaths = [];
 | 
			
		||||
            let osType = this.getOsTypeName();
 | 
			
		||||
            for (let content of xml.ListBucketResult.Contents) {
 | 
			
		||||
                let contentKey = content.Key[0];
 | 
			
		||||
                if (
 | 
			
		||||
                    // Filter for 32-bit devices, make sure x64 is not an option
 | 
			
		||||
                    (this.osarch.includes('64') || !contentKey.includes('64')) &&
 | 
			
		||||
                    // Filter for x86 macs, make sure m1 is not an option
 | 
			
		||||
                    ((this.ostype === 'Darwin' && this.osarch === 'arm64') || !contentKey.includes('m1'))
 | 
			
		||||
                ) {
 | 
			
		||||
                    // Filter for only the osType
 | 
			
		||||
                    if (contentKey.includes(osType)) {
 | 
			
		||||
                        versionPaths.push(contentKey);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return versionPaths;
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Helper method, gets the ostype and gets the name used by the XML
 | 
			
		||||
     */
 | 
			
		||||
    getOsTypeName() {
 | 
			
		||||
        // Get the os type name.
 | 
			
		||||
        if (this.ostype === 'Darwin') {
 | 
			
		||||
            return 'mac-x64';
 | 
			
		||||
        } else if (this.ostype === 'Windows_NT') {
 | 
			
		||||
            return 'win64';
 | 
			
		||||
        } else {
 | 
			
		||||
            return 'linux64';
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the latest item from the XML.
 | 
			
		||||
     */
 | 
			
		||||
    getLatestChromeDriverVersion() {
 | 
			
		||||
        const path = require('path');
 | 
			
		||||
        const fs = require('fs');
 | 
			
		||||
 | 
			
		||||
        const lastKnownGoodVersionsWithDownloads_Url =
 | 
			
		||||
            'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json';
 | 
			
		||||
        return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then((body) => {
 | 
			
		||||
            const latestVersion_Body = JSON.parse(body)['channels']['Stable'];
 | 
			
		||||
 | 
			
		||||
            const latestVersion = latestVersion_Body['version'];
 | 
			
		||||
            const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find((obj) => obj['platform'] == 'mac-x64')['url'];
 | 
			
		||||
 | 
			
		||||
            const latestMajorVersion = latestVersion.split('.')[0];
 | 
			
		||||
 | 
			
		||||
            const localVersion_FileName =
 | 
			
		||||
                fs
 | 
			
		||||
                    .readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
 | 
			
		||||
                    .find((f) => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '';
 | 
			
		||||
 | 
			
		||||
            const localVersion = localVersion_FileName.slice(13, -4);
 | 
			
		||||
            const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion);
 | 
			
		||||
 | 
			
		||||
            const localMajorVersion = localVersion.split('.')[0];
 | 
			
		||||
 | 
			
		||||
            if (latestMajorVersion == localMajorVersion) {
 | 
			
		||||
                return Promise.resolve({
 | 
			
		||||
                    url: localVersion_Url,
 | 
			
		||||
                    version: localVersion
 | 
			
		||||
                });
 | 
			
		||||
            } else {
 | 
			
		||||
                return Promise.resolve({
 | 
			
		||||
                    url: latestVersion_Url,
 | 
			
		||||
                    version: latestVersion
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a specific item from the XML.
 | 
			
		||||
     */
 | 
			
		||||
    getSpecificChromeDriverVersion(versionRequired) {
 | 
			
		||||
        const path = require('path');
 | 
			
		||||
        const fs = require('fs');
 | 
			
		||||
 | 
			
		||||
        let baseTagVersion = versionRequired.split('.');
 | 
			
		||||
        baseTagVersion.splice(-1);
 | 
			
		||||
        baseTagVersion = baseTagVersion.join('.');
 | 
			
		||||
 | 
			
		||||
        const lastKnownGoodVersionsWithDownloads_Url =
 | 
			
		||||
            'https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json';
 | 
			
		||||
        return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then((body) => {
 | 
			
		||||
            const version_Body = JSON.parse(body)['builds'][baseTagVersion];
 | 
			
		||||
 | 
			
		||||
            const opSys = this.getOsTypeName();
 | 
			
		||||
 | 
			
		||||
            const currentVersion = version_Body['version'];
 | 
			
		||||
            const currentVersion_Url = version_Body['downloads']['chromedriver'].find((obj) => obj['platform'] == opSys)['url'];
 | 
			
		||||
 | 
			
		||||
            const latestMajorVersion = currentVersion.split('.')[0];
 | 
			
		||||
 | 
			
		||||
            const localVersion_FileName =
 | 
			
		||||
                fs
 | 
			
		||||
                    .readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
 | 
			
		||||
                    .find((f) => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '';
 | 
			
		||||
 | 
			
		||||
            const localVersion = localVersion_FileName.slice(13, -4);
 | 
			
		||||
            const localVersion_Url = currentVersion_Url.replace(currentVersion, localVersion);
 | 
			
		||||
 | 
			
		||||
            const localMajorVersion = localVersion.split('.')[0];
 | 
			
		||||
 | 
			
		||||
            if (latestMajorVersion == localMajorVersion) {
 | 
			
		||||
                return Promise.resolve({
 | 
			
		||||
                    url: localVersion_Url,
 | 
			
		||||
                    version: localVersion
 | 
			
		||||
                });
 | 
			
		||||
            } else {
 | 
			
		||||
                return Promise.resolve({
 | 
			
		||||
                    url: currentVersion_Url,
 | 
			
		||||
                    version: currentVersion
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ChromeXml = ChromeXml;
 | 
			
		||||
/**
 | 
			
		||||
 * Chromedriver is the only binary that does not conform to semantic versioning
 | 
			
		||||
 * and either has too little number of digits or too many. To get this to be in
 | 
			
		||||
 * semver, we will either add a '.0' at the end or chop off the last set of
 | 
			
		||||
 * digits. This is so we can compare to find the latest and greatest.
 | 
			
		||||
 *
 | 
			
		||||
 * Example:
 | 
			
		||||
 *   2.46 -> 2.46.0
 | 
			
		||||
 *   75.0.3770.8 -> 75.0.3770
 | 
			
		||||
 *
 | 
			
		||||
 * @param version
 | 
			
		||||
 */
 | 
			
		||||
function getValidSemver(version) {
 | 
			
		||||
    let lookUpVersion = '';
 | 
			
		||||
    // This supports downloading 2.46
 | 
			
		||||
    try {
 | 
			
		||||
        const oldRegex = /(\d+.\d+)/g;
 | 
			
		||||
        const exec = oldRegex.exec(version);
 | 
			
		||||
        if (exec) {
 | 
			
		||||
            lookUpVersion = exec[1] + '.0';
 | 
			
		||||
        }
 | 
			
		||||
    } catch (_) {
 | 
			
		||||
        // no-op: is this is not valid, do not throw here.
 | 
			
		||||
    }
 | 
			
		||||
    // This supports downloading 74.0.3729.6
 | 
			
		||||
    try {
 | 
			
		||||
        const newRegex = /(\d+.\d+.\d+).\d+/g;
 | 
			
		||||
        const exec = newRegex.exec(version);
 | 
			
		||||
        if (exec) {
 | 
			
		||||
            lookUpVersion = exec[1];
 | 
			
		||||
        }
 | 
			
		||||
    } catch (_) {
 | 
			
		||||
        // no-op: if this does not work, use the other regex pattern.
 | 
			
		||||
    }
 | 
			
		||||
    return lookUpVersion;
 | 
			
		||||
}
 | 
			
		||||
exports.getValidSemver = getValidSemver;
 | 
			
		||||
//# sourceMappingURL=chrome_xml.js.map
 | 
			
		||||
@@ -1,80 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 | 
			
		||||
 | 
			
		||||
if [ "$(uname)" == "Darwin" ]; then
 | 
			
		||||
    BROWSER_TYPE="mac-x64"
 | 
			
		||||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
 | 
			
		||||
    BROWSER_TYPE="linux64"
 | 
			
		||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
 | 
			
		||||
    BROWSER_TYPE="win32"
 | 
			
		||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
 | 
			
		||||
    BROWSER_TYPE="win64"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "Getting currently installed Chrome Version"
 | 
			
		||||
 | 
			
		||||
if [ "$CI" = "true" ]; then
 | 
			
		||||
    chromeVersion=$(google-chrome --version )
 | 
			
		||||
else
 | 
			
		||||
    if [ "$BROWSER_TYPE" = "mac-x64" ]; then
 | 
			
		||||
        chromeVersion=$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version )
 | 
			
		||||
    elif [ "$BROWSER_TYPE" = "linux64" ]; then
 | 
			
		||||
        chromeVersion=$( /usr/bin/google-chrome-stable --version )
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
chromeVersion=${chromeVersion:14:20}
 | 
			
		||||
 | 
			
		||||
echo "Intalling webdriver for version: $chromeVersion"
 | 
			
		||||
 | 
			
		||||
function show_error() {
 | 
			
		||||
    echo -e "\e[31m===============================================================\e[0m"
 | 
			
		||||
    echo -e "\e[31mFAILED TO UPDATE WEBDRIVER-MANAGER, PLEASE DO IT MANUALLY!\e[0m"
 | 
			
		||||
    echo -e "\e[31mRun the following command (sometimes needs more than one kick):\e[0m"
 | 
			
		||||
    echo -e ""
 | 
			
		||||
    echo -e "\e[31mnpx webdriver-manager update --gecko=false\e[0m"
 | 
			
		||||
    echo -e ""
 | 
			
		||||
    echo -e "====== WINDOWS USERS : PLEASE RUN THIS COMMAND: "
 | 
			
		||||
    echo -e "npm run update-webdriver:windows"
 | 
			
		||||
    echo -e "====== WINDOWS USERS ADVISORY END =================="
 | 
			
		||||
    echo -e ""
 | 
			
		||||
    echo -e "\e[31m===============================================================\e[0m"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ROOTDIR="$DIR/.."
 | 
			
		||||
 | 
			
		||||
echo "BROWSER => $BROWSER_TYPE"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
PATH_TO_COMMANDS=./node_modules/webdriver-manager/built/lib/cmds
 | 
			
		||||
PATH_TO_BINARIES=./node_modules/webdriver-manager/built/lib/binaries
 | 
			
		||||
PATH_TO_SELENIUM=./node_modules/webdriver-manager/selenium
 | 
			
		||||
 | 
			
		||||
# Remove existing drivers
 | 
			
		||||
rm -rf $PATH_TO_SELENIUM/selenium-server-*
 | 
			
		||||
rm -rf $PATH_TO_SELENIUM/chromedriver-*
 | 
			
		||||
rm -f $PATH_TO_SELENIUM/chromedriver_*
 | 
			
		||||
 | 
			
		||||
# Replace browser type in file and create new file
 | 
			
		||||
echo 'Replacing new webdriver files'
 | 
			
		||||
sed "s/mac-x64/$BROWSER_TYPE/" $DIR/chrome_xml_schema.js > $DIR/chrome_xml.js && sed  "s/mac-x64/$BROWSER_TYPE/" $DIR/update_schema.js > $DIR/update.js;
 | 
			
		||||
 | 
			
		||||
if [ "$?" -ne 0 ]; then
 | 
			
		||||
    show_error
 | 
			
		||||
    exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "============== Trying to update the files =============="
 | 
			
		||||
sleep 2
 | 
			
		||||
 | 
			
		||||
# Replace webdriver files
 | 
			
		||||
echo "cp -f $DIR/update.js $PATH_TO_COMMANDS/update.js"
 | 
			
		||||
cp -f $DIR/update.js $PATH_TO_COMMANDS/update.js
 | 
			
		||||
cp -f $DIR/chrome_xml.js $PATH_TO_BINARIES/chrome_xml.js
 | 
			
		||||
 | 
			
		||||
rm -f $DIR/update.js
 | 
			
		||||
rm -f $DIR/chrome_xml.js
 | 
			
		||||
 | 
			
		||||
node ./node_modules/webdriver-manager/bin/webdriver-manager update --gecko=false --versions.chrome=$chromeVersion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,304 +0,0 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const AdmZip = require("adm-zip");
 | 
			
		||||
const child_process = require("child_process");
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
const minimist = require("minimist");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const q = require("q");
 | 
			
		||||
const rimraf = require("rimraf");
 | 
			
		||||
const binaries_1 = require("../binaries");
 | 
			
		||||
const cli_1 = require("../cli");
 | 
			
		||||
const config_1 = require("../config");
 | 
			
		||||
const files_1 = require("../files");
 | 
			
		||||
const http_utils_1 = require("../http_utils");
 | 
			
		||||
const utils_1 = require("../utils");
 | 
			
		||||
const Opt = require("./");
 | 
			
		||||
const initialize_1 = require("./initialize");
 | 
			
		||||
const opts_1 = require("./opts");
 | 
			
		||||
config_1.Config.runCommand = 'update';
 | 
			
		||||
let logger = new cli_1.Logger('update');
 | 
			
		||||
let prog = new cli_1.Program()
 | 
			
		||||
    .command('update', 'install or update selected binaries')
 | 
			
		||||
    .action(update)
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.OUT_DIR])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.VERBOSE])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.IGNORE_SSL])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.PROXY])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.ALTERNATE_CDN])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.STANDALONE])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.CHROME])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.GECKO])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.ANDROID])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.ANDROID_API_LEVELS])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.ANDROID_ARCHITECTURES])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.ANDROID_PLATFORMS])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.ANDROID_ACCEPT_LICENSES]);
 | 
			
		||||
if (config_1.Config.osType() === 'Darwin') {
 | 
			
		||||
    prog.addOption(opts_1.Opts[Opt.IOS]);
 | 
			
		||||
}
 | 
			
		||||
if (config_1.Config.osType() === 'Windows_NT') {
 | 
			
		||||
    prog.addOption(opts_1.Opts[Opt.IE]).addOption(opts_1.Opts[Opt.IE32]).addOption(opts_1.Opts[Opt.IE64]);
 | 
			
		||||
}
 | 
			
		||||
prog.addOption(opts_1.Opts[Opt.VERSIONS_STANDALONE])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.VERSIONS_CHROME])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.VERSIONS_APPIUM])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.VERSIONS_ANDROID])
 | 
			
		||||
    .addOption(opts_1.Opts[Opt.VERSIONS_GECKO]);
 | 
			
		||||
if (config_1.Config.osType() === 'Windows_NT') {
 | 
			
		||||
    prog.addOption(opts_1.Opts[Opt.VERSIONS_IE]);
 | 
			
		||||
}
 | 
			
		||||
exports.program = prog;
 | 
			
		||||
// stand alone runner
 | 
			
		||||
let argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
 | 
			
		||||
if (argv._[0] === 'update-run') {
 | 
			
		||||
    prog.run(JSON.parse(JSON.stringify(argv)));
 | 
			
		||||
}
 | 
			
		||||
else if (argv._[0] === 'update-help') {
 | 
			
		||||
    prog.printHelp();
 | 
			
		||||
}
 | 
			
		||||
let browserFile;
 | 
			
		||||
/**
 | 
			
		||||
 * Parses the options and downloads binaries if they do not exist.
 | 
			
		||||
 * @param options
 | 
			
		||||
 */
 | 
			
		||||
function update(options) {
 | 
			
		||||
    let promises = [];
 | 
			
		||||
    let standalone = options[Opt.STANDALONE].getBoolean();
 | 
			
		||||
    let chrome = options[Opt.CHROME].getBoolean();
 | 
			
		||||
    let gecko = options[Opt.GECKO].getBoolean();
 | 
			
		||||
    let ie32 = false;
 | 
			
		||||
    let ie64 = false;
 | 
			
		||||
    if (options[Opt.IE]) {
 | 
			
		||||
        ie32 = ie32 || options[Opt.IE].getBoolean();
 | 
			
		||||
    }
 | 
			
		||||
    if (options[Opt.IE32]) {
 | 
			
		||||
        ie32 = ie32 || options[Opt.IE32].getBoolean();
 | 
			
		||||
    }
 | 
			
		||||
    if (options[Opt.IE64]) {
 | 
			
		||||
        ie64 = options[Opt.IE64].getBoolean();
 | 
			
		||||
    }
 | 
			
		||||
    let android = options[Opt.ANDROID].getBoolean();
 | 
			
		||||
    let ios = false;
 | 
			
		||||
    if (options[Opt.IOS]) {
 | 
			
		||||
        ios = options[Opt.IOS].getBoolean();
 | 
			
		||||
    }
 | 
			
		||||
    let outputDir = options[Opt.OUT_DIR].getString();
 | 
			
		||||
    try {
 | 
			
		||||
        browserFile =
 | 
			
		||||
            JSON.parse(fs.readFileSync(path.resolve(outputDir, 'update-config.json')).toString());
 | 
			
		||||
    }
 | 
			
		||||
    catch (err) {
 | 
			
		||||
        browserFile = {};
 | 
			
		||||
    }
 | 
			
		||||
    let android_api_levels = options[Opt.ANDROID_API_LEVELS].getString().split(',');
 | 
			
		||||
    let android_architectures = options[Opt.ANDROID_ARCHITECTURES].getString().split(',');
 | 
			
		||||
    let android_platforms = options[Opt.ANDROID_PLATFORMS].getString().split(',');
 | 
			
		||||
    let android_accept_licenses = options[Opt.ANDROID_ACCEPT_LICENSES].getBoolean();
 | 
			
		||||
    if (options[Opt.OUT_DIR].getString()) {
 | 
			
		||||
        if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {
 | 
			
		||||
            outputDir = options[Opt.OUT_DIR].getString();
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            outputDir = path.resolve(config_1.Config.getBaseDir(), options[Opt.OUT_DIR].getString());
 | 
			
		||||
        }
 | 
			
		||||
        files_1.FileManager.makeOutputDirectory(outputDir);
 | 
			
		||||
    }
 | 
			
		||||
    let ignoreSSL = options[Opt.IGNORE_SSL].getBoolean();
 | 
			
		||||
    let proxy = options[Opt.PROXY].getString();
 | 
			
		||||
    http_utils_1.HttpUtils.assignOptions({ ignoreSSL, proxy });
 | 
			
		||||
    let verbose = options[Opt.VERBOSE].getBoolean();
 | 
			
		||||
    // setup versions for binaries
 | 
			
		||||
    let binaries = files_1.FileManager.setupBinaries(options[Opt.ALTERNATE_CDN].getString());
 | 
			
		||||
    binaries[binaries_1.Standalone.id].versionCustom = options[Opt.VERSIONS_STANDALONE].getString();
 | 
			
		||||
    binaries[binaries_1.ChromeDriver.id].versionCustom = options[Opt.VERSIONS_CHROME].getString();
 | 
			
		||||
    if (options[Opt.VERSIONS_IE]) {
 | 
			
		||||
        binaries[binaries_1.IEDriver.id].versionCustom = options[Opt.VERSIONS_IE].getString();
 | 
			
		||||
    }
 | 
			
		||||
    if (options[Opt.VERSIONS_GECKO]) {
 | 
			
		||||
        binaries[binaries_1.GeckoDriver.id].versionCustom = options[Opt.VERSIONS_GECKO].getString();
 | 
			
		||||
    }
 | 
			
		||||
    binaries[binaries_1.AndroidSDK.id].versionCustom = options[Opt.VERSIONS_ANDROID].getString();
 | 
			
		||||
    binaries[binaries_1.Appium.id].versionCustom = options[Opt.VERSIONS_APPIUM].getString();
 | 
			
		||||
    // if the file has not been completely downloaded, download it
 | 
			
		||||
    // else if the file has already been downloaded, unzip the file, rename it, and give it
 | 
			
		||||
    // permissions
 | 
			
		||||
    if (standalone) {
 | 
			
		||||
        let binary = binaries[binaries_1.Standalone.id];
 | 
			
		||||
        promises.push(files_1.FileManager.downloadFile(binary, outputDir)
 | 
			
		||||
            .then((downloaded) => {
 | 
			
		||||
            if (!downloaded) {
 | 
			
		||||
                logger.info(binary.name + ': file exists ' +
 | 
			
		||||
                    path.resolve(outputDir, binary.filename()));
 | 
			
		||||
                logger.info(binary.name + ': ' + binary.filename() + ' up to date');
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
            .then(() => {
 | 
			
		||||
            updateBrowserFile(binary, outputDir);
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
    if (chrome) {
 | 
			
		||||
        let binary = binaries[binaries_1.ChromeDriver.id];
 | 
			
		||||
        promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL).then(() => {
 | 
			
		||||
            return Promise.resolve(updateBrowserFile(binary, outputDir));
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
    if (gecko) {
 | 
			
		||||
        let binary = binaries[binaries_1.GeckoDriver.id];
 | 
			
		||||
        promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL).then(() => {
 | 
			
		||||
            return Promise.resolve(updateBrowserFile(binary, outputDir));
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
    if (ie64) {
 | 
			
		||||
        let binary = binaries[binaries_1.IEDriver.id];
 | 
			
		||||
        binary.osarch = config_1.Config.osArch(); // Win32 or x64
 | 
			
		||||
        promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL).then(() => {
 | 
			
		||||
            return Promise.resolve(updateBrowserFile(binary, outputDir));
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
    if (ie32) {
 | 
			
		||||
        let binary = binaries[binaries_1.IEDriver.id];
 | 
			
		||||
        binary.osarch = 'Win32';
 | 
			
		||||
        promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL).then(() => {
 | 
			
		||||
            return Promise.resolve(updateBrowserFile(binary, outputDir));
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
    if (android) {
 | 
			
		||||
        let binary = binaries[binaries_1.AndroidSDK.id];
 | 
			
		||||
        let sdk_path = path.resolve(outputDir, binary.executableFilename());
 | 
			
		||||
        let oldAVDList;
 | 
			
		||||
        updateBrowserFile(binary, outputDir);
 | 
			
		||||
        promises.push(q.nfcall(fs.readFile, path.resolve(sdk_path, 'available_avds.json'))
 | 
			
		||||
            .then((oldAVDs) => {
 | 
			
		||||
            oldAVDList = oldAVDs;
 | 
			
		||||
        }, () => {
 | 
			
		||||
            oldAVDList = '[]';
 | 
			
		||||
        })
 | 
			
		||||
            .then(() => {
 | 
			
		||||
            return updateBinary(binary, outputDir, proxy, ignoreSSL);
 | 
			
		||||
        })
 | 
			
		||||
            .then(() => {
 | 
			
		||||
            initialize_1.android(path.resolve(outputDir, binary.executableFilename()), android_api_levels, android_architectures, android_platforms, android_accept_licenses, binaries[binaries_1.AndroidSDK.id].versionCustom, JSON.parse(oldAVDList), logger, verbose);
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
    if (ios) {
 | 
			
		||||
        initialize_1.iOS(logger);
 | 
			
		||||
    }
 | 
			
		||||
    if (android || ios) {
 | 
			
		||||
        installAppium(binaries[binaries_1.Appium.id], outputDir);
 | 
			
		||||
        updateBrowserFile(binaries[binaries_1.Appium.id], outputDir);
 | 
			
		||||
    }
 | 
			
		||||
    return Promise.all(promises).then(() => {
 | 
			
		||||
        writeBrowserFile(outputDir);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function updateBinary(binary, outputDir, proxy, ignoreSSL) {
 | 
			
		||||
    return files_1.FileManager
 | 
			
		||||
        .downloadFile(binary, outputDir, (binary, outputDir, fileName) => {
 | 
			
		||||
        unzip(binary, outputDir, fileName);
 | 
			
		||||
    })
 | 
			
		||||
        .then(downloaded => {
 | 
			
		||||
        if (!downloaded) {
 | 
			
		||||
            // The file did not have to download, we should unzip it.
 | 
			
		||||
            logger.info(binary.name + ': file exists ' + path.resolve(outputDir, binary.filename()));
 | 
			
		||||
            let fileName = binary.filename();
 | 
			
		||||
            unzip(binary, outputDir, fileName);
 | 
			
		||||
            logger.info(binary.name + ': ' + binary.executableFilename() + ' up to date');
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function unzip(binary, outputDir, fileName) {
 | 
			
		||||
    // remove the previously saved file and unzip it
 | 
			
		||||
    let osType = config_1.Config.osType();
 | 
			
		||||
    let mv = path.resolve(outputDir, binary.executableFilename());
 | 
			
		||||
    try {
 | 
			
		||||
        fs.unlinkSync(mv);
 | 
			
		||||
    }
 | 
			
		||||
    catch (err) {
 | 
			
		||||
        try {
 | 
			
		||||
            rimraf.sync(mv);
 | 
			
		||||
        }
 | 
			
		||||
        catch (err2) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // unzip the file
 | 
			
		||||
    logger.info(binary.name + ': unzipping ' + fileName);
 | 
			
		||||
    if (fileName.slice(-4) == '.zip') {
 | 
			
		||||
        try {
 | 
			
		||||
            let zip = new AdmZip(path.resolve(outputDir, fileName));
 | 
			
		||||
            zip.extractAllTo(outputDir, true);
 | 
			
		||||
        }
 | 
			
		||||
        catch (e) {
 | 
			
		||||
            throw new Error(`Invalid filename: ${path.resolve(outputDir, fileName)}`);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        // We will only ever get .tar files on linux
 | 
			
		||||
        child_process.spawnSync('tar', ['zxvf', path.resolve(outputDir, fileName), '-C', outputDir]);
 | 
			
		||||
    }
 | 
			
		||||
    // rename
 | 
			
		||||
    if (fileName.indexOf('chromedriver_') != -1) {
 | 
			
		||||
        fs.renameSync(path.resolve(outputDir, 'chromedriver-mac-x64', binary.zipContentName()), mv)
 | 
			
		||||
    } else {
 | 
			
		||||
        fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
 | 
			
		||||
    }
 | 
			
		||||
    // set permissions
 | 
			
		||||
    if (osType !== 'Windows_NT') {
 | 
			
		||||
        logger.info(binary.name + ': setting permissions to 0755 for ' + mv);
 | 
			
		||||
        if (binary.id() !== binaries_1.AndroidSDK.id) {
 | 
			
		||||
            fs.chmodSync(mv, '0755');
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            fs.chmodSync(path.resolve(mv, 'tools', 'android'), '0755');
 | 
			
		||||
            fs.chmodSync(path.resolve(mv, 'tools', 'emulator'), '0755');
 | 
			
		||||
            // TODO(sjelin): get 64 bit versions working
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function installAppium(binary, outputDir) {
 | 
			
		||||
    logger.info('appium: installing appium');
 | 
			
		||||
    let folder = path.resolve(outputDir, binary.filename());
 | 
			
		||||
    try {
 | 
			
		||||
        rimraf.sync(folder);
 | 
			
		||||
    }
 | 
			
		||||
    catch (err) {
 | 
			
		||||
    }
 | 
			
		||||
    fs.mkdirSync(folder);
 | 
			
		||||
    fs.writeFileSync(path.resolve(folder, 'package.json'), JSON.stringify({ scripts: { appium: 'appium' } }));
 | 
			
		||||
    utils_1.spawn('npm', ['install', 'appium@' + binary.version()], null, { cwd: folder });
 | 
			
		||||
}
 | 
			
		||||
function updateBrowserFile(binary, outputDir) {
 | 
			
		||||
    let currentDownload = path.resolve(outputDir, binary.executableFilename());
 | 
			
		||||
    // if browserFile[id] exists, we should update it
 | 
			
		||||
    if (browserFile[binary.id()]) {
 | 
			
		||||
        let binaryPath = browserFile[binary.id()];
 | 
			
		||||
        if (binaryPath.last === currentDownload) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            binaryPath.last = currentDownload;
 | 
			
		||||
            for (let bin of binaryPath.all) {
 | 
			
		||||
                if (bin === currentDownload) {
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            binaryPath.all.push(currentDownload);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        // The browserFile[id] does not exist / has not been downloaded previously.
 | 
			
		||||
        // We should create the entry.
 | 
			
		||||
        let binaryPath = { last: currentDownload, all: [currentDownload] };
 | 
			
		||||
        browserFile[binary.id()] = binaryPath;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function writeBrowserFile(outputDir) {
 | 
			
		||||
    let filePath = path.resolve(outputDir, 'update-config.json');
 | 
			
		||||
    fs.writeFileSync(filePath, JSON.stringify(browserFile));
 | 
			
		||||
}
 | 
			
		||||
// for testing
 | 
			
		||||
function clearBrowserFile() {
 | 
			
		||||
    browserFile = {};
 | 
			
		||||
}
 | 
			
		||||
exports.clearBrowserFile = clearBrowserFile;
 | 
			
		||||
//# sourceMappingURL=update.js.map
 | 
			
		||||
		Reference in New Issue
	
	Block a user