All pages
Powered by GitBook
1 of 4

Loading...

Loading...

Loading...

Loading...

Installing Packages

The install command is used to tell CommandBox what you want. Here we ask for the stable release of the ColdBox MVC Platform. "coldbox" is the name of the ForgeBox slug.

install coldbox

Packages should always have a box.json descriptor file inside them. This is especially true of packages installed from endpoints other than Forgebox since they don't have any other metadata available. CommandBox will install any zip file even if it doesn't have a box.json, but this isn't ideal since the name, version, and type of the package must be guessed in that instance.

If you find a package on the internet that doesn't have a box.json, please contact the maintainer and request that they add one or submit a pull request!

ForgeBox Semantic Versioning Support

ForgeBox supports semantic version ranges for installing packages. Here are some examples:

Install Process

When you install a package, here are the steps that are taken. Most all of this should be evident by the output streamed to the console during the install process. To get even more juicy details, use the --verbose flag while installing.

  1. CommandBox inspects the ID passed to the install command to determine the endpoint to use.

  2. The matching endpoint is asked to fetch the package represented by the ID.

  3. For example, the ForgeBox endpoint checks the local artifact cache and possibly downloads the package.

Advanced Installation

Advanced Installation

In the CFML world, there are no global conventions for where to install things to nor where to store dependencies. Therefore, CommandBox for the most part will just stick packages in the root of your site unless you tell it otherwise. It may not be pretty, but it's as good as stock CFML apps can get. That means a lot of the cool things other package managers like NPM can do simply won't be available to you.

If you're using the ColdBox MVC Platform, congratulation! You just unlocked advanced mode! ColdBox uses conventions that tells you where to put stuff, and most importantly it has modularity as a first class citizen. Not only that, but modules can be nested infinitely to nicely encapsulate dependencies and WireBox will automatically find and register each module's models for your application to use.

Module Conventions

Modules are basically smart packages and when CommandBox installs or uninstalls modules it will behave a bit differently to take advantage of the functionality only available to the CFML world via the ColdBox Platform.

When installing a module, it will be placed in the modules/ directory. That means the cbvalidation module will install here:

The cbvalidation module has dependencies of its own but it is an island unto itself and will encapsulate these. Therefore the cbi18n module will be installed in a modules/ folder inside cbvalidation.

You'll be able to see a nice representation of this when you use the list command.

Moduleplicity

What this opens the door for is more than one module to depend on different versions of the same second module. Both can be installed and nested under the respective parent. In the near future, WireBox will be smart enough to present these nested modules only to their parents so they are fully encapsulated.

The idea is that a module can "see" and use another module installed at the same level or higher in the hierarchy, but not lower. That makes dependencies a bit of a black box to their parents. This also allows us to bypass some redundancy. For instance, when installing a module, if a satisfying version of that module already exists at a higher level, we skip the installation. Consider this example:

We know that cbvaliation requires cbi18n, but since it is already installed in the root modules folder, we won't install it again under cbvalidation.

Smart Uninstall

The last way modules are better than sliced papusas is in how they uninstall. We talked about how non-modules install-- just littered in the web root in a jumble of dependencies. When uninstalling a non-module package, CommandBox will recursively go through the dependencies and remove them as well. However, when uninstalling a module, that module's folder is simply deleted and that's it. Since all dependencies are contained in the "black box", there's no need to go hunting for them.

Installation Options

There are several options you can use to control how a package is installed.

Saving dependencies

By default, any package you install will be saved as a dependency. To save it as a development dependency instead, use the --saveDev flag.

install testbox --saveDev

If you DON'T want the package you're installing to be saved as a dependency pass save=false or negate the save flag as --!save.

Production Installation

When you install a package, all dependencies will be installed. If you want to skip development dependencies, use the --production flag. This will also cause CommandBox to obey the package's ignore property in its box.json.

Verbose Installation

If you're a glutton for information, or perhaps you just want to debug what's going on, set the --verbose flag to get extra debugging information out of the install command including a list of every file that's installed.

Forced Installation

If CommandBox sees the directory that it was going to install into already exists with a newer or equal version of the package inside, it will decline to install again since it would be overwriting what's already there. If you want to install anyway, use the --force flag.

Installation Path

There are several factors that determine where a package gets installed to. Here are the ways CommandBox determines the install location in order of importance.

  1. The value of the directory parameter passed into the install command by the user.

  2. The value of the installPaths.packageName property set in the project's main box.json by the user. Where packageName

is the name of the package you are installing like
logbox
.
  • The value of the directory property in the package's box.json by the package author. Note, this must be a path relative to the current working directory (CWD).

  • Based on the package type convention if the package is a command, coldbox module, commandbox module, plugin, or interceptor.

  • If the package being installed is of type lucee-extensions and if the current working directory is found to have a Lucee server in it, the lex file will instead be installed to the server context's deploy folder.

  • The current working directory (CWD)

  • Once the installation directory is determined, a folder is created that matches the package's slug which is where the package is finally copied to. If the package's createPackageDirectory property is set to false in the box.json, the package will be copied to the root of the installation directory. An example of this would be a complete application that needs to go in the web root.

    If ForgeBox is offline, the best match package will be looked for in your artifacts.
  • The package is unzipped and its box.json is read

  • Installation directory is finalized

  • Contents of package are copied based on the ignore and --production flag

  • The package is saved as a dependency in the root box.json

  • The package's dependencies are installed

  • <webroot>/modules/cbvalidation
    install cborm --!save
    # Latest stable version
    CommandBox> install foo
    
    # Same as above
    CommandBox> install foo@stable
    
    # latest version, even if pre release (bleeding edge)
    CommandBox> install foo@be
    
    # A specific version
    CommandBox> install [email protected]
    
    # Any version with a major number of 4 (4.1, 4.2, 4.9, etc)
    CommandBox> install [email protected]
    
    # Any version greater than 1.5.0
    CommandBox> install foo@>1.5.0
    
    # Any version greater than 5.2 but less than or equal to 6.3.4
    CommandBox> install "foo@>5.2 <=6.3.4"
    
    # Any version greater than or equal to 1.2 but less than or equal to 3.2
    CommandBox> install "[email protected] - 3.2"
    
    # Allows patch-level changes if a minor version is specified. Allows minor-level changes if not.  (2.1.2, 2.1.3, 2.1.4, etc)
    CommandBox> install foo@~2.1
    
    # Any greater version that does not modify the left-most non-zero digit.  4.2, 4.3, 4.9, etc
    CommandBox> install foo@^4.1.4
    <webroot>/modules/cbvalidation/modules/cbi18n
    CommandBox> list
    Dependency Hierarchy myApp (1.0.0)
    ├── coldbox (4.2.0)
    └─┬ cbvalidation (1.0.0)
      └── cbi18n (1.0.0)
    install cbi18n
    install cbvalidation
    install cbvalidation --production
    install cbi18n --verbose
    install cbsoap --force