Add packageManager config to JS/TS hook executors
Background & Motivation
Users running JS/TS hooks need to use the same package manager as their project (pnpm, yarn). Today the hook executor auto-detects from lock files but provides no override, unlike the framework service which supports ServiceConfig.Config["packageManager"]. This creates a parity gap between service configuration and hook configuration.
User Story
As a developer using pnpm/yarn, I want to specify packageManager in my hook config so that my JS/TS hooks use the correct package manager without relying on lock file detection.
Solution Approach
- Read
Config["packageManager"] in JS/TS executor Prepare() phase via execCtx.Config
- Reuse existing
packageManagerFromConfig() validation pattern from framework_service_node.go
- Pass override to
node.NewCliWithPackageManager() instead of auto-detecting
- Applies to both
js_executor.go and ts_executor.go (shared via node_helpers.go)
- Define a strongly-typed
nodeHookConfig struct and unmarshal from execCtx.Config:
type nodeHookConfig struct {
PackageManager string `json:"packageManager"` // npm, pnpm, yarn
}
- Accepted values:
npm, pnpm, yarn (same as ServiceConfig)
Example azure.yaml
hooks:
postprovision:
run: ./hooks/setup.ts
kind: ts
config:
packageManager: pnpm
Acceptance Criteria
Default when omitted: Auto-detect from lock files (existing behavior)
Out of Scope
- Custom install flags (e.g.,
--no-audit) — future enhancement
- TypeScript runtime selection (
tsRuntime) — separate P1 issue
- Bun or Deno support — not currently supported in azd
Testing Expectations
- Unit tests: table-driven tests for config unmarshalling, validation, and CLI selection
- Test that override beats auto-detection when both are present
- Test invalid/malformed config values
Constraints
- Must match the same
packageManager values accepted by ServiceConfig.Config for consistency
Related Issues
Add
packageManagerconfig to JS/TS hook executorsBackground & Motivation
Users running JS/TS hooks need to use the same package manager as their project (pnpm, yarn). Today the hook executor auto-detects from lock files but provides no override, unlike the framework service which supports
ServiceConfig.Config["packageManager"]. This creates a parity gap between service configuration and hook configuration.User Story
As a developer using pnpm/yarn, I want to specify
packageManagerin my hook config so that my JS/TS hooks use the correct package manager without relying on lock file detection.Solution Approach
Config["packageManager"]in JS/TS executorPrepare()phase viaexecCtx.ConfigpackageManagerFromConfig()validation pattern fromframework_service_node.gonode.NewCliWithPackageManager()instead of auto-detectingjs_executor.goandts_executor.go(shared vianode_helpers.go)nodeHookConfigstruct and unmarshal fromexecCtx.Config:npm,pnpm,yarn(same as ServiceConfig)Example azure.yaml
Acceptance Criteria
config.packageManager: pnpmcauses JS/TS hooks to use pnpm for installconfig.packageManager: yarncauses JS/TS hooks to use yarn for installpackageManagerpreserves current auto-detection behavior (lock file → default npm)bun) produce a clear error messageDefault when omitted: Auto-detect from lock files (existing behavior)
Out of Scope
--no-audit) — future enhancementtsRuntime) — separate P1 issueTesting Expectations
Constraints
packageManagervalues accepted byServiceConfig.Configfor consistencyRelated Issues
Config map[string]anyonExecutionContext