Skip to content

Commit 00b3eda

Browse files
committed
Version 0.3.0
1 parent d46787d commit 00b3eda

File tree

12 files changed

+216
-71
lines changed

12 files changed

+216
-71
lines changed

Archerfile

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ apiLevel: 2
44
repository: https://github.com/vknabel/Archery
55
loaders:
66
- cat Metadata/*.yml
7+
- cat Examples/BashAlias.yml
8+
- cat Examples/TestingOnMultiplePlatforms.yml
79
- swift Scripts/MapSwiftTargetsToScripts.swift --package-path .
810
scripts:
911
greet: echo Hello
10-
clean:
11-
arrow: vknabel/BashArrow
12-
command: rm -rf .archery && swift package clean
13-
printCommandBeforeExecution: true
12+
clean: rm -rf .archery && swift package clean
1413
xcopen: swift package generate-xcodeproj --enable-code-coverage && open *.xcodeproj
1514
format:
1615
arrow: vknabel/BashArrow
@@ -23,27 +22,7 @@ scripts:
2322
arrow: vknabel/MintArrow
2423
help: Lints all project files
2524
package: Realm/Swiftlint
26-
test:
27-
help: Runs tests on your current host system, but also on supported linux versions
28-
run: [host, swift5.0, swift5.1]
29-
scripts:
30-
host: swift test
31-
swift5.0:
32-
env:
33-
SWIFT_VERSION: 5.0
34-
command: |-
35-
export CONTAINER=$(docker create --rm --workdir /archery swift:$SWIFT_VERSION swift test)
36-
docker cp . $CONTAINER:/archery
37-
docker start --attach $CONTAINER
38-
swift5.1:
39-
env:
40-
SWIFT_VERSION: 5.1
41-
command: |-
42-
export CONTAINER=$(docker create --rm --workdir /archery swift:$SWIFT_VERSION swift test)
43-
docker cp . $CONTAINER:/archery
44-
docker start --attach $CONTAINER
4525
generate:
46-
arrow: vknabel/ArcheryArrow
4726
run:
4827
- readme
4928
- version

CHANGELOG.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@
22

33
## 0.3.0
44

5-
* Mint will not be bundled with Archery anymore. Instead always your global version will be used.
6-
* Initial implementation for Archerfile loaders.
5+
- **[Breaking]** Mint will not be bundled with Archery anymore and needs to be installed manually when using legacy Arrows.
6+
- **[Breaking]** Requires Swift 5.
7+
- **[Addition]** Generate new metadata by loaders.
8+
- **[Addition]** Passes custom environment variables to all scripts and arrows: `ARCHERY`, `ARCHERY_METADATA`, `ARCHERY_SCRIPT`, `ARCHERY_API_LEVEL`, `ARCHERY_LEGACY_MINT_PATH`.
9+
- **[Addition]** Scripts can now be run in sequence with just an array literal `do-all: [first, second, third]`
10+
- **[Improvement]** `vknabel/ArcheryArrow` implicitly uses the new scripting API and does not require compilation anymore.
11+
- **[Improvement]** Scripts can now be run in sequence without using `arrow: vknabel/ArcheryArrow`
12+
- **[Improvement]** Bash scripts do not require `arrow: vknabel/BashArrow` anymore.
13+
- **[Improvement]** `vknabel/BashArrow` implicitly uses the new scripting API and does not require compilation anymore.
14+
- **[Deprecation]** The classical `arrow`-script type will be deprecated and will be removed in far future.
15+
16+
### Upcoming Breaking Changes
17+
18+
Previously all scripts were defined as arrow: a separate Swift Package accepting specific arguments, being installed using Mint. This mechanism is now deprecated and will be replaced by plain scripts and environment variables.
19+
20+
Please note the arrow-shorthand syntax `script-name: your/Arrow` deprecated in version 0.2.1 is still available and has not been removed yet.
721

822
## 0.2.1
923

10-
* Bumped internal dependencies
11-
* Correctly passes interrupts
12-
* Shorthand arrow syntax will be migrated to `vknabel/BashArrow` commands
24+
- Bumped internal dependencies
25+
- Correctly passes interrupts
26+
- Shorthand arrow syntax will be migrated to `vknabel/BashArrow` commands
1327

1428
### Upcoming Breaking Change
1529

@@ -20,15 +34,15 @@ All strings containing exactly one `/`, no space and which do not start with a `
2034

2135
```yaml
2236
scripts:
23-
# Deprecated shorthand
24-
example: "vknabel/BeakArrow" # this would run the arrow
25-
# New behavior
26-
format: "swiftformat ." # this would run a `vknabel/BashArrow` command
37+
# Deprecated shorthand
38+
example: "vknabel/BeakArrow" # this would run the arrow
39+
# New behavior
40+
format: "swiftformat ." # this would run a `vknabel/BashArrow` command
2741
```
2842
2943
## 0.2.0
3044
31-
* Archerfile supports YAML
45+
- Archerfile supports YAML
3246
3347
### Archerfile supports YAML
3448
@@ -38,9 +52,9 @@ As the Archerfile should not be read directly, this update won’t break arrows.
3852
3953
## 0.1.1
4054
41-
* Improved error messages
42-
* Improved README.md
55+
- Improved error messages
56+
- Improved README.md
4357
4458
## 0.1.0
4559
46-
* Initial Release
60+
- Initial Release

Examples/BashAlias.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
scripts:
2+
alias:
3+
help: |-
4+
Generates bash aliases for all scripts.
5+
eval $(archery alias)
6+
silent: true
7+
command: |-
8+
echo '
9+
const scripts = JSON.parse(process.env.ARCHERY_METADATA).scripts;
10+
Object.keys(scripts)
11+
.filter(name => name !== "alias")
12+
.forEach(name => {
13+
const command = `${process.env.ARCHERY} ${name}`;
14+
console.log(`function ${name}() { ${command} "$@"; }`);
15+
});' | node
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
scripts:
2+
test:
3+
help: Runs tests on your current host system, but also on supported linux versions
4+
run: [host, swift5.0, swift5.1]
5+
scripts:
6+
host: swift test
7+
swift5.0:
8+
env:
9+
SWIFT_VERSION: 5.0
10+
command: |-
11+
export CONTAINER=$(docker create --rm --workdir /archery swift:$SWIFT_VERSION swift test)
12+
docker cp . $CONTAINER:/archery
13+
docker start --attach $CONTAINER
14+
swift5.1:
15+
env:
16+
SWIFT_VERSION: 5.1
17+
command: |-
18+
export CONTAINER=$(docker create --rm --workdir /archery swift:$SWIFT_VERSION swift test)
19+
docker cp . $CONTAINER:/archery
20+
docker start --attach $CONTAINER

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# 🏹 Archery
22

3-
[![Join the chat at https://gitter.im/vknabel-Archery/Lobby](https://badges.gitter.im/vknabel-Archery/Lobby.svg)](https://gitter.im/vknabel-Archery/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
53
*Archery* allows you to declare all your project's metadata and what you can do with it in one single place.
4+
All fueled with the power of scripting.
65

7-
Within Archery all your data is centralized as YAML in one file called `Archerfile`, which will be passed to arrows as JSON. The whole content of that file is treated as metadata. Within `scripts` you declare whatever you want to run.
6+
Within Archery all your data is either declared as YAML in one file called `Archerfile` or generated by scripts, which will be passed to arrows as JSON.
7+
The whole content of that file is treated as metadata. Within `scripts` you declare whatever you want to run, `loaders` is there to generate additional metadata.
88

99
The following code shows how an Archerfile may look like. Besides the name and version of the project, it declares two scripts:
10+
1011
```yaml
1112
name: YourProject
1213
help: Thanks for downloading this project and trying it out.
1314
version: 1.0.0
15+
loaders:
16+
- cat Metadata/*.yml
1417
scripts:
1518
xcproj: swift package generate-xcodeproj
1619
generate-version:
@@ -21,6 +24,7 @@ scripts:
2124
searchPaths: [Scripts]
2225

2326
```
27+
2428
* `$ archery xcproj` will use [Mint](https://github.com/yonaskolb/Mint) to load [vknabel/BashArrow](https://github.com/vknabel/BashArrow), which executes a given command. Whenever you want to run simple scripts on the command line which do not require global installs, this is an universal way to go.
2529
* `$ archery generate-version` is based on [vknabel/StencilArrow](https://github.com/vknabel/StencilArrow). It will pass all contents of the Archerfile to render the contents of `Version.swift.stencil` using the [Stencil](https://github.com/kylef/Stencil) language. Whenever you need information of your Archerfile inside other files, this way should be the most convenient.
2630

@@ -39,6 +43,7 @@ Available Commands:
3943
No matter which arrow you will choose for your scripts: it comes with all dependencies it needs. No need for any additional commands.
4044

4145
## Scripts
46+
4247
The script tag at root level drives the available subcommands and is interpreted as Array of scripts.
4348

4449
| Option | Default | Description |
@@ -67,16 +72,19 @@ Now you can add all your metadata and scripts. Don't know where to start? Here a
6772

6873

6974
### Using Mint
75+
7076
```bash
7177
$ mint run vknabel/Archery
7278
```
7379

7480
### Using Marathon
81+
7582
```bash
7683
$ marathon run vknabel/archery
7784
```
7885

7986
### Swift Package Manager
87+
8088
```bash
8189
$ git clone https://github.com/vknabel/Archery.git
8290
$ cd Archery
@@ -86,7 +94,21 @@ $ cp -f .build/release/archery /usr/local/bin/archery
8694

8795
Archery can also be embedded within your own CLI using SwiftPM.
8896

89-
## Available Arrows
97+
## Environment Variables
98+
99+
Archery passes the following environment variables to each script including loaders.
100+
101+
| Name | Description | Example use case |
102+
| -------------------------- | ----------------------------------- | --------------------------------------------- |
103+
| `ARCHERY` | Path to the archery executable. | To run child processes `$ARCHERY script-name` |
104+
| `ARCHERY_METADATA` | JSON contents of all metadata. | Parse metadata in your scripts. |
105+
| `ARCHERY_SCRIPT` | JSON contents of the script config. | Parse config in your scripts. |
106+
| `ARCHERY_API_LEVEL` | Number of the API level. | To improve backwards compatibility. |
107+
| `ARCHERY_LEGACY_MINT_PATH` | Path to the mint driver. | In case your script relies on mint. |
108+
109+
110+
## Available Legacy Arrows
111+
90112
Currently the following arrows are known. Feel free to add your own arrows. If you want to write your own arrow head over to [vknabel/ArrowKit](https://github.com/vknabel/ArrowKit/blob/master/README.md) and feel free to add to add your own arrow here.
91113

92114
### Archery
@@ -135,9 +157,6 @@ Currently the following arrows are known. Feel free to add your own arrows. If y
135157
## Development Status
136158
As Archery is still in early development I want every user to know as early as possible what may actually change or break in future. This project uses semantic versioning. Version 1.0.0 will be released when known bugs are fixed, all major features have been implemented and upcoming one can be implemented without breaking changes. Additional requirements are a good documentation and good error messages. Until 1.0 has been reached minor updates may break, but patches will stay patches and hence safe for updates.
137159

138-
### Archerfile Loaders
139-
In bigger projects the `Archerfile` may get huge when used regularly. Later it shall be possible to extract some JSON values into external files and even other scripts. As the `Archerfile` should not be read directly, this update won’t break arrows.
140-
141160
## Contributors
142161
* Valentin Knabel, [@vknabel](https://github.com/vknabel), [email protected], [@vknabel](https://twitter.com/vknabel) on Twitter
143162

Scripts/MapSwiftTargetsToScripts.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,9 @@ let package = try decoder.decode(PackageDump.self, from: output.fileHandleForRea
4848

4949
print("scripts:")
5050
for product in package.products where product.isExecutable {
51-
print(" \(product.name): 'swift run --package-path \(packagePath) \(product.name) $@'")
51+
print("""
52+
\(product.name):
53+
command: 'swift run --package-path \(packagePath) \(product.name) $@'
54+
help: 'Runs \(product.name) using the swift package manager'
55+
""")
5256
}

Scripts/README.md.stencil

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# 🏹 Archery
22

3-
[![Join the chat at https://gitter.im/vknabel-Archery/Lobby](https://badges.gitter.im/vknabel-Archery/Lobby.svg)](https://gitter.im/vknabel-Archery/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
53
*Archery* allows you to declare all your project's metadata and what you can do with it in one single place.
4+
All fueled with the power of scripting.
65

7-
Within Archery all your data is centralized as YAML in one file called `Archerfile`, which will be passed to arrows as JSON. The whole content of that file is treated as metadata. Within `scripts` you declare whatever you want to run.
6+
Within Archery all your data is either declared as YAML in one file called `Archerfile` or generated by scripts, which will be passed to arrows as JSON.
7+
The whole content of that file is treated as metadata. Within `scripts` you declare whatever you want to run, `loaders` is there to generate additional metadata.
88

99
The following code shows how an Archerfile may look like. Besides the name and version of the project, it declares two scripts:
10+
1011
```yaml
1112
name: YourProject
1213
help: Thanks for downloading this project and trying it out.
1314
version: 1.0.0
15+
loaders:
16+
- cat Metadata/*.yml
1417
scripts:
1518
xcproj: swift package generate-xcodeproj
1619
generate-version:
@@ -21,6 +24,7 @@ scripts:
2124
searchPaths: [Scripts]
2225

2326
```
27+
2428
* `$ archery xcproj` will use [Mint](https://github.com/yonaskolb/Mint) to load [vknabel/BashArrow](https://github.com/vknabel/BashArrow), which executes a given command. Whenever you want to run simple scripts on the command line which do not require global installs, this is an universal way to go.
2529
* `$ archery generate-version` is based on [vknabel/StencilArrow](https://github.com/vknabel/StencilArrow). It will pass all contents of the Archerfile to render the contents of `Version.swift.stencil` using the [Stencil](https://github.com/kylef/Stencil) language. Whenever you need information of your Archerfile inside other files, this way should be the most convenient.
2630

@@ -39,6 +43,7 @@ Available Commands:
3943
No matter which arrow you will choose for your scripts: it comes with all dependencies it needs. No need for any additional commands.
4044

4145
## Scripts
46+
4247
The script tag at root level drives the available subcommands and is interpreted as Array of scripts.
4348

4449
| Option | Default | Description |
@@ -73,16 +78,19 @@ $ brew install archery
7378
#}
7479

7580
### Using Mint
81+
7682
```bash
7783
$ mint run vknabel/Archery
7884
```
7985

8086
### Using Marathon
87+
8188
```bash
8289
$ marathon run vknabel/archery
8390
```
8491

8592
### Swift Package Manager
93+
8694
```bash
8795
$ git clone {{repository}}.git
8896
$ cd Archery
@@ -92,7 +100,21 @@ $ cp -f .build/release/archery /usr/local/bin/archery
92100

93101
Archery can also be embedded within your own CLI using SwiftPM.
94102

95-
## Available Arrows
103+
## Environment Variables
104+
105+
Archery passes the following environment variables to each script including loaders.
106+
107+
| Name | Description | Example use case |
108+
| -------------------------- | ----------------------------------- | --------------------------------------------- |
109+
| `ARCHERY` | Path to the archery executable. | To run child processes `$ARCHERY script-name` |
110+
| `ARCHERY_METADATA` | JSON contents of all metadata. | Parse metadata in your scripts. |
111+
| `ARCHERY_SCRIPT` | JSON contents of the script config. | Parse config in your scripts. |
112+
| `ARCHERY_API_LEVEL` | Number of the API level. | To improve backwards compatibility. |
113+
| `ARCHERY_LEGACY_MINT_PATH` | Path to the mint driver. | In case your script relies on mint. |
114+
115+
116+
## Available Legacy Arrows
117+
96118
Currently the following arrows are known. Feel free to add your own arrows. If you want to write your own arrow head over to [vknabel/ArrowKit](https://github.com/vknabel/ArrowKit/blob/master/README.md) and feel free to add to add your own arrow here.
97119

98120
{% for arrow in publicArrows %}### {{arrow.name}}
@@ -106,9 +128,6 @@ Currently the following arrows are known. Feel free to add your own arrows. If y
106128
## Development Status
107129
As Archery is still in early development I want every user to know as early as possible what may actually change or break in future. This project uses semantic versioning. Version 1.0.0 will be released when known bugs are fixed, all major features have been implemented and upcoming one can be implemented without breaking changes. Additional requirements are a good documentation and good error messages. Until 1.0 has been reached minor updates may break, but patches will stay patches and hence safe for updates.
108130

109-
### Archerfile Loaders
110-
In bigger projects the `Archerfile` may get huge when used regularly. Later it shall be possible to extract some JSON values into external files and even other scripts. As the `Archerfile` should not be read directly, this update won’t break arrows.
111-
112131
## Contributors
113132
{% for user in contributors %}* {{user.name}}, [@{{user.github}}](https://github.com/{{user.github}}){% if user.email %}, {{user.email}}{% endif %}{% if user.twitter %}, [@{{user.twitter}}](https://twitter.com/{{user.twitter}}) on Twitter{% endif %}
114133
{% endfor %}

Sources/ArcheryKit/ExecutionContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct ExecutionContext {
3535
func run(_ script: LabeledScript, using archerfile: Archerfile, with arguments: [String]) throws {
3636
let processes = try makeProcesses(script, using: archerfile, with: arguments, parentScripts: [:])
3737
for (label, process) in processes {
38-
if !silent {
38+
if !silent && !arguments.contains("--silent") && !(script.script.silent ?? false) {
3939
print("🏹 Running \(label.joined(separator: " ▶︎ "))")
4040
}
4141

Sources/ArcheryKit/Script.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ public struct Script: Codable, OfferingMetadata {
33
public var help: String?
44
public var env: [String: String]?
55
public var workingDirectory: String?
6+
public var silent: Bool?
67

78
public var metadata: Metadata
89

@@ -12,6 +13,7 @@ public struct Script: Codable, OfferingMetadata {
1213
let details = try? ExecutionDetailsSyntax(from: decoder)
1314
help = details?.help
1415
env = details?.env
16+
silent = details?.silent
1517

1618
metadata = try Metadata(from: decoder)
1719
.replacing(using: execution.metadata)
@@ -24,5 +26,6 @@ public struct Script: Codable, OfferingMetadata {
2426
private struct ExecutionDetailsSyntax: Codable {
2527
var help: String?
2628
var env: [String: String]?
29+
var silent: Bool?
2730
}
2831
}

0 commit comments

Comments
 (0)