Skip to content

Commit

Permalink
增加sketchtool
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodyxu committed Feb 14, 2016
1 parent b86859f commit 9721fd5
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 0 deletions.
86 changes: 86 additions & 0 deletions sketchtool/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Sketch Tool

# USAGE

For full help, use the tool's help command:

> sketchtool help


To list layers, slices, artboards or pages:

> sketchtool list slices <doc.sketch>
> sketchtool list artboards <doc.sketch>
> sketchtool list layers <doc.sketch>
> sketchtool list pages <doc.sketch>

This returns JSON information that can be parsed to obtain page and artboard ids.


To export slices or artboards:

> sketchtool export slices <doc.sketch> --output=<folder> --items=<names-or-ids> --scales="1.0, 2.0" --formats="png,pdf,eps,jpg"

> sketchtool export artboards <doc.sketch> --output=<folder> --items=<names-or-ids> --scales="1.0, 2.0" --formats="png,pdf,eps,jpg"

To export arbitrary rectangles from pages at 1.0 and 2.0 scales, as jpgs:

> sketchtool export pages <doc.sketch> --output=<folder> --items=<page-names-or-ids> --bounds="0,0,256,256" --scales="1.0, 2.0" --formats="jpg"


## Specifying Scales and Formats

By default, we export a layer using the options specified for it in the document.

However, specifying --scales, --formats, or both will override all the size/type export settings.

If --formats is specified but not --scales, the default scale "1.0" is used.

If --scales is specified but not --formats, the default format "png" is used.

If neither is specified, we use the size settings in the document itself.

If both are used, we export all combinations. For example --formats="png,eps" --scales="1.0,2.0" will produce four combinations.


## Defaults

All --options can be ommitted. The defaults are:

--formats=
--scales=
--items=(all slices, artboards, pages)
--bounds=(all content on the page)
--output=(current working directory)
--trimmed=NO
--reveal=NO

# DOCUMENT MIGRATION

Starting with Sketch 3.1, support for loading old documents has been moved into a helper process. In Sketch itself this is an xpc process,
but for the command line sketchtool we've created a standalone tool: sketchmigrate.

You can use this tool to convert old documents manually. It current supports one command:

sketchmigrate convert <old-file-path> <new-file-path>

Note that you don't have to do a migration when using sketchtool - it is smart enough to work out that the document needs migrating,
and call sketchmigrate itself, using a temporary file as the destination.

There's nothing to stop you using the tool yourself if you wish.


# INSTALLATION

The install.sh script will install the tools in /usr/local/bin, and some required resource files in /usr/local/share/sketchtool.

You can put the tools anywhere else that you want, but you currently need to follow the same folder structure:

my-folder/
bin/
sketchtool
sketchmigrate
share/
sketchtool/
resources.bundle

61 changes: 61 additions & 0 deletions sketchtool/RELEASE NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Sketch Tool Release Notes

### 3.5

- Fixed a crash in the dump command when the document contains a NaN value.

### 3.4.4

- Added -use-id-for-name option, which names the exported files using their id instead of their name.

### 3.4

- Updated for Sketch 3.4 compatibility.
- Align SketchTool and Sketch version numbers.
- Fixed a crash when using the --version option.
- Fixed a crash when dumping text with a non-RGB colorspace.
- Added additional attribute information when dumping text layers containing multiple font styles.
- Added -use-id-for-name option, which names the exported files using their id instead of their name.

### 1.4

- Updated for Sketch 3.3 compatibility.
- Fixed a bug where exporting layers with invalid names would crash sketchtool. We now export them as `<invalid layer name>`, so make sure to check for those in your scripts.
- Fixed a bug where the export slices command would ignore IDs in --items= or --item= options.
- Improved dump command output of font information.
- Added 'list layers' command which outputs information on all layers in a document.
- Increased the amount of information output for layers in the 'list' commands: we now output the relative and influence rects, and the rotation if there is
- Documents containing images or patterns should now work ok (for a while there, they caused problems).


### 1.3

- Updated for Sketch 3.2 compatibility.
- Added metadata command to dump metadata for a Sketch file.
- The layer list commands now include a "trimmed" rect for layers. This should indicate what the size will be if the --trimmed flag is used when exporting.
- Added notes command to show these release notes.
- Switched --overwriting option to -V to avoid clash with --version.
- Added --background option allowing you to set/override the background colour when exporting.
- Slight tweak to the code which checks for the resource bundle.
- Output the x and y positions of exported slices when the --outputJSON option is on.
- Added a --group-contents-only option to force the same behaviour as selecting the "Export Group Contents Only" option in a sketch slice
- The dump command now includes objectID values for any model objects which have an ID assigned


