@@ -9,7 +9,7 @@ import Foundation
99
1010/// Factory for creating the appropriate package manager based on installation method
1111final class PackageManagerFactory {
12- let installationDirectory : URL
12+ private let installationDirectory : URL
1313
1414 init ( installationDirectory: URL ) {
1515 self . installationDirectory = installationDirectory
@@ -37,94 +37,91 @@ final class PackageManagerFactory {
3737 }
3838
3939 /// Parse a registry entry and create the appropriate installation method
40- static func parseRegistryEntry( _ entry: [ String : Any ] ) -> InstallationMethod ? {
41- guard let source = entry [ " source " ] as? [ String : Any ] ,
42- let sourceId = source [ " id " ] as? String else {
43- return nil
44- }
45-
46- let buildInstructions = source [ " build " ] as? [ [ String : Any ] ]
47-
48- // Detect the build tool from the registry entry
49- var buildTool : String ?
50- if let bin = entry [ " bin " ] as? [ String : String ] {
51- let binValues = Array ( bin. values)
52- if !binValues. isEmpty {
53- let value = binValues [ 0 ]
54- if value. hasPrefix ( " cargo: " ) {
55- buildTool = " cargo "
56- } else if value. hasPrefix ( " npm: " ) {
57- buildTool = " npm "
58- } else if value. hasPrefix ( " pypi: " ) {
59- buildTool = " pip "
60- } else if value. hasPrefix ( " gem: " ) {
61- buildTool = " gem "
62- } else if value. hasPrefix ( " golang: " ) {
63- buildTool = " golang "
64- }
65- }
66- }
67-
68- var method = PackageSourceParser . parse ( sourceId, buildInstructions: buildInstructions)
69-
70- if let buildTool = buildTool {
71- switch method {
72- case . standardPackage( var source) :
73- var options = source. options
74- options [ " buildTool " ] = buildTool
75- source = PackageSource (
76- sourceId: source. sourceId,
77- type: source. type,
78- name: source. name,
79- version: source. version,
80- subpath: source. subpath,
81- repositoryUrl: source. repositoryUrl,
82- gitReference: source. gitReference,
83- options: options
84- )
85- method = . standardPackage( source: source)
86- case . sourceBuild( var source, let instructions) :
87- var options = source. options
88- options [ " buildTool " ] = buildTool
89- source = PackageSource (
90- sourceId: source. sourceId,
91- type: source. type,
92- name: source. name,
93- version: source. version,
94- subpath: source. subpath,
95- repositoryUrl: source. repositoryUrl,
96- gitReference: source. gitReference,
97- options: options
98- )
99- method = . sourceBuild( source: source, buildInstructions: instructions)
100- case . binaryDownload( var source, let url) :
101- var options = source. options
102- options [ " buildTool " ] = buildTool
103- source = PackageSource (
104- sourceId: source. sourceId,
105- type: source. type,
106- name: source. name,
107- version: source. version,
108- subpath: source. subpath,
109- repositoryUrl: source. repositoryUrl,
110- gitReference: source. gitReference,
111- options: options
112- )
113- method = . binaryDownload( source: source, url: url)
114- case . unknown:
115- break
116- }
117- }
118- return method
40+ static func parseRegistryEntry( _ entry: RegistryItem ) -> InstallationMethod ? {
41+ // let buildInstructions = source["build"] as? [[String: Any]]
42+ // entry.source.build
43+ //
44+ // // Detect the build tool from the registry entry
45+ // var buildTool: String?
46+ // if let bin = entry.bin {
47+ // let binValues = Array(bin.values)
48+ // if !binValues.isEmpty {
49+ // let value = binValues[0]
50+ // if value.hasPrefix("cargo:") {
51+ // buildTool = "cargo"
52+ // } else if value.hasPrefix("npm:") {
53+ // buildTool = "npm"
54+ // } else if value.hasPrefix("pypi:") {
55+ // buildTool = "pip"
56+ // } else if value.hasPrefix("gem:") {
57+ // buildTool = "gem"
58+ // } else if value.hasPrefix("golang:") {
59+ // buildTool = "golang"
60+ // }
61+ // }
62+ // }
63+ //
64+ // var method = PackageSourceParser.parse(entry.source.id, buildInstructions: buildInstructions)
65+ //
66+ // if let buildTool = buildTool {
67+ // switch method {
68+ // case .standardPackage(var source):
69+ // var options = source.options
70+ // options["buildTool"] = buildTool
71+ // source = PackageSource(
72+ // sourceId: source.sourceId,
73+ // type: source.type,
74+ // name: source.name,
75+ // version: source.version,
76+ // subpath: source.subpath,
77+ // repositoryUrl: source.repositoryUrl,
78+ // gitReference: source.gitReference,
79+ // options: options
80+ // )
81+ // method = .standardPackage(source: source)
82+ // case .sourceBuild(var source, let instructions):
83+ // var options = source.options
84+ // options["buildTool"] = buildTool
85+ // source = PackageSource(
86+ // sourceId: source.sourceId,
87+ // type: source.type,
88+ // name: source.name,
89+ // version: source.version,
90+ // subpath: source.subpath,
91+ // repositoryUrl: source.repositoryUrl,
92+ // gitReference: source.gitReference,
93+ // options: options
94+ // )
95+ // method = .sourceBuild(source: source, buildInstructions: instructions)
96+ // case .binaryDownload(var source, let url):
97+ // var options = source.options
98+ // options["buildTool"] = buildTool
99+ // source = PackageSource(
100+ // sourceId: source.sourceId,
101+ // type: source.type,
102+ // name: source.name,
103+ // version: source.version,
104+ // subpath: source.subpath,
105+ // repositoryUrl: source.repositoryUrl,
106+ // gitReference: source.gitReference,
107+ // options: options
108+ // )
109+ // method = .binaryDownload(source: source, url: url)
110+ // case .unknown:
111+ // break
112+ // }
113+ // }
114+ // return method
115+ return nil
119116 }
120117
121118 /// Install a package from a registry entry
122119 func installFromRegistryEntry( _ entry: [ String : Any ] ) async throws {
123- guard let method = PackageManagerFactory . parseRegistryEntry ( entry) ,
124- let manager = createPackageManager ( for: method) else {
125- throw PackageManagerError . invalidConfiguration
126- }
127- try await manager. install ( method: method)
120+ // guard let method = PackageManagerFactory.parseRegistryEntry(entry),
121+ // let manager = createPackageManager(for: method) else {
122+ // throw PackageManagerError.invalidConfiguration
123+ // }
124+ // try await manager.install(method: method)
128125 }
129126
130127 /// Install a package from a source ID string
0 commit comments