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

feat: web-ext sign now supports extensions without explicit IDs #340

Merged
merged 1 commit into from
Jul 5, 2016

Conversation

kumar303
Copy link
Contributor

@kumar303 kumar303 commented Jun 30, 2016

Supports #178

This feature also requires the patch from mozilla/sign-addon#114

@andymckay
Copy link
Contributor

If I sign the add-on a second (or third or whatever) time, how do I specify the add-on id? Do I have to change the manifest, or could I specify an id on the command line as an argument?

@kumar303
Copy link
Contributor Author

kumar303 commented Jul 1, 2016

Hmm, good point. As it stands now, each time you run the sign command it will create a new add-on which will start to make your DevHub add-on list pretty unbearable.

@kumar303
Copy link
Contributor Author

kumar303 commented Jul 1, 2016

Good catch @andymckay ✋ fixed

@kumar303 kumar303 force-pushed the sign-without-id branch 2 times, most recently from 32df77a to b0f238a Compare July 1, 2016 18:17
.then(({buildResult, manifestData}) => {
const manifestId = getManifestId(manifestData);
if (id && manifestId) {
log.warn(`Overriding manifest.json ID: ${id}`);
Copy link
Member

Choose a reason for hiding this comment

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

@kumar303 How about Overriding manifest.json ID "${id}" with "${manifestId}"?

@rpl
Copy link
Member

rpl commented Jul 1, 2016

@kumar303 how about the following tweak to the strategy used for signing the updates of an add-on without an extension id in the manifest?

  • warn the user when he submit a webextension without an extension id for the first time
  • save the addon id from the first successful signed xpi in an hidden file in the root of the add-on source dir
  • then we can use the hidden file to detect when the addon has been signed once, and even reuse it to automatically sign the next add-on XPIs with the same id, without the need for the user to remember to pass it to the sign command on every released update (and if the user re-creates its development environment, then it will be warned on the first web-ext sign, because the hidden file is missing in the newly created development environment)

@kumar303
Copy link
Contributor Author

kumar303 commented Jul 1, 2016

Per our IRC conversation, I checked what AMO does in the case of a manifest.json and custom declared ID. It chooses the manifest.json ID so I made web-ext raise an error for that case (to avoid surprises!).

@coveralls
Copy link

coveralls commented Jul 1, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 0b6b53f on kumar303:sign-without-id into e706145 on mozilla:master.

@kumar303
Copy link
Contributor Author

kumar303 commented Jul 1, 2016

BTW, this is testable on https://addons-dev.allizom.org like web-ext sign --api-key ... --api-secret ... --api-url-prefix https://addons-dev.allizom.org/api/v3

@kumar303
Copy link
Contributor Author

kumar303 commented Jul 1, 2016

@rpl really great idea about remembering the auto-generated ID! I added this feature. What it does is save a file to the artifacts directory. It will re-use the file if it exists but only as a fallback. Let me know how it looks.

.then((signingResult) => {
// All information about the downloaded files would have
// already been logged by signAddon().
log.info(signingResult.success ? 'SUCCESS' : 'FAIL');
if (signingResult.success) {
log.info(`Extension ID: ${signingResult.id}`);
Copy link
Member

Choose a reason for hiding this comment

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

@kumar303 at line 74, it seems to me that in some cases the id property can be missing from the signingResult (my guess is that it could happen when the extension id is assigned statically in the manifest.json), and in that case the above line is going to print a "Extension ID: undefined" log, which can be confusing for the the user.

If the above assumptions are true, we can probably tweak it a bit, to ensure that it is going to always print a log which contains the id (even if it is the same statically assigned in the manifest.json)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you install the latest sign-addon from this branch into web-ext? mozilla/sign-addon#114 What you're describing is the behavior before that patch is applied but not after.

@rpl
Copy link
Member

rpl commented Jul 4, 2016

@kumar303 besides the above comment (and the doubt below), this PR looks great now!

My only remaining doubt is potential side-effects of saving the auto-generated ID in the "artifact dir vs the project root":

my feeling is that is some cases, the addon developer is going to have its own building steps (e.g. for babel, webpack or browserify etc.) and it is pretty common that one of those building steps could remove the entire artifact dir (e.g. at every full rebuild), and the saved auto-generated ID will be lost (and a new one will be generated on the next web-ext sign run)

Given that the auto-generated ID is not a sensible information (and any user can get the addon id on an existent add-on pretty easily), I will probably prefer if it could be saved as an hidden file in the root of the project, because it ensures that it will not be removed by a build automation script (and by making it an hidden file, web-ext build will not include it in the generated XPI).

It is probably even reasonable to assume that the addon developer wants to add and commit the hidden file in the repository of the add-on sources, so that any of the developer that should be able to re-sign the addon will have access to the currently assigned id (but it can be overriden from the command line, if they need to test it as a separate add-on)

@kumar303
Copy link
Contributor Author

kumar303 commented Jul 5, 2016

Ah, true, good point. I will make it a hidden file in the source dir. I was a little unsure about this when working on it. I think the artifacts dir is more ephemeral.

@kumar303 kumar303 force-pushed the sign-without-id branch 2 times, most recently from a62dda4 to a3b56f3 Compare July 5, 2016 19:19
@rpl
Copy link
Member

rpl commented Jul 5, 2016

@kumar303 this PR looks great

r+

@kumar303 kumar303 force-pushed the sign-without-id branch 3 times, most recently from c8978c5 to f911460 Compare July 5, 2016 19:47
@coveralls
Copy link

coveralls commented Jul 5, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling fdf3d3b on kumar303:sign-without-id into ea378e5 on mozilla:master.

@kumar303 kumar303 merged commit 21855ae into mozilla:master Jul 5, 2016
@kumar303 kumar303 deleted the sign-without-id branch July 5, 2016 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants