Skip to content

Adding durable dependency if not present in package.json for node - #5495

Merged
Naren Soni (soninaren) merged 2 commits into
mainfrom
nasoni/nodeTemplatesFix
Jul 28, 2026
Merged

Naren Soni (soninaren) merged 2 commits into
mainfrom
nasoni/nodeTemplatesFix

Conversation

@soninaren

@soninaren Naren Soni (soninaren) commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

This pull request adds support for automatically managing the durable-functions npm package dependency when creating Node.js v4 (JavaScript/TypeScript) Azure Functions using Durable Functions templates. Now, when a user creates an orchestrator or entity function, the CLI ensures that the correct dependency is added to package.json and attempts to install it, improving the developer experience and reducing manual setup steps. The changes also include comprehensive end-to-end tests to verify this behavior.

Enhancements to Durable Functions dependency management:

  • Added a new method EnsureDurableFunctionsNpmPackage in TemplatesManager.cs that checks if the selected template is a Durable Functions orchestrator or entity, and if so, adds the durable-functions dependency (version ^3.x) to package.json and runs npm install unless in offline mode or if npm is not available. [1] [2]
  • Introduced new constants in Constants.cs for the Durable Functions npm package name, version, and trigger types for orchestration and entity.

Testing improvements:

  • Added three new end-to-end tests in NodeTests.cs to verify:
    • The durable-functions dependency is added for JavaScript orchestrator and TypeScript entity templates.
    • The dependency is not added for non-durable templates (e.g., HTTP trigger).

Code quality:

  • Added Newtonsoft.Json.Linq import for working with JSON objects in TemplatesManager.cs.

Issue describing the changes in this PR

resolves #5492

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

@soninaren
Naren Soni (soninaren) requested a review from a team as a code owner July 24, 2026 23:10
Comment thread src/Cli/func/Common/TemplatesManager.cs Resolved
@satvu
sarah (satvu) requested a review from Copilot July 27, 2026 22:02

@satvu sarah (satvu) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be added to the release notes for tracking?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the Node.js v4 template experience for Durable Functions by ensuring the durable-functions npm dependency is added to package.json when creating Durable orchestrator/entity functions, and (when possible) attempting to run npm install. It also adds E2E coverage to validate dependency injection behavior for durable vs non-durable templates.

Changes:

  • Add EnsureDurableFunctionsNpmPackage to update package.json for Node v4 Durable orchestrator/entity templates and optionally run npm install.
  • Introduce constants for the durable npm package name/version and relevant trigger types.
  • Add E2E tests verifying the dependency is added for durable templates and not added for non-durable templates.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/Cli/Func.E2ETests/Commands/FuncNew/NodeTests.cs Adds E2E tests asserting durable-functions is injected (or not) into package.json depending on template type.
src/Cli/func/Common/TemplatesManager.cs Implements durable dependency injection into package.json for Node v4 templates and triggers an npm install attempt.
src/Cli/func/Common/Constants.cs Adds constants for durable package/version and durable trigger-type identifiers.

Comment thread src/Cli/func/Common/TemplatesManager.cs Resolved
Address PR #5495 review feedback: NpmHelper.Install/RunNpmCommand now return
the npm exit code so EnsureDurableFunctionsNpmPackage can warn the user when
'npm install' fails (previously swallowed due to ignoreError=true), while
keeping the behavior best-effort. Added a release note entry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7ba7065d-e60a-4c7e-91d1-ebdf627969d9
@soninaren
Naren Soni (soninaren) merged commit 5296f01 into main Jul 28, 2026
42 checks passed
@soninaren
Naren Soni (soninaren) deleted the nasoni/nodeTemplatesFix branch July 28, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Durable function package dependencies are missing when creating node durable functions via templates

4 participants