Skip to content

Commit 93e4493

Browse files
Merge pull request raycast#3 from unnamedd/Extensions-Collector-Tool
Raycast Toolkit CLI Tool
2 parents 02e7763 + 09e2f12 commit 93e4493

39 files changed

+1805
-2
lines changed

.github/workflows/documentation.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
defaults:
8+
run:
9+
working-directory: Tools/Toolkit
10+
11+
jobs:
12+
generateDocumenation:
13+
runs-on: macos-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- uses: maxim-lobanov/setup-xcode@v1
19+
with:
20+
xcode-version: latest-stable
21+
22+
- name: Build Toolkit
23+
run: |
24+
if [ ! -f "toolkit" ]; then rm toolkit; fi
25+
swift build -c release
26+
ln -s .build/release/toolkit
27+
28+
- name: Generate Script Commands Documentation
29+
run: |
30+
./toolkit generate-documentation ../../
31+
if `git status | grep -q "nothing to commit"`; then
32+
exit 0;
33+
else
34+
git config --local user.email "[email protected]" &&
35+
git config --local user.name "Raycast Bot" &&
36+
git add ../../extensions.md ../../extensions.json &&
37+
git commit -m "Update Script Commands documentation" &&
38+
exit 0;
39+
fi
40+
41+
- name: Push changes
42+
if: success()
43+
uses: ad-m/github-push-action@master
44+
with:
45+
github_token: ${{ secrets.RAYCAST_BOT_ACCESS_TOKEN }}
46+
branch: ${{ github.ref }}

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# General
2-
.DS_Store
1+
.DS_Store
2+
.build
3+
/Packages
4+
*.xcodeproj
5+
xcuserdata/

.swiftlint

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
indentation: 2
2+
included:
3+
- Source
4+
excluded:
5+
- .build
6+
disabled_rules:
7+
- cyclomatic_complexity
8+
- file_length
9+
- line_length
10+
- nesting
11+
- todo # Use custom_todo
12+
- unused_setter_value
13+
- generic_type_name
14+
- identifier_name
15+
- function_parameter_count
16+
- type_name
17+
- function_body_length
18+
- type_body_length
19+
opt_in_rules:
20+
- array_init
21+
- closure_end_indentation
22+
- closure_spacing
23+
- collection_alignment
24+
- empty_collection_literal
25+
- empty_count
26+
- empty_string
27+
- fallthrough
28+
- fatal_error_message
29+
- file_header
30+
- overridden_super_call
31+
- sorted_imports
32+
- unused_declaration
33+
- unused_import
34+
- vertical_whitespace_closing_braces
35+
- vertical_whitespace_opening_braces
36+
- yoda_condition
37+
trailing_comma:
38+
mandatory_comma: true
39+
file_header:
40+
required_pattern: |
41+
\/\/ Copyright © \d{4} Raycast\. All rights reserved\.
42+
identifier_name:
43+
min_length:
44+
error: 3
45+
excluded:
46+
- id
47+
- os

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
This repository contains sample commands and documentation to write your own ones.
88

9+
Check out the [list](extensions.md) of all available Script Commands.
10+
911
## Install Script Commands
1012

1113
To install new commands, follow these steps:

Tools/Toolkit/Package.resolved

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"object": {
3+
"pins": [
4+
{
5+
"package": "swift-argument-parser",
6+
"repositoryURL": "https://github.com/apple/swift-argument-parser.git",
7+
"state": {
8+
"branch": null,
9+
"revision": "92646c0cdbaca076c8d3d0207891785b3379cbff",
10+
"version": "0.3.1"
11+
}
12+
},
13+
{
14+
"package": "swift-tools-support-core",
15+
"repositoryURL": "https://github.com/apple/swift-tools-support-core.git",
16+
"state": {
17+
"branch": null,
18+
"revision": "31747ebaede7e1a1f2b15346790193d5b5e5e7be",
19+
"version": "0.1.11"
20+
}
21+
}
22+
]
23+
},
24+
"version": 1
25+
}

