Skip to content

Commit e7e0d11

Browse files
authored
Re-organize the naming convention of module, type, product, and file to have consistent project structure (#450)
* rename modules * rename to CartonReleaseCommand * call async overload * fix commandName * frontend name
1 parent 67d4742 commit e7e0d11

21 files changed

+42
-34
lines changed

Package.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ let package = Package(
1414
.library(name: "SwiftToolchain", targets: ["SwiftToolchain"]),
1515
.library(name: "CartonHelpers", targets: ["CartonHelpers"]),
1616
.library(name: "CartonKit", targets: ["CartonKit"]),
17-
.library(name: "CartonCLI", targets: ["CartonCLI"]),
17+
.library(name: "CartonFrontend", targets: ["CartonFrontend"]),
1818
.executable(name: "carton", targets: ["carton"]),
1919
.executable(name: "carton-release", targets: ["carton-release"]),
20-
.plugin(name: "CartonBundle", targets: ["CartonBundle"]),
21-
.plugin(name: "CartonTest", targets: ["CartonTest"]),
22-
.plugin(name: "CartonDev", targets: ["CartonDev"]),
20+
.plugin(name: "CartonBundlePlugin", targets: ["CartonBundlePlugin"]),
21+
.plugin(name: "CartonTestPlugin", targets: ["CartonTestPlugin"]),
22+
.plugin(name: "CartonDevPlugin", targets: ["CartonDevPlugin"]),
2323
.executable(name: "carton-plugin-helper", targets: ["carton-plugin-helper"]),
2424
],
2525
dependencies: [
@@ -43,47 +43,47 @@ let package = Package(
4343
]
4444
),
4545
.executableTarget(
46-
name: "CartonFrontend",
46+
name: "carton-frontend",
4747
dependencies: [
48-
"CartonCLI",
48+
"CartonFrontend"
4949
]
5050
),
5151
.plugin(
52-
name: "CartonBundle",
52+
name: "CartonBundlePlugin",
5353
capability: .command(
5454
intent: .custom(
5555
verb: "carton-bundle",
5656
description: "Produces an optimized app bundle for distribution."
5757
)
5858
),
59-
dependencies: ["CartonFrontend"],
59+
dependencies: ["carton-frontend"],
6060
exclude: ["CartonPluginShared/README.md"]
6161
),
6262
.plugin(
63-
name: "CartonTest",
63+
name: "CartonTestPlugin",
6464
capability: .command(
6565
intent: .custom(
6666
verb: "carton-test",
6767
description: "Run the tests in a WASI environment."
6868
)
6969
),
70-
dependencies: ["CartonFrontend"],
70+
dependencies: ["carton-frontend"],
7171
exclude: ["CartonPluginShared/README.md"]
7272
),
7373
.plugin(
74-
name: "CartonDev",
74+
name: "CartonDevPlugin",
7575
capability: .command(
7676
intent: .custom(
7777
verb: "carton-dev",
7878
description: "Watch the current directory, host the app, rebuild on change."
7979
)
8080
),
81-
dependencies: ["CartonFrontend"],
81+
dependencies: ["carton-frontend"],
8282
exclude: ["CartonPluginShared/README.md"]
8383
),
8484
.executableTarget(name: "carton-plugin-helper"),
8585
.target(
86-
name: "CartonCLI",
86+
name: "CartonFrontend",
8787
dependencies: [
8888
.product(name: "Logging", package: "swift-log"),
8989
"CartonKit",
@@ -136,7 +136,7 @@ let package = Package(
136136
.testTarget(
137137
name: "CartonCommandTests",
138138
dependencies: [
139-
"CartonCLI",
139+
"CartonFrontend",
140140
.product(name: "ArgumentParser", package: "swift-argument-parser"),
141141
]
142142
),

Plugins/CartonBundle/Plugin.swift renamed to Plugins/CartonBundlePlugin/CartonBundlePluginCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616
import PackagePlugin
1717

1818
@main
19-
struct CartonBundlePlugin: CommandPlugin {
19+
struct CartonBundlePluginCommand: CommandPlugin {
2020

2121
struct Options {
2222
var product: String?

Plugins/CartonDev/Plugin.swift renamed to Plugins/CartonDevPlugin/CartonDevPluginCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616
import PackagePlugin
1717

1818
@main
19-
struct CartonDevPlugin: CommandPlugin {
19+
struct CartonDevPluginCommand: CommandPlugin {
2020
struct Options {
2121
var product: String?
2222
var release: Bool

Plugins/CartonPluginShared/PluginShared.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ internal func checkHelpFlag(_ arguments: [String], subcommand: String, context:
194194
internal func makeCartonFrontendProcess(context: PluginContext, arguments: [String]) throws
195195
-> Process
196196
{
197-
let frontend = try context.tool(named: "CartonFrontend")
197+
let frontend = try context.tool(named: "carton-frontend")
198198

199199
Diagnostics.remark(
200200
"Running " + ([frontend.path.string] + arguments).map { "\"\($0)\"" }.joined(separator: " "))

Plugins/CartonTest/Plugin.swift renamed to Plugins/CartonTestPlugin/CartonTestPluginCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616
import PackagePlugin
1717

1818
@main
19-
struct CartonTestPlugin: CommandPlugin {
19+
struct CartonTestPluginCommand: CommandPlugin {
2020
struct Options {
2121
var environment: Environment
2222
var prebuiltTestBundlePath: String?

Sources/CartonCLI/Carton.swift renamed to Sources/CartonFrontend/CartonFrontendCommand.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
import ArgumentParser
1616
import CartonHelpers
1717

18-
public struct Carton: AsyncParsableCommand {
18+
public struct CartonFrontendCommand: AsyncParsableCommand {
1919
public static let configuration = CommandConfiguration(
20+
commandName: "carton-frontend",
2021
abstract: "📦 Watcher, bundler, and test runner for your SwiftWasm apps.",
2122
version: cartonVersion,
22-
subcommands: [Bundle.self, Dev.self, Test.self]
23+
subcommands: [
24+
CartonFrontendBundleCommand.self,
25+
CartonFrontendDevCommand.self,
26+
CartonFrontendTestCommand.self
27+
]
2328
)
2429

2530
public init() {}

Sources/CartonCLI/Commands/Bundle.swift renamed to Sources/CartonFrontend/Commands/CartonFrontendBundleCommand.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum WasmOptimizations: String, CaseIterable, ExpressibleByArgument {
2222
case size, none
2323
}
2424

25-
struct Bundle: AsyncParsableCommand {
25+
struct CartonFrontendBundleCommand: AsyncParsableCommand {
2626
@Argument(
2727
help: ArgumentHelp(
2828
"Internal: Path to the main WebAssembly file built by the SwiftPM Plugin process.",
@@ -67,6 +67,7 @@ struct Bundle: AsyncParsableCommand {
6767
var output: String
6868

6969
static let configuration = CommandConfiguration(
70+
commandName: "bundle",
7071
abstract: "Produces an optimized app bundle for distribution."
7172
)
7273

0 commit comments

Comments
 (0)