Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDependenciesUpToDate ¶
func IsDependenciesUpToDate(projectDir string, pm PackageManagerKind) bool
IsDependenciesUpToDate checks if node_modules is up-to-date relative to the lock file. This avoids unnecessary reinstalls when dependencies haven't changed. Pattern borrowed from azd-app extension's installer.
Types ¶
type Cli ¶
type Cli interface {
tools.ExternalTool
Install(ctx context.Context, projectPath string, env []string) error
RunScript(ctx context.Context, projectPath string, scriptName string, env []string) error
Prune(ctx context.Context, projectPath string, production bool, env []string) error
PackageManager() PackageManagerKind
}
Cli defines the interface for Node.js package manager operations. Separate implementations for npm, pnpm, and yarn handle PM-specific behaviors.
func NewCli ¶
func NewCli(commandRunner exec.CommandRunner) Cli
NewCli creates a CLI using the default package manager (npm).
func NewCliWithPackageManager ¶
func NewCliWithPackageManager(commandRunner exec.CommandRunner, pm PackageManagerKind) Cli
NewCliWithPackageManager creates a CLI for the specified package manager.
type PackageManagerKind ¶
type PackageManagerKind string
PackageManagerKind represents the type of Node.js package manager.
const ( PackageManagerNpm PackageManagerKind = "npm" PackageManagerPnpm PackageManagerKind = "pnpm" PackageManagerYarn PackageManagerKind = "yarn" )
func DetectPackageManager ¶
func DetectPackageManager(projectDir string) PackageManagerKind
DetectPackageManager determines the Node.js package manager to use for a given project directory. Detection priority (matches azd-app extension):
- "packageManager" field in package.json (e.g., "[email protected]")
- Lock file presence: pnpm-lock.yaml → pnpm-workspace.yaml → yarn.lock → package-lock.json
- Default: npm