Skip to content

Hide CLI commands API with package access control #7381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import protocol TSCBasic.WritableByteStream

extension ProgressAnimation {
/// A ninja-like progress animation that adapts to the provided output stream.
@_spi(SwiftPMInternal)
public static func ninja(
package static func ninja(
stream: WritableByteStream,
verbose: Bool
) -> any ProgressAnimationProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import protocol TSCBasic.WritableByteStream

extension ProgressAnimation {
/// A percent-based progress animation that adapts to the provided output stream.
@_spi(SwiftPMInternal)
public static func percent(
package static func percent(
stream: WritableByteStream,
verbose: Bool,
header: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import class TSCBasic.LocalFileOutputByteStream
import protocol TSCBasic.WritableByteStream
import protocol TSCUtility.ProgressAnimationProtocol

@_spi(SwiftPMInternal)
public typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol
package typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol

/// Namespace to nest public progress animations under.
@_spi(SwiftPMInternal)
public enum ProgressAnimation {
package enum ProgressAnimation {
/// Dynamically create a progress animation based on the current stream
/// capabilities and desired verbosity.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,23 @@ final class ThrottledProgressAnimation: ProgressAnimationProtocol {
}
}

@_spi(SwiftPMInternal)
extension ProgressAnimationProtocol {
@_spi(SwiftPMInternal)
public func throttled<C: Clock>(
package func throttled<C: Clock>(
now: @escaping () -> C.Instant,
interval: C.Duration,
clock: C.Type = C.self
) -> some ProgressAnimationProtocol {
ThrottledProgressAnimation(self, now: now, interval: interval, clock: clock)
}

@_spi(SwiftPMInternal)
public func throttled<C: Clock>(
package func throttled<C: Clock>(
clock: C,
interval: C.Duration
) -> some ProgressAnimationProtocol {
self.throttled(now: { clock.now }, interval: interval, clock: C.self)
}

@_spi(SwiftPMInternal)
public func throttled(
package func throttled(
interval: ContinuousClock.Duration
) -> some ProgressAnimationProtocol {
self.throttled(clock: ContinuousClock(), interval: interval)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import Basics
import PackageGraph

@_spi(SwiftPMInternal)
import PackageModel

import OrderedCollections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import PackageGraph
import PackageLoading
import PackageModel

@_spi(SwiftPMInternal)
import SPMBuildCore

#if USE_IMPL_ONLY_IMPORTS
Expand Down
6 changes: 1 addition & 5 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@
//
//===----------------------------------------------------------------------===//

@_spi(SwiftPMInternal)
import Basics

@_spi(SwiftPMInternal)
import Build

import LLBuildManifest
import PackageGraph
import PackageLoading
import PackageModel

@_spi(SwiftPMInternal)
import SPMBuildCore

import SPMLLBuild
Expand All @@ -43,8 +40,7 @@ import DriverSupport
import SwiftDriver
#endif

@_spi(SwiftPMInternal)
public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildSystem, BuildErrorAdviceProvider {
package final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildSystem, BuildErrorAdviceProvider {
/// The delegate used by the build system.
public weak var delegate: SPMBuildCore.BuildSystemDelegate?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
//
//===----------------------------------------------------------------------===//

@_spi(SwiftPMInternal)
import Basics
import Dispatch
import Foundation
import LLBuildManifest
import PackageModel

@_spi(SwiftPMInternal)
import SPMBuildCore

import SPMLLBuild
Expand Down
1 change: 0 additions & 1 deletion Sources/Build/BuildPlan/BuildPlan+Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import struct PackageGraph.ResolvedTarget
import class PackageModel.BinaryTarget
import class PackageModel.ClangTarget

@_spi(SwiftPMInternal)
import class PackageModel.Target

import class PackageModel.SwiftTarget
Expand Down
3 changes: 1 addition & 2 deletions Sources/Build/BuildPlan/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
/// source files as well as directories to which any changes should cause us to reevaluate the build plan.
public let prebuildCommandResults: [ResolvedTarget.ID: [PrebuildCommandResult]]

@_spi(SwiftPMInternal)
public private(set) var derivedTestTargetsMap: [ResolvedProduct.ID: [ResolvedTarget]] = [:]
package private(set) var derivedTestTargetsMap: [ResolvedProduct.ID: [ResolvedTarget]] = [:]

/// Cache for pkgConfig flags.
private var pkgConfigCache = [SystemLibraryTarget: (cFlags: [String], libs: [String])]()
Expand Down
11 changes: 5 additions & 6 deletions Sources/Commands/CommandWorkspaceDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Dispatch
Expand Down Expand Up @@ -215,22 +214,22 @@ final class CommandWorkspaceDelegate: WorkspaceDelegate {
}
}

public func willUpdateDependencies() {
package func willUpdateDependencies() {
self.observabilityScope.emit(debug: "Updating dependencies")
os_signpost(.begin, name: SignpostName.updatingDependencies)
}

public func didUpdateDependencies(duration: DispatchTimeInterval) {
package func didUpdateDependencies(duration: DispatchTimeInterval) {
self.observabilityScope.emit(debug: "Dependencies updated in (\(duration.descriptionInSeconds))")
os_signpost(.end, name: SignpostName.updatingDependencies)
}

public func willResolveDependencies() {
package func willResolveDependencies() {
self.observabilityScope.emit(debug: "Resolving dependencies")
os_signpost(.begin, name: SignpostName.resolvingDependencies)
}

public func didResolveDependencies(duration: DispatchTimeInterval) {
package func didResolveDependencies(duration: DispatchTimeInterval) {
self.observabilityScope.emit(debug: "Dependencies resolved in (\(duration.descriptionInSeconds))")
os_signpost(.end, name: SignpostName.resolvingDependencies)
}
Expand Down Expand Up @@ -267,7 +266,7 @@ final class CommandWorkspaceDelegate: WorkspaceDelegate {
func willLoadManifest(packageIdentity: PackageIdentity, packagePath: AbsolutePath, url: String, version: Version?, packageKind: PackageReference.Kind) {}
}

public extension _SwiftCommand {
package extension _SwiftCommand {
var workspaceDelegateProvider: WorkspaceDelegateProvider {
return {
CommandWorkspaceDelegate(
Expand Down
2 changes: 0 additions & 2 deletions Sources/Commands/PackageCommands/APIDiff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Dispatch
import PackageGraph
import PackageModel
import SourceControl

@_spi(SwiftPMInternal)
import SPMBuildCore

struct DeprecatedAPIDiff: ParsableCommand {
Expand Down
3 changes: 1 addition & 2 deletions Sources/Commands/PackageCommands/ArchiveSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import SourceControl
Expand Down Expand Up @@ -62,7 +61,7 @@ extension SwiftPackageCommand {
}
}

public static func archiveSource(
package static func archiveSource(
at packageDirectory: AbsolutePath,
to archivePath: AbsolutePath,
fileSystem: FileSystem,
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/CompletionCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import ArgumentParser

@_spi(SwiftPMInternal)
import CoreCommands

import var TSCBasic.stdoutStream
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/ComputeChecksum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Workspace
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Workspace
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/Describe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Foundation
Expand Down
2 changes: 0 additions & 2 deletions Sources/Commands/PackageCommands/DumpCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Foundation
import PackageModel

@_spi(SwiftPMInternal)
import SPMBuildCore

import XCBuildSupport
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/EditCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import SourceControl
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/Format.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import PackageModel
Expand Down
3 changes: 1 addition & 2 deletions Sources/Commands/PackageCommands/Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import Workspace
import SPMBuildCore

extension SwiftPackageCommand {
struct Init: SwiftCommand {
public static let configuration = CommandConfiguration(
package static let configuration = CommandConfiguration(
abstract: "Initialize a new package")

@OptionGroup(visibility: .hidden)
Expand Down
2 changes: 0 additions & 2 deletions Sources/Commands/PackageCommands/InstalledPackages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

import ArgumentParser

@_spi(SwiftPMInternal)
import CoreCommands

import Foundation
import PackageModel

@_spi(SwiftPMInternal)
import SPMBuildCore

import TSCBasic
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/Learn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import PackageGraph
Expand Down
2 changes: 0 additions & 2 deletions Sources/Commands/PackageCommands/PluginCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

@_spi(SwiftPMInternal)
import SPMBuildCore

import Dispatch
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/ResetCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import ArgumentParser

@_spi(SwiftPMInternal)
import CoreCommands

extension SwiftPackageCommand {
Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/Resolve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import ArgumentParser

@_spi(SwiftPMInternal)
import CoreCommands

import TSCUtility
Expand Down
5 changes: 2 additions & 3 deletions Sources/Commands/PackageCommands/ShowDependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import ArgumentParser
import Basics

@_spi(SwiftPMInternal)
import CoreCommands

import PackageGraph
Expand Down Expand Up @@ -69,7 +68,7 @@ extension SwiftPackageCommand {
enum ShowDependenciesMode: String, RawRepresentable, CustomStringConvertible, ExpressibleByArgument {
case text, dot, json, flatlist

public init?(rawValue: String) {
package init?(rawValue: String) {
switch rawValue.lowercased() {
case "text":
self = .text
Expand All @@ -84,7 +83,7 @@ extension SwiftPackageCommand {
}
}

public var description: String {
package var description: String {
switch self {
case .text: return "text"
case .dot: return "dot"
Expand Down
Loading