Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11 from inthepocket/feature/hubble
Browse files Browse the repository at this point in the history
Rebrand: Hubble
  • Loading branch information
thibmaek authored Nov 28, 2018
2 parents f9b6f8b + aae845d commit 51a298e
Show file tree
Hide file tree
Showing 15 changed files with 6,764 additions and 4,870 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!--
Thanks for your interest in the project. We appreciate every form of contribution to the sketchxport project!
Thanks for your interest in the project. We appreciate every form of contribution to the hubble project!
Please fill out this template with all the relevant information so we can
understand what's going on and fix the issue.
Be sure to check the documentation first, your issue might be solved by following the criteria described there.
-->

<!-- Please note that using Sketchxport requires Sketch v41 or higher -->
<!-- Please note that using hubble-scripts requires Sketch v41 or higher -->
- Sketch.app version:
<!-- node -v, only node@8 or higher supported -->
- `node` version:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ npm-debug.log

# Build artifacts
sketchtool-export
sketchxport.json
hubble-data.json
logdump.json
assets/images

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ matrix:
- language: shell
sudo: false
script:
- shellcheck sketchtool.sh sketchxport.sh
- shellcheck sketchtool.sh hubble.sh
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
For the changelog, see [the releases page](https://github.com/inthepocket/sketchxport-scripts/releases)
For the changelog, see [the releases page](https://github.com/inthepocket/hubble-scripts/releases)
67 changes: 34 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<p align="center">
<h1 align="center">💎 sketchxport-scripts</h1>

<p align="center">
<a href='./LICENSE'>
<img src="https://badgen.net/badge/license/MIT/blue" alt="MIT License">
</a>
<img src="https://badgen.net/badge/platform/macOS?icon=apple" alt="" />
<a href="https://github.com/inthepocket/sketchxport-scripts/releases">
<img src="https://badgen.net/github/releases/inthepocket/sketchxport-scripts" />
</a>
<img src="https://badgen.net/github/last-commit/inthepocket/sketchxport-scripts" />
<a href="https://travis-ci.org/inthepocket/sketchxport-scripts">
<img src="https://badgen.net/travis/inthepocket/sketchxport-scripts" />
</a>
</p>

<p align="center">
Export configuration data like colors, fonts & text styles out of sketch to a universally parseable JSON format.<br/>
This repository is an attempt to further automate design systems & tooling at In The Pocket.<br/>
<br/>
Assets can also be exported as platform-friendly PNG & SVG formats.
</p>
</p>
<div align="center">
<h1 align="center">🔭 hubble-scripts</h1>
<div align="center">
<img src="./icon.png" alt="Hubble Icon" />
<p>
<a href='./LICENSE'>
<img src="https://badgen.net/badge/license/MIT/blue" alt="MIT License">
</a>
<img src="https://badgen.net/badge/platform/macOS?icon=apple" alt="" />
<a href="https://github.com/inthepocket/hubble-scripts/releases">
<img src="https://badgen.net/github/releases/inthepocket/hubble-scripts" />
</a>
<img src="https://badgen.net/github/last-commit/inthepocket/hubble-scripts" />
<a href="https://travis-ci.org/inthepocket/hubble-scripts">
<img src="https://badgen.net/travis/inthepocket/hubble-scripts" />
</a>
</p>
<p>
Export configuration data like colors, fonts & text styles out of sketch to a universally parseable JSON format.<br/>
This repository is an attempt to further automate design systems & tooling at In The Pocket.<br/>
<br/>
Assets can also be exported as platform-friendly PNG & SVG formats.
</p>
</div>
</div>

# Prerequisites

Expand All @@ -35,17 +36,17 @@
## Generating JSON config

This will generate a `sketchxport.json` file with text styles & colors found in a Sketch document.
This will generate a `hubble-data.json` file with text styles & colors found in a Sketch document.
Works best with a library file.

```bash
bash ./sketchxport.sh "/home/usr/file.sketch"
bash ./hubble.sh "/home/usr/file.sketch"
```

You can optionally specify a config output dir as $2 and asset output dir as $3. Otherwise current working directory will be used:

```bash
bash ./sketchxport.sh "/home/usr/file.sketch" "/var/sketchxport" "/var/sketchxport/assets/images"
bash ./hubble.sh "/home/usr/file.sketch" "/var/hubble" "/var/hubble/assets/images"
```

## Exporting assets
Expand All @@ -54,7 +55,7 @@ Will export all assets as SVG (for web) and PNG (1x, 2x, 3x for native).
Works best with a library file.

```bash
bash ./sketchtool.sh "MyFile.sketch" "/var/sketchxport/assets/images"
bash ./sketchtool.sh "MyFile.sketch" "/var/hubble/assets/images"
```

## Uploading to cloud
Expand All @@ -67,7 +68,7 @@ Each script takes 3 arguments
2) Configuration output folder
3) Bucket name

You can configure this service by adding one of these lines to `sketchxport.sh`
You can configure this service by adding one of these lines to `hubble.sh`

`upload_to_gcloud "$ASSETS_OUTPUT_DIR" "$CONFIG_OUTPUT_DIR" "$1"`

Expand All @@ -77,13 +78,13 @@ You can configure this service by adding one of these lines to `sketchxport.sh`

## Importing into a project

Copy `sketchxport.sh` and `sketchtool.sh` to a scripts folder in your project
Copy `hubble.sh` and `sketchtool.sh` to a scripts folder in your project
Advised is to add a npm run task for this:

```json
{
"scripts": {
"sketchxport": "./scripts/sketchxport.sh"
"hubble": "./scripts/hubble.sh"
}
}
```
Expand All @@ -108,8 +109,8 @@ If you have Docker installed you could use [trevor](https://github.com/vadimdeme
$ brew install shellcheck
$ npm run lint:shell

In sketchxport.sh line 6:
printf "\n\\033[1m\\033[34m%s\\033[0m\\n\\n" "[sketchxport-scripts] ${1}"
In hubble.sh line 6:
printf "\n\\033[1m\\033[34m%s\\033[0m\\n\\n" "[hubble-scripts] ${1}"
^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".

```
Binary file added bin/hubble-cli
Binary file not shown.
10 changes: 7 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const app = require('./index');

const cli = meow(`
Usage
$ sketchxport-cli <input> --outputDir="/home/usr/downloads"
$ hubble-cli <input> --outputDir="/home/usr/downloads"
Options
--outputDir=<dir>, -o The directory where parsed files will be placed after a run. Defaults to current working directory
--dump, -d Dump all Sketch JSON files into 1 logdump.json
--useColorArtboards Use artboards named "primitives/color/<name>" to export colors instead of using the document colors
Examples
$ sketchxport-cli "__mocks/sample_sketchfile.sketch"
$ sketchxport-cli "__mocks__/sample_sketchfile.sketch" -d --useColorArtboards --outputDir="config/"
$ hubble-cli "__mocks/sample_sketchfile.sketch"
$ hubble-cli "__mocks__/sample_sketchfile.sketch" -d --useColorArtboards --outputDir="config/"
`, {
flags: {
outputDir: {
Expand All @@ -28,6 +28,10 @@ const cli = meow(`
useColorArtboards: {
type: 'boolean',
default: false,
},
version: {
type: "boolean",
alias: 'v',
}
},
});
Expand Down
12 changes: 6 additions & 6 deletions sketchxport.sh → hubble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ set -e

# Pretty log output
function log() {
printf "\\n\\033[1m\\033[34m%s\\033[0m\\n\\n" "[sketchxport-scripts] ${1}"
printf "\\n\\033[1m\\033[34m%s\\033[0m\\n\\n" "[hubble-scripts] ${1}"
}

# Generate config file from sketchxport
# Generate config file from hubble
function generate_config() {
log "💎 Generating config from sketchfile..."
node cli.js "$SKETCHFILE" --outputDir="$CONFIG_OUTPUT_DIR" "$@"
}

# Generate assets from sketchxport
# Generate assets from hubble
function generate_assets() {
log "💎 Exporting & moving assets from sketchfile..."

if [ ! -d "$ASSETS_OUTPUT_DIR" ]; then
log "Asset output dir does not exist yet. Creating it"
mkdir -p "$ASSETS_OUTPUT_DIR/$SKETCHXPORT_ASSETS_OUTPUT_DIR"
mkdir -p "$ASSETS_OUTPUT_DIR"
fi

bash ./sketchtool.sh "$SKETCHFILE" "$ASSETS_OUTPUT_DIR"
Expand All @@ -35,7 +35,7 @@ function main() {
if [ -z "$1" ]; then
echo "No sketchfile provided"
echo "Please provide a sketchfile to export!"
echo "e.g: ./sketchxport.sh \"/home/usr/file.sketch\""
echo "e.g: ./hubble.sh \"/home/usr/file.sketch\""
exit 1
fi

Expand All @@ -56,6 +56,6 @@ function main() {
generate_config "$@"
generate_assets "$@"

upload_to_cloud "sketchxport-output-dir"
upload_to_cloud "hubble-output-dir"
}
main "$@"
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const fs = require('fs');
const sketch2json = require('sketch2json');
const pkg = require('./package.json');

const { getPageArrays, getColorsFromArtboard } = require('./lib/sketch');
const { prettyJSON } = require('./lib/utils');
const { mapTextStyles, mapColors } = require('./lib/mappers');

module.exports = (args, flags) => {
if (flags.version) return pkg.version;

if (args.length <= 0) throw new Error('No file input passed after npm start');

const [filePath] = args;

fs.readFile(filePath, async (error, data) => {
return fs.readFile(filePath, async (error, data) => {
if (error) throw new Error(error);

try {
Expand All @@ -19,7 +22,7 @@ module.exports = (args, flags) => {

const primitivesPage = getPageArrays(response).find(i => i.name === 'primitives');
if (primitivesPage && flags.useColorArtboards) {
console.log("[sketchxport-scripts] 💎 Using color artboards instead of document colors")
console.log("[hubble-scripts] 💎 Using color artboards instead of document colors")
colorLayers = getColorsFromArtboard(primitivesPage.layers);
} else {
colorLayers = response.document.assets.colors;
Expand All @@ -38,7 +41,7 @@ module.exports = (args, flags) => {
}

await fs.writeFile(
`${flags.outputDir}/sketchxport.json`,
`${flags.outputDir}/hubble-data.json`,
prettyJSON(mapping),
err => err && console.error(err),
);
Expand Down
Loading

0 comments on commit 51a298e

Please sign in to comment.