feat: add skeleton of sourcemap commands (#29578)

This commit is contained in:
Oliver Browne
2025-03-06 11:24:40 +00:00
committed by GitHub
parent 3beb781b12
commit 612caebb9d
2 changed files with 46 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
pub mod auth;
pub mod upload;
use clap::{Parser, Subcommand};
use crate::error::CapturedError;
@@ -18,6 +19,36 @@ pub struct Cli {
pub enum Commands {
/// Authenticate with PostHog, storing a personal API token locally
Login,
#[command(about = "Upload a directory of bundled chunks to PostHog")]
Sourcemap {
#[command(subcommand)]
cmd: SourcemapCommand,
},
}
#[derive(Subcommand)]
pub enum SourcemapCommand {
/// Inject each bundled chunk with a posthog chunk ID
Inject {
/// The directory containing the bundled chunks
#[arg(short, long)]
directory: String,
/// Where to write the injected chunks. If not provided, the original files will be overwritten
#[arg(short, long)]
output: Option<String>,
},
/// Upload the bundled chunks to PostHog
Upload {
/// The directory containing the bundled chunks
#[arg(short, long)]
directory: String,
/// The build ID to associate with the uploaded chunks
#[arg(short, long)]
build: Option<String>,
},
}
impl Cli {
@@ -28,6 +59,16 @@ impl Cli {
Commands::Login => {
auth::login()?;
}
Commands::Sourcemap { cmd } => match cmd {
SourcemapCommand::Inject {
directory: _,
output: _,
} => return Ok(()),
SourcemapCommand::Upload {
directory: _,
build: _,
} => return Ok(()),
},
}
Ok(())

View File

@@ -0,0 +1,5 @@
use anyhow::Error;
pub fn upload() -> Result<(), Error> {
Ok(())
}