wilr / grunt-shopify Goto Github PK
View Code? Open in Web Editor NEWGrunt plug-in for publishing Shopify theme assets
License: BSD 3-Clause "New" or "Revised" License
Grunt plug-in for publishing Shopify theme assets
License: BSD 3-Clause "New" or "Revised" License
It appears the download side is throttled as well so when you try to do a theme download it ends up erroring out.
$ grunt shopify:download
...
>> [grunt-shopify] - File "assets/j..." saved to disk.
>> [grunt-shopify] - Downloading "...".
>> [grunt-shopify] - File "assets/..." saved to disk.
Warning: Request limit exceeded for the Shopify API Use --force to continue.
Aborted due to warnings.
$
So the call should be tied into the same rate_limit_delay setting as the upload side. I did a quick hack and added a sleep loop using the current time and then doing a while loop but it is ugly since I am still new to nodeJS. There should be something more elegant added to the theme download side.
I just made a function called sleep and added it after the shopify.download(path.join(basePath, asset.key), next); call in lib/shopify.js
// At the top
function sleep(callback) {
var now = new Date().getTime();
while(new Date().getTime() < now + 500) {
// do nothing
}
}
// In the shopify.downloadTheme = function(done) {
async.eachSeries(obj.assets, function(asset, next) {
shopify.download(path.join(basePath, asset.key), next);
sleep(function() {});
I haven't gotten this plugin to work and I don't know what question to ask yet.
That aside, I was just looking at the code and noticed that you've got /admin/assets.json
hard-coded but no comments and I'm trying to understand what it's purpose is.
From a RESTful perspective I would expect that I PUT /templates/something.liquid
to replace that file and DELETE /templates/something.liquid
to destroy it. Yet it seems that you're using query parameters to specify a file?
Can you enlighten me as to what's going on? Possibly point me to the right docs on shopify?
Hi there,
I would love to use this plugin but I don't seem to be able to get it to run.
this is my grunt task:
shopify: {
options: {
api_key: '<%= shpfy.api_key %>',
password: '<%= shpfy.password %>',
url: '<%= shpfy.url %>',
theme: '<%= shpfy.theme %>',
base: './shopify/',
},
},
this is my watch:
shopify: {
files: [
'./shopify/assets/**',
'./shopify/config/**',
'./shopify/snippets/**',
'./shopify/layout/**',
'./shopify/templates/**',
],
tasks: [
'shopify',
],
},
And this is the output I get:
>> File "shopify/assets/BSBLSC.0.0.1.min.css" changed.
Running "shopify" task
Done, without errors.
When I run grunt shopify:upload
I get this:
Running "shopify:upload" task
>> [grunt-shopify] - Uploading "assets/BSBLSC.0.0.1.min.css"
>> [grunt-shopify] - File "assets/BSBLSC.0.0.1.min.css" uploaded.
>> [grunt-shopify] - Uploading "assets/BSBLSC.0.0.1.min.js"
>> [grunt-shopify] - File "assets/BSBLSC.0.0.1.min.js" uploaded.
>> [grunt-shopify] - Theme deploy complete.
Btw I am using a very fresh and updated node install. (Might be a new version that breaks compatibility?)
Any idea?
Can this feature be added. In most cases you update just few files of theme and then re-upload them and with this support it would be much faster.
UPDATE: I created PR for this: #56
Works really well until you need to compile some CoffeeScript or SASS. The problem then is that it only uploads the original file that was altered not the eventually compiled version.
Something you're thinking about?
Should be an optional feature flag in the grunt file to flag growl
You could pull in the API Key and Password from another file then encourage users to add that file to their .gitignore. This would also help teams use their own credentials with the same project.
I can do a fork and pull request if you want.
This is missing from the package.json dependencies.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I'm saving it in my editor and it's not working!!!
Is there a way to deploy without having to use the watch
task? For example after executing a copy
or sync
task? Also can we force deploying the whole theme like the desktop app does?
If not, I think those could be great additions. Thanks!
Hey guys. I have a theme on shopify. And I'm deploying it with grunt shopify:upload
. How can I configure grunt or grunt-shopify to upload all files from assets/
folder, except *.jpg
?
[grunt-shopify] - Error uploading file {"asset":["Cannot overwrite generated as
set 'assets/blog-fixes.scss'."]}
All other uploads seem to work fine...
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
In the past two weeks, grunt-shopify stopped being able to upload files, reporting the following error on every upload action:
[grunt-shopify] - File "shop/assets/global--above-fold.js" not allowed by Shopify whitelist
I've updated npm and grunt-shopify, to no avail. This has worked for me for 2 years straight without problem, up until about 2 weeks ago when it broke. Can't see anything I've done to break it.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Windows v8.1
grunt-cli v0.1.13
grunt v0.4.5
grunt-shopify v0.6.0
options: {
api_key: "------------------------------------",
password: "------------------------------------",
url: "------------------------------------",
theme: "------------",
base: "themes/main/"
}
shopify: {
files: [
theme + "assets/**",
theme + "layout/**",
theme + "snippets/**",
theme + "templates/**"
],
tasks: ["shopify"]
}
grunt.option('theme', path.join(process.cwd(), 'themes/main/'));
When running grunt watch:shopify
and changing a file:
$ grunt watch:shopify
Running "watch:shopify" (watch) task
Waiting...
>> File "themes\main\templates\cart.liquid" changed.
Running "shopify" task
Done, without errors.
Completed in 1.594s at Tue Jul 07 2015 14:47:39 GMT+0100 (GMT Summer Time) - Waiting...
The changed file however, has not been pushed to the Shopify server.
Only file changes are detected.
Platform: ubuntu 12.04.5 guest running on a windows virtualbox host.
Maybe worth to consider moving to https://github.com/paulmillr/chokidar, which is supposedly more robust and is used by karma, among others? Will be happy to work on a pull request for that.
Got this issue today in a new mac I started using. No matter which shopify I try to run, I get a "not in base path" error. It's really weird because the file IS in the base path.
For instance, when trying to do an upload or sync, or even when watching the files:
Running "shopify:sync" task
>> [grunt-shopify] - File "/XXX/assets/ajax-cart.js.liquid" not in base path
.
.
.
I was following this link to setup shopify theme locally on windows https://www.otreva.com/web-development/shopify-desktop-theme-editor-windows-linux/.
Whenever i run shopify:download command some of the theme files get downloaded and later it throws this error -> Assertion failed: end <= source_len, file src\smalloc.cc, line 280 and the task stops executing. Can someone please help me with it
I'm saving it in my editor and it's not working!!!
It says here: https://github.com/yeoman/grunt-regarde that it's deprecated and to use watch instead. Is this an easy substitution? Would be great if you could update to it.
A suggestion: A setting in the gruntfile that ignores the settings_data.json and doesn't upload it to the site if changes to it are detected.
I see there is an option for this on the upload command, but don't see a similar setting for the watch command.
Lately I am getting this alert. Is anyone else also having this issue?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hey Will, do you know if it's possible to upload to more than one store? Would be really handy for theme developers, as the same theme has multiple demo stores.
npm ERR! peerinvalid The package grunt-contrib-watch does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants grunt-contrib-watch@~0.4.4
When I run
npm install grunt-shopify --save-dev
I get a different version of the tasks/shopify.js to the one on github. Should I just clone it or download it?
Thanks!
I'm saving template/index.liquid
and in the console it detects the file change and grunt-shopify says it's "uploading" but I'm not seeing any changes reflected on the site. Any idea why this is happening? Does grunt-shopify even recognize the theme directory because some of the examples just jump right into a /javascript
directory.
I have the following setup: A folder named src with all my sass, images, template etc. organized in subdirectories. I use grunt-contrib-copy
, grunt-watch
and grunt-newer
to “compile” this into a valid Shopify theme structure. Grunt-newer
is used to only copy changed files. Let’s say I edit and save my theme.liquid in my src folder, I get the following response:
It looks like the grunt-shopify run twice. I tried to debug, but with no luck.
I tried to add a delay to grunt-shopify
, but the same thing happens.
I guess grunt-shopify
watch and looks for changes, and react immediately, before the file is done being copied with grunt-contrib-copy
. I tried setting different options in watch like options.spawn
and options.debounceDelay
, but with no luck.
Both grunt-shopify
and grunt-contrib-copy
looks for changes in the app folder, but is it possible to somehow control the order in which they run?
My current watch setup:
watch: {
copy: {
files: '<%= project.src %>/**',
tasks: ['newer:copy:shopify']
},
shopify: {
files: ["app/**"],
tasks: ["shopify"]
}
}
Could it be that grunt-contrib-copy
touches the files twice, and thereby trigger shopify-grunt
twice?
In the end the file get’s uploaded and everything works fine, but the error really annoy me. And I can’t figure out why this happens.
According to the shopify docs there is a call limit to the shopify API, causing some errors when grunt watching with this task and at the same time executing something like touch snippets/*
for uploading a set of liquid files.
For this reason I forked this repository (link to the fork) and added some changes:
I've added a queue from the caolan/async module with a concurrency of value 1 (only one upload at the same time) and a configurable delay between API requests (Shopify docs hinting is on 2 calls per second, so ~500ms delay in the best case).
This works now only on the watched files.
The purpose is to extend this to all the other interested pieces of code, but I'm pretty new to nodejs programming, and also insecure of this project guidelines.
It will be beautiful having feedback on my commits, and how to proceed if this enhancement can be useful :)
ran into an issue when i have multiple watch targets and it would try to upload changed styl file. with latest shopify-api update to catch 404s this will return a decent error message but it shouldn't really be trying to upload anyways. on a side note the output is bit crazy.
watch: {
package_update: {
files: ['package.json'],
tasks: ['stylus:style', 'rework:style']
},
style: {
files: ['styl/**/*.styl'],
tasks: ['stylus:style', 'rework:style']
},
shopify: {
files: ['shop/**'],
tasks: ['shopify']
}
}
Is there anyway to make this work with new themes that use 'Sections'? Get an error message using Grunt saying 'sections/collection.liquid not allowed by Shopify Whitelist'. Thanks.
It works for the first couple of pushes but eventually will stop pushing, then I restart the watch task and it works. Any ideas as to why? There are no errors in the console or anything.
411 length required result.
grunt-next, is the next major version, will have watch built in from the looks. the watch
event maybe dropped in favor of task.target.changed
config being set.
this is just to track the upcoming changes.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/8466884-tracking-grunt-next-watch-logic?utm_campaign=plugin&utm_content=tracker%2F432437&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F432437&utm_medium=issues&utm_source=github).I changed "options" to one shop name and put two objects in in. I was getting:
Fatal error: Cannot read property 'disable_growl_notifications' of undefined
Realized you cant change the properties of "shopify" task.
I used the watch method to upload only the files that have changed. I don't know what happened, but it stopped working overnight. shopify:upload
still works.
I didn't change anything on my end, so I'm wondering if Shopify changed something on their end.
I'm getting this line in my console:
>> [grunt-shopify] - Uploading "assets/myfile.css"
but I never get the:
>> [grunt-shopify] - File "assets/myfile" uploaded
unless I use shopify:upload
Obviously this is a huge issue since I don't want to have to manually upload every single one of my theme files when I make a change to one of them.
When grunt-shopify is set up as a watched task with livereload enabled it will do the following:
It appears that it is sending some sort of premature completion signal back to grunt-contrib-watch instead of signalling completion when the file is actually done uploading.
Here's the relevant part of Gruntfile.coffee.
shopify:
options:
base: "deploy/"
watch:
configFiles:
files: ["Gruntfile.coffee"]
options:
reload: true
shopify:
files: ["deploy/**"]
tasks: ["shopify"]
options:
livereload: true
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?
After updating to the latest version, I receive this error when running a watch tasks with [email protected]
:
Loading "shopify.js" tasks...ERROR
Rolling back to 1.0.0 fixed this issue.
"devDependencies": { "glob": "~3.2.3", "growl": "^1.7.0", "grunt": "^1.0.1", "grunt-contrib-jshint": "^1.1.0", "grunt-contrib-nodeunit": "^1.0.0", "grunt-contrib-uglify": "^3.0.1", "grunt-contrib-watch": "^1.0.0", "grunt-shopify": "^1.0.0" }
New to your grunt-shopify project and looking forward to adding it to our workflow.
Until now, we've been building on one hand and using shopify_theme on the other. Having everything under one roof is definitely very nice!
Wondering if its possible to support themeid, so one could upload to an unpublished theme using this plugin. We use unpublished themes as development areas since all the store info is there. Not a biggie to get around using shopify_theme, but def would be a nice feature to keep everything clean and in one place in our Gruntfile.
I saw in lieu of donations you recommend Charity Water, our pleasure to support them. Thank you, and keep up the great work!
Followed on from #6, Shopify defines allowed base folders (snippets, assets etc) and throws a 404 if the folder does not match. If we sync an incorrect path throw a warning.
Hi there. How can it be that shopify:themes command works (in fact it works without the Api key but just the password) and shopify:download hands the following error?
Warning: Request failed with "HTTP 404 Not Found" from the Shopify API Use --force to continue.
the other commands do not show any warning but still do not manage to complete the tasks. (e.g. upload, which does not change anything).
Any idea?
Grunt-shopify works perfectly fine. But can you please provide a gulp equivalent for the same as configuring with gulp is quite simpler compared to grunt?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.