Skip to content

Commit

Permalink
chore: bunch of issues (see below)
Browse files Browse the repository at this point in the history
- Add Github Action for release
- Add License
- Add code of conduct
- General code cleanup
  • Loading branch information
markemer committed Nov 8, 2023
1 parent 41b93b5 commit 0db6b76
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 20 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release Cap2SPM

on:
push:
tags:
'*.*.*'

jobs:
release:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v1
with:
swift-version: "5.9"
- name: Build for Release
run: swift build -c release --arch arm64 --arch x86_64 --product cap2spm
- name: Zip Executable
run: zip cap2spm-${{ github.ref_name }}.zip .build/apple/Products/Release/cap2spm
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: cap2spm-${{ github.ref_name }}.zip
token: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Contributor Code of Conduct

As contributors and maintainers of the Capacitor project, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities.

Communication through any of Capacitor's channels (GitHub, Slack, Forum, IRC, mailing lists, Twitter, etc.) must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the Capacitor project to do the same.

If any member of the community violates this code of conduct, the maintainers of the Capacitor project may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate.

If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at [[email protected]](mailto:[email protected]).
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-present Drifty Co.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 19 additions & 20 deletions Sources/cap2spm.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
//
// Swift Argument Parser
// https://swiftpackageindex.com/apple/swift-argument-parser/documentation

import Foundation
import SwiftParser
import SwiftSyntax
Expand Down Expand Up @@ -48,25 +42,30 @@ struct Cap2SPM: ParsableCommand {
swiftFileURL = try capacitorPluginPackage.findSwiftPluginFile(from: mFileURL)
}

let source = try String(contentsOf: swiftFileURL, encoding: .utf8)
let sourceFile = Parser.parse(source: source)

guard let capPlugin = capacitorPluginPackage.oldPlugin?.capacitorPlugin else { return }

let incremented = AddPluginToClass(with: capPlugin).visit(sourceFile)
try modifySwiftFile(at: swiftFileURL, plugin: capPlugin)

try fileBackup(at: mFileURL)
try fileBackup(at: hFileURL)
}

private func fileBackup(at fileURL: URL) throws {
let fileBackupURL = fileURL.appendingPathExtension("old")
print("Moving \(fileURL.path()) to \(fileBackupURL.path())")
try FileManager.default.moveItem(at: fileURL, to: fileBackupURL)
}

private func modifySwiftFile(at fileURL: URL, plugin: CapacitorPluginSyntax) throws {
let source = try String(contentsOf: fileURL, encoding: .utf8)
let sourceFile = Parser.parse(source: source)

let mFileBackup = mFileURL.appendingPathExtension("old")
let hFileBackup = hFileURL.appendingPathExtension("old")
let swiftFileBackup = swiftFileURL.appendingPathExtension("old")
let incremented = AddPluginToClass(with: plugin).visit(sourceFile)

try fileBackup(at: fileURL)

try FileManager.default.moveItem(at: mFileURL, to: mFileBackup)
try FileManager.default.moveItem(at: hFileURL, to: hFileBackup)
try FileManager.default.moveItem(at: swiftFileURL, to: swiftFileBackup)

var outputString: String = ""
incremented.write(to: &outputString)
try outputString.write(to: swiftFileURL, atomically: true, encoding: .utf8)
try outputString.write(to: fileURL, atomically: true, encoding: .utf8)
}
}


0 comments on commit 0db6b76

Please sign in to comment.