MCPcopy Create free account
hub / github.com/codename-co/stack / run

Function run

packages/app/src-tauri/src/cli.rs:131–214  ·  view source on GitHub ↗

Runs a software stack from a stack bundle. # Arguments `bundle` - A string slice that holds the path to the stack bundle file.

(bundle: &str)

Source from the content-addressed store, hash-verified

129///
130/// * `bundle` - A string slice that holds the path to the stack bundle file.
131pub async fn run(bundle: &str) {
132 let bundle_path = if bundle.starts_with("http://")
133 || bundle.starts_with("https://")
134 || bundle.starts_with("file://")
135 {
136 debug!("Downloading bundle: {}", bundle);
137
138 download_file(bundle)
139 .await
140 .expect("Failed to download bundle file")
141 } else {
142 PathBuf::from(bundle)
143 };
144
145 debug!("bundle_path: {:?}", bundle_path);
146
147 // Check if file exists before proceeding
148 if !bundle_path.exists() {
149 error!("Bundle file not found: {:?}", bundle_path);
150 return;
151 }
152
153 let file = match File::open(&bundle_path) {
154 Ok(f) => f,
155 Err(e) => {
156 error!("Failed to open bundle file: {}", e);
157 return;
158 }
159 };
160
161 debug!("Reading stack file: {:?}", file);
162 let gz = MultiGzDecoder::new(file);
163 let temp_dir = tempdir().expect("Failed to create temp dir").into_path();
164
165 // Use a subdirectory to keep things cleaner
166 let extract_dir = temp_dir.join("bundle_extract");
167 debug!("Extracting to: {:?}", extract_dir);
168 if let Err(e) = fs::create_dir_all(&extract_dir) {
169 error!("Failed to create extract directory: {:?}", e);
170 return;
171 }
172
173 let mut archive = Archive::new(gz);
174 if let Err(e) = archive.unpack(&extract_dir) {
175 error!("Failed to unpack bundle: {:?}", e);
176 return;
177 }
178 debug!("Extraction complete: {:?}", extract_dir);
179
180 // Now we can access the metadata file
181 let config_path = extract_dir.join("stack.yaml");
182 debug!("Loading stack metadata from: {:?}", config_path);
183 let config = load_stack_manifest(config_path.as_path());
184
185 debug!("Stack metadata: {:?}", config);
186
187 // Get the stack name from the original filename without .stack extension
188 let bundle_name = config["slug"]

Callers

nothing calls this directly

Calls 4

download_fileFunction · 0.85
load_stack_manifestFunction · 0.85
guess_flavorFunction · 0.85
run_stackFunction · 0.85

Tested by

no test coverage detected