Skip to content

Commit

Permalink
feat: SPM(Swift Package Manager) backend (#2241)
Browse files Browse the repository at this point in the history
* first simple implementation

* get executables list and work with them only

* rename SpmForge -> SPMBackend

* Package description deserialization with serde

* copy build artifacts

* refactoring

* spm e2e tests

* use project git client

* refactoring

* fix repo url name usage; fix git checkout

* update test assert

* fix lint violations

* fix package version in e2e test

* add spm repo parsing unit tests

* Better error message

Co-authored-by: Pedro Piñera Buendía <[email protected]>

* reformat

---------

Co-authored-by: Pedro Piñera Buendía <[email protected]>
  • Loading branch information
kattouf and pepicrft authored Jun 3, 2024
1 parent e22d5a0 commit 8d37aab
Show file tree
Hide file tree
Showing 6 changed files with 408 additions and 0 deletions.
21 changes: 21 additions & 0 deletions e2e/backend/test_spm_slow
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Enable test when `Swift` installation will be fixed on Linux (for docker run)
# Wait for https://github.com/jdx/mise/pull/1708
exit 0

mise use swift

assert "mise x spm:nicklockwood/[email protected] -- swiftformat --version" "0.53.10"
assert "mise x spm:https://github.com/nicklockwood/[email protected] -- swiftformat --version" "0.53.10"

# test package with resources (`templates list` command depends on resources being installed)
assert "mise x spm:SwiftGen/[email protected] --verbose -- swiftgen templates list --only colors" "colors:
- literals-swift4
- literals-swift5
- swift4
- swift5
---
You can also specify custom templates by path, using \`templatePath\` instead of \`templateName\`.
For more information, see the documentation on GitHub or use \`swiftgen template doc\`.
"
4 changes: 4 additions & 0 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub mod cargo;
pub mod go;
pub mod npm;
pub mod pipx;
pub mod spm;
pub mod ubi;

pub type ABackend = Arc<dyn Backend>;
Expand Down Expand Up @@ -65,6 +66,7 @@ pub enum BackendType {
Go,
Npm,
Pipx,
Spm,
Ubi,
}

Expand Down Expand Up @@ -107,6 +109,7 @@ fn list_installed_backends() -> eyre::Result<BackendList> {
BackendType::Npm => Arc::new(npm::NPMBackend::new(fa.name)) as ABackend,
BackendType::Go => Arc::new(go::GoBackend::new(fa.name)) as ABackend,
BackendType::Pipx => Arc::new(pipx::PIPXBackend::new(fa.name)) as ABackend,
BackendType::Spm => Arc::new(spm::SPMBackend::new(fa.name)) as ABackend,
BackendType::Ubi => Arc::new(ubi::UbiBackend::new(fa.name)) as ABackend,
}
})
Expand Down Expand Up @@ -138,6 +141,7 @@ pub fn get(fa: &BackendArg) -> ABackend {
BackendType::Npm => Arc::new(npm::NPMBackend::new(name)),
BackendType::Go => Arc::new(go::GoBackend::new(name)),
BackendType::Pipx => Arc::new(pipx::PIPXBackend::new(name)),
BackendType::Spm => Arc::new(spm::SPMBackend::new(name)),
BackendType::Ubi => Arc::new(ubi::UbiBackend::new(name)),
})
.clone()
Expand Down
Loading

0 comments on commit 8d37aab

Please sign in to comment.