We've seen how any folder can be turned into a package with the init
command. Initial properties can be set as named parameters to the init
command.
init name="My Package" version=1.0.0
The init
command can be called more than once on a package and it will keep existing properties and only overwrite the ones you specify.
Once you've created your box.json, you can edit the file directly, or there are other commands to help manage it programmatically.
Each of these commands support tab-complete that is dynamic based on what properties are currently in your box.json.
The package show
command can be used to out put any part of the box.json. You can specifiy any property name from your box.json.
Outputs package name and keywords
package show name
package show keywords
Nested attributes may be accessed by specifying dot-delimited names or using array notation. If the accessed property is a complex value, the JSON representation will be displayed
Outputs testbox runner(s)
package show testbox.runner
Outputs the first testbox notify E-mail
package show testbox.notify.emails[1]
Output the entire box.json
package show
using JmesPath with package show
package show jq:slug
# grab contributors and split each result by spaces
package show "jq:contributors|split(@,' ')"
# get an array of all engine names
package show "jq:engines[].type"
# filter struct values and add in an additional value => { "myprop":"test", "name":"MyPackageName" }
package show "jq:{name:name, myprop:'test'}"
# return struct values in an array => [MyPackageName,2.4]
package show "jq:[name,version]"
Any property in your box.json can be set from the command line with the package set
command.
Set package name
package set name=myPackage
Nested attributes may be set by specifying dot-delimited names or using array notation. If the set value is JSON, it will be stored as a complex value in the box.json.
Set the repository type.
package set repository.type=Git
Set first testbox notify E-mail.
package set testbox.notify.email[1]="[email protected]"
Set multiple params at once by passing as many named parameters as you like.
package set name=myPackage version="1.0.0.000" author="Brad Wood" slug="foo"
Set a complex value as JSON.
package set testbox.notify.emails="[ '[email protected]', '[email protected]' ]"
Objects and arrays can be appended to using the append
parameter. This only works if the property and incoming value are both of the same complex type.
Add an additional contributor to the existing contributors
array.
package set contributors="[ '[email protected]' ]" --append
Add an additional dependency to the existing dependencies
object.
package set dependencies="{'cbcommons':'1.0.0'}" --append
If you need to remove a property entirely from your box.json, use the package clear
command. It also works on nested properties using "dot" or array notation.
Remove the package description entirely.
package clear description