Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion NectoMac/Sources/necto-cli/NectoCLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,12 @@ struct Pack: AsyncParsableCommand {
// The next step is only news to someone doing this by hand. A script that
// packages several plugins is going to publish them together.
if !quiet {
let assets = [archivePath, manifestPath].map { file in
shellArgument(output == nil ? "./\(file.lastPathComponent)" : file.path)
}.joined(separator: " ")
print("")
print("Next:")
print(" gh release create <tag> \(archivePath.lastPathComponent) \(manifestPath.lastPathComponent)")
print(" gh release create <tag> \(assets)")
}
}

Expand Down
8 changes: 4 additions & 4 deletions NectoMac/Sources/necto-cli/PluginHelp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ enum PluginHelp {
return displayText(lines.joined(separator: "\n"))
}

private static func shellArgument(_ value: String) -> String {
"'" + value.replacingOccurrences(of: "'", with: "'\"'\"'") + "'"
}

static func schemaLines(_ schema: NectoJSONValue, name: String? = nil, required: Bool = false, depth: Int = 0) -> [String] {
let indent = String(repeating: " ", count: depth + 1)
guard depth < 12 else { return [indent + "… See --json for the complete schema."] }
Expand All @@ -143,6 +139,10 @@ enum PluginHelp {
}
}

func shellArgument(_ value: String) -> String {
"'" + value.replacingOccurrences(of: "'", with: "'\"'\"'") + "'"
}

func displayText(_ text: String) -> String {
String(text.unicodeScalars.filter { !CharacterSet.controlCharacters.contains($0) || $0 == "\n" || $0 == "\t" })
}
28 changes: 28 additions & 0 deletions NectoMac/Tests/NectoCLITests/NectoCLIBlackBoxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,34 @@ struct NectoCLIBlackBoxTests {
#expect(result.status == 130)
}

@Test("pack's release command names both files in the selected output directory")
func packReleasePaths() async throws {
let fixture = try CLIProcessFixture()
defer { fixture.close() }
let panel = fixture.directory.appending(path: "dist")
try FileManager.default.createDirectory(at: panel, withIntermediateDirectories: true)
let manifest = NectoPluginManifest(
id: "sample", name: "Sample", description: "Sample panel", version: "1.0.0",
author: "Necto", icon: .init(systemName: "terminal"), assets: ["index.html"],
allowedOrigins: ["self"], operations: []
)
try JSONEncoder().encode(manifest).write(to: panel.appending(path: "manifest.json"))
try Data("<!doctype html>".utf8).write(to: panel.appending(path: "index.html"))

let output = fixture.directory.appending(path: "Author's releases")
let result = try await fixture.run(["plugin", "pack", panel.path, "--output", output.path])
try #require(result.status == 0, "\(result.error)")
let command = try #require(result.output.split(separator: "\n").last).trimmingCharacters(in: .whitespaces)
let prefix = "gh release create <tag> "
try #require(command.hasPrefix(prefix))
let parsed = try await fixture.run(["-c", "printf '%s\\n' " + command.dropFirst(prefix.count)],
executable: URL(filePath: "/bin/sh"))
let files = ["sample-1.0.0.zip", "sample-1.0.0.manifest.json"].map { output.appending(path: $0).path }
#expect(parsed.status == 0)
#expect(parsed.output.split(separator: "\n").map(String.init) == files)
#expect(files.allSatisfy { FileManager.default.fileExists(atPath: $0) })
}

@Test("skills install for both agents without Necto and protect user edits")
func skillInstallation() async throws {
let fixture = try CLIProcessFixture()
Expand Down
Loading