Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BinaryBirds/swift-plugins
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.0.3
Choose a base ref
...
head repository: BinaryBirds/swift-plugins
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 1 commit
  • 7 files changed
  • 1 contributor

Commits on Jul 15, 2024

  1. Copy the full SHA
    6ef683f View commit details
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,3 +7,5 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.swiftpm/xcode/xcshareddata/xcschemes/swift-plugins-Package.xcscheme
openapi/index.html
openapi/openapi.yaml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ struct RunOpenApiServerPlugin: CommandPlugin {
context: PackagePlugin.PluginContext,
arguments: [String]
) async throws {
try context.runScript(RunOpenApiServerScript())
try context.runScript(RunOpenApiServerScript(), arguments)
}

}
10 changes: 8 additions & 2 deletions Plugins/Shared/Extension + PluginContext.swift
Original file line number Diff line number Diff line change
@@ -13,8 +13,13 @@ import PackagePlugin
//https://forums.swift.org/t/difficulty-sharing-code-between-swift-package-manager-plugins/61690/6
extension PackagePlugin.PluginContext {

func createFile(fileName: String, fileContent: String) throws -> String {
let filePath = self.pluginWorkDirectory.appending(fileName).string
func createFile(
fileVersion: String = "",
fileName: String,
fileContent: String
) throws -> String {
let filePath = self.pluginWorkDirectory
.appending(fileVersion + fileName).string
let fm = FileManager.default

// check if file exist
@@ -40,6 +45,7 @@ extension PackagePlugin.PluginContext {
_ arguments: [String]? = nil
) throws {
let scriptFilePath = try createFile(
fileVersion: ScriptEnum.version.rawValue + "_",
fileName: script.shFile(),
fileContent: script.scriptToRun()
)
2 changes: 2 additions & 0 deletions Plugins/Shared/ScriptEnum.swift
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@

enum ScriptEnum: String {

case version = "4"

case head = """
#!/usr/bin/env bash
set -euo pipefail
2 changes: 1 addition & 1 deletion Plugins/Shared/scripts/CheckOpenApiValidationScript.swift
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
struct CheckOpenApiValidationScript: ScriptProtocol {

func shFile() -> String {
return "check-openapi-validation"
return "check-openapi-validation.sh"
}

func scriptToRun() -> String {
16 changes: 13 additions & 3 deletions Plugins/Shared/scripts/RunOpenApiServerScript.swift
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
struct RunOpenApiServerScript: ScriptProtocol {

func shFile() -> String {
return "run-openapi-server"
return "run-openapi-server.sh"
}

func scriptToRun() -> String {
@@ -23,10 +23,20 @@ struct RunOpenApiServerScript: ScriptProtocol {
exit 0
fi
NAME="openapi-server"
PORT="8888:80"
while getopts ":n:p:": flag
do
case "${flag}" in
n) NAME=${OPTARG};;
p) PORT=${OPTARG};;
esac
done
# Run the Docker container to serve the OpenAPI files using Nginx
docker run --rm --name "run-openapi-server" \
docker run --rm --name "${NAME}" \
-v "${OPENAPI_YAML_LOCATION}:/usr/share/nginx/html" \
-p 8888:80 nginx
-p ${PORT} nginx
"""
}

17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ This repository contains a set of Swift plugins designed to streamline various t
Add the repository as a dependency:

```swift
.package(url: "https://github.com/BinaryBirds/swift-plugins", from: "0.0.2"),
.package(url: "https://github.com/BinaryBirds/swift-plugins", from: "0.0.4"),
```

Update the packages and you are ready.
@@ -53,12 +53,12 @@ This plugin generates a list of contributors for the repository. It uses the git
Usage: `swift package --disable-sandbox generate-contributors-list`

### InstallSwiftFormatPlugin
This plugin installs the swift-format tool, the version can be optionally defined using the `-v` parameter.
This plugin installs the swift-format tool, the version can be optionally defined using the `-v` parameter. The default version is `510.1.0`.

Usage: `swift package --disable-sandbox install-swift-format`

### InstallSwiftOpenApiGeneratorPlugin
This plugin installs the Swift OpenAPI generator tool, the version can be optionally defined using the `-v` parameter.
This plugin installs the Swift OpenAPI generator tool, the version can be optionally defined using the `-v` parameter. The default version is `1.2.1`.

Usage: `swift package --disable-sandbox install-swift-openapi-generator`

@@ -73,14 +73,19 @@ This plugin cleans up build artifacts and other temporary files from the reposit
Usage: `swift package --disable-sandbox run-clean`

### RunOpenApiServerPlugin
This plugin serves the OpenAPI documentation using an Nginx server.
This plugin serves the OpenAPI documentation using an Nginx server. This try to run inside a Docker container.

Optional parameters:

- `-n` : add a custom identifier for the container, the default is `openapi-server`
- `-p` : add a custom port to bind it to the container, the default is `8888:80`

Usage: `swift package --disable-sandbox run-openapi-server`

### RunSwiftFormatPlugin
This plugin formats Swift code using the swift-format tool. It runs the tool on all Swift files in the repository, optionally fixing some of the issues if the `--fix` argument is provided.
This plugin checks/formats Swift code using the swift-format tool. It runs the tool on all Swift files in the repository, optionally fixing some of the issues if the `--fix` argument is provided.

Usage: `swift package --disable-sandbox run-swift-format` or `swift package--disable-sandbox run-swift-format --fix` for fixing
Usage: `swift package --disable-sandbox run-swift-format` for run lint or `swift package--disable-sandbox run-swift-format --fix` for fixing

## Makefile