node

package
v0.0.0-...-113aa42 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRuntimeForProject

func IsRuntimeForProject(ctx context.Context, fs afero.Fs, dirPath string, sdkConfig hooks.SDKCLIConfig) bool

IsRuntimeForProject returns true if dirPath is a Node.js project

Types

type NPM

type NPM interface {
	InstallAllPackages(ctx context.Context, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (string, error)
	InstallDevPackage(ctx context.Context, pkgName string, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (string, error)
	ListPackage(ctx context.Context, pkgName string, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (pkgNameVersion string, exists bool)
}

NPM defines the npm commands to interact with a node project

type NPMClient

type NPMClient struct {
}

NPMClient implements the NPM interface and executes real npm commands

func (*NPMClient) InstallAllPackages

func (n *NPMClient) InstallAllPackages(ctx context.Context, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (string, error)

InstallAllPackages installs all packages by running a command similar to `npm install .`

func (*NPMClient) InstallDevPackage

func (n *NPMClient) InstallDevPackage(ctx context.Context, pkgName string, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (string, error)

InstallDevPackage installs the specified package and saves it as a "devDependency" by running a command similar to `npm install --save-dev <package>`

func (*NPMClient) ListPackage

func (n *NPMClient) ListPackage(ctx context.Context, pkgName string, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (pkgNameVersion string, exists bool)

ListPackage lists the installed version of a provided package

type NPMMock

type NPMMock struct {
	mock.Mock
}

NPMMock mocks the NPM interface.

func (*NPMMock) InstallAllPackages

func (n *NPMMock) InstallAllPackages(ctx context.Context, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (string, error)

InstallAllPackages mocks the `npm install .` command

func (*NPMMock) InstallDevPackage

func (n *NPMMock) InstallDevPackage(ctx context.Context, pkgName string, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (string, error)

InstallDevPackage mocks the `npm install --save-dev <package>` command

func (*NPMMock) ListPackage

func (n *NPMMock) ListPackage(ctx context.Context, pkgName string, dirPath string, hookExecutor hooks.HookExecutor, ios iostreams.IOStreamer) (pkgNameVersion string, exists bool)

ListPackage mocks the `npm list` command

type Node

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

Node runtime type

func New

func New() *Node

New creates a new Node runtime

func (*Node) HooksJSONTemplate

func (n *Node) HooksJSONTemplate() []byte

HooksJSONTemplate returns the default hooks.json template

func (*Node) IgnoreDirectories

func (n *Node) IgnoreDirectories() []string

IgnoreDirectories is a list of directories to ignore when packaging the runtime for deployment.

func (*Node) InstallProjectDependencies

func (n *Node) InstallProjectDependencies(
	ctx context.Context,
	dirPath string,
	hookExecutor hooks.HookExecutor,
	ios iostreams.IOStreamer,
	fs afero.Fs,
	os types.Os,
) (string, error)

InstallProjectDependencies runs `npm install` in the dirPath

func (*Node) Name

func (n *Node) Name() string

Name prints the name of the runtime

func (*Node) PreparePackage

func (n *Node) PreparePackage(ctx context.Context, sdkConfig hooks.SDKCLIConfig, hookExecutor hooks.HookExecutor, opts types.PreparePackageOpts) error

PreparePackage will prepare and copy the app in projectDirPath to tmpDirPath as a release-ready bundle.

func (*Node) SetVersion

func (n *Node) SetVersion(version string)

SetVersion sets the Version value

func (*Node) Version

func (n *Node) Version() string

Version is the runtime version used by the hosted app deployment

Jump to

Keyboard shortcuts

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