Tools/Toolkit/Package.swift

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// swift-tools-version:5.3
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "toolkit",
7+
platforms: [
8+
.macOS(.v10_14)
9+
],
10+
dependencies: [
11+
.package(
12+
url: "https://github.com/apple/swift-tools-support-core.git",
13+
.upToNextMinor(from: "0.1.11")
14+
),
15+
.package(
16+
url: "https://github.com/apple/swift-argument-parser.git",
17+
.upToNextMinor(from: "0.3.0")
18+
)
19+
],
20+
targets: [
21+
.target(
22+
name: "Toolkit",
23+
dependencies: [
24+
"ToolkitLibrary",
25+
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
26+
.product(name: "ArgumentParser", package: "swift-argument-parser")
27+
]
28+
),
29+
.target(
30+
name: "ToolkitLibrary",
31+
dependencies: [
32+
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core")
33+
]
34+
),
35+
.testTarget(
36+
name: "ToolkitLibraryTests",
37+
dependencies: ["ToolkitLibrary"])
38+
]
39+
)

Tools/Toolkit/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Raycast Toolkit
2+
3+
[Raycast](https://raycast.com) Toolkit helps you to generate documentation for all script commands on a predefined or customized path.
4+
5+
## CLI overview
6+
7+
```shell
8+
OVERVIEW: A tool to generate automatized documentation
9+
10+
USAGE: toolkit [--version] <subcommand>
11+
12+
OPTIONS:
13+
-v, --version Print the version and exit
14+
-h, --help Show help information.
15+
16+
SUBCOMMANDS:
17+
generate-documentation Generate the documentation in JSON and Markdown format
18+
19+
See 'toolkit help <subcommand>' for detailed help.
20+
```
21+
22+
## TO DO
23+
24+
- [ ] Script validator command
25+
- [ ] Create a script command
26+
27+
## Community
28+
29+
This is a shared place and we're always looking for new Script Commands or other ways to improve Raycast. If you have anything cool to show, please send us a pull request. If we screwed something up, please report a bug. Join our [Slack community](https://www.raycast.com/community) to brainstorm ideas with like-minded folks.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// MIT License
3+
// Copyright (c) 2020 Raycast. All rights reserved.
4+
//
5+
6+
import TSCBasic
7+
8+
extension FileSystem {
9+
func absolutePath(for path: String) -> AbsolutePath {
10+
11+
if let path = try? AbsolutePath(validating: path) {
12+
return path
13+
} else if
14+
let path = try? RelativePath(validating: path),
15+
let currentWorkingDirectory = localFileSystem.currentWorkingDirectory {
16+
17+
return AbsolutePath(
18+
path.pathString,
19+
relativeTo: currentWorkingDirectory
20+
)
21+
}
22+
23+
return localFileSystem.homeDirectory.appending(
24+
RelativePath(path)
25+
)
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// MIT License
3+
// Copyright (c) 2020 Raycast. All rights reserved.
4+
//
5+
6+
import ArgumentParser
7+
8+
struct VersionOptions: ParsableArguments {
9+
@Flag(name: .shortAndLong, help: "Print the version and exit")
10+
var version: Bool = false
11+
12+
func validate() throws {
13+
if version {
14+
print("Raycast Toolkit")
15+
print("Current version: 0.1")
16+
throw ExitCode.success
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// MIT License
3+
// Copyright (c) 2020 Raycast. All rights reserved.
4+
//
5+
6+
import ArgumentParser
7+
import ToolkitLibrary
8+
import TSCBasic
9+
10+
extension ToolkitCommand {
11+
12+
struct GenerateDocumentation: ParsableCommand {
13+
14+
static var configuration = CommandConfiguration(
15+
abstract: "Generate the documentation in JSON and Markdown format"
16+
)
17+
18+
@Argument(help: "Path of the Raycast extensions folder. [Default path: ../../]")
19+
var path: String = "../../"
20+
21+
func run() throws {
22+
let fileSystem = TSCBasic.localFileSystem
23+
24+
do {
25+
let toolkit = Toolkit(
26+
path: fileSystem.absolutePath(for: self.path)
27+
)
28+
29+
try toolkit.generateDocumentation()
30+
} catch {
31+
print("Error: \(error)")
32+
}
33+
34+
}
35+
36+
}
37+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// MIT License
3+
// Copyright (c) 2020 Raycast. All rights reserved.
4+
//
5+
6+
import Foundation
7+
8+
import ArgumentParser
9+
import ToolkitLibrary
10+
import TSCBasic
11+
12+
struct ToolkitCommand: ParsableCommand {
13+
14+
static var configuration = CommandConfiguration(
15+
commandName: "toolkit",
16+
abstract: "A tool to generate automatized documentation",
17+
subcommands: [
18+
GenerateDocumentation.self
19+
]
20+
)
21+
22+
@OptionGroup
23+
var versionOptions: VersionOptions
24+
25+
}
26+
27+
ToolkitCommand.main()

0 commit comments

Comments
 (0)