Skip to content

Commit

Permalink
Merge branch 'main' into environment-optional-helper
Browse files Browse the repository at this point in the history
* main:
  Rebuild frameworks
  Remove unnecessary step
  Add Luis to the core team
  Fix Xcode version
  Fix syntax issue
  Bump gatsby-plugin-mdx from 1.10.0 to 2.0.1 in /next (tuist#2652)
  Plugins: Finalize support for tuist edit (tuist#2642)
  Drop support for Xcode 11.x (tuist#2651)
  docs: add tiarnann as a contributor (tuist#2657)
  Install script bug fix: Adding bin folder to usr/local/ when it is missing (tuist#2655)

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
DimaMishchenko committed Mar 15, 2021
2 parents dc959c7 + f541f1b commit 8ccdbb7
Show file tree
Hide file tree
Showing 166 changed files with 846 additions and 363 deletions.
18 changes: 9 additions & 9 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,6 @@
"code"
]
},
{
"login": "luispadron",
"name": "Luis Padron",
"avatar_url": "https://avatars3.githubusercontent.com/u/13840545?v=4",
"profile": "http://www.luispadron.com",
"contributions": [
"code"
]
},
{
"login": "hebertialmeida",
"name": "Heberti Almeida",
Expand Down Expand Up @@ -333,6 +324,15 @@
"contributions": [
"code"
]
},
{
"login": "tiarnann",
"name": "Tíarnán McGrath",
"avatar_url": "https://avatars.githubusercontent.com/u/10522081?v=4",
"profile": "https://github.com/tiarnann",
"contributions": [
"bug"
]
}
],
"contributorsPerLine": 7,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode ${{ matrix.xcode }}
Expand All @@ -41,7 +41,7 @@ jobs:
runs-on: macOS-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fixturegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: macOS-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/meta-tuist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode
Expand All @@ -46,4 +46,4 @@ jobs:
./bin/fourier generate tuist
- name: Build
run: |
./bin/fourier build all
./bin/fourier build all
22 changes: 12 additions & 10 deletions .github/workflows/tuist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- Sources/**
- Tests/**
- features/**
- fixtures/**

env:
RUBY_VERSION: '2.7.2'
Expand All @@ -23,7 +24,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode
Expand Down Expand Up @@ -56,7 +57,7 @@ jobs:
runs-on: macOS-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode
Expand All @@ -79,6 +80,12 @@ jobs:
xcode: ['12.3']
feature:
[
'build',
'cache-frameworks',
'cache-xcframeworks',
'dependencies',
'edit',
'env',
'generate-1',
'generate-2',
'generate-3',
Expand All @@ -88,17 +95,12 @@ jobs:
'generate-7',
'generate-8',
'init',
'lint-project',
'lint-code',
'lint-project',
'precompiled',
'scaffold',
'up',
'build',
'test',
'env',
'cache-xcframeworks',
'cache-frameworks',
'precompiled',
'dependencies',
'up',
]
steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tuistbench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: macOS-latest
strategy:
matrix:
xcode: ['11.5', '12.3']
xcode: ['12', '12.4']
steps:
- uses: actions/checkout@v1
- name: Select Xcode
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
### Added

- Add support for `--no-use-binaries` Carthage flag. [#2608](https://github.com/tuist/tuist/pull/2608) by [@laxmorek](https://github.com/laxmorek)
- Add support for `tuist edit` for projects with plugins. [#2642](https://github.com/tuist/tuist/pull/2642) by [@luispadron](https://github.com/luispadron)

### Changed

- **Breaking** Redesign `ProjectDescription.CarthageDependencies` manifest model. [#2608](https://github.com/tuist/tuist/pull/2608) by [@laxmorek](https://github.com/laxmorek)
- Changed the auto generated scheme heuristic to pick test bundles that have a matching name prefixed with either `Tests`, `IntegrationTests` or `UITests`. [#2641](https://github.com/tuist/tuist/pull/2641) by [@FranzBusch](https://github.com/FranzBusch)
- Remove building of ProjectDescriptionHelpers for `Plugin.swift` and `Config.swift` manifests (not supported for these manifests). [#2642](https://github.com/tuist/tuist/pull/2642) by [@luispadron](https://github.com/luispadron)

### Fixed

- Fixed running `tuist test` with `--clean` flag [#2649](https://github.com/tuist/tuist/pull/2649) by [@fortmarek](https://github.com/fortmarek)
- Install script bug fix: Adding bin folder to usr/local/ when it is missing [#2655](https://github.com/tuist/tuist/pull/2655) by [@tiarnann](https://github.com/tiarnann)
- Fixed `Environment` retrieve methods [#2653](https://github.com/tuist/tuist/pull/2653) by [@DimaMishchenko](https://github.com/DimaMishchenko)

### Removed

- Support for Xcode 11.x. [#2651](https://github.com/tuist/tuist/pull/2651) by [@pepibumur](https://github.com/pepibumur)

## 1.37.0 - Twister

### Added
Expand Down
10 changes: 10 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ let package = Package(
"TuistDocTesting",
"TuistAsyncQueueTesting",
"TuistGraphTesting",
"TuistPlugin",
"TuistPluginTesting",
]
),
.testTarget(
Expand Down Expand Up @@ -729,6 +731,14 @@ let package = Package(
swiftToolsSupportDependency,
]
),
.target(
name: "TuistPluginTesting",
dependencies: [
"TuistGraph",
"TuistPlugin",
swiftToolsSupportDependency,
]
),
.testTarget(
name: "TuistPluginTests",
dependencies: [
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ If you are interested in contributed to the project, our documentation has a sec
<td align="center"><a href="https://github.com/ollieatkinson"><img src="https://avatars1.githubusercontent.com/u/1382565?v=4" width="100px;" alt=""/><br /><sub><b>Oliver Atkinson</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/RomainBoulay"><img src="https://avatars1.githubusercontent.com/u/169323?v=4" width="100px;" alt=""/><br /><sub><b>Romain Boulay</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/laxmorek"><img src="https://avatars1.githubusercontent.com/u/4774319?v=4" width="100px;" alt=""/><br /><sub><b>Kamil Harasimowicz</b></sub></a><br /></td>
<td align="center"><a href="http://www.luispadron.com"><img src="https://avatars3.githubusercontent.com/u/13840545?v=4" width="100px;" alt=""/><br /><sub><b>Luis Padron</b></sub></a></td>
</tr>
</table>

Expand Down Expand Up @@ -139,6 +140,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center"><a href="https://twitter.com/FranzJBusch"><img src="https://avatars.githubusercontent.com/u/3491887?v=4" width="100px;" alt=""/><br /><sub><b>Franz Busch</b></sub></a></td>
<td align="center"><a href="https://github.com/tiarnann"><img src="https://avatars.githubusercontent.com/u/10522081?v=4" width="100px;" alt=""/><br /><sub><b>Tíarnán McGrath</b></sub></a></td>
</tr>
</table>

Expand Down
15 changes: 14 additions & 1 deletion Sources/TuistGraph/Models/ProjectDescriptionHelpersPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@ import TSCBasic

/// A model representing a custom `ProjectDescription` helper.
public struct ProjectDescriptionHelpersPlugin: Equatable {
/// Possible locations for a ProjectDescriptionHelpersPlugin
public enum Location: Equatable {
/// A plugin local to the current file system.
case local
/// A plugin on a remote server.
case remote
}

/// The name of the helper module.
public let name: String
/// The path to `Plugin` manifest for this helper.
public let path: AbsolutePath
/// The type of location for the plugin.
public let location: Location

/// Creates a `ProjectDescriptionHelpersPlugin`.
/// - Parameters:
/// - name: The name of the helper module.
/// - path: The path to `Plugin` manifest for this helper.
/// - location: The type of location for the plugin.
public init(
name: String,
path: AbsolutePath
path: AbsolutePath,
location: Location
) {
self.name = name
self.path = path
self.location = location
}
}
11 changes: 11 additions & 0 deletions Sources/TuistGraphTesting/Models/Plugins+TestData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation
import TSCBasic
@testable import TuistGraph

public extension Plugins {
static func test(
projectDescriptionHelpers: [ProjectDescriptionHelpersPlugin] = []
) -> Plugins {
Plugins(projectDescriptionHelpers: projectDescriptionHelpers)
}
}
18 changes: 18 additions & 0 deletions Sources/TuistKit/ProjectEditor/EditablePluginManifest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation
import TSCBasic

/// A plugin which is loaded & editable as part of the `tuist edit` command.
struct EditablePluginManifest {
let name: String
let path: AbsolutePath
}

extension EditablePluginManifest: Hashable {
func hash(into hasher: inout Hasher) {
hasher.combine(path)
}

static func == (lhs: Self, rhs: Self) -> Bool {
lhs.path == rhs.path
}
}
62 changes: 54 additions & 8 deletions Sources/TuistKit/ProjectEditor/ProjectEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ protocol ProjectEditing: AnyObject {
/// - Parameters:
/// - editingPath: Directory whose project will be edited.
/// - destinationDirectory: Directory in which the Xcode project will be generated.
/// - plugins: The plugins to load as part of the edit project.
/// - Returns: The path to the generated Xcode project.
func edit(at editingPath: AbsolutePath, in destinationDirectory: AbsolutePath) throws -> AbsolutePath
func edit(
at editingPath: AbsolutePath,
in destinationDirectory: AbsolutePath,
plugins: Plugins
) throws -> AbsolutePath
}

final class ProjectEditor: ProjectEditing {
Expand All @@ -50,9 +55,12 @@ final class ProjectEditor: ProjectEditing {
/// Utility to locate the helpers directory.
let helpersDirectoryLocator: HelpersDirectoryLocating

/// Utiltity to locate the custom templates directory
/// Utility to locate the custom templates directory
let templatesDirectoryLocator: TemplatesDirectoryLocating

/// Builder used to compile and build the loaded plugins
let projectDescriptionHelpersBuilder: ProjectDescriptionHelpersBuilding

/// Xcode Project writer
private let writer: XcodeProjWriting

Expand All @@ -63,7 +71,8 @@ final class ProjectEditor: ProjectEditing {
manifestFilesLocator: ManifestFilesLocating = ManifestFilesLocator(),
helpersDirectoryLocator: HelpersDirectoryLocating = HelpersDirectoryLocator(),
writer: XcodeProjWriting = XcodeProjWriter(),
templatesDirectoryLocator: TemplatesDirectoryLocating = TemplatesDirectoryLocator()
templatesDirectoryLocator: TemplatesDirectoryLocating = TemplatesDirectoryLocator(),
projectDescriptionHelpersBuilder: ProjectDescriptionHelpersBuilding = ProjectDescriptionHelpersBuilder()
) {
self.generator = generator
self.projectEditorMapper = projectEditorMapper
Expand All @@ -72,12 +81,16 @@ final class ProjectEditor: ProjectEditing {
self.helpersDirectoryLocator = helpersDirectoryLocator
self.writer = writer
self.templatesDirectoryLocator = templatesDirectoryLocator
self.projectDescriptionHelpersBuilder = projectDescriptionHelpersBuilder
}

func edit(at editingPath: AbsolutePath, in destinationDirectory: AbsolutePath) throws -> AbsolutePath {
func edit(
at editingPath: AbsolutePath,
in destinationDirectory: AbsolutePath,
plugins: Plugins
) throws -> AbsolutePath {
let projectDescriptionPath = try resourceLocator.projectDescription()
let projectManifests = manifestFilesLocator.locateProjectManifests(at: editingPath)
let pluginManifests = manifestFilesLocator.locatePluginManifests(at: editingPath)
let configPath = manifestFilesLocator.locateConfig(at: editingPath)
let dependenciesPath = manifestFilesLocator.locateDependencies(at: editingPath)
let setupPath = manifestFilesLocator.locateSetup(at: editingPath)
Expand All @@ -90,14 +103,20 @@ final class ProjectEditor: ProjectEditing {
FileHandler.shared.glob($0, glob: "**/*.swift") + FileHandler.shared.glob($0, glob: "**/*.stencil")
} ?? []

let editablePluginManifests = locateEditablePluginManifests(at: editingPath, plugins: plugins)
let builtPluginHelperModules = try buildRemotePluginModules(
in: editingPath,
projectDescriptionPath: projectDescriptionPath,
plugins: plugins
)

/// We error if the user tries to edit a project in a directory where there are no editable files.
if projectManifests.isEmpty, pluginManifests.isEmpty, helpers.isEmpty, templates.isEmpty {
if projectManifests.isEmpty, editablePluginManifests.isEmpty, helpers.isEmpty, templates.isEmpty {
throw ProjectEditorError.noEditableFiles(editingPath)
}

// To be sure that we are using the same binary of Tuist that invoked `edit`
let tuistPath = AbsolutePath(TuistCommand.processArguments()!.first!)

let workspaceName = "Manifests"

let graph = try projectEditorMapper.map(
Expand All @@ -109,7 +128,8 @@ final class ProjectEditor: ProjectEditing {
configPath: configPath,
dependenciesPath: dependenciesPath,
projectManifests: projectManifests.map(\.1),
pluginManifests: pluginManifests,
editablePluginManifests: editablePluginManifests,
pluginProjectDescriptionHelpersModule: builtPluginHelperModules,
helpers: helpers,
templates: templates,
projectDescriptionPath: projectDescriptionPath
Expand All @@ -120,4 +140,30 @@ final class ProjectEditor: ProjectEditing {
try writer.write(workspace: descriptor)
return descriptor.xcworkspacePath
}

/// - Returns: A list of plugin manifests which should be loaded as part of the project.
private func locateEditablePluginManifests(at path: AbsolutePath, plugins: Plugins) -> [EditablePluginManifest] {
let loadedEditablePluginManifests = plugins.projectDescriptionHelpers
.filter { $0.location == .local }
.map { EditablePluginManifest(name: $0.name, path: $0.path.parentDirectory) }

let localEditablePluginManifests = manifestFilesLocator.locatePluginManifests(at: path)
.map { EditablePluginManifest(name: $0.parentDirectory.basename, path: $0.parentDirectory) }

return Array(Set(loadedEditablePluginManifests + localEditablePluginManifests))
}

/// - Returns: Builds all remote plugins and returns a list of the helper modules.
private func buildRemotePluginModules(
in path: AbsolutePath,
projectDescriptionPath: AbsolutePath,
plugins: Plugins
) throws -> [ProjectDescriptionHelpersModule] {
let loadedPluginHelpers = plugins.projectDescriptionHelpers.filter { $0.location == .remote }
return try projectDescriptionHelpersBuilder.buildPlugins(
at: path,
projectDescriptionSearchPaths: ProjectDescriptionSearchPaths.paths(for: projectDescriptionPath),
projectDescriptionHelperPlugins: loadedPluginHelpers
)
}
}
Loading

0 comments on commit 8ccdbb7

Please sign in to comment.