IgniteUI / igniteui-cli

Ignite UI Command-Line Interface by Infragistics
https://bit.ly/2L19rhp
MIT License
120 stars 4 forks source link

Error when creating licensed project with ng new with igniteui/angular-schematics #1349

Open valadzhov opened 1 week ago

valadzhov commented 1 week ago

Description

Describe the issue.

Steps to reproduce

  1. Install the latest igniteui/angular-schematics
  2. Create a new project with ng new --collection="@igniteui/angular-schematics"
  3. Create a project (doesn't matter what).
  4. Run the project and choose to upgrade the license feed.

Result

There is an error: image

Expected result

There shouldn't be an error when the license feed is chosen.

valadzhov commented 1 week ago

Once this issue is resolved the information about it in the Wiki should be deleted ("Currently there is an issue when executing the command...").

jackofdiamond5 commented 6 days ago

The reason why this error occurs is because currently the upgrade logic relies on the existence of an ignite-ui-cli.json. Let me try to shed some light on what's happening.

First, the ng new igniteui/angular-schematics is executed and following the spawned prompt session a project is generated.

Then if the user has chosen to apply licensing, the following logic is executed: image

In this context, the projTemplate can either point to packages\igx-templates\igx-ts\projects\_base\index.ts or packages\igx-templates\igx-ts-legacy\projects\_base\index.ts but these two files are more or less identical and they both define a upgradeIgniteUIPackages. image

upgradeIgniteUIPackages will in turn execute updateWorkspace which points to packages/core/update/Update.ts. The logic in the updateWorkspace method attempts to load a config file, which refers to the ignite-ui-cli.json file. It does so because later it wants to find the framework which the update is called for as the logic was written with the mindset of supporting multiple platforms.

This is where the throw occurs: image

When executing ng new igniteui/angular-schematics the config file does not yet exist, so the update logic cannot read the framework. Moreover, executing an Angular schematic should not have to rely on the existence of a config file, since the schematic can be executed outside of the CLI's context. One easy fix here is to just allow upgradeIgniteUIPackages to send the framework when we run the ng-new schematic, as we definitely know we are dealing with the Angular framework.