Skip to content

Commit eda4033

Browse files
authored
Release (#134)
## What’s Changed * feat: add release tagging and clean up code (#133) @insanoid * Add access control selection (#121) @yonihemi * fix: add new keyword support and fix build (#132) @insanoid * Add Community Standards (#131) @insanoid * Update TextColor and BackgroundColor (#124) @cntrump * build(deps): bump cocoapods from 1.10.2 to 1.11.3 (#130) @dependabot * Fix text color in light mode (#120) @kchatzigeorgiou * Upgrade to GitHub-native Dependabot (#126) @dependabot-preview * build(deps): bump cocoapods from 1.7.5 to 1.10.2 (#127) @dependabot-preview
1 parent 0ef17ac commit eda4033

34 files changed

+721
-267
lines changed

.commitlintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"]
3+
}

.github/CODE_OF_CONDUCT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
education, socio-economic status, nationality, personal appearance, race,
10+
religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at {{ email }}. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+

.github/ISSUE_TEMPLATE

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Bug Report
2+
description: File a bug report
3+
title: "[Bug]: "
4+
labels: ["bug", "triage"]
5+
assignees:
6+
- octocat
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this bug report!
12+
- type: input
13+
id: contact
14+
attributes:
15+
label: Contact Details
16+
description: How can we get in touch with you if we need more info?
17+
placeholder: ex. email@example.com
18+
validations:
19+
required: false
20+
- type: textarea
21+
id: what-happened
22+
attributes:
23+
label: What happened?
24+
description: Also tell us, what did you expect to happen?
25+
placeholder: Tell us what you see!
26+
value: "A bug happened!"
27+
validations:
28+
required: true
29+
- type: input
30+
id: version
31+
attributes:
32+
label: Version
33+
description: What version of the app are you running?
34+
validations:
35+
required: true
36+
- type: input
37+
id: macOS-version
38+
attributes:
39+
label: macOS Version
40+
description: What version of macOS are you running?
41+
validations:
42+
required: true
43+
- type: dropdown
44+
id: build-it-self
45+
attributes:
46+
label: Did you build the application or download a pre-built version?
47+
multiple: true
48+
options:
49+
- Built it with Xcode / main branch
50+
- Built it with Xcode / dev branch
51+
- Downloaded .app file
52+
- type: dropdown
53+
id: apple-silicon
54+
attributes:
55+
label: Are you using an apple silicon machine (M1-x, M2)
56+
multiple: true
57+
options:
58+
- Yes
59+
- No
60+
- type: textarea
61+
id: logs
62+
attributes:
63+
label: Relevant log output
64+
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
65+
render: shell
66+
- type: checkboxes
67+
id: terms
68+
attributes:
69+
label: Code of Conduct
70+
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/insanoid/SwiftyJSONAcceleratorblob/master/.github/CONTRIBUTING.md)
71+
options:
72+
- label: I agree to follow this project's Code of Conduct
73+
required: true

.github/contributing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Contributing Guide
2+
- All improvements are welcome in the form of pull-requests. More so now than before, as I no longer work primarily on swift. Any suggestions regarding code quality of the app, generated code's quality, Swift related improvements and pull requests are all very welcome.
3+
- If you find bugs please raise them as issue tickets with specifics. Bug is when the feature is not working as it was designed or the app is broken.
4+
- If there are interesting use-cases that you would like to have in the application that would be useful for everyone - would be happy to add them to the app, either raise them as pull-requests or if isn't possible for you to build it raise them as feature request for others to contribute.
5+
6+
- When making any changes please assess them:
7+
- Is this change relevant for you or do others need it as well - adding features that you/your organisation needs sometimes is a niche and can be done in your branched version. Would be happy to consider but I usually merge things which I see as a more broadly used feature.
8+
- When changing existing functionality (e.g., changing generated variables from `var` to `let`) assess if this is an opinion or a standard way
9+
- When contributing please open your pull-requests to `dev` branch as there will be automation built to create releases.
10+
- Please ensure you add tests for new code you write and fix any tests you break.

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "04:00"
8+
open-pull-requests-limit: 10

.github/pull_request_template.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Proposed changes
2+
3+
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
4+
5+
## Types of changes
6+
7+
What types of changes does your code introduce to SwiftyJSONAccelerator?
8+
_Put an `x` in the boxes that apply_
9+
10+
- [ ] Bugfix (non-breaking change which fixes an issue)
11+
- [ ] New feature (non-breaking change which adds functionality)
12+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
13+
- [ ] Documentation Update (if none of the other choices apply)
14+
15+
## Checklist
16+
17+
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
18+
19+
- [ ] I have read the [CONTRIBUTING](https://github.com/insanoid/SwiftyJSONAccelerator/blob/main/.github/CONTRIBUTING.md) doc
20+
- [ ] Lint and unit tests pass locally with my changes
21+
- [ ] I have added tests that prove my fix is effective or that my feature works
22+
- [ ] I have added necessary documentation (if appropriate)
23+
24+
## Further comments
25+
26+
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

.github/release-drafter.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
template: |
2+
## What’s Changed
3+
4+
$CHANGES

.github/workflows/create_release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
# We create a new version if the branch is master.
10+
version_and_publish:
11+
name: Create Release
12+
if: github.ref == 'refs/heads/master'
13+
runs-on: ubuntu-latest
14+
outputs:
15+
release_version: ${{ steps.generate_version.outputs.release_version }}
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0
21+
# In future we should run tests to ensure if it's worth making a release.
22+
- name: Install semantic-release
23+
run: |
24+
npm set registry https://registry.npmjs.org/
25+
sudo npm install -g \
26+
semantic-release \
27+
@semantic-release/commit-analyzer \
28+
@semantic-release/github \
29+
@semantic-release/exec \
30+
@semantic-release/release-notes-generator \
31+
conventional-changelog-conventionalcommits
32+
33+
- name: Generate version
34+
id: generate_version
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
37+
NPM_TOKEN: ${{ secrets.GH_TOKEN }}
38+
run: |
39+
npx semantic-release --ci
40+
41+
- name: No Releases Done
42+
if: "!steps.generate_version.outputs.release_version"
43+
run: |
44+
echo "No Release was done either due to wrong commit or no major changes."

.github/workflows/release_drafter.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- dev
8+
pull_request:
9+
types: [opened, reopened, synchronize]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
update_release_draft:
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: release-drafter/release-drafter@v5
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

.releaserc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"branches": ["main"],
3+
"tagFormat": "${version}",
4+
"plugins": [
5+
[
6+
"@semantic-release/commit-analyzer", {
7+
"preset": "conventionalcommits",
8+
"releaseRules": [
9+
{"type": "doc", "release": false},
10+
{"type": "test", "release": false},
11+
{"type": "chore", "release": "patch"},
12+
{"type": "devx", "release": false}
13+
],
14+
"parserOpts": {
15+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
16+
}
17+
}
18+
],
19+
"@semantic-release/github",
20+
[
21+
"@semantic-release/exec", {
22+
"publishCmd": "echo \"::set-output name=release_version::${nextRelease.version}\""
23+
}
24+
],
25+
[
26+
"@semantic-release/release-notes-generator", {
27+
"preset": "conventionalcommits",
28+
"presetConfig": {
29+
"types": [
30+
{"type": "feat", "section": "Features"},
31+
{"type": "fix", "section": "Bug Fixes"},
32+
{"type": "doc", "section": "Documentation", "hidden": true},
33+
{"type": "test", "section": "Tests", "hidden": true},
34+
{"type": "chore", "section": "Chore / Improvements"},
35+
{"type": "devx", "section": "Improved Developer Experience", "hidden": false}
36+
]
37+
},
38+
"parserOpts": {
39+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
40+
},
41+
"writerOpts": {
42+
"commitsSort": ["subject", "scope"]
43+
}
44+
}
45+
]
46+
]
47+
}

Core/Constants.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ enum ConstructType: String {
2929
case structType = "struct"
3030
}
3131

32+
/// Various types of access control modifiers that can be applied to objects and properties.
33+
enum AccessControl: String, CaseIterable {
34+
case `internal`
35+
case `private`
36+
case `public`
37+
38+
/// The prefix to be applied to objects and properties' declarations.
39+
var declarationPrefix: String {
40+
switch self {
41+
case .internal:
42+
// The default access control type, no need to explicitly set it
43+
return ""
44+
default:
45+
return rawValue
46+
}
47+
}
48+
}
49+
3250
/// JSON mapping options available in the UI
3351
///
3452
/// - Swift: Pure Swift 5 Codeable
@@ -56,6 +74,6 @@ enum PropertyType: String {
5674
}
5775

5876
/// Place to store actual constants that don't fit in classes.
59-
struct Constants {
77+
enum Constants {
6078
static let filePathKey: String = "path"
6179
}

Core/Generator/FileGeneratorExtension.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ extension FileGenerator {
1212
static func generateFileContentWith(_ modelFile: ModelFile, configuration: ModelGenerationConfiguration) -> String {
1313
var content = try! loadFileWith("BaseTemplate")
1414
let singleTab = " ", doubleTab = " "
15+
let accessPrefix = modelFile.accessControl.declarationPrefix
1516
content = content.replacingOccurrences(of: "{OBJECT_NAME}", with: modelFile.fileName)
1617
content = content.replacingOccurrences(of: "{DATE}", with: todayDateString())
1718
content = content.replacingOccurrences(of: "{OBJECT_KIND}", with: modelFile.type.rawValue)
19+
content = content.replacingOccurrences(of: "{ACCESS_CONTROL}", with: accessPrefix)
1820

1921
if let authorName = configuration.authorName {
2022
content = content.replacingOccurrences(of: "__NAME__", with: authorName)
@@ -33,8 +35,19 @@ extension FileGenerator {
3335

3436
if modelFile.type == .classType {
3537
content = content.replacingOccurrences(of: "{REQUIRED}", with: "required ")
38+
if modelFile.configuration?.shouldGenerateInitMethod == true {
39+
let assignment = modelFile.component.initialiserFunctionComponent.map { doubleTab + $0.assignmentString }.joined(separator: "\n")
40+
let functionParameters = modelFile.component.initialiserFunctionComponent.map { $0.functionParameter }.joined(separator: ", ")
41+
let initialiserFunctionStatement = "\n\(singleTab)\(accessPrefix)init (\(functionParameters)) {"
42+
content = content.replacingOccurrences(of: "{INITIALIZER_FUNCTION_DECLRATION}", with: initialiserFunctionStatement)
43+
content = content.replacingOccurrences(of: "{INITIALISER_FUNCTION_ASSIGNMENT}", with: assignment)
44+
content = content.replacingOccurrences(of: "{INITIALISER_FUNCTION_END}", with: "\(singleTab)}\n")
45+
}
3646
} else {
3747
content = content.replacingOccurrences(of: "{REQUIRED}", with: "")
48+
content = content.replacingOccurrences(of: "{INITIALIZER_FUNCTION_DECLRATION}", with: "")
49+
content = content.replacingOccurrences(of: "{INITIALISER_FUNCTION_ASSIGNMENT}", with: "")
50+
content = content.replacingOccurrences(of: "{INITIALISER_FUNCTION_END}", with: "")
3851
}
3952
return content
4053
}
@@ -48,7 +61,7 @@ extension FileGenerator {
4861

4962
- returns: Boolean indicating if the process was successful.
5063
*/
51-
internal static func writeToFileWith(_ name: String, content: String, path: String) throws {
64+
static func writeToFileWith(_ name: String, content: String, path: String) throws {
5265
let filename = path.appendingFormat("%@", name + ".swift")
5366
try FileManager.default.createDirectory(at: URL(fileURLWithPath: path),
5467
withIntermediateDirectories: true,

0 commit comments

Comments
 (0)