Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ng-update): properly handle update from different working directory #19933

Conversation

devversion
Copy link
Member

In some situations, developers will run ng update from a sub directory
of the project. This currently results in a noop migration as file
system paths were computed incorrectly. This is because ng-update
always assumed that the CWD is the workspace root in the real file
system. This is not the case and therefore threw off path resolution.

We can fix this by determining the workspace file system path from
the virtual file system host tree's. This is not ideal, but best
solution for now until we can parse/resolve TypeScript projects
purely from within the virtual file system. This is currently
not easy to implement and requires helpers from TS which are
not exposed yet. See: microsoft/TypeScript#13793.

This is tracked with: COMP-387.

Fixes #19779.

In some situations, developers will run `ng update` from a sub directory
of the project. This currently results in a noop migration as file
system paths were computed incorrectly. This is because ng-update
always assumed that the CWD is the workspace root in the real file
system. This is not the case and therefore threw off path resolution.

We can fix this by determining the workspace file system path from
the virtual file system host tree's. This is not ideal, but best
solution for now until we can parse/resolve TypeScript projects
purely from within the virtual file system. This is currently
not easy to implement and requires helpers from TS which are
not exposed yet. See:
microsoft/TypeScript#13793.

This is tracked with: COMP-387.

Fixes angular#19779.
@devversion devversion added P2 The issue is important to a large percentage of users, with a workaround merge safe target: patch This PR is targeted for the next patch release labels Jul 9, 2020
@devversion devversion requested a review from jelbourn as a code owner July 9, 2020 22:08
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 9, 2020
if (!(tree.root instanceof HostDirEntry)) {
return null;
}
const hostTree = tree.root['_tree'];
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment about this private accesses in this function?

* Gets the workspace file system path from the given tree. Returns
* `null` if the path could not be determined.
*/
// TODO: Remove this once we have a fully virtual TypeScript compiler host: COMP-387
Copy link
Member

Choose a reason for hiding this comment

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

nit: the TODO should go above the JsDoc block

@devversion devversion closed this Jul 10, 2020
@devversion
Copy link
Member Author

devversion commented Jul 10, 2020

Thanks for reviewing. I went ahead and made the long-term changes that we need anyway in framework too, rather than fiddling more around with the non-ideal tricks to get the TS compiler API work for schematics. See: #19934

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(cdk): Update Failed : Cannot read property 'length' of null
3 participants