Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardcoded paths for .sketch files #4

Open
artemnovichkov opened this issue Oct 18, 2017 · 5 comments
Open

Remove hardcoded paths for .sketch files #4

artemnovichkov opened this issue Oct 18, 2017 · 5 comments

Comments

@artemnovichkov
Copy link
Owner

project command creates a folder structure and copies .sketch files. Paths for the files are hardcoded:

private func addSketchFiles(to folder: Folder, projectName: String) throws {
//TODO: Hardcoded paths. Think about it.
try Platform.all.forEach { platform in
let platformName = platform.rawValue
let sketchFile = try File(path: Keys.fileTemplates + "sketch_\(platformName.lowercased()).sketch")
let sketchFileData = try sketchFile.read()
let fileName = "\(platformName)/UI/" + projectName + " -\(platformName.lowercased()).sketch"
try folder.createFile(named: fileName, contents: sketchFileData)
}
}
}

I want to update project.sasha configuration file format and add possibility to add these paths, for example:

Main
-folder
--{ sketch_ios.sketch }

Also, I want to improve parsing of configuration files:

func paths(fromString string: String) -> [String] {
let components = string.components(separatedBy: "\n")
let allFolders = components.map { component -> Folder in
let name = component.replacingOccurrences(of: "-", with: "")
let level = component.characters.filter { $0 == "-" }
return Folder(name: name, level: level.count)
}
var paths = [String]()
var currentLevel = 0
var currentPath: String?
allFolders.forEach { folder in
if let path = currentPath {
if folder.level > currentLevel {
currentPath = path + Keys.slash + folder.name
}
else {
var components = path.components(separatedBy: Keys.slash)
var subComponents = components[0..<folder.level]
subComponents.append(folder.name)
currentPath = subComponents.joined(separator: Keys.slash)
}
currentLevel = folder.level
}
else {
currentPath = folder.name
currentLevel = folder.level
}
if let path = currentPath {
paths.append(path)
}
}
return paths
}

@artemnovichkov artemnovichkov changed the title Remove hardcoded oaths for .sketch files Remove hardcoded paths for .sketch files Oct 18, 2017
@stalinkay
Copy link

@artemnovichkov Maybe this will also help. After clean installing sasha. I get the following output.

/usr/local/Cellar/sasha/2.0.3
├── INSTALL_RECEIPT.json
├── LICENSE
├── README.md
└── bin
    └── sasha

1 directory, 4 files

@artemnovichkov
Copy link
Owner Author

@stalinkay, this issues is not related to installation. When you run project command, Sasha also adds .sketch templates. But paths for these files are hardcoded.

@stalinkay
Copy link

@artemnovichkov Cool. There's currently no file at ~/.sasha/project.sasha, in fact ~/.sasha is never created.

@artemnovichkov
Copy link
Owner Author

I guess I forgot to add coping of project.sasha here:

sasha/Makefile

Lines 22 to 24 in e58db8f

install: build
mkdir -p $(PREFIX)/bin
cp -f $(RELEASE_BINARY_FOLDER) $(PREFIX)/bin/$(BINARY)

It would be great if you fix it

@stalinkay
Copy link

@artemnovichkov Cool. I'll hop on it.

@artemnovichkov artemnovichkov self-assigned this Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants