diff --git a/.github/workflows/e2e-cli-master.yaml b/.github/workflows/e2e-cli-master.yaml index ece4d2d14..08179b4af 100644 --- a/.github/workflows/e2e-cli-master.yaml +++ b/.github/workflows/e2e-cli-master.yaml @@ -8,44 +8,44 @@ on: jobs: # TODO: re-enable after 0.8 to check cmd spawning fix - # saas-template-win32: - # name: Create saas starter template (win32) - # runs-on: windows-latest + saas-template-win32: + name: Create saas (win32) + runs-on: windows-latest - # permissions: - # contents: read + permissions: + contents: read - # steps: - # - name: Checkout the code - # uses: actions/checkout@v4 - # - uses: dtolnay/rust-toolchain@stable - # with: - # toolchain: nightly - # - run: | - # cargo install --path . - # working-directory: ./loco-cli - # - run: | - # loco new -n saas -t saas --db sqlite --bg async --assets none - # env: - # ALLOW_IN_GIT_REPO: true - # - run: | - # cargo build - # working-directory: ./saas - # - run: | - # cargo loco routes - # working-directory: ./saas - # - run: | - # cargo loco db migrate - # working-directory: ./saas - # - run: | - # cargo loco generate scaffold movie title:string - # working-directory: ./saas - # - run: | - # cargo loco db migrate - # working-directory: ./saas + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + - run: | + cargo install --path . + working-directory: ./loco-cli + - run: | + loco new -n saas -t saas --db sqlite --bg async --assets none + env: + ALLOW_IN_GIT_REPO: true + - run: | + cargo build + working-directory: ./saas + - run: | + cargo loco routes + working-directory: ./saas + - run: | + cargo loco db migrate + working-directory: ./saas + - run: | + cargo loco generate scaffold movie title:string + working-directory: ./saas + - run: | + cargo loco db migrate + working-directory: ./saas saas-template: - name: Create saas starter template + name: Create saas runs-on: ubuntu-latest permissions: @@ -59,13 +59,13 @@ jobs: toolchain: nightly - run: | cargo install loco-cli - ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=saas LOCO_TEMPLATE=saas loco new + ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=saas LOCO_TEMPLATE=saas loco new --db postgres --bg queue --assets serverside - run: | cargo build working-directory: ./saas rest-api: - name: Create stateless starter template + name: Create rest-api runs-on: ubuntu-latest permissions: @@ -79,13 +79,13 @@ jobs: toolchain: nightly - run: | cargo install loco-cli - ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=restapi LOCO_TEMPLATE=rest-api loco new + ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=restapi LOCO_TEMPLATE=rest-api loco new --db postgres --bg queue - run: | cargo build working-directory: ./restapi lightweight-service: - name: Create stateless starter template + name: Create lightweight-service runs-on: ubuntu-latest permissions: diff --git a/examples/demo/.cargo/config.toml b/examples/demo/.cargo/config.toml index 21b762815..fb921ea85 100644 --- a/examples/demo/.cargo/config.toml +++ b/examples/demo/.cargo/config.toml @@ -1,3 +1,4 @@ [alias] loco = "run --" +loco-tool = "run --bin tool --" playground = "run --example playground" diff --git a/examples/demo/Cargo.toml b/examples/demo/Cargo.toml index 64eb870ab..f66344992 100644 --- a/examples/demo/Cargo.toml +++ b/examples/demo/Cargo.toml @@ -5,6 +5,7 @@ name = "blo" version = "0.1.0" edition = "2021" +default-run = "blo-cli" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -47,6 +48,11 @@ name = "blo-cli" path = "src/bin/main.rs" required-features = [] +[[bin]] +name = "tool" +path = "src/bin/tool.rs" +required-features = [] + [dev-dependencies] serial_test = "3.1.1" rstest = "0.21.0" diff --git a/examples/demo/src/bin/tool.rs b/examples/demo/src/bin/tool.rs new file mode 100644 index 000000000..c0b9e7e7e --- /dev/null +++ b/examples/demo/src/bin/tool.rs @@ -0,0 +1,8 @@ +use blo::app::App; +use loco_rs::cli; +use migration::Migrator; + +#[tokio::main] +async fn main() -> loco_rs::Result<()> { + cli::main::().await +} diff --git a/src/gen/model.rs b/src/gen/model.rs index 8870dd5db..e7d6fa08f 100644 --- a/src/gen/model.rs +++ b/src/gen/model.rs @@ -62,7 +62,7 @@ pub fn generate( let cwd = current_dir()?; let env_map: HashMap<_, _> = std::env::vars().collect(); - let _ = cmd!("cargo", "loco", "db", "migrate",) + let _ = cmd!("cargo", "loco-tool", "db", "migrate",) .stderr_to_stdout() .dir(cwd.as_path()) .full_env(&env_map) @@ -72,7 +72,7 @@ pub fn generate( "failed to run loco db migration. error details: `{err}`", )) })?; - let _ = cmd!("cargo", "loco", "db", "entities",) + let _ = cmd!("cargo", "loco-tool", "db", "entities",) .stderr_to_stdout() .dir(cwd.as_path()) .full_env(&env_map) diff --git a/starters/lightweight-service/.cargo/config.toml b/starters/lightweight-service/.cargo/config.toml index 5ebf03388..bf8cb501c 100644 --- a/starters/lightweight-service/.cargo/config.toml +++ b/starters/lightweight-service/.cargo/config.toml @@ -1,2 +1,3 @@ [alias] loco = "run --" +loco-tool = "run --bin tool --" diff --git a/starters/lightweight-service/Cargo.toml b/starters/lightweight-service/Cargo.toml index 3b7f87496..802a7a173 100644 --- a/starters/lightweight-service/Cargo.toml +++ b/starters/lightweight-service/Cargo.toml @@ -5,6 +5,7 @@ name = "loco_starter_template" version = "0.1.0" edition = "2021" publish = false +default-run = "loco_starter_template-cli" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -24,6 +25,11 @@ name = "loco_starter_template-cli" path = "src/bin/main.rs" required-features = [] +[[bin]] +name = "tool" +path = "src/bin/tool.rs" +required-features = [] + [dev-dependencies] serial_test = "3.1.1" rstest = "0.21.0" diff --git a/starters/lightweight-service/src/bin/tool.rs b/starters/lightweight-service/src/bin/tool.rs new file mode 100644 index 000000000..92061442c --- /dev/null +++ b/starters/lightweight-service/src/bin/tool.rs @@ -0,0 +1,7 @@ +use loco_rs::cli; +use loco_starter_template::app::App; + +#[tokio::main] +async fn main() -> loco_rs::Result<()> { + cli::main::().await +} diff --git a/starters/rest-api/.cargo/config.toml b/starters/rest-api/.cargo/config.toml index 21b762815..fb921ea85 100644 --- a/starters/rest-api/.cargo/config.toml +++ b/starters/rest-api/.cargo/config.toml @@ -1,3 +1,4 @@ [alias] loco = "run --" +loco-tool = "run --bin tool --" playground = "run --example playground" diff --git a/starters/rest-api/Cargo.toml b/starters/rest-api/Cargo.toml index 011eec8d7..744a38ed7 100644 --- a/starters/rest-api/Cargo.toml +++ b/starters/rest-api/Cargo.toml @@ -5,6 +5,7 @@ name = "loco_starter_template" version = "0.1.0" edition = "2021" publish = false +default-run = "loco_starter_template-cli" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -37,6 +38,11 @@ name = "loco_starter_template-cli" path = "src/bin/main.rs" required-features = [] +[[bin]] +name = "tool" +path = "src/bin/tool.rs" +required-features = [] + [dev-dependencies] serial_test = "3.1.1" rstest = "0.21.0" diff --git a/starters/rest-api/src/bin/tool.rs b/starters/rest-api/src/bin/tool.rs new file mode 100644 index 000000000..167386ae6 --- /dev/null +++ b/starters/rest-api/src/bin/tool.rs @@ -0,0 +1,8 @@ +use loco_rs::cli; +use loco_starter_template::app::App; +use migration::Migrator; + +#[tokio::main] +async fn main() -> loco_rs::Result<()> { + cli::main::().await +} diff --git a/starters/saas/.cargo/config.toml b/starters/saas/.cargo/config.toml index 21b762815..fb921ea85 100644 --- a/starters/saas/.cargo/config.toml +++ b/starters/saas/.cargo/config.toml @@ -1,3 +1,4 @@ [alias] loco = "run --" +loco-tool = "run --bin tool --" playground = "run --example playground" diff --git a/starters/saas/Cargo.toml b/starters/saas/Cargo.toml index bb2a83a51..a1c9f069f 100644 --- a/starters/saas/Cargo.toml +++ b/starters/saas/Cargo.toml @@ -5,6 +5,7 @@ name = "loco_starter_template" version = "0.1.0" edition = "2021" publish = false +default-run = "loco_starter_template-cli" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -42,6 +43,11 @@ name = "loco_starter_template-cli" path = "src/bin/main.rs" required-features = [] +[[bin]] +name = "tool" +path = "src/bin/tool.rs" +required-features = [] + [dev-dependencies] serial_test = "3.1.1" rstest = "0.21.0" diff --git a/starters/saas/src/bin/tool.rs b/starters/saas/src/bin/tool.rs new file mode 100644 index 000000000..167386ae6 --- /dev/null +++ b/starters/saas/src/bin/tool.rs @@ -0,0 +1,8 @@ +use loco_rs::cli; +use loco_starter_template::app::App; +use migration::Migrator; + +#[tokio::main] +async fn main() -> loco_rs::Result<()> { + cli::main::().await +}