From fb4fcc1b8d5bf5740bf160ec63003bfce1ebac12 Mon Sep 17 00:00:00 2001 From: all123all Date: Mon, 13 Nov 2023 15:58:18 +0000 Subject: [PATCH 1/3] add install pinia --- store/store.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 store/store.js diff --git a/store/store.js b/store/store.js new file mode 100644 index 0000000..01b656d --- /dev/null +++ b/store/store.js @@ -0,0 +1,4 @@ +import { defineStore } from 'pinia' +export const useAlertsStore = defineStore('alerts', { + // other options... +}) From 0366bc7c084b1692ab0f0d2ea466d51884b8894f Mon Sep 17 00:00:00 2001 From: all123all Date: Mon, 13 Nov 2023 21:37:55 +0000 Subject: [PATCH 2/3] update main.rs --- src/main.rs | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 93e0003..2eadbda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use std::io; use std::num::ParseIntError; +use std::process::Command; fn main() { let mut parsed_input: Result; @@ -37,7 +38,46 @@ fn print_options() { } fn install_pinia() { - println!("Installing Pinia..."); + println!("Installing Pinia..."); + + let npm_install = Command::new("npm") + .arg("install") + .arg("pinia") + .spawn(); + + match npm_install { + Ok(mut child) => { + let status = child.wait().expect("Failed to wait for npm install"); + + if status.success() { + let mkdir_status = Command::new("mkdir") + .arg("store") + .status() + .expect("Failed to execute mkdir command"); + + if mkdir_status.success() { + let mv_status = Command::new("mv") + .arg("store.js") + .arg("./store/store.js") + .status() + .expect("Failed to execute mv command"); + + if mv_status.success() { + println!("Pinia successfully installed!"); + } else { + println!("Failed to move store.js. mv command failed."); + } + } else { + println!("Failed to create the 'store' directory. mkdir command failed."); + } + } else { + println!("Failed to install Pinia. npm install command failed."); + } + } + Err(e) => { + println!("Failed to run npm install: {}", e); + } + } } fn install_husky() { From f713d29f5a1dc819883d9229d493a6ea55d4171a Mon Sep 17 00:00:00 2001 From: all123all Date: Tue, 14 Nov 2023 10:04:35 +0000 Subject: [PATCH 3/3] separate module --- src/main.rs | 44 +++-------------------------------- src/pinia.rs | 44 +++++++++++++++++++++++++++++++++++ src/pinia/App.vue | 3 +++ {store => tmp/pinia}/store.js | 0 4 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 src/pinia.rs create mode 100644 src/pinia/App.vue rename {store => tmp/pinia}/store.js (100%) diff --git a/src/main.rs b/src/main.rs index 2eadbda..e6737bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use std::io; use std::num::ParseIntError; -use std::process::Command; + +mod pinia; fn main() { let mut parsed_input: Result; @@ -38,46 +39,7 @@ fn print_options() { } fn install_pinia() { - println!("Installing Pinia..."); - - let npm_install = Command::new("npm") - .arg("install") - .arg("pinia") - .spawn(); - - match npm_install { - Ok(mut child) => { - let status = child.wait().expect("Failed to wait for npm install"); - - if status.success() { - let mkdir_status = Command::new("mkdir") - .arg("store") - .status() - .expect("Failed to execute mkdir command"); - - if mkdir_status.success() { - let mv_status = Command::new("mv") - .arg("store.js") - .arg("./store/store.js") - .status() - .expect("Failed to execute mv command"); - - if mv_status.success() { - println!("Pinia successfully installed!"); - } else { - println!("Failed to move store.js. mv command failed."); - } - } else { - println!("Failed to create the 'store' directory. mkdir command failed."); - } - } else { - println!("Failed to install Pinia. npm install command failed."); - } - } - Err(e) => { - println!("Failed to run npm install: {}", e); - } - } + pinia::install(); } fn install_husky() { diff --git a/src/pinia.rs b/src/pinia.rs new file mode 100644 index 0000000..9cb0dc4 --- /dev/null +++ b/src/pinia.rs @@ -0,0 +1,44 @@ +use std::process::Command; + +pub fn install() { + println!("Installing Pinia..."); + + let npm_install = Command::new("npm") + .arg("install") + .arg("pinia") + .spawn(); + + match npm_install { + Ok(mut child) => { + let status = child.wait().expect("Failed to wait for npm install"); + + if status.success() { + let mkdir_status = Command::new("mkdir") + .arg("store") + .status() + .expect("Failed to execute mkdir command"); + + if mkdir_status.success() { + let mv_status = Command::new("mv") + .arg("store.js") + .arg("./store/store.js") + .status() + .expect("Failed to execute mv command"); + + if mv_status.success() { + println!("Pinia successfully installed!"); + } else { + println!("Failed to move store.js. mv command failed."); + } + } else { + println!("Failed to create the 'store' directory. mkdir command failed."); + } + } else { + println!("Failed to install Pinia. npm install command failed."); + } + } + Err(e) => { + println!("Failed to run npm install: {}", e); + } + } +} diff --git a/src/pinia/App.vue b/src/pinia/App.vue new file mode 100644 index 0000000..aa36e1c --- /dev/null +++ b/src/pinia/App.vue @@ -0,0 +1,3 @@ + diff --git a/store/store.js b/tmp/pinia/store.js similarity index 100% rename from store/store.js rename to tmp/pinia/store.js