diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..c7cfc85a9 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,256 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events + push: + branches: + - '**' + tags: + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' + pull_request: + # Allows you to reuse this workflow from another one + workflow_call: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + PHARO: 110 + ARCHITECTURE: 64 + VM: vm + isRelease: ${{ startsWith(github.ref, 'refs/tags/') }} + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set environment + run: | + echo GITHUB_REF_NAME = ${GITHUB_REF_NAME} + echo GITHUB_SHA = ${GITHUB_SHA} + echo isRelease = ${{ env.isRelease }} + echo GITHUB_WORKSPACE = $GITHUB_WORKSPACE + SHORT_SHA=$(git rev-parse --short HEAD) + echo SHORT_SHA = $SHORT_SHA + echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV + case ${{ env.isRelease }} in + (true) export LAUNCHER_VERSION="$(git describe --tags --always)";; + (false) export LAUNCHER_VERSION=$SHORT_SHA;; + *) echo "${{ env.isRelease }}";; + esac + echo "LAUNCHER_VERSION=$LAUNCHER_VERSION" >> $GITHUB_ENV + echo LAUNCHER_VERSION = $LAUNCHER_VERSION + if [ '${{ env.ARCHITECTURE }}' = '64' ]; then + export FILE_NAME_ARCH_SUFFIX='x64' + fi + echo "FILE_NAME_ARCH_SUFFIX=$FILE_NAME_ARCH_SUFFIX" >> $GITHUB_ENV + echo FILE_NAME_ARCH_SUFFIX = $FILE_NAME_ARCH_SUFFIX + + - name: Build and test + run: | + VERSION=${SHORT_SHA} ./build.sh prepare + VERSION=${SHORT_SHA} ./build.sh test + + - uses: actions/upload-artifact@v3 # upload test results + if: success() || failure() # run this step even if previous step failed + with: + name: test-results + path: ./*.xml + + - name: Test report + uses: dorny/test-reporter@v1 + if: success() || failure() # run this step even if previous step failed + with: + name: Pharo Launcher Tests # Name of the check run which will be created + path: ./*.xml # Path to test results + reporter: java-junit # Format of test results + + - name: Make Pharo Launcher deployed + run: ./build.sh make-deployed + + - uses: actions/upload-artifact@v3 + with: + name: packaging-user + path: | + PharoLauncher.image + PharoLauncher.changes + Pharo*.sources + + - name: Linux packaging + run: VERSION=${LAUNCHER_VERSION} ./build.sh linux-package + + - uses: actions/upload-artifact@v3 + with: + name: PharoLauncher-linux-${{ env.LAUNCHER_VERSION }}-${{ env.FILE_NAME_ARCH_SUFFIX }} + path: pharo-launcher-linux.tar + + outputs: + launcherVersion: ${{ env.LAUNCHER_VERSION }} + + win-package: + name: Windows packaging + needs: build + runs-on: windows-latest + env: + PACKAGE_DIR: windows\pharo-launcher-win + + steps: + - name: Compute Installer version + shell: bash + run: | + # VERSION cannot be a string in Advanced Installer. Let's use 0.0.0 for bleeding edge versions + installerVersion=0.0.0 + if [ "${{ env.isRelease }}" = true ] ; then + # only get version number, not arch + # uses bash parameter expansion using a pattern. + # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html + # and https://tldp.org/LDP/abs/html/string-manipulation.html + installerVersion=${{ needs.build.outputs.launcherVersion }} + installerVersion=${installerVersion%-*} + fi + echo installerVersion = $installerVersion + echo "INSTALLER_VERSION=$installerVersion" >> $GITHUB_ENV + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Prepare files + shell: pwsh + run: | + Invoke-WebRequest -OutFile pharo-win-stable-signed.zip -Uri http://files.pharo.org/get-files/${{ env.PHARO }}/pharo-win-stable-signed.zip + Expand-Archive -LiteralPath .\pharo-win-stable-signed.zip -DestinationPath $Env:PACKAGE_DIR + $Env:IMAGES_DIR = "${Env:PACKAGE_DIR}\images" + mkdir "$Env:IMAGES_DIR" + Invoke-WebRequest -OutFile ${Env:IMAGES_DIR}\pharo-stable.zip -Uri https://files.pharo.org/image/stable/stable-64.zip + + - uses: actions/download-artifact@v3 + with: + name: packaging-user + path: ${{ env.PACKAGE_DIR }} + + - name: Display structure of files to package + run: Get-ChildItem -Recurse ${{ env.PACKAGE_DIR }} + + - uses: actions/upload-artifact@v3 + with: + name: PharoLauncher-windows-${{ needs.build.outputs.launcherVersion }} + path: ${{ env.PACKAGE_DIR }} + + - name: Build Advanced Installer Project + uses: caphyon/advinst-github-action@v1.0 + with: + advinst-version: '20.9.1' + advinst-enable-automation: 'true' + + # See https://www.advancedinstaller.com/user-guide/tutorial-powershell-commands-installation.html for more details + - name: Build setup using Advinst Powershell Automation + shell: pwsh + run: | + $advinst = New-Object -ComObject AdvancedInstaller + $project = $advinst.CreateProjects("simple") + $project.ProductDetails.Name = “Pharo Launcher” + $project.ProductDetails.Publisher= “Pharo project” + $project.ProductDetails.Version= “${{ env.INSTALLER_VERSION }}” + $Env:PHARO_LAUNCHER_ICON = "${{ github.workspace }}\icons\pharo-launcher.ico" + $project.ProductDetails.SetIcon($Env:PHARO_LAUNCHER_ICON) + $project.InstallParameters.ApplicationFolder = "[LocalAppDataFolder]\[ProductName]" + + $project.FilesComponent.AddFolderContents(“appdir”, “${{ github.workspace }}\${{ env.PACKAGE_DIR }}”) + $project.FilesComponent.Files + + $project.ShortcutsComponent.CreateFileShortcutS("desktopfolder", "appdir\Pharo.exe") + $project.ShortcutsComponent.CreateFileShortcutS("programmenufolder", "appdir\Pharo.exe") + $project.ShortcutsComponent.CreateFileShortcutS($project.PredefinedFolders.ShortcutFolder.FullPath, "appdir\Pharo.exe") + for ($index = 0 ; $index -le 2 ; $index++) { + $shortcut = $project.ShortcutsComponent.Shortcuts[$index] + $shortcut.Icon($Env:PHARO_LAUNCHER_ICON) + $shortcut.Name = 'Pharo Launcher' + $shortcut.Arguments = 'PharoLauncher.image' + } + + $outputFolder = "${{ github.workspace }}\setup"; + $defaultBuild = $project.BuildComponent.Builds[0]; + $defaultBuild.OutputFolder = $outputFolder + + $projectFile = "${{ github.workspace }}\pharo-launcher-${{ needs.build.outputs.launcherVersion }}.aip" + $project.SaveAs($projectFile) + get-content $projectFile + $project.Build() + + - uses: actions/upload-artifact@v3 + with: + name: PharoLauncher-windows-installer-${{ needs.build.outputs.launcherVersion }} + path: setup/pharo-launcher*.msi + + mac-package: + name: Mac OS packaging + needs: build + runs-on: macos-latest + env: + RESOURCES_DIR: PharoLauncher.app/Contents/Resources + strategy: + matrix: + arch: [64, arm64] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v3 + with: + name: packaging-user + path: ${{ env.RESOURCES_DIR }} + + - name: Build ${{ matrix.arch }} mac os package + run: ARCHITECTURE=${{ matrix.arch }} VERSION=${{ needs.build.outputs.launcherVersion }} ./build.sh mac-package + + - uses: actions/upload-artifact@v3 + with: + name: PharoLauncher-mac-installer-${{ needs.build.outputs.launcherVersion }}-${{ matrix.arch == '64' && 'x64' || matrix.arch }} + path: PharoLauncher-*.dmg + + publish: + runs-on: ubuntu-latest + needs: [ build, mac-package, win-package ] + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download artefacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Prepare upload + run: | + LINUX_PKG_NAME=$(echo artifacts/PharoLauncher-linux-${{ needs.build.outputs.launcherVersion }}-*) + echo LINUX_PKG_NAME = $LINUX_PKG_NAME + zip -q -r -9 $LINUX_PKG_NAME.zip $LINUX_PKG_NAME + WINDOWS_PKG_NAME=$(echo artifacts/PharoLauncher-windows-${{ needs.build.outputs.launcherVersion }}) + echo WINDOWS_PKG_NAME = $WINDOWS_PKG_NAME + zip -q -r -9 $WINDOWS_PKG_NAME.zip $WINDOWS_PKG_NAME + ls -R . + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: | + **/*.msi + **/*.dmg + artifacts/*.zip + body: | + Warning: Release artefacts below are not signed nor notarized and by consequence, are not recognized as safe by Operating Systems. + You can still use them but the prefered way is to download signed and notarized installers from https://pharo.org/download diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 000000000..efb1f95eb --- /dev/null +++ b/.github/workflows/doc.yml @@ -0,0 +1,29 @@ +name: documentation +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + deploy-to-gh-pages: + type: boolean + description: Deploy the documentation built with mkdocs to GitHub pages? + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.x + - run: pip install mkdocs + + - run: mkdocs build + if: github.event.inputs.deploy-to-gh-pages == 'false' + - uses: actions/upload-artifact@v3 + with: + name: pharo-launcher-documentation + path: site + if: github.event.inputs.deploy-to-gh-pages == 'false' + + - run: mkdocs gh-deploy + if: github.event.inputs.deploy-to-gh-pages == 'true' diff --git a/.gitignore b/.gitignore index c7248c9f9..a321203e1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ site/ *.html *.swp + +.DS_Store diff --git a/Jenkinsfile b/Jenkinsfile index 191f5d5a6..a055e252f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ def buildArchitecture(architecture, pharoVersion) { } } */ archiveArtifacts artifacts: 'pharo-launcher-*.msi, Pharo-win.zip', fingerprint: true - stash includes: 'pharo-launcher-*.msi', name: "pharo-launcher-win-${architecture}-package" + stash includes: 'pharo-launcher-*.msi, Pharo-win.zip', name: "pharo-launcher-win-${architecture}-package" } } } @@ -96,6 +96,7 @@ def buildArchitecture(architecture, pharoVersion) { if (isNotArm64Architecure()) { unstash "pharo-launcher-win-${architecture}-package" upload('pharo-launcher-*.msi', uploadDirectoryName()) + upload('Pharo-win.zip', uploadDirectoryName()) } unstash "pharo-launcher-osx-${architecture}-package" fileToUpload = 'PharoLauncher*-' + fileNameArchSuffix(architecture) + '.dmg' @@ -123,9 +124,7 @@ def notifyBuild() { } def cleanUploadFolderIfNeeded(launcherVersion) { - if (isPullRequest()) { - //Only upload files if not in a PR (i.e., CHANGE_ID not empty) - echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim()) + if (shouldNotUpload()) { return; } @@ -159,9 +158,7 @@ def finalizeUpload(launcherVersion) { } def upload(file, launcherVersion) { - if (isPullRequest()) { - //Only upload files if not in a PR (i.e., CHANGE_ID not empty) - echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim()) + if (shouldNotUpload()) { return; } @@ -185,6 +182,30 @@ def fileNameArchSuffix(architecture) { return (architecture == '64') ? 'x64' : architecture } +def shouldNotUpload() { + if (isRelease) { + return false + } + + if (isPullRequest()) { + //Only upload files if not in a PR (i.e., CHANGE_ID not empty) + echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim()) + return true + } + + if (isNotDevBranch()) { + echo "[DO NO UPLOAD] In branch " + (env.BRANCH_NAME?.trim()) + return true + } + + // Do upload + return false +} + +def isNotDevBranch() { + return env.BRANCH_NAME != "dev" +} + def isPullRequest() { return env.CHANGE_ID != null } diff --git a/PharoLauncherCmdLine-description.md b/PharoLauncherCmdLine-description.md deleted file mode 100644 index 4a4d1d27b..000000000 --- a/PharoLauncherCmdLine-description.md +++ /dev/null @@ -1,17 +0,0 @@ -# Introduction -Purpose of this document is to describe command line interface for Pharo launcher with description of necessary commands. - -# Plans -1. At first, estabilish structure/design of cmd-line interface and what operations, arguments should be supported (this document). -2. Implement stub of cmd-line interface using CLAP. It won't contain necessary connection to Pharo launcher commands yet. -3. If cmd-line design is good to go, we can start on moving Pharo launcher backend code to dedicated package, which could be used by CLAP commands in previous step. -4. Build of headless Pharo launcher (resulting in change of Pharo launcher baseline and change of corresponding Github actions) can be then initiated. Resulting app (executable) will no longer open UI of Pharo launcher. - -# Open questions -1. What if there is some interaction needed? E.g. network is unavailable, should we offer dialog-like options (e.g.: "Reconnect Y/N?"), or rather to avoid that? -2. What is priority of every command? I guess some of them are more important than others (order of how it should be implemented). -3. How to escape path parameters? What type of quotes should be used? (single like 'path to dir' or rathter "this is path" -4. How to print-out errors? Some kind of formatting? (E.g. "ERROR: Could not create image to directory: usr/local/Pharo/images") -5. How to display progress (if ever)? This could be useful during downlaod commands, like "INFO: Fetching from remote-site URL..." (dot's added every second, or maybe percentage?). - - diff --git a/README.md b/README.md index 19cfdd7df..1708699b8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Pharo Launcher [![Build Status](https://ci.inria.fr/pharo-ci-jenkins2/job/PharoLauncher-Pipeline/job/development/badge/icon)](https://ci.inria.fr/pharo-ci-jenkins2/job/PharoLauncher-Pipeline/job/development/) +# Pharo Launcher [![CI](https://github.com/pharo-project/pharo-launcher/actions/workflows/CI.yml/badge.svg)](https://github.com/pharo-project/pharo-launcher/actions/workflows/CI.yml) The Pharo Launcher is a cross-platform application that - lets you manage your Pharo images (launch, rename, copy and delete); - lets you download image templates (i.e., zip archives) from many @@ -6,7 +6,7 @@ The Pharo Launcher is a cross-platform application that - lets you create new images from any template, - automatically find and download the appropriate VM to launch your images. -A Pharo Launcher screenshot +A Pharo Launcher screenshot The idea behind the Pharo Launcher is that you should be able to access it very rapidly from your OS application launcher. As a result, launching any image is never more than 3 clicks away. @@ -16,7 +16,8 @@ Please report bugs on the 'Launcher' project at [https://github.com/pharo-projec You can contribute to this project. All classes and most methods are commented. There are unit tests. Please contribute! - **Source code:** [https://github.com/pharo-project/pharo-launcher](https://github.com/pharo-project/pharo-launcher) -- **CI:** [https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/PharoLauncher-Pipeline/branches/](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/PharoLauncher-Pipeline/branches/) [![Build Status](https://ci.inria.fr/pharo-ci-jenkins2/job/PharoLauncher-Pipeline/job/development/badge/icon)](https://ci.inria.fr/pharo-ci-jenkins2/job/PharoLauncher-Pipeline/job/development/) +- **CI:** [https://github.com/pharo-project/pharo-launcher/actions](https://github.com/pharo-project/pharo-launcher/actions) [![CI](https://github.com/pharo-project/pharo-launcher/actions/workflows/CI.yml/badge.svg)](https://github.com/pharo-project/pharo-launcher/actions/workflows/CI.yml) + ## Motivations In the past, I had several folders with images everywhere on my HD. Sometimes with the VM, sometimes without. Lots of image searching as you can imagine. Now, my HD is now much cleaner - all images are in a central place and I need only one icon/starter on the desktop to open. PharoLauncher is also a convenient tool to download specific image update versions if you want to reproduce or fix Pharo bugs. I also associated one of the unused laptop keys with PharoLauncher - so the world of Smalltalk is just one click away... @@ -79,8 +80,8 @@ Once done, you can load the project through Metacello integration (uses Baseline ```Smalltalk Metacello new baseline: 'PharoLauncher'; - repository: 'github://pharo-project/pharo-launcher:development/src'; + repository: 'github://pharo-project/pharo-launcher:dev/src'; load ``` -Then evaluate "PharoLauncher open". You can also launch it from the World menu. +Then evaluate "PharoLauncherApplication open". You can also launch it from the World menu. diff --git a/build.sh b/build.sh index a11b3e0c9..4fdf0776d 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ set -ex # $ARCHITECTURE : targeted architecture 32 or 64 bits. Default will be 32. # Script parameters -# $1: the target to run between prepare | test | user +# $1: the target to run function prepare_image() { case "$ARCHITECTURE" in @@ -24,7 +24,7 @@ function prepare_image() { esac wget --quiet -O - get.pharo.org/$ARCH_PATH$PHARO | bash wget --quiet -O - get.pharo.org/$ARCH_PATH$VM$PHARO | bash - echo $PHARO > 'pharo.version' + echo "$PHARO" > 'pharo.version' ./pharo Pharo.image save PharoLauncher --delete-old ./pharo PharoLauncher.image --version > version.txt @@ -32,7 +32,8 @@ function prepare_image() { } function run_tests() { - ./pharo PharoLauncher.image test --junit-xml-output "PharoLauncher.*" + rm -rf ~/Pharo # clean posssible remaining Pharo files + ./pharo PharoLauncher.image test --junit-xml-output "PharoLauncher.*" run_shell_cli_tests } @@ -45,7 +46,7 @@ function run_shell_cli_tests() { popd } -function package_user_version() { +function make_pharo_launcher_deloyed() { ./pharo PharoLauncher.image eval --save "PhLDeploymentScript doAll" # Set the launcher version on Pharo @@ -57,50 +58,34 @@ function package_user_version() { "PhLTemplateSources resetLauncherCoreDir. PharoLauncherApplication resetTemplateRepository. PhLDeploymentScript resetPharoLauncherIcebergRepositoryLocation" - - # Create the platform-specific archives - mkdir One - cp PharoLauncher.image One/Pharo.image - cp PharoLauncher.changes One/Pharo.changes - cp Pharo*.sources One/ - cd One - copy_current_stable_image - cd .. - - set_env - - zip -9r PharoLauncher-user-$VERSION_NUMBER.zip PharoLauncher.image PharoLauncher.changes launcher-version.txt } function package_linux_version() { set_env - rm -f pharo-build-scripts/platform/icons/* - cp icons/pharo-launcher.png pharo-build-scripts/platform/icons/ - rm pharo-build-scripts/platform/templates/linux/%\{NAME\}.template - cp linux/pharo-launcher-ui pharo-build-scripts/platform/templates/linux/pharo-launcher-ui.template - cp script/pharo-launcher.sh pharo-build-scripts/platform/templates/linux/pharo-launcher.template - EXECUTABLE_NAME=pharo-launcher-ui WORKSPACE=$(pwd) IMAGES_PATH=$(pwd)/One INPUT_SOURCES=$(ls $IMAGES_PATH/Pharo*.sources) ./pharo-build-scripts/build-platform.sh \ - -i Pharo \ - -o PharoLauncher \ - -r $PHARO \ - -v $VERSION-$DATE \ - -t PharoLauncher \ - -p linux - - mv PharoLauncher-linux.zip PharoLauncher-linux-$VERSION_NUMBER.zip + OUTPUT_PATH=build + RESOURCES_PATH=$OUTPUT_PATH/shared + rm -f $OUTPUT_PATH; mkdir $OUTPUT_PATH + mkdir $OUTPUT_PATH/icons; cp icons/pharo-launcher.png $OUTPUT_PATH/icons/ + cp linux/pharo-launcher-ui $OUTPUT_PATH/ + cp scripts/pharo-launcher.sh $OUTPUT_PATH/pharo-launcher + mkdir $RESOURCES_PATH + copy_current_stable_image_to $RESOURCES_PATH + expand_all_templates $OUTPUT_PATH + cp PharoLauncher.image $RESOURCES_PATH + cp PharoLauncher.changes $RESOURCES_PATH + cp Pharo*.sources $RESOURCES_PATH + fetch_current_vm_to $OUTPUT_PATH + # ensure the linux scripts are executable + chmod +x "$OUTPUT_PATH/pharo-launcher" "$OUTPUT_PATH/pharo-launcher-ui" || true + mv build pharo-launcher + tar -cvf pharo-launcher-linux.tar pharo-launcher } -function prepare_mac_resources_for_build_platform_script() { - rm -f pharo-build-scripts/platform/icons/* +function copy_mac_icon_files_to() { cd icons ./build-icns.sh pharo-launcher.png PharoLauncher.iconset cd .. - cp icons/PharoLauncher.icns pharo-build-scripts/platform/icons/ - rm -f pharo-build-scripts/platform/templates/mac/Contents/* - cp mac/Info.plist.template pharo-build-scripts/platform/templates/mac/Contents/ -} - -function copy_mac_icon_files_to() { + cp icons/PharoLauncher.icns $1 cp icons/PharoImage.icns $1 cp icons/PharoChanges.icns $1 cp icons/PharoSources.icns $1 @@ -108,82 +93,34 @@ function copy_mac_icon_files_to() { function package_mac_version() { set_env - local should_sign=${1:-false} # If no argument given, do not sign - prepare_mac_resources_for_build_platform_script - WORKSPACE=$(pwd) IMAGES_PATH=$(pwd)/One INPUT_SOURCES=$(ls $IMAGES_PATH/Pharo*.sources) ./pharo-build-scripts/build-platform.sh \ - -i Pharo \ - -o PharoLauncher \ - -r $PHARO \ - -v $VERSION-$DATE \ - -t PharoLauncher \ - -p mac - unzip PharoLauncher-mac.zip -d . + OUTPUT_PATH=PharoLauncher.app/Contents + RESOURCES_PATH=$OUTPUT_PATH/Resources + BIN_PATH=$OUTPUT_PATH/MacOS + cp mac/Info.plist.template $OUTPUT_PATH/ + cp -R mac/MainMenu.nib $RESOURCES_PATH/English.lproj/ + expand_all_templates $OUTPUT_PATH + copy_current_stable_image_to $RESOURCES_PATH + copy_mac_icon_files_to $RESOURCES_PATH/ mv mac-installer-background.png background.png - rm -f PharoLauncher.app/Contents/Resources/English.lproj/MainMenu.nib - cp -R mac/MainMenu.nib PharoLauncher.app/Contents/Resources/English.lproj/ - cp script/pharo-launcher.sh PharoLauncher.app/Contents/MacOS/pharo-launcher - chmod +x PharoLauncher.app/Contents/MacOS/pharo-launcher - copy_mac_icon_files_to PharoLauncher.app/Contents/Resources/ + fetch_current_mac_vm_to $(pwd)/$OUTPUT_PATH + cp scripts/pharo-launcher.sh $BIN_PATH/pharo-launcher && chmod +x $BIN_PATH/pharo-launcher VERSION=$VERSION_NUMBER APP_NAME=PharoLauncher SHOULD_SIGN=false ./mac/build-dmg.sh - local generated_dmg=$(echo *.dmg) + local generated_dmg + generated_dmg=$(echo *.dmg) mv "$generated_dmg" "PharoLauncher-$VERSION_NUMBER.dmg" generated_dmg=$(echo *.dmg) md5 "$generated_dmg" > "$generated_dmg.md5sum" } -function package_windows_version() { - local should_sign=false # For now do not sign, we do not have anymore a valid certificate file ${1:-false} # If no argument given, do not sign - set_env - WIN_VM_PATH=pharo-win-stable-signed.zip INPUT_SOURCES=One/$(basename $(ls One/Pharo*.sources)) bash ./pharo-build-scripts/build-platform.sh \ - -i Pharo \ - -o Pharo \ - -r $PHARO \ - -v $VERSION-$DATE \ - -t Pharo \ - -p win - unzip Pharo-win.zip -d . - - if [ "$should_sign" = true ] ; then - openssl aes-256-cbc -k "${PHARO_CERT_PASSWORD}" -in signing/pharo-windows-certificate.p12.enc -out pharo-windows-certificate.p12 -d - local signtool='C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe' - "$signtool" sign //f pharo-windows-certificate.p12 //p ${PHARO_CERT_PASSWORD} Pharo/Pharo.exe - "$signtool" sign //f pharo-windows-certificate.p12 //p ${PHARO_CERT_PASSWORD} Pharo/PharoConsole.exe - fi - - local installerVerion=bleedingEdge - if [ "$IS_RELEASE" = true ] ; then - # only get version number, not arch - # uses bash parameter expansion using a pattern. - # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html - installerVerion=${VERSION_NUMBER%-*} - fi - OS_NAME=$(uname -s) - OS_NAME=${OS_NAME:0:6} - if [[ "$OS_NAME" = "CYGWIN" ]] - then - # Cygwin specific stuff - CMD="cygstart --wait cmd" - else - CMD=cmd - fi - INSTALLER_VERSION=$installerVerion $CMD /c windows\\build-launcher-installer.bat - if [ "$should_sign" = true ] ; then - "$signtool" sign //f pharo-windows-certificate.p12 //p ${PHARO_CERT_PASSWORD} pharo-launcher-${VERSION}.msi - rm pharo-windows-certificate.p12 - fi -} - function set_env() { DATE=$(date +%Y.%m.%d) case "$ARCHITECTURE" in 32) ARCH_SUFFIX="x86" ;; 64) ARCH_SUFFIX="x64" - export ARCH=64 ;; arm64) ARCH_SUFFIX="arm64" - export ARCH=arm64 ;; *) echo "Error! Architecture $ARCHITECTURE is not supported!" exit 1 @@ -192,16 +129,84 @@ function set_env() { VERSION_NUMBER="$VERSION-$ARCH_SUFFIX" } -function copy_current_stable_image() { - local IMAGES_PATH="images" +function copy_current_stable_image_to() { + local DEST_PATH=${1:-.} # If no argument given, use current working dir + local IMAGES_PATH=$DEST_PATH/images mkdir "$IMAGES_PATH" - wget -P $IMAGES_PATH https://files.pharo.org/image/stable/stable-64.zip + wget --progress=dot:mega -P "$IMAGES_PATH" https://files.pharo.org/image/stable/stable-64.zip mv "$IMAGES_PATH/stable-64.zip" "$IMAGES_PATH/pharo-stable.zip" } -PHARO=${PHARO:=70} # If PHARO not set, set it to 70. +function fetch_current_vm_to() { + local DEST_PATH=${1:-.} # If no argument given, use current working dir + set_arch_path + local LINUX_VM_PATH="pharo-vm-Linux-$VM_ARCH_PATH-stable.zip" + test -f $LINUX_VM_PATH || wget --progress=dot:mega http://files.pharo.org/get-files/$PHARO/$LINUX_VM_PATH + + if [ -f "$LINUX_VM_PATH" ] ; then + unzip -q "$LINUX_VM_PATH" -d "$DEST_PATH/tmp" + mkdir "$DEST_PATH/pharo-vm/" + mv "$DEST_PATH"/tmp/* "$DEST_PATH/pharo-vm/" + else + echo "Warning: Cannot find Linux VM!" + fi +} + +function fetch_current_mac_vm_to() { + # Only works for VM >= 90. If you need a VM < 90, you need to + # udpate this method to use either the old or new VM URL format (see zeroconf). + local DEST_PATH=${1:-.} # If no argument given, use current working dir + set_arch_path + local VM_URL="http://files.pharo.org/get-files/$PHARO/pharo-vm-Darwin-${VM_ARCH_PATH}-stable.zip" + local VM_TMP_PATH="$DEST_PATH/tmp" + mkdir "$VM_TMP_PATH" && cd "$VM_TMP_PATH" + VM_ZIP="${VM_TMP_PATH}/vm.zip" + curl --silent --location --compressed --output "${VM_ZIP}" ${VM_URL} + if [ -f "${VM_ZIP}" ] ; then + unzip -q "${VM_ZIP}" -d "$VM_TMP_PATH" + # Ensuring bin and plugins + mv "$VM_TMP_PATH/Pharo.app/Contents/MacOS" "$DEST_PATH" + # Need to add this ugly '*' outside double-quotes to be able to copy the content of the folder (and not the folder itself) on linux + cp -R "$VM_TMP_PATH/Pharo.app/Contents/Resources/"* "$DEST_PATH/Resources" + + cd - + rm -rf "$VM_TMP_PATH" + else + echo "Warning: Cannot find Mac OS VM!" + fi +} + +function set_arch_path() { + case "$ARCHITECTURE" in + 64) export VM_ARCH_PATH="x86_64" + ;; + arm64) export VM_ARCH_PATH="arm64" + ;; + *) echo "Error! Architecture $ARCHITECTURE is not supported!" + export VM_ARCH_PATH= + exit 1 + ;; + esac +} + +function expand_all_templates() { + local OUTPUT_PATH=$1 + local OPTION_WHEN=`date +"%B %d, %Y"` + set_env + find "$OUTPUT_PATH" -name "*.template" | while read FILE ; do + sed \ + -e "s/%{NAME}/PharoLauncher/g" \ + -e "s/%{TITLE}/PharoLauncher/g" \ + -e "s/%{VERSION}/$VERSION-$DATE/g" \ + -e "s/%{WHEN}/$OPTION_WHEN/g" \ + "$FILE" > "${FILE%.*}" + rm -f "$FILE" + done +} + +PHARO=${PHARO:=70} # If PHARO not set, set it to 70. VM=${VM:=signedVm} # If VM not set, set it to signedVm. -ARCHITECTURE=${ARCHITECTURE:-'32'} # If ARCH not set, set it to 32 bits +ARCHITECTURE=${ARCHITECTURE:-'32'} # If ARCHITECTURE not set, set it to 32 bits SCRIPT_TARGET=${1:-all} SHOULD_SIGN=${SHOULD_SIGN:-false} @@ -215,21 +220,14 @@ prepare) test) run_tests ;; -user) - package_user_version - ;; -win-package) - package_windows_version $SHOULD_SIGN - ;; -mac-package) - package_mac_version $SHOULD_SIGN +make-deployed) + make_pharo_launcher_deloyed ;; linux-package) package_linux_version ;; -all) - prepare_image && run_tests && package_user_version \ - && package_linux_version +mac-package) + package_mac_version "$SHOULD_SIGN" ;; *) echo "No valid target specified! Exiting" diff --git a/docs/commands-cmd-line.md b/doc/commands-cmd-line.md similarity index 80% rename from docs/commands-cmd-line.md rename to doc/commands-cmd-line.md index caf363ef3..2da253b1e 100644 --- a/docs/commands-cmd-line.md +++ b/doc/commands-cmd-line.md @@ -1,6 +1,6 @@ # Pharo Laucher command-line This is list of subject oriented CLI commands of Pharo launcher, where subjects are Pharo VM, image or image template of launcher. -Use: `pharo-launcher.sh ` +Use: `pharo-launcher ` | Command | Sub-command | | Description | | ------- | ----------- | ----------------- | ----------- | @@ -14,12 +14,13 @@ Use: `pharo-launcher.sh ` | | | [fromSHA](#Image-create-from-SHA-commit) | Downloads and creates new image based on the commit SHA (7 letter string contained in the name of Pharo dev template). | | | [delete](#image-delete) | | Deletes the local image, including image directory content. | | | [info](#image-info) | | Prints information about image: name, description, origin template, etc. | -| | [kill](#image-kill) | | Kills the running process(es) of given local image. | | | [launch](#image-launch) | | Launches image with using default (auto-detected) VM. | | | [list](#image-list) | | Lists all local images from Pharo laucher repository. | | | [package](#image-package) | | Creates a package containing all necessary artefacts to launch the image. | -| | [processList](#image-process-list) | | Lists all running Pharo image processes. | | | [recreate](#image-recreate) | | Recreates the local image, the image argument determines the image name to recreate. | +| [process](#process) | | | All sub-commands related to Pharo processes. (Prints help only) | +| | [kill](#process-kill) | | Kills the running Pharo process(es) of given image. | +| | [list](#process-list) | | Lists all running Pharo image processes. | | [template](#template) | | | All sub-commands related to image templates. (Prints help only) | | | [categories](#template-categories) | | Lists all image template categories, based on which are image templates categorized. | | | [info](#template-info) | | Prints information about image template name, origin url. | @@ -33,9 +34,9 @@ Use: `pharo-launcher.sh ` # Getting started Command line interface of Pharo Launcher is avaliable from directory, where launcher is installed. -Pharo Launcher CLI can be executed using: `pharo-launcher.sh ` (choosing on of the commands above). +Pharo Launcher CLI can be executed using: `pharo-launcher ` (choosing on of the commands above). ## 1. List Pharo images -You can start listing Pharo images deployed by Pharo launcher by: `pharo-launcher.sh image list` +You can start listing Pharo images deployed by Pharo launcher by: `pharo-launcher image list` This will give output like: ``` # Name Architecture Pharo version Last modified @@ -47,7 +48,7 @@ This will give output like: 5 Pharo 10.0 - 64bit (stable) 64 100 2022-06-17 12:26:09 ``` ## 2. Create new Pharo image -New Pharo image can be created by executing: `pharo-launcher.sh image create myImage` +New Pharo image can be created by executing: `pharo-launcher image create myImage` This will efectively create Pharo image based on latest stable Pharo release template. Output looks like this: ``` @@ -59,27 +60,27 @@ You could check result by listing Pharo images again. > __Note__: There are other ways to create images, check sub-commands. ## 3. Launching Pharo image -To launch image, execute following: `pharo-launcher.sh image launch myImage` +To launch image, execute following: `pharo-launcher image launch myImage` This will start new Pharo process and window with Pharo should be visible. Check command options, to see how to pass launch configuration. ## 4. Listing running Pharo images -To see, which Pharo images are running: `pharo-launcher.sh image processList` +To see, which Pharo images are running: `pharo-launcher process list` Output will look similar like this: ``` 3093 /home/dbajger/Pharo/vms/100-x64/lib/pharo /home/dbajger/Pharo/images/myImage/myImage.image ``` ## 5. Kill running Pharo image process -To kill running Pharo process execute: `pharo-launcher.sh image kill myImage` +To kill running Pharo process execute: `pharo-launcher process kill myImage` This will kill all running images with name `myImage`. You can also use specific PID, to precisely specify process to kill instead of name of image. ## 6. Create package with Pharo image -To pack existing image with VM and all artefacts you can run: `pharo-launcher.sh image package myImage /home/dbajger/fresh` +To pack existing image with VM and all artefacts you can run: `pharo-launcher image package myImage /home/dbajger/fresh` This will create new directory in `/home/dbajger/fresh` with image and all artefacts. > __Note__: You can also use `--zip` option to have just zip archive with image artifacts (see details below). ## 7. Deleting existing image -To delete image and its directory, run: `pharo-launcher.sh image delete myImage` +To delete image and its directory, run: `pharo-launcher image delete myImage` You can list Pharo images again to check that image is deleted. # Description of all Pharo Launcher CLI commands @@ -88,19 +89,19 @@ You can list Pharo images again to check that image is deleted. This is help for command line interface of Pharo Launcher. Common purpose of laucher is to create Pharo image locally from remote site template, launch Pharo, eventually delete an image, update VMs, etc. -Run: `pharo-launcher.sh help` +Run: `pharo-launcher help` # Image commands ## Image Root command of all image commands, prints help only. -Run: `pharo-launcher.sh image` to see help. +Run: `pharo-launcher image` to see help. ## Image copy Creates copy of given image with new name. ### Usage ```bash -pharo-launcher.sh image copy [--help] [] [] +pharo-launcher image copy [--help] [] [] ``` ### Parameters @@ -114,13 +115,13 @@ pharo-launcher.sh image copy [--help] [] [] ### Examples **#1:** To copy existing image `myImage` and create new copy `newImage` from it, run: ``` -pharo-launcher.sh image copy myImage newImage +pharo-launcher image copy myImage newImage ``` ## Image create Downloads and creates new image on local computer from remote site based on template name (latest stable template is used by default). ### Usage ```bash -pharo-launcher.sh image create [--help] [--templateName ] [--templateCategory ] [] +pharo-launcher image create [--help] [--templateName ] [--templateCategory ] [] ``` ### Parameters @@ -139,15 +140,15 @@ pharo-launcher.sh image create [--help] [--templateName ] [- ### Examples **#1:** Creates an image (passing new image name as argument) based on the last pharo stable 64bits version: ``` -pharo-launcher.sh image create myNewImageName +pharo-launcher image create myNewImageName ``` **#2:** Creates an image based on the template `Pharo 7.0 - 64bit (old stable)` listed in `Official distributions` (default) template category: ``` -pharo-launcher.sh image create myNewImageName "Pharo 7.0 - 64bit (old stable)" +pharo-launcher image create myNewImageName "Pharo 7.0 - 64bit (old stable)" ``` **#3:** Creates an image based on the template `Pharo Mooc` from template category `Pharo Mooc`: ``` -pharo-launcher.sh image create myNewImageName "Pharo Mooc" --templateCategory "Pharo Mooc" +pharo-launcher image create myNewImageName "Pharo Mooc" --templateCategory "Pharo Mooc" ``` ## Image create from build number @@ -155,7 +156,7 @@ Downloads and creates new image based on a the build number contained in the Pha ### Usage ```bash -pharo-launcher.sh image create fromBuild [--help] [--pharoVersion ] [--newImageName ] [] +pharo-launcher image create fromBuild [--help] [--pharoVersion ] [--newImageName ] [] ``` ### Parameters @@ -175,7 +176,7 @@ Downloads and creates new image based on a Github pull request number from the s ### Usage ```bash -pharo-launcher.sh image create fromPR [--help] [--newImageName ] [--templateName ] [--templateCategory ] [] +pharo-launcher image create fromPR [--help] [--newImageName ] [--templateName ] [--templateCategory ] [] ``` ### Parameters @@ -196,7 +197,7 @@ Downloads and creates new image based on a template and loads user defined proje ### Usage ```bash -pharo-launcher.sh image create fromRepo [--help] [--newImageName ] [--templateName ] [--templateCategory ] [--subfolder ] [--baseline ] [--group ] [] +pharo-launcher image create fromRepo [--help] [--newImageName ] [--templateName ] [--templateCategory ] [--subfolder ] [--baseline ] [--group ] [] ``` ### Parameters @@ -225,7 +226,7 @@ Downloads and creates new image based on the commit SHA (7 letter string) of Pha ### Usage ```bash -pharo-launcher.sh image create fromSHA [--help] [--pharoVersion ] [--newImageName ] [] +pharo-launcher image create fromSHA [--help] [--pharoVersion ] [--newImageName ] [] ``` ### Parameters Commit SHA (7 letters) of Pharo image development template, from which will be image created. @@ -244,7 +245,7 @@ Deletes the local image, including image directory content. ### Usage ```bash -pharo-launcher.sh image delete [--help] [] +pharo-launcher image delete [--help] [] ``` ### Parameters @@ -261,7 +262,7 @@ Prints information about image: name, description, origin template, etc. ### Usage ```bash -pharo-launcher.sh image info [--help] [--brief] [--rowMode] [--delimiter ] [--ston] [] +pharo-launcher image info [--help] [--brief] [--rowMode] [--delimiter ] [--ston] [] ``` ### Parameters @@ -277,31 +278,12 @@ pharo-launcher.sh image info [--help] [--brief] [--rowMode] [--delimiter ] -``` - -### Parameters - - Specifies the local image name to kill its process. - -### Options - --help Prints this documentation - --all Determines whether to kill all running Pharo image processes. - -### Examples -No examples yet. - ## Image launch Launches image with using default (auto-detected) VM. ### Usage ```bash -pharo-launcher.sh image launch [--help] [--script ] [] +pharo-launcher image launch [--help] [--script ] [] ``` ### Parameters @@ -315,11 +297,11 @@ pharo-launcher.sh image launch [--help] [--script ] [] [--brief] [--rowMode] [--delimiter ] [--ston] +pharo-launcher image list [--help] [--nameFilter ] [--brief] [--rowMode] [--delimiter ] [--ston] ``` ### Options --help Prints this documentation - --name - Determines the name of image (or its sub-part) to list local images. + --nameFilter + Images listing will be filtered by the provided name filter. --brief Prints only name attribute (with leading sequence number). --rowMode Prints one attribute per line only. --delimiter @@ -347,7 +329,7 @@ Creates a package containing all necessary artefacts to launch the image. ### Usage ```bash -pharo-launcher.sh image package [--help] [--zip] [--vm ] [] [] +pharo-launcher image package [--help] [--zip] [--vm ] [] [] ``` ### Parameters @@ -364,43 +346,72 @@ pharo-launcher.sh image package [--help] [--zip] [--vm ] [] ``` +### Parameters + + Local image name to recreate. + ### Options --help Prints this documentation -### Examples -No examples yet. -## Image recreate -Recreates the local image, the image argument determines the image name to recreate. +# Process commands + +## Process +Root command of all process commands, prints help only. +Run: `pharo-launcher process` to see help. + +## Process kill +Kills the running Pharo process(es) of given local image. ### Usage ```bash -pharo-launcher.sh image recreate [--help] [] +pharo-launcher process kill [--help] [--all] [] ``` + ### Parameters - Local image name to recreate. + Specifies the local image name to kill its process. ### Options --help Prints this documentation + --all Determines whether to kill all running Pharo image processes. + +### Examples +No examples yet. + +## Process list +Lists all running Pharo image processes. + +### Usage +```bash +pharo-launcher process list [--help] +``` +### Options + --help Prints this documentation + +### Examples +No examples yet. + + # Template commands + ## Template Root command of all template commands, prints help only. -Run: `pharo-launcher.sh template` to see help. +Run: `pharo-launcher template` to see help. ## Template categories Prints list of image template categories. ### Usage ```bash -pharo-launcher.sh template categories [--help] [--brief] [--rowMode] [--delimiter ] [--ston] +pharo-launcher template categories [--help] [--brief] [--rowMode] [--delimiter ] [--ston] ``` ### Options @@ -418,7 +429,7 @@ Prints information about image template name, origin url. ### Usage ```bash -pharo-launcher.sh template info [--help] [--templateCategory ] [] +pharo-launcher template info [--help] [--templateCategory ] [] ``` ### Parameters @@ -437,7 +448,7 @@ Prints list of image templates. ### Usage ```bash -pharo-launcher.sh template list [--help] [--templateCategory ] [--brief] [--rowMode] [--delimiter ] [--ston] +pharo-launcher template list [--help] [--templateCategory ] [--brief] [--rowMode] [--delimiter ] [--ston] ``` ### Options @@ -453,18 +464,19 @@ pharo-launcher.sh template list [--help] [--templateCategory ] +pharo-launcher vm delete [--help] [] ``` ### Parameters @@ -482,7 +494,7 @@ Prints information about VM: name, remote-site URL, last update status, etc. ### Usage ```bash -pharo-launcher.sh vm info [--help] [] +pharo-launcher vm info [--help] [] ``` ### Parameters @@ -499,7 +511,7 @@ Lists all available VMs, with status. ### Usage ```bash -pharo-launcher.sh vm list [--help] [--brief] [--rowMode] [--delimiter ] [--ston] [] +pharo-launcher vm list [--help] [--brief] [--rowMode] [--delimiter ] [--ston] [] ``` ### Parameters @@ -521,7 +533,7 @@ Updates VM executable, including dependent libs to latest version from remote si ### Usage ```bash -pharo-launcher.sh vm update [--help] [] +pharo-launcher vm update [--help] [] ``` ### Parameters diff --git a/docs/commands.md b/doc/commands.md similarity index 100% rename from docs/commands.md rename to doc/commands.md diff --git a/docs/contribute.md b/doc/contribute.md similarity index 100% rename from docs/contribute.md rename to doc/contribute.md diff --git a/docs/create-images.md b/doc/create-images.md similarity index 93% rename from docs/create-images.md rename to doc/create-images.md index 3c3a8d581..e34beb66b 100644 --- a/docs/create-images.md +++ b/doc/create-images.md @@ -27,7 +27,7 @@ In Pharo, an image is the object space containing ALL the objects of the system: Initially on a new computer the image list is empty. When creating a new image, you can see the image templates that are available on the web (there is also a local cache). Select the template image you want to use and download it. For instance you can download "Official distributions" -> "Pharo 8.0 (stable)" which is the latest stable image as of today. The launcher will download the image into a specific directory somewhere in your users home directory (you can configure where by clicking the Settings button). Each image gets its own folder. Use the "Show in folder" menu item if you want to open this location. -## Where are stored my images? +## Where are my images stored? Launcher files are considered as user documents and so, they are stored in the user document folder, i.e.: - *$HOME/Documents/Pharo* on OS X, @@ -37,7 +37,7 @@ Launcher files are considered as user documents and so, they are stored in the u In this folder, you will find your images and virtual machines needed to run images. The default location can be customized in Pharo Launcher settings. ## Image initialization script -When working with Pharo, you often need to load your project code and its dependencies. You could also want to execute some actions once to configure your image. This the purpose of the image initialization script: it is a Smalltalk script that will be **executed at the first launch of the image and will then be disabled**. +When working with Pharo, you often need to load your project code and its dependencies. You could also want to execute some actions once to configure your image. This is the purpose of the image initialization script: it is a Smalltalk script that will be **executed at the first launch of the image and will then be disabled**. When creating an image, you can select an already existing script or create a new one. For your conveniance, there is a script editor included in Pharo Launcher. Just click on the edit button ![New image command](images/edit-script-button.png){: style="width:30px"} at the right of the initialization script dropbox. ![Initialization script dropbox](images/initialization-script-dropbox.png){: style="width:250px"} ![Initialization script editor](images/init-script-editor.png) @@ -62,5 +62,5 @@ Metacello new load ``` -If you need to execute again the initialization script at image launch, select the image in the list of images and then click on the checkbox **Initialization script**. The script will be executed at next image launch and then disabled. -![Initialization script editor](images/image-description.png){: style="border:1px solid black;"} \ No newline at end of file +If you need to execute the initialization script again at image launch, select the image in the list of images and then click on the checkbox **Initialization script**. The script will be executed at next image launch and then disabled. +![Initialization script editor](images/image-description.png){: style="border:1px solid black;"} diff --git a/docs/images/about-command.png b/doc/images/about-command.png similarity index 100% rename from docs/images/about-command.png rename to doc/images/about-command.png diff --git a/docs/images/basic-launch-command.png b/doc/images/basic-launch-command.png similarity index 100% rename from docs/images/basic-launch-command.png rename to doc/images/basic-launch-command.png diff --git a/docs/images/delete-command.png b/doc/images/delete-command.png similarity index 100% rename from docs/images/delete-command.png rename to doc/images/delete-command.png diff --git a/docs/images/edit-script-button.png b/doc/images/edit-script-button.png similarity index 100% rename from docs/images/edit-script-button.png rename to doc/images/edit-script-button.png diff --git a/docs/images/global-commands.png b/doc/images/global-commands.png similarity index 100% rename from docs/images/global-commands.png rename to doc/images/global-commands.png diff --git a/docs/images/image-contextual-menu-commands.png b/doc/images/image-contextual-menu-commands.png similarity index 100% rename from docs/images/image-contextual-menu-commands.png rename to doc/images/image-contextual-menu-commands.png diff --git a/docs/images/image-creation-filled.png b/doc/images/image-creation-filled.png similarity index 100% rename from docs/images/image-creation-filled.png rename to doc/images/image-creation-filled.png diff --git a/docs/images/image-creation.png b/doc/images/image-creation.png similarity index 100% rename from docs/images/image-creation.png rename to doc/images/image-creation.png diff --git a/docs/images/image-description.png b/doc/images/image-description.png similarity index 100% rename from docs/images/image-description.png rename to doc/images/image-description.png diff --git a/docs/images/image-name-not-valid.png b/doc/images/image-name-not-valid.png similarity index 100% rename from docs/images/image-name-not-valid.png rename to doc/images/image-name-not-valid.png diff --git a/docs/images/import-command.png b/doc/images/import-command.png similarity index 100% rename from docs/images/import-command.png rename to doc/images/import-command.png diff --git a/docs/images/init-script-editor.png b/doc/images/init-script-editor.png similarity index 100% rename from docs/images/init-script-editor.png rename to doc/images/init-script-editor.png diff --git a/docs/images/initialization-script-dropbox.png b/doc/images/initialization-script-dropbox.png similarity index 100% rename from docs/images/initialization-script-dropbox.png rename to doc/images/initialization-script-dropbox.png diff --git a/docs/images/install-dmg.png b/doc/images/install-dmg.png similarity index 100% rename from docs/images/install-dmg.png rename to doc/images/install-dmg.png diff --git a/docs/images/launch-command.png b/doc/images/launch-command.png similarity index 100% rename from docs/images/launch-command.png rename to doc/images/launch-command.png diff --git a/docs/images/launch-configuration-editor.png b/doc/images/launch-configuration-editor.png similarity index 100% rename from docs/images/launch-configuration-editor.png rename to doc/images/launch-configuration-editor.png diff --git a/docs/images/launch-configuration-toolbar.png b/doc/images/launch-configuration-toolbar.png similarity index 100% rename from docs/images/launch-configuration-toolbar.png rename to doc/images/launch-configuration-toolbar.png diff --git a/docs/images/launch-from-disk-command.png b/doc/images/launch-from-disk-command.png similarity index 100% rename from docs/images/launch-from-disk-command.png rename to doc/images/launch-from-disk-command.png diff --git a/docs/images/new-command.png b/doc/images/new-command.png similarity index 100% rename from docs/images/new-command.png rename to doc/images/new-command.png diff --git a/docs/images/pharo-launcher-launch-linux.png b/doc/images/pharo-launcher-launch-linux.png similarity index 100% rename from docs/images/pharo-launcher-launch-linux.png rename to doc/images/pharo-launcher-launch-linux.png diff --git a/doc/images/pharo-launcher-main-window.png b/doc/images/pharo-launcher-main-window.png new file mode 100644 index 000000000..a77d7f00f Binary files /dev/null and b/doc/images/pharo-launcher-main-window.png differ diff --git a/docs/images/pharo-launcher-settings-browser.png b/doc/images/pharo-launcher-settings-browser.png similarity index 100% rename from docs/images/pharo-launcher-settings-browser.png rename to doc/images/pharo-launcher-settings-browser.png diff --git a/docs/images/pharo-launcher-unzip-linux.png b/doc/images/pharo-launcher-unzip-linux.png similarity index 100% rename from docs/images/pharo-launcher-unzip-linux.png rename to doc/images/pharo-launcher-unzip-linux.png diff --git a/docs/images/pharo-launcher.png b/doc/images/pharo-launcher.png similarity index 100% rename from docs/images/pharo-launcher.png rename to doc/images/pharo-launcher.png diff --git a/docs/images/quit-command.png b/doc/images/quit-command.png similarity index 100% rename from docs/images/quit-command.png rename to doc/images/quit-command.png diff --git a/docs/images/refresh-command.png b/doc/images/refresh-command.png similarity index 100% rename from docs/images/refresh-command.png rename to doc/images/refresh-command.png diff --git a/docs/images/settings-command.png b/doc/images/settings-command.png similarity index 100% rename from docs/images/settings-command.png rename to doc/images/settings-command.png diff --git a/docs/images/show-command.png b/doc/images/show-command.png similarity index 100% rename from docs/images/show-command.png rename to doc/images/show-command.png diff --git a/docs/images/taskbar.png b/doc/images/taskbar.png similarity index 100% rename from docs/images/taskbar.png rename to doc/images/taskbar.png diff --git a/docs/images/template-categories.png b/doc/images/template-categories.png similarity index 100% rename from docs/images/template-categories.png rename to doc/images/template-categories.png diff --git a/docs/images/template-commands.png b/doc/images/template-commands.png similarity index 100% rename from docs/images/template-commands.png rename to doc/images/template-commands.png diff --git a/docs/images/vm-command.png b/doc/images/vm-command.png similarity index 100% rename from docs/images/vm-command.png rename to doc/images/vm-command.png diff --git a/docs/images/vm-presenter-private.png b/doc/images/vm-presenter-private.png similarity index 100% rename from docs/images/vm-presenter-private.png rename to doc/images/vm-presenter-private.png diff --git a/docs/images/vm-presenter.png b/doc/images/vm-presenter.png similarity index 100% rename from docs/images/vm-presenter.png rename to doc/images/vm-presenter.png diff --git a/docs/images/vm-private-toggle-command.png b/doc/images/vm-private-toggle-command.png similarity index 100% rename from docs/images/vm-private-toggle-command.png rename to doc/images/vm-private-toggle-command.png diff --git a/docs/images/warning-osx-gatekeeper.png b/doc/images/warning-osx-gatekeeper.png similarity index 100% rename from docs/images/warning-osx-gatekeeper.png rename to doc/images/warning-osx-gatekeeper.png diff --git a/docs/images/warning-osx-not-appstore.png b/doc/images/warning-osx-not-appstore.png similarity index 100% rename from docs/images/warning-osx-not-appstore.png rename to doc/images/warning-osx-not-appstore.png diff --git a/docs/images/windows-installer-2-folder.png b/doc/images/windows-installer-2-folder.png similarity index 100% rename from docs/images/windows-installer-2-folder.png rename to doc/images/windows-installer-2-folder.png diff --git a/docs/images/windows-installer-3-finish.png b/doc/images/windows-installer-3-finish.png similarity index 100% rename from docs/images/windows-installer-3-finish.png rename to doc/images/windows-installer-3-finish.png diff --git a/docs/images/windows-installer.png b/doc/images/windows-installer.png similarity index 100% rename from docs/images/windows-installer.png rename to doc/images/windows-installer.png diff --git a/docs/images/windows-shorcut.png b/doc/images/windows-shorcut.png similarity index 100% rename from docs/images/windows-shorcut.png rename to doc/images/windows-shorcut.png diff --git a/docs/index.md b/doc/index.md similarity index 100% rename from docs/index.md rename to doc/index.md diff --git a/docs/installation.md b/doc/installation.md similarity index 100% rename from docs/installation.md rename to doc/installation.md diff --git a/docs/launch-configurations.md b/doc/launch-configurations.md similarity index 100% rename from docs/launch-configurations.md rename to doc/launch-configurations.md diff --git a/docs/manage-vms.md b/doc/manage-vms.md similarity index 100% rename from docs/manage-vms.md rename to doc/manage-vms.md diff --git a/docs/settings.md b/doc/settings.md similarity index 100% rename from docs/settings.md rename to doc/settings.md diff --git a/docs/templates.md b/doc/templates.md similarity index 100% rename from docs/templates.md rename to doc/templates.md diff --git a/linux/pharo-launcher-ui b/linux/pharo-launcher-ui index 3db3d9c16..3979a18f6 100755 --- a/linux/pharo-launcher-ui +++ b/linux/pharo-launcher-ui @@ -1,8 +1,8 @@ #!/usr/bin/env bash # path -DIR=`readlink -f $0` #resolve symlink -ROOT=`dirname "$DIR"` #obtain dir of the resolved path +DIR=$(readlink -f "$0") #resolve symlink +ROOT=$(dirname "$DIR") #obtain dir of the resolved path LINUX="$ROOT/pharo-vm" RESOURCES="$ROOT/shared" ICONS="$ROOT/icons" diff --git a/mac/Info.plist.template b/mac/Info.plist.template index 797840215..28b7617e7 100644 --- a/mac/Info.plist.template +++ b/mac/Info.plist.template @@ -29,7 +29,7 @@ PharoImageFile PharoLauncher.image PharoLogLevel - 4 + 1 CFBundleDocumentTypes diff --git a/mac/MainMenu.xib b/mac/MainMenu.xib deleted file mode 100644 index 130247a76..000000000 --- a/mac/MainMenu.xib +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mac/build-dmg.sh b/mac/build-dmg.sh index a2e9594c4..b1fee87f5 100755 --- a/mac/build-dmg.sh +++ b/mac/build-dmg.sh @@ -27,8 +27,8 @@ readonly DMG_FINAL="${VOL_NAME/ /_}.dmg" # final DMG name will be "Super readonly STAGING_DIR="./Install" # we copy all our stuff into this dir check_background_image_DPI_and_convert_it_if_not_72_by_72() { - local _BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'` - local _BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'` + local _BACKGROUND_IMAGE_DPI_H=$(sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+') + local _BACKGROUND_IMAGE_DPI_W=$(sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+') if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then echo "WARNING: The background image's DPI is not 72. This will result in distorted backgrounds on Mac OS X 10.7+." @@ -102,7 +102,7 @@ function sign_mac_app() { # See https://code-examples.net/en/q/1344e6a security set-key-partition-list -S apple-tool:,apple: -s -k ${keychain_password} "${keychain_name}" # debug - echo ${sign_identity} >> "id.txt" + echo "${sign_identity}" >> "id.txt" # Invoke codesign if [[ -d "${app_dir}/Contents/MacOS/Plugins" ]]; then # Pharo.app does not (yet) have its plugins in Resources dir rm -rf "${app_dir}/Contents/MacOS/Plugins/pkgconfig" # Should be fixed in VM build diff --git a/mkdocs.yml b/mkdocs.yml index 1f2fbc852..5dd05b2dd 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,7 @@ site_name: Pharo Launcher documentation repo_url: https://github.com/pharo-project/pharo-launcher/ -edit_uri: edit/dev/docs/ +docs_dir: doc +edit_uri: edit/dev/doc/ nav: - Home: index.md - installation.md diff --git a/pharo-launcher-main-window.png b/pharo-launcher-main-window.png deleted file mode 100644 index f4dc3298e..000000000 Binary files a/pharo-launcher-main-window.png and /dev/null differ diff --git a/script/pharo-launcher.bat b/scripts/pharo-launcher.bat similarity index 100% rename from script/pharo-launcher.bat rename to scripts/pharo-launcher.bat diff --git a/script/pharo-launcher.sh b/scripts/pharo-launcher.sh similarity index 90% rename from script/pharo-launcher.sh rename to scripts/pharo-launcher.sh index a97d35658..ceadc06e5 100755 --- a/script/pharo-launcher.sh +++ b/scripts/pharo-launcher.sh @@ -30,7 +30,7 @@ fi # RUN THE VM and pass along all arguments as is ================================ if [ "$OS" = "linux" ]; then - "$ROOT"/pharo-vm/pharo --headless "$ROOT"/shared/PharoLauncher.image clap launcher "$@" + "$ROOT"/pharo-vm/pharo --headless "$ROOT"/shared/PharoLauncher.image --no-default-preferences clap launcher "$@" elif [ "$OS" = "mac" ]; then - "$ROOT"/Pharo --headless "$ROOT"/../Resources/PharoLauncher.image clap launcher "$@" + "$ROOT"/Pharo --headless "$ROOT"/../Resources/PharoLauncher.image --no-default-preferences clap launcher "$@" fi diff --git a/sources.list b/sources.list index 85e995e5c..d0b40a64b 100644 --- a/sources.list +++ b/sources.list @@ -20,43 +20,48 @@ OrderedCollection [ #templates : [ PhLTemplateSource { #type : #URL, - #name : 'Pharo 11.0 - 64bit (development version, latest)', - #url : 'https://files.pharo.org/image/110/latest-64.zip' + #name : 'Pharo 12.0 - 64bit (development version, latest)', + #url : 'https://files.pharo.org/image/120/latest-64.zip' }, PhLTemplateSource { #type : #URL, - #name : 'Pharo 11.0 - 32bit (development version, latest)', - #url : 'https://files.pharo.org/image/110/latest-32.zip' - },(stable) + #name : 'Pharo 12.0 - 32bit (development version, latest)', + #url : 'https://files.pharo.org/image/120/latest-32.zip' + }, PhLTemplateSource { #type : #URL, - #name : 'Pharo 10.0 - 64bit (stable)', - #url : 'https://files.pharo.org/image/100/latest-64.zip' + #name : 'Pharo 11.0 - 64bit (stable)', + #url : 'https://files.pharo.org/image/110/latest-64.zip' }, PhLTemplateSource { #type : #URL, - #name : 'Pharo 10.0 - 32bit (stable)', - #url : 'https://files.pharo.org/image/100/latest-32.zip' + #name : 'Pharo 11.0 - 32bit (stable)', + #url : 'https://files.pharo.org/image/110/latest-32.zip' }, PhLTemplateSource { #type : #URL, - #name : 'Pharo 9.0 - 64bit (old stable)', - #url : 'https://files.pharo.org/image/90/stable-64.zip' + #name : 'Pharo 10.0 - 64bit (old stable)', + #url : 'https://files.pharo.org/image/100/latest-64.zip' }, PhLTemplateSource { #type : #URL, - #name : 'Pharo 9.0 - 32bit (old stable)', - #url : 'https://files.pharo.org/image/90/stable-32.zip' + #name : 'Pharo 10.0 - 32bit (old stable)', + #url : 'https://files.pharo.org/image/100/latest-32.zip' }, PhLTemplateSource { #type : #URL, - #name : 'Moose Suite 9.0 (development)', - #url : 'https://files.pharo.org/moose/Moose9-development.zip' + #name : 'Moose Suite 11 (development)', + #url : 'https://github.com/moosetechnology/Moose/releases/download/continuous/Moose11-development-Pharo64-11.zip' + }, + PhLTemplateSource { + #type : #URL, + #name : 'Moose Suite 10 (stable)', + #url : 'https://github.com/moosetechnology/Moose/releases/download/v10.x.x/Moose10-stable-Pharo64-10.zip' }, PhLTemplateSource { #type : #URL, - #name : 'Moose Suite 8.0 (stable)', - #url : 'https://files.pharo.org/moose/Moose8-stable.zip' + #name : 'Moose Suite 9.0 (old stable)', + #url : 'https://github.com/moosetechnology/Moose/releases/download/v9.x.x/Moose9-stable-Pharo64-10.zip' } ], #expanded : true @@ -65,6 +70,16 @@ OrderedCollection [ #type : #URLGroup, #name : 'Deprecated distributions', #templates : [ + PhLTemplateSource { + #type : #URL, + #name : 'Pharo 9.0 - 64bit', + #url : 'https://files.pharo.org/image/90/stable-64.zip' + }, + PhLTemplateSource { + #type : #URL, + #name : 'Pharo 9.0 - 32bit', + #url : 'https://files.pharo.org/image/90/stable-32.zip' + }, PhLTemplateSource { #type : #URL, #name : 'Pharo 8.0 - 64bit', @@ -117,53 +132,23 @@ OrderedCollection [ }, PhLTemplateSource { #type : #URL, - #name : 'Moose Suite 7.0 (old stable)', - #url : 'https://ci.inria.fr/moose/job/moose-7.0-64bit/lastSuccessfulBuild/artifact/moose-7.0-64bit.zip' - }, - PhLTemplateSource { - #type : #URL, - #name : 'Moose Suite 6.1', - #url : 'https://ci.inria.fr/moose/job/moose-6.1/lastSuccessfulBuild/artifact/moose-6.1.zip' - }, - PhLTemplateSource { - #type : #URL, - #name : 'Moose Suite 6.0', - #url : 'https://ci.inria.fr/moose/job/moose-6.0/lastSuccessfulBuild/artifact/moose-6.0.zip' - }, - PhLTemplateSource { - #type : #URL, - #name : 'Moose Suite 5.1', - #url : 'https://ci.inria.fr/moose/job/moose-5.1/lastSuccessfulBuild/artifact/moose-5.1.zip' - }, - PhLTemplateSource { - #type : #URL, - #name : 'Moose Suite 5.0', - #url : 'https://moosetechnology.org/res/download/moose_image_5_0.zip' - } + #name : 'Moose Suite 8.0 (old stable)', + #url : 'https://github.com/moosetechnology/Moose/releases/download/v8.x.x/Moose8-old-stable-Pharo64-8.0.zip' + } ] }, - PhLTemplateSource { - #type : #JenkinsServer, - #name : 'Pharo Contribution Jenkins', - #url : 'https://ci.inria.fr/pharo-contribution' - }, - PhLTemplateSource { - #type : #JenkinsServer, - #name : 'Moose Jenkins', - #url : 'https://ci.inria.fr/moose' - }, PhLTemplateSource { #type : #HttpListing, - #name : 'Pharo 10.0 (stable)', - #url : 'https://files.pharo.org/image/100/', - #filterPattern : 'href="(Pharo-?10-SNAPSHOT.build.[^"]*.zip)"' + #name : 'Pharo 11.0 (stable)', + #url : 'https://files.pharo.org/image/110/', + #filterPattern : 'href="(Pharo-?11-SNAPSHOT.build.[^"]*.zip)"' }, PhLTemplateSource { #type : #HttpListing, - #name : 'Pharo 11.0 (development version)', - #url : 'https://files.pharo.org/image/110/', - #filterPattern : 'href="(Pharo-?11-SNAPSHOT.build.[^"]*.zip)"' - }, + #name : 'Pharo 12.0 (development version)', + #url : 'https://files.pharo.org/image/120/', + #filterPattern : 'href="(Pharo-?12(.[0-9]+)?-SNAPSHOT.build.[^"]*.zip)"' + }, PhLTemplateSource { #type : #HttpListing, #name : 'Pharo IoT (PharoThings)', diff --git a/src/BaselineOfPharoLauncher/BaselineOfPharoLauncher.class.st b/src/BaselineOfPharoLauncher/BaselineOfPharoLauncher.class.st index 2f2de89d2..71618ba11 100644 --- a/src/BaselineOfPharoLauncher/BaselineOfPharoLauncher.class.st +++ b/src/BaselineOfPharoLauncher/BaselineOfPharoLauncher.class.st @@ -63,7 +63,7 @@ BaselineOfPharoLauncher >> clap: spec [ spec baseline: #Clap - with: [ spec repository: 'github://demarey/clap-st:refactoring/src' ] + with: [ spec repository: 'github://pharo-contributions/clap-st:master/src' ] ] { #category : #'external projects' } diff --git a/src/PharoLauncher-100Compatibility/String.extension.st b/src/PharoLauncher-100Compatibility/String.extension.st deleted file mode 100644 index e3031e624..000000000 --- a/src/PharoLauncher-100Compatibility/String.extension.st +++ /dev/null @@ -1,7 +0,0 @@ -Extension { #name : #String } - -{ #category : #'*PharoLauncher-100Compatibility' } -String >> asFileLocatorOrReference [ - - ^ FileLocator fromString: self ifNone: [ self asFileReference ] -] diff --git a/src/PharoLauncher-CLI-Tests/ConsoleListFormatterTest.class.st b/src/PharoLauncher-CLI-Tests/ConsoleListFormatterTest.class.st index e7f77920a..7ebec14bd 100644 --- a/src/PharoLauncher-CLI-Tests/ConsoleListFormatterTest.class.st +++ b/src/PharoLauncher-CLI-Tests/ConsoleListFormatterTest.class.st @@ -140,6 +140,28 @@ ConsoleListFormatterTest >> testPrintAttributeTable [ ] +{ #category : #tests } +ConsoleListFormatterTest >> testPrintAttributeTableWithDefaultValue [ + + |expectedString| + formatter attributeLabels: #('Value' 'Squared' 'Raised to 3'). + formatter attributeValueBlocks: { [:a |a asWords ]. [:a |a squared asWords ]. [:a |(a **3) asWords ] }. + formatter domainObjects: #(1 2 3) defaultValue: 2. + formatter printAttributeTable. + + expectedString := String streamContents: [:aStream | + aStream + nextPutAll: '# *Value*Squared*Raised to 3 '; newLine; + nextPutAll: '---*-----*-------*------------'; newLine; + nextPutAll: ' 1 *one *one *one '; newLine; + nextPutAll: '*2 *two *four *eight '; newLine; + nextPutAll: ' 3 *three*nine *twenty-seven'; newLine + ]. + + self assert: formatter outStream contents equals: expectedString. + +] + { #category : #tests } ConsoleListFormatterTest >> testPrintCellWidth [ diff --git a/src/PharoLauncher-CLI-Tests/PhLCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLCliCommandTest.class.st index e5e10db96..cb1d6ea44 100644 --- a/src/PharoLauncher-CLI-Tests/PhLCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLCliCommandTest.class.st @@ -73,19 +73,12 @@ PhLCliCommandTest >> testExecuteLauncherCommandToPrintHelp [ ] { #category : #tests } -PhLCliCommandTest >> testExecuteOSShellCommand [ - - "nothing is executed" - self assert: PhLCliCommand new executeOSShellCommand isEmptyOrNil. +PhLCliCommandTest >> testExecuteLauncherCommandToPrintVersion [ + |expectedPrintout| + expectedPrintout := PhLAboutCommand new launcherVersion. -] + self assertCommand: #('launcher' '--version') toPrintHelpWith: expectedPrintout. -{ #category : #tests } -PhLCliCommandTest >> testExecuteOSShellCommandWithArgs [ - |aCmd| - aCmd := PhLCliCommand new. - self deny: (aCmd executeOSShellCommandWithArgs: #('ls')) isEmptyOrNil. - self should: [aCmd executeOSShellCommandWithArgs: #('bleh')] raise: PhLProcessCommandError description: 'Invoking invalid OS shell command should end up with domain error exception: PHLProcessCommandError'. ] { #category : #tests } @@ -190,7 +183,7 @@ PhLCliCommandTest >> testPositionalWithValue [ "now test - when value is not present" aCommand := (cmdSpec activationWith: #('launcher' '--delimiter')) command. - self assert: (aCommand positional: #delimiter) isNil. + self assert: (aCommand positional: #delimiter) equals: aCommand implicitDelimiter. ] { #category : #printing } diff --git a/src/PharoLauncher-CLI-Tests/PhLCliTestClapContext.class.st b/src/PharoLauncher-CLI-Tests/PhLCliTestClapContext.class.st index fc0d07377..640005316 100644 --- a/src/PharoLauncher-CLI-Tests/PhLCliTestClapContext.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLCliTestClapContext.class.st @@ -24,7 +24,7 @@ PhLCliTestClapContext >> command [ PhLCliTestClapContext >> initialize [ super initialize. - launcherModel := PharoLauncherCLIModel new. + launcherModel := PharoLauncherCLIModel fromDefaultConfiguration. ] { #category : #accessing } diff --git a/src/PharoLauncher-CLI-Tests/PhLImageCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLImageCliCommandTest.class.st index 176809d74..ecb9110ea 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLImageCliCommandTest.class.st @@ -41,7 +41,7 @@ PhLImageCliCommandTest >> testExecuteLauncherImageCommandToPrintHelp [ PhLImageCliCommandTest >> testFindImageFromDiskShouldRaiseNotFound [ | memoryFileSystem command location | command := (PhLImageLaunchCliCommand asCliCommand activationWith: #('launch')) command. - command context: context. + command setContext: context. memoryFileSystem := FileSystem memory. DiskStore currentFileSystem: memoryFileSystem @@ -53,7 +53,7 @@ PhLImageCliCommandTest >> testFindImageFromDiskShouldRaiseNotFound [ PhLImageCliCommandTest >> testFindImageFromDiskShouldSucceed [ | memoryFileSystem command location | command := (PhLImageLaunchCliCommand asCliCommand activationWith: #('launch')) command. - command context: context. + command setContext: context. memoryFileSystem := FileSystem memory. DiskStore currentFileSystem: memoryFileSystem diff --git a/src/PharoLauncher-CLI-Tests/PhLImageCreateCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLImageCreateCliCommandTest.class.st index 410600e71..7f8e020a6 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageCreateCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLImageCreateCliCommandTest.class.st @@ -26,6 +26,14 @@ PhLImageCreateCliCommandTest >> addTemplateNamed: aName inCategory: aCategoryNam inCategory: aCategoryName ] +{ #category : #adding } +PhLImageCreateCliCommandTest >> addTemplateNamed: aName shortName: aShortName inCategory: aCategoryName [ + ^ self launcherModel templateRepository + createTemplateNamed: aName + shortName: aShortName + inCategory: aCategoryName +] + { #category : #instance } PhLImageCreateCliCommandTest >> defaultTemplateCategoryName [ ^ 'Official distributions' @@ -53,6 +61,61 @@ PhLImageCreateCliCommandTest >> testCreateImageShouldSucceed [ self assertSuccess. self assert: self imageRepository imagesName equals: #( 'myImage1' 'myImage3' 'myImage2' ) asSet. + self assert: (self imageRepository imageNamed: 'myimage3') isLaunched +] + +{ #category : #tests } +PhLImageCreateCliCommandTest >> testCreateImageWithDevFlagUsesDevImage [ + | template devTemplate | + self addTemplateCategoryNamed: self defaultTemplateCategoryName. + self addTemplateNamed: 'Pharo 9 64bit stable' inCategory: self defaultTemplateCategoryName. + devTemplate := self addTemplateNamed: 'Pharo 10 64bit (development version, latest)' inCategory: self defaultTemplateCategoryName. + context arguments: #('launcher' 'image' 'create' '--dev' 'myImage'). + + template := context command findTemplate. + + self assert: template equals: devTemplate +] + +{ #category : #tests } +PhLImageCreateCliCommandTest >> testCreateImageWithNoFlagUsesDefaultImage [ + | template stableTemplate | + self addTemplateCategoryNamed: self defaultTemplateCategoryName. + stableTemplate := self addTemplateNamed: 'Pharo 9 64bit stable' inCategory: self defaultTemplateCategoryName. + self addTemplateNamed: 'Pharo 10 64bit (development version)' inCategory: self defaultTemplateCategoryName. + context arguments: {'launcher' . 'image' . 'create' . 'myImage'}. + + template := context command findTemplate. + + self assert: template equals: stableTemplate +] + +{ #category : #tests } +PhLImageCreateCliCommandTest >> testCreateImageWithNoFlagUsesUserDefaultImageWhenSpecified [ + | template devTemplate | + + context pharoLauncherModel configuration: + (context pharoLauncherModel configuration + defaultTemplate: #dev; + yourself). + self addTemplateCategoryNamed: self defaultTemplateCategoryName. + self addTemplateNamed: 'Pharo 9 64bit stable' inCategory: self defaultTemplateCategoryName. + devTemplate := self addTemplateNamed: 'Pharo 10 64bit (development version, latest)' inCategory: self defaultTemplateCategoryName. + context arguments: {'launcher' . 'image' . 'create' . 'myImage'}. + + template := context command findTemplate. + + self assert: template equals: devTemplate +] + +{ #category : #tests } +PhLImageCreateCliCommandTest >> testCreateImageWithNoLaunchFlagShouldNotLaunchImage [ + self addLocalTemplateNamed: 'fakeTemplate'. + + self runCommand: {'launcher' . 'image' . 'create' . 'myImage' . '--no-launch' . '--templateName'. 'fakeTemplate' . '--templateCategory' . self templateRepository localTemplatesGroupName}. + + self assertSuccess. + self deny: (self imageRepository imageNamed: 'myimage') isLaunched ] { #category : #tests } @@ -121,3 +184,34 @@ PhLImageCreateCliCommandTest >> testCreateImageWrongCategoryNameShouldRaiseError self assert: (self errorString includesSubstring: 'wrong category name not found'). ] + +{ #category : #tests } +PhLImageCreateCliCommandTest >> testTemplateCanBeFoundByShortName [ + + | createdTemplate foundTemplate | + + self addTemplateCategoryNamed: self defaultTemplateCategoryName. + createdTemplate := self addTemplateNamed: 'fakeTemplate' shortName: 'foo' inCategory: self defaultTemplateCategoryName. + context arguments: {'launcher' . 'image' . 'create' . 'myImage3' . '--templateName'. 'foo' }. + context match. + + foundTemplate := context command findUserTemplate. + + self assert: foundTemplate equals: createdTemplate +] + +{ #category : #tests } +PhLImageCreateCliCommandTest >> testTemplateIsFirstSearchByName [ + + | createdTemplate foundTemplate | + + self addTemplateCategoryNamed: self defaultTemplateCategoryName. + createdTemplate := self addTemplateNamed: 'fakeTemplate' shortName: 'foo' inCategory: self defaultTemplateCategoryName. + self addTemplateNamed: 'foo' inCategory: self defaultTemplateCategoryName. + context arguments: {'launcher' . 'image' . 'create' . 'myImage3' . '--templateName'. 'fakeTemplate' }. + context match. + + foundTemplate := context command findUserTemplate. + + self assert: foundTemplate equals: createdTemplate +] diff --git a/src/PharoLauncher-CLI-Tests/PhLImageCreateFromPullRequestCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLImageCreateFromPullRequestCliCommandTest.class.st index d5156b51a..7520e9a36 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageCreateFromPullRequestCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLImageCreateFromPullRequestCliCommandTest.class.st @@ -11,7 +11,9 @@ PhLImageCreateFromPullRequestCliCommandTest >> testExecuteFromPR [ command := (context arguments: #('launcher' 'image' 'create' 'fromPR' '9588')) command. command imageFinderClass: PhLImageFinderStub. + command execute. + self assert: self errorString isEmpty. self assert: (self outputString includesSubstring: 'PR-9588'). diff --git a/src/PharoLauncher-CLI-Tests/PhLImageCreateFromRemoteRepoCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLImageCreateFromRemoteRepoCliCommandTest.class.st index f8d1edbf9..c84781100 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageCreateFromRemoteRepoCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLImageCreateFromRemoteRepoCliCommandTest.class.st @@ -75,14 +75,21 @@ PhLImageCreateFromRemoteRepoCliCommandTest >> testValidCreateFromRemoteRepoWithA { #category : #tests } PhLImageCreateFromRemoteRepoCliCommandTest >> testValidateRepoFullName [ - | commandSpec validRepoNames | + | commandSpec validRepoNames invalidRepoName createCommand | commandSpec := PhLImageCreateFromRemoteRepoCliCommand asCliCommand. - validRepoNames := #('owner/project' 'owner/project:branch' 'owner/some-project:feature/branch-name'). + validRepoNames := #('owner/project' 'owner/project:branch' 'owner/some-project:feature/branch-name' 'owner/project:v1' 'owner/project:v1.1' 'owner/project:v1.1a' 'owner/project:V1.1.1a' 'owner/project:1.0-RC-somecomment'). validRepoNames do: [:repoName | - |createCommand| - createCommand := (commandSpec activationWith: { 'fromRepo'. repoName. } asArray) command. - createCommand validateRepoFullName - ] + createCommand := (commandSpec activationWith: { 'fromRepo'. repoName }) command. + self + assert: createCommand isValidRepoFullName + description: 'Valid repository name not validated: ', repoName. + ]. + + invalidRepoName := 'owner/project:'. + createCommand := (commandSpec activationWith: { 'fromRepo'. invalidRepoName }) command. + self + deny: createCommand isValidRepoFullName + description: 'Invalid repository name validated: ', invalidRepoName. ] diff --git a/src/PharoLauncher-CLI-Tests/PhLImageListCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLImageListCliCommandTest.class.st index e19b3ace2..cac5ab3fb 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageListCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLImageListCliCommandTest.class.st @@ -39,8 +39,8 @@ PhLImageListCliCommandTest >> testListImageShouldSucceed [ self runCommand: #('launcher' 'image' 'list' '--brief' '--delimiter' '+'). self assertSuccess. - self assert: (self outputString includesSubstring:'1 +myImage1'). - self assert: (self outputString includesSubstring:'2 +myImage2'). + self assert: (self outputString includesSubstring:' +myImage1'). + self assert: (self outputString includesSubstring:' +myImage2'). ] { #category : #tests } @@ -53,19 +53,20 @@ PhLImageListCliCommandTest >> testListImageShouldSucceedOutputInSTON [ self assertSuccess. images := STON fromString: self outputString. - self assert: images size equals: 2. - self assert: images first name equals: 'myImage1'. + self + assertCollection: (images collect: #name) + hasSameElements: #('myImage1' 'myImage2'). ] { #category : #tests } -PhLImageListCliCommandTest >> testListImageWithImageNameShouldSucceed [ +PhLImageListCliCommandTest >> testListImageWithImageNameFilterShouldSucceed [ self addImageNamed: 'myImage1'. self addImageNamed: 'myImage2'. self addImageNamed: 'shouldNotBeListed'. self addImageNamed: 'myImage3'. - self runCommand: #('launcher' 'image' 'list' '--name' 'myImage'). + self runCommand: #('launcher' 'image' 'list' '--nameFilter' 'myImage'). self assertSuccess. self assert: (self outputString includesSubstring:'myImage1'). diff --git a/src/PharoLauncher-CLI-Tests/PhLProcessCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLProcessCliCommandTest.class.st new file mode 100644 index 000000000..0b31fbab8 --- /dev/null +++ b/src/PharoLauncher-CLI-Tests/PhLProcessCliCommandTest.class.st @@ -0,0 +1,27 @@ +Class { + #name : #PhLProcessCliCommandTest, + #superclass : #PhLCliCommandTest, + #category : #'PharoLauncher-CLI-Tests' +} + +{ #category : #tests } +PhLProcessCliCommandTest >> testExecuteOSShellCommand [ + + "nothing is executed" + self assert: PhLProcessCliCommand new executeOSShellCommand isEmptyOrNil. + +] + +{ #category : #tests } +PhLProcessCliCommandTest >> testExecuteOSShellCommandWithArgs [ + + | aCmd | + aCmd := PhLProcessCliCommand new. + + self deny: + (aCmd executeOSShellCommandWithArgs: #( 'ls' )) isEmptyOrNil. + self + should: [ aCmd executeOSShellCommandWithArgs: #( 'non-existing-command' ) ] + raise: PhLProcessCommandError + description: 'Invoking invalid OS shell command should end up with domain error exception: PHLProcessCommandError' +] diff --git a/src/PharoLauncher-CLI-Tests/PhLImageKillCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLProcessKillCliCommandTest.class.st similarity index 57% rename from src/PharoLauncher-CLI-Tests/PhLImageKillCliCommandTest.class.st rename to src/PharoLauncher-CLI-Tests/PhLProcessKillCliCommandTest.class.st index 7ed9e08a4..3b917af2d 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageKillCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLProcessKillCliCommandTest.class.st @@ -2,68 +2,71 @@ A PhLImageKillCliCommandTest is a test class for testing the behavior of PhLImageKillCliCommand " Class { - #name : #PhLImageKillCliCommandTest, - #superclass : #PhLImageCliCommandTest, + #name : #PhLProcessKillCliCommandTest, + #superclass : #PhLProcessCliCommandTest, #category : #'PharoLauncher-CLI-Tests' } { #category : #tests } -PhLImageKillCliCommandTest >> testHasAllFlag [ +PhLProcessKillCliCommandTest >> testHasAllFlag [ | killCliCommand | - killCliCommand := (PhLImageKillCliCommand asCliCommand activationWith: #('kill' '--all')) command. + killCliCommand := (PhLProcessKillCliCommand asCliCommand activationWith: #('kill' '--all')) command. self assert: killCliCommand hasAllFlag. - killCliCommand := (PhLImageKillCliCommand asCliCommand activationWith: #('kill' 'someImageName')) command. + killCliCommand := (PhLProcessKillCliCommand asCliCommand activationWith: #('kill' 'someImageName')) command. self deny: killCliCommand hasAllFlag. ] { #category : #tests } -PhLImageKillCliCommandTest >> testKillArgString [ +PhLProcessKillCliCommandTest >> testKillArgString [ | killCliCommand aResult | - killCliCommand := (PhLImageKillCliCommand asCliCommand activationWith: #('kill' 'someImage.image')) command. + killCliCommand := (PhLProcessKillCliCommand asCliCommand activationWith: #('kill' 'someImage.image')) command. aResult := killCliCommand killArgString. "test if command includes grep of image name" self assert: (aResult includesSubstring: 'grep someImage.image'). - "test whether current PID of vm is filtered from list" - self assert: (aResult includesSubstring: ('grep -v ', (killCliCommand currentVMPid asString))). - + self assert: (aResult includesSubstring: ('grep -v ', (killCliCommand currentVMPid asString))). "avoid doubling pipes in cascading" self deny: (aResult includesSubstring: '||'). +] + +{ #category : #tests } +PhLProcessKillCliCommandTest >> testKillArgStringWithAllFlag [ + + | killCliCommand aResult | - "test same method with --all argument present" - killCliCommand := (PhLImageKillCliCommand asCliCommand activationWith: #('kill' '--all')) command. + killCliCommand := (PhLProcessKillCliCommand asCliCommand activationWith: #('kill' '--all')) command. aResult := killCliCommand killArgString. "grep of image name shound not be included anymore" self deny: (aResult includesSubstring: 'grep someImage.image'). - "test whether current PID of vm is filtered from list" self assert: (aResult includesSubstring: ('grep -v ', (killCliCommand currentVMPid asString))). ] { #category : #tests } -PhLImageKillCliCommandTest >> testMissingImageName [ - self runCommand: #('launcher' 'image' 'kill'). +PhLProcessKillCliCommandTest >> testMissingImageName [ + self runCommand: #('launcher' 'process' 'kill'). + self assertFailure. self assert: ( self errorString includesSubstring: 'specify the local image name to kill it process') ] { #category : #tests } -PhLImageKillCliCommandTest >> testOsShellArgArray [ +PhLProcessKillCliCommandTest >> testOsShellArgArray [ | killCliCommand result| - - killCliCommand := (PhLImageKillCliCommand asCliCommand activationWith: #('kill' 'someImageName')) command. + killCliCommand := (PhLProcessKillCliCommand asCliCommand activationWith: #('kill' 'someImageName')) command. + result := killCliCommand osShellArgArray. self assert: (result first includesSubstring: 'kill'). diff --git a/src/PharoLauncher-CLI-Tests/PhLProcessListCliCommand.extension.st b/src/PharoLauncher-CLI-Tests/PhLProcessListCliCommand.extension.st new file mode 100644 index 000000000..fdd465774 --- /dev/null +++ b/src/PharoLauncher-CLI-Tests/PhLProcessListCliCommand.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #PhLProcessListCliCommand } + +{ #category : #'*PharoLauncher-CLI-Tests' } +PhLProcessListCliCommand >> shellOutput: aString [ + + shellOutput := aString +] diff --git a/src/PharoLauncher-CLI-Tests/PhLImageProcessListCliCommandTest.class.st b/src/PharoLauncher-CLI-Tests/PhLProcessListCliCommandTest.class.st similarity index 74% rename from src/PharoLauncher-CLI-Tests/PhLImageProcessListCliCommandTest.class.st rename to src/PharoLauncher-CLI-Tests/PhLProcessListCliCommandTest.class.st index ba8976c90..aab2b6821 100644 --- a/src/PharoLauncher-CLI-Tests/PhLImageProcessListCliCommandTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PhLProcessListCliCommandTest.class.st @@ -2,15 +2,15 @@ A PhLImageProcessListCliCommandTest is a test class for testing the behavior of PhLImageProcessListCliCommand " Class { - #name : #PhLImageProcessListCliCommandTest, - #superclass : #PhLImageCliCommandTest, + #name : #PhLProcessListCliCommandTest, + #superclass : #PhLProcessCliCommandTest, #category : #'PharoLauncher-CLI-Tests' } { #category : #tests } -PhLImageProcessListCliCommandTest >> testExecute [ +PhLProcessListCliCommandTest >> testExecute [ - self runCommand: #('launcher' 'image' 'processList'). + self runCommand: #('launcher' 'process' 'list'). self assertSuccess. @@ -19,11 +19,11 @@ PhLImageProcessListCliCommandTest >> testExecute [ ] { #category : #tests } -PhLImageProcessListCliCommandTest >> testImageProcesListFrom [ +PhLProcessListCliCommandTest >> testImageProcesListFrom [ - |processListCmd aString resultArray| - processListCmd := PhLImageProcessListCliCommand new. - aString := String streamContents: [: aStream | + | processListCmd resultArray | + processListCmd := PhLProcessListCliCommand new. + processListCmd shellOutput: (String streamContents: [: aStream | aStream nextPutAll: '933 /tmp/PhLLaunchImageTest.61d1f200-02cc-0d00-88d2-05d60e98deae/110-x64/pharo /tmp/Yann-Gaël Bérès.61d1f200-02cc-0d00-88d2-05d60e98deae/PharoLauncher.image'; nextPutAll: OSPlatform current lineEnding; @@ -35,23 +35,24 @@ PhLImageProcessListCliCommandTest >> testImageProcesListFrom [ nextPutAll: OSPlatform current lineEnding; nextPutAll: '2304 /home/runner/Pharo/vms/100-x64/lib/pharo --headless /home/runner/Pharo/images/PhLTestImage/PhLTestImage.image --no-quit '; nextPutAll: OSPlatform current lineEnding; - nextPutAll: '57499 /Users/dbajger/Documents/Pharo/vms/110-x64/Pharo.app/Contents/MacOS/Pharo /Users/dbajger/Documents/Pharo/images/P11-launcher-dev/P11-launcher-dev.image' - ]. + nextPutAll: '57499 /Users/dbajger/Documents/Pharo/vms/110-x64/Pharo.app/Contents/MacOS/Pharo /Users/dbajger/Documents/Pharo/images/P11-launcher-dev/P11-launcher-dev.image' ]). + "each of string lines above represents information about one Pharo process, so there should be 6 processes (PhLImageProcess instances) determined from these lines" - resultArray := processListCmd imageProcesListFrom: aString. + resultArray := processListCmd imageProcesList. + self assert: resultArray size equals: 6. ] { #category : #tests } -PhLImageProcessListCliCommandTest >> testOsShellArgArray [ +PhLProcessListCliCommandTest >> testOsShellArgArray [ - |processListCmd argArray| - processListCmd := PhLImageProcessListCliCommand new. + | processListCmd argArray | + processListCmd := PhLProcessListCliCommand new. argArray := processListCmd osShellArgArray. - + "test whether current PID of vm is filtered from list" - + self assert: (argArray first includesSubstring: 'pgrep'). - self assert: (argArray first includesSubstring: ('grep -v ', (processListCmd currentVMPid asString))). + self assert: (argArray first includesSubstring: 'grep -v ' , processListCmd currentVMPid asString) ] diff --git a/src/PharoLauncher-CLI-Tests/PharoLauncherCLIConfigurationTest.class.st b/src/PharoLauncher-CLI-Tests/PharoLauncherCLIConfigurationTest.class.st index ee50a47ad..7ae16a21d 100644 --- a/src/PharoLauncher-CLI-Tests/PharoLauncherCLIConfigurationTest.class.st +++ b/src/PharoLauncher-CLI-Tests/PharoLauncherCLIConfigurationTest.class.st @@ -3,7 +3,8 @@ Class { #superclass : #TestCase, #instVars : [ 'root', - 'errorStream' + 'errorStream', + 'outStream' ], #category : #'PharoLauncher-CLI-Tests' } @@ -22,8 +23,11 @@ PharoLauncherCLIConfigurationTest >> createPreferencesFileWith: aConfiguration [ PharoLauncherCLIConfigurationTest >> setUp [ super setUp. root := FileSystem memory root. + outStream := WriteStream on: (String new). errorStream := WriteStream on: (String new). - PhLNotificationCenter default errorStream: errorStream + PhLNotificationCenter default + errorStream: errorStream; + outStream: outStream. ] @@ -74,7 +78,7 @@ PharoLauncherCLIConfigurationTest >> testGetConfigurationWhenConfigurationFileAb config := PharoLauncherCLIConfiguration configurationFromFile: (root / 'launcherSettings.ston') asFileReference . self assert: (config isKindOf: PharoLauncherCLIConfiguration). - self assert: ( PhLNotificationCenter default errorStream contents includesSubstring: 'Config' ) + self assert: (PhLNotificationCenter default outStream contents includesSubstring: 'Config') ] @@ -104,16 +108,16 @@ PharoLauncherCLIConfigurationTest >> testGetConfigurationWhenInvalidConfiguratio ] { #category : #tests } -PharoLauncherCLIConfigurationTest >> testProcessWithExplicitWorkingDirectory [ - | dir config configurator | - dir := root / 'foo' / 'bar'. - config := PhLLaunchConfiguration new - workingDirectory: dir. - configurator := PhLLaunchImageProcessConfigurator new - launchConfiguration: config; - yourself. +PharoLauncherCLIConfigurationTest >> testGetStableTemplateWhenGivingWrongDefaultTemplateValue [ + + | config deserializeConfig | + config := PharoLauncherCLIConfiguration new. + self assert: config defaultTemplate equals: #stable. - self assert: configurator workingDirectory equals: dir + config defaultTemplate: #foo. + deserializeConfig := STON fromString: (STON toString: config). + self assert: deserializeConfig defaultTemplate equals: #stable. + ] { #category : #tests } diff --git a/src/PharoLauncher-CLI/ClapContext.extension.st b/src/PharoLauncher-CLI/ClapContext.extension.st index 32db3c6c8..75cd82f28 100644 --- a/src/PharoLauncher-CLI/ClapContext.extension.st +++ b/src/PharoLauncher-CLI/ClapContext.extension.st @@ -13,5 +13,5 @@ ClapContext >> initializeLauncherNotificationCenter [ { #category : #'*PharoLauncher-CLI' } ClapContext >> pharoLauncherModel [ - ^ PharoLauncherCLIModel new + ^ PharoLauncherCLIModel fromDefaultConfiguration ] diff --git a/src/PharoLauncher-CLI/ConsoleListFormatter.class.st b/src/PharoLauncher-CLI/ConsoleListFormatter.class.st index 72feb6a99..ddbee4dbe 100644 --- a/src/PharoLauncher-CLI/ConsoleListFormatter.class.st +++ b/src/PharoLauncher-CLI/ConsoleListFormatter.class.st @@ -33,7 +33,8 @@ Class { 'outStream', 'outputAsSton', 'printSequence', - 'rowMode' + 'rowMode', + 'defaultValue' ], #category : #'PharoLauncher-CLI-Utility' } @@ -121,7 +122,15 @@ ConsoleListFormatter >> domainObjects [ { #category : #'accessing - public' } ConsoleListFormatter >> domainObjects: anObjects [ - domainObjects := anObjects + domainObjects := anObjects. + defaultValue := nil. +] + +{ #category : #'accessing - public' } +ConsoleListFormatter >> domainObjects: someObjects defaultValue: anObject [ + + domainObjects := someObjects. + defaultValue := anObject. ] { #category : #private } @@ -143,6 +152,24 @@ ConsoleListFormatter >> getMaxPrintStringWidthFor: someObjects printBlock: print max ] +{ #category : #testing } +ConsoleListFormatter >> hasDefaultValue [ + + ^ defaultValue notNil +] + +{ #category : #private } +ConsoleListFormatter >> indexColumnDefaultSize [ + ^ 2 +] + +{ #category : #private } +ConsoleListFormatter >> indexColumnSize [ + ^ self hasDefaultValue + ifTrue: [ self indexColumnDefaultSize + 1 ] + ifFalse: [ self indexColumnDefaultSize ] +] + { #category : #'accessing - command' } ConsoleListFormatter >> outStream [ @@ -168,37 +195,38 @@ ConsoleListFormatter >> outputAsSton: aBoolean [ ] { #category : #private } -ConsoleListFormatter >> printAttributeHeaders: labels by: colWidths [ +ConsoleListFormatter >> printAttributeHeaders: labels by: columnWidths [ "print header labels and header line" "print sequence nr. eventually" self printSequence ifTrue: [ - self printCell: '#' width: 2. + self printCell: '#' width: self indexColumnSize. self printDelimiter ]. - self printRowValues: labels by: colWidths. - self printHeaderLinesBy: colWidths. + self printRowValues: labels by: columnWidths. + self printHeaderLinesBy: columnWidths. ] { #category : #private } -ConsoleListFormatter >> printAttributeRows: someObjects by: colWidths [ +ConsoleListFormatter >> printAttributeRows: someObjects by: columnWidths [ someObjects withIndexDo: [:listedObject :idx| - self printCell: idx asString width: 2. + self hasDefaultValue ifTrue: [ self printDefaultValueMark: listedObject ]. + self printCell: idx asString width: self indexColumnDefaultSize. self printDelimiter. - self printRowValues: (self attributeValuesFrom: listedObject) by: colWidths + self printRowValues: (self attributeValuesFrom: listedObject) by: columnWidths ] ] { #category : #private } ConsoleListFormatter >> printAttributeTable [ - |colWidths | - colWidths := self getColumnWidthsFrom: self domainObjects. - "no header if brief print is enabled" - self briefPrint ifFalse: [self printAttributeHeaders: self attributeLabels by: colWidths]. - self printAttributeRows: self domainObjects by: colWidths. - + | columnWidths | + columnWidths := self getColumnWidthsFrom: self domainObjects. + "no header if brief print is enabled" + self briefPrint + ifFalse: [ self printAttributeHeaders: self attributeLabels by: columnWidths ]. + self printAttributeRows: self domainObjects by: columnWidths ] { #category : #private } @@ -212,6 +240,14 @@ ConsoleListFormatter >> printCell: aString width: widthSize [ ] +{ #category : #private } +ConsoleListFormatter >> printDefaultValueMark: listedObject [ + + self outStream nextPut: (listedObject == defaultValue + ifTrue: [ $* ] + ifFalse: [ Character space ]) +] + { #category : #private } ConsoleListFormatter >> printDelimiter [ @@ -219,15 +255,15 @@ ConsoleListFormatter >> printDelimiter [ ] { #category : #private } -ConsoleListFormatter >> printHeaderLinesBy: colWidths [ +ConsoleListFormatter >> printHeaderLinesBy: columnWidths [ "print header line" self printSequence ifTrue: [ - self printLineSized: 2. + self printLineSized: self indexColumnSize. self printDelimiter. ]. - colWidths withIndexDo: [:aWidth :idx| self printLineSized: aWidth. - idx = colWidths size ifFalse: [ self printDelimiter]]. + columnWidths withIndexDo: [:aWidth :idx| self printLineSized: aWidth. + idx = columnWidths size ifFalse: [ self printDelimiter]]. self outStream newLine. ] @@ -277,12 +313,11 @@ ConsoleListFormatter >> printOneAttrPerRow [ ] { #category : #private } -ConsoleListFormatter >> printRowValues: aStringColl by: colWidths [ +ConsoleListFormatter >> printRowValues: values by: columnWidths [ - "print string values by column widths" - aStringColl withIndexDo: [:aLabel :idx | - self printCell: aLabel width: (colWidths at: idx). - idx = aStringColl size ifFalse: [ self printDelimiter]. + values withIndexDo: [:aLabel :idx | + self printCell: aLabel width: (columnWidths at: idx). + idx = values size ifFalse: [ self printDelimiter]. ]. self outStream newLine. ] diff --git a/src/PharoLauncher-CLI/MacOSPlatform.extension.st b/src/PharoLauncher-CLI/MacOSPlatform.extension.st index 9c1a6e558..d80de68d6 100644 --- a/src/PharoLauncher-CLI/MacOSPlatform.extension.st +++ b/src/PharoLauncher-CLI/MacOSPlatform.extension.st @@ -10,5 +10,5 @@ MacOSPlatform >> processListArgs [ { #category : #'*PharoLauncher-CLI' } MacOSPlatform >> processStartDateArgs [ - ^ 'xargs -I{} date -jf "%a %b %e %H:%M:%S %Y" "{}" ''+%Y-%m-%d %H:%M:%S''' + ^ 'LANG=C xargs -I{} date -jf "%a %b %d %H:%M:%S %Y" "{}" ''+%Y-%m-%d %H:%M:%S''' ] diff --git a/src/PharoLauncher-CLI/PhLAbstractTemplate.extension.st b/src/PharoLauncher-CLI/PhLAbstractTemplate.extension.st index ba807e22c..2972c1e5d 100644 --- a/src/PharoLauncher-CLI/PhLAbstractTemplate.extension.st +++ b/src/PharoLauncher-CLI/PhLAbstractTemplate.extension.st @@ -4,7 +4,7 @@ Extension { #name : #PhLAbstractTemplate } PhLAbstractTemplate class >> listPrintAttributeBlocks [ ^ {[:template | template name]. - [:template | template url]} + [:template | template url asString]} ] { #category : #'*PharoLauncher-CLI' } diff --git a/src/PharoLauncher-CLI/PhLCliCommand.class.st b/src/PharoLauncher-CLI/PhLCliCommand.class.st index 3b5a8b122..1d30a448a 100644 --- a/src/PharoLauncher-CLI/PhLCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLCliCommand.class.st @@ -49,9 +49,10 @@ PhLCliCommand class >> addDelimiterFlagTo: aCommandSpec [ { #category : #'command line - arguments' } PhLCliCommand class >> addLauncherFlagsTo: aCommandSpec [ - "No positionals on root spec class - use on subclasses e.g.: aCommandSpec addFlag: #someFlag + "Only version flag to launcher commmand. + Use on subclasses e.g.: aCommandSpec addFlag: #someFlag " + self addVersionFlagTo: aCommandSpec ] { #category : #'command line - arguments' } @@ -94,6 +95,14 @@ PhLCliCommand class >> addStonFlagTo: aCommandSpec [ description: 'Prints information in STON format.' ] +{ #category : #'command line - arguments' } +PhLCliCommand class >> addVersionFlagTo: aCommandSpec [ + + aCommandSpec + addFlag: #version + description: 'Prints version of the Pharo Launcher.' +] + { #category : #'command line - converting' } PhLCliCommand class >> asCliCommand [ ^ self newLauncherCommandSpec: #launcher @@ -157,6 +166,7 @@ PhLCliCommand class >> raiseMissingDelimiter [ PhLCliCommand >> basicExecute [ "should be implemented on all sub-classed commands that have business logic, otherwise will print just help" + self hasVersionFlag ifTrue: [ ^ self printVersion ]. self printHelp ] @@ -178,10 +188,12 @@ PhLCliCommand >> cliFormatter: aFormatter [ cliFormatter := aFormatter ] -{ #category : #accessing } -PhLCliCommand >> currentVMPid [ - - ^ OSSVMProcess vmProcess pid +{ #category : #default } +PhLCliCommand >> defaultTemplate [ + + ^ self pharoLauncherModel defaultTemplate = #dev + ifTrue: [ self latestDevTemplate ] + ifFalse: [ self latestStableTemplate ] ] { #category : #default } @@ -220,21 +232,6 @@ PhLCliCommand >> execute [ ] ] -{ #category : #'command execution' } -PhLCliCommand >> executeOSShellCommand [ - - ^ self executeOSShellCommandWithArgs: self osShellArgArray -] - -{ #category : #'command execution' } -PhLCliCommand >> executeOSShellCommandWithArgs: argArray [ - -^ PhLProcessWrapper new - shellCommand; - addAllArguments: argArray; - runAndWaitWithStdOutput -] - { #category : #private } PhLCliCommand >> filterPrintAttributesFrom: attrCollection [ @@ -248,6 +245,12 @@ PhLCliCommand >> findLatestPharoStableVersionIn: aTemplateGroup [ ^ aTemplateGroup latestStableTemplate ] +{ #category : #'accessing arguments' } +PhLCliCommand >> hasVersionFlag [ + + ^ self hasFlag: #version +] + { #category : #accessing } PhLCliCommand >> imageRepository [ ^ self pharoLauncherModel imageRepository @@ -266,6 +269,30 @@ PhLCliCommand >> initialize [ self cliFormatter: (ConsoleListFormatter on: self). ] +{ #category : #default } +PhLCliCommand >> isDefaultTemplateCategory: aCategory ifTrue: trueBlock ifFalse: falseBlock [ + + [ aCategory == self defaultTemplateCategory + ifTrue: trueBlock + ifFalse: falseBlock ] + on: NotFound "default template category not found" + do: falseBlock +] + +{ #category : #default } +PhLCliCommand >> latestDevTemplate [ + + "from default 'Official distributions' obtain latest development template" + ^ self defaultTemplateCategory latestDevelopmentTemplate +] + +{ #category : #default } +PhLCliCommand >> latestStableTemplate [ + + "from default 'Official distributions' obtain latest Pharo version stable template" + ^ self defaultTemplateCategory latestStableTemplate +] + { #category : #printing } PhLCliCommand >> list: domainObjects [ @@ -274,6 +301,13 @@ PhLCliCommand >> list: domainObjects [ printList. ] +{ #category : #printing } +PhLCliCommand >> list: domainObjects default: defaultValue [ + self cliFormatter + domainObjects: domainObjects defaultValue: defaultValue; + printList. +] + { #category : #private } PhLCliCommand >> listPrintAttributeBlocks [ @@ -345,6 +379,12 @@ PhLCliCommand >> printSequence [ ^ true ] +{ #category : #printing } +PhLCliCommand >> printVersion [ + + self logInfoMessage: PhLAboutCommand new launcherVersion +] + { #category : #'accessing arguments' } PhLCliCommand >> rowMode [ diff --git a/src/PharoLauncher-CLI/PhLImageCliCommand.class.st b/src/PharoLauncher-CLI/PhLImageCliCommand.class.st index 9c336341a..cff773ab6 100644 --- a/src/PharoLauncher-CLI/PhLImageCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLImageCliCommand.class.st @@ -39,12 +39,6 @@ PhLImageCliCommand class >> raiseNewImageNotFound [ ^ NotFound signal: 'An argument is missing. Please specify the name for the new Pharo image.' ] -{ #category : #private } -PhLImageCliCommand >> checkOS [ - - OSPlatform current isWindows ifTrue: [ self raiseOperationNotSupported ] -] - { #category : #'find-select' } PhLImageCliCommand >> findByPath: anImageName [ (anImageName asFileReference exists @@ -81,12 +75,6 @@ PhLImageCliCommand >> modelClass [ ^ self class environment at: #PhLImage ] -{ #category : #'error signalling' } -PhLImageCliCommand >> raiseOperationNotSupported [ - - ^ PhLProcessCommandError signal: 'Launcher command currently not supported on OS Windows.' -] - { #category : #accessing } PhLImageCliCommand >> targetName [ diff --git a/src/PharoLauncher-CLI/PhLImageCreateCliCommand.class.st b/src/PharoLauncher-CLI/PhLImageCreateCliCommand.class.st index d37fd756d..a64a8a28d 100644 --- a/src/PharoLauncher-CLI/PhLImageCreateCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLImageCreateCliCommand.class.st @@ -34,9 +34,19 @@ Class { #category : #'PharoLauncher-CLI-Commands' } +{ #category : #'command line - arguments' } +PhLImageCreateCliCommand class >> addDevFlagTo: aCommandSpec [ + + aCommandSpec + addFlag: #'dev' + description: 'When flag is present, the last development image will be used as template. Will take precedence if templateName is specified.' +] + { #category : #'command line - arguments' } PhLImageCreateCliCommand class >> addLauncherFlagsTo: aCommandSpec [ + self addDevFlagTo: aCommandSpec. + self addNoLaunchFlagTo: aCommandSpec. self addTemplateNameFlagTo: aCommandSpec. self addTemplateCategoryFlagTo: aCommandSpec. ] @@ -59,6 +69,14 @@ PhLImageCreateCliCommand class >> addNewImageFlagTo: aCommandSpec [ positionalSpec: [ :positional | positional defaultValue: [ :arg :app | app implicitImageName ] ] ] +{ #category : #'command line - arguments' } +PhLImageCreateCliCommand class >> addNoLaunchFlagTo: aCommandSpec [ + + aCommandSpec + addFlag: #'no-launch' + description: 'When flag is present, the just created image will not be launched after its creation.' +] + { #category : #'command line - arguments' } PhLImageCreateCliCommand class >> addPharoVersionFlagTo: aCommandSpec [ @@ -74,17 +92,7 @@ PhLImageCreateCliCommand class >> addTemplateCategoryFlagTo: aCommandSpec [ aCommandSpec addFlag: #templateCategory description: 'Specifies the template category to search the target template.' - positionalSpec: [ :positional | positional defaultValue: [ :arg :app | app defaultTemplateCategoryName ]]. - -"^ (ClapFlag id: #templateCategory) - description: 'Specifies the template category to search the target template.'; - meaning: [ :arg :app | (arg at: #templateCategoryArg) value ]; - implicitMeaning: [ :arg :app | app defaultTemplateCategoryName ]; - add: ((ClapPositional id: #templateCategoryArg) - description: 'Template category argument.'; - meaning: [ :pos | pos word asSymbol . ]; - implicitMeaning: [ :arg :app | app defaultTemplateCategoryName]); - yourself" + positionalSpec: [ :positional | positional defaultValue: [ :arg :app | app defaultTemplateCategoryName ]] ] { #category : #'command line - arguments' } @@ -92,17 +100,7 @@ PhLImageCreateCliCommand class >> addTemplateNameFlagTo: aCommandSpec [ aCommandSpec addFlagWithPositional: #templateName - description: 'Template which will be used to create the image'. -" ^ (ClapFlag id: #templateName) - description: 'Template which will be used to create the image.'; - meaning: [ :arg :app | (arg at: #templateNameArg) value ]; - implicitMeaning: [ :arg :app | ]; - add: ((ClapPositional id: #templateNameArg) - description: 'Template name argument.'; - meaning: [ :pos | pos word asString ]; - implicitMeaning: [ :arg :app | NotFound signal: self missingTemplateNameArgMessage]); - yourself -" + description: 'Template which will be used to create the image' ] { #category : #'command line' } @@ -130,8 +128,11 @@ PhLImageCreateCliCommand class >> raiseMissingTemplateName [ { #category : #'command execution' } PhLImageCreateCliCommand >> basicExecute [ - - self findTemplateAndCreateImage + | image | + + image := self findTemplateAndCreateImage. + self shouldLaunchImage + ifTrue: [ image launch ] ] { #category : #'command execution' } @@ -148,12 +149,13 @@ PhLImageCreateCliCommand >> createImage: newImageName from: template [ { #category : #querying } PhLImageCreateCliCommand >> findTemplate [ + (self hasFlag: #dev) ifTrue: [ ^ self latestDevTemplate ]. "find template defined by user" (self hasFlag: #templateName) ifTrue: [ ^ self findUserTemplate ]. "otherwise latest stable Pharo version template" - ^ self latestStableTemplate + ^ self defaultTemplate ] { #category : #'command execution' } @@ -164,7 +166,15 @@ PhLImageCreateCliCommand >> findTemplateAndCreateImage [ ] { #category : #querying } -PhLImageCreateCliCommand >> findUserTemplate [ +PhLImageCreateCliCommand >> findUserTemplate [ + + ^ [ self findUserTemplateFromName ] + on: NotFound + do: [ self findUserTemplateFromShortName ] +] + +{ #category : #querying } +PhLImageCreateCliCommand >> findUserTemplateFromName [ ^ self templateRepository templateNamed: self templateName @@ -172,6 +182,15 @@ PhLImageCreateCliCommand >> findUserTemplate [ ] +{ #category : #querying } +PhLImageCreateCliCommand >> findUserTemplateFromShortName [ + + ^ self templateRepository + templateShortNamed: self templateName + inCategoryNamed: self templateCategory + +] + { #category : #accessing } PhLImageCreateCliCommand >> imageFinderClass [ @@ -202,20 +221,6 @@ PhLImageCreateCliCommand >> implicitPharoVersion [ ^ self imageFinderClass findLatestPharoDevelopmentVersion ] -{ #category : #default } -PhLImageCreateCliCommand >> latestDevTemplate [ - - "from default 'Official distributions' obtain latest development template" - ^ self defaultTemplateCategory latestDevelopmentTemplate -] - -{ #category : #default } -PhLImageCreateCliCommand >> latestStableTemplate [ - - "from default 'Official distributions' obtain latest Pharo version stable template" - ^ self defaultTemplateCategory latestStableTemplate -] - { #category : #logging } PhLImageCreateCliCommand >> logCannotFindTemplate: templateName [ @@ -251,12 +256,9 @@ PhLImageCreateCliCommand >> pharoVersionNumber [ ^ self positional: #pharoVersion ] -{ #category : #'command execution' } -PhLImageCreateCliCommand >> printSubCommandsHelp [ - - arguments positionalValues isEmpty ifTrue:[ - (ClapDocumenter on: self outStream) explain: arguments parent specification - ] +{ #category : #asserting } +PhLImageCreateCliCommand >> shouldLaunchImage [ + ^ (self hasFlag: #'no-launch') not ] { #category : #querying } diff --git a/src/PharoLauncher-CLI/PhLImageCreateFromRemoteRepoCliCommand.class.st b/src/PharoLauncher-CLI/PhLImageCreateFromRemoteRepoCliCommand.class.st index a40190ddb..a5a172432 100644 --- a/src/PharoLauncher-CLI/PhLImageCreateFromRemoteRepoCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLImageCreateFromRemoteRepoCliCommand.class.st @@ -206,13 +206,16 @@ PhLImageCreateFromRemoteRepoCliCommand >> raiseRepoNameInvalid [ { #category : #private } PhLImageCreateFromRemoteRepoCliCommand >> regexForRepoName [ - |stringWithDash| - + |stringWithDash versionOrBranch| + "e.g. some-project-123" stringWithDash := '[\w]+-?[\w]+'. - "should match {alphanumeric-chars with dash}/{alphanumeric-chars with dash}:{feature}/{alphanumeric-chars with dash}" - ^ stringWithDash, '\/', stringWithDash, '(\:?', stringWithDash, '(\/', stringWithDash, ')?', ')?' + "e.g. v1.2.3b or 1.0-RC-somecomment" + versionOrBranch := '[a-zA-Z0-9_\-./]+$'. + + "should match {alphanumeric-chars with dash}/{alphanumeric-chars with dash}:{versionOrBranch})" + ^ '{dashString}\\/{dashString}(\\:?({versionOrBranchString}))' format: { 'dashString' -> stringWithDash. 'versionOrBranchString' -> versionOrBranch. } asDictionary. ] { #category : #private } diff --git a/src/PharoLauncher-CLI/PhLImageListCliCommand.class.st b/src/PharoLauncher-CLI/PhLImageListCliCommand.class.st index 0f875d8e9..4b369fc07 100644 --- a/src/PharoLauncher-CLI/PhLImageListCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLImageListCliCommand.class.st @@ -17,8 +17,8 @@ Class { PhLImageListCliCommand class >> addLauncherFlagsTo: aCommandSpec [ aCommandSpec - addFlagWithPositional: #name - description: 'Determines the name of image (or its sub-part) to list local images.'. + addFlagWithPositional: #nameFilter + description: 'Images listing will be filtered by the provided name filter'. self addPrintFlagsTo: aCommandSpec. ] @@ -52,15 +52,15 @@ PhLImageListCliCommand >> imagesFromName: aSubtring [ PhLImageListCliCommand >> listImages [ | images | - images := (self hasFlag: #name) - ifTrue: [ self imagesFromName: self name ] + images := (self hasFlag: #nameFilter) + ifTrue: [ self imagesFromName: self nameFilter ] ifFalse: [ self imageRepository images ]. - self list: images + self list: (images sorted: [:a :b | b lastModification <= a lastModification]) ] { #category : #'accessing arguments' } -PhLImageListCliCommand >> name [ +PhLImageListCliCommand >> nameFilter [ - ^ self positional: #name + ^ self positional: #nameFilter ] diff --git a/src/PharoLauncher-CLI/PhLImagePackageCliCommand.class.st b/src/PharoLauncher-CLI/PhLImagePackageCliCommand.class.st index 513bf8925..9a4eca083 100644 --- a/src/PharoLauncher-CLI/PhLImagePackageCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLImagePackageCliCommand.class.st @@ -107,7 +107,9 @@ PhLImagePackageCliCommand >> createDirectoryForImageToPack [ |aPath| aPath := self location , '/' , self image name. (self directoryAlreadyExists: aPath) ifTrue: [self raiseDirectoryAlreadyExists: aPath]. - ^ aPath asFileReference ensureCreateDirectory + ^ [aPath asFileReference ensureCreateDirectory] + on: PrimitiveFailed + do: [ self raiseCannotCreateDirectory: self location] ] { #category : #private } @@ -208,6 +210,12 @@ PhLImagePackageCliCommand >> location [ ^ self positional: #location ] +{ #category : #'error signalling' } +PhLImagePackageCliCommand >> raiseCannotCreateDirectory: aPath [ + + ^PhLCommandError signal: ('Cannot write to target directory: ''{1}'', please check write permissions.' format: { aPath }) +] + { #category : #'error signalling' } PhLImagePackageCliCommand >> raiseDirectoryAlreadyExists: aPath [ diff --git a/src/PharoLauncher-CLI/PhLImageProcess.extension.st b/src/PharoLauncher-CLI/PhLImageProcess.extension.st new file mode 100644 index 000000000..ffe2b8f51 --- /dev/null +++ b/src/PharoLauncher-CLI/PhLImageProcess.extension.st @@ -0,0 +1,8 @@ +Extension { #name : #PhLImageProcess } + +{ #category : #'*PharoLauncher-CLI' } +PhLImageProcess class >> newFrom: osOutputLine [ + + "initialize image process instance from line represented by OS command output line" + ^ (PhLProcessListEntry with: osOutputLine) asImageProcess +] diff --git a/src/PharoLauncher-CLI/PhLImageProcessListCliCommand.class.st b/src/PharoLauncher-CLI/PhLImageProcessListCliCommand.class.st deleted file mode 100644 index 6dd837cc4..000000000 --- a/src/PharoLauncher-CLI/PhLImageProcessListCliCommand.class.st +++ /dev/null @@ -1,143 +0,0 @@ -" -Command to list all the running images. -" -Class { - #name : #PhLImageProcessListCliCommand, - #superclass : #PhLImageCliCommand, - #category : #'PharoLauncher-CLI-Commands' -} - -{ #category : #'command line - arguments' } -PhLImageProcessListCliCommand class >> addLauncherFlagsTo: aCommandSpec [ - - self addPrintFlagsTo: aCommandSpec. -] - -{ #category : #'command line' } -PhLImageProcessListCliCommand class >> asCliCommand [ - ^ self newLauncherCommandSpec: #processList -] - -{ #category : #'command line' } -PhLImageProcessListCliCommand class >> launcherCmdDescription [ - - ^ 'Lists all running Pharo image processes.' -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> basicExecute [ - |processList| - "TODO: Win Powershell version should be something like this: Get-Process | Where-Object { $_.Path -like '*Pharo*' -and $_.Path -like '*.image*' -and $_.Id -ne 2232 } | Select-Object Id, Path, StartTime, CommandLine" - self checkOS. - - "trim trailing newlines" - processList := self imageProcesListFrom: self executeOSShellCommand trim. - self list: processList -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> getImageAttributesFrom: lineString [ - |lineWords pid imagePath vmPath startDate| - lineWords := lineString substrings. - pid := self pidStringFrom: lineWords. - vmPath := self vmPathFrom: lineWords. - imagePath := self imagePathFrom: lineWords. - startDate := self startDateOfPid: pid. - ^ {pid. vmPath. imagePath. startDate} -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> imagePathFrom: lineWords [ - - |pharoVMIndex pharoImgIndex resultImgString| - "find index of word containing pharo VM name" - pharoVMIndex := lineWords detectIndex: [:word | word includesSubstring: 'pharo' caseSensitive: false] ifNone: [^ '']. - "find index of word containing pharo image file" - pharoImgIndex := lineWords detectIndex: [:word | word includesSubstring: '.image' caseSensitive: false] ifNone: [0]. - resultImgString := String streamContents: [:aStream | - lineWords from: pharoVMIndex + 1 to: pharoImgIndex do: [:word | - (word beginsWith: '--') ifFalse: [ - aStream - nextPutAll: word; - nextPut: Character space] - ]. - lineWords from: pharoImgIndex + 1 to: lineWords size do: [:word | - (word beginsWith: '--') ifTrue: [ aStream nextPutAll: word; nextPut: Character space ]. - ] - ]. - - ^ resultImgString trim -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> imageProcesListFrom: shellOutput [ - - ^ (shellOutput substrings: OSPlatform current lineEnding) collect: [:line | - PhLImageProcess newFrom: (self getImageAttributesFrom: line) - ] -] - -{ #category : #private } -PhLImageProcessListCliCommand >> modelClass [ - - ^ self class environment at: #PhLImageProcess -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> osShellArgArray [ - - ^ Array with: self processListCmdArgs -] - -{ #category : #private } -PhLImageProcessListCliCommand >> pidStringFrom: lineWords [ - - "pid is the first word of line" - ^ lineWords first -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> processListCmdArgs [ - - "process grep of all processes with 'pharo' (case-insensitive), where launcher process is ommited as well as export commands for path env. variables" - ^ String streamContents: [:aStream | - aStream - nextPutAll: OSPlatform current processListArgs; - nextPutAll: ' | grep -v ".bash"| grep -v "export LD_LIBRARY_PATH" | grep -v '; - nextPutAll: self currentVMPid asString; - "return 0 exit code also for cases, when no process is found. (default for no match is 1)" - nextPutAll: '; pgrep_exit_code=$?; if [ "$pgrep_exit_code" -eq 1 ]; then exit 0; else exit "$pgrep_exit_code"; fi' - ] -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> startDateOfPid: pidString [ - - |pidDateCmd | - pidDateCmd := String streamContents: [: aStream | - aStream - nextPutAll: 'LANG=C ps -o lstart= -p "'; - nextPutAll: pidString; - nextPutAll: '" | '; - nextPutAll: OSPlatform current processStartDateArgs. - ]. - ^ (self executeOSShellCommandWithArgs: (Array with: pidDateCmd)) trim -] - -{ #category : #'command execution' } -PhLImageProcessListCliCommand >> vmPathFrom: lineWords [ - - |pharoVMIndex pharoImgIndex resultVmString| - "find index of word containing pharo VM name" - pharoVMIndex := lineWords detectIndex: [:word | word includesSubstring: 'pharo' caseSensitive: false] ifNone: [^ '']. - "find index of word containing pharo image file" - pharoImgIndex := lineWords detectIndex: [:word | word includesSubstring: '.image' caseSensitive: false] ifNone: [0]. - resultVmString := String streamContents: [:aStream | - lineWords from: 2 to: pharoVMIndex do: [:word | aStream nextPutAll: word; nextPut: Character space]. - lineWords from: pharoVMIndex to: pharoImgIndex do: [:word | - (word beginsWith: '--') ifTrue: [ aStream nextPutAll: word; nextPut: Character space ]. - ] - ]. - - ^ resultVmString trim -] diff --git a/src/PharoLauncher-CLI/PhLImageRecreateCliCommand.class.st b/src/PharoLauncher-CLI/PhLImageRecreateCliCommand.class.st index ae265353d..584e50741 100644 --- a/src/PharoLauncher-CLI/PhLImageRecreateCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLImageRecreateCliCommand.class.st @@ -13,7 +13,7 @@ PhLImageRecreateCliCommand class >> addLauncherPositionalsTo: aCommandSpec [ (aCommandSpec addPositional: #existingImageName description: 'Local image name to recreate.') - implicitMeaning: [:arg :app | app raiseMissingImageToRecreate] + implicitMeaning: [:arg :app | self raiseMissingImageToRecreate] ] { #category : #'command line' } diff --git a/src/PharoLauncher-CLI/PhLNotificationCenter.class.st b/src/PharoLauncher-CLI/PhLNotificationCenter.class.st index ac4676b6a..04fb0cc3b 100644 --- a/src/PharoLauncher-CLI/PhLNotificationCenter.class.st +++ b/src/PharoLauncher-CLI/PhLNotificationCenter.class.st @@ -1,5 +1,8 @@ " -This represents singleton object for accessing errorStream, outStream in methods used by CLI, that do not have any reference to streams of CLI command (or CLI context) object. +I represent an object to manage notifications to user when ran in CLI mode. + +I can act as the PharoLauncher default application (see PharoLauncherApplication class>>#default). +I only have a minimal set of methods to provide some polymorphism with an SpApplication and avoid UI interactions. " Class { #name : #PhLNotificationCenter, @@ -54,3 +57,28 @@ PhLNotificationCenter >> outStream [ PhLNotificationCenter >> outStream: anOutStream [ outStream := anOutStream ] + +{ #category : #ui } +PhLNotificationCenter >> pushProgress: aString with: aFullBlockClosure [ + "do not display progress, only evaluate the block" + aFullBlockClosure value: DummySystemProgressItem new +] + +{ #category : #polymorphism } +PhLNotificationCenter >> reset [ + + "This method is not a 'real' reset but is there for polymorphism with `PharoLauncherApplication`. + It is called by `PhLStartupManager class>>#startUp:`. + One should not reset my streams as they are initialized by clap at image startup." +] + +{ #category : #ui } +PhLNotificationCenter >> showError: anError [ + + self errorStream + nextPutAll: 'Error: '; + nextPutAll: anError name; + nextPutAll: ' - '; + nextPutAll: anError longDescription; + cr +] diff --git a/src/PharoLauncher-CLI/PhLProcessCliCommand.class.st b/src/PharoLauncher-CLI/PhLProcessCliCommand.class.st new file mode 100644 index 000000000..4a32f8e67 --- /dev/null +++ b/src/PharoLauncher-CLI/PhLProcessCliCommand.class.st @@ -0,0 +1,64 @@ +" +I represent a Pharo process sub-command of Pharo Launcher. My responsibility is to take care of Pharo process sub-commands. + +I use: +- Pharo launcher root command to declare my other sub-commands. + +I declare: + +• list, kill + + +I execute: + +• just printing help about my sub-commands relevant for Pharo templates +" +Class { + #name : #PhLProcessCliCommand, + #superclass : #PhLCliCommand, + #category : #'PharoLauncher-CLI-Commands' +} + +{ #category : #'command line - converting' } +PhLProcessCliCommand class >> asCliCommand [ + ^ self newLauncherCommandSpec: #process +] + +{ #category : #'command line - description' } +PhLProcessCliCommand class >> launcherCmdDescription [ + + ^ 'All sub-commands related to Pharo processes.' +] + +{ #category : #private } +PhLProcessCliCommand >> checkOS [ + + OSPlatform current isWindows ifTrue: [ self raiseOperationNotSupported ] +] + +{ #category : #accessing } +PhLProcessCliCommand >> currentVMPid [ + + ^ OSSVMProcess vmProcess pid +] + +{ #category : #'command execution' } +PhLProcessCliCommand >> executeOSShellCommand [ + + ^ self executeOSShellCommandWithArgs: self osShellArgArray +] + +{ #category : #'command execution' } +PhLProcessCliCommand >> executeOSShellCommandWithArgs: argArray [ + +^ PhLProcessWrapper new + shellCommand; + addAllArguments: argArray; + runAndWaitWithStdOutput +] + +{ #category : #'error signalling' } +PhLProcessCliCommand >> raiseOperationNotSupported [ + + ^ PhLProcessCommandError signal: 'Launcher command currently not supported on OS Windows.' +] diff --git a/src/PharoLauncher-CLI/PhLImageKillCliCommand.class.st b/src/PharoLauncher-CLI/PhLProcessKillCliCommand.class.st similarity index 59% rename from src/PharoLauncher-CLI/PhLImageKillCliCommand.class.st rename to src/PharoLauncher-CLI/PhLProcessKillCliCommand.class.st index 29c8826fa..c364a0747 100644 --- a/src/PharoLauncher-CLI/PhLImageKillCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLProcessKillCliCommand.class.st @@ -1,14 +1,14 @@ " -Command to kill one image if given in option or all the images if the --all flag is set +Command to kill one image if given in option or all the images if the --all flag is set " Class { - #name : #PhLImageKillCliCommand, - #superclass : #PhLImageCliCommand, + #name : #PhLProcessKillCliCommand, + #superclass : #PhLProcessCliCommand, #category : #'PharoLauncher-CLI-Commands' } { #category : #'command line - arguments' } -PhLImageKillCliCommand class >> addLauncherFlagsTo: aCommandSpec [ +PhLProcessKillCliCommand class >> addLauncherFlagsTo: aCommandSpec [ aCommandSpec addFlag: #all @@ -16,7 +16,7 @@ PhLImageKillCliCommand class >> addLauncherFlagsTo: aCommandSpec [ ] { #category : #'command line - arguments' } -PhLImageKillCliCommand class >> addLauncherPositionalsTo: aCommandSpec [ +PhLProcessKillCliCommand class >> addLauncherPositionalsTo: aCommandSpec [ (aCommandSpec addPositional: #existingImageName @@ -24,39 +24,46 @@ PhLImageKillCliCommand class >> addLauncherPositionalsTo: aCommandSpec [ implicitMeaning: [ :arg :app | self raiseMissingImageToKill] ] -{ #category : #'command line' } -PhLImageKillCliCommand class >> asCliCommand [ +{ #category : #'command line - converting' } +PhLProcessKillCliCommand class >> asCliCommand [ ^ self newLauncherCommandSpec: #kill ] -{ #category : #'command line' } -PhLImageKillCliCommand class >> launcherCmdDescription [ +{ #category : #'command line - description' } +PhLProcessKillCliCommand class >> launcherCmdDescription [ ^ 'Kills the running process(es) of given local image.' ] { #category : #'error signalling' } -PhLImageKillCliCommand class >> raiseMissingImageToKill [ +PhLProcessKillCliCommand class >> raiseMissingImageToKill [ ^ NotFound signal: 'An argument is missing, please specify the local image name to kill it process.' ] { #category : #'command execution' } -PhLImageKillCliCommand >> basicExecute [ +PhLProcessKillCliCommand >> basicExecute [ "currently unsupported on Windows" self checkOS. + ^ self executeOSShellCommand ] -{ #category : #accessing } -PhLImageKillCliCommand >> hasAllFlag [ +{ #category : #testing } +PhLProcessKillCliCommand >> hasAllFlag [ ^ self hasFlag: #all ] +{ #category : #accessing } +PhLProcessKillCliCommand >> imageName [ + + ^ self positional: #existingImageName +] + { #category : #commands } -PhLImageKillCliCommand >> killArgString [ +PhLProcessKillCliCommand >> killArgString [ ^ String streamContents: [ :aStream | @@ -69,8 +76,11 @@ PhLImageKillCliCommand >> killArgString [ ] { #category : #'command execution' } -PhLImageKillCliCommand >> osShellArgArray [ +PhLProcessKillCliCommand >> osShellArgArray [ + "provide the command and its args in array" - "provide list of command and its args in array" - ^ Array with: 'kill' with: self killArgString with: '/dev/null' + ^ Array + with: 'kill' + with: self killArgString + with: '/dev/null' ] diff --git a/src/PharoLauncher-CLI/PhLProcessListCliCommand.class.st b/src/PharoLauncher-CLI/PhLProcessListCliCommand.class.st new file mode 100644 index 000000000..2b35956ef --- /dev/null +++ b/src/PharoLauncher-CLI/PhLProcessListCliCommand.class.st @@ -0,0 +1,97 @@ +" +Command to list all the Pharo processes, i.e. all running Pharo images. +" +Class { + #name : #PhLProcessListCliCommand, + #superclass : #PhLProcessCliCommand, + #instVars : [ + 'shellOutput' + ], + #category : #'PharoLauncher-CLI-Commands' +} + +{ #category : #'command line - arguments' } +PhLProcessListCliCommand class >> addLauncherFlagsTo: aCommandSpec [ + + self addPrintFlagsTo: aCommandSpec. +] + +{ #category : #'command line - converting' } +PhLProcessListCliCommand class >> asCliCommand [ + ^ self newLauncherCommandSpec: #list +] + +{ #category : #'command line - description' } +PhLProcessListCliCommand class >> launcherCmdDescription [ + + ^ 'Lists all running Pharo image processes.' +] + +{ #category : #'command execution' } +PhLProcessListCliCommand >> basicExecute [ + |processList| + "TODO: Win Powershell version should be something like this: Get-Process | Where-Object { $_.Path -like '*Pharo*' -and $_.Path -like '*.image*' -and $_.Id -ne 2232 } | Select-Object Id, Path, StartTime, CommandLine" + self checkOS. + + "trim trailing newlines" + shellOutput := self executeOSShellCommand trim. + processList := self imageProcesList. + self list: processList +] + +{ #category : #private } +PhLProcessListCliCommand >> getImageProcessFrom: lineString [ + + | imageProcess | + + imageProcess := PhLImageProcess newFrom: lineString. + imageProcess startDateTime: (self startDateOfPid: imageProcess pid). + ^ imageProcess +] + +{ #category : #'command execution' } +PhLProcessListCliCommand >> imageProcesList [ + + ^ (shellOutput substrings: OSPlatform current lineEnding) + collect: [:line | self getImageProcessFrom: line ] +] + +{ #category : #private } +PhLProcessListCliCommand >> modelClass [ + + ^ self class environment at: #PhLImageProcess +] + +{ #category : #'command execution' } +PhLProcessListCliCommand >> osShellArgArray [ + + ^ Array with: self processListCmdArgs +] + +{ #category : #'command execution' } +PhLProcessListCliCommand >> processListCmdArgs [ + + "process grep of all processes with 'pharo' (case-insensitive), where launcher process is ommited as well as export commands for path env. variables" + ^ String streamContents: [:aStream | + aStream + nextPutAll: OSPlatform current processListArgs; + nextPutAll: ' | grep -v ".bash"| grep -v "export LD_LIBRARY_PATH" | grep -v '; + nextPutAll: self currentVMPid asString; + "returns 0 exit code also for cases, when no process is found. (default for no match is 1)" + nextPutAll: '; pgrep_exit_code=$?; if [ "$pgrep_exit_code" -eq 1 ]; then exit 0; else exit "$pgrep_exit_code"; fi' + ] +] + +{ #category : #private } +PhLProcessListCliCommand >> startDateOfPid: pidString [ + + | pidDateCmd | + pidDateCmd := String streamContents: [: aStream | + aStream + nextPutAll: 'LANG=C ps -o lstart= -p "'; + nextPutAll: pidString; + nextPutAll: '" | '; + nextPutAll: OSPlatform current processStartDateArgs. + ]. + ^ (self executeOSShellCommandWithArgs: (Array with: pidDateCmd)) trim +] diff --git a/src/PharoLauncher-CLI/PhLProcessListEntry.class.st b/src/PharoLauncher-CLI/PhLProcessListEntry.class.st new file mode 100644 index 000000000..fdc65438c --- /dev/null +++ b/src/PharoLauncher-CLI/PhLProcessListEntry.class.st @@ -0,0 +1,100 @@ +" +I represent the output of a Shell process listing command for one entry. +I can parse this output to retrieve the Pharo VM and image. + +Example of input string from a process listing command: +'933 /tmp/61d1f200-02cc-0d00-88d2-05d60e98deae/110-x64/pharo /tmp/61d1f200-02cc-0d00-88d2-05d60e98deae/PharoLauncher.image' +" +Class { + #name : #PhLProcessListEntry, + #superclass : #Object, + #instVars : [ + 'words', + 'vmIndex', + 'imageIndex' + ], + #category : #'PharoLauncher-CLI-Utility' +} + +{ #category : #'instance creation' } +PhLProcessListEntry class >> with: aString [ + + ^ self new + shellString: aString; + yourself +] + +{ #category : #converting } +PhLProcessListEntry >> asImageProcess [ + + ^ PhLImageProcess new + pid: self pidString; + imagePath: self imagePath; + vmPath: self vmPath +] + +{ #category : #private } +PhLProcessListEntry >> computeImageIndex [ + + imageIndex := words + detectIndex: [ :word | word includesSubstring: '.image' caseSensitive: false ] + ifNone: [ 0 ] +] + +{ #category : #private } +PhLProcessListEntry >> computeVmIndex [ + + vmIndex := words + detectIndex: [ :word | word includesSubstring: 'pharo' caseSensitive: false ] + ifNone: [ nil ] +] + +{ #category : #accessing } +PhLProcessListEntry >> imagePath [ + + vmIndex ifNil: [ ^ '' ]. + + ^ ( + String streamContents: [ :aStream | + words + from: vmIndex + 1 to: imageIndex + do: [ :word | (word beginsWith: '--') ifFalse: [ aStream nextPutAll: word; nextPut: Character space ] ]. + words + from: imageIndex + 1 to: words size + do: [ :word | (word beginsWith: '--') ifTrue: [ aStream nextPutAll: word; nextPut: Character space ] ] ] + ) trim +] + +{ #category : #private } +PhLProcessListEntry >> pidIndex [ + + ^ 1 +] + +{ #category : #accessing } +PhLProcessListEntry >> pidString [ + + ^ words at: self pidIndex +] + +{ #category : #initialization } +PhLProcessListEntry >> shellString: aString [ + + words := aString substrings. + self computeVmIndex. + self computeImageIndex +] + +{ #category : #accessing } +PhLProcessListEntry >> vmPath [ + + vmIndex ifNil: [ ^ '' ]. + + ^ (String streamContents: [:aStream | + words + from: self pidIndex + 1 to: vmIndex + do: [ :word | aStream nextPutAll: word; nextPut: Character space ]. + words from: vmIndex to: imageIndex + do: [ :word | (word beginsWith: '--') ifTrue: [ aStream nextPutAll: word; nextPut: Character space ] ] + ]) trim +] diff --git a/src/PharoLauncher-CLI/PhLTemplateCategoriesCliCommand.class.st b/src/PharoLauncher-CLI/PhLTemplateCategoriesCliCommand.class.st index e649409c0..28533b111 100644 --- a/src/PharoLauncher-CLI/PhLTemplateCategoriesCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLTemplateCategoriesCliCommand.class.st @@ -33,7 +33,9 @@ PhLTemplateCategoriesCliCommand class >> launcherCmdDescription [ { #category : #'command execution' } PhLTemplateCategoriesCliCommand >> basicExecute [ - self list: self templateRepository roots + [ self list: self templateRepository roots default: self defaultTemplateCategory ] + on: NotFound + do: [ self list: self templateRepository roots ] ] { #category : #private } diff --git a/src/PharoLauncher-CLI/PhLTemplateInfoCliCommand.class.st b/src/PharoLauncher-CLI/PhLTemplateInfoCliCommand.class.st index 6c9b5e36e..685e56860 100644 --- a/src/PharoLauncher-CLI/PhLTemplateInfoCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLTemplateInfoCliCommand.class.st @@ -28,7 +28,7 @@ PhLTemplateInfoCliCommand class >> addLauncherPositionalsTo: aCommandSpec [ (aCommandSpec addPositional: #templateName description: 'Specifies the template name to print information.') - implicitMeaning: [:arg :app | app raiseMissingTemplateToPrint] + implicitMeaning: [:arg :app | self raiseMissingTemplateToPrint] ] { #category : #'command line - converting' } diff --git a/src/PharoLauncher-CLI/PhLTemplateListCliCommand.class.st b/src/PharoLauncher-CLI/PhLTemplateListCliCommand.class.st index 7d8777f8d..0847bcf64 100644 --- a/src/PharoLauncher-CLI/PhLTemplateListCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLTemplateListCliCommand.class.st @@ -41,8 +41,11 @@ PhLTemplateListCliCommand >> basicExecute [ categoryNamed: self templateCategory ] on: NotFound do: [ ^ self raiseCategoryNotFound: self templateCategory ]. - - self list: templateCategory templatesAndGroups asOrderedCollection + + self + isDefaultTemplateCategory: templateCategory + ifTrue: [ self list: templateCategory templatesAndGroups asOrderedCollection default: self defaultTemplate ] + ifFalse: [ self list: templateCategory templatesAndGroups asOrderedCollection ] ] { #category : #message } diff --git a/src/PharoLauncher-CLI/PhLVmCliCommand.class.st b/src/PharoLauncher-CLI/PhLVmCliCommand.class.st index 56ac87d33..f7a34edd3 100644 --- a/src/PharoLauncher-CLI/PhLVmCliCommand.class.st +++ b/src/PharoLauncher-CLI/PhLVmCliCommand.class.st @@ -21,7 +21,7 @@ PhLVmCliCommand class >> addLauncherPositionalsTo: aCommandSpec [ (aCommandSpec addPositional: #existingVirtualMachineId description: 'Specifies the local Virtual Machine ID.') - implicitMeaning: [:arg :app | app raiseMissingVM] + implicitMeaning: [:arg :app | self raiseMissingVM] ] { #category : #'command line - converting' } diff --git a/src/PharoLauncher-CLI/PharoLauncherCLIConfiguration.class.st b/src/PharoLauncher-CLI/PharoLauncherCLIConfiguration.class.st index 3207680db..85e789d58 100644 --- a/src/PharoLauncher-CLI/PharoLauncherCLIConfiguration.class.st +++ b/src/PharoLauncher-CLI/PharoLauncherCLIConfiguration.class.st @@ -8,17 +8,18 @@ Class { 'imagesDirectory', 'vmsDirectory', 'launchImageFromALoginShell', - 'initScriptsDirectory' + 'initScriptsDirectory', + 'defaultTemplate' ], #category : #'PharoLauncher-CLI-Model' } { #category : #'error signalling' } PharoLauncherCLIConfiguration class >> configFileNotFound: aFile [ - PhLNotificationCenter default errorStream + PhLNotificationCenter default outStream nextPutAll: - 'Config file not found, creating a new one at ' - , self preferencesFile fullName; + 'Config file not found, creating a new one at '; + nextPutAll: self preferencesFile fullName; newLine. ^ self createConfigurationFile: aFile ] @@ -87,6 +88,19 @@ PharoLauncherCLIConfiguration >> = anObject [ and: [ vmsDirectory = anObject vmsDirectory ] ] ] ] +{ #category : #accessing } +PharoLauncherCLIConfiguration >> defaultTemplate [ + ^ defaultTemplate ifNil: [ #stable ] +] + +{ #category : #accessing } +PharoLauncherCLIConfiguration >> defaultTemplate: aString [ + "default template can only be the stable Pharo version or the dev Pharo version" + + (#(dev stable) includes: aString) + ifTrue: [ defaultTemplate := aString asSymbol ] +] + { #category : #comparing } PharoLauncherCLIConfiguration >> hash [ ^ imagesDirectory hash @@ -119,12 +133,10 @@ PharoLauncherCLIConfiguration >> initScriptsDirectory: aFileReference [ PharoLauncherCLIConfiguration >> initialize [ super initialize. imagesDirectory := PhLDirectoryBasedImageRepository defaultLocation asFileReference . - vmsDirectory := FileLocator launcherUserFilesLocation / 'vms'. - vmsDirectory := vmsDirectory asFileReference. - initScriptsDirectory := PharoLauncherApplication + vmsDirectory := (FileLocator launcherUserFilesLocation / 'vms') asFileReference. + initScriptsDirectory := PharoLauncherApplication defaultInitializationScriptLocation asFileReference. - launchImageFromALoginShell := PhLLaunchConfiguration - launchInALoginShell + launchImageFromALoginShell := PhLLaunchConfiguration launchInALoginShell ] { #category : #accessing } diff --git a/src/PharoLauncher-CLI/PharoLauncherCLIModel.class.st b/src/PharoLauncher-CLI/PharoLauncherCLIModel.class.st index 79c6d82b5..ba8dc5910 100644 --- a/src/PharoLauncher-CLI/PharoLauncherCLIModel.class.st +++ b/src/PharoLauncher-CLI/PharoLauncherCLIModel.class.st @@ -9,17 +9,47 @@ Class { #instVars : [ 'imageRepository', 'templateRepository', - 'vmManager' + 'vmManager', + 'configuration' ], #category : #'PharoLauncher-CLI-Model' } +{ #category : #'instance creation' } +PharoLauncherCLIModel class >> fromConfiguration: aPharoLauncherConfiguration [ + + ^ self new + configuration: aPharoLauncherConfiguration; + yourself +] + +{ #category : #'instance creation' } +PharoLauncherCLIModel class >> fromDefaultConfiguration [ + + ^ self fromConfiguration: PharoLauncherCLIConfiguration defaultConfiguration +] + +{ #category : #accessing } +PharoLauncherCLIModel >> configuration [ + + ^ configuration +] + +{ #category : #accessing } +PharoLauncherCLIModel >> configuration: aPharoLauncherConfiguration [ + + configuration := aPharoLauncherConfiguration +] + +{ #category : #accessing } +PharoLauncherCLIModel >> defaultTemplate [ + ^ configuration defaultTemplate +] + { #category : #accessing } PharoLauncherCLIModel >> imageRepository [ ^ imageRepository - ifNil: [ | configuration | - configuration := PharoLauncherCLIConfiguration defaultConfiguration. - self + ifNil: [ self imageRepository: (PhLDirectoryBasedImageRepository forDirectory: configuration imagesDirectory). @@ -46,9 +76,7 @@ PharoLauncherCLIModel >> templateRepository: aPathString [ { #category : #accessing } PharoLauncherCLIModel >> vmManager [ ^ vmManager - ifNil: [ | configuration | - configuration := PharoLauncherCLIConfiguration defaultConfiguration. - PhLVirtualMachineManager vmStore: configuration vmsDirectory. + ifNil: [ PhLVirtualMachineManager vmStore: configuration vmsDirectory. self vmManager: PhLVirtualMachineManager new. vmManager ] ] diff --git a/src/PharoLauncher-Core/OmSessionStore.extension.st b/src/PharoLauncher-Core/OmSessionStore.extension.st new file mode 100644 index 000000000..0164d2450 --- /dev/null +++ b/src/PharoLauncher-Core/OmSessionStore.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #OmSessionStore } + +{ #category : #'*PharoLauncher-Core' } +OmSessionStore class >> startUp [ + + PharoLauncherApplication isDeployed ifTrue: [ ^ self ]. + + registry do: [ :each | each store ] +] diff --git a/src/PharoLauncher-Core/PhLAbstractTemplate.class.st b/src/PharoLauncher-Core/PhLAbstractTemplate.class.st index b9446f80a..d400c9e5a 100644 --- a/src/PharoLauncher-Core/PhLAbstractTemplate.class.st +++ b/src/PharoLauncher-Core/PhLAbstractTemplate.class.st @@ -8,7 +8,8 @@ Class { #name : #PhLAbstractTemplate, #superclass : #PhLObject, #instVars : [ - 'name' + 'name', + 'shortName' ], #category : #'PharoLauncher-Core-Model' } @@ -17,11 +18,18 @@ Class { PhLAbstractTemplate >> extractTo: aDirectory named: aString [ "Extract myself to aDirectory. Name the resulting image aString" | extractionDirectory archive | - - archive := self zipArchive. - extractionDirectory := self extractZipArchive: archive to: aDirectory. - self relocateImageFilesFrom: extractionDirectory to: aDirectory withName: aString. - extractionDirectory deleteAll. + PharoLauncherApplication default + pushProgress: 'Extract template' + with: [ :bar | + bar label: 'Downloading zip archive'; + current: 25. + archive := self zipArchive. + bar label: 'Extracting archive to target directory'; + current: 75. + extractionDirectory := self extractZipArchive: archive to: aDirectory. + self relocateImageFilesFrom: extractionDirectory to: aDirectory withName: aString. + extractionDirectory deleteAll + ]. "Will serialize image metadata with the template information" ^ (PhLImage location: aDirectory / aString , 'image') originTemplate: self. @@ -107,6 +115,16 @@ PhLAbstractTemplate >> renameTo: aString [ name := aString ] +{ #category : #accessing } +PhLAbstractTemplate >> shortName [ + ^ shortName +] + +{ #category : #accessing } +PhLAbstractTemplate >> shortName: aString [ + shortName := aString +] + { #category : #testing } PhLAbstractTemplate >> shouldComputeChildrenLazily [ ^ false diff --git a/src/PharoLauncher-Core/PhLAbstractTemplateGroup.class.st b/src/PharoLauncher-Core/PhLAbstractTemplateGroup.class.st index b6ad9df5d..e16c6d90e 100644 --- a/src/PharoLauncher-Core/PhLAbstractTemplateGroup.class.st +++ b/src/PharoLauncher-Core/PhLAbstractTemplateGroup.class.st @@ -85,6 +85,16 @@ PhLAbstractTemplateGroup >> templateNamed: aTemplateName [ , ' not found, please enter a correct template name' ] ] +{ #category : #querying } +PhLAbstractTemplateGroup >> templateShortNamed: aTemplateShortName [ + ^ self templatesAndGroups + detect: [ :aTemplate | aTemplate shortName = aTemplateShortName ] + ifNone: [ NotFound + signal: + aTemplateShortName asString + , ' not found, please enter a correct short template name' ] +] + { #category : #accessing } PhLAbstractTemplateGroup >> templatesAndGroups [ "Return a collection of all the templates and subgroups I contain" diff --git a/src/PharoLauncher-Core/PhLCorruptedTemplateError.class.st b/src/PharoLauncher-Core/PhLCorruptedTemplateError.class.st index 24c25b1c1..40bc820ae 100644 --- a/src/PharoLauncher-Core/PhLCorruptedTemplateError.class.st +++ b/src/PharoLauncher-Core/PhLCorruptedTemplateError.class.st @@ -6,3 +6,14 @@ Class { #superclass : #PhLError, #category : #'PharoLauncher-Core-Model' } + +{ #category : #accessing } +PhLCorruptedTemplateError >> longDescription [ + + ^ self name +] + +{ #category : #accessing } +PhLCorruptedTemplateError >> name [ + ^ 'This template appears to be corrupted! Please try again.' +] diff --git a/src/PharoLauncher-Core/PhLCreateImageFromTemplateCommand.class.st b/src/PharoLauncher-Core/PhLCreateImageFromTemplateCommand.class.st index 0db77b654..011404922 100644 --- a/src/PharoLauncher-Core/PhLCreateImageFromTemplateCommand.class.st +++ b/src/PharoLauncher-Core/PhLCreateImageFromTemplateCommand.class.st @@ -58,7 +58,7 @@ PhLCreateImageFromTemplateCommand >> execute [ [ ^ self createImage ] on: PhLCorruptedTemplateError do: [ :error | - self application showError: 'This template appears to be corrupted! Please try again.' ] + self application showError: error ] ] { #category : #initialization } diff --git a/src/PharoLauncher-Core/PhLDeleteImageCommand.class.st b/src/PharoLauncher-Core/PhLDeleteImageCommand.class.st index 41f87b36c..1fb7362ae 100644 --- a/src/PharoLauncher-Core/PhLDeleteImageCommand.class.st +++ b/src/PharoLauncher-Core/PhLDeleteImageCommand.class.st @@ -21,13 +21,13 @@ PhLDeleteImageCommand >> canBeExecuted [ ^ self imagesPresenter selectedImages notEmpty ] -{ #category : #accessing } +{ #category : #executing } PhLDeleteImageCommand >> execute [ | images imageNames confirmMessage answer | images := self imagesPresenter selectedImages. imageNames := images collect: #name. - confirmMessage := 'Are you sure you want to delete ', (imageNames joinUsing: ', ' last: ' and '). + confirmMessage := 'Are you sure you want to delete {1} images: {2}' format: {images size . (imageNames joinUsing: ', ' last: ' and ')}. answer := self imagesPresenter newConfirmation parentWindow: self context window; message: (confirmMessage withNoLineLongerThan: 60) , '?'; diff --git a/src/PharoLauncher-Core/PhLDownloadError.class.st b/src/PharoLauncher-Core/PhLDownloadError.class.st index 1b61bbc53..85315ee8e 100644 --- a/src/PharoLauncher-Core/PhLDownloadError.class.st +++ b/src/PharoLauncher-Core/PhLDownloadError.class.st @@ -18,6 +18,14 @@ PhLDownloadError class >> signalUrl: anUrl [ signal ] +{ #category : #signalling } +PhLDownloadError class >> signalUrl: anUrl message: errorMessage [ + ^ self new + setUrl: anUrl; + messageText: errorMessage; + signal +] + { #category : #polymorphism } PhLDownloadError >> hasChildren [ ^ false @@ -30,7 +38,11 @@ PhLDownloadError >> isTemplate [ { #category : #accessing } PhLDownloadError >> longDescription [ - ^ 'Error downloading ', (url printStringLimitedTo: 100) + ^ String streamContents: [ :stream | + stream + nextPutAll: 'Error downloading '; + nextPutAll: (url printStringLimitedTo: 100). + messageText ifNotNil: [ stream cr; nextPutAll: messageText ] ] ] { #category : #accessing } diff --git a/src/PharoLauncher-Core/PhLDownloadManager.class.st b/src/PharoLauncher-Core/PhLDownloadManager.class.st index f05116b24..79a5ececd 100644 --- a/src/PharoLauncher-Core/PhLDownloadManager.class.st +++ b/src/PharoLauncher-Core/PhLDownloadManager.class.st @@ -46,8 +46,6 @@ PhLDownloadManager >> basicDownload: url toFile: destinationFile [ { #category : #private } PhLDownloadManager >> displayProgress: aTitle during: workBlock [ "Inform user about download progression" - | bar | - bar := ConsoleProgressBar on: PhLNotificationCenter default outStream. PharoLauncherApplication default pushProgress: aTitle @@ -83,9 +81,10 @@ PhLDownloadManager >> download: url toFile: destinationFile [ ] { #category : #private } -PhLDownloadManager >> downloadFailureForUrl: url [ +PhLDownloadManager >> downloadFailureForUrl: url message: errorMessage [ + semaphore critical: [ errors add: url ]. - PhLDownloadError signalUrl: url + PhLDownloadError signalUrl: url message: errorMessage. ] { #category : #action } @@ -118,7 +117,7 @@ PhLDownloadManager >> newHTTPClientForUrl: url [ url: url; enforceHttpSuccess: true; withOptions: [ :options | options at: #queryKeyValueSafeSet put: (ZnOptions queryKeyValueSafeSet \ '/;') ]; - ifFail: [ :exception | self downloadFailureForUrl: url ]; + ifFail: [ :exception | self downloadFailureForUrl: url message: exception messageText ]; yourself ] diff --git a/src/PharoLauncher-Core/PhLFileBrowser.class.st b/src/PharoLauncher-Core/PhLFileBrowser.class.st deleted file mode 100644 index 7dd826eda..000000000 --- a/src/PharoLauncher-Core/PhLFileBrowser.class.st +++ /dev/null @@ -1,65 +0,0 @@ -" -I'm a simple visitor in charge of opening an operating system browser on the provided path string. -" -Class { - #name : #PhLFileBrowser, - #superclass : #OSPlatformVisitor, - #instVars : [ - 'process', - 'vmPath', - 'launchInALoginShell', - 'imageFile', - 'usePharoSettings', - 'path' - ], - #category : #'PharoLauncher-Core-Model' -} - -{ #category : #'instance creation' } -PhLFileBrowser class >> openOn: aFileReferenceOrPathString [ - - ^ self new - path: aFileReferenceOrPathString; - open. -] - -{ #category : #action } -PhLFileBrowser >> open [ - self visit -] - -{ #category : #accessing } -PhLFileBrowser >> path: aFileReferenceOrPathString [ - "Opens an OS-specific file and directory browser on ==aFileReference==. If aFileReference is a file, opens the browser on its containing directory instead." - | ref | - aFileReferenceOrPathString isNil ifTrue: [ ^ nil ]. - ref := aFileReferenceOrPathString asFileReference. - ref exists ifFalse: [ ^ nil ]. - - ref := ref isFile ifTrue: [ ref parent ] ifFalse: [ ref ]. - (ref isNil or: [ ref exists not ]) - ifTrue: [ ^ nil ]. - - path := ref fullName. -] - -{ #category : #visiting } -PhLFileBrowser >> visitMacOS: aPlatform [ - ^ PhLProcessWrapper new - shellCommand; - addArgument: ('open "{1}"' format: {path}); - runUnwatch -] - -{ #category : #visiting } -PhLFileBrowser >> visitUnix: aPlatform [ - ^ PhLProcessWrapper new - shellCommand; - addArgument: ('xdg-open "{1}"' format: {path}); - runUnwatch -] - -{ #category : #visiting } -PhLFileBrowser >> visitWindows: aPlatform [ - ^ aPlatform privShellExplore: path -] diff --git a/src/PharoLauncher-Core/PhLImage.class.st b/src/PharoLauncher-Core/PhLImage.class.st index d76321e70..2e78dae7f 100644 --- a/src/PharoLauncher-Core/PhLImage.class.st +++ b/src/PharoLauncher-Core/PhLImage.class.st @@ -392,12 +392,10 @@ PhLImage >> launchWithConfiguration: aPhLLaunchConfiguration [ ^ self ]. architectureWarningEnabled := true. continue := true. - [ [ | processWrapper| + [ | processWrapper| processWrapper := (aPhLLaunchConfiguration launchProcess) runUnwatch. self doNotRunInitializationScript. "Just run, image already initialized" ^ processWrapper ] - on: PhLImageVersionDeterminationError - do: [ :error | error uiAlert ] ] on: PhLArchitectureMismatchWarning do: [ :warning | architectureWarningEnabled ifTrue: [ @@ -509,7 +507,7 @@ PhLImage >> shouldRunInitializationScript: aBoolean [ { #category : #printing } PhLImage >> showNativeFolder [ - PhLFileBrowser openOn: file + file asFileReference openInOSFileBrowser ] { #category : #'private ui' } @@ -521,7 +519,7 @@ PhLImage >> showWarning: warning [ ifTrue: [ continue := (PharoLauncherApplication default newConfirm title: warning name ; - message: warning longDescription; + label: warning longDescription; openModalWithParent: PharoLauncherApplication default topWindow) ]. ^ continue diff --git a/src/PharoLauncher-Core/PhLImageDescriptionUpdater.class.st b/src/PharoLauncher-Core/PhLImageDescriptionUpdater.class.st index 177e22411..a0eb7a283 100644 --- a/src/PharoLauncher-Core/PhLImageDescriptionUpdater.class.st +++ b/src/PharoLauncher-Core/PhLImageDescriptionUpdater.class.st @@ -66,7 +66,10 @@ PhLImageDescriptionUpdater >> newProcess [ { #category : #private } PhLImageDescriptionUpdater >> terminateProcess [ - process ifNotNil: [ process terminate ] + (process isNil or: [ process isTerminated ]) + ifTrue: [ ^ self ]. + + process terminate. ] { #category : #accessing } diff --git a/src/PharoLauncher-Core/PhLImageFinder.class.st b/src/PharoLauncher-Core/PhLImageFinder.class.st index 52d14f348..d813f8bc2 100644 --- a/src/PharoLauncher-Core/PhLImageFinder.class.st +++ b/src/PharoLauncher-Core/PhLImageFinder.class.st @@ -163,7 +163,7 @@ PhLImageFinder >> pullRequest: aString [ { #category : #private } PhLImageFinder >> pullRequestBuildArtifactsUrlString [ - ^ 'https://ci.inria.fr/pharo-ci-jenkins2/job/Test%20pending%20pull%20request%20and%20branch%20Pipeline/view/change-requests/job/PR-{1}/lastSuccessfulBuild/artifact/bootstrap-cache/' + ^ 'https://ci.inria.fr/pharo-ci-jenkins2/job/Test%20pending%20pull%20request%20and%20branch%20Pipeline/view/change-requests/job/PR-{1}/lastSuccessfulBuild/artifact/build/bootstrap-cache/' format: { self pullRequest } ] diff --git a/src/PharoLauncher-Core/PhLImageProcess.class.st b/src/PharoLauncher-Core/PhLImageProcess.class.st index c75a06ab7..221632db0 100644 --- a/src/PharoLauncher-Core/PhLImageProcess.class.st +++ b/src/PharoLauncher-Core/PhLImageProcess.class.st @@ -15,23 +15,19 @@ Class { { #category : #private } PhLImageProcess class >> listPrintAttributeBlocks [ - - ^ {[:imgProcess | imgProcess pid asString]. [:imgProcess | imgProcess imageName]. [:imgProcess | imgProcess vmPath]. [:imgProcess | imgProcess imagePath]. [:imgProcess | imgProcess startDateTime ].} + ^ { + [ :imgProcess | imgProcess pid asString ]. + [ :imgProcess | imgProcess imageName ]. + [ :imgProcess | imgProcess vmPath ]. + [ :imgProcess | imgProcess imagePath ]. + [ :imgProcess | imgProcess startDateTime ] } ] { #category : #private } PhLImageProcess class >> listPrintAttributeLabels [ - - ^ #('PID' 'Image name' 'VM path' 'Image path' 'Date/Time started') -] - -{ #category : #'instance creation' } -PhLImageProcess class >> newFrom: osOutputLine [ - "initialize image process instance from line represented by OS command output line" - ^ self new initializeFrom: osOutputLine; yourself - + ^ #( 'PID' 'Image name' 'VM path' 'Image path' 'Date/Time started' ) ] { #category : #accessing } diff --git a/src/PharoLauncher-Core/PhLImageVersionDeterminationError.class.st b/src/PharoLauncher-Core/PhLImageVersionDeterminationError.class.st deleted file mode 100644 index d4125c168..000000000 --- a/src/PharoLauncher-Core/PhLImageVersionDeterminationError.class.st +++ /dev/null @@ -1,37 +0,0 @@ -" -Error thrown when Pharo Launcher did not succeed to determine the Pharo version of the image to launch. -Probably, the run command failed. -I hold the command run to determoine the version so that it can be reused for debugging purposes. -" -Class { - #name : #PhLImageVersionDeterminationError, - #superclass : #PhLError, - #instVars : [ - 'command' - ], - #category : #'PharoLauncher-Core-Download' -} - -{ #category : #signalling } -PhLImageVersionDeterminationError class >> signalCommand: aCommandString [ - ^ self new - setCommand: aCommandString; - signal -] - -{ #category : #accessing } -PhLImageVersionDeterminationError >> longDescription [ - ^ PhLImage versionFileName , - ' file was not found for your image, and probably your VMs are not up to date. -Please, contact us at http://pharo.org/community' -] - -{ #category : #accessing } -PhLImageVersionDeterminationError >> name [ - ^ 'Cannot determine image version' -] - -{ #category : #initialization } -PhLImageVersionDeterminationError >> setCommand: aCommandString [ - command := aCommandString reject: [ :c | c = Character cr ] "easier to run the copy/pasted command in a shell if command has only one line" -] diff --git a/src/PharoLauncher-Core/PhLImageVersionFileNotFound.class.st b/src/PharoLauncher-Core/PhLImageVersionFileNotFound.class.st new file mode 100644 index 000000000..b6db705ef --- /dev/null +++ b/src/PharoLauncher-Core/PhLImageVersionFileNotFound.class.st @@ -0,0 +1,28 @@ +" +Error thrown when Pharo Launcher did not succeed to determine the Pharo version of the image to launch. +Probably, the run command failed. +I hold the command run to determoine the version so that it can be reused for debugging purposes. +" +Class { + #name : #PhLImageVersionFileNotFound, + #superclass : #PhLError, + #category : #'PharoLauncher-Core-Download' +} + +{ #category : #accessing } +PhLImageVersionFileNotFound >> longDescription [ + ^ PhLImage versionFileName , + ' file was not found for your image, and probably your VMs are not up to date. +Please, contact us at http://pharo.org/community' +] + +{ #category : #accessing } +PhLImageVersionFileNotFound >> messageText [ + + ^ self longDescription +] + +{ #category : #accessing } +PhLImageVersionFileNotFound >> name [ + ^ 'Image version file ', PhLImage versionFileName , ' not found!' +] diff --git a/src/PharoLauncher-Core/PhLLaunchImageCommand.class.st b/src/PharoLauncher-Core/PhLLaunchImageCommand.class.st index caf711ad8..061108576 100644 --- a/src/PharoLauncher-Core/PhLLaunchImageCommand.class.st +++ b/src/PharoLauncher-Core/PhLLaunchImageCommand.class.st @@ -128,9 +128,9 @@ PhLLaunchImageCommand >> launchConfigurationOfImage: aPhLImage [ { #category : #executing } PhLLaunchImageCommand >> launchImage: aPhLImage [ | process launchConfig | - - [ - launchConfig := self launchConfigurationOfImage: aPhLImage. + + self imagesPresenter ensurePharoVersion. + [ launchConfig := self launchConfigurationOfImage: aPhLImage. launchConfig useSettings: useSettings. process := aPhLImage launchWithConfiguration: launchConfig ] on: PhLError diff --git a/src/PharoLauncher-Core/PhLNetworkSettings.class.st b/src/PharoLauncher-Core/PhLNetworkSettings.class.st index e8d4a76ee..86ef37b78 100644 --- a/src/PharoLauncher-Core/PhLNetworkSettings.class.st +++ b/src/PharoLauncher-Core/PhLNetworkSettings.class.st @@ -13,9 +13,13 @@ Class { PhLNetworkSettings class >> networkSettingsOn: aBuilder [ - (aBuilder setting: #useHTTPProxy) + (aBuilder group: #network) + label: 'Network' ; + description: 'All settings concerned with the network'. + + (aBuilder setting: #useHTTPProxy) label: 'Use HTTP proxy'; - parent: #pharoLauncher; + parent: #network; target: NetworkSystemSettings; order: 10; description: @@ -32,5 +36,21 @@ PhLNetworkSettings class >> networkSettingsOn: aBuilder [ (aBuilder setting: #manageHttpProxyExceptions) label: 'Exceptions' translated; target: NetworkSystemSettings; - description: 'Domains to avoid to proxy (separated by ;)' ] + description: 'Domains to avoid to proxy (separated by ;)' ]. + + (aBuilder setting: #useNetworkAuthentification) + label: 'Proxy authentication' ; + parent: #network; + order: 20; + target: NetworkSystemSettings; + description: 'If checked then you will be able to enter a user name and a password for network authentification. Store HTTP 1.0 basic authentication credentials. Note: this is an ugly hack that stores your password in your image. It''s just enought to get you going if you use a firewall that requires authentication'; + with: [ + (aBuilder setting: #proxyUser) + label: 'User name' ; + description: 'The proxy user name'. + (aBuilder setting: #proxyPassword) + type: #Password; + label: 'Password' ; + description: 'The user password']. + ] diff --git a/src/PharoLauncher-Core/PhLPharoTemplateSources.class.st b/src/PharoLauncher-Core/PhLPharoTemplateSources.class.st index 79da3ffc7..5fcc02d9e 100644 --- a/src/PharoLauncher-Core/PhLPharoTemplateSources.class.st +++ b/src/PharoLauncher-Core/PhLPharoTemplateSources.class.st @@ -26,7 +26,11 @@ PhLPharoTemplateSources class >> announcer [ { #category : #private } PhLPharoTemplateSources class >> basicSourcesUrl: aUrl [ + | oldUrl | + oldUrl := SourcesUrl. SourcesUrl := aUrl. + + ^ oldUrl ] { #category : #updating } @@ -100,10 +104,9 @@ PhLPharoTemplateSources class >> sourcesUrl [ PhLPharoTemplateSources class >> sourcesUrl: aUrl [ | oldUrl | - oldUrl := SourcesUrl. - SourcesUrl := aUrl. - + oldUrl := self basicSourcesUrl: aUrl. oldUrl = SourcesUrl ifTrue: [ ^ self "ok" ]. + self checkForUpdates ] diff --git a/src/PharoLauncher-Core/PhLPrivateVirtualMachine.class.st b/src/PharoLauncher-Core/PhLPrivateVirtualMachine.class.st deleted file mode 100644 index 07f6ac7ca..000000000 --- a/src/PharoLauncher-Core/PhLPrivateVirtualMachine.class.st +++ /dev/null @@ -1,27 +0,0 @@ -" -I represent a Pharo virtual machine used to determine an image phar version by running it with a VM compatible with its image format. - - ex: 6505 6521 68021 - -" -Class { - #name : #PhLPrivateVirtualMachine, - #superclass : #PhLVirtualMachine, - #category : #'PharoLauncher-Core-Download' -} - -{ #category : #testing } -PhLPrivateVirtualMachine class >> isSubclassForDirectory: aFileReference private: isPrivateVm [ - ^ isPrivateVm -] - -{ #category : #querying } -PhLPrivateVirtualMachine >> downloadUrl [ - ^ self manager compatibleVmUrls - at: self name asInteger -] - -{ #category : #accessing } -PhLPrivateVirtualMachine >> vmStore [ - ^ self manager privateVmStore -] diff --git a/src/PharoLauncher-Core/PhLRemoteTemplate.class.st b/src/PharoLauncher-Core/PhLRemoteTemplate.class.st index 722ea1db1..97b4d1fed 100644 --- a/src/PharoLauncher-Core/PhLRemoteTemplate.class.st +++ b/src/PharoLauncher-Core/PhLRemoteTemplate.class.st @@ -15,6 +15,15 @@ PhLRemoteTemplate class >> example [ ^ self name: 'Pharo Mooc' url: 'https://mooc.pharo.org/image/PharoWeb.zip' ] +{ #category : #'instance creation' } +PhLRemoteTemplate class >> name: aString shortName: shortNameString url: anUrl username: anotherString password: yetAnotherString [ + ^ (self name: aString url: anUrl) + shortName: shortNameString; + username: anotherString; + password: yetAnotherString; + yourself +] + { #category : #'instance creation' } PhLRemoteTemplate class >> name: aString url: anUrl [ ^ self new @@ -24,10 +33,7 @@ PhLRemoteTemplate class >> name: aString url: anUrl [ { #category : #'instance creation' } PhLRemoteTemplate class >> name: aString url: anUrl username: anotherString password: yetAnotherString [ - ^ (self name: aString url: anUrl) - username: anotherString; - password: yetAnotherString; - yourself + ^ self name: aString shortName: nil url: anUrl username: anotherString password: yetAnotherString ] { #category : #comparing } diff --git a/src/PharoLauncher-Core/PhLShowImageInFolderCommand.class.st b/src/PharoLauncher-Core/PhLShowImageInFolderCommand.class.st index faa6f4f83..aa5ec5404 100644 --- a/src/PharoLauncher-Core/PhLShowImageInFolderCommand.class.st +++ b/src/PharoLauncher-Core/PhLShowImageInFolderCommand.class.st @@ -18,6 +18,8 @@ PhLShowImageInFolderCommand >> asSpecCommand [ { #category : #executing } PhLShowImageInFolderCommand >> execute [ + + self imagesPresenter hasSingleImageSelected ifFalse: [ ^self ]. self imagesPresenter singleImage showNativeFolder ] diff --git a/src/PharoLauncher-Core/PhLTemplateGroupRepository.class.st b/src/PharoLauncher-Core/PhLTemplateGroupRepository.class.st index c7d353ea7..fad94d802 100644 --- a/src/PharoLauncher-Core/PhLTemplateGroupRepository.class.st +++ b/src/PharoLauncher-Core/PhLTemplateGroupRepository.class.st @@ -163,3 +163,10 @@ PhLTemplateGroupRepository >> templateNamed: aTemplateName inCategoryNamed: aCat category := self categoryNamed: aCategoryName. ^ category templateNamed: aTemplateName ] + +{ #category : #querying } +PhLTemplateGroupRepository >> templateShortNamed: aTemplateName inCategoryNamed: aCategoryName [ + | category | + category := self categoryNamed: aCategoryName. + ^ category templateShortNamed: aTemplateName +] diff --git a/src/PharoLauncher-Core/PhLTemplateSource.class.st b/src/PharoLauncher-Core/PhLTemplateSource.class.st index db69c421f..0e8a222f8 100644 --- a/src/PharoLauncher-Core/PhLTemplateSource.class.st +++ b/src/PharoLauncher-Core/PhLTemplateSource.class.st @@ -10,6 +10,7 @@ Class { #instVars : [ 'type', 'name', + 'shortName', 'url', 'filterPattern', 'templates', @@ -293,6 +294,7 @@ PhLTemplateSource >> asTemplate [ type == self class urlType ifTrue: [ ^ PhLRemoteTemplate name: name + shortName: shortName url: url asUrl username: username password: password ]. @@ -356,6 +358,11 @@ PhLTemplateSource >> printOn: aStream [ nextPut: $) ] +{ #category : #accessing } +PhLTemplateSource >> shortName [ + ^ shortName +] + { #category : #accessing } PhLTemplateSource >> templateNameFormat [ ^ templateNameFormat diff --git a/src/PharoLauncher-Core/PhLTemplateSources.class.st b/src/PharoLauncher-Core/PhLTemplateSources.class.st index f388a31d0..1764dcf05 100644 --- a/src/PharoLauncher-Core/PhLTemplateSources.class.st +++ b/src/PharoLauncher-Core/PhLTemplateSources.class.st @@ -128,13 +128,13 @@ PhLTemplateSources >> initializeWith: aSourcesFile [ { #category : #accessing } PhLTemplateSources >> sources [ + | sources | - file exists - ifFalse: [ ^ #() ]. - - [ file readStreamDo: [ :stream | - sources := STON fromStream: stream] ] - on: STONReaderError, InstanceVariableNotFound - do: [ sources := #() ]. + file exists ifFalse: [ ^ #( ) ]. + + [ file readStreamDo: [ :stream | sources := STON fromStream: stream ] ] + on: STONReaderError , InstanceVariableNotFound + do: [ sources := #( ) ]. + ^ sources ] diff --git a/src/PharoLauncher-Core/PhLTemplateSourcesUpdateChecker.class.st b/src/PharoLauncher-Core/PhLTemplateSourcesUpdateChecker.class.st index d568491a9..bd3762f6b 100644 --- a/src/PharoLauncher-Core/PhLTemplateSourcesUpdateChecker.class.st +++ b/src/PharoLauncher-Core/PhLTemplateSourcesUpdateChecker.class.st @@ -38,6 +38,9 @@ PhLTemplateSourcesUpdateChecker class >> launcherStartUpPriority [ PhLTemplateSourcesUpdateChecker class >> run [ self shouldRun ifFalse: [ ^ self ]. + "need to manage it for command-line. Not available for now" + Smalltalk isInteractive ifFalse: [ ^ self ]. + self uniqueInstance run @@ -47,12 +50,14 @@ PhLTemplateSourcesUpdateChecker class >> run [ PhLTemplateSourcesUpdateChecker class >> settingsOn: aBuilder [ - (aBuilder setting: #shouldRun) - label: 'Check for template sources update?' translated; + (aBuilder setting: #shouldCheckTemplateSourcesUpdate) + label: 'Check for template sources update?'; parent: #pharoLauncher; target: self; + getSelector: #shouldRun; + setSelector: #shouldRun:; order: 55; - description: 'Check if Pharo Launcher Template sources has an update available (needs internet access)' translated + description: 'Check if Pharo Launcher Template sources has an update available (needs internet access)' ] { #category : #settings } diff --git a/src/PharoLauncher-Core/PhLToggleVmPrivateVmCommand.class.st b/src/PharoLauncher-Core/PhLToggleVmPrivateVmCommand.class.st deleted file mode 100644 index ae44681ba..000000000 --- a/src/PharoLauncher-Core/PhLToggleVmPrivateVmCommand.class.st +++ /dev/null @@ -1,28 +0,0 @@ -" -Toggle between display of VMs used to launch Pharo images and ""private"" VMs used to determine Pharo version of an image (one VM per image format) -" -Class { - #name : #PhLToggleVmPrivateVmCommand, - #superclass : #PhLVmCommand, - #category : #'PharoLauncher-Core-Commands' -} - -{ #category : #converting } -PhLToggleVmPrivateVmCommand >> asSpecCommand [ - ^ super asSpecCommand - iconName: #remote; - beDisplayedOnRightSide; - configureAsToolBarToggleButton; - yourself -] - -{ #category : #executing } -PhLToggleVmPrivateVmCommand >> execute [ - self vmsPresenter toggleShowVmPrivateVm. -] - -{ #category : #initialization } -PhLToggleVmPrivateVmCommand >> initialize [ - super initialize. - self name: 'public' -] diff --git a/src/PharoLauncher-Core/PhLVirtualMachine.class.st b/src/PharoLauncher-Core/PhLVirtualMachine.class.st index 65f710fc7..4eb3d6e06 100644 --- a/src/PharoLauncher-Core/PhLVirtualMachine.class.st +++ b/src/PharoLauncher-Core/PhLVirtualMachine.class.st @@ -41,18 +41,14 @@ Class { { #category : #'instance creation' } PhLVirtualMachine class >> directory: aFileReference [ - ^ self - directory: aFileReference - private: false -] -{ #category : #'instance creation' } -PhLVirtualMachine class >> directory: aFileReference private: isPrivateVm [ | targetClass | - targetClass := self allSubclasses detect: [ :cls | cls isSubclassForDirectory: aFileReference private: isPrivateVm ] ifNone: [ self ]. - ^ targetClass new - initializeOn: aFileReference; - yourself + targetClass := self allSubclasses + detect: [ :cls | cls isSubclassForDirectory: aFileReference ] + ifNone: [ self ]. + ^ targetClass new + initializeOn: aFileReference; + yourself ] { #category : #accessing } @@ -80,9 +76,9 @@ PhLVirtualMachine class >> id: aString [ ] { #category : #testing } -PhLVirtualMachine class >> isSubclassForDirectory: aFileReference private: isPrivateVm [ +PhLVirtualMachine class >> isSubclassForDirectory: aFileReference [ - ^ isPrivateVm not and: [ aFileReference basename beginsWith: self versionPrefix ] + ^ aFileReference basename beginsWith: self versionPrefix ] { #category : #accessing } @@ -356,7 +352,7 @@ PhLVirtualMachine >> removeFromSystem [ { #category : #actions } PhLVirtualMachine >> showInFolder [ - PhLFileBrowser openOn: self vmStore / self id + (self vmStore / self id) asFileReference openInOSFileBrowser ] { #category : #'ston persistence' } diff --git a/src/PharoLauncher-Core/PhLVirtualMachineManager.class.st b/src/PharoLauncher-Core/PhLVirtualMachineManager.class.st index c309c6919..f78f4b37f 100644 --- a/src/PharoLauncher-Core/PhLVirtualMachineManager.class.st +++ b/src/PharoLauncher-Core/PhLVirtualMachineManager.class.st @@ -117,12 +117,6 @@ PhLVirtualMachineManager class >> pharoUnzip: aZipFileReference to: outputDirect overwrite: true ] ] -{ #category : #private } -PhLVirtualMachineManager class >> privateVmStore [ - "The private store is used to fetch one VM per image format and open image to determine their pharo version number (e.g. 6.0, 7.0, etc.). Then we download the latest stable VM for the given Pharo image version." - ^ (self vmStore / 'private') ensureCreateDirectory -] - { #category : #initialization } PhLVirtualMachineManager class >> reset [
h5ai 0.22.1⚡ JavaScript is disabled! ⚡⚡ Some features disabled! Works best in modern browsers. ⚡
' +] + +{ #category : #helpers } +PhLHTTPListingTemplateGroupTest >> pharo12ExampleUrl [ + ^ 'https://files.pharo.org/image/120/' asZnUrl +] + { #category : #running } PhLHTTPListingTemplateGroupTest >> setUp [ super setUp. - self downloadManager atUrl: self exampleUrl answer: self exampleContent + self downloadManager atUrl: self exampleUrl answer: self exampleContent. + self downloadManager atUrl: self pharo12ExampleUrl answer: self pharo12ExampleContent +] + +{ #category : #tests } +PhLHTTPListingTemplateGroupTest >> testCanMatchPharo12Templates [ + | group templatesAndGroups | + group := self newPharo12Group. + + templatesAndGroups := group templatesAndGroups. + + self assert: (templatesAndGroups noneSatisfy: [ :template | template isTemplateGroup ]). + self + assertCollection: (templatesAndGroups collect: #name) + hasSameElements: #('Pharo12.0-SNAPSHOT.build.1329.sha.25a911c.arch.64bit' + 'Pharo12.0-SNAPSHOT.build.1328.sha.10f5de5.arch.64bit' + 'Pharo12-SNAPSHOT.build.1229.sha.ed99075.arch.64bit' + 'Pharo12-SNAPSHOT.build.1228.sha.826d9bb.arch.64bit') ] { #category : #tests } diff --git a/src/PharoLauncher-Tests-Functional/PhLLaunchImageTest.class.st b/src/PharoLauncher-Tests-Functional/PhLLaunchImageTest.class.st index b3b3e003e..c7df9637f 100644 --- a/src/PharoLauncher-Tests-Functional/PhLLaunchImageTest.class.st +++ b/src/PharoLauncher-Tests-Functional/PhLLaunchImageTest.class.st @@ -81,7 +81,7 @@ PhLLaunchImageTest >> tearDown [ { #category : #tests } PhLLaunchImageTest >> testArchitectureErrorSignaledWhenTryingToRun32BitImageOn64BitOnlyOS [ | image | - image := PhLOsXMojaveTestImage example32. + image := PhLOsXCatalinaTestImage example32. self should: [ process := image launchWithConfiguration: nil ] @@ -118,12 +118,11 @@ PhLLaunchImageTest >> testCanLaunchImageWithNonAsciiCharactersUsingLoginShell [ { #category : #tests } PhLLaunchImageTest >> testCanRun64bitImageOn64BitOnlyOS [ | image config commandToEval | - image := PhLOsXMojaveTestImage example. + image := PhLOsXCatalinaTestImage example. + image pharoVersion: '80'. commandToEval := '"''' , imageDir fullName , '/result'' asFileReference writeStreamDo:[ :s | s nextPutAll: (1 + 1) asString ]"'. config := image defaultLaunchConfiguration. - config - vm: self pharo80x86Vm; - imageArguments: {'eval' . commandToEval}. + config imageArguments: {'eval' . commandToEval}. self shouldnt: [ process := image launchWithConfiguration: config ] diff --git a/src/PharoLauncher-Tests-Functional/PhLOsXCatalinaTestImage.class.st b/src/PharoLauncher-Tests-Functional/PhLOsXCatalinaTestImage.class.st new file mode 100644 index 000000000..35bbc7a52 --- /dev/null +++ b/src/PharoLauncher-Tests-Functional/PhLOsXCatalinaTestImage.class.st @@ -0,0 +1,20 @@ +" +Class used for test purpose. +I override the default OS to return Mac Os Catalina 10.15. +It is used to test support of 32-bit app as Mac Os Catalina is the first Mac Os version to drop support of 32-bit apps. +" +Class { + #name : #PhLOsXCatalinaTestImage, + #superclass : #PhLImage, + #category : #'PharoLauncher-Tests-Functional' +} + +{ #category : #testing } +PhLOsXCatalinaTestImage class >> isSubclassForLocation: aFileReference [ + ^ false +] + +{ #category : #'private - accessing' } +PhLOsXCatalinaTestImage >> os [ + ^ TestMacOSXCatalinaPlatform new +] diff --git a/src/PharoLauncher-Tests-Functional/PhLOsXMojaveTestImage.class.st b/src/PharoLauncher-Tests-Functional/PhLOsXMojaveTestImage.class.st deleted file mode 100644 index ea9623616..000000000 --- a/src/PharoLauncher-Tests-Functional/PhLOsXMojaveTestImage.class.st +++ /dev/null @@ -1,19 +0,0 @@ -" -Class used for test purpose. -I override the default OS to return OS X Mojave 10.15 (used to test support of 32-bit app) -" -Class { - #name : #PhLOsXMojaveTestImage, - #superclass : #PhLImage, - #category : #'PharoLauncher-Tests-Functional' -} - -{ #category : #testing } -PhLOsXMojaveTestImage class >> isSubclassForLocation: aFileReference [ - ^ false -] - -{ #category : #'private - accessing' } -PhLOsXMojaveTestImage >> os [ - ^ TestMacOSXMojavePlatform new -] diff --git a/src/PharoLauncher-Tests-Functional/PhLPrivateVirtualMachineTest.class.st b/src/PharoLauncher-Tests-Functional/PhLPrivateVirtualMachineTest.class.st deleted file mode 100644 index a50872a20..000000000 --- a/src/PharoLauncher-Tests-Functional/PhLPrivateVirtualMachineTest.class.st +++ /dev/null @@ -1,18 +0,0 @@ -Class { - #name : #PhLPrivateVirtualMachineTest, - #superclass : #TestCase, - #traits : 'TPhLVirtualMachineTestUtil', - #classTraits : 'TPhLVirtualMachineTestUtil classTrait', - #category : 'PharoLauncher-Tests-Functional' -} - -{ #category : #tests } -PhLPrivateVirtualMachineTest >> testCanGetDownloadUrl [ - | vm | - vm := PhLPrivateVirtualMachine new - basicInitializeOn: FileSystem memory / '6521'; - yourself. - self - assert: (self replaceOSByMacIn: vm downloadUrl) - equals: 'https://files.pharo.org/get-files/70/pharo-mac-stable.zip' -] diff --git a/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerFunctionalTest.class.st b/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerFunctionalTest.class.st index c7f3add70..0d548ee5a 100644 --- a/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerFunctionalTest.class.st +++ b/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerFunctionalTest.class.st @@ -45,88 +45,16 @@ PhLVirtualMachineManagerFunctionalTest >> testCanDetectSystemUnzip [ { #category : #tests } PhLVirtualMachineManagerFunctionalTest >> testCanGetImageVersion [ - | version | - self timeLimit: 30 seconds. - - PhLVirtualMachineManagerTestResource current - withCopyOfPharo90ImageDo: [ :imageRef | - version := (PhLVirtualMachineManager forImage: imageRef) - imageVersion. - self assert: version equals: '90' ] -] - -{ #category : #tests } -PhLVirtualMachineManagerFunctionalTest >> testCanGetImageVersionFromFileWhenRunningExtraVM [ - - | vmManager | - self timeLimit: 30 seconds. - - PhLVirtualMachineManagerTestResource current - withCopyOfPharo90ImageDo: [ :imageRef | - vmManager := PhLVirtualMachineManager forImage: imageRef. - vmManager imageVersionFile ensureDelete. - - self assert: vmManager imageVersion equals: '90' ] -] - -{ #category : #tests } -PhLVirtualMachineManagerFunctionalTest >> testCanGetImageVersionFromFileWithRightCommand [ - | vmManager command | - self timeLimit: 30 seconds. - - vmManager := PhLVirtualMachineManager forImage: Smalltalk image lastImagePath. - vmManager imageVersionFile ensureDelete. - command := PhLProcessWrapper new - shellCommand; - addArguments: 'echo 60 >'; - addArgument: vmManager imageVersionFile fullName surroundedByDoubleQuotes. - - self - assert: (vmManager imageVersionFromFileWith: command) - equals: '60' -] - -{ #category : #tests } -PhLVirtualMachineManagerFunctionalTest >> testCanGetImageVersionFromPharo14Image [ - - | vmManager | - self skip: 'skip this test for now to allow a release soon'. - self timeLimit: 60 seconds. - - PhLVirtualMachineManagerTestResource current - withCopyOfPharo14ImageDo: [ :imageRef | - vmManager := PhLVirtualMachineManager forImage: imageRef. - vmManager imageVersionFile ensureDelete. - - self assert: vmManager imageVersion equals: '14' ] -] - -{ #category : #tests } -PhLVirtualMachineManagerFunctionalTest >> testGetExceptionWhenRunningImageVersionFromFileWithBadCommand [ - - | vmManager command | - command := PhLProcessWrapper new - shellCommand; - addArgument: 'foo'. - - PhLVirtualMachineManagerTestResource current - withCopyOfPharo90ImageDo: [ :imageRef | - vmManager := PhLVirtualMachineManager forImage: imageRef. - vmManager imageVersionFile ensureDelete. - - self - should: [ vmManager imageVersionFromFileWith: command ] - raise: PhLImageVersionDeterminationError ] -] - -{ #category : #tests } -PhLVirtualMachineManagerFunctionalTest >> testImageVersionDeterminationIsRunWithoutSettings [ - | manager command | - manager := PhLVirtualMachineManager forImage: Smalltalk image lastImagePath. + | vmManager expectedVersion imageRef | - command := manager imageVersionCommandWithPreferences: false. - self assert: (command arguments includes: '--no-default-preferences') + expectedVersion := '110'. + imageRef := PhLVirtualMachineManagerTestResource current workspace / 'Pharo.image'. + vmManager := PhLVirtualMachineManager forImage: imageRef. + vmManager imageVersionFile ensureDelete. + vmManager imageVersionFile writeStreamDo: [ :stream | stream nextPutAll: expectedVersion ]. + + self assert: vmManager imageVersion equals: expectedVersion ] { #category : #tests } diff --git a/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerTestResource.class.st b/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerTestResource.class.st index b6ea71144..379c52275 100644 --- a/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerTestResource.class.st +++ b/src/PharoLauncher-Tests-Functional/PhLVirtualMachineManagerTestResource.class.st @@ -31,15 +31,6 @@ PhLVirtualMachineManagerTestResource >> cleanWorkspace [ ensureCreateDirectory. ] -{ #category : #downloading } -PhLVirtualMachineManagerTestResource >> downloadCompatibleVm64Bit [ - | vmManager | - vmManager := PhLVirtualMachineManager forImage: self pharo90image. - vmManager availableVirtualMachinesByImageFormat - at: vmManager imageFormatNumber asString - ifAbsent: [ vmManager fetchCompatibleVm ] -] - { #category : #downloading } PhLVirtualMachineManagerTestResource >> downloadPharo14Image [ diff --git a/src/PharoLauncher-Tests-Functional/PhLVirtualMachineTest.class.st b/src/PharoLauncher-Tests-Functional/PhLVirtualMachineTest.class.st index c9c35124d..aee3fb13b 100644 --- a/src/PharoLauncher-Tests-Functional/PhLVirtualMachineTest.class.st +++ b/src/PharoLauncher-Tests-Functional/PhLVirtualMachineTest.class.st @@ -32,6 +32,7 @@ PhLVirtualMachineTest >> testCanDetect64BitArchPath [ PhLVirtualMachineTest >> testCanDetectExecutablePath [ "WARNING: this test is Linux specific!" | vm vmFolder | + self onPharoCITestingEnvironment ifFalse: [ self skip ]. Smalltalk os isWindows ifTrue: [ self skip. ^ self ]. vmFolder := FileLocator imageDirectory asFileReference / 'pharo-vm'. @@ -43,8 +44,9 @@ PhLVirtualMachineTest >> testCanDetectExecutablePath [ { #category : #tests } PhLVirtualMachineTest >> testCanDetectVMDirectory [ - "WARNING: this test is Linux specific!" + "WARNING: this test is CI and Linux specific!" | vm | + self onPharoCITestingEnvironment ifFalse: [ self skip ]. Smalltalk os isWindows ifTrue: [ self skip. ^ self ]. vm := PhLVirtualMachine directory: FileLocator imageDirectory asFileReference / 'pharo-vm'. diff --git a/src/PharoLauncher-Tests-Functional/TestMacOSXCatalinaPlatform.class.st b/src/PharoLauncher-Tests-Functional/TestMacOSXCatalinaPlatform.class.st new file mode 100644 index 000000000..1f72479dc --- /dev/null +++ b/src/PharoLauncher-Tests-Functional/TestMacOSXCatalinaPlatform.class.st @@ -0,0 +1,13 @@ +" +I'm used to represent a Mac OS X Catalina operating system for test purposes. +" +Class { + #name : #TestMacOSXCatalinaPlatform, + #superclass : #MacOSXPlatform, + #category : #'PharoLauncher-Tests-Functional' +} + +{ #category : #accessing } +TestMacOSXCatalinaPlatform >> version [ + ^ '1015.1' +] diff --git a/src/PharoLauncher-Tests-Functional/TestMacOSXMojavePlatform.class.st b/src/PharoLauncher-Tests-Functional/TestMacOSXMojavePlatform.class.st deleted file mode 100644 index 3db72a4fd..000000000 --- a/src/PharoLauncher-Tests-Functional/TestMacOSXMojavePlatform.class.st +++ /dev/null @@ -1,13 +0,0 @@ -" -I'm used to represent a Mac OS X Mojave operating system for test purposes -" -Class { - #name : #TestMacOSXMojavePlatform, - #superclass : #MacOSXPlatform, - #category : #'PharoLauncher-Tests-Functional' -} - -{ #category : #accessing } -TestMacOSXMojavePlatform >> version [ - ^ '1015.1' -] diff --git a/src/PharoLauncher-Tests-SpecUI/PhLImagesPresenterTest.class.st b/src/PharoLauncher-Tests-SpecUI/PhLImagesPresenterTest.class.st index 00f020eb2..254e6f1f4 100644 --- a/src/PharoLauncher-Tests-SpecUI/PhLImagesPresenterTest.class.st +++ b/src/PharoLauncher-Tests-SpecUI/PhLImagesPresenterTest.class.st @@ -9,7 +9,7 @@ Class { { #category : #running } PhLImagesPresenterTest >> tearDown [ - presenter window ifNotNil: #close. + presenter window ifNotNil: [ :window | window close]. super tearDown ] diff --git a/test/PharoLauncherCommonFunctions.sh b/test/PharoLauncherCommonFunctions.sh index 8ae9f1268..54f2f6a25 100644 --- a/test/PharoLauncherCommonFunctions.sh +++ b/test/PharoLauncherCommonFunctions.sh @@ -59,7 +59,7 @@ prepareLauncherScriptAndImage () { # ensure that launcher script and image are in needed directories for test evaluation (before packaging) pushd .. > /dev/null if [ ! -f "$PHL_SCRIPT" ] ; then - cp ./script/pharo-launcher.sh $PHL_SCRIPT + cp ./scripts/pharo-launcher.sh $PHL_SCRIPT fi detectPharoLauncherImagePath if [ ! -f "$IMAGE" ] ; then diff --git a/test/testImageCommands.sh b/test/testImageCommands.sh index 5baec2857..d86faef7a 100755 --- a/test/testImageCommands.sh +++ b/test/testImageCommands.sh @@ -14,7 +14,7 @@ SAMPLE_IMAGE_PATH="$HOME"/Pharo/images/$SAMPLE_IMAGE # setup commands for sample image manipulation createSampleImageCommand () { - runLauncherScript image create $SAMPLE_IMAGE --templateName "$SAMPLE_TEMPLATE" + runLauncherScript image create $SAMPLE_IMAGE --no-launch --templateName "$SAMPLE_TEMPLATE" cp -f "$ROOT"/$IMAGE_METADATA_FILE $SAMPLE_IMAGE_PATH/$IMAGE_METADATA_FILE } @@ -23,7 +23,7 @@ launchSampleImageCommand () { } killSampleImageCommand () { - runLauncherScript image kill $SAMPLE_IMAGE + runLauncherScript process kill $SAMPLE_IMAGE } deleteSampleImageCommand () { @@ -31,7 +31,7 @@ deleteSampleImageCommand () { } processListCommand () { - runLauncherScript image processList + runLauncherScript process list } killAllCommand () { diff --git a/windows/build-launcher-installer.bat b/windows/build-launcher-installer.bat deleted file mode 100644 index 862ca26a7..000000000 --- a/windows/build-launcher-installer.bat +++ /dev/null @@ -1,25 +0,0 @@ -SETLOCAL - -REM VERSION cannot be a string in Advanced Installer. Let's use 0.0.0 for bleeding edge versions -SET LAUNCHER_VERSION=%INSTALLER_VERSION:bleedingEdge=0.0.0% - -REM ADVINST env variable has to set to C:\Program Files (x86)\Caphyon\Advanced Installer x.x.x\bin\x86\ -REM You can set it with setx /M ADVINST "PATH". Do not gorget to restart the slave to see the new var. -SET PATH=%PATH%;%ADVINST%; -SET ADVINST_PROJECT=pharo-launcher.aip -SET ADVINST_COMMAND_FILE=pharo-launcher.aic - -SET PHARO_WIN_DIR="Pharo-win\Pharo" -REM cd% will give you the current working directory (variable) -REM %~dp0 will give you the full path to the batch file's directory (static) -SET OUT_DIR=%~dp0 - -REM Advanced Installer working directory is the directory where the AIP file stands -COPY icons\pharo-launcher.ico windows\ -MKDIR windows\Pharo-win -MOVE Pharo windows\Pharo-win\Pharo - -cd windows -REM "%ADVINST%\AdvancedInstaller.com" /newproject $ADVINST_PROJECT -lang en -overwrite -"%ADVINST%\AdvancedInstaller.com" /execute "%ADVINST_PROJECT%" "%ADVINST_COMMAND_FILE%" -MOVE pharo-launcher.msi ..\pharo-launcher-%VERSION%.msi diff --git a/windows/pharo-launcher-installer-builder.nsi b/windows/pharo-launcher-installer-builder.nsi deleted file mode 100644 index 089f3dc92..000000000 --- a/windows/pharo-launcher-installer-builder.nsi +++ /dev/null @@ -1,123 +0,0 @@ -!define APPNAME "PharoLauncher" -!define DESCRIPTION "Manage your Pharo images easily" -!define VERSIONMAJOR 1 -!define VERSIONMINOR 1 - -# These will be displayed by the "Click here for support information" link in "Add/Remove Programs" -# It is possible to use "mailto:" links in here to open the email client -!define HELPURL "mailto://pharo-users@lists.pharo.org" # "Support Information" link -!define UPDATEURL "https://github.com/pharo-project/pharo-launcher/releases" # "Product Updates" link -!define ABOUTURL "https://github.com/pharo-project/pharo-launcher" # "Publisher" link - -# This is the size (in kB) of all the files copied into "Program Files" -!define INSTALLSIZE 69664 - -InstallDir "$LOCALAPPDATA\${APPNAME}" - -# rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n) -# LicenseData "license.rtf" - -Name "${APPNAME}" -Icon "pharo-launcher.ico" -outfile "pharo-launcher-installer.exe" - -!include LogicLib.nsh - -# Just three pages - license agreement, install location, and installation -# page license -page directory -Page instfiles - -function .onInit - setShellVarContext all -functionEnd - -section "install" - # Files for the install directory - to build the installer, these should be in the same directory as the install script (this file) - # Files added here should be removed by the uninstaller (see section "uninstall") - setOutPath $INSTDIR - file pharo-launcher.ico - # you can use the following command to generate the list of files needed by the Pharo VM: - # find Pharo -depth 1 -type f -not -iname "*.zip" -exec bash -c 'file=$(basename {}); echo "file Pharo-win\Pharo\\$file"' \; - - file Pharo-win\Pharo\FT2Plugin.dll - file Pharo-win\Pharo\iconv.dll - file Pharo-win\Pharo\libcairo-2.dll - file Pharo-win\Pharo\libeay32.dll - file Pharo-win\Pharo\libfreetype.dll - file Pharo-win\Pharo\libgcc_s_sjlj-1.dll - file Pharo-win\Pharo\libgit2.dll - file Pharo-win\Pharo\libpixman-1-0.dll - file Pharo-win\Pharo\libpng16-16.dll - file Pharo-win\Pharo\libssh2-1.dll - file Pharo-win\Pharo\libwinpthread-1.dll - file Pharo-win\Pharo\Pharo.changes - file Pharo-win\Pharo\Pharo.exe - file Pharo-win\Pharo\Pharo.image - file Pharo-win\Pharo\Pharo.ini - file Pharo-win\Pharo\PharoConsole.exe - file Pharo-win\Pharo\PharoV60.sources - file Pharo-win\Pharo\ProcessWrapperPlugin.dll - file Pharo-win\Pharo\README.txt - file Pharo-win\Pharo\SDL2.dll - file Pharo-win\Pharo\SqueakSSL.dll - file Pharo-win\Pharo\ssleay32.dll - file Pharo-win\Pharo\SurfacePlugin.dll - file Pharo-win\Pharo\zlib1.dll - - # find Pharo -type d -depth 1 -exec bash -c 'file=$(basename {}); echo "file /r Pharo-win\Pharo\\$file"' \; - file /r Pharo-win\Pharo\images - - # Uninstaller - See function un.onInit and section "uninstall" for configuration - writeUninstaller "$INSTDIR\uninstall.exe" - - # Start Menu - createDirectory "$SMPROGRAMS\${APPNAME}" - createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\pharo.exe" "" "$INSTDIR\pharo-launcher.ico" - - # Registry information for add/remove programs - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME} - ${DESCRIPTION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$\"$INSTDIR\pharo-launcher.ico$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "$\"${APPNAME}$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "HelpLink" "$\"${HELPURL}$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "$\"${VERSION}$\"" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "VersionMajor" ${VERSIONMAJOR} - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "VersionMinor" ${VERSIONMINOR} - # There is no option for modifying or repairing the install - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" 1 - # Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "EstimatedSize" ${INSTALLSIZE} -sectionEnd - -# Uninstaller - -function un.onInit - SetShellVarContext all - - #Verify the uninstaller - last chance to back out - MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}?" IDCANCEL - Abort -functionEnd - -section "uninstall" - - # Remove Start Menu launcher - delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" - # Try to remove the Start Menu folder - this will only happen if it is empty - rmDir "$SMPROGRAMS\${APPNAME}" - - # Delete Files - rmDir /r "$INSTDIR\*.*" - - #Remove the installation directory - rmDir "$INSTDIR" - - # Remove uninstaller information from the registry - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" -sectionEnd diff --git a/windows/pharo-launcher.aic b/windows/pharo-launcher.aic deleted file mode 100755 index 5fdca85b9..000000000 --- a/windows/pharo-launcher.aic +++ /dev/null @@ -1,15 +0,0 @@ -;aic -SetVersion %LAUNCHER_VERSION% - -AddFile APPDIR "..\icons\pharo-launcher.ico" -AddFolder APPDIR %PHARO_WIN_DIR% -install_in_parent_folder - -; Target dir MUST refers to the path included in the installer and not to the final destination -NewShortcut -name PharoLauncher -dir DesktopFolder -wkdir APPDIR -target APPDIR\Pharo\Pharo.exe -arg Pharo.image -icon pharo-launcher.ico -NewShortcut -name PharoLauncher -dir ProgramMenuFolder -wkdir APPDIR -target APPDIR\Pharo\Pharo.exe -arg Pharo.image -icon pharo-launcher.ico -NewShortcut -name PharoLauncher -dir APPDIR -wkdir APPDIR -target APPDIR\Pharo\Pharo.exe -arg Pharo.image -icon pharo-launcher.ico - -SetAppdir -buildname DefaultBuild -path [LocalAppDataFolder]\[ProductName] -; Save -SetOutputLocation -buildname DefaultBuild -path %OUT_DIR% -Rebuild \ No newline at end of file diff --git a/windows/pharo-launcher.aip b/windows/pharo-launcher.aip deleted file mode 100755 index ddcdd6915..000000000 --- a/windows/pharo-launcher.aip +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -