noderunscript

package module
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Node Run Script Cloud Native Buildpack

https://hub.docker.com/r/initializbuildpacks/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(npm Executable, yarn Executable, clock chronos.Clock, logger scribe.Logger, env Environment) packit.BuildFunc

func Detect

func Detect(env Environment) packit.DetectFunc

func ScriptsToRun

func ScriptsToRun(workingDir string, nodeRunScripts string) ([]string, string, error)

Types

type BuildPlanMetadata

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

type Environment

type Environment struct {
	LogLevel       string
	NodeRunScripts string
}

func LoadEnvironment

func LoadEnvironment(variables []string) Environment

type Executable

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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