-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from bitwit/powered-by-marathon
Slurp CLI, Marathon as a dependency
- Loading branch information
Showing
35 changed files
with
9,214 additions
and
2,847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
.DS_Store | ||
/.build | ||
.build | ||
build | ||
/Packages | ||
/Scripts | ||
**/xcuserdata/** | ||
build | ||
|
||
Slurp | ||
|
||
example.xcarchive | ||
example.ipa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
import Foundation | ||
import Slurp | ||
import SlurpXCTools | ||
import MarathonCore | ||
|
||
// Slurp.currentWorkingDirectory = "/path/to/cwd" | ||
|
||
let xcBuildConfig = XcodeBuild.Config( | ||
scheme: "SlurpExampleApp", | ||
archivePath: "example.xcarchive", | ||
exportPath: "example.ipa", | ||
exportOptionsPlist: "ExportOptions.plist" | ||
) | ||
|
||
let uploadConfig = ApplicationLoader.Config( | ||
file: "example.ipa/SlurpExampleApp.ipa", | ||
username: "", | ||
password: "" | ||
) | ||
// Slurp.currentWorkingDirectory = "/path/to/cwd" | ||
|
||
//let xcBuildConfig = XcodeBuild.Config( | ||
// scheme: "SlurpExampleApp", | ||
// archivePath: "example.xcarchive", | ||
// exportPath: "example.ipa", | ||
// exportOptionsPlist: "ExportOptions.plist" | ||
//) | ||
// | ||
//let uploadConfig = ApplicationLoader.Config( | ||
// file: "example.ipa/SlurpExampleApp.ipa", | ||
// username: "", | ||
// password: "" | ||
//) | ||
// | ||
let slurp = Slurp() | ||
slurp | ||
.register("buildAndDeploy") { | ||
.register("test") { | ||
return slurp | ||
|> Version(.incrementBuildNumber, all: true) | ||
|> Version(.setMarketingVersion("1.0.1"), all: true) | ||
|> XcodeBuild([.archive, .export], config: xcBuildConfig) | ||
|> ApplicationLoader(.uploadApp, config: uploadConfig) | ||
|> CWD("~/Development/personal/Slurp") | ||
|> Shell(.createFile(named: "testing.cool", contents: "cool")) | ||
|> Shell(.removeFile(from: "testing.cool")) | ||
// |> Version(.incrementBuildNumber, all: true) | ||
// |> Version(.setMarketingVersion("1.0.1"), all: true) | ||
// |> XcodeBuild([.archive, .export], config: xcBuildConfig) | ||
// |> ApplicationLoader(.uploadApp, config: uploadConfig) | ||
} | ||
|
||
try! slurp.runAndExit(taskName: "buildAndDeploy") | ||
try! slurp.runAndExit(taskName: "test") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
install: | ||
# Update and build | ||
swift package update | ||
swift build -c release --product SlurpCLI | ||
# Move repo for local referencing | ||
mkdir -p ~/.slurp/ | ||
rm -rf ~/.slurp/clone | ||
cp -R ./ ~/.slurp/clone | ||
# Copy over bin file | ||
rm /usr/local/bin/slurp | ||
cp -f .build/release/SlurpCLI /usr/local/bin/slurp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
[![Releases](https://img.shields.io/github/tag/bitwit/slurp.svg)](https://github.com/bitwit/Slurp/releases) | ||
|
||
|
||
A Swift task runner and file watcher with an interface inspired by Gulp.js. Run it from your command line or inside of Xcode | ||
A Swift task runner and file watcher that you can run from your Xcode Workspace or the ommand line. Comes with everything you need to build and deploy an iOS app just by running an XCode Scheme. | ||
Inspired by Gulp.js. | ||
|
||
## Contents | ||
- [Intended Uses](#intended-uses) | ||
|
@@ -62,27 +63,20 @@ RunLoop.main.run() // Keep the task running indefinitely | |
``` | ||
|
||
## Installation | ||
Add Slurp to your `package.swift` and create a new executable `Tasks` module with Slurp as a dependency. You may also need `SlurpXCTools` for Xcode related Tasks. | ||
A basic `package.swift` might look like this: | ||
|
||
```swift | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "MyApp", | ||
products: [], | ||
dependencies: [ | ||
.package(url: "https://github.com/bitwit/Slurp.git", .exact(.init(0, 0, 1))), | ||
], | ||
targets: [ | ||
.target( | ||
name: "Tasks", | ||
dependencies: ["Slurp", "SlurpXCTools"]) | ||
] | ||
) | ||
``` | ||
1. `$ git clone [email protected]:bitwit/Slurp.git` | ||
2. `$ cd Slurp && make` | ||
3. The Slurp CLI will now be installed and the repo copied to `~/.slurp/clone` for local reference in your projects | ||
|
||
## Adding Slurp to your project | ||
In the root of the project: | ||
1. `$ slurp init`. This will create a new SlurpTasks package in `<project root>/Slurp`. | ||
2. `$ slurp edit` will open the the SlurpTasks Xcode project, but you can also add this project to your regular Workspace. | ||
3. `$ slurp` will run your SlurpTasks executable | ||
|
||
## Your first slurp task | ||
|
||
A basic `Sources/Tasks/main.swift` file would look like: | ||
A basic `Sources/SlurpTasks/main.swift` file would look like: | ||
|
||
```swift | ||
import Slurp | ||
|
@@ -94,25 +88,29 @@ slurp.register("sayHello", Shell(arguments: ["echo", "hello world"])) | |
try! slurp.runAndExit(taskName: "sayHello") | ||
``` | ||
|
||
From the command line you can now execute: | ||
### Developing and Running in Xcode | ||
|
||
```sh | ||
$ swift run Tasks | ||
``` | ||
When you run your Tasks from XCode it will execute from the build folder. To get around this there are several ways to set the current working directly correctly: | ||
|
||
1. Set it at the top of your main.swift | ||
|
||
### Developing and Running in Xcode | ||
Start by setting up a workspace. Then run | ||
|
||
```sh | ||
$ swift package generate-xcodeproj --output myTasks.xcodeproj | ||
``` | ||
> **Note**: By default the xcodeproj file name is your Package name i.e. "MyApp.xcodeproj". Keep this generated xcodeproj separate from your main XCode target app so that can can rerun this command if necessary | ||
Include this xcodeproj in your workspace. There should now be a scheme you can run to execute your task. You may need set your current working directory in order for this to run processes from the right folder. | ||
|
||
```swift | ||
Slurp.currentWorkingDirectory = "/path/to/app" | ||
``` | ||
2. Pass it as an environment variable | ||
|
||
`$ SLURP_CWD=/path/to/app slurp` | ||
|
||
3. Change it at any point in the task flow | ||
```swift | ||
slurp | ||
.register("example") { | ||
return slurp | ||
|> CWD("~/Development/personal/Slurp") | ||
|> ... | ||
} | ||
``` | ||
|
||
> **Note**: You can pass this as an environment variable too through `SLURP_CWD`. This can be set in your task scheme's configuration | ||
This git repo contains an xcworkspace and example app that mimic this suggested structure. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.