scriptcs-contrib / svm

scriptcs version manager
Apache License 2.0
43 stars 13 forks source link

Rewrite in Go for v1.0 #83

Open paulbouwer opened 8 years ago

paulbouwer commented 8 years ago

Design Notes - svm v1.0

Overview

svm is being rewritten in Go for v1.0. The decision was made to allow a common codebase across OSX, Linux and Windows. This will also make it easier to have consistent functionality - managing this across the original PowerShell and bash scripts was becoming painful.

.NET Native was a consideration, but at this point, Go is more mature as an option.

Commands

The commands supported by svm will have some subtle changes. At a high level the commands are reflected below:

> svm help

    ______   ______ ___ 
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/ 
             scriptcs version manager 1.0

 Usage
    svm <command> [arguments]

 Display general help or help for a given command
    svm help [<command>]

 Display svm version
    svm <-v|--version>

 Commands

    install     Install a scriptcs version.
    uninstall   Uninstall a scriptcs version.

    list        List scriptcs versions.
    info        Display detailed scriptcs version information.
    set         Set the active scriptcs version.
    unset       Unset the active scriptcs version.

    upgrade     Upgrade svm.

Version

This will display the version of svm.

> svm --version

    ______   ______ ___ 
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/ 
             scriptcs version manager 1.0

