noderunscript

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Node Run Script Cloud Native Buildpack

gcr.io/paketo-buildpacks/node-run-script

The Node Run Script CNB runs any arbitrary scripts desired for the given application. The scripts run are determined by the environment variable BP_NODE_RUN_SCRIPTS and run scripts specified in the contents of package.json. For example, given a package.json and BP_NODE_RUN_SCRIPTS var with the following content:

{
    "scripts": {
        "build": "<build-commands>",
        "deploy": "<deploy-commands>",
        "another-script": "<some-other-commands>"
    }
}

BP_NODE_RUN_SCRIPTS="build,another-script"

The scripts build and another-script will be run through npm run-script or yarn run.

Integration

This CNB currently does not provide anything specific and is purposed primarily to run scripts in node framework apps, so there's no scenario we can imagine where you would need to require it as a dependency.

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 \
-b <path/to/node-and-yarn-requiring-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 (e.g. 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.

Specifying the scripts to be run

To specify which scripts inside package.json you would like to run, please use the BP_NODE_RUN_SCRIPTS environment variable at build time either directly or through a project.toml file. The value of the variable should be a comma separated list of events listed in the app's package.json

Run Tests

To run all unit tests, run:

./scripts/unit.sh

To run all integration tests, run:

/scripts/integration.sh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(npmExec Executable, yarnExec Executable, scriptManager PackageInterface, clock chronos.Clock, logger scribe.Logger) packit.BuildFunc

func Detect

func Detect(scriptManager PackageInterface) packit.DetectFunc

Types

type BuildPlanMetadata

type BuildPlanMetadata struct {
	Build bool `toml:"build"`
}

type Executable

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

type PackageInterface

type PackageInterface interface {
	GetPackageScripts(path string) (map[string]string, error)
	GetPackageManager(path string) string
}

type ScriptManager

type ScriptManager struct{}

func NewScriptManager

func NewScriptManager() *ScriptManager

func (*ScriptManager) GetPackageManager

func (s *ScriptManager) GetPackageManager(path string) string

func (*ScriptManager) GetPackageScripts

func (s *ScriptManager) GetPackageScripts(path string) (map[string]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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