├── .gitignore ├── LICENSE ├── README.md ├── keymaps └── sourcefetch.json ├── lib └── sketchapp-scripter.js ├── menus └── sourcefetch.json ├── package.json ├── scripting └── run.sketchplugin └── styles └── sourcefetch.less /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | npm-debug.log 4 | node_modules 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Timur Carpeev 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sketchapp scripter 2 | 3 | Atom package for running sketch app scripts from the atom editor 4 | 5 | ## Install 6 | 7 | Using `apm`: 8 | 9 | ```sh 10 | apm install sketchapp-scripter 11 | ``` 12 | 13 | Or search for `sketchapp-scripter` in Atom settings view. 14 | 15 | ## Run 16 | From any file in the Atom editor press ```CTRL+R``` 17 | 18 | Tip: You can monitor Sketch logs from the Atom's console ```(alt+cmd+i)``` 19 | -------------------------------------------------------------------------------- /keymaps/sourcefetch.json: -------------------------------------------------------------------------------- 1 | { 2 | "atom-workspace": { 3 | "ctrl-r": "sketchapp-scripter:runScript" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/sketchapp-scripter.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import { CompositeDisposable } from 'atom' 4 | import fs from 'fs' 5 | import child_process from 'child_process' 6 | import coscript from 'coscript' 7 | 8 | export default { 9 | 10 | subscriptions: null, 11 | 12 | activate() { 13 | this.subscriptions = new CompositeDisposable() 14 | 15 | this.subscriptions.add(atom.commands.add('atom-workspace', { 16 | 'sketchapp-scripter:runScript': () => this.runScript() 17 | })) 18 | }, 19 | 20 | deactivate() { 21 | this.subscriptions.dispose() 22 | }, 23 | 24 | runScript() { 25 | 26 | const packageDir = atom.packages.getLoadedPackage('sketchapp-scripter').path; 27 | let editor = atom.workspace.getActiveTextEditor(); 28 | 29 | if(editor){ 30 | const userCode = editor.getText(); 31 | fs.writeFile(packageDir+'/scripting/run.sketchplugin', userCode) 32 | child_process.exec(coscript + ' -e "[[[COScript app:\\\"Sketch\\\"] delegate] runPluginAtURL:[NSURL fileURLWithPath:\\\"'+ packageDir +'/scripting/run.sketchplugin\\\"]]"', function (error, stdout, stderr) { 33 | console.log(error) 34 | console.log(stdout) 35 | console.log(stderr) 36 | }); 37 | } 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /menus/sourcefetch.json: -------------------------------------------------------------------------------- 1 | { 2 | "context-menu": { 3 | "atom-text-editor": [ 4 | { 5 | "label": "Run script", 6 | "command": "sketchapp-scripter:runScript" 7 | } 8 | ] 9 | }, 10 | "menu": [ 11 | { 12 | "label": "Packages", 13 | "submenu": [ 14 | { 15 | "label": "Sketchapp scripter", 16 | "submenu": [ 17 | { 18 | "label": "Run script", 19 | "command": "sketchapp-scripter:runScript" 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sketchapp-scripter", 3 | "main": "./lib/sketchapp-scripter", 4 | "version": "0.1.0", 5 | "description": "Run scketch scripts from Atom", 6 | "keywords": [], 7 | "activationCommands": { 8 | "atom-workspace": "sketchapp-scripter:runScript" 9 | }, 10 | "repository": "https://github.com/timuric/sketchapp-scripter", 11 | "license": "MIT", 12 | "engines": { 13 | "atom": ">=1.0.0 <2.0.0" 14 | }, 15 | "dependencies": { 16 | "coscript": "^1.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /scripting/run.sketchplugin: -------------------------------------------------------------------------------- 1 | context.document.showMessage('hola') 2 | log(context) -------------------------------------------------------------------------------- /styles/sourcefetch.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .sourcefetch { 8 | } 9 | --------------------------------------------------------------------------------