WIP install command

This commit is contained in:
SkyfallWasTaken 2024-07-29 15:43:52 +01:00
parent 32845b9006
commit f59bb4def4
9 changed files with 44 additions and 11 deletions

View file

@ -15,6 +15,7 @@ tokio = { version = "1.38.0", features = [
dinopkg-package-json = { path = "../dinopkg-package-json", features = [
"tokio",
] }
dinopkg-npm-registry = { path = "../dinopkg-npm-registry" }
exitcode = "1.1.2"
env_logger = "0.11.3"
dialoguer = "0.11.0"
@ -25,3 +26,4 @@ serde_json = "1.0.120"
syntect = "5.2.0"
validate_package_name = { path = "../validate_package_name" }
spdx = "0.10.6"
reqwest = "0.12.5"

View file

@ -1,6 +1,7 @@
use clap::{Parser, Subcommand};
pub mod init;
pub mod install;
pub mod run;
#[derive(Parser)]
@ -26,4 +27,11 @@ pub enum Command {
/// Create a package.json file
#[command(aliases = ["create", "innit"])]
Init,
/// Installs dependencies for `package.json`
#[command(aliases = ["i", "add"])]
Install {
/// The name of the package to install
name: String,
},
}

View file

@ -4,7 +4,7 @@ use camino::Utf8PathBuf;
use color_eyre::eyre::eyre;
use color_eyre::Result;
use dialoguer::{theme::ColorfulTheme, Confirm, Input};
use dinopkg_package_json::PackageJson;
use dinopkg_package_json::{PackageJson, AuthorObjOrString};
use gix_config::File as GitConfigFile;
use maplit::hashmap;
use owo_colors::OwoColorize;
@ -96,7 +96,7 @@ pub async fn init() -> Result<()> {
let package_json = PackageJson {
name: package_name,
version,
author: Some(author),
author: Some(AuthorObjOrString::String(author)),
repository: Some(git_repository),
license: Some(license),
description: Some(description),

View file

@ -0,0 +1,10 @@
use color_eyre::Result;
use dinopkg_npm_registry::PackageInfo;
pub async fn install_cmd(name: String) -> Result<()> {
let client = reqwest::Client::new();
let package_info = PackageInfo::from_name(&name, &client).await?;
dbg!(package_info);
Ok(())
}

View file

@ -19,6 +19,7 @@ async fn main() -> Result<()> {
Command::Run { script_name } => command::run::run(script_name).await?,
Command::Test => command::run::run(Some("test".into())).await?,
Command::Init => command::init::init().await?,
Command::Install { name } => command::install::install_cmd(name).await?,
}
Ok(())
}