Install

 > svm help install

    ______   ______ ___                                                                                                                               
   / ___/ | / / __ `__ \                                                                                                                              
  (__  )| |/ / / / / / /                                                                                                                              
 /____/ |___/_/ /_/ /_/                                                                                                                               
             scriptcs version manager 1.0                                                                                                             

 Description                                                                                                                                          
   Install a scriptcs version. If this is the only version installed, then it will be automatically set as the active version at a global level.      

 Usage                                                                                                                                                
   svm install <version|latest>                                                                                                                       
   svm install <version> <-f|--from> <path> [<-s|--snapshot>]                                                                                         
   svm install <version> <-f|--from> <url>                                                                                                            

 svm install <version|latest>                                                                                                                         

   Install scriptcs version indicated by <version>. If <latest> is provided, then the latest stable scriptcs version available will be downloaded and installed.                                                                                                                                            

   Examples                                                                                                                                           

   > svm install 0.16.1                                                                                                                               
   > svm install 0.16.0                                                                                                                               
   > svm install latest                                                                                                                               

 svm install <version> <-f|--from> <path> [<-s|--snapshot>]                                                                                           

   Install scriptcs version from path <path> as version <version>. Path may be a local folder or a local NuGet package. If Path is a local folder, then a soft link to the local folder is created. Use the --snapshot option to create a snapshot of the local folder instead of a soft link.              

   Examples                                                                                                                                           

   > svm install devbuild -f 'C:\scriptcs\artifacts\Release\bin'                                                                                      
   > svm install mysnapshot --from 'C:\scriptcs\artifacts\Release\bin' --snapshot                                                                     
   > svm install 0.15.0 --from 'C:\Downloads\ScriptCs.0.15.0.nupkg'                                                                                   

 svm install <version> <-f|--from> <url>                                                                                                              

   Install scriptcs version from url <url> as version <version>. Url must refer to a remote NuGet package directly or must eventually resolve to a remote NuGet package through one or more 302 http responses.                                                                                            

   Examples                                                                                                                                           

   > svm install 0.16.0 -f 'https://scriptcs.mydomain.com/ScriptCs.0.16.0-bugfix.nupkg'                                                               
   > svm install choco-0.16.1 -f 'https://chocolatey.org/api/v2/package/ScriptCs/0.16.1'                                                              

Uninstall

> svm help uninstall
    ______   ______ ___
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/
             scriptcs version manager 1.0

 Description
   Uninstall a scriptcs version. If this was set as the global active version, then this will be removed.

 Usage
   svm uninstall <version>

 svm uninstall <version>

   Uninstall installed scriptcs version indicated by <version>.

   Examples

   > svm uninstall 0.14.0

List

> svm help list
    ______   ______ ___
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/
             scriptcs version manager 1.0

 Description
   List scriptcs versions.

 Usage
   svm list [<-i|--installed>]
   svm list <-r|--remote>
   svm list <-a|--active>

 svm list [<-i|--installed>]

   List the locally installed scriptcs versions available to use by specifying the -i or --installed switches. The active version of the installed scriptcs versions will be highlighted and will be specific to the path in which this command is executed taking into account global and local version selections.

   NOTE: This is also the default option and will be used when no switch is specified on this command.

   Examples

   > svm list --installed
   > svm list

 svm list <-r|--remote>

   List the scriptcs versions available to install from the remote repositories by specifying the -r or --remote switches.

   Examples

   > svm list --remote

 svm list <-a|--active>

   List the active version of the installed scriptcs versions available to use by specifying the -a or --active switches. This will be specific to the path in which the command is executed and will take into account global and local version selections.

   Examples

   > svm list -a

Info

> svm help info
    ______   ______ ___
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/
             scriptcs version manager 1.0

 Description
   Display detailed scriptcs version information.

 Usage
   svm info <version>

 svm info <version>

   Display detailed information about the specified scriptcs version. This will include scriptcs version, source of installed versions and soft link information if scriptcs version is symlinked to local folders.

   Examples

   > svm info 0.15.0

Set

> svm help set
    ______   ______ ___
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/
             scriptcs version manager 1.0

 Description
   Set the active scriptcs version.

 Usage
   svm set <version> [<-g|--global>]
   svm set <version> <-l|--local>

 svm set <version> [<-g|--global>]

   If the -g or --global switch is utilised, this will be set at a global level and will be the active scriptcs version for all paths in which scriptcs is executed.

   If there is an existing active scriptcs version at the specified level, it will be superceded by the version specified via this command.

   NOTE: This is also the default option and will be used when no switch is specified on this command.

   Examples

   > svm set 0.16.0
   > svm set 0.16.1 -g

 svm set <version> <-l|--local>

   If the -l or --local switch is utilised, this will be set at a local level and will be the active scriptcs version only for the path in which this command was executed. This version will supercede any active scriptcs version set at a global level. An .svm file will be added at the path location that will contain the active scriptcs version details.

   If there is an existing active scriptcs version at the specified level, it will be superceded by the version specified via this command.

   Examples

   > svm set 0.16.1 --local

Unset

> svm help unset
    ______   ______ ___
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/
             scriptcs version manager 1.0

 Description
   Unset the active scriptcs version.

 Usage
   svm unset <version> <-g|--global>
   svm unset <version> <-l|--local>

 svm unset <version> <-g|--global>

   If the -g or --global switch is utilised, this will be unset at a global level and there will be no active scriptcs version for any paths in which scriptcs is executed.

   NOTE: This does not uninstall/remove the scriptcs version. It simply removes any global references to it.

   Examples

   > svm unset --global

 svm unset <version> <-l|--local>

   If the -l or --local switch is utilised, this will unset at a local level and there will no longer be a local override of the active scriptcs version for the path in which this command was executed. The .svm file will be removed from the path location.

   NOTE: This does not uninstall/remove the scriptcs version. It simply removes any global references to it.

   Examples

   > svm unset -l

Upgrade

> svm help upgrade
    ______   ______ ___
   / ___/ | / / __ `__ \
  (__  )| |/ / / / / / /
 /____/ |___/_/ /_/ /_/
             scriptcs version manager 1.0

 Description
   Upgrade svm.

 Usage
   svm upgrade

 svm upgrade

   Performs an inplace upgrade of svm if there is a newer version. All existing versions and configuration is preserved.

   Examples

   > svm upgrade

Environment Variables

SVM_PATH - default is .svm in user location
PATH - add SVM_PATH/bin

SCRIPTCS_PATH

Config


// .config in .svm folder - to manage global version and other global config
{
  "version": {
     "global": "0.15.0"
  },
  "console": {
     "encoding": "utf8"
  }
}

// .$VERSION$ in .svm/versions-metadata folder - to manage version
{
  "version": {
     "name": "0.15.0",
     "build": "stable"
     "publishDate": "2014-08-01T02:41:53.897"
   },
   "source": {
     "type": "path",
     "path": "C:\scriptcs\artifacts\Release\bin",
     "type": "snapshot|symlink"
   },
   "source": {
     "type": "url",
     "url": "https://scriptcs.mydomain.com/ScriptCs.0.14.1-bugfix.nupkg"
   },
   "source": {
     "type": "url"
     "repository": "Chocolatey"
     "url": "https://chocolatey.org/api/v2/package/ScriptCs/0.14.1"
   },

}

// .svm in local script folder - to manage local version
{
  "version": {
     "local": "0.15.0"
   }
}