diff --git a/packages/slate-config/common/paths.schema.js b/packages/slate-config/common/paths.schema.js index 881387717..1f13d29c7 100644 --- a/packages/slate-config/common/paths.schema.js +++ b/packages/slate-config/common/paths.schema.js @@ -39,6 +39,22 @@ module.exports = { 'paths.theme.src.snippets': (config) => path.join(config.get('paths.theme.src'), 'snippets'), + // Source frame directory + 'paths.theme.src.frame': (config) => + path.join(config.get('paths.theme.src'), 'frame'), + + // Source content directory + 'paths.theme.src.content': (config) => + path.join(config.get('paths.theme.src'), 'content'), + + // Source pages directory + 'paths.theme.src.pages': (config) => + path.join(config.get('paths.theme.src'), 'pages'), + + // Source pages directory + 'paths.theme.src.pages.customers': (config) => + path.join(config.get('paths.theme.src.pages'), 'customers'), + // Static asset directory for files that statically copied to paths.theme.dist.assets 'paths.theme.src.sections': (config) => path.join(config.get('paths.theme.src'), 'sections'), @@ -82,6 +98,18 @@ module.exports = { 'paths.theme.dist.templates': (config) => path.join(config.get('paths.theme.dist'), 'templates'), + // Distribution frame directory + 'paths.theme.dist.frame': (config) => + path.join(config.get('paths.theme.dist'), 'frame'), + + // Distribution content directory + 'paths.theme.dist.content': (config) => + path.join(config.get('paths.theme.dist'), 'content'), + + // Distribution pages directory + 'paths.theme.dist.pages': (config) => + path.join(config.get('paths.theme.dist'), 'pages'), + // Directory for storing all temporary and/or cache files 'paths.theme.cache': (config) => path.join(config.get('paths.theme'), '.cache'), diff --git a/packages/slate-sections-plugin/index.js b/packages/slate-sections-plugin/index.js index e4bd8122e..569852a5f 100644 --- a/packages/slate-sections-plugin/index.js +++ b/packages/slate-sections-plugin/index.js @@ -17,7 +17,9 @@ module.exports = class sectionsPlugin { } apply(compiler) { - compiler.hooks.emit.tapPromise(PLUGIN_NAME, this.addLocales.bind(this)); + if (fs.existsSync(this.options.from)) { + compiler.hooks.emit.tapPromise(PLUGIN_NAME, this.addLocales.bind(this)); + } } async addLocales(compilation) { diff --git a/packages/slate-sync/index.js b/packages/slate-sync/index.js index e3fab15e5..cbbf1a09f 100755 --- a/packages/slate-sync/index.js +++ b/packages/slate-sync/index.js @@ -18,7 +18,7 @@ function maybeDeploy() { if (filesToDeploy.length) { const files = [...filesToDeploy]; filesToDeploy = []; - return deploy('upload', files); + return deploy('deploy', false, files); } return Promise.resolve(); @@ -45,17 +45,17 @@ function _generateConfigFlags() { _validateEnvValues(); const flags = { - '--password': slateEnv.getPasswordValue(), - '--themeid': slateEnv.getThemeIdValue(), - '--store': slateEnv.getStoreValue(), - '--env': slateEnv.getEnvNameValue(), + password: slateEnv.getPasswordValue(), + themeId: slateEnv.getThemeIdValue(), + store: slateEnv.getStoreValue(), + env: slateEnv.getEnvNameValue(), }; if (slateEnv.getTimeoutValue()) { - flags['--timeout'] = slateEnv.getTimeoutValue(); + flags.timeout = slateEnv.getTimeoutValue(); } // Convert object to key value pairs and flatten the array - return Array.prototype.concat(...Object.entries(flags)); + return flags; } function _generateIgnoreFlags() { @@ -63,8 +63,9 @@ function _generateIgnoreFlags() { const flags = []; ignoreFiles.forEach((pattern) => { - flags.push('--ignored-file'); - flags.push(pattern); + if (pattern.length > 0) { + flags.push(pattern); + } }); return flags; @@ -77,11 +78,9 @@ function _generateIgnoreFlags() { * @param files Array An array of files to deploy * @return Promise */ -async function deploy(cmd = '', files = []) { - if (!['upload', 'replace'].includes(cmd)) { - throw new Error( - 'shopify-deploy.deploy() first argument must be either "upload", "replace"', - ); +async function deploy(cmd = '', replace = false, files = []) { + if (!cmd === 'deploy') { + throw new Error(`shopify-deploy.deploy() first argument must be "deploy"`); } deploying = true; @@ -90,7 +89,7 @@ async function deploy(cmd = '', files = []) { try { await promiseThemekitConfig(); - await promiseThemekitDeploy(cmd, files); + await promiseThemekitDeploy(cmd, replace, files); } catch (error) { console.error('My Error', error); } @@ -100,49 +99,34 @@ async function deploy(cmd = '', files = []) { return maybeDeploy; } -function promiseThemekitConfig() { - return new Promise((resolve, reject) => { - themekit( - { - args: [ - 'configure', - ..._generateConfigFlags(), - ..._generateIgnoreFlags(), - ], - cwd: config.get('paths.theme.dist'), - }, - (err) => { - if (err) { - reject(err); - } else { - resolve(); - } - }, - ); - }); +async function promiseThemekitConfig() { + const configure = await themekit( + 'configure', + { + ..._generateConfigFlags(), + ignoredFiles: _generateIgnoreFlags(), + }, + { + cwd: config.get('paths.theme.dist'), + }, + ); + return configure; } -function promiseThemekitDeploy(cmd, files) { - return new Promise((resolve, reject) => { - themekit( - { - args: [ - cmd, - '--no-update-notifier', - ..._generateConfigFlags(), - ...files, - ], - cwd: config.get('paths.theme.dist'), - }, - (err) => { - if (err) { - reject(err); - } else { - resolve(); - } - }, - ); - }); +async function promiseThemekitDeploy(cmd, replace, files) { + const deployment = await themekit( + cmd, + { + noUpdateNotifier: true, + ..._generateConfigFlags(), + files: [...files], + noDelete: !replace, + }, + { + cwd: config.get('paths.theme.dist'), + }, + ); + return deployment; } /** @@ -233,11 +217,11 @@ module.exports = { }, replace() { - return deploy('replace'); + return deploy('deploy', true); }, upload() { - return deploy('upload'); + return deploy('deploy', false); }, fetchMainThemeId, diff --git a/packages/slate-sync/package.json b/packages/slate-sync/package.json index 815b1f250..bdba75e01 100755 --- a/packages/slate-sync/package.json +++ b/packages/slate-sync/package.json @@ -14,7 +14,7 @@ "@shopify/slate-analytics": "1.0.0-beta.16", "@shopify/slate-config": "1.0.0-beta.14", "@shopify/slate-env": "1.0.0-beta.16", - "@shopify/themekit": "0.6.12", + "@shopify/themekit": "1.1.2", "array-flatten": "^2.1.1", "chalk": "2.3.2", "figures": "^2.0.0", diff --git a/packages/slate-tools/package.json b/packages/slate-tools/package.json index 8119733fe..d599ec7a2 100755 --- a/packages/slate-tools/package.json +++ b/packages/slate-tools/package.json @@ -24,7 +24,7 @@ "@shopify/slate-tag-webpack-plugin": "1.0.0-beta.14", "@shopify/slate-translations": "1.0.0-beta.19", "@shopify/theme-lint": "^2.0.0", - "@shopify/themekit": "0.6.12", + "@shopify/themekit": "1.1.2", "archiver": "^2.1.0", "array-flatten": "^2.1.1", "autoprefixer": "6.7.7", diff --git a/packages/slate-tools/tools/webpack/config/parts/core.js b/packages/slate-tools/tools/webpack/config/parts/core.js index 8aaf3b6ec..48249f2a9 100755 --- a/packages/slate-tools/tools/webpack/config/parts/core.js +++ b/packages/slate-tools/tools/webpack/config/parts/core.js @@ -111,5 +111,20 @@ module.exports = { from: config.get('paths.theme.src.sections'), to: config.get('paths.theme.dist.sections'), }), + + new SlateSectionsPlugin({ + from: config.get('paths.theme.src.frame'), + to: config.get('paths.theme.dist.frame'), + }), + + new SlateSectionsPlugin({ + from: config.get('paths.theme.src.content'), + to: config.get('paths.theme.dist.content'), + }), + + new SlateSectionsPlugin({ + from: config.get('paths.theme.src.pages'), + to: config.get('paths.theme.dist.pages'), + }), ], }; diff --git a/yarn.lock b/yarn.lock index e1f14d5f0..2439277be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1173,10 +1173,10 @@ htmllint "^0.6.0" lodash "^4.15.0" -"@shopify/themekit@0.6.12": - version "0.6.12" - resolved "https://registry.yarnpkg.com/@shopify/themekit/-/themekit-0.6.12.tgz#7cf86175b3b62ef7f405f068fd6f7c0cc8fd30bc" - integrity sha512-8yzAoXACUvAJEZU7vpcIGZcMayHcvwMqEc2XKKSSqZN7HHD1VMbogepMb/8h6jZ0xFUHH0IQSpT0sKZfAKDMrw== +"@shopify/themekit@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@shopify/themekit/-/themekit-1.1.2.tgz#658a54a9b933ffb13015f5e4eae8a10b4d704bd7" + integrity sha512-+/iu/U4UHDM0VmPfx0dgj7mtjSD5QS09JOnS1Lz9iitxzKl/YdZ0GwnJK0plmt5TxqRpzFK5hYbM9DYBnto9Bg== dependencies: bin-wrapper "3.0.2" minimist "1.2.0"