wilr / grunt-shopify

Grunt plug-in for publishing Shopify theme assets
BSD 3-Clause "New" or "Revised" License
107 stars 32 forks source link

grunt.log says file updated, but not working #6

Closed ryanburnette closed 11 years ago

ryanburnette commented 11 years ago

@wilr

I've read the documentation page and I have my task set up correctly as far as I can tell. I'm using watch, the task runs and I see an "OK" message in grunt.log but nothing is updated at the store. For a test I tried putting in an invalid api_key and it still says uploaded "OK."

I'm using Shopify 2, but I don't think that makes a difference.

Is there anything I can do to troubleshoot this?

wilr commented 11 years ago

Got the latest version? All my sites use Shopify 2 now, had to make a couple updates to the API (b290166bbf2cdee132577c97ef6473740b608fda) but apart from that should be fine. I'll give the latest a test tomorrow and see if I can replicate the issue with an invalid key and work backwards from there.

ryanburnette commented 11 years ago

Yea I'm on latest. Let me know if I can do anything to help. I'd love to get my entire Shopify workflow into one Gruntfile.

On Wed, Jul 10, 2013 at 2:38 AM, Will Rossiter notifications@github.comwrote:

Got the latest version? All my sites use Shopify 2 now, had to make a couple updates to the API (b290166https://github.com/wilr/grunt-shopify/commit/b290166bbf2cdee132577c97ef6473740b608fda) but apart from that should be fine. I'll give the latest a test tomorrow and see if I can replicate the issue with an invalid key and work backwards from there.

— Reply to this email directly or view it on GitHubhttps://github.com/wilr/grunt-shopify/issues/6#issuecomment-20724169 .

wilr commented 11 years ago

Sure thing, only thing to do at this stage is look at the HTTP request it creates and what the response is by using something like Charles or Fiddler and try and get to the bottom of the issue (not sure what your javascript is like!).

Might add a verbose debug method to help out for issues like now.

ryanburnette commented 11 years ago

My colleague and I used tcpdump but that was fruitless as it connects via HTTPS, not HTTP.

I'm back to the desktop app for now, let me know if anything comes of it. That's just weird if it works for you and not for me. I wonder what's different.

I'm using Node 0.10.13.

pagameba commented 11 years ago

yeah, its not working for me either. I've spent a bit of time digging into this, the isBinaryFile method is called but the callback to fs.readFile is never called. I've tested to see if the file exists in this method and it does, so I'm not sure why fs.readFile would not do its job. One thing to note with 0.10 is that the optional middle arg to fs.readFile has changed from the encoding to an options object with encoding being one of the possible values. Changing that didn't make ia difference though.

It seems to me as if it is an async thing and the grunt task is exiting immediately and not waiting for a callback to indicate that it is done.

pagameba commented 11 years ago

Ok, got it to work with some hacking, PR will follow once I've cleaned it up. As suspected, the upload task should use this.async() to register it as asynchronous. I also had a problem using the base option, the getAssetKey method assumes base is set with the trailing / but the docs are not clear on this (another PR for this).

ryanburnette commented 11 years ago

@pagameba Thanks for looking into this one! I'm dying to use this Grunt task to complete my workflow. I wrote a theme files compiler that's going to go great with this task. https://github.com/ryanburnette/grunt-shopify-theme

pagameba commented 11 years ago

see #8.

pagameba commented 11 years ago

@ryanburnette my PRs have been merged, hope this works for you. I think this issue could be closed if you report success.

ryanburnette commented 11 years ago

@pagameba Nice, I'll try it out within a day or two.

terkelg commented 11 years ago

Did it work @ryanburnette? I'm having the same issue. I'm trying to make a grunt workflow with grunt-shopify-theme and grunt-shopify. This could be a killer setup, and a perfect solution to get Foundation by Zurb and Shopify play well together.

ryanburnette commented 11 years ago

@terkelg I haven't tried this again since then. I've been using the Mac desktop app to upload my changes along w/ grunt-shopify-theme. I need to try again though. The desktop app works about 50% of the time for me. I have to keep restarting it to get it to upload all the changed files.

I also need to update grunt-shopify-theme to allow for the customers subdirectory. I'll be working on a new Shopify theme shortly so I'll check some things out before I ramp that project up. https://github.com/ryanburnette/grunt-shopify-theme/issues/1

wilr commented 11 years ago

@terkelg using the latest master? npm install https://github.com/wilr/grunt-shopify/tarball/master

terkelg commented 11 years ago

Thanks for the quick reply. So far so good. The store still doesn't update, but at least i get an error in response from the terminal. This is indeed a good sign. I'm getting 404 error (Error upload failed with response - Status Code: 404). I've checked URL, API and password in my Gruntfile.js twice. They are all correct. screen shot 2013-09-17 at 11 24 11

My Gruntfile.js:

module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-shopify');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // Shopify Store - Shop API - Theme ID: 4878267
        shopify: {
            options: {
                api_key: "***",
                password: "***",
                url: "***.myshopify.com"
            }
        },

        watch: {

            /** 
             * grunt-shopify
             * Grunt plug-in for publishing Shopify theme assets
             * https://github.com/wilr/grunt-shopify
             */
            shopify: {
                files: ["deploy/**"],
                tasks: ["shopify"]
            }
        }  
    })

    grunt.registerTask('default', ['shopify']);

};
wilr commented 11 years ago

