diff --git a/.github/workflows/loco-cli-new.yml b/.github/workflows/loco-cli-new.yml index a8741d4f..b385ebb6 100644 --- a/.github/workflows/loco-cli-new.yml +++ b/.github/workflows/loco-cli-new.yml @@ -5,11 +5,10 @@ on: branches: - master paths: - - 'loco-new/**' + - "loco-new/**" pull_request: paths: - - 'loco-new/**' - + - "loco-new/**" env: RUST_TOOLCHAIN: stable @@ -61,4 +60,5 @@ jobs: - name: Run cargo test run: cargo test --all-features working-directory: ./loco-new - + env: + LOCO_DEV_MODE_PATH: ${{ github.workspace }} diff --git a/loco-new/base_template/Cargo.toml.t b/loco-new/base_template/Cargo.toml.t index 47de1b63..d449a99c 100644 --- a/loco-new/base_template/Cargo.toml.t +++ b/loco-new/base_template/Cargo.toml.t @@ -16,7 +16,7 @@ default-run = "{{settings.module_name}}-cli" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace.dependencies] -loco-rs = { version = "0.12.0" {%- if not settings.features.default_features %}, default-features = false {%- endif %} } +loco-rs = { {{settings.loco_version_text}} {%- if not settings.features.default_features %}, default-features = false {%- endif %} } [dependencies] loco-rs = { workspace = true {% if feature_list | length > 0 %}, features = {{feature_list}}{% endif %} } diff --git a/loco-new/base_template/migration/Cargo.toml b/loco-new/base_template/migration/Cargo.toml index 01ed5e18..cb2ad9b2 100644 --- a/loco-new/base_template/migration/Cargo.toml +++ b/loco-new/base_template/migration/Cargo.toml @@ -10,7 +10,8 @@ path = "src/lib.rs" [dependencies] async-std = { version = "1", features = ["attributes", "tokio1"] } -loco-rs = { version = "0.12.0" } +loco-rs = { workspace = true } + [dependencies.sea-orm-migration] version = "1.1.0" diff --git a/loco-new/src/bin/main.rs b/loco-new/src/bin/main.rs index 7b3650e8..b0b3dc44 100644 --- a/loco-new/src/bin/main.rs +++ b/loco-new/src/bin/main.rs @@ -1,12 +1,12 @@ -use duct::cmd; -use std::process::exit; use std::{ + env, path::{Path, PathBuf}, - process::Command, + process::{exit, Command}, sync::Arc, }; use clap::{Parser, Subcommand}; +use duct::cmd; use loco::{ generator::{executer, extract_default_template, Generator}, settings::Settings, @@ -107,7 +107,12 @@ fn main() -> Result<()> { let executor = executer::FileSystem::new(generator_tmp_folder.as_path(), to.as_path()); - let settings = Settings::from_wizard(&app_name, &user_selection); + let mut settings = Settings::from_wizard(&app_name, &user_selection); + + if let Ok(path) = env::var("LOCO_DEV_MODE_PATH") { + println!("⚠️ NOTICE: working in dev mode, pointing to local Loco on '{path}'"); + settings.loco_version_text = format!(r#"version="*", path="{path}""#); + } let res = match Generator::new(Arc::new(executor), settings).run() { Ok(()) => { diff --git a/loco-new/src/lib.rs b/loco-new/src/lib.rs index 391994fe..70f1be82 100644 --- a/loco-new/src/lib.rs +++ b/loco-new/src/lib.rs @@ -5,6 +5,9 @@ pub mod wizard_opts; pub type Result = std::result::Result; +/// Matching minimal Loco version +pub const LOCO_VERSION: &str = "0.13"; + #[derive(thiserror::Error, Debug)] pub enum Error { #[error("{0}")] diff --git a/loco-new/src/settings.rs b/loco-new/src/settings.rs index 5c3574c7..3767181f 100644 --- a/loco-new/src/settings.rs +++ b/loco-new/src/settings.rs @@ -1,10 +1,11 @@ //! Defines configurable application settings. -use crate::{wizard, wizard_opts}; use heck::ToSnakeCase; use rhai::{CustomType, TypeBuilder}; use serde::{Deserialize, Serialize}; +use crate::{wizard, wizard_opts, LOCO_VERSION}; + /// Represents general application settings. #[derive(Serialize, Deserialize, Clone, Debug, Default, CustomType)] pub struct Settings { @@ -17,6 +18,7 @@ pub struct Settings { pub mailer: bool, pub initializers: Option, pub features: Features, + pub loco_version_text: String, } impl From for Option { @@ -77,6 +79,7 @@ impl Settings { None }, features, + loco_version_text: format!(r#"version = "{LOCO_VERSION}""#), } } }