diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3f9c301 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +TOOL_NAME = dh-state-machine-generate +FORMULA_NAME = dh-state-machine-generate-test +VERSION = $(shell git describe --abbrev=0 --tags) + +PREFIX = /usr/local +INSTALL_PATH = $(PREFIX)/bin/$(TOOL_NAME) +SHARE_PATH = $(PREFIX)/share/$(TOOL_NAME) +BUILD_PATH = .build/release/$(TOOL_NAME) +CURRENT_PATH = $(PWD) +REPO = https://github.com/WalterWong94/$(TOOL_NAME) +RELEASE_TAR = $(REPO)/archive/$(VERSION).tar.gz +SHA = $(shell curl -L -s $(RELEASE_TAR) | shasum -a 256 | sed 's/ .*//') + +build: + swift build --disable-sandbox -c release + +install: build + mkdir -p $(PREFIX)/bin + cp -f $(BUILD_PATH) $(INSTALL_PATH) + +uninstall: + rm -f $(INSTALL_PATH) + +format: + swiftformat . + +update_brew: + sed -i '' 's|\(url ".*/archive/\)\(.*\)\(.tar\)|\1$(VERSION)\3|' Formula/$(FORMULA_NAME).rb + sed -i '' 's|\(sha256 "\)\(.*\)\("\)|\1$(SHA)\3|' Formula/$(FORMULA_NAME).rb + + git add Formula/* + git commit -m "Update brew to $(VERSION)" \ No newline at end of file diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..1665c5d --- /dev/null +++ b/Package.resolved @@ -0,0 +1,25 @@ +{ + "object": { + "pins": [ + { + "package": "swift-argument-parser", + "repositoryURL": "https://github.com/apple/swift-argument-parser", + "state": { + "branch": null, + "revision": "6b2aa2748a7881eebb9f84fb10c01293e15b52ca", + "version": "0.5.0" + } + }, + { + "package": "SwiftFormat", + "repositoryURL": "https://github.com/nicklockwood/SwiftFormat", + "state": { + "branch": null, + "revision": "a9bdfd2548ebe518a693a5c6341d27c42b7e7a0a", + "version": "0.48.11" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..02b57f4 --- /dev/null +++ b/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "StateMachineGenerator", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .executable(name: "dh-state-machine-generate", targets: ["StateMachineGenerator"]) + ], + dependencies: [ + .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.41.2"), + .package(url: "https://github.com/apple/swift-argument-parser", from: "0.3.0") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "StateMachineGenerator", + dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser")]), + .testTarget( + name: "StateMachineGeneratorTests", + dependencies: ["StateMachineGenerator"]), + ] +) diff --git a/Sources/StateMachineGenerator/main.swift b/Sources/StateMachineGenerator/main.swift new file mode 100644 index 0000000..5d8929c --- /dev/null +++ b/Sources/StateMachineGenerator/main.swift @@ -0,0 +1,21 @@ +// +// File.swift +// +// +// Created by Walter Wong on 27/9/21. +// + +import ArgumentParser +import Foundation + +StateMachineGenerator.main() + +struct StateMachineGenerator: ParsableCommand { + static var configuration = CommandConfiguration( + commandName: "dh-state-machine-generate" + ) + + func run() throws { + + } +} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..c9d69c8 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import StateMachineGeneratorTests + +var tests = [XCTestCaseEntry]() +tests += StateMachineGeneratorTests.allTests() +XCTMain(tests) diff --git a/Tests/StateMachineGeneratorTests/StateMachineGeneratorTests.swift b/Tests/StateMachineGeneratorTests/StateMachineGeneratorTests.swift new file mode 100644 index 0000000..f5bb8fb --- /dev/null +++ b/Tests/StateMachineGeneratorTests/StateMachineGeneratorTests.swift @@ -0,0 +1,15 @@ +import XCTest +@testable import StateMachineGenerator + +final class StateMachineGeneratorTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(StateMachineGenerator().text, "Hello, World!") + } + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/Tests/StateMachineGeneratorTests/XCTestManifests.swift b/Tests/StateMachineGeneratorTests/XCTestManifests.swift new file mode 100644 index 0000000..eecf252 --- /dev/null +++ b/Tests/StateMachineGeneratorTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(StateMachineGeneratorTests.allTests), + ] +} +#endif