mikenorthorp / gulp-shopify-upload

gulp plugin to watch and upload files to Shopify for use in theme editing
Other
40 stars 21 forks source link

Stops uploading on Watch #25

Open gregorskii opened 8 years ago

gregorskii commented 8 years ago

Hi there,

When using Gulp-Watch the Shopify upload task stops uploading files on change even though the underlying tasks compiling JS/CSS continue to run and place files in the folders watched by this plugin.

gulp.task('shopify:watch', function() {
  watch(config.shopify.assetGlob)
    .pipe(through2.obj(function(file, _, cb) {
      gutil.log(gutil.colors.cyan('CHANGE:' + file.path));
      this.push(file);
      cb();
    }))
    .pipe(gulpShopify(
      config.shopify.api_key,
      config.shopify.password,
      config.shopify.store,
      config.shopify.theme_id
      )
    );
});

Where config.shopify is:

shopify: {
  api_key: shopifyConfig[':api_key'],
  password: shopifyConfig[':password'],
  store: shopifyConfig[':store'],
  theme_id: shopifyConfig[':theme_id'],
  theme_id_production: shopifyConfig[':theme_id_production'],
  assetGlob: path.join(baseDir, '/+(assets|layout|config|snippets|templates|locales)/**')
},

And shopifyConfig is loaded from a config.yml:


---
:api_key: <API KEY FROM SHOPIFY>
:password: <PASSWORD FROMS SHOPIFY>
:store:  vinedistrict-2.myshopify.com
:theme_id: <THEME ID, obtain from theme URL>
:theme_id_production: <THEME ID PRODUCTION, obtain from theme URL>
:whitelist_files:
- layout/
- assets/
- config/
- snippets/
- templates/
- locales/
:ignore_files:
- node_modules/
- bower_components/
- resources/
- assets/.gitkeep

There are other watch tasks that place files in the assets folder of Shopify. Those tasks are working and defined as:

gulp.task('watch-setup', function(cb) {
  gutil.log(gutil.colors.bgGreen('Watching for changes...'));

  watch(config.src + '/styles/' + config.extensionGlobs.shopifyStyles)
    .pipe(gulp.dest(config.dist))
  ;

  watch(config.src + '/svg/' + config.extensionGlobs.svg)
    .pipe(gulp.dest(config.dist))
  ;

  watch(config.src + '/scripts/' + config.extensionGlobs.js)
    .pipe(gulp.dest(config.dist))
  ;

  gulp.watch(config.src + '/scripts/widgets/' + config.extensionGlobs.shopfiyJSLiquid, ['shopify:js:liquid'], {interval: 600});

  cb();
});

Webpacks watch task is also used to build a vendor.js bundle placed in assets.

I am using v2.0.0 of the plugin.

Let me know of any other information you would need to debug.

Thanks,

Greg

justinmetros commented 8 years ago

I ran into this today setting up a new machine. Really put a damper on my afternoon. Went through un-/re-installing everything from node/npm to gulp, matching up everything to my other system trying to identify the cause of the error.

Turns out, it was having a space in my absolute filepath that caused the silent upload fail. My project's grandparent folder had a space in it.

I would check every path from the root downward for anything funky and try again, preferably restarting terminal / computer after making the change.

gregorskii commented 8 years ago

I do not think that is it. It uploads files fine for the first few changes, then it stops notifying me that files have been uploaded.

justinmetros commented 8 years ago

Yeah, different error than I ran into then. Mine was a silent failure. Some path checking is needed.

Could be the API limit? Shopify's limit is 40 but I found setting it a bit lower ( 36 ) helps to eliminate some errors from rapid uploads.

Just posted some updates to my fork - its been working well but I haven't cleaned it up for a proper pull request yet https://github.com/justinmetros/gulp-shopify-upload - so use with caution.

If you try it, there's an new config option "listThemes": true you can pass in for fun.

Another branch by @tmslnz also has some interesting changes.

A lot of people rely on this in their workflow, and we're happy to help debug along with you.

gregorskii commented 8 years ago

Will test your fork out.

Appreciate it!

Nope it appears to stop as well. It has better debugging messages though... :/


[20:44:20] Upload Complete: app.js.liquid
[20:44:54] Starting 'shopify:styles:app.scss.liquid'...
[20:44:54] Finished 'shopify:styles:app.scss.liquid' after 35 ms
[20:44:54] CHANGE:<PROJECT>assets/app.scss.liquid
[20:44:54] Uploading: <PROJECT>assets/app.scss.liquid
[20:44:57] Upload Complete: app.scss.liquid
[20:45:39] Starting 'shopify:styles:app.scss.liquid'...
[20:45:39] Finished 'shopify:styles:app.scss.liquid' after 49 ms
[20:45:39] CHANGE:<PROJECT>assets/app.scss.liquid
[20:45:39] Uploading: <PROJECT>assets/app.scss.liquid
[20:45:41] Upload Complete: app.scss.liquid
[20:52:05] CHANGE:<PROJECT>snippets/product-subscription-form.liquid
[20:52:05] Uploading: <PROJECT>snippets/product-subscription-form.liquid
[20:52:07] Upload Complete: product-subscription-form.liquid
[20:52:47] Starting 'shopify:scripts:app.js.liquid'...
[20:52:47] Finished 'shopify:scripts:app.js.liquid' after 38 ms
[20:52:47] CHANGE:<PROJECT>config/settings_data.json
[20:52:47] CHANGE:<PROJECT>snippets/delivery-date.liquid
[20:52:47] CHANGE:<PROJECT>layout/theme.liquid
[20:52:47] CHANGE:<PROJECT>snippets/header.liquid
[20:52:47] CHANGE:<PROJECT>snippets/social-meta-info.liquid
[20:52:47] CHANGE:<PROJECT>snippets/product-subscription-configure.liquid
[20:52:47] CHANGE:<PROJECT>assets/app.js.liquid
[20:57:07] Starting 'shopify:styles:app.scss.liquid'...
[20:57:07] Finished 'shopify:styles:app.scss.liquid' after 88 ms
[20:57:07] CHANGE:<PROJECT>assets/app.scss.liquid
[20:57:14] Starting 'shopify:styles:app.scss.liquid'...
[20:57:14] Finished 'shopify:styles:app.scss.liquid' after 30 ms
[20:57:14] CHANGE:<PROJECT>assets/app.scss.liquid
justinmetros commented 8 years ago

I've run into some issues not identical but similar to what you describe. Ive rigged some stuff on my local version not comitted and its still buggy. Generally i can work fine for a few hours before i get a fail but i dont have a leg to stand on without any unit tests.

Was at Shopify Unite and spoke personally with Carson, and themekit is ready, by his word.

Having a good experience so far using themekit via a shell command from my gulp file. Its another window to mind but pretty stable and definitely a step up from the initial shopify_theme gem

Not naysaying this project, use it daily! But i think testing and hammering on themekit is a good thing if your workflow allows.

justinmetros commented 8 years ago

Themekit aside, will continue to help contribute to solving this issue