-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add support for prebuilt asars #823
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
Conversation
|
Thanks for opening a pull request! Here are some highlighted action items that will help get it across the finish line, from the
Development and triage is community-driven, so please be patient and we will get back to you as soon as we can. |
Codecov Report
@@ Coverage Diff @@
## master #823 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 12
Lines 622 643 +21
=====================================
+ Hits 622 643 +21
Continue to review full report at Codecov.
|
malept
left a comment
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.
Thank you for the pull request! This is an excellent starting point. I've made several comments that should hopefully move this PR in the right direction. Let me know if there's anything I need to clarify.
.editorconfig
Outdated
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 we're going to add this, it should be in a separate PR.
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.
sorry about that, I didn't mean to add that. I was trying to follow the current style and that file made my editor honor it.
NEWS.md
Outdated
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.
Could you please adjust this to conform to the Keep a Changelog format?
docs/api.md
Outdated
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 don't think there needs to be an example for this, it should be self-explanatory.
docs/api.md
Outdated
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.
The description should start with "A path to", like ordering below it.
test/_setup.js
Outdated
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.
This should be in a different PR.
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.
The description needs to be updated.
platform.js
Outdated
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 that if there are other asarOptions other than filename and filename is set, it should warn that the other options won't be used.
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.
should that happen here? or in the argument parsing?
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 should happen here. If it happens in argument parsing, people who use the JS API (such as users of Electron Forge or ember-electron) will not get the warning.
platform.js
Outdated
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 for efficiency purposes, if asar.filename is set, we shouldn't even copy the app directory in the first place. Then we can get rid of this fs.remove call.
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 started to go down that route, but tried to keep the change minimal. I'll short circuit that.
platform.js
Outdated
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.
Could you explain how target is determined? Shouldn't target always be dest?
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 the user specified a directory (containing their app.asar and additional resources) fs-extra's copy requires the dest to be a directory... if the src is a file, it requires dest to be a file.
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's not clear from the docs that you can specify a directory for asar.filename. Although even if it did, I would disagree with it because the name of the option makes that choice not obvious. I think the value of asar.filename should only be an ASAR file.
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.
There should only be one item in devDependencies, and it should be "electron": "1.3.1". Every time we add a new Electron version to the tests, it takes longer to run the tests due to downloading prebuilt binaries.
NEWS.md
Outdated
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.
Minor nit, remove the period and add (#823) at the end.
docs/api.md
Outdated
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.
This is kind of redundant. Let me think about a better way to word this.
platform.js
Outdated
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.
At this point asarOptions should be an instance variable, no need to calculate it twice.
platform.js
Outdated
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 would rather have a real if statement than a multi-line ternary statement.
platform.js
Outdated
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 don't know whether afterPrune and afterCopy hooks should be run, since neither of those operations actually took place, and this.originalResourcesAppDir doesn't actually exist.
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.
Yeah, I didn't know what those hooks were for... I've changed it to just return early.
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 don't think returning early is the right solution... we may have to adjust the hook signature so that it's either the path to the resources app directory, or the path to the app.asar file (which would be a breaking change).
@MarshallOfSound since you have dealt with a lot of code relating to the hooks, you might have some insight here.
test/asar.js
Outdated
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.
This can be:
}).then(exists => t.false(exists, 'app subdirectory should NOT exist when app.asar is built'))
platform.js
Outdated
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.
This should have a test.
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 do you mean? Test that it warns? or test that the other options are ignored? If the later, how should that be done?
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.
Test that it warns. This is an example of doing that (although it should probably be genericized into a function):
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.
done.
malept
left a comment
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'll need to take another pass at the diff later tonight, but one thing I noticed is that it should also be documented in usage.txt (which I should replace with yargs declarations...).
|
I'm also a little worried about the drop in code coverage, but let's see what it looks like after the latest changes go through CI. |
|
I updated the usage.txt. |
platform.js
Outdated
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.
This needs a test.
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
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.
done
malept
left a comment
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.
Aside from the suggestions below, the one thing holding back this PR is how to deal with the hooks. I'm pretty sure that omitting the hooks when asar.filename is set will break Electron Forge, but I don't know exactly what the correct way to resolve that is.
docs/api.md
Outdated
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.
A path to a pre-built asar file (this will circumvent asar generation).
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.
done
test/asar.js
Outdated
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.
Shouldn't this be wrapped in t.true()?
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.
sorry, i’ve been in jest land for a while, i assumed sinon made the assertion. i’ll update.
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.
done
usage.txt
Outdated
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.
path to a pre-built asar file (this will circumvent asar generation)
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.
done
|
None of this is breaking existing configurations. Without adding the The whole point of this option is to take control of the app bundle generation... the hooks can be external to this once the filename is used... if something is needed to be done to the app package, a more general hook can be added? |
|
Never mind, I think I understand those hooks now. With a pre-built asar, you don't need the afterCopy/Prune hooks... all processing has already happened when the asar was generated outside of this tool. I can't think of anything you would need to hook for when specifying your own asar... so I'm sticking with my last comment. Just add a new pre-finalize hook called near the end before signing to allow last minute changes... |
|
RE the hooks issue I believe the operation should throw an error if Also I don't think this option should go into the Also @malept we should just make forge error out instantly if this option is used 😄 |
|
The docs should be updated to note the |
|
I think I got all the suggestions implemented. |
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 wonder if it would be cleaner to deal with prebuiltAsar this way:
initialize () {
debug(`Initializing app in ${this.stagingPath} from ${this.templatePath} template`)
return fs.move(this.templatePath, this.stagingPath, { clobber: true })
.then(() => {
if (this.opts.prebuiltAsar) {
return this.copyPrebuiltAsar()
.then(() => this.removeDefaultApp())
} else {
return this.copyTemplate()
.then(() => this.removeDefaultApp())
.then(() => this.asarApp())
}
})
}
common.js
Outdated
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.
✂️ debug line
common.js
Outdated
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.
Should be !args.derefSymlinks
common.js
Outdated
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.
This should be outside of the CLI argument parsing, as I mentioned yesterday, because it will not give warnings to consumers of the JavaScript API.
docs/api.md
Outdated
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.
The lines are unnecessary.
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 thought it was a nice visual grouping. I'll drop them.
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 if we're going to do that, it should be in a separate PR.
docs/api.md
Outdated
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'd get rid of , or any option related to the copy processes. Also, it's a little too verbose in general, but I need some time to think of a better way to word it.
platform.js
Outdated
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.
You should just be able to throw new Error.
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.
This isn't an async function, I was trying to make as little of a splash as possible. I hadn't looked to see if the callers were setup to handle thrown exceptions and not just promise rejections. I'll make it throw instead.
|
I've updated to use your suggested initialize() |
|
looks like a transient error caused the signing test to fail for one of the jobs... but the rest seem to be passing. I haven't looked further into it, since its outside the scope of my changes and it has been passing. |
|
Anything I should change? |
|
@malept Would you like anything else? or do you think this is good? |
|
I rebased from your current master |
NEWS.md
Outdated
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.
This is now in the wrong place
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.
ah, should be fixed now
|
I hope all is well? Is this still wanted? |
|
I rebased again, let me know if any docs need touch ups. |
|
@malpet is there reservations for merging this? |
|
Your cleanup looks way better than my changes. :) I didn't want to change too much without fully comprehending the codebase. Sorry if I misunderstood your requests. Hope this gets merged 👍 |
|
I've been using this branch to bundle my apps, the flag works well. Hope we can merge soon. |
|
Is this blocked by something? Anything I could help with? |
|
Thanks for your contribution! 🎉 |
|
🎉 |
Summarize your changes:
I implemented the --asar.filename option referenced in #161