Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
[![GitHub License](https://img.shields.io/github/license/XCEssentials/RepoConfigurator.svg?longCache=true)](LICENSE)
[![GitHub Tag](https://img.shields.io/github/tag/XCEssentials/RepoConfigurator.svg?longCache=true)](https://github.com/XCEssentials/RepoConfigurator/tags)
[![Swift Package Manager Compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg?longCache=true)](Package.swift)
[![Written in Swift](https://img.shields.io/badge/Swift-5.0-orange.svg?longCache=true)](https://swift.org)
[![Written in Swift](https://img.shields.io/badge/Swift-5.9-orange.svg?longCache=true)](https://swift.org)
[![Supported platforms](https://img.shields.io/badge/platforms-macOS-blue.svg?longCache=true)](Package.swift)
[![Build Status](https://travis-ci.com/XCEssentials/RepoConfigurator.svg?branch=master)](https://travis-ci.com/XCEssentials/RepoConfigurator)
[![CI](https://github.com/XCEssentials/RepoConfigurator/actions/workflows/ci.yml/badge.svg)](https://github.com/XCEssentials/RepoConfigurator/actions/workflows/ci.yml)

# RepoConfigurator

Generate repo config files using Swift and Xcode.

## Usage
## How it works

The goal is to create a Swift script file that will contain all the settings for the repo (Swift version number, product name, company name, author(s) name, company prefix, project and target(s) names(s), etc.) and which you can run on demand to generate and re-generate all sorts of infrastructure / settings / configuration files for the repo ([gitignore](https://git-scm.com/docs/gitignore), [Fastfile](https://fastlane.tools/), [Podfile](https://guides.cocoapods.org/syntax/podfile.html), etc.), to easily keep them all up to date and in coherence with each other.
XCERepoConfigurator is a Swift library for programmatically generating all the scaffolding files of a new Swift package.

Note, that you might want to write some files only once during the repo lifetime (in the beginning), but in most cases it is supposed that all those files described in the config should be kept up to date only via this config. So whenever you want to rename the product or change any of it's settings, or add a CocoaPods dependency — those fixes should be done in the config script and then entire script should be executed to regenerate everything. This way we always can guarantee that everything is up to date and in sync with each other, plus it's super easy to review all settings in one place.
Instead of manually creating and maintaining boilerplate files scattered across a repo, you write a single Swift script that declares your project's parameters once — then run it to produce (or regenerate) every file in one shot.

## Installation
The library is consumed via a small, dedicated Swift executable package called **Setup**, placed in a `.setup/` folder at the root of the target repo:

`XCERepoConfigurator` is a standard SwiftPM-compatible [package](Package.swift), so it can be used as dependincy in any [SPM](https://github.com/apple/swift-package-manager/tree/master/Documentation) based script.
```
MyLibrary/ ← the Swift package being created/maintained
├── .setup/
│ ├── Package.swift ← a separate Swift package; depends on XCERepoConfigurator
│ └── Sources/
│ └── Setup/
│ └── main.swift ← declares all settings and calls generators
├── Sources/
├── Tests/
├── Package.swift ← generated by the Setup script
├── README.md ← generated by the Setup script
└── ... ← all other config files, generated
```

The Setup script imports `XCERepoConfigurator`, sets project metadata, then calls generators using a fluent builder API:

```swift
try ReadMe()
.addGitHubLicenseBadge(account: company.name, repo: project.name)
.addGitHubTagBadge(account: company.name, repo: project.name)
.addSwiftPMCompatibleBadge()
.prepare()
.writeToFileSystem(ifFileExists: .skip)
```

## Usage
To run it: `cd .setup && swift run`

To get an idea of how to use this library, see `.setup/main.swift` in this repo and also templates for [Cocoa app](https://github.com/XCEssentials/AppTemplate) and [Cocoa framework](https://github.com/XCEssentials/FrameworkTemplate).
This is run **manually** by the developer — when bootstrapping a new project, or when any config needs to change.

## Installation

`XCERepoConfigurator` is a standard SwiftPM-compatible [package](Package.swift), so it can be used as dependincy in any [SPM](https://github.com/apple/swift-package-manager/tree/master/Documentation) based script.

## Remember

Expand Down