Skip to content

Commit

Permalink
Merge pull request #2 from bitwit/powered-by-marathon
Browse files Browse the repository at this point in the history
Slurp CLI, Marathon as a dependency
  • Loading branch information
bitwit authored Nov 14, 2018
2 parents c4d46f6 + 120b948 commit 6c588f6
Show file tree
Hide file tree
Showing 35 changed files with 9,214 additions and 2,847 deletions.
7 changes: 5 additions & 2 deletions .gitignore
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
44 changes: 25 additions & 19 deletions ExampleTasks/SlurpTasks/main.swift
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")

12 changes: 12 additions & 0 deletions Makefile
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
81 changes: 81 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
{
"object": {
"pins": [
{
"package": "Files",
"repositoryURL": "https://github.com/JohnSundell/Files.git",
"state": {
"branch": null,
"revision": "06f95bd1bf4f8d5f50bc6bb30b808c253acd4c88",
"version": "2.2.1"
}
},
{
"package": "Guaka",
"repositoryURL": "https://github.com/nsomar/Guaka.git",
"state": {
"branch": null,
"revision": "9dfb2ea95b8ab9e799d0f65a79a2316679a758e0",
"version": "0.1.3"
}
},
{
"package": "Marathon",
"repositoryURL": "https://github.com/bitwit/Marathon.git",
"state": {
"branch": "slurp-0.1.0",
"revision": "cadda85857dfa24947b03e00d703b95ea9609ef4",
"version": null
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
Expand Down Expand Up @@ -28,6 +55,24 @@
"version": "1.2.0"
}
},
{
"package": "Releases",
"repositoryURL": "https://github.com/JohnSundell/Releases.git",
"state": {
"branch": null,
"revision": "e74f0895855b56147cb96f2d45aba3ec37da64fb",
"version": "3.0.0"
}
},
{
"package": "Require",
"repositoryURL": "https://github.com/JohnSundell/Require.git",
"state": {
"branch": null,
"revision": "7cfbd0d8a2dede0e01f6f0d8ab2c7acef1df112e",
"version": "2.0.1"
}
},
{
"package": "RxSwift",
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
Expand All @@ -37,6 +82,15 @@
"version": "4.1.2"
}
},
{
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "f1c253a34a40df4bfd268b09fdb101b059f6d52d",
"version": "2.1.0"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
Expand All @@ -45,6 +99,33 @@
"revision": "e34d5687e1e9d865e3527dd58bc2f7464ef6d936",
"version": "0.8.0"
}
},
{
"package": "StringScanner",
"repositoryURL": "https://github.com/oarrabi/StringScanner",
"state": {
"branch": null,
"revision": "246c697efe2f57d9042f58b1b53ace4fddb1efc4",
"version": "0.2.0"
}
},
{
"package": "Unbox",
"repositoryURL": "https://github.com/JohnSundell/Unbox.git",
"state": {
"branch": null,
"revision": "e084f13aea85495b07d015e893845e097a5eaeb4",
"version": "3.0.0"
}
},
{
"package": "Wrap",
"repositoryURL": "https://github.com/JohnSundell/Wrap.git",
"state": {
"branch": null,
"revision": "8085c925060b84a1fc0caef444c130da2c8154c3",
"version": "3.0.1"
}
}
]
},
Expand Down
18 changes: 11 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
// swift-tools-version:4.0
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Slurp",
products: [
.library(name: "Slurp", targets: ["Slurp"]),
.library(name: "SlurpXCTools", targets: ["SlurpXCTools"])
],
.library(name: "Slurp", targets: ["Slurp"]),
.library(name: "SlurpXCTools", targets: ["SlurpXCTools"])
],
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift.git", .exact(.init(4, 1, 2))),
.package(url: "https://github.com/kylef/PathKit.git", .exact(.init(0, 9, 0))),
.package(url: "https://github.com/bitwit/Marathon.git", .branch("slurp-0.1.0")),
.package(url: "https://github.com/nsomar/Guaka.git", .exact(.init(0, 1, 3))),

// Testing
.package(url: "https://github.com/Quick/Quick.git", .exact(.init(1, 2, 0))),
.package(url: "https://github.com/Quick/Nimble.git", .exact(.init(7, 0, 3)))
],
targets: [
.target(
name: "SlurpCLI",
dependencies: ["MarathonCore", "Guaka", "Slurp"]),
.target(
name: "Slurp",
dependencies: ["RxSwift", "PathKit"]),
dependencies: ["RxSwift", "PathKit", "MarathonCore"]),
.target(
name: "SlurpXCTools",
dependencies: ["Slurp", "RxSwift", "PathKit"]),
Expand All @@ -32,9 +37,8 @@ let package = Package(

// Example
.target(
name: "SlurpTasks",
name: "ExampleSlurpTasks",
dependencies: ["Slurp", "SlurpXCTools"],
path: "ExampleTasks")

]
)
66 changes: 32 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions Slurp.xcodeproj/Guaka_Info.plist
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>
25 changes: 25 additions & 0 deletions Slurp.xcodeproj/MarathonCore_Info.plist
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>
Loading

0 comments on commit 6c588f6

Please sign in to comment.