yarninstall

package module
v1.2.18 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Initializ Buildpack for Yarn Install

https://hub.docker.com/r/initializbuildpacks/yarn-install

The Yarn Install CNB generates and provides application dependencies for node applications that use the yarn package manager.

NOTE: Support for yarn is limited to version 1 (Classic).

Integration

The Yarn 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 Yarn 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
  # node_modules.

  # The Yarn 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 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 Yarn are available for the running application. If you
    # are writing an application that needs 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 <path/to/yarn.cnb> /
-b build/buildpackage.cnb

Specifying a project path

To specify a project subdirectory to be used as the root of the app, please use the BP_NODE_PROJECT_PATH environment variable at build time either directly (ex. pack build my-app --env BP_NODE_PROJECT_PATH=./src/my-app) or through a project.toml file. This could be useful if your app is a part of a monorepo.

Run Tests

To run all unit tests, run:

./scripts/unit.sh

To run all integration tests, run:

/scripts/integration.sh

Documentation

Index

Constants

View Source
const (
	PlanDependencyNodeModules = "node_modules"
	PlanDependencyNode        = "node"
	PlanDependencyYarn        = "yarn"
)

Variables

This section is empty.

Functions

func Build

func Build(entryResolver EntryResolver,
	configurationManager ConfigurationManager,
	homeDir string,
	symlinker SymlinkManager,
	installProcess InstallProcess,
	sbomGenerator SBOMGenerator,
	clock chronos.Clock,
	logger scribe.Emitter,
	tmpDir string) packit.BuildFunc

func Detect

func Detect() packit.DetectFunc

Types

type BindingResolver

type BindingResolver interface {
	Resolve(typ, provider, platformDir string) ([]servicebindings.Binding, error)
}

type BuildPlanMetadata

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

type CacheHandler

type CacheHandler struct{}

func NewCacheHandler

func NewCacheHandler() CacheHandler

func (CacheHandler) Match

func (ch CacheHandler) Match(metadata map[string]interface{}, key, sha string) bool

type ConfigurationManager

type ConfigurationManager interface {
	DeterminePath(typ, platformDir, entry string) (path string, err error)
}

type EntryResolver

type EntryResolver interface {
	MergeLayerTypes(string, []packit.BuildpackPlanEntry) (launch, build bool)
}

type Executable

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

type InstallProcess

type InstallProcess interface {
	ShouldRun(workingDir string, metadata map[string]interface{}) (run bool, sha string, err error)
	SetupModules(workingDir, currentModulesLayerPath, nextModulesLayerPath string) (string, error)
	Execute(workingDir, modulesLayerPath string, launch bool) error
}

type PackageManagerConfigurationManager

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

func NewPackageManagerConfigurationManager

func NewPackageManagerConfigurationManager(bindingResolver BindingResolver, logs scribe.Emitter) PackageManagerConfigurationManager

func (PackageManagerConfigurationManager) DeterminePath

func (p PackageManagerConfigurationManager) DeterminePath(typ, platformDir, entry string) (string, error)

type SBOMGenerator

type SBOMGenerator interface {
	Generate(dir string) (sbom.SBOM, error)
}

type Summer

type Summer interface {
	Sum(paths ...string) (string, error)
}

type SymlinkManager

type SymlinkManager interface {
	Link(oldname, newname string) error
	Unlink(path string) error
}

type Symlinker

type Symlinker struct {
}

func NewSymlinker

func NewSymlinker() Symlinker
func (s Symlinker) Link(oldname, newname string) error
func (s Symlinker) Unlink(path string) error

type YarnInstallProcess

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

func NewYarnInstallProcess

func NewYarnInstallProcess(executable Executable, summer Summer, logger scribe.Emitter) YarnInstallProcess

func (YarnInstallProcess) Execute

func (ip YarnInstallProcess) Execute(workingDir, modulesLayerPath string, launch bool) error

The build process here relies on yarn install ... --frozen-lockfile note that even if we provide a node_modules directory we must run a 'yarn install' as this is the ONLY way to rebuild native extensions.

func (YarnInstallProcess) SetupModules

func (ip YarnInstallProcess) SetupModules(workingDir, currentModulesLayerPath, nextModulesLayerPath string) (string, error)

func (YarnInstallProcess) ShouldRun

func (ip YarnInstallProcess) ShouldRun(workingDir string, metadata map[string]interface{}) (run bool, sha string, err error)

Directories

Path Synopsis
cmd
setup-symlinks command

Jump to

Keyboard shortcuts

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