Skip to content

feat(cli): add automatic CLI version selection and temporary execution for ig update - #1891

Open
georgianastasov wants to merge 10 commits into
ganastasov/ig-update-commandfrom
ganastasov/temporary-cli-version
Open

georgianastasov wants to merge 10 commits into
ganastasov/ig-update-commandfrom
ganastasov/temporary-cli-version

Conversation

@georgianastasov

Copy link
Copy Markdown
Contributor

Related to #1847

Description

Enhances ig update with automatic CLI version selection and temporary execution, ensuring updates can run using a newer compatible igniteui-cli without requiring users to manually upgrade their global CLI installation.

When updating packages in React or Web Components projects, the CLI checks whether a newer compatible version is available and temporarily uses it to perform the update.

Key changes:

  • CLI version selection: Prefers the appropriate project-local CLI and checks npm for a newer compatible version, considering Node.js requirements.
  • Temporary CLI execution: Installs the selected CLI version in an isolated temporary directory, forwards the original command, and cleans up afterward.
  • Explicit version requests: Supports selecting the CLI major version through requests such as ig update igniteui-cli@17.
  • Safe fallback: Continues with the current CLI when version checks fail, including offline or unavailable registry scenarios.
  • Reliable execution: Preserves exit codes, handles installation failures, and prevents stale npm cache issues.
  • Analytics: Avoids duplicate analytics events when execution is delegated to a temporary CLI.

The implementation reuses existing npm utilities and preserves the current behavior for Angular, other frameworks, and commands unrelated to ig update.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring / code cleanup
  • Build / CI configuration change

Affected Packages

  • igniteui-cli (packages/cli)
  • @igniteui/cli-core (packages/core)
  • @igniteui/angular-templates (packages/igx-templates)
  • @igniteui/angular-schematics (packages/ng-schematics)
  • @igniteui/mcp-server (packages/igniteui-mcp)

Checklist

  • I have tested my changes locally (npm run test)
  • I have built the project successfully (npm run build)
  • I have run the linter (npm run lint)
  • I have added/updated tests as needed
  • My changes do not introduce new warnings or errors

Additional Context

  • Automated tests: 1015 executed, 0 failures, 2 existing pending specs.
  • Manual E2E: Validated on Windows using an isolated npm registry with CLI 16.0.0 → 16.0.1 test fixtures.
  • Verified React, Web Components, Angular delegation, version selection, explicit versions, update flags, error handling, npm cache, and temporary CLI cleanup.
  • No new defects were confirmed during E2E testing.

Comment thread packages/core/update/version-update.ts Dismissed
@coveralls

coveralls commented Nov 11, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 95.928% — ganastasov/temporary-cli-version into ganastasov/ig-update-command. No base build found for ganastasov/ig-update-command.

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.

🔵 Needs a closer look

The CLI delegates to a local installation without checking its Node.js requirement, risking a startup failure before compatibility checks can preserve the usable invoked CLI.

No open issues 🎉

What changed in this PR

Adds automatic CLI selection and temporary execution to ig update for React and Web Components, extending the update workflow introduced for #1847 without requiring a global CLI upgrade.

Changes:

  • Selects a project-local or newer registry CLI, including explicit major-version requests.
  • Installs temporary runners, forwards arguments, preserves exit codes, and cleans up afterward.
  • Reuses npm helpers and suppresses duplicate analytics during delegated execution.
File Description
spec/​unit/​version-update-spec.ts Tests shared npm command construction and extra arguments.
spec/​unit/​update-runner-spec.ts Tests runner selection, installation, execution, and cleanup.
spec/​unit/​update-command-spec.ts Tests delegation, fallback, analytics, and framework exclusions.
spec/​unit/​GoogleAnalytic-spec.ts Tests environment-based analytics suppression.
spec/​unit/​execute-spec.ts Tests version-aware project-local CLI selection.
packages/​core/​util/​GoogleAnalytics.ts Supports disabling analytics through an environment variable.
packages/​core/​update/​version-update.ts Exports reusable npm helpers and validates Windows shell arguments.
packages/​cli/​lib/​commands/​update.ts Integrates runner selection before updates and migrations.
packages/​cli/​lib/​commands/​update-runner.ts Implements registry selection and temporary CLI execution.
packages/​cli/​bin/​execute.js Adds version-aware local delegation for update.

Review effort: Balanced

This comment was marked as off-topic.

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.

🔵 Needs a closer look

The temporary CLI receives host process arguments instead of the arguments supplied to exported run(args) calls, potentially launching interactive setup rather than the requested update.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Forward run() arguments to the temporary CLI

packages/​cli/​lib/​commands/​update-runner.ts:80

When a newer runner is selected for an exported run(args) call, the temporary CLI receives the host process's arguments instead of the supplied update arguments. For example, run(["update", "igniteui-react", "--dry-run"]) from a script with no command-line arguments launches interactive setup rather than the update. Pass the actual invocation arguments through the update handler to runTemporaryCli instead of reading process.argv here.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants