Skip to content

Commit badf781

Browse files
committed
Initial project template
1 parent b6dfab9 commit badf781

12 files changed

Lines changed: 426 additions & 0 deletions

File tree

cookiecutter.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "project",
3+
"swift_version": "5.7",
4+
"package_version": "1.0.0",
5+
"ios": [
6+
"Yes",
7+
"No"
8+
],
9+
"macOS": [
10+
"Yes",
11+
"No"
12+
],
13+
"watchOS": [
14+
"Yes",
15+
"No"
16+
],
17+
"tvOS": [
18+
"Yes",
19+
"No"
20+
]
21+
}

hooks/post_gen_project.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
swift package init --name {{ cookiecutter.name }} --type library
4+
5+
make bootstrap
6+
make fmt
7+
8+
git init
9+
git add .
10+
git commit -m "Initial commit"
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#{% raw %}
2+
name: "{{ cookiecutter.name | lower }}"
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
pull_request:
10+
paths:
11+
- '.swiftlint.yml'
12+
branches:
13+
- main
14+
- dev
15+
16+
concurrency:
17+
group: ci
18+
cancel-in-progress: true
19+
20+
jobs:
21+
SwiftLint:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: GitHub Action for SwiftLint
26+
uses: norio-nomura/action-swiftlint@3.2.1
27+
with:
28+
args: --strict
29+
env:
30+
DIFF_BASE: ${{ github.base_ref }}
31+
Latest:
32+
name: Test Latest (iOS, macOS, tvOS, watchOS)
33+
runs-on: macOS-12
34+
env:
35+
DEVELOPER_DIR: "/Applications/Xcode_14.1.app/Contents/Developer"
36+
timeout-minutes: 10
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
include:
41+
{% if cookiecutter.ios == "Yes" %}
42+
- destination: "OS=16.1,name=iPhone 14 Pro"
43+
name: "iOS"
44+
scheme: "{{ cookiecutter.name }}"
45+
sdk: iphonesimulator
46+
{% endif %}
47+
{% if cookiecutter.tvOS == "Yes" %}
48+
- destination: "OS=16.1,name=Apple TV"
49+
name: "tvOS"
50+
scheme: "{{ cookiecutter.name }}"
51+
sdk: appletvsimulator
52+
{% endif %}
53+
{% if cookiecutter.watchOS == "Yes" %}
54+
- destination: "OS=9.1,name=Apple Watch Series 8 (45mm)"
55+
name: "watchOS"
56+
scheme: "{{ cookiecutter.name }}"
57+
sdk: watchsimulator
58+
{% endif %}
59+
{% if cookiecutter.macOS == "Yes" %}
60+
- destination: "platform=macOS"
61+
name: "macOS"
62+
scheme: "{{ cookiecutter.name }}"
63+
sdk: macosx
64+
{% endif %}
65+
steps:
66+
- uses: actions/checkout@v3
67+
- name: ${{ matrix.name }}
68+
run: xcodebuild test -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "./${{ matrix.sdk }}.xcresult" | xcpretty -r junit
69+
- name: Upload coverage reports to Codecov
70+
uses: codecov/codecov-action@v3.1.0
71+
with:
72+
token: ${{ secrets.CODECOV_TOKEN }}
73+
xcode: true
74+
xcode_archive_path: "./${{ matrix.sdk }}.xcresult"
75+
#{% endraw %}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Stream rules
2+
3+
--swiftversion 5.3
4+
5+
# Use 'swiftformat --options' to list all of the possible options
6+
7+
--header "\n{{ cookiecutter.name }}\nCopyright © {created.year} Space Code. All rights reserved.\n//"
8+
9+
--enable blankLinesBetweenScopes
10+
--enable blankLinesAtStartOfScope
11+
--enable blankLinesAtEndOfScope
12+
--enable blankLinesAroundMark
13+
--enable anyObjectProtocol
14+
--enable consecutiveBlankLines
15+
--enable consecutiveSpaces
16+
--enable duplicateImports
17+
--enable elseOnSameLine
18+
--enable emptyBraces
19+
--enable initCoderUnavailable
20+
--enable leadingDelimiters
21+
--enable numberFormatting
22+
--enable preferKeyPath
23+
--enable redundantBreak
24+
--enable redundantExtensionACL
25+
--enable redundantFileprivate
26+
--enable redundantGet
27+
--enable redundantInit
28+
--enable redundantLet
29+
--enable redundantLetError
30+
--enable redundantNilInit
31+
--enable redundantObjc
32+
--enable redundantParens
33+
--enable redundantPattern
34+
--enable redundantRawValues
35+
--enable redundantReturn
36+
--enable redundantSelf
37+
--enable redundantVoidReturnType
38+
--enable semicolons
39+
--enable sortedImports
40+
--enable sortedSwitchCases
41+
--enable spaceAroundBraces
42+
--enable spaceAroundBrackets
43+
--enable spaceAroundComments
44+
--enable spaceAroundGenerics
45+
--enable spaceAroundOperators
46+
--enable spaceInsideBraces
47+
--enable spaceInsideBrackets
48+
--enable spaceInsideComments
49+
--enable spaceInsideGenerics
50+
--enable spaceInsideParens
51+
--enable strongOutlets
52+
--enable strongifiedSelf
53+
--enable todos
54+
--enable trailingClosures
55+
--enable unusedArguments
56+
--enable void
57+
--enable markTypes
58+
--enable isEmpty
59+
60+
# format options
61+
62+
--wraparguments before-first
63+
--wrapcollections before-first
64+
--maxwidth 140
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
excluded:
2+
- Tests
3+
- Package.swift
4+
- .build
5+
6+
# Rules
7+
8+
disabled_rules:
9+
- trailing_comma
10+
- todo
11+
- opening_brace
12+
13+
opt_in_rules: # some rules are only opt-in
14+
- anyobject_protocol
15+
- array_init
16+
- attributes
17+
- closure_body_length
18+
- closure_end_indentation
19+
- closure_spacing
20+
- collection_alignment
21+
- conditional_returns_on_newline
22+
- contains_over_filter_count
23+
- contains_over_filter_is_empty
24+
- contains_over_first_not_nil
25+
- contains_over_range_nil_comparison
26+
- convenience_type
27+
- discouraged_object_literal
28+
- discouraged_optional_boolean
29+
- empty_collection_literal
30+
- empty_count
31+
- empty_string
32+
- empty_xctest_method
33+
- enum_case_associated_values_count
34+
- explicit_init
35+
- fallthrough
36+
- fatal_error_message
37+
- file_name
38+
- file_types_order
39+
- first_where
40+
- flatmap_over_map_reduce
41+
- force_unwrapping
42+
- ibinspectable_in_extension
43+
- identical_operands
44+
- implicit_return
45+
- inert_defer
46+
- joined_default_parameter
47+
- last_where
48+
- legacy_multiple
49+
- legacy_random
50+
- literal_expression_end_indentation
51+
- lower_acl_than_parent
52+
- multiline_arguments
53+
- multiline_function_chains
54+
- multiline_literal_brackets
55+
- multiline_parameters
56+
- multiline_parameters_brackets
57+
- no_space_in_method_call
58+
- operator_usage_whitespace
59+
- optional_enum_case_matching
60+
- orphaned_doc_comment
61+
- overridden_super_call
62+
- override_in_extension
63+
- pattern_matching_keywords
64+
- prefer_self_type_over_type_of_self
65+
- prefer_zero_over_explicit_init
66+
- prefixed_toplevel_constant
67+
- private_action
68+
- prohibited_super_call
69+
- quick_discouraged_call
70+
- quick_discouraged_focused_test
71+
- quick_discouraged_pending_test
72+
- reduce_into
73+
- redundant_nil_coalescing
74+
- redundant_objc_attribute
75+
- redundant_type_annotation
76+
- required_enum_case
77+
- single_test_class
78+
- sorted_first_last
79+
- sorted_imports
80+
- static_operator
81+
- strict_fileprivate
82+
- switch_case_on_newline
83+
- toggle_bool
84+
- unavailable_function
85+
- unneeded_parentheses_in_closure_argument
86+
- unowned_variable_capture
87+
- untyped_error_in_catch
88+
- vertical_parameter_alignment_on_call
89+
- vertical_whitespace_closing_braces
90+
- vertical_whitespace_opening_braces
91+
- xct_specific_matcher
92+
- yoda_condition
93+
94+
force_cast: warning
95+
force_try: warning
96+
97+
identifier_name:
98+
excluded:
99+
- id
100+
- URL
101+
102+
analyzer_rules:
103+
- unused_import
104+
- unused_declaration
105+
106+
line_length:
107+
warning: 130
108+
error: 200
109+
110+
type_body_length:
111+
warning: 300
112+
error: 400
113+
114+
file_length:
115+
warning: 500
116+
error: 1200
117+
118+
function_body_length:
119+
warning: 30
120+
error: 50
121+
122+
large_tuple:
123+
error: 3
124+
125+
nesting:
126+
type_level:
127+
warning: 2
128+
statement_level:
129+
warning: 10
130+
131+
132+
type_name:
133+
max_length:
134+
warning: 40
135+
error: 50
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
all: bootstrap
2+
3+
bootstrap: hook
4+
mint bootstrap
5+
6+
hook:
7+
ln -sf ../../hooks/pre-commit .git/hooks/pre-commit
8+
chmod +x .git/hooks/pre-commit
9+
10+
mint:
11+
mint bootstrap
12+
13+
lint:
14+
mint run swiftlint
15+
16+
fmt:
17+
mint run swiftformat Sources Tests
18+
19+
.PHONY: all bootstrap hook mint lint fmt
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nicklockwood/SwiftFormat@0.47.12
2+
realm/SwiftLint@0.47.1

0 commit comments

Comments
 (0)