commandbox.system.services

Class PackageService

lucee.Component
    extended by commandbox.system.services.PackageService

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I handle working with the box.json file

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    any CR


    • access = public
    • returntype = any
    • inject = CR@constants
    true false
    any JSONService


    • access = public
    • returntype = any
    • inject = JSONService
    true false
    any artifactService


    • access = public
    • returntype = any
    • inject = ArtifactService
    true false
    any consoleLogger


    • access = public
    • returntype = any
    • inject = logbox:logger:console
    true false
    any endpointService


    • access = public
    • returntype = any
    • inject = EndpointService
    true false
    any fileSystemUtil


    • access = public
    • returntype = any
    • inject = FileSystem
    true false
    any formatterUtil


    • access = public
    • returntype = any
    • inject = formatter
    true false
    any interceptorService


    • access = public
    • returntype = any
    • inject = interceptorService
    true false
    any javaService


    • access = public
    • returntype = any
    • inject = provider:JavaService
    true false
    any logger


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any pathPatternMatcher


    • access = public
    • returntype = any
    • inject = provider:pathPatternMatcher@globber
    true false
    any semanticVersion


    • access = public
    • returntype = any
    • inject = provider:semanticVersion@semver
    true false
    any serverService


    • access = public
    • returntype = any
    • inject = serverService
    true false
    any shell


    • access = public
    • returntype = any
    • inject = Shell
    true false
    any systemSettings


    • access = public
    • returntype = any
    • inject = SystemSettings
    true false
    any tempDir


    • access = public
    • returntype = any
    • inject = tempDir@constants
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    any addDependency(string currentWorkingDirectory, string packageName, string version, [string installDirectory=''], [boolean installDirectoryIsDedicated='true'], [boolean dev='false'], [struct endpointData])
         Adds a dependency to a packge.
    private any buildChildren(struct boxJSON, struct parent, string basePath, [any depth='0'], [any currentlevel])
    any buildDependencyHierarchy(any directory, [any depth='0'])
         Builds a struct of structs that represents the dependency hierarchy.
    any completeProperty(any directory, [any all='false'], [any asSet='false'])
         Dynamic completion for property name based on contents of box.
    any findPackageRoot([any packagePath])
    string getArtifactService()
    string getCR()
    string getConsoleLogger()
    any getDescriptorPath(string directory)
         Returns the path to the package descriptor.
    string getEndpointService()
    string getFileSystemUtil()
    string getFormatterUtil()
    string getInterceptorService()
    string getJSONService()
    string getJavaService()
    string getLogger()
    array getOutdatedDependencies(any directory, any print, [boolean verbose='false'], [any includeSlugs=''])
         Return an array of all outdated depdendencies in a project.
    string getPathPatternMatcher()
    string getSemanticVersion()
    string getServerService()
    string getShell()
    string getSystemSettings()
    string getTempDir()
    string getWirebox()
    boolean installPackage(string ID, [string directory], [boolean save='false'], [boolean saveDev='false'], [boolean production], [string currentWorkingDirectory='[runtime expression]'], [boolean verbose='false'], [boolean force='false'], [string packagePathRequestingInstallation='[runtime expression]'], [string defaultName=''])
         Installs a package and its dependencies, obeying ignors in the box.
    any isPackage(string directory)
         Checks to see if a box.
    any isPackageModule(string packageType)
    any newPackageDescriptor([struct defaults='[runtime expression]'], [boolean omitDeprecated='false'])
         Get the default package description, AKA box.
    private any parseSlug(string package)
         Parses just the slug portion out of an endpoint ID.
    private any parseVersion(string package)
         Parses just the version portion out of an endpoint ID.
    private any processDependencies([any dependencies], [any installPaths], [any dev='false'], [any basePath], [any depth='0'], [any currentlevel])
    struct readPackageDescriptor(any directory, [boolean expandSystemSettings='true'])
         Get the box.
    struct readPackageDescriptorRaw(any directory)
         Get the box.
    struct readPackageDescriptorTemplate(any directory)
         Does everything readPackageDescriptor() does, but won't default deprecated box.
    any removeDependency(string directory, string packageName)
         Removes a dependency from a packge if it exists.
    any runScript(string scriptName, [string directory='[runtime expression]'], [boolean ignoreMissing='true'], [any interceptData='[runtime expression]'])
         Nice wrapper to run a package script.
    any setArtifactService(any artifactService)
    any setCR(any CR)
    any setConsoleLogger(any consoleLogger)
    any setEndpointService(any endpointService)
    any setFileSystemUtil(any fileSystemUtil)
    any setFormatterUtil(any formatterUtil)
    any setInterceptorService(any interceptorService)
    any setJSONService(any JSONService)
    any setJavaService(any javaService)
    any setLogger(any logger)
    any setPathPatternMatcher(any pathPatternMatcher)
    any setSemanticVersion(any semanticVersion)
    any setServerService(any serverService)
    any setShell(any shell)
    any setSystemSettings(any systemSettings)
    any setTempDir(any tempDir)
    any setWirebox(any wirebox)
    any uninstallPackage(string ID, [string directory], [boolean save='false'], string currentWorkingDirectory, [string packagePathRequestingUninstallation='[runtime expression]'], [boolean verbose='false'])
         Uninstalls a package and its dependencies.
    any writePackageDescriptor(any JSONData, any directory)
         Write the box.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    CR

    property any CR

    Attributes:
    access - public
    required - false
    returntype - any
    inject - CR@constants
    serializable - true

    JSONService

    property any JSONService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - JSONService
    serializable - true

    artifactService

    property any artifactService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - ArtifactService
    serializable - true

    consoleLogger

    property any consoleLogger

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:console
    serializable - true

    endpointService

    property any endpointService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - EndpointService
    serializable - true

    fileSystemUtil

    property any fileSystemUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - FileSystem
    serializable - true

    formatterUtil

    property any formatterUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - formatter
    serializable - true

    interceptorService

    property any interceptorService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - interceptorService
    serializable - true

    javaService

    property any javaService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - provider:JavaService
    serializable - true

    logger

    property any logger

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    pathPatternMatcher

    property any pathPatternMatcher

    Attributes:
    access - public
    required - false
    returntype - any
    inject - provider:pathPatternMatcher@globber
    serializable - true

    semanticVersion

    property any semanticVersion

    Attributes:
    access - public
    required - false
    returntype - any
    inject - provider:semanticVersion@semver
    serializable - true

    serverService

    property any serverService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - serverService
    serializable - true

    shell

    property any shell

    Attributes:
    access - public
    required - false
    returntype - any
    inject - Shell
    serializable - true

    systemSettings

    property any systemSettings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - SystemSettings
    serializable - true

    tempDir

    property any tempDir

    Attributes:
    access - public
    required - false
    returntype - any
    inject - tempDir@constants
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    addDependency

    public any addDependency(string currentWorkingDirectory, string packageName, string version, [string installDirectory=''], [boolean installDirectoryIsDedicated='true'], [boolean dev='false'], [struct endpointData])

    Adds a dependency to a packge

    Parameters:
    currentWorkingDirectory - The directory that is the root of the package
    packageName - Package to add a a dependency
    version - Version of the dependency
    installDirectory - The location that the package is installed to including the container folder.
    installDirectoryIsDedicated - True if the package was placed in a dedicated folder
    dev - True if this is a development dependency, false if it is a production dependency
    endpointData

    buildChildren

    private any buildChildren(struct boxJSON, struct parent, string basePath, [any depth='0'], [any currentlevel])

    Parameters:
    boxJSON
    parent
    basePath
    depth
    currentlevel

    buildDependencyHierarchy

    public any buildDependencyHierarchy(any directory, [any depth='0'])

    Builds a struct of structs that represents the dependency hierarchy

    Parameters:
    directory - The directory of the package to start in
    depth - how deep to climb down the rabbit hole. A value of 0 means infinite depth

    completeProperty

    public any completeProperty(any directory, [any all='false'], [any asSet='false'])

    Dynamic completion for property name based on contents of box.json

    Parameters:
    directory - The package root
    all - Pass false to ONLY suggest existing property names. True will suggest all possible box.json properties.
    asSet - Pass true to add = to the end of the options

    findPackageRoot

    public any findPackageRoot([any packagePath])

    Parameters:
    packagePath

    getArtifactService

    public string getArtifactService()


    getCR

    public string getCR()


    getConsoleLogger

    public string getConsoleLogger()


    getDescriptorPath

    public any getDescriptorPath(string directory)

    Returns the path to the package descriptor

    Parameters:
    directory - The directory that is the root of the package

    getEndpointService

    public string getEndpointService()


    getFileSystemUtil

    public string getFileSystemUtil()


    getFormatterUtil

    public string getFormatterUtil()


    getInterceptorService

    public string getInterceptorService()


    getJSONService

    public string getJSONService()


    getJavaService

    public string getJavaService()


    getLogger

    public string getLogger()


    getOutdatedDependencies

    public array getOutdatedDependencies(any directory, any print, [boolean verbose='false'], [any includeSlugs=''])

    Return an array of all outdated depdendencies in a project.

    Parameters:
    directory - The directory of the package to start in
    print - The print buffer used for command operation
    verbose - Outputs additional information about each package as it is checked
    includeSlugs - A commit-delimited list of slugs to include. Empty means include everything.
    Returns:
    An array of structs of outdated dependencies

    getPathPatternMatcher

    public string getPathPatternMatcher()


    getSemanticVersion

    public string getSemanticVersion()


    getServerService

    public string getServerService()


    getShell

    public string getShell()


    getSystemSettings

    public string getSystemSettings()


    getTempDir

    public string getTempDir()


    getWirebox

    public string getWirebox()


    installPackage

    public boolean installPackage(string ID, [string directory], [boolean save='false'], [boolean saveDev='false'], [boolean production], [string currentWorkingDirectory='[runtime expression]'], [boolean verbose='false'], [boolean force='false'], [string packagePathRequestingInstallation='[runtime expression]'], [string defaultName=''])

    Installs a package and its dependencies, obeying ignors in the box.json file. Returns a struct containing a "copied" array and an "ignored" array containing the relative paths inside the package that were copied and ignored.

    Parameters:
    ID
    directory - The directory to install in. This will override the packages's box.json install dir if provided.
    save - Save the installed package as a dependancy in box.json (if it exists)
    saveDev - Save the installed package as a dev dependancy in box.json (if it exists)
    production - When calling this command with no slug to install all dependencies, set this to true to ignore devDependencies.
    currentWorkingDirectory - Root of the application (used for finding box.json)
    verbose - If set, it will produce much more verbose information about the package installation
    force - When set to true, it will force dependencies to be installed whether they already exist or not
    packagePathRequestingInstallation - If installing smart dependencies packages (like ColdBox modules) that are capable of being nested, this is our current level
    defaultName

    isPackage

    public any isPackage(string directory)

    Checks to see if a box.json exists in a given directory

    Parameters:
    directory - The directory to examine

    isPackageModule

    public any isPackageModule(string packageType)

    Parameters:
    packageType

    newPackageDescriptor

    public any newPackageDescriptor([struct defaults='[runtime expression]'], [boolean omitDeprecated='false'])

    Get the default package description, AKA box.json

    Parameters:
    defaults - A struct of default values to be merged into the empty, default document
    omitDeprecated

    parseSlug

    private any parseSlug(string package)

    Parses just the slug portion out of an endpoint ID

    Parameters:
    package - The full endpointID like foo@1.0.0

    parseVersion

    private any parseVersion(string package)

    Parses just the version portion out of an endpoint ID

    Parameters:
    package - The full endpointID like foo@1.0.0

    processDependencies

    private any processDependencies([any dependencies], [any installPaths], [any dev='false'], [any basePath], [any depth='0'], [any currentlevel])

    Parameters:
    dependencies
    installPaths
    dev
    basePath
    depth
    currentlevel

    readPackageDescriptor

    public struct readPackageDescriptor(any directory, [boolean expandSystemSettings='true'])

    Get the box.json as data from the passed directory location. Any missing properties will be defaulted with our box.json template. If you plan on writing the box.json back out to disk, use readPackageDescriptorRaw() instead. If you ask for system settings to be swapped out, do not write this box.json back to disk. It's has possibly been modified to expand the props like ${foo} and will overwrite the actual place holders

    Parameters:
    directory - The directory to search for the box.json
    expandSystemSettings

    readPackageDescriptorRaw

    public struct readPackageDescriptorRaw(any directory)

    Get the box.json as data from the passed directory location, if not found then we return an empty struct. This method will NOT default box.json properties and will return JUST what was defined. Make sure you use existence checks when using the returned data structure

    Parameters:
    directory - The directory to search for the box.json

    readPackageDescriptorTemplate

    public struct readPackageDescriptorTemplate(any directory)

    Does everything readPackageDescriptor() does, but won't default deprecated box.json proprties.

    Parameters:
    directory - The directory to search for the box.json

    removeDependency

    public any removeDependency(string directory, string packageName)

    Removes a dependency from a packge if it exists

    Parameters:
    directory - The directory that is the root of the package
    packageName - Package to add a a dependency

    runScript

    public any runScript(string scriptName, [string directory='[runtime expression]'], [boolean ignoreMissing='true'], [any interceptData='[runtime expression]'])

    Nice wrapper to run a package script

    Parameters:
    scriptName - Name of the package script to run
    directory - The package root
    ignoreMissing - Set true to ignore missing package scripts, false to throw an exception
    interceptData - An optional struct of data if this package script is being fired as part of an interceptor announcement. Will be loaded into env vars

    setArtifactService

    public any setArtifactService(any artifactService)

    Parameters:
    artifactService

    setCR

    public any setCR(any CR)

    Parameters:
    CR

    setConsoleLogger

    public any setConsoleLogger(any consoleLogger)

    Parameters:
    consoleLogger

    setEndpointService

    public any setEndpointService(any endpointService)

    Parameters:
    endpointService

    setFileSystemUtil

    public any setFileSystemUtil(any fileSystemUtil)

    Parameters:
    fileSystemUtil

    setFormatterUtil

    public any setFormatterUtil(any formatterUtil)

    Parameters:
    formatterUtil

    setInterceptorService

    public any setInterceptorService(any interceptorService)

    Parameters:
    interceptorService

    setJSONService

    public any setJSONService(any JSONService)

    Parameters:
    JSONService

    setJavaService

    public any setJavaService(any javaService)

    Parameters:
    javaService

    setLogger

    public any setLogger(any logger)

    Parameters:
    logger

    setPathPatternMatcher

    public any setPathPatternMatcher(any pathPatternMatcher)

    Parameters:
    pathPatternMatcher

    setSemanticVersion

    public any setSemanticVersion(any semanticVersion)

    Parameters:
    semanticVersion

    setServerService

    public any setServerService(any serverService)

    Parameters:
    serverService

    setShell

    public any setShell(any shell)

    Parameters:
    shell

    setSystemSettings

    public any setSystemSettings(any systemSettings)

    Parameters:
    systemSettings

    setTempDir

    public any setTempDir(any tempDir)

    Parameters:
    tempDir

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    uninstallPackage

    public any uninstallPackage(string ID, [string directory], [boolean save='false'], string currentWorkingDirectory, [string packagePathRequestingUninstallation='[runtime expression]'], [boolean verbose='false'])

    Uninstalls a package and its dependencies

    Parameters:
    ID - Identifier of the packge to uninstall.
    directory - The directory to install in. This will override the packages's box.json install dir if provided.
    save - Remove package as a dependancy in box.json (if it exists)
    currentWorkingDirectory - Root of the application (used for finding box.json)
    packagePathRequestingUninstallation
    verbose

    writePackageDescriptor

    public any writePackageDescriptor(any JSONData, any directory)

    Write the box.json data as a JSON file

    Parameters:
    JSONData - The JSON data to write to the file. Can be a struct, or the string JSON
    directory - The directory to write the box.json