Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hisaac committed Nov 12, 2024
0 parents commit f4e03e7
Show file tree
Hide file tree
Showing 42 changed files with 110,802 additions and 0 deletions.
1 change: 1 addition & 0 deletions .config/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.0
1 change: 1 addition & 0 deletions .config/.xcode-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.1
21 changes: 21 additions & 0 deletions .config/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

extends: default

ignore:
- '**/.build'
- '**/DerivedData'

rules:

# The default line-length of 80 is a bit too restrictive.
line-length:
max: 120

# GitHub's workflow schema includes a key named "on" which trips this rule.
# We'll disable the check for keys only, so it will still check values.
truthy:
check-keys: false
ignore: |
*
!.github/workflows
68 changes: 68 additions & 0 deletions .config/swift-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentation": {
"tabs": 1
},
"indentConditionalCompilationBlocks": true,
"indentSwitchCaseLabels": true,
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineLength": 120,
"maximumBlankLines": 1,
"multiElementCollectionTrailingCommas": true,
"noAssignmentInExpressions": {
"allowedFunctions": ["XCTAssertNoThrow"]
},
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": false,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": true,
"NeverUseForceTry": true,
"NeverUseImplicitlyUnwrappedOptionals": true,
"NoAccessLevelOnExtensionDeclaration": true,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": false,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": true,
"UseExplicitNilCheckInConditions": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": true
},
"spacesAroundRangeFormationOperators": true,
"tabWidth": 4,
"version": 1
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,yaml,pkr.hcl}]
indent_size = 2
indent_style = space
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "swift"
directory: "/"
schedule:
interval: "weekly"
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

name: Test

on:
pull_request:
branches: main

jobs:
test:
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test
run: |
sudo xcode-select --switch "/Applications/Xcode_16_beta_6.app"
make ci
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.build/
.DS_Store
.netrc
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
*.xcodeproj
*.xcworkspace
Derived/
DerivedData/
graph.dot
Package.resolved
Packages/
xcuserdata/
6 changes: 6 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tools]
just = "latest"
shfmt = "latest"
tuist = "latest"
xcodes = "latest"
yamllint = "latest"
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"configurations": [
{
"type": "lldb",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:workbench}/src/sw_vers",
"name": "Debug sw_vers (src/sw_vers)",
"program": "${workspaceFolder:workbench}/src/sw_vers/.build/debug/sw_vers",
"preLaunchTask": "swift: Build Debug sw_vers (src/sw_vers)"
},
{
"type": "lldb",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:workbench}/src/sw_vers",
"name": "Release sw_vers (src/sw_vers)",
"program": "${workspaceFolder:workbench}/src/sw_vers/.build/release/sw_vers",
"preLaunchTask": "swift: Build Release sw_vers (src/sw_vers)"
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"othr"
]
}
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright © 2024 Isaac Halvorson

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.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# config
.PHONY: * # all targets phony
$(V).SILENT: # all targets silent

# variables
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_root := $(realpath $(dir $(mkfile_path)))
scripts_dir := $(project_root)/scripts

up:
"$(scripts_dir)/up.bash"
91 changes: 91 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Notes

This document contains notes to myself for reference later.

## Example Commands

### Shell Commands

#### User Accounts

Can use the `dscl` binary, or the OpenDirectory framework.

Some examples of using `dscl`:

Get all user accounts on the machine

```shell
/usr/bin/dscl -plist localhost readall /Local/Default/Users UniqueID RecordName RealName NFSHomeDirectory HomeDirectory IsHidden
```

Get user accounts in the admin group

```shell
/usr/bin/dscl -plist localhost read /Local/Default/Groups/admin GroupMembership
```

Some examples of using OpenDirectory:

```swift
import OpenDirectory

let session = ODSession.default()
let node = try ODNode(session: session, name: "/Local/Default")
let query = try ODQuery(
node: node,
forRecordTypes: kODRecordTypeUsers,
attribute: nil,
matchType: 0,
queryValues: nil,
returnAttributes: nil,
maximumResults: 0
)

let results = try query.resultsAllowingPartial(false)
for result in results {
dump(result)
}
```

Library for styled TUI components: <https://github.com/dduan/Termbox>

