Skip to content

fix(upgrade-packages): detect framework & run without ignite-ui-cli.json#1690

Open
Copilot wants to merge 6 commits into
masterfrom
copilot/fix-upgrade-packages-error
Open

fix(upgrade-packages): detect framework & run without ignite-ui-cli.json#1690
Copilot wants to merge 6 commits into
masterfrom
copilot/fix-upgrade-packages-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

ig upgrade-packages throws Cannot read properties of undefined (reading 'framework') when run in a project without ignite-ui-cli.json, since config.project is undefined when no local config exists.

Changes

  • Auto-detect framework: When config.project.framework is absent, fall back to the existing detectFrameworkFromPackageJson() utility to infer the framework from package.json dependencies
  • Safe property access: Use optional chaining on config.project?.framework, config.project?.projectType, and config.project?.projectTemplate
  • Derive projectType: Map detected framework to its project type (angular→igx-ts, react→igr-ts, webcomponents→igc-ts) when not specified in config
  • Informative error: Log a clear message when neither config nor package.json can determine the framework
// Before: crashes when config.project is undefined
const framework = config.project.framework;

// After: falls back to package.json detection
let framework = config.project?.framework;
if (!framework) {
    const detected = detectFrameworkFromPackageJson();
    if (!detected) {
        Util.log("Unable to determine the project framework. ...", "yellow");
        return;
    }
    framework = detected;
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.google-analytics.com
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js new --help (dns block)
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js config --help (dns block)
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js generate --help (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix ig upgrade-packages error for ignite-ui-cli.json Fix upgrade-packages crash when ignite-ui-cli.json is missing May 15, 2026
Copilot finished work on behalf of kdinev May 15, 2026 10:29
Copilot AI requested a review from kdinev May 15, 2026 10:29
@coveralls
Copy link
Copy Markdown

coveralls commented May 15, 2026

Coverage Status

coverage: 87.455% (+0.08%) from 87.371% — copilot/fix-upgrade-packages-error into master

@kdinev kdinev requested a review from damyanpetev May 19, 2026 07:36
Comment thread packages/cli/lib/commands/upgrade.ts Outdated
if (!framework) {
const detected = detectFrameworkFromPackageJson();
if (!detected) {
Util.log("Unable to determine the project framework. " +
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.

@copilot Can use Util.warn then to put this in the right standard io (can keep the explicit color) and you will need to spy that for the message test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switched to Util.warn and updated the test to spy on it. Done in a637180.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 19, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.google-analytics.com
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js new --help de_modules/.bin/tsx ma && npm run build:mcp (dns block)
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js config --help (dns block)
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js generate --help (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from damyanpetev May 19, 2026 08:51
@damyanpetev damyanpetev marked this pull request as ready for review May 19, 2026 08:52
Copilot AI review requested due to automatic review settings May 19, 2026 08:52
@damyanpetev damyanpetev changed the title Fix upgrade-packages crash when ignite-ui-cli.json is missing fix(upgrade-packages): detect framework & run without ignite-ui-cli.json May 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 aims to prevent ig upgrade-packages from crashing when a project has no local ignite-ui-cli.json by safely reading config.project and falling back to framework detection from package.json.

Changes:

  • Add optional chaining for config.project access and fall back to detectFrameworkFromPackageJson() when framework is missing.
  • Derive a default projectType from the detected framework via a simple mapping.
  • Add unit tests covering the “no config” detection path and the “cannot detect framework” warning path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/cli/lib/commands/upgrade.ts Adds framework/package.json fallback and derives projectType when config is missing.
spec/unit/upgrade-spec.ts Adds unit tests for framework auto-detection and the warning when detection fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 34 to +44
const config = ProjectConfig.getConfig();
const framework = config.project.framework;
const projectType = config.project.projectType;
let framework = config.project?.framework;
let projectType = config.project?.projectType;

if (!framework) {
const detected = detectFrameworkFromPackageJson();
if (!detected) {
Util.warn("Unable to determine the project framework. " +
"Please ensure you are running this command in a project directory with a package.json file, " +
"or create an ignite-ui-cli.json configuration file.", "yellow");
return;
Comment on lines 62 to 67
const projectLibrary = templateManager.getProjectLibrary(framework, projectType);
let project: ProjectTemplate;
if (!config.project.projectTemplate || !projectLibrary.hasProject(config.project.projectTemplate)) {
if (!config.project?.projectTemplate || !projectLibrary.hasProject(config.project.projectTemplate)) {
// in case project template is missing from the config we provide backward.
project = projectLibrary.getProject(projectLibrary.projectIds[0]);
} else {
Comment thread spec/unit/upgrade-spec.ts
Comment on lines +149 to +153
it("Should auto-detect framework from package.json when config has no project", async () => {
const config = {} as Config;
spyOn(ProjectConfig, "getConfig").and.returnValue(config);
spyOn(detectFrameworkModule, "detectFrameworkFromPackageJson").and.returnValue("react");

angular: "igx-ts",
react: "igr-ts",
webcomponents: "igc-ts"
};
Copy link
Copy Markdown
Member

@damyanpetev damyanpetev May 19, 2026

Choose a reason for hiding this comment

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

Might be worth to add default project type per framework (bit out of scope), even though those are currently singular IIRC and templateManager.getProjectLibrary will return the first if type is not supplied, so this can possibly even be dropped. Need to check tho.

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.

ig upgrade-packages throws an error when it doesn't find any ignite-ui-cli.json

5 participants