Skip to content

Commit e6c0a6d

Browse files
consideRatioErik SundellJonas-Puksta-Sensmetryandrius-puksta-sensmetry
authored
Add publish command (#249)
* Add publish command Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com> Signed-off-by: Erik Sundell <erik.sundell@sensmetry.com> Co-authored-by: Erik Sundell <erik.sundell@sensmetry.com> Co-authored-by: Jonas Pukšta <146448971+Jonas-Puksta-Sensmetry@users.noreply.github.com> Co-authored-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
1 parent a57d5c8 commit e6c0a6d

15 files changed

Lines changed: 1434 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ log = { version = "0.4.29", default-features = false }
4545
pubgrub = { version = "0.3.0", default-features = false }
4646
# partialzip = { version = "5.0.0", default-features = false, optional = true }
4747
pyo3 = { version = "0.28.2", default-features = false, features = ["macros", "chrono", "indexmap"], optional = true }
48-
reqwest-middleware = { version = "0.5.1" }
48+
reqwest-middleware = { version = "0.5.1", features = ["multipart"] }
4949
semver = { version = "1.0.27", features = ["serde"] }
5050
serde = { version = "1.0.228", features = ["derive"] }
5151
serde_json = { version = "1.0.149", default-features = false, features = ["preserve_order"] }
@@ -67,7 +67,7 @@ tokio = { version = "1.50.0", default-features = false, features = ["rt", "io-ut
6767
bytes = { version = "1.11.1", default-features = false }
6868
toml_edit = { version = "0.25.4", features = ["serde"] }
6969
globset = { version = "0.4.18", default-features = false }
70-
reqwest = { version = "0.13.2", optional = true, features = ["rustls", "stream"] }
70+
reqwest = { version = "0.13.2", optional = true, features = ["rustls", "stream", "multipart"] }
7171
dunce = "1.0.5"
7272

7373
[dev-dependencies]

core/src/auth.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,32 @@ pub type StandardHTTPAuthentication = RestrictAuthentication<
416416
Unauthenticated,
417417
>;
418418

419+
impl StandardHTTPAuthentication {
420+
/// Extracts the bearer tokens from the configured credential set into a URL-glob map
421+
/// suitable for driving publish-time credential selection. Basic-auth entries are
422+
/// dropped, since publish only supports bearer authentication.
423+
pub fn try_into_publish_bearer_auth_map(
424+
self,
425+
) -> Result<GlobMap<ForceBearerAuth>, globset::Error> {
426+
let mut partial = GlobMapBuilder::new();
427+
428+
// `GlobMap` stores keys and values in parallel vectors; consume `self` so we
429+
// can move bearer tokens into a publish-only map without cloning secrets.
430+
for (key, sequence_auth) in self
431+
.restricted
432+
.keys
433+
.into_iter()
434+
.zip(self.restricted.values.into_iter())
435+
{
436+
if let StandardInnerAuthentication::BearerAuth(inner) = sequence_auth.lower {
437+
partial.add(key, inner);
438+
}
439+
}
440+
441+
partial.build()
442+
}
443+
}
444+
419445
/// Utility to simplify construction of `StandardHTTPAuthentication`
420446
#[derive(Debug, Default, Clone)]
421447
pub struct StandardHTTPAuthenticationBuilder {

core/src/commands/build.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use camino::Utf8Path;
1+
use camino::{Utf8Path, Utf8PathBuf};
22
use thiserror::Error;
33

44
use crate::{
@@ -209,6 +209,19 @@ impl<ProjectReadError: ErrorBound> From<IntoKparError<LocalSrcError>>
209209
}
210210
}
211211

212+
pub fn default_kpar_path<Pr: ProjectRead>(
213+
project: &Pr,
214+
workspace: Option<&Workspace>,
215+
project_path: &Utf8Path,
216+
) -> Result<Utf8PathBuf, KParBuildError<Pr::Error>> {
217+
let mut path = workspace
218+
.map(Workspace::root_path)
219+
.unwrap_or(project_path)
220+
.join("output");
221+
path.push(default_kpar_file_name(project)?);
222+
Ok(path)
223+
}
224+
212225
pub fn default_kpar_file_name<Pr: ProjectRead>(
213226
project: &Pr,
214227
) -> Result<String, KParBuildError<Pr::Error>> {

core/src/commands/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub mod include;
1010
pub mod info;
1111
pub mod init;
1212
pub mod lock;
13+
#[cfg(all(feature = "filesystem", feature = "networking"))]
14+
pub mod publish;
1315
pub mod remove;
1416
#[cfg(feature = "filesystem")]
1517
pub mod root;

0 commit comments

Comments
 (0)