Thanks, super helpful. I think in your case you need to set the base attribute as described in the README to your deploy folder as it's in a subfolder.

terkelg commented 11 years ago

That's wired. I still get a 404. I can get https://github.com/Shopify/shopify_theme to work though. The 404 error indicate that there somewhere is a broken link.

terkelg commented 11 years ago

I've messed a bit. It seems like the upload run twice. But the store-front doesn't upload. screen shot 2013-09-19 at 14 44 59

wilr commented 11 years ago

You'll get a 404 if it cannot put that file in the correct folder. Shopify only gives you certain folders to use. In your example you're now using app, make sure your shopify.base option is set to app/

terkelg commented 11 years ago

It works! I don't know how I could miss the dash in my base string. Thanks

ryanburnette commented 11 years ago

That's rad to hear that you got this working. I can't wait to use this Grunt task with my theme compiler. https://github.com/ryanburnette/grunt-shopify-theme

On Fri, Sep 20, 2013 at 11:08 AM, Terkel notifications@github.com wrote:

It works! I don't know how I could miss the dash in my base string. Thanks

— Reply to this email directly or view it on GitHubhttps://github.com/wilr/grunt-shopify/issues/6#issuecomment-24817149 .

terkelg commented 11 years ago

@ryanburnette I've made a workflow which compile to the shopify directory structure too (using grunt-contrib-copy). Furthermore it compiles sass/scss (including @import, which Shopify doesn't support), concatenate JavaScript Files, minify JavaScript, CSS and HTML, optimize images and automatically upload to Shopify using this plugin. The only feature I miss at the moment is automatic browser refresh/liveload. Not sure if this is possible when not using localhost. I can share the Gruntfile.js if you like. My plan is to upload it as a Shopify Skeleton Theme on GitHub.

terkelg commented 11 years ago

@wilr I appreciate your work and help, and I'll love to donate a small amount of money to this project to support future development. Can't imagine my workflow without this plugin.

wilr commented 11 years ago

Thank you @terkelg, I'm glad it's available to help the community. I can't take all the credit (few other contributors) and my client shopify projects help fund the development of the tool (and the ongoing development - full theme sync, retroactive sync of changed files coming next). If you feel you must donate, I would love donations to be contributed to a good cause such as Charity Water (https://www.charitywater.org/donate/) who can use the money in greater ways than I.

In conclusion for this ticket I have created (#15).