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(build): support tilde expansion on windows #563

Merged
merged 1 commit into from Jul 13, 2021
Merged

Conversation

hiepxanh
Copy link
Contributor

Platforms affected

Android, ios, Browser

What does this PR do?

I struggeling with home path every time changing build computer or transfer code to my teammate computer. the build.json config does not find home path on window with "command line" or "power shell". there is no tutorial about this. I have to go to build file to know that there is ~ equivalent with $HOME and %HOMEPATH% on window.
I think it is feature?

What testing has been done on this change?

Checklist

  • Reported an issue in the JIRA database
  • Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
  • Added automated test coverage as appropriate for this change.

janpio
janpio previously requested changes Nov 16, 2018
Copy link
Member

@janpio janpio left a comment

Choose a reason for hiding this comment

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

Code is currently broken

bin/templates/cordova/lib/build.js Outdated Show resolved Hide resolved
@janpio
Copy link
Member

janpio commented Nov 16, 2018

Hm, first time I see this. Is the ~ behavior documented anywhere? Where did you learn that you can do it this way?

Also: Isn't the code here currently already exactly for making it possible to use ~ on Windows, where this isn't supported out of the box?

@hiepxanh
Copy link
Contributor Author

hiepxanh commented Nov 18, 2018

Hm, first time I see this. Is the ~ behavior documented anywhere? Where did you learn that you can do it this way?

=> It take me to 5 hours to learn that there is no documented or any suggestion from google ( I was read about 10 google pages <=> 50 web page with a lot of try times) but it have nothing. Then, I go to read the source code. The document is lack of this.
The situation when you have a team with alot of computer, you have different home path.

Also: Isn't the code here currently already exactly for making it possible to use ~ on Windows, where this isn't supported out of the box?

=> yes it support windows. that very nice, except:
not every body install $HOME enviroment variable as home path. Only after I read the source code. I found out that I have to use ~ and it match to variable $HOME, but I dont have that path ??. Then I have to update my window enviroment variable with this path.

that was take a lot of time.

@codecov-io
Copy link

codecov-io commented Nov 18, 2018

Codecov Report

Merging #563 into master will decrease coverage by 0.18%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #563      +/-   ##
==========================================
- Coverage   62.11%   61.92%   -0.19%     
==========================================
  Files          17       17              
  Lines        1985     1991       +6     
  Branches      371      374       +3     
==========================================
  Hits         1233     1233              
