tmslnz / gulp-shopify-theme

Shopify theme synchronisation during development
Apache License 2.0
24 stars 6 forks source link

How to use in a CI situation? #3

Closed shelldandy closed 6 years ago

shelldandy commented 7 years ago

Hey there I'm currently using this setup for development or to deploy a theme:

const gulp = require('gulp')
const watch = require('gulp-watch')
const config = require('../gulp.config')
const shopify = require('gulp-shopify-theme')

const theme = shopify.create()

const shopifyConfig = {
  api_key: config.shopify.key,
  password: config.shopify.pass,
  shared_secret: config.shopify.secret,
  shop_name: config.shopify.shopName,
  theme_id: config.shopify.themeId,
  root: process.cwd() + '/deploy'
}

const CAN_DEPLOY = () => {
  const validKeys = Object.keys(shopifyConfig).filter(key => shopifyConfig[key])
  return validKeys.length > 0
}

const themeFiles = config.theme + '/{assets,layout,config,snippets,templates,locales,sections}/**/*.*'

gulp.task('theme:init', done => {
  if (CAN_DEPLOY()) {
    theme.init(shopifyConfig)
  }
  done()
})

gulp.task('theme:watch', () => {
  return CAN_DEPLOY()
  ? watch(themeFiles)
    .pipe(theme.stream())
    .on('error', config.onError)
  : null
})

gulp.task('theme:upload', () => {
  return CAN_DEPLOY()
  ? gulp.src(themeFiles)
    .pipe(theme.stream())
    .on('error', config.onError)
  : null
})

gulp.task('deploy', gulp.series('theme:init', 'theme:upload'))

// Danger Zone 💀
gulp.task('theme:purge', function (done) {
  theme.purge()
  done()
})
gulp.task('kill:theme', gulp.series('theme:init', 'theme:purge'))
shelldandy commented 7 years ago

However when using the gulp deploy command the terminal just hangs after finishing all the uploads, is there a way for it to know/close the process after everything is done?

tmslnz commented 6 years ago

v1.1.2 emits done so you can use that in your case. And the task queue is not a continuous loop anymore.

shelldandy commented 6 years ago

:O that's very nice thanks a lot i'll try it soon