Skip to content

Commit 6340897

Browse files
committed
Fix formatting by running swiftformat on the output and applying those rules to the text
In the long run, it would be better for this code to construct a `Manifest` and then use `ManifestSourceGeneration` to generate the text
1 parent 807d96d commit 6340897

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

Sources/Workspace/InitPackage.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,20 @@ public final class InitPackage {
284284
} else if packageType == .buildToolPlugin {
285285
param += """
286286
.plugin(
287-
name: "\(typeName)",
288-
capability: .buildTool()
289-
),
287+
name: "\(typeName)",
288+
capability: .buildTool()
289+
),
290290
]
291291
"""
292292
} else if packageType == .commandPlugin {
293293
param += """
294294
.plugin(
295-
name: "\(typeName)",
296-
capability: .command(intent: .custom(verb: "\(typeName)", description: "prints hello world"))
297-
),
295+
name: "\(typeName)",
296+
capability: .command(intent: .custom(
297+
verb: "\(typeName)",
298+
description: "prints hello world"
299+
))
300+
),
298301
]
299302
"""
300303
} else if packageType == .macro {
@@ -398,24 +401,27 @@ public final class InitPackage {
398401
import PackagePlugin
399402
400403
@main
404+
401405
"""
402406
if packageType == .buildToolPlugin {
403407
content += """
404-
struct \(typeName): BuildToolPlugin {
405-
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
406-
print("Hello, World!")
407-
return []
408-
}
408+
struct \(typeName): BuildToolPlugin {
409+
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
410+
print("Hello, World!")
411+
return []
409412
}
413+
}
414+
410415
"""
411416
}
412417
else {
413418
content += """
414-
struct \(typeName): CommandPlugin {
415-
func performCommand(context: PluginContext, arguments: [String]) async throws {
416-
print("Hello, World!")
417-
}
419+
struct \(typeName): CommandPlugin {
420+
func performCommand(context: PluginContext, arguments: [String]) async throws {
421+
print("Hello, World!")
418422
}
423+
}
424+
419425
"""
420426
}
421427

Tests/WorkspaceTests/InitTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class InitTests: XCTestCase {
169169
XCTAssertFileExists(manifest)
170170
let manifestContents: String = try localFileSystem.readFileContents(manifest)
171171
XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("targets: [\"MyCommandPlugin\"]")))
172-
XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("capability: .command(intent: .custom(verb")))
172+
XCTAssertMatch(manifestContents, .and(.contains(".plugin("),
173+
.and(.contains("capability: .command(intent: .custom("), .contains("verb: \"MyCommandPlugin\""))))
173174

174175
let source = path.appending("Plugins", "MyCommandPlugin.swift")
175176
XCTAssertFileExists(source)

0 commit comments

Comments
 (0)