Skip to content

Commit

Permalink
3.0.2 released
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Bazarov committed Sep 16, 2019
1 parent a231a40 commit 1c7b3ad
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Change Log

## Version 3.0.2 (16 Sep 2019)
- Improved error handling

## Version 3.0.1 (13 Sep 2019)
- Updated plugin icon

Expand Down
Binary file modified PuzzleTokens.sketchplugin.zip
Binary file not shown.
39 changes: 21 additions & 18 deletions PuzzleTokens.sketchplugin/Contents/Sketch/classes/DSApp.js
Expand Up @@ -77,13 +77,15 @@ class DSApp {
if(!this._showDialog()) return false
this.pathToTokens = this.pathToTokensLess.substring(0, this.pathToTokensLess.lastIndexOf("/"));

this._initPages()

while(true){
this._initPages()

if( !this.loadLess()) return false
if( !this._applyLess() ) return false
if( !this.loadLess()) break
if( !this._applyLess() ) break
if(this.genSymbTokens) this._saveElements()

if(this.genSymbTokens) this._saveElements()
break
}

// show final message
if(this.errors.length>0){
Expand All @@ -99,10 +101,6 @@ class DSApp {


_saveElements(){
/*
const pathToRules = this.pathToSketchStylesJSON.substring(0, this.pathToSketchStylesJSON.lastIndexOf("/"))
+ "/" + this.doc.name + "." + Constants.SYMBOLTOKENFILE_POSTFIX
*/
const pathDetails = path.parse(this.jDoc.path)
const pathToRules = pathDetails.dir + "/" + pathDetails.name + Constants.SYMBOLTOKENFILE_POSTFIX
log(pathToRules)
Expand Down Expand Up @@ -150,17 +148,12 @@ class DSApp {
return true
}

_getTokensText(){
var tokensStr = ''

tokensStr = tokensStr + Utils.readFile(this.pathToTokensLess)

return tokensStr
}


_applyLess() {
var tokensStr = Utils.readFile(this.pathToSketchStylesJSON)
if(null==tokensStr){
this.logError("Can not find .json file by path: "+this.pathToSketchStylesJSON)
return false
}
var tokens = JSON.parse(tokensStr)

for(var tokenName of Object.keys(tokens)){
Expand Down Expand Up @@ -252,6 +245,16 @@ class DSApp {
loadLess() {
const tempFolder = Utils.getPathToTempFolder()

// check files
if(!Utils.fileExistsAtPath(this.pathToTokensLess)){
this.logError("Can not find .less file by path: "+this.pathToTokensLess)
return false
}
if(!Utils.fileExistsAtPath(this.pathToSketchStylesJSON)){
this.logError("Can not find .json file by path: "+this.pathToSketchStylesJSON)
return false
}

// Copy less2json conversion script
const scriptPath = Utils.copyScript('nsconvert.js',tempFolder)
if(undefined==scriptPath) return false
Expand Down
5 changes: 5 additions & 0 deletions PuzzleTokens.sketchplugin/Contents/Sketch/lib/utils.js
Expand Up @@ -78,6 +78,11 @@ class Utils {
return NSString.stringWithContentsOfFile_encoding_error(path, NSUTF8StringEncoding, null);
}

static fileExistsAtPath(filePath) {
const fileManager = NSFileManager.defaultManager();
return fileManager.fileExistsAtPath(filePath);
}

static deleteFile(filePath) {
const fileManager = NSFileManager.defaultManager();

Expand Down
2 changes: 1 addition & 1 deletion PuzzleTokens.sketchplugin/Contents/Sketch/manifest.json
Expand Up @@ -7,7 +7,7 @@
"appcast": "https://raw.githubusercontent.com/ingrammicro/puzzle-tokens/master/appcast.xml",
"compatibleVersion": 3,
"bundleVersion": 1,
"version" : "3.0.1",
"version" : "3.0.2",
"icon": "icon.png",
"commands" : [
{
Expand Down
Expand Up @@ -31,7 +31,12 @@ function loadLessVars(fileName1,fileName2){
var lessVars = {}

var data = ''
data = data + fs.readFileSync(fileName1, 'utf8');
const data1 = fs.readFileSync(fileName1, 'utf8');
if(null==data1){
console.log("Can't open file by path:"+fileName1)
return lessVars
}
data = data + data1;
if(fileName2!=undefined){
data = data + fs.readFileSync(fileName2, 'utf8');
}
Expand Down
6 changes: 3 additions & 3 deletions appcast.xml
Expand Up @@ -6,9 +6,9 @@
<description>Apply tokens to Sketch layers and styles</description>
<language>en</language>
<item>
<title>Version 3.0.1</title>
<date>13 Sep 2019</date>
<enclosure url="https://github.com/ingrammicro/puzzle-tokens/raw/master/PuzzleTokens.sketchplugin.zip" sparkle:version="3.0.1"/>
<title>Version 3.0.2</title>
<date>16 Sep 2019</date>
<enclosure url="https://github.com/ingrammicro/puzzle-tokens/raw/master/PuzzleTokens.sketchplugin.zip" sparkle:version="3.0.2"/>
</item>

</channel>
Expand Down
Binary file added archives/PuzzleTokens.sketchplugin.3.0.2.zip
Binary file not shown.

0 comments on commit 1c7b3ad

Please sign in to comment.