Skip to content

Commit 04e5c52

Browse files
QA sessions (#146)
* show information about what the render fails * remove playground page content - prevent user add its code between hidden blocks * update nef version * Update project/Core/Models/CoreRenderError.swift Co-Authored-By: Tomás Ruiz-López <[email protected]> * Update project/Core/Models/CoreRenderError.swift Co-Authored-By: Tomás Ruiz-López <[email protected]> * Update project/Core/Models/CoreRenderError.swift Co-Authored-By: Tomás Ruiz-López <[email protected]> Co-authored-by: Tomás Ruiz-López <[email protected]>
1 parent ba19147 commit 04e5c52

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

project/Component/NefRender/Render.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public struct Render<A> {
9696

9797
return binding(
9898
|<-env.console.print(information: "\t• Processing page \(info.data?.page.title ?? "content")"),
99-
rendered <- env.nodePrinter(content).provide(info).mapError { _ in .content() },
99+
rendered <- env.nodePrinter(content).provide(info).mapError { e in .content(info: e) },
100100
yield: rendered.get)^.reportStatus(console: env.console)
101101
}
102102
}

project/Component/nef/Instances/MacNefPlaygroundSystem.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class MacNefPlaygroundSystem: NefPlaygroundSystem {
103103
private func downloadTemplate(into output: URL) -> EnvIO<FileSystem, NefPlaygroundSystemError, URL> {
104104
func downloadZip(into output: URL) -> EnvIO<FileSystem, NefPlaygroundSystemError, URL> {
105105
EnvIO.invoke { _ in
106-
let zip = output.appendingPathComponent("\(BuildConfiguration.templateName).zip")
106+
let zip = output.appendingPathComponent("\(BuildConfiguration.templateVersion).zip")
107107
let result = run("curl", args: ["-LkSs", Template.path, "-o", zip.path])
108108
guard result.exitStatus == 0 else {
109109
throw NefPlaygroundSystemError.template(info: result.stderr)
@@ -123,7 +123,7 @@ class MacNefPlaygroundSystem: NefPlaygroundSystem {
123123
}
124124

125125
return EnvIO { fileSystem in
126-
let templateName = "nef-\(BuildConfiguration.templateName)"
126+
let templateName = "nef-\(BuildConfiguration.templateVersion)"
127127
let unzipFolder = output.appendingPathComponent(templateName)
128128

129129
let cleamTemplateIO = fileSystem.removeDirectory(unzipFolder.path).handleError { _ in }
@@ -420,7 +420,7 @@ class MacNefPlaygroundSystem: NefPlaygroundSystem {
420420

421421
// MARK: - Constants
422422
private enum Template {
423-
static let path = "https://github.com/bow-swift/nef/archive/\(BuildConfiguration.templateName).zip"
423+
static let path = "https://github.com/bow-swift/nef/archive/\(BuildConfiguration.templateVersion).zip"
424424
}
425425

426426
private enum Bow {

project/Component/nef/Utils/BuildConfiguration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
import Foundation
44

55
internal enum BuildConfiguration {
6-
static let buildVersion = "0.6.0"
7-
static let templateName = "0.6.0"
6+
static let buildVersion = "0.6.1"
7+
static let templateVersion = "0.6.1"
88
}

project/Core/Models/CoreRenderError.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22

33
import Foundation
44

5-
public enum CoreRenderError: Error {
5+
public enum CoreRenderError: Error, Equatable {
66
case ast
7-
case renderNode
7+
case renderNode(String)
88
case renderEmpty
99
}
10+
11+
extension CoreRenderError: CustomStringConvertible {
12+
public var description: String {
13+
switch self {
14+
case .ast:
15+
return "Syntax analysis failed. Review all the begin/end delimiters are correct."
16+
case .renderNode(let node):
17+
return "Could not render node: \n\(node)\n"
18+
case .renderEmpty:
19+
return "Render result was empty. Review the page and nef hidden blocks."
20+
}
21+
}
22+
}

project/Core/Render/CoreCarbon.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension Node {
3636
let code = nodes.map { $0.carbon() }.joined()
3737
guard !code.isEmpty else { return IO.raiseError(.renderEmpty)^ }
3838
let configuration = CarbonModel(code: code, style: style)
39-
return downloader.carbon(configuration: configuration).mapError { _ in .renderNode }
39+
return downloader.carbon(configuration: configuration).mapError { _ in .renderNode(code) }
4040

4141
default:
4242
return IO.pure(Image.empty)^
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
// nef:begin:hidden
2-
import UIKit
3-
4-
Nef.Playground.needsIndefiniteExecution(true)
5-
// nef:end
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
// nef:begin:hidden
2-
import UIKit
3-
4-
Nef.Playground.needsIndefiniteExecution(true)
5-
// nef:end

0 commit comments

Comments
 (0)