@softlimit/theme-envy 0.1.7-alpha → 0.1.10-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,9 @@ module.exports = function(path) {
19
19
  if (path.includes('templates/customers')) {
20
20
  return `templates/customers/${filename}`
21
21
  }
22
+ if (path.includes('templates/metaobject')) {
23
+ return `templates/metaobject/${filename}`
24
+ }
22
25
  if (path.includes('templates/') && !path.includes('customers/')) {
23
26
  return `templates/${filename}`
24
27
  }
@@ -72,8 +72,7 @@ function watch({ mode, verbose }) {
72
72
  const chokidar = require('chokidar')
73
73
  console.log('watching for changes...')
74
74
  chokidar.watch(ThemeEnvy.themePath).on('change', (path) => {
75
- // pass path to the event so we can use to update files separately
76
- ThemeEnvy.events.emit('watch:change', path)
75
+ ThemeEnvy.events.emit('watch:start')
77
76
  const isJSONTemplate = path.includes('templates/') && path.extname(path) === '.json'
78
77
  if (!isJSONTemplate) {
79
78
  console.log(`updated: ${path.split(ThemeEnvy.themePath + '/')[1]}`)
@@ -17,7 +17,5 @@ assets.forEach(asset => {
17
17
  ThemeEnvy.progress.increment('assets', 1)
18
18
  } catch (err) {
19
19
  console.error(err)
20
- } finally {
21
- // use chokidar to watch for changes and copy to dist again
22
20
  }
23
21
  })
@@ -34,7 +34,7 @@ const writeSettingsSchema = () => {
34
34
 
35
35
  writeSettingsSchema()
36
36
 
37
- ThemeEnvy.events.on('watch:change', () => {
37
+ ThemeEnvy.events.on('watch:start', () => {
38
38
  // clear node cache of ThemeRequired modules
39
39
  requiredModules.forEach(module => {
40
40
  delete require.cache[require.resolve(module)]
@@ -23,7 +23,7 @@ const setPreGlobs = () => {
23
23
  }
24
24
 
25
25
  // uncache all required files after a build is complete so changes can be made to partials and schemas in between watch events
26
- ThemeEnvy.events.on('watch:change', () => {
26
+ ThemeEnvy.events.on('watch:start', () => {
27
27
  // clear node cache of ThemeRequired modules
28
28
  requiredModules.forEach(module => {
29
29
  delete require.cache[require.resolve(module)]
@@ -14,6 +14,14 @@ const templateOutputPath = path.resolve(ThemeEnvy.outputPath, 'templates')
14
14
  fs.ensureDirSync(templateOutputPath)
15
15
  globbedTemplates.forEach(file => {
16
16
  // write each file to dist
17
+ // if the file path includes customers, output into a customers directory in templates
18
+ if (file.includes('customers')) {
19
+ const customerOutputPath = path.resolve(templateOutputPath, 'customers')
20
+ fs.ensureDirSync(customerOutputPath)
21
+ fs.copyFileSync(file, path.resolve(customerOutputPath, path.basename(file)))
22
+ ThemeEnvy.progress.increment('templates', 1)
23
+ return
24
+ }
17
25
  fs.copyFileSync(file, path.resolve(templateOutputPath, path.basename(file)))
18
26
  // update progress bar
19
27
  ThemeEnvy.progress.increment('templates', 1)
@@ -12,7 +12,7 @@ const { spawn } = require('child_process')
12
12
 
13
13
  module.exports = function() {
14
14
  const relativeDistPath = path.relative(process.cwd(), ThemeEnvy.outputPath)
15
- const themePull = ['theme', 'pull', `--store=${ThemeEnvy.store}`, `--path=${relativeDistPath}`, '--only=settings_data.json', '--only=templates/*.json']
15
+ const themePull = ['theme', 'pull', `--store=${ThemeEnvy.store}`, `--path=${relativeDistPath}`, '--only=settings_data.json', '--only=templates/*.json', '--only=sections/*.json']
16
16
  const shopify = spawn('shopify', themePull, { cwd: path.resolve(process.cwd()), stdio: 'inherit' })
17
17
 
18
18
  shopify.on('exit', function() {
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @file Creates a .shopifyignore file in the outputPath directory based on the type of push specified in the argument.
3
+ * @param {string} type - The type of ignore pattern to use: 'none', 'locales', 'push'
4
+ */
5
+
6
+ const path = require('path')
7
+ const fs = require('fs')
8
+
9
+ const patterns = {
10
+ none: '',
11
+ locales: 'locales/*',
12
+ push: `locales/*
13
+ templates/*.json
14
+ sections/*.json
15
+ config/settings_data.json
16
+ `,
17
+ }
18
+
19
+ module.exports = function(type) {
20
+ if (!fs.existsSync(path.resolve(process.cwd(), 'dist'))) {
21
+ fs.mkdirSync(path.resolve(process.cwd(), 'dist'))
22
+ }
23
+ fs.writeFileSync(path.resolve(process.cwd(), 'dist/.shopifyignore'), patterns[type])
24
+ }
package/index.js CHANGED
@@ -21,6 +21,7 @@ const themeEnvyCommands = {
21
21
  convert: require('#Convert'),
22
22
  dev: require('#Helpers/functions/dev.js'),
23
23
  init: require('#Init'),
24
+ ignore: require('#Ignore'),
24
25
  new: require('#Helpers/functions/scaffold-new/index.js'),
25
26
  orphans: require('#Helpers/functions/find-orphans.js'),
26
27
  'pull-json': require('#Helpers/functions/pull-json.js'),
@@ -188,4 +189,15 @@ program
188
189
  scriptMessage(command.name())
189
190
  themeEnvyCommands.convert(source)
190
191
  })
192
+
193
+ program
194
+ .command('ignore')
195
+ .description('Create a .shopifyignore file in the output directory based on the type of ignore patter specified in the argument')
196
+ .usage(['[none|locales|push]'])
197
+ .addArgument(new commander.Argument('[type]', 'The type of ignore pattern to use').choices(['none', 'locales', 'push']))
198
+ .action((type, options, command) => {
199
+ scriptMessage(command.name())
200
+ themeEnvyCommands.ignore(type)
201
+ })
202
+
191
203
  program.parse()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softlimit/theme-envy",
3
- "version": "0.1.7-alpha",
3
+ "version": "0.1.10-alpha",
4
4
  "description": "Softlimit Shopify Theme Development Environment",
5
5
  "bin": {
6
6
  "theme-envy": "./index.js"
@@ -27,6 +27,7 @@
27
27
  "#Init/*": "./init/*",
28
28
  "#Init/functions": "./init/functions/index.js",
29
29
  "#Init/functions/*": "./init/functions/*",
30
+ "#Ignore": "./ignore/index.js",
30
31
  "#LogSymbols": "./helpers/functions/log-symbols.js",
31
32
  "#Root/*": "./*"
32
33
  },