diff --git a/.cursor/commands/deslop.md b/.cursor/commands/deslop.md new file mode 100644 index 000000000..51ecc654f --- /dev/null +++ b/.cursor/commands/deslop.md @@ -0,0 +1,12 @@ +# Remove AI code slop + +Check the diff against main, and remove all AI generated slop introduced in this branch. + +This includes: + +- Extra comments that a human wouldn't add or is inconsistent with the rest of the file +- Extra defensive checks or try/catch blocks that are abnormal for that area of the codebase (especially if called by trusted / validated codepaths) +- Casts to any to get around type issues +- Any other style that is inconsistent with the file + +Report at the end with only a 1-3 sentence summary of what you changed diff --git a/.github/actions/setup-swiftlint/README.md b/.github/actions/setup-swiftlint/README.md new file mode 100644 index 000000000..ce7d4e8a4 --- /dev/null +++ b/.github/actions/setup-swiftlint/README.md @@ -0,0 +1,72 @@ +# Setup SwiftLint Action + +A reusable GitHub Action that downloads and installs SwiftLint binary from [SwiftLint releases](https://github.com/realm/SwiftLint/releases/) to `/usr/bin`. + +## Usage + +### Basic usage + +```yaml +- uses: ./.github/actions/setup-swiftlint +``` + +This will install the latest version of SwiftLint. + +### Specify version + +```yaml +- uses: ./.github/actions/setup-swiftlint + with: + version: '0.58.2' +``` + +Or use version with `v` prefix: + +```yaml +- uses: ./.github/actions/setup-swiftlint + with: + version: 'v0.58.2' +``` + +## Inputs + +| Input | Description | Required | Default | +|-------|-------------|----------|---------| +| `version` | SwiftLint version (e.g., `0.58.2`). If not specified, the latest version will be used | No | `latest` | + +## Example workflow + +```yaml +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Install SwiftLint + uses: ./.github/actions/setup-swiftlint + with: + version: '0.58.2' + + - name: Run SwiftLint + run: swiftlint +``` + +## Supported operating systems + +- macOS +- Linux + +## Notes + +- This action requires `sudo` permissions to install the binary to `/usr/bin` +- After installation, the `swiftlint` command will be globally available in PATH +- If the specified version does not exist, the action will fail with an error message diff --git a/.github/actions/setup-swiftlint/action.yml b/.github/actions/setup-swiftlint/action.yml new file mode 100644 index 000000000..fd4b544c0 --- /dev/null +++ b/.github/actions/setup-swiftlint/action.yml @@ -0,0 +1,96 @@ +name: 'Setup SwiftLint' +description: 'Download and install SwiftLint binary to /usr/bin' +branding: + icon: 'code' + color: 'blue' + +inputs: + version: + description: 'SwiftLint version (e.g., 0.58.2). If not specified, the latest version will be used' + required: false + default: 'latest' + +runs: + using: 'composite' + steps: + - name: Detect OS + id: os + shell: bash + run: | + if [[ "$RUNNER_OS" == "macOS" ]]; then + echo "platform=macos" >> $GITHUB_OUTPUT + echo "archive_name=portable_swiftlint.zip" >> $GITHUB_OUTPUT + elif [[ "$RUNNER_OS" == "Linux" ]]; then + echo "platform=linux" >> $GITHUB_OUTPUT + echo "archive_name=swiftlint_linux.zip" >> $GITHUB_OUTPUT + else + echo "Error: Unsupported OS $RUNNER_OS" + exit 1 + fi + + - name: Get latest version + if: inputs.version == 'latest' + id: version + shell: bash + run: | + VERSION=$(curl -s https://api.github.com/repos/realm/SwiftLint/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + if [[ -z "$VERSION" ]]; then + echo "Error: Failed to get latest version" + exit 1 + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Latest version: $VERSION" + + - name: Set version + if: inputs.version != 'latest' + id: version + shell: bash + run: | + VERSION="${{ inputs.version }}" + if [[ ! "$VERSION" =~ ^v ]]; then + VERSION="v$VERSION" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Using specified version: $VERSION" + + - name: Download and install SwiftLint + shell: bash + run: | + set -e + + PLATFORM="${{ steps.os.outputs.platform }}" + VERSION="${{ steps.version.outputs.version }}" + ARCHIVE_NAME="${{ steps.os.outputs.archive_name }}" + DOWNLOAD_URL="https://github.com/realm/SwiftLint/releases/download/${VERSION}/${ARCHIVE_NAME}" + + echo "Downloading SwiftLint from $DOWNLOAD_URL..." + + if ! curl -L -f -o swiftlint.zip "$DOWNLOAD_URL"; then + echo "Error: Download failed, please check if the version is correct" + exit 1 + fi + + echo "Extracting..." + unzip -q swiftlint.zip + + if [[ -f "swiftlint" ]]; then + BINARY_PATH="swiftlint" + elif [[ -f "swiftlint_linux/swiftlint" ]]; then + BINARY_PATH="swiftlint_linux/swiftlint" + elif [[ -f "portable_swiftlint/swiftlint" ]]; then + BINARY_PATH="portable_swiftlint/swiftlint" + else + echo "Error: Could not find swiftlint binary" + ls -la + exit 1 + fi + + chmod +x "$BINARY_PATH" + sudo mv "$BINARY_PATH" /usr/bin/swiftlint + + if ! swiftlint version; then + echo "Error: SwiftLint installation verification failed" + exit 1 + fi + + rm -rf swiftlint.zip swiftlint_linux portable_swiftlint 2>/dev/null || true diff --git a/.github/workflows/autofix.yaml b/.github/workflows/autofix.yaml index e33e9b7ba..f4a5d1fdd 100644 --- a/.github/workflows/autofix.yaml +++ b/.github/workflows/autofix.yaml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-swiftlint - uses: pnpm/action-setup@v3 - uses: actions/setup-node@v6 with: @@ -23,6 +24,7 @@ jobs: - run: pnpm install - run: pnpm prune && pnpm dedupe - run: pnpm run lint:fix + - run: pnpm run lint:swift --fix # - name: AutoCorrect # uses: huacnlee/autocorrect-action@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54fc9aa5d..25675f871 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-swiftlint - uses: pnpm/action-setup@v3 - uses: actions/setup-node@v5 with: @@ -23,6 +24,7 @@ jobs: - run: pnpm install --frozen-lockfile - run: pnpm run lint + - run: pnpm run lint:swift build-test: name: Build Test (${{ matrix.app_name }}) diff --git a/apps/stage-pocket/ios/.gitignore b/apps/stage-pocket/ios/.gitignore index f47029973..eaee04eaf 100644 --- a/apps/stage-pocket/ios/.gitignore +++ b/apps/stage-pocket/ios/.gitignore @@ -11,3 +11,6 @@ capacitor-cordova-ios-plugins # Generated Config files App/App/capacitor.config.json App/App/config.xml + +App.xcarchive +archive.plist diff --git a/apps/stage-pocket/ios/App/CapApp-SPM/Package.resolved b/apps/stage-pocket/ios/App/CapApp-SPM/Package.resolved new file mode 100644 index 000000000..f87c5b108 --- /dev/null +++ b/apps/stage-pocket/ios/App/CapApp-SPM/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "capacitor-swift-pm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ionic-team/capacitor-swift-pm.git", + "state" : { + "revision" : "596259033e94829dffc552a40e7129262122995e", + "version" : "8.0.0" + } + } + ], + "version" : 2 +} diff --git a/apps/stage-pocket/package.json b/apps/stage-pocket/package.json index b2546f0c1..33add45d7 100644 --- a/apps/stage-pocket/package.json +++ b/apps/stage-pocket/package.json @@ -12,6 +12,7 @@ "scripts": { "build": "vite build", "lint": "eslint .", + "lint:swift": "swiftlint", "preview": "vite preview", "typecheck": "vue-tsc --noEmit", "dev:web": "vite", diff --git a/package.json b/package.json index 2b8e5db84..c79fae3f4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "lint": "moeru-lint .", "lint:fix": "moeru-lint --fix .", "lint:rust": "cargo fmt --check && cargo clippy --workspace", + "lint:swift": "pnpm -rF @proj-airi/stage-pocket run lint:swift", "to-avif": "tsx docs/scripts/avif.ts", "typecheck": "pnpm -rF=\"./packages/*\" -F=\"./apps/*\" -F=\"./docs\" --parallel typecheck", "up": "taze -w -r -I && pnpm prune && pnpm dedupe",