Skip to content

Commit

Permalink
Update README, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
finestructure committed Nov 3, 2023
1 parent bf96105 commit c21b826
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Make sure to properly quote the URL if you are using the `..<` range operator. O

## Adding another dependency

Arena does not currently support adding further depenencies to an existing playground. However, since its dependencies are managed via the `Dependencies` package, you can simply add further entries to its `Package.swift` file - just like you would when extending any other package manifest.
Arena does not currently support adding further dependencies to an existing playground. However, since its dependencies are managed via the `PlaygroundDependencies` package, you can simply add further entries to its `Package.swift` file - just like you would when extending any other package manifest.

Here's what this looks like:

Expand Down
26 changes: 13 additions & 13 deletions Sources/ArenaCore/ArenaCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ extension Arena {
try shellOut(to: .createSwiftPackage(withType: .library), at: dependencyPackagePath)
}

// update Package.swift dependencies
// we need to keep the original description around, because we're going to re-write
// the manifest a second time, after we've resolved the packages. This is because we
// Update Package.swift dependencies
// We need to keep the original description around, because we're going to re-write
// the manifest a second time, after we've resolved the packages. This is because we need
// the manifest to resolve the packages and we need package resolution to be able to
// get PackageInfo, which we'll need to write out the proper dependency incl `name:`
// See https://github.com/finestructure/Arena/issues/33
// and https://github.com/finestructure/Arena/issues/38
let packagePath = dependencyPackagePath/"Package.swift"
let originalPackageDescription = try String(contentsOf: packagePath)
let manifestPath = dependencyPackagePath/"Package.swift"
let originalPackageDescription = try String(contentsOf: manifestPath)
do {
let depsClause = dependencies.map { " " + $0.packageClause() }.joined(separator: ",\n")
let updatedDeps = "package.dependencies = [\n\(depsClause)\n]"
try [originalPackageDescription, updatedDeps].joined(separator: "\n").write(to: packagePath)
try [originalPackageDescription, updatedDeps].joined(separator: "\n").write(to: manifestPath)
}

do {
Expand Down Expand Up @@ -157,13 +157,13 @@ extension Arena {
" " + dep.packageClause(name: pkg.name)
}.joined(separator: ",\n")
let updatedDeps = "package.dependencies = [\n\(depsClause)\n]"
try [originalPackageDescription, updatedDeps].joined(separator: "\n").write(to: packagePath)
try [originalPackageDescription, updatedDeps].joined(separator: "\n").write(to: manifestPath)
}

// update Package.swift targets
do {
let packagePath = dependencyPackagePath/"Package.swift"
let packageDescription = try String(contentsOf: packagePath)
let manifestPath = dependencyPackagePath/"Package.swift"
let packageDescription = try String(contentsOf: manifestPath)
let updatedTgts = """
package.targets = [
.target(name: "\(depdencyPackageName)",
Expand All @@ -173,20 +173,20 @@ extension Arena {
)
]
"""
try [packageDescription, updatedTgts].joined(separator: "\n").write(to: packagePath)
try [packageDescription, updatedTgts].joined(separator: "\n").write(to: manifestPath)
}

// update Package.swift platforms
do {
let packagePath = dependencyPackagePath/"Package.swift"
let packageDescription = try String(contentsOf: packagePath)
let manifestPath = dependencyPackagePath/"Package.swift"
let packageDescription = try String(contentsOf: manifestPath)
let platforms = packageInfo.compactMap {
$0.1.platforms
.map(PackageGenerator.Platforms.init(platforms:))
}
try [packageDescription,
PackageGenerator.platformsClause(platforms)]
.joined(separator: "\n").write(to: packagePath)
.joined(separator: "\n").write(to: manifestPath)
}

// create workspace
Expand Down

0 comments on commit c21b826

Please sign in to comment.