Packages are quite simply a folder that contains some code and a
box.jsonfile. A package can be a simple CFC, a self-contained library, or even an entire application. ColdBox and ContentBox modules also make great "smart" packages.
Remember, packages aren't just the things you install into your application, but your application is a package too! That's why when you install something in your app, we'll create a /box.json if it doesn't exist to start tracking your dependencies.
box.jsonfile describes your package, dependencies, and how to install it. To turn a boring folder into a sweet package just run the
initcommand in the root of the folder.
init name="My Package" version="1.0.0"
That's it. Your folder now has extra meta data in the
box.jsonfile that describes it in a way that is meaningful to ForgeBox and CommandBox.
When making a package available on ForgeBox, each version of that package has its own location. Most download locations point to a zip file, that when extracted, contains a folder with a box.json in it. The box.json designates the root of the package. However, the
locationproperty of your box.json can be any valid endpoint ID. An example would be:
In that case, the
1.0.0of this package is the
v1.0.0tag in that GitHub repository.
ForgeBox can store the binaries for your packages in the ForgeBox Cloud. This provides you with an easy way to store multiple versions of your package distributed across the globe.
To utilize ForgeBox Storage, simply set
forgeboxStorageas the value of your package's
package set location=forgeboxStorage
When you publish a package, CommandBox will automatically zip up your package and send it to ForgeBox.
When you run the
publishcommand from the root of a package, the package will be created on ForgeBox. If the package already exists in ForgeBox, the new version will be added. If the version already exists, the package metadata will be updated.
Most of the data about a package exists in the
box.jsonsuch as name, slug, version, etc. There are also some files read from disk by convention. The
publishcommand looks by convention for the following files (case insensitive) when publishing
readme- Maps to Package Description
instructions- Maps to Installation Instructions
changelog- Maps to Change Log
Every file is checked for
.txt, and no extension in that order.
Below is an example of the commands that would take you from scratch to a published package:
# Create user (first time only)
forgebox register username password [email protected] firstName lastName
forgebox login username password
# Create package
mkdir mypackage --cd
package init slug=my-package type=modules
# Publish it
# Viewable and installable by the world!
forgebox show my-package
ForgeBox supports private packages. Private packages are only visible to the user who created it.
To create a private package, pass the
privateflag to the
CommandBox:my-package> package init slug=my-package --private
- Set name = My Package
- Set slug = [email protected]
- Set version = 0.0.0
- Set private = true
- Set shortDescription = A sweet package
- Set ignore = ["**/.*","test","tests"]
Package Initialized & Created /Users/username/code/sandbox/my-package/box.json