shopifly 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +52 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +76 -0
- data/LICENSE.txt +21 -0
- data/README.md +167 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/fly +4 -0
- data/exe/shopifly +4 -0
- data/lib/shopifly/cli.rb +123 -0
- data/lib/shopifly/syncer.rb +152 -0
- data/lib/shopifly/version.rb +3 -0
- data/lib/shopifly.rb +8 -0
- data/shopifly.gemspec +32 -0
- data/shopifly_functionality.txt +29 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 42436242fd27ab99de6ffcb49dc1364abf83f3c88fd3352de053da1bf60f5a73
|
4
|
+
data.tar.gz: 1f9dde3e060b8ebb56ac4337a03e0b7d093b18527446f96043627fa5a1fb37be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc1339ec10e27719947afb65bc277c38fe3a488240bbe93d0444ecb61a2d21755149e55831987a7d31385abb45ff99b0c434e722e21e13dd57195cb8e29bed88
|
7
|
+
data.tar.gz: eb9eae068e9cc406d63f9459e5637d1cac1c1d1fffa80f3e6e91fb64d3d8fb4e058780dfc7bc3bf64ed2ee6c4a18247b4323cf1d23d1158937fe99ccb7ab32de
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6.3
|
3
|
+
Exclude:
|
4
|
+
- db/schema.rb
|
5
|
+
- vendor/**/*
|
6
|
+
|
7
|
+
Layout/MultilineMethodCallIndentation:
|
8
|
+
EnforcedStyle: indented
|
9
|
+
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 25
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Exclude:
|
15
|
+
- config/environments/*
|
16
|
+
- spec/factories.rb
|
17
|
+
- spec/**/*_spec.rb
|
18
|
+
|
19
|
+
Metrics/ClassLength:
|
20
|
+
Exclude:
|
21
|
+
- lib/helpers/seeder.rb
|
22
|
+
Max: 130
|
23
|
+
|
24
|
+
Metrics/CyclomaticComplexity:
|
25
|
+
Max: 15
|
26
|
+
|
27
|
+
Metrics/PerceivedComplexity:
|
28
|
+
Max: 10
|
29
|
+
|
30
|
+
Metrics/LineLength:
|
31
|
+
Exclude:
|
32
|
+
- lib/helpers/seeder.rb
|
33
|
+
- config/environments/*
|
34
|
+
- db/migrate/*
|
35
|
+
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Exclude:
|
38
|
+
- lib/helpers/seeder.rb
|
39
|
+
Max: 25
|
40
|
+
|
41
|
+
Style/Documentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/FrozenStringLiteralComment:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Style/GuardClause:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/StringLiterals:
|
51
|
+
EnforcedStyle: double_quotes
|
52
|
+
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shopifly (0.1.0)
|
5
|
+
json
|
6
|
+
rainbow
|
7
|
+
shopify_api
|
8
|
+
thor (~> 0.20)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activemodel (6.0.2.1)
|
14
|
+
activesupport (= 6.0.2.1)
|
15
|
+
activemodel-serializers-xml (1.0.2)
|
16
|
+
activemodel (> 5.x)
|
17
|
+
activesupport (> 5.x)
|
18
|
+
builder (~> 3.1)
|
19
|
+
activeresource (5.1.0)
|
20
|
+
activemodel (>= 5.0, < 7)
|
21
|
+
activemodel-serializers-xml (~> 1.0)
|
22
|
+
activesupport (>= 5.0, < 7)
|
23
|
+
activesupport (6.0.2.1)
|
24
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
|
+
i18n (>= 0.7, < 2)
|
26
|
+
minitest (~> 5.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
zeitwerk (~> 2.2)
|
29
|
+
builder (3.2.4)
|
30
|
+
concurrent-ruby (1.1.5)
|
31
|
+
diff-lcs (1.3)
|
32
|
+
graphql (1.10.0)
|
33
|
+
graphql-client (0.16.0)
|
34
|
+
activesupport (>= 3.0)
|
35
|
+
graphql (~> 1.8)
|
36
|
+
i18n (1.8.2)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
json (2.3.0)
|
39
|
+
minitest (5.14.0)
|
40
|
+
rack (2.1.1)
|
41
|
+
rainbow (3.0.0)
|
42
|
+
rake (10.5.0)
|
43
|
+
rspec (3.9.0)
|
44
|
+
rspec-core (~> 3.9.0)
|
45
|
+
rspec-expectations (~> 3.9.0)
|
46
|
+
rspec-mocks (~> 3.9.0)
|
47
|
+
rspec-core (3.9.0)
|
48
|
+
rspec-support (~> 3.9.0)
|
49
|
+
rspec-expectations (3.9.0)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.9.0)
|
52
|
+
rspec-mocks (3.9.0)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.9.0)
|
55
|
+
rspec-support (3.9.0)
|
56
|
+
shopify_api (8.1.0)
|
57
|
+
activeresource (>= 4.1.0, < 6.0.0)
|
58
|
+
graphql-client
|
59
|
+
rack
|
60
|
+
thor (0.20.3)
|
61
|
+
thread_safe (0.3.6)
|
62
|
+
tzinfo (1.2.6)
|
63
|
+
thread_safe (~> 0.1)
|
64
|
+
zeitwerk (2.2.2)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
bundler (~> 2.0)
|
71
|
+
rake (~> 10.0)
|
72
|
+
rspec (~> 3.0)
|
73
|
+
shopifly!
|
74
|
+
|
75
|
+
BUNDLED WITH
|
76
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Mateo Lugo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
# Shopifly
|
2
|
+
|
3
|
+
Shopifly is a command-line utility that simplifies git flows with Shopify's
|
4
|
+
themekit.
|
5
|
+
|
6
|
+
Shopifly exists to enforce branch-theme parity.
|
7
|
+
|
8
|
+
At this time it is compatible only with `config.yml` based Shopify Themekit
|
9
|
+
setups.
|
10
|
+
|
11
|
+
## Dependencies
|
12
|
+
|
13
|
+
Shopifly requires the `theme` command to be in your command line. See
|
14
|
+
[installation instructions](https://shopify.github.io/themekit/).
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'shopifly'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it globally using:
|
29
|
+
|
30
|
+
$ gem install shopifly
|
31
|
+
|
32
|
+
## Setup
|
33
|
+
|
34
|
+
Shopifly requires two local files: `config.stores.yml` and `.current_store`.
|
35
|
+
|
36
|
+
These files should both be added to your `.gitignore`.
|
37
|
+
|
38
|
+
### config.stores.yml
|
39
|
+
|
40
|
+
The `config.stores.yml` file tells it how to access the different stores you
|
41
|
+
own.
|
42
|
+
|
43
|
+
Sample Config:
|
44
|
+
|
45
|
+
```
|
46
|
+
# config.stores.yml
|
47
|
+
|
48
|
+
shared_config:
|
49
|
+
deploy_command: "theme deploy"
|
50
|
+
directory: ../shopify/
|
51
|
+
ignore_files:
|
52
|
+
- config/settings_data.json
|
53
|
+
|
54
|
+
stores:
|
55
|
+
default: "dev"
|
56
|
+
dev:
|
57
|
+
password: xxx
|
58
|
+
store: my-shop-dev.myshopify.com
|
59
|
+
qa:
|
60
|
+
password: xxx
|
61
|
+
store: my-shop-staging.myshopify.com
|
62
|
+
live
|
63
|
+
password: xxx
|
64
|
+
store: my-shop.myshopify.com
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
### .current_store
|
69
|
+
|
70
|
+
The `.current_store` file tells Shopifly which store you currently would like to
|
71
|
+
work with.
|
72
|
+
|
73
|
+
The `.current_store` file should just be a one-line file with the name of the
|
74
|
+
store from the `config.stores.yml` file that you'd currently like to work with.
|
75
|
+
You can easily upload the same theme to multiple stores by manipulating this
|
76
|
+
variable
|
77
|
+
|
78
|
+
For example, a possible value for the `config.stores.yml` file above would be:
|
79
|
+
|
80
|
+
```
|
81
|
+
dev
|
82
|
+
```
|
83
|
+
|
84
|
+
## Usage
|
85
|
+
|
86
|
+
Shopifly configures the local `config.yml` to point to a theme that corresponds
|
87
|
+
to the current branch name.
|
88
|
+
|
89
|
+
It uses a "find or create" algorithm, generating this theme if it does not exist.
|
90
|
+
|
91
|
+
Shopifly configures the `build`, `development` and `production` keys of your
|
92
|
+
`config.yml` to all point to this remote theme.
|
93
|
+
|
94
|
+
**Note** It is _always_ important to quit any running file watch processes (i.e.
|
95
|
+
`theme watch`) before switching branches.
|
96
|
+
|
97
|
+
### Create a new theme based on a new branch
|
98
|
+
|
99
|
+
$ git checkout -b new-branch
|
100
|
+
$ fly sync
|
101
|
+
|
102
|
+
"Theme doesn't exist, creating..."
|
103
|
+
"Setting config to point to new-branch, my-shop-dev.myshopify.com"
|
104
|
+
"Uploading theme!"
|
105
|
+
|
106
|
+
### Configure your local environment to point to an existing theme
|
107
|
+
|
108
|
+
$ git checkout master
|
109
|
+
$ fly sync
|
110
|
+
|
111
|
+
"Theme already exists: master, mack-weldon.myshopify.com"
|
112
|
+
"Setting config to point to master, my-shop-dev.myshopify.com"
|
113
|
+
|
114
|
+
### Sync `settings_data.json` from the published theme to an existing theme
|
115
|
+
|
116
|
+
$ git checkout existing-branch
|
117
|
+
$ fly sync --with-settings
|
118
|
+
|
119
|
+
"Downloading settings"
|
120
|
+
...
|
121
|
+
"Uploading settings"
|
122
|
+
|
123
|
+
## Explanation
|
124
|
+
|
125
|
+
The `fly sync` command performs the following:
|
126
|
+
|
127
|
+
Assuming we're on a branch called `my-branch-theme`, and `.current_store` ==
|
128
|
+
`dev`
|
129
|
+
|
130
|
+
1. Checks if there exists a theme on the `dev` store named `my-branch-theme`.
|
131
|
+
2. If so, skips to step 5. If not:
|
132
|
+
3. Create a Shopify theme on the `dev` store named `my-branch-theme`.
|
133
|
+
4. Uploads the contents of your current branch to the theme using the
|
134
|
+
`shared_config.deploy_command` from `config.stores.yml`.
|
135
|
+
5. If the theme did not previously exist or if the `--with-settings` flag is
|
136
|
+
used, identifies the currently _published_ theme on your `.current_store` and
|
137
|
+
copies the `settings_data.json` from the published theme to the `my-branch-theme`
|
138
|
+
theme.
|
139
|
+
6. Sets your `config.yml` `build`, `development` and `production` keys to point
|
140
|
+
to this new theme.
|
141
|
+
|
142
|
+
## Development
|
143
|
+
|
144
|
+
In this repo:
|
145
|
+
|
146
|
+
```
|
147
|
+
rake build
|
148
|
+
```
|
149
|
+
|
150
|
+
In another repo:
|
151
|
+
|
152
|
+
```
|
153
|
+
gem install --local ~/dev/lunchtime/shopifly/pkg/shopifly-X.X.X.gem
|
154
|
+
```
|
155
|
+
|
156
|
+
To install this gem onto your local machine and ruby version (found in
|
157
|
+
`.ruby-version`), run `bundle exec rake install`.
|
158
|
+
|
159
|
+
To
|
160
|
+
release a new version, update the version number in `version.rb`, and then run
|
161
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
162
|
+
git commits and tags, and push the `.gem` file to
|
163
|
+
[rubygems.org](https://rubygems.org).
|
164
|
+
|
165
|
+
## License
|
166
|
+
|
167
|
+
All rights reserved, Lunchtime Labs LLC, 2020
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "shopifly"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/fly
ADDED
data/exe/shopifly
ADDED
data/lib/shopifly/cli.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Shopifly
|
4
|
+
class CLI < Thor
|
5
|
+
using Rainbow
|
6
|
+
|
7
|
+
desc "sync", "synchronize current git branch with shopify theme\n\n" \
|
8
|
+
"this command looks for a shopify theme with the current branch name\n" \
|
9
|
+
"if it finds such a theme, it sets your local config.yml to use it.\n" \
|
10
|
+
"if it does not find such a theme, it creates a theme and then sets " \
|
11
|
+
"your local config.yml to use it.\n" \
|
12
|
+
"--with-settings: Force upload settings.json file from currently " \
|
13
|
+
"published theme to currently configured theme\n"
|
14
|
+
|
15
|
+
method_option "with-settings", type: :boolean, default: false
|
16
|
+
def sync
|
17
|
+
unless File.exist? "config.stores.yml"
|
18
|
+
puts "file not found: config.stores.yml".red
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
unless File.exist? ".current_store"
|
23
|
+
puts "file not found: .current_store".red
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
Shopifly::Syncer.new.sync
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "open", "open the current theme in the browser"
|
31
|
+
def open
|
32
|
+
puts "not yet implemented"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "themes", "open the themes view for the current store"
|
36
|
+
def themes
|
37
|
+
puts "not yet implemented"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "apps", "open the apps view for the current store"
|
41
|
+
def apps
|
42
|
+
puts "not yet implemented"
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "init", "initialize with defaults"
|
46
|
+
def init
|
47
|
+
unless system "theme version"
|
48
|
+
puts "Error: 'theme' command not found path. See " \
|
49
|
+
"https://shopify.github.io/themekit/".red
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
53
|
+
command = ask(
|
54
|
+
"Command you use to deploy theme code to Shopify:",
|
55
|
+
default: "theme deploy"
|
56
|
+
)
|
57
|
+
|
58
|
+
puts
|
59
|
+
puts "Writing " + "sample.config.stores.yml".green
|
60
|
+
|
61
|
+
write_sample_config(command)
|
62
|
+
|
63
|
+
puts "Done."
|
64
|
+
puts
|
65
|
+
|
66
|
+
puts "Writing " + ".current_store".green
|
67
|
+
|
68
|
+
write_current_store
|
69
|
+
|
70
|
+
puts "Done."
|
71
|
+
puts
|
72
|
+
|
73
|
+
puts "To complete setup, configure " + "sample.config.stores.yml".green +
|
74
|
+
" and rename to " + "config.stores.yml".green
|
75
|
+
puts
|
76
|
+
|
77
|
+
puts "Change the store that you sync to by editing " +
|
78
|
+
".current_store".green
|
79
|
+
puts
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def write_current_store
|
85
|
+
File.open(".current_store", "w") do |file|
|
86
|
+
file.write <<~CONFIG
|
87
|
+
development
|
88
|
+
CONFIG
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def write_sample_config(command)
|
93
|
+
File.open("sample.config.stores.yml", "w") do |file|
|
94
|
+
file.write <<~CONFIG
|
95
|
+
defaults:
|
96
|
+
branch: "master"
|
97
|
+
|
98
|
+
shared_config:
|
99
|
+
deploy_command: "#{command}"
|
100
|
+
directory: "shopify/"
|
101
|
+
ignore_files:
|
102
|
+
- "config/settings_data.json"
|
103
|
+
|
104
|
+
stores:
|
105
|
+
development:
|
106
|
+
api_key: ""
|
107
|
+
password: ""
|
108
|
+
store: "my-site-dev"
|
109
|
+
qa:
|
110
|
+
api_key: ""
|
111
|
+
password: ""
|
112
|
+
store: "my-site-staging"
|
113
|
+
production:
|
114
|
+
api_key: ""
|
115
|
+
password: ""
|
116
|
+
store: "my-site-production"
|
117
|
+
CONFIG
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "shopify_api"
|
3
|
+
require "pry"
|
4
|
+
|
5
|
+
module Shopifly
|
6
|
+
class Syncer
|
7
|
+
def initialize
|
8
|
+
file = File.read("config.stores.yml")
|
9
|
+
@config = YAML.safe_load(file)
|
10
|
+
|
11
|
+
@shared_config = @config["shared_config"]
|
12
|
+
@deploy_command = @shared_config["deploy_command"]
|
13
|
+
@current_store = File.read(".current_store").strip
|
14
|
+
@current_branch = `git branch | grep \\* | cut -d ' ' -f2`.strip
|
15
|
+
store_config = @config["stores"][@current_store]
|
16
|
+
api_key = store_config["api_key"]
|
17
|
+
@password = store_config["password"]
|
18
|
+
store = store_config["store"]
|
19
|
+
@store_url = "#{store}.myshopify.com"
|
20
|
+
@api_version = "2019-10"
|
21
|
+
|
22
|
+
set_shopify_api(api_key, @password, @store_url)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_shopify_api(api_key, password, store_url)
|
26
|
+
shop_url = "https://#{api_key}:#{password}@#{store_url}"
|
27
|
+
ShopifyAPI::Base.api_version = @api_version
|
28
|
+
ShopifyAPI::Base.site = shop_url
|
29
|
+
end
|
30
|
+
|
31
|
+
def sync
|
32
|
+
with_settings = ARGV.include? "--with-settings"
|
33
|
+
|
34
|
+
themes_array = ShopifyAPI::Theme.find(:all)
|
35
|
+
|
36
|
+
current_theme = themes_array.select do |theme|
|
37
|
+
theme.attributes["name"] == @current_branch
|
38
|
+
end.first
|
39
|
+
|
40
|
+
if current_theme.nil?
|
41
|
+
p "Theme doesn't exist, creating..."
|
42
|
+
current_theme = create_theme(@current_branch)
|
43
|
+
|
44
|
+
if current_theme.errors.present?
|
45
|
+
return p "Errors: #{current_theme.errors.first}"
|
46
|
+
end
|
47
|
+
|
48
|
+
with_settings_json(current_theme, default_theme) do
|
49
|
+
deploy_theme if set_config_for(current_theme, true)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
p "Theme already exists: #{@current_branch}, #{@store_url}"
|
53
|
+
if with_settings
|
54
|
+
with_settings_json(current_theme, default_theme) do
|
55
|
+
set_config_for(current_theme, false)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
set_config_for(current_theme, false)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def deploy_theme
|
64
|
+
p "Uploading theme!"
|
65
|
+
system @deploy_command
|
66
|
+
end
|
67
|
+
|
68
|
+
def with_settings_json(current_theme, default_theme)
|
69
|
+
yield
|
70
|
+
|
71
|
+
set_config_for(default_theme, true)
|
72
|
+
get_settings_json
|
73
|
+
|
74
|
+
set_config_for(current_theme, true)
|
75
|
+
upload_settings_json
|
76
|
+
|
77
|
+
delete_settings_json
|
78
|
+
end
|
79
|
+
|
80
|
+
def default_theme
|
81
|
+
@default_theme ||= begin
|
82
|
+
themes_array = ShopifyAPI::Theme.find(:all)
|
83
|
+
|
84
|
+
themes_array.select do |theme|
|
85
|
+
theme.attributes["role"] == "main"
|
86
|
+
end.first
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_settings_json
|
91
|
+
p "Downloading settings"
|
92
|
+
|
93
|
+
system("theme download config/settings_data.json")
|
94
|
+
end
|
95
|
+
|
96
|
+
def delete_settings_json
|
97
|
+
p "Removing local settings"
|
98
|
+
|
99
|
+
`rm #{@shared_config["directory"]}config/settings_data.json`
|
100
|
+
end
|
101
|
+
|
102
|
+
def upload_settings_json
|
103
|
+
p "Uploading settings"
|
104
|
+
|
105
|
+
config = File.read("config.yml")
|
106
|
+
|
107
|
+
if config.include? "theme_id: #{@default_theme.attributes['id']}"
|
108
|
+
raise "Refusing to push settings_data.json to currently published branch"
|
109
|
+
end
|
110
|
+
|
111
|
+
system("theme deploy config/settings_data.json")
|
112
|
+
end
|
113
|
+
|
114
|
+
def create_theme(branch)
|
115
|
+
ShopifyAPI::Theme.create(name: branch)
|
116
|
+
end
|
117
|
+
|
118
|
+
def set_config_for(theme, allow_config_override = false)
|
119
|
+
p "Setting config to point to #{theme.attributes[:name]}, #{@store_url}"
|
120
|
+
|
121
|
+
ignore_files = allow_config_override ? "[]" : @shared_config["ignore_files"]
|
122
|
+
|
123
|
+
File.open("config.yml", "w") do |file|
|
124
|
+
file.write <<~CONFIG
|
125
|
+
build:
|
126
|
+
password: #{@password}
|
127
|
+
theme_name: "#{theme.attributes[:name]}"
|
128
|
+
theme_id: #{theme.attributes[:id]}
|
129
|
+
store: #{@store_url}
|
130
|
+
directory: #{@shared_config['directory']}
|
131
|
+
ignore_files: #{ignore_files}
|
132
|
+
|
133
|
+
development:
|
134
|
+
password: #{@password}
|
135
|
+
theme_name: "#{theme.attributes[:name]}"
|
136
|
+
theme_id: #{theme.attributes[:id]}
|
137
|
+
store: #{@store_url}
|
138
|
+
directory: #{@shared_config['directory']}
|
139
|
+
ignore_files: #{ignore_files}
|
140
|
+
|
141
|
+
production:
|
142
|
+
password: #{@password}
|
143
|
+
theme_name: "#{theme.attributes[:name]}"
|
144
|
+
theme_id: #{theme.attributes[:id]}
|
145
|
+
store: #{@store_url}
|
146
|
+
directory: #{@shared_config['directory']}
|
147
|
+
ignore_files: #{ignore_files}
|
148
|
+
CONFIG
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
data/lib/shopifly.rb
ADDED
data/shopifly.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "shopifly/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "shopifly"
|
7
|
+
spec.version = Shopifly::VERSION
|
8
|
+
spec.authors = ["Lee Pender", "Mateo Lugo"]
|
9
|
+
spec.email = ["lee@lunchtimelabs.io", "lugomateo@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = ""
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = "https://github.com/lugomateo/shopifly"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
+
`git ls-files -z`.split("\x0")
|
18
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_dependency "json"
|
29
|
+
spec.add_dependency "rainbow"
|
30
|
+
spec.add_dependency "shopify_api"
|
31
|
+
spec.add_dependency "thor", "~> 0.20"
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
As a user
|
2
|
+
When I am at the command line inside of a Shopify theme repository
|
3
|
+
|
4
|
+
And I am on the master branch
|
5
|
+
|
6
|
+
And I type “fly branch my-branch-name”
|
7
|
+
|
8
|
+
Then the branch “my-branch-name” is created in git and checked out
|
9
|
+
|
10
|
+
And my Shopify shop has a new theme called “my-branch-name” which is a duplicate of the master branch
|
11
|
+
|
12
|
+
|
13
|
+
Checks you are in a master branch?
|
14
|
+
Checks you are in a shopify theme repository?
|
15
|
+
Shopify API to get master branch and make a copy and rename copy with new branch name
|
16
|
+
Serve new theme ID
|
17
|
+
|
18
|
+
add option to specify which theme you would like to copy and rename
|
19
|
+
if no option is provided search for theme with name: "master" or role: "main"
|
20
|
+
|
21
|
+
|
22
|
+
LEE
|
23
|
+
You should basically select what store you want to be working on. And then Shopifly should manage keeping branches / themes in sync within that store. And there should be shortcuts, i.e. fly preview which opens the theme preview in the browser.
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
-------
|
28
|
+
` ` to run commands? is there another way?
|
29
|
+
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shopifly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lee Pender
|
8
|
+
- Mateo Lugo
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: json
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rainbow
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: shopify_api
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: thor
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.20'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.20'
|
112
|
+
description: ''
|
113
|
+
email:
|
114
|
+
- lee@lunchtimelabs.io
|
115
|
+
- lugomateo@gmail.com
|
116
|
+
executables:
|
117
|
+
- fly
|
118
|
+
- shopifly
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ".gitignore"
|
123
|
+
- ".rspec"
|
124
|
+
- ".rubocop.yml"
|
125
|
+
- ".ruby-version"
|
126
|
+
- ".travis.yml"
|
127
|
+
- Gemfile
|
128
|
+
- Gemfile.lock
|
129
|
+
- LICENSE.txt
|
130
|
+
- README.md
|
131
|
+
- Rakefile
|
132
|
+
- bin/console
|
133
|
+
- bin/setup
|
134
|
+
- exe/fly
|
135
|
+
- exe/shopifly
|
136
|
+
- lib/shopifly.rb
|
137
|
+
- lib/shopifly/cli.rb
|
138
|
+
- lib/shopifly/syncer.rb
|
139
|
+
- lib/shopifly/version.rb
|
140
|
+
- shopifly.gemspec
|
141
|
+
- shopifly_functionality.txt
|
142
|
+
homepage: https://github.com/lugomateo/shopifly
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
|
+
metadata: {}
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubygems_version: 3.0.3
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: ''
|
165
|
+
test_files: []
|