fix(functions): forward NPM_AUTH_TOKEN to deploy bundler container by addniner · Pull Request #4933 · supabase/cli

Summary

The Docker bundler for functions deploy only passes NPM_CONFIG_REGISTRY to the container environment (added in #3020). When .npmrc uses ${NPM_AUTH_TOKEN} for private registry authentication, the variable is not available inside the container, causing 401 errors.

This PR forwards NPM_AUTH_TOKEN from the host environment to the Docker container, following the same pattern established in #3020.

Reproduction

# Method Result Error
1 supabase functions deploy hello (.npmrc with ${NPM_AUTH_TOKEN}) Fail 401 unauthenticated
2 NPM_AUTH_TOKEN=xxx supabase functions deploy hello Fail 401 unauthenticated (env not forwarded to container)
3 .npmrc with hardcoded token Pass -
4 NPM_AUTH_TOKEN=xxx with patched CLI Pass -

Tested with a private package (@addniner/test-private-pkg) on GitHub Packages, with Docker cache cleared between attempts.

Change

3-line addition in internal/functions/deploy/bundle.go, same pattern as the existing NPM_CONFIG_REGISTRY forwarding:

if authToken := os.Getenv("NPM_AUTH_TOKEN"); authToken \!= "" {
    env = append(env, "NPM_AUTH_TOKEN="+authToken)
}

Closes #4927