Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Chore: Migrating from using the cordova-res package to using the capacitor-assets package for asset generation #2364
base: master
Are you sure you want to change the base?
Chore: Migrating from using the cordova-res package to using the capacitor-assets package for asset generation #2364
Changes from 4 commits
0542ffa
3bfbc3c
2fab38c
3e441a7
a423a93
12f4ca1
cf99cf6
c4f3033
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Hopefully this is working now and this comment can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this works, why do we need the more complicated final version where the path gets manipulated to remove the
../../
and then the process gets run relative to a different directory? Or is it only that latter version that works?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that I have removed that function. Regarding the
../../
, I am not sure why it is the case. I think it has to do with how the assetPath flag works. But I have removed the code that this comment is referring too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can see that this code is now removed. But I was thinking – if this logic (now removed) works, why not use this logic in the
set_icons_and_splash_images
function that remains? Is it that this logic never actually worked?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know whether the file has to be a
.png
? Either way, I think it would be better to check whether the path is to a file in a more general way. Have a look at these docs (we're already importingfs
so can use its methods)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this accomplishing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is within the methods for
android.ts
. I believe they check if the folder to the assets actually existsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at this line again.
iconAndSplashSources
isn't being consumed anywhere, so what does pushing a value to it accomplish? I think you can replace lines 55-63 with something like:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure what this one is supposed to accomplish really. It was here during the Cordova options, so I just pasted it in the new function.
I have made your changes though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a nicer way to do this, without the
.replace()
and regex? Potentially an existing method ofpath
? It could be worth thinking if this whole logic of manipulating the path and then then executing the command relative to thecwd
could be simplified (I'm not saying that it definitely can, but it's quite hard to follow currently)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment on line 68 below. I think this line could also use the
ROOT_DIR
value instead ofprocess.cwd()
, and avoid doing the regex replacement. Try logging outROOT_DIR
andassetPath
at this point, and see if there's a method(s) ofpath
that could be used to combine them and give the output you wantThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the change here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Rather than doing a string replace, it would probably be better to use the
path
npm library to get the correct path – path.relative(from, to) might be what you needThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found out that only relative paths work for the
npx
command, so I am attempting to find methods of converting the path to a relative one (without the/../..
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With research ( and help with ChatGPT ), this may be the best way to get rid of leading dots in a directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Line 68 is effectively just getting the relative path to the root directory, right? I think you can delete this line and instead import
ROOT_DIR
frompackages/scripts/src/paths.ts
(look at the file changes for this PR, you'll see thatpackages/scripts/src/tasks/providers/android.ts
used to importROOT_DIR
). Then you should be able to just pass this value to theexecSync()
function below, like:See also comment on line 65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made these changes, and they function the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think again that this should be "icon-only.png" instead of "icon.png". And no harm in linking to the docs again... Also copy over this comment to corresponding Android equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one may have to be changed within the gdrive. The comment I have changed but the actual name itself might have to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
icon.png
should beicon-only.png
insteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too sure what this comment is specifically referencing. When I checked my assets, the image was called
icon.png
. However, I think any name changes can be solved by accessing the Google Drive.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going off the docs, which suggest that the source asset should be called "icon-only.png". So I think that's what this comment should specify as the name for the source file too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay will do