flowey_lib_common/
ado_task_npm_authenticate.rs1use flowey::node::prelude::*;
7
8flowey_request! {
9 pub enum Request {
10 UsingNpmrc(ReadVar<PathBuf>),
12 Done(WriteVar<SideEffect>),
14 }
15}
16
17new_flow_node!(struct Node);
18
19impl FlowNode for Node {
20 type Request = Request;
21
22 fn imports(_ctx: &mut ImportCtx<'_>) {}
23
24 fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
25 let mut npmrcs = Vec::new();
26 let mut done = Vec::new();
27
28 for req in requests {
29 match req {
30 Request::UsingNpmrc(v) => npmrcs.push(v),
31 Request::Done(v) => done.push(v),
32 }
33 }
34
35 let did_run = npmrcs
36 .into_iter()
37 .map(|npmrc| {
38 let npmrc = npmrc.map(ctx, |x| x.display().to_string());
39 let (did_run, claim_did_run) = ctx.new_var();
40 ctx.emit_ado_step("Authenticate npm", move |ctx| {
41 claim_did_run.claim(ctx);
42 let npmrc = npmrc.claim(ctx);
43 move |rt| {
44 let npmrc = rt.get_var(npmrc);
45 let npmrc = npmrc.as_raw_var_name();
46
47 format!(
48 r#"
49 - task: npmAuthenticate@0
50 inputs:
51 workingFile: $({npmrc})
52 "#
53 )
54 }
55 });
56 did_run
57 })
58 .collect::<Vec<_>>();
59
60 ctx.emit_side_effect_step(did_run, done);
61
62 Ok(())
63 }
64}