- Misses        752      758       +6
Impacted Files Coverage Δ
bin/templates/cordova/lib/build.js 27.2% <0%> (-1.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1396c7...a2ca994. Read the comment docs.

@janpio
Copy link
Member

janpio commented Nov 18, 2018

So your issue is that you develop your app on different computers. To be able to use the same build.json on all machines, you used ~ in the path to the keystore - but this didn't work as HOME was not correctly set on some machines. Is that correct?

And to "fix" that, you now implemented this PR that allows the usage of $HOME, %HOMEPATH% and %USERPROFILE% instead of only ~ in the path of the keystore. But doesn't this still mean that all computer using the build.json still have to have exactly one of those environment variables set to work?

Wouldn't it make more sense to try to replace ~ with all those environment variables, whichever are available instead of just offering alternatives?

Is the usage of ~ in paths properly documented somewhere?

@janpio
Copy link
Member

janpio commented Nov 18, 2018

After writing this, I decided to look into why this tilde code is there in the first place:
d78ae30
https://issues.apache.org/jira/browse/CB-10105
Maybe this is not needed any more in the first place as the problem in node was fixed?

Your original issue nd problem seems more like an unintended side effect of this "hack" that was used to work around this node problem.

Anyway, the usage of environment variables in the path itself is a totally new and different feature and I am not sure this is the way to go.

@brodybits
Copy link
Contributor

Thanks @hiepxanh for the proposal, my response is in apache/cordova-cli#359 (comment).

@raphinesse
Copy link
Contributor

raphinesse commented Nov 18, 2018

@janpio I'm not aware that the lack of tilde expansion has ever been accepted as being a bug in Node.js. AFAIK, it had always been like that and there are a variety of libraries for this use-case. I prefer https://www.npmjs.com/package/untildify

@janpio
Copy link
Member

janpio commented Nov 18, 2018

Thanks @raphinesse for this necessary context.

So if we decide to keep this functionality, it would probably make sense to switch over to using this package (any maybe make this available to all platforms along the way?). The package uses os.homedir() internally, which is probably a lot more stable than any hack we can place in our code ourselves. Agree?

@brodybits
Copy link
Contributor

So if we decide to keep this functionality, it would probably make sense to switch over to using this package (any maybe make this available to all platforms along the way?).

Agreed on my part and I would definitely favor making this available to all platforms. (I was about to suggest the same idea.)

janpio
janpio previously requested changes Nov 18, 2018
Copy link
Member

@janpio janpio left a comment

Choose a reason for hiding this comment

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

suggested changes don't actually solve the underlying problem and create more unrelated problems

@brodybits
Copy link
Contributor

suggested changes don't actually solve the underlying problem [...]

I think that means changes suggested 2 days ago and not the recent suggestion to use untildify.

@janpio
Copy link
Member

janpio commented Nov 18, 2018

@brodybits Pull Request reviews relate to the code being suggested in the Pull Request, so of course yes, this does not refer to the comments and discussion made here - I just made sure it is clear that the suggested code should not be merged by anyone.

@hiepxanh
Copy link
Contributor Author

@janpio @brodybits thank you for reviewing my small idea. I think this will be helpful and help alot of people like me. Have to build code with team have different develop enviroment. I agree that my solution not work with all platforms and not a global solution. So I think that we should use @raphinesse suggested library. It will be nice.
thank you for helping me. Should I try to use that library in my code then you can continue review or you will help me to do that and I will close this issue?

@brodybits
Copy link
Contributor

@hiepxanh it would be great if you could try using untildify to solve the problem. Let's keep your proposals open for now. @janpio entered reviews with "changes requested" on all your proposals to tell the other committers not to merge them prematurely.

@hiepxanh
Copy link
Contributor Author

@brodybits yes sir. I will do it

@janpio janpio added this to 🐣 New PR / Untriaged in Apache Cordova: Platform Pull Requests Dec 8, 2018
@brodybits brodybits added the bug label Jun 12, 2020
@erisu erisu changed the title [Fix] better support to find Home path for window fix(windows): improve support to find home path Mar 27, 2021
@erisu erisu added this to the 10.0.0 milestone Apr 13, 2021
@erisu erisu added this to In Progress in Release Plan - 10.1.0 via automation Apr 13, 2021
Apache Cordova: Platform Pull Requests automation moved this from 🐣 New PR / Untriaged to 🙅 Pending Approval Jul 13, 2021
Release Plan - 10.1.0 automation moved this from In Progress to Review in progress Jul 13, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2021

Codecov Report

Merging #563 (09a870a) into master (16ff6e1) will increase coverage by 0.06%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #563      +/-   ##
==========================================
+ Coverage   73.20%   73.26%   +0.06%     
==========================================
  Files          21       21              
  Lines        1646     1646              
==========================================
+ Hits         1205     1206       +1     
+ Misses        441      440       -1     
Impacted Files Coverage Δ
lib/build.js 40.59% <50.00%> (+0.99%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16ff6e1...09a870a. Read the comment docs.

@raphinesse raphinesse changed the title fix(windows): improve support to find home path fix(build): support tilde expansion on windows Jul 13, 2021
Copy link
Contributor

@raphinesse raphinesse left a comment

Choose a reason for hiding this comment

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

I redid the fix using untildify

Apache Cordova: Platform Pull Requests automation moved this from 🙅 Pending Approval to ✅ Approved, waiting for Merge Jul 13, 2021
Release Plan - 10.1.0 automation moved this from Review in progress to Reviewer approved Jul 13, 2021
@erisu erisu merged commit 68a302e into apache:master Jul 13, 2021
Apache Cordova: Platform Pull Requests automation moved this from ✅ Approved, waiting for Merge to 🏆 Merged, waiting for Release Jul 13, 2021
Release Plan - 10.1.0 automation moved this from Reviewer approved to Done Jul 13, 2021
wedgberto pushed a commit to wedgberto/cordova-android that referenced this pull request May 17, 2022
Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Apache Cordova: Platform Pull Requests
🏆 Merged, waiting for Release
Development

Successfully merging this pull request may close these issues.

None yet

7 participants