Information about Mac computers located at `/System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/en.lproj/SIMachineAttributes.plist`

```swift
import OSLog

// Extension that makes it a breeze to create a logger that is
// configured with an appropriate subsystem and category ✨
// source: // Source: https://mastodon.social/@simonbs/111985986963709036
extension Logger {
init<T>(forType type: T.Type) {
let subsystem = Bundle.main.bundleIdentifier!
let category = String(describing: type)
self.init(subsystem: subsystem, category: category)
}
}

// Example usage 👇
struct MyStruct {
private let logger = Logger(forType: Self.self)

func performOperation() {
logger.info("Performing operation...")
// ...
logger.info("Did perform operation.")
}
}
```

- https://github.com/QiuZhiFei/swift-commands
- https://macdevelopers.wordpress.com/2014/01/24/programmatically-retrieving-system-information-on-mac/
- https://opensource.apple.com/source/system_cmds/system_cmds-541/sysctl.tproj/sysctl.c?txt
- https://opensource.apple.com/source/system_cmds/
- https://opensource.apple.com/source/DarwinTools/
- https://theapplewiki.com/wiki/Filesystem:/System/Library/PrivateFrameworks
- https://robnapier.net/understanding-systemprofiler
- https://github.com/keith/dyld-shared-cache-extractor
- https://github.com/joshua-d-miller/macOSLAPS
- https://github.com/freegeek-pdx/mkuser

- [In the Hunt for the macOS AutoLogin Setup Process](https://www.offsec.com/blog/in-the-hunt-for-the-macos-autologin-setup-process/)
37 changes: 37 additions & 0 deletions Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import ProjectDescription

let swiftVersionFile = Path("//.config/.swift-version")
let swiftVersionFileContents = try! String(contentsOfFile: swiftVersionFile.pathString, encoding: .utf8)
let swiftVersionFileContentsTrimmed = swiftVersionFileContents.trimmingCharacters(in: .whitespacesAndNewlines)

let project = Project(
name: "SysInfoKit",
settings: .settings(
base: SettingsDictionary().swiftVersion(swiftVersionFileContentsTrimmed)
),
targets: [
.target(
name: "SysInfoKit",
destinations: .macOS,
product: .framework,
bundleId: "co.othr.SysInfoKit",
sources: ["src/SysInfoKit/Sources/**"],
dependencies: [
.external(name: "Command"),
.external(name: "MetaCodable"),
.external(name: "Version"),
]
),
.target(
name: "SysInfoKitTests",
destinations: .macOS,
product: .unitTests,
bundleId: "co.othr.SysInfoKitTests",
sources: ["src/SysInfoKit/Tests/**"],
resources: ["src/SysInfoKit/Tests/Resources/**"],
dependencies: [
.target(name: "SysInfoKit")
]
),
]
)
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# workbench

This repository is a place for me to experiment with new tools and little projects. Consider anything here a work in progress, and if I consider it ready for use, I'll move it to a more permanent home.

# SysInfoKit

Library for introspecting information about the system currently running your code.

# `xcb`

`xcb` is a Swift CLI for interacting with the `xcodebuild` and `swift` CLI tools. It aims to provide nicer defaults, new features, and improved ergonomics.

> [!WARNING]
> This project is in the very early stages of development, and is not yet ready for real world usage.
## Goals

### Nicer Defaults

### New Features

- Ensure usage of the desired Xcode / Swift version if specified.

### Improved Ergonomics

- Define build settings in a config file.
- Easier selection of schemes and devices.
- Improved output formatting using [`xcbeautify`](https://github.com/cpisciotta/xcbeautify/).
- Common errors will automatically detected and displayed in a user-friendly manner.

## TODO

- [x] Use dependabot to keep the dependencies up to date.
- [ ] Use `xcbeautify` to format the output of the `xcodebuild` command.
- [ ] Implement build settings from a config file.
- [ ] Implement scheme selection.
- [ ] Implement device selection.
- [ ] Implement build destination selection.
- [ ] Implement build configuration selection.
- [ ] Use mise cache to speed up the build in CI.
Loading

0 comments on commit f4e03e7

Please sign in to comment.