[CommandBox] box.json configuration question

I’m working on a project that I’m trying to configure so that I can publish it on ForgeBox for use with CommandBox.

I have a /lib folder that I want all external libraries to be installed to (including TestBox 2.0). Is there any documentation out there on what the various keys in the box.json file are used for? I’ve tried putting the following line in my box.json file:

“packageDirectory”: “lib/”

but every time I run “box install” from the root directory where the box.json file is, TestBox gets created in the root folder.

I’ve also tried the following with no luck:

“installPaths”:{
“testbox”:“lib/testbox”
}

Is what I’m trying to do possible?

Thanks
Dan

Hi Dan,

> Is there any documentation out there on what the various keys in the box.json file are used for?

I am still working on the “Package Management” portion of the docs. We do have a sample box.json with comments for each property here:
http://www.ortussolutions.com/products/commandbox/docs/current/package-management/boxjson

> “packageDirectory”: “lib/”

This has no bearing on where dependencies are installed to. This controls the name of the folder THAT package installs to instead of the slug. For instance, the “coldbox-be” packaged on ForgeBox has a packageDirectory set to “coldbox” since we don’t want CommandBox putting it in a folder called “coldbox-be” or the default mapping from the web root wouldn’t work. Generally speaking, you should probably never need to use this property.

> every time I run “box install” from the root directory where the box.json file is, TestBox gets created in the root folder.

Yep, the current directory is the default install location for any package that is not a module, command, plugin, or interceptor.

> “installPaths”:{
> “testbox”:“lib/testbox”
> }

The installPaths are only used for uninstallation right now. CommandBox will store the location where it installed a package to after it finishes the installation (providing packageDirectory was set to false in that package). Perhaps that could make a nice feature request-- for CommandBox to use the installPaths location if it exists for that package to override the default location.

> Is what I’m trying to do possible?

Well, if you were specifically installing that library, you could just use the “directory” parameter like so;

install testbox …/lib

However, if you’re just doing “install” and letting CommandBox install your dependencies for you, it’s going to use the default location.

Figuring out how to make installations work has been a little tricky since there’s no precedence for this behavior in other package managers that we’ve looked at. In NPM, for instance, there’s no such thing as you choosing where to install a package. They go into node_modules and there’s nothing you can do about it. CommandBox is trying to introduce a lot more flexibility by giving people control over where things install to but we’re making up a lot of these rules as we go so your input is welcome :slight_smile:

Personally, I think it makes the most sense to use the installPaths if they’re defined. Of course, you’ll need to have the appropriate mapping defined in your Application.cfc.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Awesome…thanks for the info Brad. That worked like a champ.

Yeah, it would be really nice to have the ability to check out a project, run ‘box install’ and have it install all the dependencies into the specified paths.

That’s what I’ll have to do as part of my build process to install TestBox if I can figure out how to get Travis-CI to download/run the CommandBox executable (see related thread Google Groups)

Thanks again.

Dan

Ok, I put in ticket COMMANDBOX-109 and just committed the fix for it. Give a couple more minutes for our Jenkins server to crank out a new build and then run:

upgrade --latest

Now when you run either “install” by itself or “install foobar” for a specific slug, here is how it determines where the base location is to put that package.

  1. If a directory parameter is passed into the “install” command, it is used.
  2. Else, if there is a install path in the parent box.json for this package it is used (minus the last folder in the path)
  3. Else, if the package is a module, command, interceptor, or plugin; convention is used
  4. Else, the package is installed to the current working directory (CWD)

So basically this means you can put this in your app’s box.json:

“dependencies”:{
“testbox”:“2.0.0”
},
“installPaths”:{
“testbox”:“lib\testbox”
}

And then just run “install”: and TestBox will be dropped in your lib folder.

Also, please ask further CommandBox questions over on our dedicated CommandBox list
https://groups.google.com/a/ortussolutions.com/forum/#!forum/commandbox

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Awesome…that worked like a champ. I got CommandBox upgraded, blew away my /lib/testbox folder and ran ‘box install’ and it put testbox back into my lib folder as specified by the box.json file.

Also, thanks for the link to the other group…wasn’t aware it existed. Apologies for posting in the wrong area.

Dan