Skip to content

Added StellarEnv to manage and communicate with stellar installed versions#24

Merged
albertodebortoli merged 86 commits intomasterfrom
feature/13-stellar-env
Mar 11, 2023
Merged

Added StellarEnv to manage and communicate with stellar installed versions#24
albertodebortoli merged 86 commits intomasterfrom
feature/13-stellar-env

Conversation

@malcommac
Copy link
Contributor

@malcommac malcommac commented Feb 5, 2023

This PR introduces a new CLI tool called stellarenv (note: it must be called stellar via shell).
Stellar is composed by two CLI tools.

BEFORE TEST

Since our private repo, we need to perform authenticated requests to GitHub APIs.
Create your own token and put into ~./stellar/GITHUB-TOKEN file. It will be used automatically by our tools to perform authenticated requests.

stellar

This is the CLI tool you can use to perform automation.
You can have more than one version installed; all the files related to a particular version, including the binary itself, are under the ~/.stellar/Versions directory.

stellarenv

This CLI tool is installed in /usr/local/bin.
It offers functions to update stellar installations and also itself.

Once called, it has two different behaviors:

  • if called command is one of the commands available in stellarenv, it just executes the command
  • if called command is not recognized, it just fallback to one of the versions of the StellarCLI tool installed

How the correct version binary is picked from /Versions?
The VersionResolver.swift class does the following checks into the current working directory:

  • If you have a .stellar-bin folder with a complete stellar installation, it will resolve to that
  • If you have specified a .stellar-version file with a valid version. If the version is not present locally, it will execute an install automatically.

Install_private.sh

A copy of the install.sh called install_private.sh was created to support the installation of stellarenv until the repository became public.
Once called:

  • it gets the latest release of the project
  • download the StellarEnv.zip package and install it in /usr/local/bin
  • call stellarenv install to install the StellarCLI (latest version) in ~/.stellar/Version subdirectory

stellarenv COMMANDS

install

The following command is used to install a specific version of stellar.
You can call it by adding the version parameter or not; if not passed, the latest stable release will be installed.
When you don't specify version, you can also set pre-release parameter to install the latest pre-release available.

  • stellar install 0.0.4: install stellar 0.0.4
  • stellar install: install the latest stable release available
  • stellar install pre-release: install the latest pre-release available

update

This command checks for updates of both the ENV and CLI tools.

  • stellarenv update update both stellar and stellarenv to the latest stable remote version.

local

This command creates a .stellar-version file to pin the stellar version that should be used in the current directory.
If the version parameter is not specified, it just prints the locally installed versions of stellar (the ones you can find in ~/.stellar/Versions folder).

  • stellarenv local: print installed versions
  • stellarenv local 0.0.4: pin the project at the current working directory to the passed version

list

The following command lists the remote versions of stellar by using GitHub APIs.
It includes the pre-release parameter, which includes or excludes pre-releases from the list.

  • stellarenv list: list all stable releases of the stellar package
  • stellarenv list pre-releases: also includes releases marked as pre-releases in GitHub releases

bundle

Bundles the version specified in the .stellar-version file in CWD into the .stellar-bin directory (eventually download specified release if unavailable locally).

  • stellarenv bundle: from the CWD (.stellar-version is required on cwd btw)

@malcommac malcommac changed the title WIP: #13: Create stellarenv to handle stellar versions #13: Create stellarenv to handle list, installation, update of the tool Feb 19, 2023
@malcommac malcommac requested review from albertodebortoli and xl4kj and removed request for albertodebortoli February 19, 2023 16:24
@malcommac malcommac requested review from albertodebortoli and removed request for xl4kj February 19, 2023 16:24
@malcommac malcommac added the enhancement New feature or request label Feb 19, 2023
@malcommac malcommac changed the title #13: Create stellarenv to handle list, installation, update of the tool Create stellarenv to handle list, installation, update of the tool Feb 20, 2023
@malcommac malcommac self-assigned this Feb 20, 2023
@malcommac
Copy link
Contributor Author

@albertodebortoli @xl4kj
Changes since the last revision:

  • Fixed the command forwarder; it should now work fine (it was a bug in the name of the stellar CLI bin)
  • Added the bundle command, which bundles the version specified in the .stellar-version file into the .stellar-bin directory
  • Minor renaming of the classes which are now under Services directory

@malcommac malcommac changed the title Create stellarenv to handle list, installation, update of the tool Added StellarEnv to manage and communicate with stellar installed versions Mar 11, 2023
Copy link
Member

@albertodebortoli albertodebortoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PS brings in an amazing addition! Some things are still pending but we agreed to address them separately as the PR is quite big and we want to have all changes in master to more easily move on.

@malcommac top stuff! 🎉 🌟

@albertodebortoli albertodebortoli added this to the 0.1.0 milestone Mar 11, 2023
@albertodebortoli albertodebortoli merged commit a25c487 into master Mar 11, 2023
@albertodebortoli albertodebortoli deleted the feature/13-stellar-env branch March 11, 2023 17:54
albertodebortoli added a commit that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants