Is the git subtree method recommended for Online Store 2.0 on Shopify?

devenini
Visitor
2 0 11

With the Online Store 2.0 stuff, are you guys using the whole git subtree method mentioned in the shopify/git docs (https://shopify.dev/themes/best-practices/version-control) ? I've been putting src/ folder in my theme and it's working fine, but they don't mention that as a viable option in the docs.

Replies 6 (6)

luistmartins
Shopify Partner
21 2 2

I've just tested this approach and it does work. I think the reason they don't list it as a viable option is because you can't plug a Github action directly to the main repo, and you have to keep the contents of the assets folder under version control for them to be deployed.  For the former that means you need to run your build commands locally. As for the latter, having assets part of the repo would be a requirement anyway, so it appears to be a viable workflow to me too.

mojosef
Visitor
3 0 0

Have either of you managed to go down the subtree route yet? I too have a src folder in my root and everything seems to be working ( anything outside of Shopify's theme structure is ignored ). I can't seem to get my head around splitting the production code out.

cpozo
Shopify Partner
4 0 2

The problem is that if you have assets/Build folder inside your project, you will get this error while executing a lightouse action in github:

 

Configuring shopify CLI
Will run Lighthouse CI on https://***
==============================
Creating development theme
This command ran with ID: 50863
Please include this information in any issues/report along with relevant logs
/root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/file.rb:20:in `read': Is a directory @ io_fread - assets/Build (Errno::EISDIR)
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/file.rb:20:in `read'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/file.rb:20:in `read'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/file.rb:57:in `checksum'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/syncer.rb:291:in `file_has_changed?'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/syncer.rb:193:in `enqueue'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/syncer.rb:42:in `block in enqueue_updates'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/syncer.rb:42:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/syncer.rb:42:in `enqueue_updates'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/theme/syncer.rb:152:in `upload_theme!'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/project_types/theme/commands/push.rb:55:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/sub_command.rb:13:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/command.rb:19:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:16:in `block (2 levels) in call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:37:in `block (2 levels) in with_logging'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb:169:in `with_id'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:36:in `block in with_logging'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-ui/lib/cli/ui.rb:176:in `log_output_to'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:35:in `with_logging'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:15:in `block in call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:45:in `block (2 levels) in with_traps'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:51:in `twrap'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:44:in `block in with_traps'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:55:in `twrap'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:43:in `with_traps'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/executor.rb:14:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/core/executor.rb:15:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/core/entry_point.rb:24:in `block in call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/core/monorail.rb:20:in `log'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/lib/shopify-cli/core/entry_point.rb:23:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/bin/shopify:33:in `block in <main>'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb:75:in `handle_abort'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb:21:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/shopify-cli-2.0.1/bin/shopify:32:in `<main>'
==============================
Configuring Lighthouse CI
Fetching product handle
Using 2-case-bundle
Fetching collection handle
Using best-sellers
==============================
Running Lighthouse CI
  .lighthouseci/ directory writable
  Configuration file found
  Chrome installation found
  GitHub token set
Healthcheck passed!

Getting a new page...
Getting preview cookie...
Error: Protocol error (Page.navigate): Cannot navigate to invalid URL
    at /.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:217:63
    at new Promise (<anonymous>)
    at CDPSession.send (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:216:16)
    at navigate (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:108:47)
    at FrameManager.navigateFrame (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:91:13)
    at Frame.goto (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:416:41)
    at Page.goto (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1133:53)
    at module.exports (/github/workspace/setPreviewCookies.js:18:14)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

    at async PuppeteerManager.invokePuppeteerScriptForUrl (/.node/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:108:5)

 

 

 

sandywyperII
Visitor
2 0 0

I can't see a reason to use subtree at all.  Just maintain the current theme folder structure and have your build process put files into assets. 

 

I have just finished setting up webpack to compile scss, and translate/compile js as well.  The output files go into the assets folder and all is well!  My `npm run dev` command uses 'concurrently' to run webpack along side 'shopify theme serve'.

pierrewebdev
Shopify Partner
32 2 7

Hello Sandy,
In your approach how do you ensure that you have everything under version control while also being able to make use of the Shopify Github Integration?

I am currently trying to set up the Shopify Github Integration with my theme project that uses gulp to compile sass and es6 javascript into the asset folder of my theme.

I've sent everything that I want to use for production into a dist/ folder and was trying to use a subtree to store the dist, but was having issues.

Check out my Shopify Content on the Code That Converts YouTube Channel
If you need Shopify Help send me an email at patrick@codethatconverts.com
sandywyperII
Visitor
2 0 0
Hi pierrewebdev

The way i do it isn't in the Shopify Docs... but works well for us. You
need to set out the project so that shopify can pull down all the
directories it wants.... all other directories and files in the repo
will be ignored.  So don't use a dist folder.... just have your bundled
files go into assets.  One thing you have to watch out for is to use a
.shopifyignore file listing everything that's not a theme file, and do
not use the `shopify theme pull` command without the `--nodelete` flag. 
Actually... i recommend committing your changes and then doing that
command..... then you will see how shopify pulls files from the repo.

Hope that all makes sense!