Merge pull request #276 from yldio/sketch-precomiit
Sketch precommit hook
This commit is contained in:
commit
c1e30ffce1
19
README.md
19
README.md
@ -19,7 +19,7 @@ running `make`, make continues without any errors, then you are good to go. [nod
|
|||||||
is also needed if deployment to Triton is required.
|
is also needed if deployment to Triton is required.
|
||||||
|
|
||||||
```
|
```
|
||||||
make && make install
|
make && make install
|
||||||
```
|
```
|
||||||
|
|
||||||
Then to run each individual component locally (subject to change).
|
Then to run each individual component locally (subject to change).
|
||||||
@ -84,3 +84,20 @@ Code for the reusable UI framework.
|
|||||||
### spikes
|
### spikes
|
||||||
|
|
||||||
Implementation examples from spikes, this directory is experimental and is likely broken.
|
Implementation examples from spikes, this directory is experimental and is likely broken.
|
||||||
|
|
||||||
|
### Sketch Pre Commit
|
||||||
|
|
||||||
|
A pre-commit hook has been added to generate a PNG shot of each .sketch file "page".
|
||||||
|
|
||||||
|
To use, make sure the following are installed:
|
||||||
|
- [Sketch Toolbox](http://sketchtoolbox.com/)
|
||||||
|
- [Sketch Measure Plugin](https://github.com/utom/sketch-measure)
|
||||||
|
|
||||||
|
|
||||||
|
Then add following to your `.git/config`
|
||||||
|
|
||||||
|
```
|
||||||
|
[diff "sketchtool"]
|
||||||
|
textconv = "sketchtool dump"
|
||||||
|
cachetextconv = true
|
||||||
|
```
|
||||||
|
57
bin/generate-sketch-pngs
Executable file
57
bin/generate-sketch-pngs
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
|
PROGNAME = 'pre-commit (auto-generate sketch previews)'
|
||||||
|
|
||||||
|
def main
|
||||||
|
progress "Installing sketchtool"
|
||||||
|
system!(%W[/Applications/Sketch.app/Contents/Resources/sketchtool/install.sh])
|
||||||
|
|
||||||
|
progress "Looking for changed or added .sketch files"
|
||||||
|
diff_output = capture!(%W[git diff --name-only --cached --pretty=format:])
|
||||||
|
sketch_files = diff_output.split("\n").grep(/\.sketch\z/)
|
||||||
|
if sketch_files.empty?
|
||||||
|
progress "No sketch files to create preview images for in this commit!"
|
||||||
|
end
|
||||||
|
puts sketch_files
|
||||||
|
|
||||||
|
sketch_files.each do |f|
|
||||||
|
unless File.exist?(f)
|
||||||
|
progress "#{f} does not exist (anymore?)"
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
png_output_dir = f.sub(/\.sketch\z/, '') + '-sketch-previews'
|
||||||
|
progress "deleting old previews"
|
||||||
|
FileUtils.rm_rf(png_output_dir)
|
||||||
|
|
||||||
|
progress "exporting pages"
|
||||||
|
cmd = %W[sketchtool --overwriting=YES --output=#{png_output_dir} export pages #{f}]
|
||||||
|
system!(cmd)
|
||||||
|
|
||||||
|
progress "adding to git"
|
||||||
|
system!(%W[git add #{png_output_dir}])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def system!(cmd)
|
||||||
|
puts "running: #{cmd.join(' ')}"
|
||||||
|
abort failure_message(cmd) unless system(*cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
def capture!(cmd)
|
||||||
|
puts "capturing: #{cmd.join(' ')}"
|
||||||
|
result = IO.popen(cmd) { |io| io.read }
|
||||||
|
abort failure_message(cmd) unless $?.success?
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def failure_message(cmd)
|
||||||
|
"#{PROGNAME}: command failed: #{cmd.join(' ')}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def progress(msg)
|
||||||
|
puts "#{PROGNAME}: #{msg}"
|
||||||
|
end
|
||||||
|
|
||||||
|
main
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:0f309ebcba76858ace475bd09b7a4e4350bc5b17484b2beb17d03191c264ae40
|
|
||||||
size 5660672
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:0165f3e1cb013ec3803e0728d192e22d6be2640d47e2b81a29754b39b73d3d42
|
|
||||||
size 2170880
|
|
BIN
design/UI-Guidelines-14-02-2017-sketch-previews/Page 1.png
Normal file
BIN
design/UI-Guidelines-14-02-2017-sketch-previews/Page 1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 MiB |
3
design/UI-Guidelines-14-02-2017.sketch
Normal file
3
design/UI-Guidelines-14-02-2017.sketch
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ca906f48160b64584963c313e35b57d2acf45b82e18ba783d8b198451a8e7bd6
|
||||||
|
size 8896512
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:2e3852b6dd90ea66998c7c09372cb4bbbf777dc717acbae55a121cf260688244
|
|
||||||
size 170759
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:cce7ea7b4c4e0dfaa8ae99d2e900313edefdebd915c137a10c6c75057ddf5886
|
|
||||||
size 170363
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:7284698aae7f849f0be594ec3afaf346d9fd48686e0cc2f6594286ab15c3f1c3
|
|
||||||
size 175613
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:d46e6919d52db3cb09cc984ae74d656753d292f54d92e608d31edabffe376272
|
|
||||||
size 198833
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6a5c2234401dd9da3d8b96853f9d174b86e90b687308a0569ef289b9b1996331
|
|
||||||
size 199020
|
|
Binary file not shown.
Before Width: | Height: | Size: 166 KiB |
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:688effc898f80da9f7b0b274c0778514273d945e1b4720e9aa10537fe2a30cc6
|
|
||||||
size 189476
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:110beddb61b42f171f4593f39f7d9bf05f2de40c03cb6ad57fde73adabdb4630
|
|
||||||
size 171204
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:5bd710e4fcde003191b7af7edefe105078318a7a890e88b0777fd79310749cc2
|
|
||||||
size 166610
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:825c54dad90b921aed5aa2e32bb4080c720889bd37590dcd99aeda336416436d
|
|
||||||
size 204289
|
|
Binary file not shown.
Before Width: | Height: | Size: 142 KiB |
Binary file not shown.
Before Width: | Height: | Size: 176 KiB |
Binary file not shown.
Before Width: | Height: | Size: 176 KiB |
Binary file not shown.
Before Width: | Height: | Size: 177 KiB |
@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "make test",
|
"test": "make test",
|
||||||
"precommit": "make -j4 lint",
|
"precommit": "./bin/generate-sketch-pngs && make -j4 lint",
|
||||||
"prepush": "make test"
|
"prepush": "make test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user