### 1.2

- Updated to understand Sketch 3.1 documents.
- Slight tweaks to the way trimming and sizing works, which may slightly reduce the size of exported documents.
- Moved support for old documents into the standalone sketchmigrate tool.
- We now look for the resources in ../share/sketchtool/resources.bundle (for legacy reasons, we also still check for "sketch resources.bundle" in the old location).
- Items (pages, artboards, slices etc) with slashes in their names will now correctly export into subfolders.


### 1.1.1

- Added an export layers command which lets you export any layer, even if it's not been marked as exportable in the document.
- Added a --compact option for SVG export which removes some of the extra crud that we would otherwise generate.
- Added a --trimmed option, although it's not respected currently.
- Fixed some bugs relating to the --items option.
- Fixed the app name in generated SVG files.

Binary file added sketchtool/bin/sketchmigrate
Binary file not shown.
Binary file added sketchtool/bin/sketchtool
Binary file not shown.
12 changes: 12 additions & 0 deletions sketchtool/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

base=`dirname "$0"`

cp "$base/bin/sketchmigrate" /usr/local/bin/
echo Installed `"$base/bin/sketchmigrate" --version` in "/usr/local/bin"

cp "$base/bin/sketchtool" /usr/local/bin/
mkdir -p /usr/local/share/sketchtool
cp -r "$base/share/sketchtool/resources.bundle" /usr/local/share/sketchtool/
echo Installed `"$base/bin/sketchtool" --version` in "/usr/local/bin"

42 changes: 42 additions & 0 deletions sketchtool/share/sketchtool/resources.bundle/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>14F1605</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>share/sketchtool/resources</string>
<key>CFBundleIdentifier</key>
<string>com.bohemiancoding.share-sketchtool-resources</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>share/sketchtool/resources</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6E35b</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>14D125</string>
<key>DTSDKName</key>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0640</string>
<key>DTXcodeBuild</key>
<string>6E35b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013 Bohemian Coding. All rights reserved.</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Sketch Tool Release Notes

### 3.5

- Fixed a crash in the dump command when the document contains a NaN value.

### 3.4.4

- Added -use-id-for-name option, which names the exported files using their id instead of their name.

### 3.4

- Updated for Sketch 3.4 compatibility.
- Align SketchTool and Sketch version numbers.
- Fixed a crash when using the --version option.
- Fixed a crash when dumping text with a non-RGB colorspace.
- Added additional attribute information when dumping text layers containing multiple font styles.
- Added -use-id-for-name option, which names the exported files using their id instead of their name.

### 1.4

- Updated for Sketch 3.3 compatibility.
- Fixed a bug where exporting layers with invalid names would crash sketchtool. We now export them as `<invalid layer name>`, so make sure to check for those in your scripts.
- Fixed a bug where the export slices command would ignore IDs in --items= or --item= options.
- Improved dump command output of font information.
- Added 'list layers' command which outputs information on all layers in a document.
- Increased the amount of information output for layers in the 'list' commands: we now output the relative and influence rects, and the rotation if there is
- Documents containing images or patterns should now work ok (for a while there, they caused problems).


### 1.3

- Updated for Sketch 3.2 compatibility.
- Added metadata command to dump metadata for a Sketch file.
- The layer list commands now include a "trimmed" rect for layers. This should indicate what the size will be if the --trimmed flag is used when exporting.
- Added notes command to show these release notes.
- Switched --overwriting option to -V to avoid clash with --version.
- Added --background option allowing you to set/override the background colour when exporting.
- Slight tweak to the code which checks for the resource bundle.
- Output the x and y positions of exported slices when the --outputJSON option is on.
- Added a --group-contents-only option to force the same behaviour as selecting the "Export Group Contents Only" option in a sketch slice
- The dump command now includes objectID values for any model objects which have an ID assigned


### 1.2

- Updated to understand Sketch 3.1 documents.
- Slight tweaks to the way trimming and sizing works, which may slightly reduce the size of exported documents.
- Moved support for old documents into the standalone sketchmigrate tool.
- We now look for the resources in ../share/sketchtool/resources.bundle (for legacy reasons, we also still check for "sketch resources.bundle" in the old location).
- Items (pages, artboards, slices etc) with slashes in their names will now correctly export into subfolders.


### 1.1.1

- Added an export layers command which lets you export any layer, even if it's not been marked as exportable in the document.
- Added a --compact option for SVG export which removes some of the extra crud that we would otherwise generate.
- Added a --trimmed option, although it's not respected currently.
- Fixed some bugs relating to the --items option.
- Fixed the app name in generated SVG files.

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9721fd5

Please sign in to comment.