npminstall

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

Paketo NPM Install Cloud Native Buildpack

The NPM Install CNB makes use of the npm tooling installed within the Node Engine CNB to manage application dependencies.

Integration

The NPM Install CNB provides node_modules as a dependency. Downstream buildpacks can require the node_modules dependency by generating a Build Plan TOML file that looks like the following:

[[requires]]

  # The name of the NPM Install dependency is "node_modules". This value is
  # considered part of the public API for the buildpack and will not change
  # without a plan for deprecation.
  name = "node_modules"

  # Note: The version field is unsupported as there is no version for a set of
  # npm.

  # The NPM Install buildpack supports some non-required metadata options.
  [requires.metadata]

    # Setting the build flag to true will ensure that the node modules are
    # available for subsequent buildpacks during their build phase.
    # If you are writing a buildpack that needs to run a node module during its build
    # process, this flag should be set to true.
    build = true

    # Setting the launch flag to true will ensure that the packages managed by
    # NPM will be available for the running application. If you
    # are writing an application that needs to run node modules at runtime, this
    # flag should be set to true.
    launch = true

Usage

To package this buildpack for consumption:

$ ./scripts/package.sh --version <version-number>

This will create a buildpackage.cnb file under the build directory which you can use to build your app as follows: pack build <app-name> -p <path-to-app> -b <path/to/node-engine.cnb> -b build/buildpackage.cnb

buildpack.yml Configurations

The NPM Install buildpack does not support configurations using buildpack.yml.

Run Tests

To run all unit tests, run:

./scripts/unit.sh

To run all integration tests, run:

/scripts/integration.sh

Stack support

For most apps, the NPM Install Buildpack runs fine on the Base builder. But when the app requires compilation of native extensions using node-gyp, the buildpack requires that you use the Full builder. This is because node-gyp requires python that's absent on the Base builder, and the module may require other shared objects.

Documentation

Index

Constants

View Source
const (
	NodeModules = "node_modules"
	Node        = "node"
	Npm         = "npm"

	LayerNameNodeModules = "modules"
	LayerNameCache       = "npm-cache"
)

Variables

This section is empty.

Functions

func Build

func Build(buildManager BuildManager, clock chronos.Clock, logger scribe.Logger) packit.BuildFunc

func Detect

func Detect(packageJSONParser VersionParser) packit.DetectFunc

Types

type BuildManager

type BuildManager interface {
	Resolve(workingDir, cacheDir string) (BuildProcess, error)
}

type BuildPlanMetadata

type BuildPlanMetadata struct {
	Version       string `toml:"version"`
	VersionSource string `toml:"version-source"`
	Build         bool   `toml:"build"`
	Launch        bool   `toml:"launch"`
}

type BuildProcess

type BuildProcess interface {
	ShouldRun(workingDir string, metadata map[string]interface{}) (run bool, sha string, err error)
	Run(modulesDir, cacheDir, workingDir string) error
}

type BuildProcessResolver

type BuildProcessResolver struct {
	// contains filtered or unexported fields
}

func NewBuildProcessResolver

func NewBuildProcessResolver(executable Executable, summer Summer, logger scribe.Logger) BuildProcessResolver

func (BuildProcessResolver) Resolve

func (r BuildProcessResolver) Resolve(workingDir, cacheDir string) (BuildProcess, error)

type CIBuildProcess

type CIBuildProcess struct {
	// contains filtered or unexported fields
}

func NewCIBuildProcess

func NewCIBuildProcess(executable Executable, summer Summer, logger scribe.Logger) CIBuildProcess

func (CIBuildProcess) Run

func (r CIBuildProcess) Run(modulesDir, cacheDir, workingDir string) error

func (CIBuildProcess) ShouldRun

func (r CIBuildProcess) ShouldRun(workingDir string, metadata map[string]interface{}) (bool, string, error)

type Executable

type Executable interface {
	Execute(pexec.Execution) (err error)
}

type InstallBuildProcess

type InstallBuildProcess struct {
	// contains filtered or unexported fields
}

func NewInstallBuildProcess

func NewInstallBuildProcess(executable Executable, logger scribe.Logger) InstallBuildProcess

func (InstallBuildProcess) Run

func (r InstallBuildProcess) Run(modulesDir, cacheDir, workingDir string) error

func (InstallBuildProcess) ShouldRun

func (r InstallBuildProcess) ShouldRun(workingDir string, metadata map[string]interface{}) (bool, string, error)

type PackageJSONParser

type PackageJSONParser struct{}

func NewPackageJSONParser

func NewPackageJSONParser() PackageJSONParser

func (PackageJSONParser) ParseVersion

func (p PackageJSONParser) ParseVersion(path string) (string, error)

type RebuildBuildProcess

type RebuildBuildProcess struct {
	// contains filtered or unexported fields
}

func NewRebuildBuildProcess

func NewRebuildBuildProcess(executable Executable, summer Summer, logger scribe.Logger) RebuildBuildProcess

func (RebuildBuildProcess) Run

func (r RebuildBuildProcess) Run(modulesDir, cacheDir, workingDir string) error

func (RebuildBuildProcess) ShouldRun

func (r RebuildBuildProcess) ShouldRun(workingDir string, metadata map[string]interface{}) (bool, string, error)

type Summer

type Summer interface {
	Sum(path string) (string, error)
}

type VersionParser

type VersionParser interface {
	ParseVersion(path string) (version string, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL