haystack / tipsy

A new project to encourage pay-what-you-want support for any web site.
http://tipsy.csail.mit.edu/
MIT License
31 stars 9 forks source link

Fix the chrome build system #98

Open Stebalien opened 7 years ago

Stebalien commented 7 years ago

So, the chrome build system is a bit weird. npm build chrome runs the tasks in the following order:

> tipsy@ build-chrome /home/steb/projects/tipsy
> grunt chrome-extension

Running "clean:chrome-extension" (clean) task
>> 1 path cleaned.

Running "compress:chrome-extension" (compress) task
Created chrome-extension/dist/tipsy.zip (521682 bytes)

Running "copy:chrome-extension" (copy) task
Created 25 directories, copied 138 files

Running "stylus:chrome-extension" (stylus) task
File chrome-extension/dist/tipsy/css/tipsy.css created.

Running "es6:chrome-extension" (es6) task

Running "shell:chrome-extension" (shell) task

Now, the chrome store expects a zip with a key.pem so I tried uploading the file produced by compress:chrome-extension (which meets both of these requirements). However, that zip file is missing the manifest‽ Worse, it appears to have a slightly different directory structure than the .crx. At the end of the day, I just extracted the compiled extension (.crx), put the key.pem in place, re-zipped, and uploaded that.

As far as I can tell, the correct way to do this is to move the compress:chrome-extension task after es6:chrome-extension and make sure to build the .crx and .zip from the same source.

tbranyen commented 7 years ago

Strange this has been working, was there a change that broke it I wonder? We did not need to follow the steps you just said to publish any of the other versions and I've been using this same exact code (at least the code I wrote originally) for two other chrome extensions as well.

tbranyen commented 7 years ago

Also to add to this issue, we should drop the chrome- prefix and try and clean up the code to remove any trace of the previous branching.

Stebalien commented 7 years ago

How exactly did you publish it then? Did you upload the zip or did Google accept pre-packaged crx files in the past.

tbranyen commented 7 years ago

Good question, it's been over a year since I last published an extension, it's possible they changed something on their end. I vaguely remember uploading both a key and the zip separately. I think the idea was that Google signs the .crx for you.

Stebalien commented 7 years ago

Actually, given that the current system drops the key in the zip file (as key.pem) as required by google, I don't think anything has changed. Have you tried building from a clean source?

By the way, here's a diff showing how I think this should work:

diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index 9c991bb..9f3d03d 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -23,10 +23,10 @@ module.exports = ->

   @registerTask 'chrome-extension', [
     'clean:chrome-extension'
-    'compress:chrome-extension'
     'copy:chrome-extension'
     'stylus:chrome-extension'
     'es6:chrome-extension'
+    'compress:chrome-extension'
     'shell:chrome-extension'
   ]

diff --git a/build/tasks/compress.coffee b/build/tasks/compress.coffee
index a02c5d2..4aee196 100644
--- a/build/tasks/compress.coffee
+++ b/build/tasks/compress.coffee
@@ -8,14 +8,6 @@ module.exports = ->
         mode: 'zip'

       files: [
-        { src: ['node_modules/purecss/*'], dest: '.' }
-        { src: ['**/*'], expand: true, cwd: 'shared' }
-        {
-          src: [
-            'key.pem'
-            '_locales/**'
-          ]
-          expand: true
-          cwd: 'chrome-extension'
-        }
+        { src: ['key.pem'], cwd: 'chrome-extension/dist' }
+        { src: ['**/*'], expand: true, cwd: 'chrome-extension/dist/tipsy' }
       ]

However, I don't really know grunt so I don't know if this is how one is supposed to do it. The basic idea is that the crx and zip should look identical modulo key.pem (only in the zip).

tbranyen commented 7 years ago

This makes sense to me. I dunno how it could work with compress running before building.