├── .buildnumber
├── docs
├── api
│ ├── .lock
│ ├── cli
│ │ ├── runner
│ │ │ └── sidebar-items.js
│ │ ├── cli
│ │ │ └── sidebar-items.js
│ │ ├── logger
│ │ │ └── sidebar-items.js
│ │ ├── cli_commands
│ │ │ ├── list_steps
│ │ │ │ └── sidebar-items.js
│ │ │ ├── print_steps
│ │ │ │ └── sidebar-items.js
│ │ │ └── sidebar-items.js
│ │ ├── completion
│ │ │ └── sidebar-items.js
│ │ ├── cli_parser
│ │ │ └── sidebar-items.js
│ │ ├── config
│ │ │ └── sidebar-items.js
│ │ ├── error
│ │ │ └── sidebar-items.js
│ │ ├── sidebar-items.js
│ │ └── types
│ │ │ └── sidebar-items.js
│ ├── makers
│ │ ├── sidebar-items.js
│ │ ├── all.html
│ │ └── fn.get_name.html
│ ├── cargo_make
│ │ ├── sidebar-items.js
│ │ ├── all.html
│ │ └── fn.get_name.html
│ ├── search.desc
│ │ ├── makers
│ │ │ └── makers-desc-0-.js
│ │ └── cargo_make
│ │ │ └── cargo_make-desc-0-.js
│ ├── crates.js
│ ├── static.files
│ │ ├── favicon-32x32-6580c154.png
│ │ ├── FiraSans-Medium-e1aa3f0a.woff2
│ │ ├── FiraSans-Regular-0fe48ade.woff2
│ │ ├── SourceSerif4-It-ca3b17ed.ttf.woff2
│ │ ├── NanumBarunGothic-13b3dcba.ttf.woff2
│ │ ├── SourceCodePro-It-fc8b9304.ttf.woff2
│ │ ├── SourceSerif4-Bold-6d4fd4c0.ttf.woff2
│ │ ├── SourceSerif4-Regular-6b053e98.ttf.woff2
│ │ ├── SourceCodePro-Regular-8badfe75.ttf.woff2
│ │ ├── SourceCodePro-Semibold-aa29a496.ttf.woff2
│ │ ├── LICENSE-MIT-23f18e03.txt
│ │ ├── normalize-9960930a.css
│ │ ├── COPYRIGHT-eb44e4cf.txt
│ │ └── scrape-examples-d508a8a9.js
│ ├── trait.impl
│ │ ├── core
│ │ │ ├── hash
│ │ │ │ └── trait.Hash.js
│ │ │ ├── ops
│ │ │ │ └── deref
│ │ │ │ │ ├── trait.Deref.js
│ │ │ │ │ └── trait.DerefMut.js
│ │ │ ├── convert
│ │ │ │ ├── trait.AsRef.js
│ │ │ │ └── trait.Into.js
│ │ │ ├── marker
│ │ │ │ └── trait.Copy.js
│ │ │ ├── fmt
│ │ │ │ └── trait.Display.js
│ │ │ └── cmp
│ │ │ │ └── trait.Eq.js
│ │ └── std
│ │ │ └── process
│ │ │ └── trait.Termination.js
│ ├── src-files.js
│ ├── settings.html
│ └── help.html
├── index.md
├── Gemfile
├── favicon.ico
├── vscode-example
│ ├── settings.json
│ ├── launch.json
│ └── tasks.json
├── _config.yml
├── _includes
│ ├── main.html
│ └── README.md
├── api.html
└── assets
│ ├── badges
│ └── cargo-make.svg
│ └── css
│ └── style.scss
├── examples
├── profile.env
├── workspace-emulation2
│ ├── python1
│ │ └── .gitkeep
│ ├── rust1
│ │ ├── Cargo.toml
│ │ └── src
│ │ │ └── lib.rs
│ ├── rust2
│ │ ├── Cargo.toml
│ │ └── src
│ │ │ └── lib.rs
│ └── Makefile.toml
├── script.sh
├── cargo-make
│ ├── cache.toml
│ └── config.toml
├── load_only_undefined.env
├── min_version.toml
├── skip_core_tasks.toml
├── workspace
│ ├── Cargo.toml
│ ├── common.toml
│ ├── member1
│ │ ├── Cargo.toml
│ │ ├── .cargo
│ │ │ └── config.toml
│ │ ├── Makefile.toml
│ │ └── src
│ │ │ └── lib.rs
│ ├── member2
│ │ ├── Cargo.toml
│ │ ├── src
│ │ │ └── lib.rs
│ │ └── Makefile.toml
│ ├── member3
│ │ ├── Cargo.toml
│ │ ├── Makefile.toml
│ │ └── src
│ │ │ └── lib.rs
│ └── Makefile.toml
├── extending.toml
├── override_core.toml
├── workspace2
│ ├── member1
│ │ ├── Cargo.toml
│ │ └── Makefile.toml
│ ├── member
│ │ └── member3
│ │ │ ├── Cargo.toml
│ │ │ └── Makefile.toml
│ ├── Cargo.toml
│ ├── member2
│ │ ├── Cargo.toml
│ │ └── Makefile.toml
│ └── Makefile.toml
├── extending-env.toml
├── extends_not_found.toml
├── workspace-inherit
│ ├── member1
│ │ ├── src
│ │ │ └── main.rs
│ │ ├── Cargo.toml
│ │ └── Makefile.toml
│ ├── Cargo.toml
│ └── Makefile.toml
├── workspace_crate
│ ├── Cargo.toml
│ └── src
│ │ └── lib.rs
├── cross_platform_shell.toml
├── perl.toml
├── clear.toml
├── python.toml
├── extends_optional_not_found.toml
├── files
│ └── extending.toml
├── javascript.toml
├── performance_tuning.toml
├── fork.toml
├── modify_core_tasks.toml
├── test.env
├── cross-file.toml
├── ignore_errors.toml
├── dependencies.toml
├── workspace-emulation
│ ├── member2
│ │ ├── Cargo.toml
│ │ └── Makefile.toml
│ ├── member1
│ │ └── Makefile.toml
│ ├── member
│ │ └── member3
│ │ │ └── Makefile.toml
│ └── Makefile.toml
├── alias.toml
├── deprecated.toml
├── kcov.toml
├── env2.toml
├── private.toml
├── shebang.toml
├── php.toml
├── on_error.toml
├── install_disabled.toml
├── legacy_migration.toml
├── platform_override.toml
├── skip_tasks_pattern.toml
├── simple-example.toml
├── task_extend.toml
├── extends_list.toml
├── varargs.toml
├── watch.toml
├── plugin_workspace_parallel.toml
├── run_task.toml
├── subcommands.toml
├── plugin_workspace_emulation.toml
├── script.toml
├── plugin_rust_env.toml
├── cwd.toml
├── install.toml
├── rust-script.toml
├── plugin_powershell.toml
├── profile.toml
├── toolchain.toml
├── plugin.toml
├── functions.toml
├── duckscript.toml
└── plugin_dockerize.toml
├── src
├── lib
│ ├── test
│ │ ├── makefiles
│ │ │ ├── empty.toml
│ │ │ ├── broken_makefile.toml
│ │ │ ├── test1.toml
│ │ │ ├── test2.toml
│ │ │ ├── env-reorder-extended.toml
│ │ │ ├── broken_makefile_minversion.toml
│ │ │ ├── task_extend.toml
│ │ │ ├── env-reorder.toml
│ │ │ ├── env-extended.toml
│ │ │ └── env.toml
│ │ ├── workspace2
│ │ │ ├── target_dir
│ │ │ │ ├── src
│ │ │ │ │ └── lib.rs
│ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ ├── Makefile.toml
│ │ │ │ └── Cargo.toml
│ │ │ ├── target_dir_and_triple
│ │ │ │ ├── src
│ │ │ │ │ └── lib.rs
│ │ │ │ ├── Makefile.toml
│ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ ├── Cargo.toml
│ │ │ │ └── x86_64-pc-windows-msvc.json
│ │ │ ├── env_target_dir_and_triple
│ │ │ │ ├── src
│ │ │ │ │ └── lib.rs
│ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ ├── Makefile.toml
│ │ │ │ ├── Cargo.toml
│ │ │ │ └── x86_64-pc-windows-msvc.json
│ │ │ ├── member2
│ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ └── Makefile.toml
│ │ │ ├── member
│ │ │ │ └── member3
│ │ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ │ └── Makefile.toml
│ │ │ ├── member1
│ │ │ │ └── Makefile.toml
│ │ │ ├── member4
│ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ ├── Makefile.toml
│ │ │ │ └── x86_64-pc-windows-msvc.json
│ │ │ ├── Cargo.toml
│ │ │ └── Makefile.toml
│ │ ├── test_files
│ │ │ ├── text_file.txt
│ │ │ ├── env.env
│ │ │ ├── profile.env
│ │ │ └── .crates.toml
│ │ ├── cargo
│ │ │ ├── invalid_config.toml
│ │ │ └── config.toml
│ │ ├── workspace3
│ │ │ ├── Cargo.toml
│ │ │ ├── members
│ │ │ │ ├── nocargo
│ │ │ │ │ └── Makefile.toml
│ │ │ │ ├── member
│ │ │ │ │ └── member3
│ │ │ │ │ │ ├── Makefile.toml
│ │ │ │ │ │ └── .cargo
│ │ │ │ │ │ └── config.toml
│ │ │ │ ├── member1
│ │ │ │ │ ├── Cargo.toml
│ │ │ │ │ └── Makefile.toml
│ │ │ │ ├── member2
│ │ │ │ │ ├── .cargo
│ │ │ │ │ │ └── config.toml
│ │ │ │ │ ├── Cargo.toml
│ │ │ │ │ └── Makefile.toml
│ │ │ │ └── member4
│ │ │ │ │ ├── Cargo.toml
│ │ │ │ │ └── Makefile.toml
│ │ │ └── Makefile.toml
│ │ ├── workspace1
│ │ │ ├── member1
│ │ │ │ ├── Cargo.toml
│ │ │ │ ├── Makefile.toml
│ │ │ │ ├── .cargo
│ │ │ │ │ └── config.toml
│ │ │ │ └── src
│ │ │ │ │ └── lib.rs
│ │ │ ├── member2
│ │ │ │ ├── Cargo.toml
│ │ │ │ ├── Makefile.toml
│ │ │ │ └── src
│ │ │ │ │ └── lib.rs
│ │ │ ├── Cargo.toml
│ │ │ ├── member
│ │ │ │ └── member3
│ │ │ │ │ └── Makefile.toml
│ │ │ └── Makefile.toml
│ │ └── workspace-inherit
│ │ │ ├── member1
│ │ │ ├── src
│ │ │ │ └── main.rs
│ │ │ └── Cargo.toml
│ │ │ └── Cargo.toml
│ ├── cli_commands
│ │ └── mod.rs
│ ├── plugin
│ │ ├── mod.rs
│ │ ├── types_test.rs
│ │ ├── types.rs
│ │ ├── sdk
│ │ │ ├── cm_plugin_force_plugin_clear.rs
│ │ │ ├── mod.rs
│ │ │ ├── cm_plugin_force_plugin_set.rs
│ │ │ ├── cm_plugin_check_task_condition.rs
│ │ │ ├── cm_plugin_run_task.rs
│ │ │ ├── cm_plugin_run_custom_task.rs
│ │ │ ├── cm_plugin_check_task_condition_test.rs
│ │ │ └── cm_plugin_run_task_test.rs
│ │ └── descriptor.rs
│ ├── descriptor
│ │ ├── makefiles
│ │ │ ├── base.toml
│ │ │ ├── mod.rs
│ │ │ ├── rust-wasm.toml
│ │ │ ├── toml.toml
│ │ │ ├── build-file.toml
│ │ │ ├── beta.toml
│ │ │ ├── git.toml
│ │ │ └── deprecated.toml
│ │ ├── cargo_alias_test.rs
│ │ ├── descriptor_deserializer_test.rs
│ │ ├── descriptor_deserializer.rs
│ │ └── cargo_alias.rs
│ ├── scriptengine
│ │ ├── os_script.rs
│ │ ├── shell_to_batch_test.rs
│ │ ├── duck_script
│ │ │ └── sdk
│ │ │ │ ├── mod.rs
│ │ │ │ └── cm_run_task.rs
│ │ ├── os_script_test.rs
│ │ ├── shell_to_batch.rs
│ │ ├── script_utils_test.rs
│ │ ├── generic_script.rs
│ │ └── generic_script_test.rs
│ ├── recursion_level_test.rs
│ ├── functions
│ │ ├── remove_empty_func.rs
│ │ ├── remove_empty_func_test.rs
│ │ ├── getat_func.rs
│ │ ├── trim_func.rs
│ │ ├── split_func.rs
│ │ ├── decode_func.rs
│ │ └── trim_func_test.rs
│ ├── recursion_level.rs
│ ├── cache_test.rs
│ ├── storage_test.rs
│ ├── storage.rs
│ ├── config.rs
│ ├── profile.rs
│ ├── proxy_task.rs
│ ├── config_test.rs
│ ├── mod.rs
│ └── time_summary.rs
├── main_test.rs
├── makers_test.rs
├── makers.rs
└── main.rs
├── .gitattributes
├── .rusty-hook.toml
├── .github
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── workflows
│ ├── cron.yml
│ ├── ci.yml
│ └── publish.yml
└── CONTRIBUTING.md
├── .gitignore
├── .editorconfig
├── .typos.toml
├── extra
└── shell
│ └── makers-completion.bash
└── Cargo.toml
/.buildnumber:
--------------------------------------------------------------------------------
1 | 279
--------------------------------------------------------------------------------
/docs/api/.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/examples/profile.env:
--------------------------------------------------------------------------------
1 | PROFILE_ENV=true
--------------------------------------------------------------------------------
/src/lib/test/makefiles/empty.toml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/workspace-emulation2/python1/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir/src/lib.rs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.ico binary
2 | *.woff binary
3 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 | {% include main.html %}
--------------------------------------------------------------------------------
/examples/script.sh:
--------------------------------------------------------------------------------
1 | echo hello world from script file
--------------------------------------------------------------------------------
/src/lib/test/test_files/text_file.txt:
--------------------------------------------------------------------------------
1 | text 1
2 | text 2
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir_and_triple/src/lib.rs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/examples/cargo-make/cache.toml:
--------------------------------------------------------------------------------
1 | last_update_check = 1000
2 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/env_target_dir_and_triple/src/lib.rs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lib/test/cargo/invalid_config.toml:
--------------------------------------------------------------------------------
1 |
2 | [alias]
3 | bad = 10
4 |
--------------------------------------------------------------------------------
/examples/load_only_undefined.env:
--------------------------------------------------------------------------------
1 | new_env=yes
2 | ENV1_TEST=defaults
3 |
--------------------------------------------------------------------------------
/examples/min_version.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | min_version = "0.20.1"
4 |
--------------------------------------------------------------------------------
/docs/api/cli/runner/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["run"]};
--------------------------------------------------------------------------------
/examples/skip_core_tasks.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
--------------------------------------------------------------------------------
/docs/api/cli/cli/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["run","run_cli"]};
--------------------------------------------------------------------------------
/docs/api/makers/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["get_name","main"]};
--------------------------------------------------------------------------------
/src/lib/test/workspace3/Cargo.toml:
--------------------------------------------------------------------------------
1 |
2 | [workspace]
3 | members = ["members/*"]
4 |
--------------------------------------------------------------------------------
/.rusty-hook.toml:
--------------------------------------------------------------------------------
1 | [hooks]
2 | pre-push = "cargo run --bin cargo-make -- make ci-flow"
3 |
--------------------------------------------------------------------------------
/docs/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | gem 'github-pages', group: :jekyll_plugins
--------------------------------------------------------------------------------
/docs/api/cargo_make/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["get_name","main"]};
--------------------------------------------------------------------------------
/docs/api/cli/logger/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"struct":["LoggerOptions"]};
--------------------------------------------------------------------------------
/examples/workspace/Cargo.toml:
--------------------------------------------------------------------------------
1 |
2 | [workspace]
3 | members = ["member1", "member2"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/broken_makefile.toml:
--------------------------------------------------------------------------------
1 | [tasks.bootstrap]
2 | command = false
3 |
--------------------------------------------------------------------------------
/docs/api/cli/cli_commands/list_steps/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["run"]};
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/favicon.ico
--------------------------------------------------------------------------------
/docs/vscode-example/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "debug.allowBreakpointsEverywhere": true
3 | }
--------------------------------------------------------------------------------
/docs/api/cli/cli_commands/print_steps/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["print"]};
--------------------------------------------------------------------------------
/docs/api/cli/completion/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["generate_completions"]};
--------------------------------------------------------------------------------
/docs/api/search.desc/makers/makers-desc-0-.js:
--------------------------------------------------------------------------------
1 | searchState.loadedDescShard("makers", 0, "makers")
--------------------------------------------------------------------------------
/examples/extending.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = "alias.toml"
3 |
4 | [tasks.extended]
5 | alias = "D2"
6 |
--------------------------------------------------------------------------------
/examples/override_core.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.post-build]
3 | description = "Override description"
4 |
--------------------------------------------------------------------------------
/examples/workspace/common.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.common]
3 | command = "echo"
4 | args = ["common"]
5 |
--------------------------------------------------------------------------------
/examples/workspace/member1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member1"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/examples/workspace/member2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member2"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/examples/workspace/member3/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member3"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/examples/workspace2/member1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member1"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/test1.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.test1]
3 | command = "echo"
4 | args = ["test1"]
5 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/test2.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.test2]
3 | command = "echo"
4 | args = ["test2"]
5 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target-dir = "my_custom_dir"
3 |
--------------------------------------------------------------------------------
/docs/api/cli/cli_commands/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"mod":["list_steps","print_steps"]};
--------------------------------------------------------------------------------
/examples/extending-env.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = "env.toml"
3 |
4 | [env]
5 | SIMPLE = "EXTENDED VALUE"
6 |
--------------------------------------------------------------------------------
/examples/extends_not_found.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = "bad.toml"
3 |
4 | [tasks.extended]
5 | alias = "D2"
6 |
--------------------------------------------------------------------------------
/examples/workspace-emulation2/rust1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust1"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/examples/workspace-emulation2/rust2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust2"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/examples/workspace-inherit/member1/src/main.rs:
--------------------------------------------------------------------------------
1 | fn main() {
2 | println!("Hello World!");
3 | }
4 |
--------------------------------------------------------------------------------
/examples/workspace/member3/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member3"]
4 |
--------------------------------------------------------------------------------
/examples/workspace2/member/member3/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member3"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member1"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member2"
3 | version = "5.4.3"
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member2/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "wasm32-unknown-unknown"
3 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/nocargo/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["exit 1"]
4 |
--------------------------------------------------------------------------------
/docs/api/cli/cli_parser/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["create_cli","parse","parse_args"]};
--------------------------------------------------------------------------------
/src/lib/test/workspace-inherit/member1/src/main.rs:
--------------------------------------------------------------------------------
1 | fn main() {
2 | println!("Hello World!");
3 | }
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member1"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member2"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member/member3/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "aarch64-linux-android"
3 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member1"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member2"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member4/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "x86_64-pc-windows-msvc.json"
3 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member4/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member4"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member/member3/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["exit 1"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member1"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member2/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "wasm32-unknown-unknown"
3 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member2"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member4/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member4"
3 | version = "1.0.0"
4 |
--------------------------------------------------------------------------------
/docs/api/search.desc/cargo_make/cargo_make-desc-0-.js:
--------------------------------------------------------------------------------
1 | searchState.loadedDescShard("cargo_make", 0, "cargo-make")
--------------------------------------------------------------------------------
/examples/workspace_crate/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "example"
3 | version = "0.1.0"
4 |
5 | [workspace]
6 |
--------------------------------------------------------------------------------
/docs/api/crates.js:
--------------------------------------------------------------------------------
1 | window.ALL_CRATES = ["cargo_make","cli","makers"];
2 | //{"start":21,"fragment_lengths":[12,6,9]}
--------------------------------------------------------------------------------
/src/lib/test/workspace1/Cargo.toml:
--------------------------------------------------------------------------------
1 |
2 | [workspace]
3 | members = ["member1", "member2"]
4 | exclude = ["member1"]
5 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member/member3/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member3"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member/member3/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member3"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from target_dir"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member/member3/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "aarch64-linux-android"
3 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member1"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member2"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/members/member4/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member4"]
4 |
--------------------------------------------------------------------------------
/examples/workspace2/Cargo.toml:
--------------------------------------------------------------------------------
1 |
2 | [workspace]
3 | members = ["member", "member1", "member2"]
4 | exclude = ["member"]
5 |
--------------------------------------------------------------------------------
/src/lib/test/test_files/env.env:
--------------------------------------------------------------------------------
1 | CARGO_MAKE_ENV_FILE_TEST1=1
2 | CARGO_MAKE_ENV_FILE_TEST2=2
3 | CARGO_MAKE_ENV_FILE_TEST3=3
--------------------------------------------------------------------------------
/src/lib/test/workspace2/env_target_dir_and_triple/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "x86_64-pc-windows-msvc.json"
3 |
--------------------------------------------------------------------------------
/examples/cross_platform_shell.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.shell]
3 | script_runner = "@shell"
4 | script = '''
5 | rm ./myfile.txt
6 | '''
7 |
--------------------------------------------------------------------------------
/src/lib/test/cargo/config.toml:
--------------------------------------------------------------------------------
1 |
2 | [alias]
3 | b2 = "build"
4 | c2 = "check"
5 | t2 = "test"
6 | test_specific = ["test", "sometest"]
7 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/Cargo.toml:
--------------------------------------------------------------------------------
1 |
2 | [workspace]
3 | members = ["target_dir", "target_dir_and_triple", "env_target_dir_and_triple"]
4 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir_and_triple/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from target_dir_and_triple"]
4 |
--------------------------------------------------------------------------------
/docs/api/cli/config/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["get_config_directory","load","load_from_path"],"static":["CONFIG_FILE"]};
--------------------------------------------------------------------------------
/docs/api/cli/error/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"enum":["CargoMakeError","CargoMakeErrorDiscriminants","SuccessOrCargoMakeError"]};
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "target_dir"
3 | version = "0.1.0"
4 | authors = []
5 | edition = "2018"
6 |
--------------------------------------------------------------------------------
/examples/perl.toml:
--------------------------------------------------------------------------------
1 | [tasks.perl]
2 | script_runner = "perl"
3 | script_extension = "pl"
4 | script = '''
5 | print "Hello, World!\n";
6 | '''
7 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/env_target_dir_and_triple/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from env_target_dir_and_triple"]
4 |
--------------------------------------------------------------------------------
/src/main_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | fn get_name_test() {
5 | let name = get_name();
6 | assert_eq!(name, "make");
7 | }
8 |
--------------------------------------------------------------------------------
/examples/clear.toml:
--------------------------------------------------------------------------------
1 | extend = "script.toml"
2 |
3 | [tasks.hello-world]
4 | clear = true
5 | command = "echo"
6 | args = ["extended hello world"]
7 |
--------------------------------------------------------------------------------
/examples/python.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.python]
3 | script_runner = "python"
4 | script_extension = "py"
5 | script = '''
6 | print("Hello, World!")
7 | '''
8 |
--------------------------------------------------------------------------------
/examples/workspace/member1/.cargo/config.toml:
--------------------------------------------------------------------------------
1 |
2 | [alias]
3 | b2 = "build"
4 | c2 = "check"
5 | t2 = "test"
6 | test_specific = ["test", "sometest"]
7 |
--------------------------------------------------------------------------------
/examples/workspace/member1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | load_cargo_aliases = true
4 |
5 | [tasks.echo]
6 | script = ["echo hello from member1"]
7 |
--------------------------------------------------------------------------------
/src/lib/test/test_files/profile.env:
--------------------------------------------------------------------------------
1 | CARGO_MAKE_ENV_FILE_PROFILE_TEST1=1
2 | CARGO_MAKE_ENV_FILE_PROFILE_TEST2=2
3 | CARGO_MAKE_ENV_FILE_PROFILE_TEST3=3
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir_and_triple/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "x86_64-pc-windows-msvc.json"
3 | target-dir = "my_custom_dir"
4 |
--------------------------------------------------------------------------------
/src/makers_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | fn get_name_test() {
5 | let name = get_name();
6 | assert_eq!(name, "makers");
7 | }
8 |
--------------------------------------------------------------------------------
/docs/api/static.files/favicon-32x32-6580c154.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/favicon-32x32-6580c154.png
--------------------------------------------------------------------------------
/examples/workspace_crate/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member1/.cargo/config.toml:
--------------------------------------------------------------------------------
1 |
2 | [alias]
3 | b2 = "build"
4 | c2 = "check"
5 | t2 = "test"
6 | test_specific = ["test", "sometest"]
7 |
--------------------------------------------------------------------------------
/examples/extends_optional_not_found.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = { path = "does_not_exist_makefile.toml", optional = true }
3 |
4 | [tasks.extended]
5 | alias = "D2"
6 |
--------------------------------------------------------------------------------
/examples/files/extending.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = "../extending.toml"
3 |
4 | [config]
5 | init_task = "test_init"
6 |
7 | [tasks.extended2]
8 | alias = "extended"
9 |
--------------------------------------------------------------------------------
/examples/javascript.toml:
--------------------------------------------------------------------------------
1 | [tasks.javascript]
2 | script_runner = "node"
3 | script_extension = "js"
4 | script = '''
5 | console.log('Hello, World!');
6 | '''
7 |
--------------------------------------------------------------------------------
/examples/performance_tuning.toml:
--------------------------------------------------------------------------------
1 | [config]
2 | skip_core_tasks = true
3 | skip_git_env_info = true
4 | skip_rust_env_info = true
5 | skip_crate_env_info = true
6 |
--------------------------------------------------------------------------------
/examples/workspace/member1/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/workspace/member2/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/workspace/member3/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | title: cargo-make
3 | description: Rust task runner and build tool.
4 | show_downloads: false
5 | version: 0.37.24
6 |
--------------------------------------------------------------------------------
/docs/api/static.files/FiraSans-Medium-e1aa3f0a.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/FiraSans-Medium-e1aa3f0a.woff2
--------------------------------------------------------------------------------
/docs/api/static.files/FiraSans-Regular-0fe48ade.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/FiraSans-Regular-0fe48ade.woff2
--------------------------------------------------------------------------------
/examples/fork.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | command = "echo"
4 | args = ["hello world"]
5 |
6 | [tasks.fork-example]
7 | run_task = { name = "echo", fork = true }
8 |
--------------------------------------------------------------------------------
/examples/modify_core_tasks.toml:
--------------------------------------------------------------------------------
1 |
2 | [config.modify_core_tasks]
3 | private = true
4 | namespace = "default"
5 |
6 | [tasks.empty2]
7 | run_task = "default::empty"
8 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member1/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/member2/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
4 |
5 | [tasks.echo]
6 | script = ["echo hello from workspace"]
7 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir_and_triple/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "target_dir_and_triple"
3 | version = "0.1.0"
4 | authors = []
5 | edition = "2018"
6 |
--------------------------------------------------------------------------------
/src/lib/test/workspace3/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
4 |
5 | [tasks.echo]
6 | script = ["echo hello from workspace"]
7 |
--------------------------------------------------------------------------------
/docs/api/cli/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"fn":["run_cli"],"mod":["cli","cli_commands","cli_parser","completion","config","error","logger","runner","types"]};
--------------------------------------------------------------------------------
/docs/api/static.files/SourceSerif4-It-ca3b17ed.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/SourceSerif4-It-ca3b17ed.ttf.woff2
--------------------------------------------------------------------------------
/examples/test.env:
--------------------------------------------------------------------------------
1 | #just a comment...
2 | ENV1_TEST=TEST1
3 | ENV2_TEST=TEST2
4 | ENV3_TEST=VALUE OF ENV2 IS: ${ENV2_TEST}
5 | PROFILE_ENV_VALUE=Profile loaded: ${PROFILE_ENV}
--------------------------------------------------------------------------------
/examples/workspace-emulation2/rust1/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/workspace-emulation2/rust2/src/lib.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | #[test]
4 | fn it_works() {
5 | assert_eq!(2 + 2, 4);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/workspace/member2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = { path = "./common.toml", relative = "workspace" }
3 |
4 | [tasks.echo]
5 | script = ["echo hello from member2"]
6 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/env_target_dir_and_triple/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "env_target_dir_and_triple"
3 | version = "0.1.0"
4 | authors = []
5 | edition = "2018"
6 |
--------------------------------------------------------------------------------
/docs/api/static.files/NanumBarunGothic-13b3dcba.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/NanumBarunGothic-13b3dcba.ttf.woff2
--------------------------------------------------------------------------------
/docs/api/static.files/SourceCodePro-It-fc8b9304.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/SourceCodePro-It-fc8b9304.ttf.woff2
--------------------------------------------------------------------------------
/docs/api/static.files/SourceSerif4-Bold-6d4fd4c0.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/SourceSerif4-Bold-6d4fd4c0.ttf.woff2
--------------------------------------------------------------------------------
/docs/api/static.files/SourceSerif4-Regular-6b053e98.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/SourceSerif4-Regular-6b053e98.ttf.woff2
--------------------------------------------------------------------------------
/src/lib/test/makefiles/env-reorder-extended.toml:
--------------------------------------------------------------------------------
1 | extend = "./env-reorder.toml"
2 |
3 | [env]
4 | ENV4 = "${ENV5} ${ENV6}"
5 | ENV5 = "${ENV6} --health"
6 | ENV6 = "--verbose"
7 |
--------------------------------------------------------------------------------
/docs/api/static.files/SourceCodePro-Regular-8badfe75.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/SourceCodePro-Regular-8badfe75.ttf.woff2
--------------------------------------------------------------------------------
/docs/api/static.files/SourceCodePro-Semibold-aa29a496.ttf.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sagiegurari/cargo-make/master/docs/api/static.files/SourceCodePro-Semibold-aa29a496.ttf.woff2
--------------------------------------------------------------------------------
/examples/cargo-make/config.toml:
--------------------------------------------------------------------------------
1 | log_level = "error"
2 | disable_color = true
3 | default_task_name = "build"
4 | update_check_minimum_interval = "daily"
5 | search_project_root = true
6 |
--------------------------------------------------------------------------------
/src/lib/cli_commands/mod.rs:
--------------------------------------------------------------------------------
1 | //! # cli_commands
2 | //!
3 | //! Wrappers for each CLI sub command.
4 | //!
5 |
6 | pub(crate) mod diff_steps;
7 | pub mod list_steps;
8 | pub mod print_steps;
9 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/broken_makefile_minversion.toml:
--------------------------------------------------------------------------------
1 | [config]
2 | # Should always be above the current version.
3 | min_version = "999.999.999"
4 |
5 | [tasks.bootstrap]
6 | command = false
7 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: cargo
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: '03:00'
8 | open-pull-requests-limit: 99
9 |
--------------------------------------------------------------------------------
/docs/_includes/main.html:
--------------------------------------------------------------------------------
1 |
2 |
{% include nav.md %}
3 |
{% include content.md %}
4 |
--------------------------------------------------------------------------------
/src/lib/plugin/mod.rs:
--------------------------------------------------------------------------------
1 | //! # plugin
2 | //!
3 | //! Manages and runs the plugins.
4 | //!
5 |
6 | pub(crate) mod descriptor;
7 | pub(crate) mod runner;
8 | mod sdk;
9 | pub(crate) mod types;
10 |
--------------------------------------------------------------------------------
/examples/workspace2/member2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member2"
3 | version = "1.0.0"
4 |
5 | [dependencies]
6 | test200 = { version = "1.0.0", features = ["abc"] }
7 | test100 = { path = "../test100" }
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .c9
3 | target/
4 | temp/
5 | **/*.rs.bk
6 | **/*.log
7 | dump.rdb
8 | /rs*.sh
9 | /docs/_site
10 | /core
11 | /src/**/Cargo.lock
12 | /examples/**/Cargo.lock
13 | *.rustc_info.json
14 |
--------------------------------------------------------------------------------
/examples/cross-file.toml:
--------------------------------------------------------------------------------
1 | [tasks.cross-file]
2 | dependencies = [
3 | # specific file name
4 | { name = "private", path = "private.toml" },
5 | # in a folder
6 | { name = "echo", path = "workspace2" },
7 | ]
8 |
--------------------------------------------------------------------------------
/examples/ignore_errors.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.error]
3 | script = "exit 1"
4 |
5 | [tasks.ignore]
6 | script = "exit 1"
7 | ignore_errors = true
8 |
9 | [tasks.force]
10 | script = "exit 1"
11 | force = true
12 |
--------------------------------------------------------------------------------
/examples/dependencies.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.A]
3 | dependencies = ["B", "C"]
4 |
5 | [tasks.B]
6 | dependencies = ["D"]
7 |
8 | [tasks.C]
9 | dependencies = ["D"]
10 |
11 | [tasks.D]
12 | script = "echo hello"
13 |
--------------------------------------------------------------------------------
/examples/workspace-emulation/member2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member2"
3 | version = "1.0.0"
4 |
5 | [dependencies]
6 | test200 = { version = "1.0.0", features = ["abc"] }
7 | test100 = { path = "../test100" }
8 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/task_extend.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [tasks.task1]
6 | env = { Foo = "foo" }
7 | command = "echo"
8 | args = ["${Foo}"]
9 |
10 | [tasks.task2]
11 | extend = "task1"
12 |
--------------------------------------------------------------------------------
/src/lib/test/workspace1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | main_project_member = "member2"
4 |
5 | [env]
6 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
7 |
8 | [tasks.echo]
9 | script = ["echo hello from workspace"]
10 |
--------------------------------------------------------------------------------
/src/lib/plugin/types_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | fn plugins_new() {
5 | let plugins = Plugins::new();
6 |
7 | assert!(plugins.aliases.is_none());
8 | assert!(plugins.plugins.is_empty());
9 | }
10 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/env-reorder.toml:
--------------------------------------------------------------------------------
1 | [env]
2 | ENV1 = "${ENV2}"
3 | ENV3 = "--amount 1 -HrA ${ENV4}"
4 | ENV2 = "${ENV3}"
5 | ENV4 = "--defined yes"
6 |
7 | [tasks.echo]
8 | command = "echo"
9 | args = ["@@split(ENV3)"]
10 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 |
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | end_of_line = lf
7 | insert_final_newline = true
8 | trim_trailing_whitespace = true
9 | indent_style = space
10 | indent_size = 4
11 |
12 | [*.json]
13 | indent_size = 2
14 |
--------------------------------------------------------------------------------
/docs/api.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/alias.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.A]
3 | dependencies = ["B", "C"]
4 |
5 | [tasks.B]
6 | dependencies = ["D"]
7 |
8 | [tasks.C]
9 | dependencies = ["D2"]
10 |
11 | [tasks.D]
12 | script = "echo hello"
13 |
14 | [tasks.D2]
15 | alias = "D"
16 |
--------------------------------------------------------------------------------
/examples/deprecated.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [tasks.legacy]
6 | deprecated = "Please use task OTHER instead"
7 |
8 | [tasks.legacy-extended]
9 | extend = "legacy"
10 | deprecated = false
11 |
12 | [tasks.legacy2]
13 | deprecated = true
14 |
--------------------------------------------------------------------------------
/examples/workspace-emulation/member1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member1"]
4 |
5 | [tasks.workspace_root]
6 | script = [
7 | "echo member 1 found root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
8 | ]
9 |
--------------------------------------------------------------------------------
/examples/workspace-emulation/member2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member2"]
4 |
5 | [tasks.workspace_root]
6 | script = [
7 | "echo member 2 found root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
8 | ]
9 |
--------------------------------------------------------------------------------
/examples/kcov.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | # The following environmental variables are passed to kcov to exclude lines or regions of code
4 | # during coverage.
5 | CARGO_MAKE_KCOV_EXCLUDE_LINE = "unreachable,kcov-ignore"
6 | CARGO_MAKE_KCOV_EXCLUDE_REGION = "kcov-ignore-start:kcov-ignore-end"
7 |
--------------------------------------------------------------------------------
/examples/workspace-emulation/member/member3/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member3"]
4 |
5 | [tasks.workspace_root]
6 | script = [
7 | "echo member 3 found root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
8 | ]
9 |
--------------------------------------------------------------------------------
/.typos.toml:
--------------------------------------------------------------------------------
1 | # If there are words that you think should not be treated as typo.
2 | # Please list here along with a comment.
3 | [default.extend-words]
4 | "MUTLI" = "MUTLI"
5 | "SPLITTED" = "SPLITTED"
6 | "ba" = "ba"
7 | "hel" = "hel"
8 |
9 | [files]
10 | extend-exclude = ["docs/api/*"]
11 |
--------------------------------------------------------------------------------
/examples/env2.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [tasks.echo]
6 | script_runner = "@shell"
7 | script = '''
8 | echo ENV1_TEST: ${ENV1_TEST}
9 | echo ENV2_TEST: ${ENV2_TEST}
10 | echo ENV3_TEST: ${ENV3_TEST}
11 | echo PROFILE_ENV_VALUE: ${PROFILE_ENV_VALUE}
12 | '''
13 |
--------------------------------------------------------------------------------
/examples/workspace-inherit/member1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member1"
3 | version.workspace = true
4 | authors.workspace = true
5 | description.workspace = true
6 | documentation.workspace = true
7 | license.workspace = true
8 | homepage.workspace = true
9 | repository.workspace = true
10 |
--------------------------------------------------------------------------------
/src/lib/test/workspace-inherit/member1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "member1"
3 | version.workspace = true
4 | authors.workspace = true
5 | description.workspace = true
6 | documentation.workspace = true
7 | license.workspace = true
8 | homepage.workspace = true
9 | repository.workspace = true
10 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/env-extended.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = "./env.toml"
3 |
4 | [env]
5 | IF_UNDEFINED = "EXTENDED"
6 |
7 | [plugins.aliases]
8 | new = "newer2"
9 | extended = "test"
10 |
11 | [plugins.impl.base1]
12 | script = "extended1 test"
13 |
14 | [plugins.impl.extended]
15 | script = "extended test"
16 |
--------------------------------------------------------------------------------
/examples/private.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.public]
3 | description = "This is a public task that can be invoked via cli"
4 | dependencies = ["private"]
5 |
6 | [tasks.private]
7 | description = "This is a private task that can only be invoked by other tasks"
8 | private = true
9 | command = "echo"
10 | args = ["private..."]
11 |
--------------------------------------------------------------------------------
/examples/shebang.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.shebang-sh]
3 | script = '''
4 | #!/bin/bash
5 | echo hello
6 | '''
7 |
8 | [tasks.shebang-sh-arg]
9 | script = '''
10 | #!/usr/bin/env bash
11 | echo hello
12 | '''
13 |
14 | [tasks.shebang-python]
15 | script = '''
16 | #!/usr/bin/env python3
17 | print("Hello, World!")
18 | '''
19 |
--------------------------------------------------------------------------------
/examples/workspace2/member1/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member1"]
4 |
5 | [tasks.member-only]
6 | script = ["echo member 1"]
7 |
8 | [tasks.workspace_root]
9 | script = [
10 | "echo member 1 found root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
11 | ]
12 |
--------------------------------------------------------------------------------
/examples/workspace2/member2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = ["echo hello from member2"]
4 |
5 | [tasks.member-only]
6 | script = ["echo member 2"]
7 |
8 | [tasks.workspace_root]
9 | script = [
10 | "echo member 1 found root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
11 | ]
12 |
--------------------------------------------------------------------------------
/examples/php.toml:
--------------------------------------------------------------------------------
1 | [tasks.php]
2 | script_runner = "php"
3 | script_extension = "php"
4 | script = '''
5 |
12 |
13 | ### Describe The Solution You'd Like
14 |
15 |
16 | ### Code Sample
17 |
18 | ```rust
19 | /// paste code here
20 | ```
21 |
--------------------------------------------------------------------------------
/examples/simple-example.toml:
--------------------------------------------------------------------------------
1 | [tasks.format]
2 | install_create = "rustfmt"
3 | command = "cargo"
4 | args = ["fmt", "--", "--write-mode=overwrite"]
5 |
6 | [tasks.clean]
7 | command = "cargo"
8 | args = ["clean"]
9 |
10 | [tasks.build]
11 | command = "cargo"
12 | args = ["build"]
13 | dependencies = ["clean"]
14 |
15 | [tasks.test]
16 | command = "cargo"
17 | args = ["test"]
18 | dependencies = ["clean"]
19 |
20 | [tasks.my-flow]
21 | dependencies = ["format", "build", "test"]
22 |
--------------------------------------------------------------------------------
/examples/workspace/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = "../plugin_workspace_parallel.toml"
3 |
4 | [config]
5 | skip_core_tasks = true
6 |
7 | [env]
8 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
9 |
10 | [tasks.echo]
11 | # to make echo serial and not parallel, remove following 2 lines
12 | plugin = "parallel-members"
13 | workspace = false
14 |
15 | [tasks.workspace-echo]
16 | env = { "CARGO_MAKE_MEMBER_TASK" = "echo", "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "member2" }
17 | run_task = "do-on-members"
18 |
--------------------------------------------------------------------------------
/examples/task_extend.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [tasks.1]
6 | category = "1"
7 | description = "1"
8 | command = "echo"
9 | args = ["1"]
10 |
11 | [tasks.2]
12 | extend = "1"
13 | category = "2"
14 | args = ["2"]
15 |
16 | [tasks.3]
17 | extend = "2"
18 | args = ["3"]
19 |
20 | [tasks.task1]
21 | env = { Foo = "foo" }
22 | command = "echo"
23 | args = ["${Foo}"]
24 |
25 | [tasks.task1.linux]
26 | env = { Foo = "foo-linux" }
27 |
28 | [tasks.task2]
29 | extend = "task1"
30 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug Report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: sagiegurari
7 |
8 | ---
9 |
10 | ### Describe The Bug
11 |
12 |
13 | ### To Reproduce
14 |
15 |
16 | ### Error Stack
17 |
18 | ```console
19 | The error stack trace
20 | ```
21 |
22 | ### Code Sample
23 |
24 | ```rust
25 | /// paste code here
26 | ```
27 |
--------------------------------------------------------------------------------
/examples/extends_list.toml:
--------------------------------------------------------------------------------
1 |
2 | extend = [
3 | { path = "alias.toml" },
4 | { path = "optional_makefile.toml", optional = true },
5 | { path = "cwd.toml" },
6 | { path = "cwd.toml", relative = "bad" },
7 | { path = "./examples/python.toml", relative = "crate" },
8 | { path = "./examples/javascript.toml", relative = "git" },
9 | ]
10 |
11 | [config]
12 | skip_core_tasks = true
13 | skip_git_env_info = true
14 | skip_rust_env_info = true
15 | skip_crate_env_info = true
16 |
17 | [tasks.extended]
18 | alias = "D2"
19 |
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/base.toml:
--------------------------------------------------------------------------------
1 |
2 | env_files = []
3 | env_scripts = []
4 |
5 | [config]
6 | init_task = "init"
7 | end_task = "end"
8 |
9 | [env]
10 |
11 | [tasks.init]
12 | description = "By default this task is invoked at the start of every cargo-make run."
13 | category = "Hooks"
14 |
15 | [tasks.end]
16 | description = "By default this task is invoked at the end of every cargo-make run."
17 | category = "Hooks"
18 |
19 | [tasks.empty]
20 | description = "Empty Task"
21 | category = "Tools"
22 |
23 | [tasks.default]
24 | description = "Empty Task"
25 |
--------------------------------------------------------------------------------
/examples/varargs.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.varargs]
3 | command = "echo"
4 | args = ["args are:", "${@}"]
5 |
6 | [tasks.varargs-template]
7 | command = "echo"
8 | args = ["args are:", "-o=${@}"]
9 |
10 | [tasks.cli-args]
11 | script = "echo args are: ${@}"
12 |
13 | [tasks.cli-args-shell]
14 | script_runner = "@shell"
15 | script = "echo args are: ${@}"
16 |
17 | [tasks.cli-args-rust]
18 | script_runner = "@rust"
19 | script = '''
20 | use std::env;
21 | fn main() {
22 | let args: Vec = env::args().collect();
23 | println!("args are: {:?}", args);
24 | }
25 | '''
26 |
--------------------------------------------------------------------------------
/src/lib/scriptengine/os_script.rs:
--------------------------------------------------------------------------------
1 | //! # os_script
2 | //!
3 | //! Runs OS scripts.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "os_script_test.rs"]
8 | mod os_script_test;
9 |
10 | use crate::command;
11 | use crate::error::CargoMakeError;
12 |
13 | pub(crate) fn execute(
14 | script_text: &Vec,
15 | runner: Option,
16 | cli_arguments: &Vec,
17 | validate: bool,
18 | ) -> Result {
19 | let exit_code =
20 | command::run_script_get_exit_code(&script_text, runner, &cli_arguments, validate)?;
21 | Ok(exit_code == 0)
22 | }
23 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/hash/trait.Hash.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Hash for UnstableFeature "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[278]}
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/ops/deref/trait.Deref.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Deref for TestArg "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[274]}
--------------------------------------------------------------------------------
/src/lib/scriptengine/shell_to_batch_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | fn execute_valid() {
5 | let valid = execute(
6 | &vec!["echo test".to_string()],
7 | &vec!["test".to_string()],
8 | true,
9 | )
10 | .unwrap();
11 |
12 | assert!(valid);
13 | }
14 |
15 | #[test]
16 | #[should_panic]
17 | fn execute_error() {
18 | execute(&vec!["exit 1".to_string()], &vec![], true).unwrap();
19 | }
20 |
21 | #[test]
22 | fn execute_error_no_validate() {
23 | let valid = execute(&vec!["exit 1".to_string()], &vec![], false).unwrap();
24 | assert!(!valid);
25 | }
26 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/ops/deref/trait.DerefMut.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl DerefMut for TestArg "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[283]}
--------------------------------------------------------------------------------
/src/lib/recursion_level_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | #[ignore]
5 | fn recursion_level_changes() {
6 | // backup environment to avoid having conflicts if
7 | // the test is run within `cargo-make`.
8 | let rec_lvl = envmnt::get_or(RECURSION_ENV_VAR_NAME, "0");
9 | envmnt::remove(RECURSION_ENV_VAR_NAME);
10 |
11 | assert!(is_top());
12 | assert_eq!(get(), 0);
13 |
14 | increment(); // explicitly set to 0
15 | increment();
16 | assert!(!is_top());
17 | assert_eq!(get(), 1);
18 |
19 | increment();
20 | assert_eq!(get(), 2);
21 |
22 | envmnt::set(RECURSION_ENV_VAR_NAME, rec_lvl);
23 | }
24 |
--------------------------------------------------------------------------------
/examples/watch.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | env = { "ECHO_TEST" = "ECHO_ENV" }
4 | script = '''
5 | echo watch triggered
6 | echo ECHO_TEST: ${ECHO_TEST}
7 | echo CARGO_MAKE_DISABLE_WATCH: ${CARGO_MAKE_DISABLE_WATCH}
8 | '''
9 | watch = true
10 |
11 | [tasks.watch-example]
12 | command = "echo"
13 | args = ["Triggered by watch"]
14 | watch = true
15 |
16 | [tasks.watch-args-example]
17 | command = "echo"
18 | args = ["Triggered by watch"]
19 | watch = { postpone = true, no_git_ignore = true, ignore_pattern = "examples/files/*", watch = [
20 | "./docs/",
21 | ] }
22 |
23 | [tasks.watch-task-args-example]
24 | command = "echo"
25 | args = ["@@split(CARGO_MAKE_TASK_ARGS, ;)"]
26 | watch = true
27 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/convert/trait.AsRef.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl AsRef <str > for CargoMakeError "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[388]}
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/mod.rs:
--------------------------------------------------------------------------------
1 | //! # makefiles
2 | //!
3 | //! Provides access to internal makefiles.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "mod_test.rs"]
8 | mod mod_test;
9 |
10 | pub(crate) static BASE: &str = include_str!("base.toml");
11 | pub(crate) static STABLE: &str = concat!(
12 | include_str!("stable.toml"),
13 | include_str!("build-file.toml"),
14 | include_str!("git.toml"),
15 | include_str!("github.toml"),
16 | include_str!("toml.toml"),
17 | include_str!("rust.toml"),
18 | include_str!("rust-coverage.toml"),
19 | include_str!("rust-wasm.toml"),
20 | include_str!("deprecated.toml")
21 | );
22 | pub(crate) static BETA: &str = include_str!("beta.toml");
23 |
--------------------------------------------------------------------------------
/src/lib/functions/remove_empty_func.rs:
--------------------------------------------------------------------------------
1 | //! # remove_empty_func
2 | //!
3 | //! Takes an environment variable name and returns its value of if its defined and contains some text.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "remove_empty_func_test.rs"]
8 | mod remove_empty_func_test;
9 |
10 | pub(crate) fn invoke(function_args: &Vec) -> Vec {
11 | if function_args.len() != 1 {
12 | error!("remove_empty expects only 1 argument (environment variable name)");
13 | }
14 |
15 | let env_key = function_args[0].clone();
16 |
17 | let value = envmnt::get_or(&env_key, "");
18 |
19 | if value.len() > 0 {
20 | vec![value]
21 | } else {
22 | vec![]
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/lib/recursion_level.rs:
--------------------------------------------------------------------------------
1 | //! # recursion_level
2 | //!
3 | //! Utility functions to keep track of the recursion of cargo-make calls.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "recursion_level_test.rs"]
8 | mod recursion_level_test;
9 |
10 | static RECURSION_ENV_VAR_NAME: &str = "CARGO_MAKE_INTERNAL_RECURSION_LEVEL";
11 |
12 | pub(crate) fn get() -> u32 {
13 | envmnt::get_u32(RECURSION_ENV_VAR_NAME, 0)
14 | }
15 |
16 | pub(crate) fn is_top() -> bool {
17 | get() == 0
18 | }
19 |
20 | pub(crate) fn increment() {
21 | if envmnt::exists(RECURSION_ENV_VAR_NAME) {
22 | envmnt::increment(RECURSION_ENV_VAR_NAME);
23 | } else {
24 | envmnt::set_u32(RECURSION_ENV_VAR_NAME, 0);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/convert/trait.Into.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Into <TaskIdentifier > for DependencyIdentifier "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[435]}
--------------------------------------------------------------------------------
/src/lib/scriptengine/duck_script/sdk/mod.rs:
--------------------------------------------------------------------------------
1 | //! # sdk
2 | //!
3 | //! Loads the cargo-make duckscript SDK.
4 | //!
5 |
6 | mod cm_run_task;
7 |
8 | use crate::types::{FlowInfo, FlowState};
9 | use duckscript::types::command::Commands;
10 | use duckscript::types::error::ScriptError;
11 | use std::cell::RefCell;
12 | use std::rc::Rc;
13 |
14 | /// Loads all core commands
15 | pub(crate) fn load(
16 | commands: &mut Commands,
17 | flow_info_option: Option<&FlowInfo>,
18 | flow_state_option: Option>>,
19 | ) -> Result<(), ScriptError> {
20 | if let (Some(flow_info), Some(flow_state)) = (flow_info_option, flow_state_option) {
21 | commands.set(cm_run_task::create(flow_info, flow_state))?;
22 | }
23 |
24 | Ok(())
25 | }
26 |
--------------------------------------------------------------------------------
/.github/workflows/cron.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | schedule:
4 | - cron: '0 17 * * 4'
5 | env:
6 | CLICOLOR_FORCE: 1
7 | jobs:
8 | cron_ci:
9 | name: cron_ci
10 | runs-on: ubuntu-latest
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v2
14 | - name: Install rust
15 | uses: actions-rs/toolchain@v1
16 | with:
17 | toolchain: stable
18 | profile: minimal
19 | override: true
20 | - name: Install cargo-make
21 | uses: actions-rs/cargo@v1
22 | with:
23 | command: install
24 | args: --debug cargo-make
25 | - name: Run CI
26 | uses: actions-rs/cargo@v1
27 | with:
28 | command: run
29 | args: --bin cargo-make --target-dir target/ci -- make ci-flow
30 |
--------------------------------------------------------------------------------
/src/lib/scriptengine/os_script_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::test;
3 |
4 | #[test]
5 | fn execute_shell() {
6 | execute(&vec!["exit 0".to_string()], None, &vec![], true).unwrap();
7 | }
8 |
9 | #[test]
10 | fn execute_shell_with_runner() {
11 | let valid = execute(
12 | &vec!["exit 0".to_string()],
13 | Some(test::get_os_runner()),
14 | &vec![],
15 | true,
16 | )
17 | .unwrap();
18 | assert!(valid);
19 | }
20 |
21 | #[test]
22 | #[should_panic]
23 | fn execute_shell_error() {
24 | execute(&vec!["exit 1".to_string()], None, &vec![], true).unwrap();
25 | }
26 |
27 | #[test]
28 | fn execute_shell_error_no_validate() {
29 | let valid = execute(&vec!["exit 1".to_string()], None, &vec![], false).unwrap();
30 | assert!(!valid);
31 | }
32 |
--------------------------------------------------------------------------------
/docs/assets/badges/cargo-make.svg:
--------------------------------------------------------------------------------
1 | built with built with cargo-make cargo-make
--------------------------------------------------------------------------------
/examples/plugin_workspace_parallel.toml:
--------------------------------------------------------------------------------
1 |
2 | [plugins.impl.parallel-members]
3 | script = '''
4 | plugin_used = get_env PLUGIN_USED
5 | plugin_used = eq "${plugin_used}" 1
6 |
7 | if not ${plugin_used}
8 | set_env PLUGIN_USED 1
9 | members = split ${CARGO_MAKE_CRATE_WORKSPACE_MEMBERS} ,
10 |
11 | workspace_dir = pwd
12 | for member in ${members}
13 | cd ./${member}
14 | spawn cargo make --disable-check-for-updates --allow-private --no-on-error ${flow.task.name} %{args}
15 | cd ${workspace_dir}
16 | end
17 |
18 | release ${members}
19 | else
20 | task_definition = json_parse --collection ${task.as_json}
21 | map_remove ${task_definition} workspace
22 | task_json = json_encode --collection ${task_definition}
23 | cm_plugin_run_custom_task ${task_json}
24 | end
25 | '''
26 |
--------------------------------------------------------------------------------
/src/lib/test/makefiles/env.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | IF_UNDEFINED = { value = "defined_in_makefile", condition = { env_not_set = [
4 | "IF_UNDEFINED",
5 | ] } }
6 | COMPOSITE_OF_MAPPED = "VALUE: ${IF_UNDEFINED}"
7 |
8 | [plugins.aliases]
9 | old = "new"
10 | new = "newer"
11 |
12 | [plugins.impl.base1]
13 | script = "base1 test"
14 |
15 | [plugins.impl.base2]
16 | script = "base2 test"
17 |
18 | [tasks.if-undefined-print]
19 | script = '''
20 | echo IF_UNDEFINED: ${IF_UNDEFINED}
21 | echo COMPOSITE_OF_MAPPED: ${COMPOSITE_OF_MAPPED}
22 | '''
23 |
24 | [tasks.if-undefined-fork]
25 | env = { IF_UNDEFINED = "defined_from_fork" }
26 | run_task = { name = "if-undefined-fork", fork = true }
27 |
28 | [tasks.if-undefined-cli]
29 | command = "cargo"
30 | args = [
31 | "make",
32 | "--makefile",
33 | "env.toml",
34 | "--env",
35 | "IF_UNDEFINED=defined_from_cli",
36 | "if-undefined-print",
37 | ]
38 |
--------------------------------------------------------------------------------
/examples/workspace-emulation/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
4 | CARGO_MAKE_WORKSPACE_EMULATION = true
5 | CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = ["member1", "member2"]
6 |
7 | [tasks.echo]
8 | script = ["echo hello from workspace"]
9 |
10 | [tasks.echo_top_and_members]
11 | workspace = false
12 | dependencies = ["echo"]
13 | run_task = { name = "echo", fork = true }
14 |
15 | [tasks.echo_top_and_member2]
16 | env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = "member2" }
17 | dependencies = ["echo"]
18 | run_task = { name = "echo", fork = true }
19 |
20 | [tasks.workspace_root]
21 | script = [
22 | "echo root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
23 | ]
24 |
25 | [tasks.workspace_root_top_and_members]
26 | workspace = false
27 | dependencies = ["workspace_root"]
28 | run_task = { name = "workspace_root", fork = true }
29 |
--------------------------------------------------------------------------------
/examples/run_task.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.echo]
3 | script = "echo hello world"
4 |
5 | [tasks.flow]
6 | run_task = "echo"
7 | condition_script = ["exit 0"]
8 |
9 | [tasks.echo1]
10 | command = "echo"
11 | args = ["1"]
12 |
13 | [tasks.echo2]
14 | command = "echo"
15 | args = ["2"]
16 |
17 | [tasks.simple-multi]
18 | run_task = { name = ["echo1", "echo2"] }
19 |
20 | [tasks.routing-multi]
21 | run_task = [{ name = ["echo1", "echo2"] }]
22 |
23 | [tasks.parallel-multi]
24 | run_task = { name = ["echo1", "echo2"], parallel = true }
25 |
26 | [tasks.fail]
27 | script = "exit 1"
28 |
29 | [tasks.cleanup]
30 | command = "echo"
31 | args = ["cleanup"]
32 |
33 | [tasks.cleanup-example]
34 | run_task = { name = ["echo1", "echo2"], fork = true, cleanup_task = "cleanup" }
35 |
36 | [tasks.cleanup-example-with-error]
37 | run_task = { name = [
38 | "echo1",
39 | "echo2",
40 | "fail",
41 | ], fork = true, cleanup_task = "cleanup" }
42 |
--------------------------------------------------------------------------------
/extra/shell/makers-completion.bash:
--------------------------------------------------------------------------------
1 | #/usr/bin/env bash
2 |
3 | _cargo_make_completions()
4 | {
5 | if [ "${#COMP_WORDS[@]}" != "2" ]; then
6 | return
7 | fi
8 |
9 | # add cli options
10 | ALL_WORDS="--allow-private --diff-steps --disable-check-for-updates --experimental -h --help --list-all-steps --no-color --no-on-error --no-workspace --print-steps -skip-init-end-tasks --time-summary -v --version -V --version --cwd -e --env --env-file -l --loglevel verbose info error --makefile --output-format default short-description markdown markdown-single-page markdown-sub-section autocomplete --output-file -p --profile --skip-tasks -t --task "
11 |
12 | # add task names
13 | ALL_WORDS=("${ALL_WORDS}$(makers --loglevel error --list-all-steps --output-format autocomplete)")
14 |
15 | COMPREPLY=($(compgen -W "$ALL_WORDS" -- "${COMP_WORDS[1]}"))
16 | }
17 |
18 | complete -F _cargo_make_completions makers
19 |
20 |
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/rust-wasm.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.install-wasm-pack]
3 | description = "Installs wasm-pack crate."
4 | category = "wasm"
5 | install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }
6 |
7 | [tasks.wasm-pack-base]
8 | category = "wasm"
9 | dependencies = ["install-wasm-pack"]
10 | command = "wasm-pack"
11 |
12 | [tasks.wasm-pack-test]
13 | description = "Run wasm-pack test command."
14 | extend = "wasm-pack-base"
15 | condition = { env_set = ["CARGO_MAKE_WASM_TEST_ARGS"] }
16 | args = ["test", "@@split(CARGO_MAKE_WASM_TEST_ARGS, )"]
17 |
18 | [tasks.wasm-pack-pack]
19 | description = "Run wasm-pack pack command."
20 | extend = "wasm-pack-base"
21 | args = ["pack", "@@split(CARGO_MAKE_WASM_PACK_ARGS, )"]
22 |
23 | [tasks.wasm-pack-publish]
24 | description = "Run wasm-pack publish command."
25 | extend = "wasm-pack-base"
26 | args = ["publish", "@@split(CARGO_MAKE_WASM_PUBLISH_ARGS, )"]
27 |
--------------------------------------------------------------------------------
/examples/subcommands.toml:
--------------------------------------------------------------------------------
1 | [config]
2 | skip_core_tasks = true
3 | skip_git_env_info = true
4 | skip_rust_env_info = true
5 | skip_crate_env_info = true
6 |
7 | [tasks.server]
8 | private = false
9 | extend = "subcommand"
10 | env = { "SUBCOMMAND_PREFIX" = "server" }
11 |
12 | [tasks.client]
13 | private = false
14 | extend = "subcommand"
15 | env = { "SUBCOMMAND_PREFIX" = "client" }
16 |
17 | [tasks.subcommand]
18 | private = true
19 | script = '''
20 | #!@duckscript
21 |
22 | cm_run_task ${SUBCOMMAND_PREFIX}_${1}
23 | '''
24 |
25 | [tasks.server_start]
26 | private = true
27 | command = "echo"
28 | args = ["starting server..."]
29 |
30 | [tasks.server_stop]
31 | private = true
32 | command = "echo"
33 | args = ["stopping server..."]
34 |
35 | [tasks.client_start]
36 | private = true
37 | command = "echo"
38 | args = ["starting client..."]
39 |
40 | [tasks.client_stop]
41 | private = true
42 | command = "echo"
43 | args = ["stopping client..."]
44 |
--------------------------------------------------------------------------------
/src/lib/plugin/types.rs:
--------------------------------------------------------------------------------
1 | //! # types
2 | //!
3 | //! Defines the various plugin related types.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "types_test.rs"]
8 | mod types_test;
9 |
10 | use indexmap::IndexMap;
11 |
12 | #[derive(Serialize, Deserialize, Debug, Clone)]
13 | /// Holds a plugin implementation
14 | pub(crate) struct Plugin {
15 | /// The plugin script content
16 | pub(crate) script: String,
17 | }
18 |
19 | #[derive(Serialize, Deserialize, Debug, Clone, Default)]
20 | /// Holds the entire plugin config and implementation structure
21 | pub struct Plugins {
22 | /// The plugin name aliases
23 | pub(crate) aliases: Option>,
24 | /// All plugin definitions
25 | #[serde(rename = "impl")]
26 | pub(crate) plugins: IndexMap,
27 | }
28 |
29 | impl Plugins {
30 | /// Creates and returns a new instance.
31 | pub fn new() -> Plugins {
32 | Default::default()
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/docs/vscode-example/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "(LLDB) Launch",
9 | "type": "lldb",
10 | "request": "launch",
11 | "program": "${workspaceRoot}/target/debug/makers",
12 | "windows": {
13 | "program": "${workspaceRoot}/target/debug/makers.exe"
14 | },
15 | "args": [
16 | "--list-all-steps"
17 | ],
18 | "cwd": "${workspaceRoot}",
19 | "environment": [],
20 | "stopOnEntry": false,
21 | "sourceLanguages": [
22 | "rust"
23 | ],
24 | "preLaunchTask": "build debug"
25 | },
26 | ]
27 | }
--------------------------------------------------------------------------------
/examples/workspace-inherit/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
4 |
5 | [tasks.echo]
6 | script = ["echo hello from workspace"]
7 |
8 | [tasks.echo-member]
9 | script = ["echo hello from member"]
10 |
11 | [tasks.echo_top_and_members]
12 | workspace = false
13 | dependencies = ["echo"]
14 | run_task = { name = "echo", fork = true }
15 |
16 | [tasks.workspace_root]
17 | script = [
18 | "echo root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
19 | ]
20 |
21 | [tasks.workspace_root_top_and_members]
22 | workspace = false
23 | dependencies = ["workspace_root"]
24 | run_task = { name = "workspace_root", fork = true }
25 |
26 | [tasks.echo_run_task]
27 | run_task = "echo"
28 |
29 | [tasks.composite_with_run_task]
30 | workspace = false
31 | dependencies = ["echo_run_task"]
32 | run_task = { name = "echo-member", fork = true }
33 |
34 | [tasks.varargs]
35 | command = "echo"
36 | args = ["args are:", "${@}"]
37 |
--------------------------------------------------------------------------------
/docs/api/cli/types/sidebar-items.js:
--------------------------------------------------------------------------------
1 | window.SIDEBAR_ITEMS = {"enum":["ConditionScriptValue","ConditionType","CrateDependency","DependencyIdentifier","DeprecationInfo","EnvFile","EnvValue","Extend","InstallCrate","MaybeArray","RunTaskInfo","RunTaskName","ScriptValue","TaskWatchOptions","ToolchainSpecifier","UnstableFeature"],"fn":["get_platform_name"],"struct":["Cache","CliArgs","CommandSpec","Config","ConfigSection","CrateDependencyInfo","CrateInfo","EnvFileInfo","EnvInfo","EnvValueConditioned","EnvValueDecode","EnvValuePathGlob","EnvValueScript","EnvValueUnset","ExecutionPlan","ExtendOptions","ExternalConfig","FileScriptValue","FilesFilesModifiedCondition","FlowInfo","FlowState","GlobalConfig","InstallCargoPluginInfo","InstallCrateInfo","InstallRustupComponentInfo","ModifyConfig","PackageInfo","PlatformOverrideTask","RunTaskDetails","RunTaskRoutingInfo","RustVersionCondition","ScriptSections","Step","Task","TaskCondition","TaskIdentifier","TestArg","ToolchainBoundedSpecifier","WatchOptions","Workspace"]};
--------------------------------------------------------------------------------
/examples/plugin_workspace_emulation.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 | skip_git_env_info = true
5 | skip_rust_env_info = true
6 | skip_crate_env_info = true
7 |
8 | [plugins.impl.python]
9 | script = '''
10 | member_run = eq ${CARGO_MAKE_WORKSPACE_EMULATION} 1
11 |
12 | if ${member_run}
13 | cm_plugin_run_task
14 | else
15 | set_env CARGO_MAKE_WORKSPACE_EMULATION 1
16 | set_env CARGO_MAKE_CRATE_WORKSPACE_MEMBERS ${PYTHON_MEMBERS}
17 | args = array_join ${flow.cli.args} " "
18 | exec --fail-on-error cargo make ${flow.task.name} %{args}
19 | end
20 | '''
21 |
22 | [plugins.impl.rust]
23 | script = '''
24 | member_run = eq ${CARGO_MAKE_WORKSPACE_EMULATION} 1
25 |
26 | if ${member_run}
27 | cm_plugin_run_task
28 | else
29 | set_env CARGO_MAKE_WORKSPACE_EMULATION 1
30 | set_env CARGO_MAKE_CRATE_WORKSPACE_MEMBERS ${RUST_MEMBERS}
31 | args = array_join ${flow.cli.args} " "
32 | exec --fail-on-error cargo make ${flow.task.name} %{args}
33 | end
34 | '''
35 |
--------------------------------------------------------------------------------
/examples/script.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [tasks.hello-world]
6 | script = '''
7 | echo start...
8 | echo "Hello World From Script"
9 | echo end...
10 | '''
11 |
12 | [tasks.hello-world-from-script-file]
13 | script = { file = "script.sh" }
14 |
15 | [tasks.hello-world-from-script-file-absolute-path]
16 | script = { file = "${CARGO_MAKE_WORKING_DIRECTORY}/script.sh", absolute_path = true }
17 |
18 | [tasks.default]
19 | dependencies = ["hello-world"]
20 |
21 | [tasks.read-input]
22 | script = ['''
23 | echo Enter Input
24 | read
25 | echo Input: ${REPLY}
26 | ''']
27 |
28 | [tasks.force-pipe-stdin]
29 | env = { CARGO_MAKE_SCRIPT_FORCE_PIPE_STDIN = true }
30 | script = ['''
31 | echo start
32 | sleep 20
33 | echo end
34 | ''']
35 |
36 | [tasks.base-script]
37 | script.pre = "echo start"
38 | script.main = "echo old"
39 | script.post = "echo end"
40 |
41 | [tasks.extended-script]
42 | extend = "base-script"
43 | script.main = "echo new"
44 |
--------------------------------------------------------------------------------
/src/lib/functions/remove_empty_func_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | #[should_panic]
5 | fn remove_empty_invoke_empty() {
6 | invoke(&vec![]);
7 | }
8 |
9 | #[test]
10 | #[should_panic]
11 | fn remove_empty_invoke_invalid_too_many_args() {
12 | invoke(&vec!["TEST".to_string(), "1".to_string()]);
13 | }
14 |
15 | #[test]
16 | fn remove_empty_invoke_exists_with_value() {
17 | envmnt::set("TEST_REMOVE_EMPTY_VALID", "abc");
18 |
19 | let output = invoke(&vec!["TEST_REMOVE_EMPTY_VALID".to_string()]);
20 |
21 | assert_eq!(output, vec!["abc"]);
22 | }
23 |
24 | #[test]
25 | fn remove_empty_invoke_exists_empty() {
26 | envmnt::set("TEST_REMOVE_EMPTY_EMPTY", "");
27 |
28 | let output = invoke(&vec!["TEST_REMOVE_EMPTY_EMPTY".to_string()]);
29 |
30 | assert_eq!(output.len(), 0);
31 | }
32 |
33 | #[test]
34 | fn remove_empty_invoke_not_exists() {
35 | let output = invoke(&vec!["TEST_REMOVE_EMPTY_NOT_EXISTS".to_string()]);
36 |
37 | assert_eq!(output.len(), 0);
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/scriptengine/shell_to_batch.rs:
--------------------------------------------------------------------------------
1 | //! # shell_to_batch
2 | //!
3 | //! Converts shell scripts to windows batch and invokes them.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "shell_to_batch_test.rs"]
8 | mod shell_to_batch_test;
9 |
10 | use crate::command;
11 | use crate::error::CargoMakeError;
12 |
13 | pub(crate) fn execute(
14 | script: &Vec,
15 | cli_arguments: &Vec,
16 | validate: bool,
17 | ) -> Result {
18 | let exit_code = if cfg!(windows) {
19 | let shell_script = script.join("\n");
20 | let windows_batch = shell2batch::convert(&shell_script);
21 |
22 | let windows_script_lines = windows_batch
23 | .split("\n")
24 | .map(|string| string.to_string())
25 | .collect();
26 |
27 | command::run_script_get_exit_code(&windows_script_lines, None, cli_arguments, validate)
28 | } else {
29 | command::run_script_get_exit_code(script, None, cli_arguments, validate)
30 | }?;
31 |
32 | Ok(exit_code == 0)
33 | }
34 |
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_force_plugin_clear.rs:
--------------------------------------------------------------------------------
1 | //! # cm_run_task
2 | //!
3 | //! Enables to run cargo-make tasks from within duckscript.
4 | //!
5 |
6 | use crate::types::FlowState;
7 | use duckscript::types::command::{Command, CommandInvocationContext, CommandResult};
8 | use std::cell::RefCell;
9 | use std::rc::Rc;
10 |
11 | #[derive(Clone)]
12 | pub(crate) struct CommandImpl {
13 | flow_state: Rc>,
14 | }
15 |
16 | impl Command for CommandImpl {
17 | fn name(&self) -> String {
18 | "cm_plugin_force_plugin_clear".to_string()
19 | }
20 |
21 | fn clone_and_box(&self) -> Box {
22 | Box::new((*self).clone())
23 | }
24 |
25 | fn run(&self, _context: CommandInvocationContext) -> CommandResult {
26 | self.flow_state.borrow_mut().forced_plugin = None;
27 |
28 | CommandResult::Continue(Some("true".to_string()))
29 | }
30 | }
31 |
32 | pub(crate) fn create(flow_state: Rc>) -> Box {
33 | Box::new(CommandImpl { flow_state })
34 | }
35 |
--------------------------------------------------------------------------------
/docs/_includes/README.md:
--------------------------------------------------------------------------------
1 | # cargo-make
2 |
3 | [](https://crates.io/crates/cargo-make)
4 | [](https://github.com/sagiegurari/cargo-make/actions)
5 | [](https://codecov.io/gh/sagiegurari/cargo-make)
6 | [](https://github.com/sagiegurari/cargo-make/blob/master/LICENSE)
7 | [](https://crates.io/crates/cargo-make)
8 | [](https://github.com/sagiegurari/cargo-make/releases)
9 | [](https://sagiegurari.github.io/cargo-make)
10 |
11 | > [Rust](https://www.rust-lang.org/) task runner and build tool.
12 |
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/toml.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.pre-format-toml]
3 | category = "Development"
4 |
5 | [tasks.format-toml]
6 | description = "Formats all toml files defined in the CARGO_MAKE_FORMAT_TOML_FILES environment variable."
7 | category = "Development"
8 | condition = { env_set = ["CARGO_MAKE_FORMAT_TOML_FILES"] }
9 | install_crate = { crate_name = "taplo-cli", binary = "taplo", test_arg = [
10 | "--help",
11 | ] }
12 | command = "taplo"
13 | args = [
14 | "format",
15 | "${CARGO_MAKE_FORMAT_TOML_FILES}",
16 | "@@split(CARGO_MAKE_FORMAT_TOML_ARGS, )",
17 | ]
18 |
19 | [tasks.post-format-toml]
20 | category = "Development"
21 |
22 | [tasks.format-toml-flow]
23 | description = "Runs the format toml tasks."
24 | category = "Development"
25 | dependencies = ["pre-format-toml", "format-toml", "post-format-toml"]
26 |
27 | [tasks.format-toml-conditioned-flow]
28 | description = "Runs the format toml tasks if conditions are met."
29 | category = "Development"
30 | condition = { env_set = ["CARGO_MAKE_RUN_TOML_FORMAT"] }
31 | run_task = "format-toml-flow"
32 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/std/process/trait.Termination.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Termination for CargoMakeError "],["impl<T: Any > Termination for SuccessOrCargoMakeError <T>"]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[762]}
--------------------------------------------------------------------------------
/src/makers.rs:
--------------------------------------------------------------------------------
1 | //! # makers
2 | //!
3 | //! Rust task runner and build tool.
4 | //! The makers executable works the same as cargo-make except that it is not invoked
5 | //! as a cargo sub command.
6 | //!
7 | //! # Contributing
8 | //! See [contributing guide](https://github.com/sagiegurari/cargo-make/blob/master/.github/CONTRIBUTING.md)
9 | //!
10 | //! # License
11 | //! Developed by Sagie Gur-Ari and licensed under the
12 | //! [Apache 2](https://github.com/sagiegurari/cargo-make/blob/master/LICENSE) open source license.
13 | //!
14 |
15 | use cli::error::SuccessOrCargoMakeError;
16 |
17 | #[cfg(test)]
18 | #[path = "makers_test.rs"]
19 | mod makers_test;
20 |
21 | fn get_name() -> String {
22 | "makers".to_string()
23 | }
24 |
25 | fn main() -> SuccessOrCargoMakeError {
26 | #[cfg(windows)]
27 | let _ = nu_ansi_term::enable_ansi_support();
28 | let name = get_name();
29 | match cli::run_cli(name, false) {
30 | Ok(_) => Ok(std::process::ExitCode::SUCCESS).into(),
31 | Err(e) => SuccessOrCargoMakeError::Err(e),
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/lib/cache_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use std::env;
3 |
4 | #[test]
5 | fn load_from_path_exists() {
6 | let cwd = env::current_dir().unwrap();
7 | let path = cwd.join("examples/cargo-make");
8 | let cache_data = load_from_path(path);
9 |
10 | assert_eq!(cache_data.last_update_check.unwrap(), 1000u64);
11 | }
12 |
13 | #[test]
14 | fn load_from_path_not_exists() {
15 | let path = PathBuf::from("examples2/.cargo-make");
16 | let cache_data = load_from_path(path);
17 |
18 | assert!(cache_data.last_update_check.is_none());
19 | }
20 |
21 | #[test]
22 | #[ignore]
23 | fn load_with_cargo_home() {
24 | let path = env::current_dir().unwrap();
25 | let directory = path.join("examples/cargo-make");
26 | envmnt::set("CARGO_MAKE_HOME", directory.to_str().unwrap());
27 | let cache_data = load();
28 |
29 | envmnt::remove("CARGO_MAKE_HOME");
30 |
31 | assert_eq!(cache_data.last_update_check.unwrap(), 1000u64);
32 | }
33 |
34 | #[test]
35 | #[ignore]
36 | fn load_without_cargo_home() {
37 | envmnt::remove("CARGO_MAKE_HOME");
38 | load();
39 | }
40 |
--------------------------------------------------------------------------------
/examples/plugin_rust_env.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 | skip_git_env_info = true
5 | skip_rust_env_info = true
6 | skip_crate_env_info = true
7 |
8 | [plugins.impl.rust-env]
9 | script = '''
10 | # make sure the task has a script
11 | assert ${task.has_script}
12 |
13 | taskjson = json_parse ${task.as_json}
14 | script = set ${taskjson.script}
15 | writefile ./target/_tempplugin/main.rs ${script}
16 |
17 | out = exec --fail-on-error rust-script ./target/_tempplugin/main.rs
18 |
19 | output = trim ${out.stdout}
20 | lines = split ${output} \n
21 | for line in ${lines}
22 | parts = split ${line} =
23 | key = array_get ${parts} 0
24 | value = array_get ${parts} 1
25 | set_env ${key} ${value}
26 | end
27 | '''
28 |
29 | [tasks.default]
30 | alias = "test"
31 |
32 | [tasks.test]
33 | dependencies = ["dorust"]
34 | command = "echo"
35 | args = ["${ENV_FROM_RUST1}", "${ENV_FROM_RUST2}"]
36 |
37 | [tasks.dorust]
38 | private = true
39 | plugin = "rust-env"
40 | script = '''
41 | fn main() {
42 | println!("ENV_FROM_RUST1=hello");
43 | println!("ENV_FROM_RUST2=world");
44 | }
45 | '''
46 |
--------------------------------------------------------------------------------
/examples/cwd.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.env]
3 | script = '''
4 | echo CARGO_MAKE_CURRENT_TASK_NAME: ${CARGO_MAKE_CURRENT_TASK_NAME}
5 | echo CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE: ${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE}
6 | echo CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY: ${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}
7 | '''
8 |
9 | [tasks.cwd]
10 | command = "pwd"
11 | condition_script = ["echo pwd during condition:", "pwd"]
12 | install_script = '''
13 | echo pwd during installation:
14 | pwd
15 | '''
16 |
17 | [tasks.change-cwd]
18 | command = "pwd"
19 | cwd = "./examples/files"
20 | condition_script = ["echo pwd during condition:", "pwd"]
21 | install_script = '''
22 | echo pwd during installation:
23 | pwd
24 | '''
25 |
26 | [tasks.makefile-cwd]
27 | command = "pwd"
28 | cwd = "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}"
29 | condition_script = ["echo pwd during condition:", "pwd"]
30 | install_script = '''
31 | echo pwd during installation:
32 | pwd
33 | '''
34 |
35 | [tasks.back-again]
36 | alias = "cwd"
37 |
38 | [tasks.all]
39 | dependencies = ["env", "cwd", "change-cwd", "makefile-cwd", "back-again"]
40 |
--------------------------------------------------------------------------------
/docs/api/static.files/LICENSE-MIT-23f18e03.txt:
--------------------------------------------------------------------------------
1 | Permission is hereby granted, free of charge, to any
2 | person obtaining a copy of this software and associated
3 | documentation files (the "Software"), to deal in the
4 | Software without restriction, including without
5 | limitation the rights to use, copy, modify, merge,
6 | publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software
8 | is furnished to do so, subject to the following
9 | conditions:
10 |
11 | The above copyright notice and this permission notice
12 | shall be included in all copies or substantial portions
13 | of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/target_dir_and_triple/x86_64-pc-windows-msvc.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi-return-struct-as-int": true,
3 | "arch": "x86_64",
4 | "cpu": "x86-64",
5 | "crt-static-allows-dylibs": true,
6 | "crt-static-respected": true,
7 | "data-layout": "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
8 | "dll-prefix": "",
9 | "dll-suffix": ".dll",
10 | "dynamic-linking": true,
11 | "emit-debug-gdb-scripts": false,
12 | "env": "msvc",
13 | "exe-suffix": ".exe",
14 | "executables": true,
15 | "is-builtin": false,
16 | "is-like-msvc": true,
17 | "is-like-windows": true,
18 | "linker-flavor": "msvc",
19 | "lld-flavor": "link",
20 | "llvm-target": "x86_64-pc-windows-msvc",
21 | "max-atomic-width": 64,
22 | "no-default-libraries": false,
23 | "os": "windows",
24 | "pre-link-args": {
25 | "lld-link": [
26 | "/NOLOGO"
27 | ],
28 | "msvc": [
29 | "/NOLOGO"
30 | ]
31 | },
32 | "requires-uwtable": true,
33 | "staticlib-prefix": "",
34 | "staticlib-suffix": ".lib",
35 | "target-family": "windows",
36 | "target-pointer-width": "64",
37 | "vendor": "pc"
38 | }
39 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/marker/trait.Copy.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Copy for CargoMakeErrorDiscriminants "],["impl Copy for UnstableFeature "],["impl Copy for EnvValueUnset "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[864]}
--------------------------------------------------------------------------------
/examples/install.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [tasks.simple-example]
6 | install_crate = { min_version = "0.0.1" }
7 | command = "cargo"
8 | args = ["make", "--version"]
9 |
10 | [tasks.complex-example]
11 | install_crate = { crate_name = "cargo-make", binary = "cargo", test_arg = [
12 | "make",
13 | "--version",
14 | ], min_version = "0.0.1" }
15 | command = "cargo"
16 | args = ["make", "--version"]
17 |
18 | [tasks.alt-command-example1]
19 | install_crate = { install_command = "custom-install" }
20 | command = "cargo"
21 | args = ["somecrate"]
22 |
23 | [tasks.alt-command-example2]
24 | install_crate = { crate_name = "somecrate", install_command = "custom-install" }
25 |
26 | [tasks.alt-command-example3.install_crate]
27 | crate_name = "cargo-make"
28 | binary = "cargo"
29 | test_arg = ["make", "--help"]
30 | version = "9999.0.0"
31 | install_command = "custom-install"
32 | force = false
33 |
34 | [tasks.fmt]
35 | install_crate = { crate_name = "rustfmt", binary = "rustfmt", version = "1.4.37", test_arg = "--help" }
36 | command = "cargo"
37 | args = ["fmt", "badarg"]
38 |
39 | [tasks.make]
40 | command = "cargo"
41 | args = ["make", "--version"]
42 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/env_target_dir_and_triple/x86_64-pc-windows-msvc.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi-return-struct-as-int": true,
3 | "arch": "x86_64",
4 | "cpu": "x86-64",
5 | "crt-static-allows-dylibs": true,
6 | "crt-static-respected": true,
7 | "data-layout": "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
8 | "dll-prefix": "",
9 | "dll-suffix": ".dll",
10 | "dynamic-linking": true,
11 | "emit-debug-gdb-scripts": false,
12 | "env": "msvc",
13 | "exe-suffix": ".exe",
14 | "executables": true,
15 | "has-elf-tls": true,
16 | "is-builtin": false,
17 | "is-like-msvc": true,
18 | "is-like-windows": true,
19 | "linker-flavor": "msvc",
20 | "lld-flavor": "link",
21 | "llvm-target": "x86_64-pc-windows-msvc",
22 | "max-atomic-width": 64,
23 | "no-default-libraries": false,
24 | "os": "windows",
25 | "pre-link-args": {
26 | "lld-link": [
27 | "/NOLOGO"
28 | ],
29 | "msvc": [
30 | "/NOLOGO"
31 | ]
32 | },
33 | "requires-uwtable": true,
34 | "staticlib-prefix": "",
35 | "staticlib-suffix": ".lib",
36 | "target-family": "windows",
37 | "target-pointer-width": "64",
38 | "vendor": "pc"
39 | }
40 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on: [push, pull_request]
3 | concurrency:
4 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5 | cancel-in-progress: true
6 |
7 | env:
8 | CLICOLOR_FORCE: 1
9 | CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
10 |
11 | jobs:
12 | ci:
13 | name: CI
14 | runs-on: ${{ matrix.os }}
15 | strategy:
16 | fail-fast: false
17 | matrix:
18 | rust: [stable, beta, nightly]
19 | os: [ubuntu-latest, windows-latest, macOS-latest]
20 | steps:
21 | - name: Checkout
22 | uses: actions/checkout@v4
23 | - name: Install rust
24 | uses: dtolnay/rust-toolchain@master
25 | with:
26 | toolchain: ${{ matrix.rust }}
27 | - name: Install cargo-make
28 | run: cargo install --debug cargo-make
29 | - name: Rust Cache
30 | uses: Swatinem/rust-cache@v2
31 | - name: Run CI
32 | env:
33 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
34 | if: matrix.rust == 'stable' || matrix.rust == 'beta' || matrix.rust == 'nightly'
35 | run: cargo run --bin cargo-make --target-dir target/ci -- make --env "CODECOV_TOKEN=${CODECOV_TOKEN}" ci-flow
36 |
--------------------------------------------------------------------------------
/examples/rust-script.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | load_script = """
4 | #!@rust
5 |
6 | fn main() {
7 | println!("test load script invocation via rust");
8 | }
9 | """
10 |
11 | [tasks.rust]
12 | script_runner = "@rust"
13 | script = '''
14 | //! ```cargo
15 | //! [dependencies]
16 | //! envmnt = "*"
17 | //! ```
18 | fn main() {
19 | let value = envmnt::get_or("PATH", "NO PATH VAR DEFINED");
20 | println!("Path Value: {}", &value);
21 | }
22 | '''
23 |
24 | [tasks.rust-simple]
25 | script_runner = "@rust"
26 | script = '''
27 | fn main() {
28 | println!("test");
29 | }
30 | '''
31 |
32 | [tasks.cargo-script]
33 | env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "cargo-script" }
34 | script_runner = "@rust"
35 | script = '''
36 | fn main() {
37 | println!("test");
38 | }
39 | '''
40 |
41 | [tasks.cargo-play]
42 | env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "cargo-play" }
43 | script_runner = "@rust"
44 | script = '''
45 | fn main() {
46 | println!("test");
47 | }
48 | '''
49 |
50 | [tasks.rust-script]
51 | env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "rust-script" }
52 | script_runner = "@rust"
53 | script = '''
54 | fn main() {
55 | println!("test");
56 | }
57 | '''
58 |
--------------------------------------------------------------------------------
/src/lib/test/workspace2/member4/x86_64-pc-windows-msvc.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi-return-struct-as-int": true,
3 | "arch": "x86_64",
4 | "cpu": "x86-64",
5 | "crt-static-allows-dylibs": true,
6 | "crt-static-respected": true,
7 | "data-layout": "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
8 | "dll-prefix": "",
9 | "dll-suffix": ".dll",
10 | "dynamic-linking": true,
11 | "emit-debug-gdb-scripts": false,
12 | "env": "msvc",
13 | "exe-suffix": ".exe",
14 | "executables": true,
15 | "has-elf-tls": true,
16 | "is-builtin": true,
17 | "is-like-msvc": true,
18 | "is-like-windows": true,
19 | "linker-flavor": "msvc",
20 | "lld-flavor": "link",
21 | "llvm-target": "x86_64-pc-windows-msvc",
22 | "max-atomic-width": 64,
23 | "no-default-libraries": false,
24 | "os": "windows",
25 | "pre-link-args": {
26 | "lld-link": [
27 | "/NOLOGO"
28 | ],
29 | "msvc": [
30 | "/NOLOGO"
31 | ]
32 | },
33 | "requires-uwtable": true,
34 | "split-debuginfo": "packed",
35 | "staticlib-prefix": "",
36 | "staticlib-suffix": ".lib",
37 | "target-family": "windows",
38 | "target-pointer-width": "64",
39 | "vendor": "pc"
40 | }
41 |
--------------------------------------------------------------------------------
/examples/plugin_powershell.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 | skip_git_env_info = true
5 | skip_rust_env_info = true
6 | skip_crate_env_info = true
7 |
8 | [plugins.impl.powershell]
9 | script = '''
10 | # Adds simpler powershell integration
11 |
12 | # make sure we are on windows
13 | windows = is_windows
14 | assert ${windows}
15 |
16 | # make sure the task has args
17 | args_empty = array_is_empty ${task.args}
18 | assert_false ${args_empty}
19 |
20 | task_definition = json_parse --collection ${task.as_json}
21 |
22 | # prepend powershell args to task args
23 | powershell_args = array -C
24 | all_args = array_concat ${powershell_args} ${task.args}
25 | args = map_get ${task_definition} args
26 | release ${args}
27 | map_put ${task_definition} args ${all_args}
28 |
29 | # set powershell command
30 | map_put ${task_definition} command pwsh.exe
31 |
32 | powershell_task_json = json_encode --collection ${task_definition}
33 |
34 | echo Custom Task:\n${powershell_task_json}
35 | cm_plugin_run_custom_task ${powershell_task_json}
36 | '''
37 |
38 | [tasks.default]
39 | alias = "test"
40 |
41 | [tasks.test]
42 | plugin = "powershell"
43 | args = ["echo hello from windows powershell"]
44 |
--------------------------------------------------------------------------------
/examples/profile.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | COMMON = "COMMON"
4 | PROFILE_NAME = "${CARGO_MAKE_PROFILE}"
5 | CARGO_PROFILE_NAME = "${CARGO_MAKE_CARGO_PROFILE}"
6 | IS_CI = false
7 |
8 | [config]
9 | additional_profiles = ["ci", "ci-all-tasks"]
10 |
11 | [env.development]
12 | IS_DEV = "TRUE"
13 | IS_PROD = "FALSE"
14 |
15 | [env.production]
16 | IS_DEV = "FALSE"
17 | IS_PROD = "TRUE"
18 |
19 | [env.ci]
20 | IS_CI = true
21 |
22 | [tasks.echo]
23 | script = '''
24 | echo COMMON: ${COMMON}
25 | echo PROFILE_NAME: ${PROFILE_NAME}
26 | echo CARGO_PROFILE_NAME: ${CARGO_PROFILE_NAME}
27 | echo IS_DEV: ${IS_DEV}
28 | echo IS_PROD: ${IS_PROD}
29 | echo IS_CI: ${IS_CI}
30 |
31 |
32 | echo CARGO_MAKE_RUN_CHECK_FORMAT: ${CARGO_MAKE_RUN_CHECK_FORMAT}
33 | echo CARGO_MAKE_RUN_BENCH: ${CARGO_MAKE_RUN_BENCH}
34 | echo CARGO_MAKE_RUN_CLIPPY: ${CARGO_MAKE_RUN_CLIPPY}
35 | echo CARGO_MAKE_RUN_CODECOV: ${CARGO_MAKE_RUN_CODECOV}
36 | '''
37 |
38 | [tasks.echo-development]
39 | condition = { profiles = ["development"] }
40 | command = "echo"
41 | args = ["running in development profile"]
42 |
43 | [tasks.echo-production]
44 | condition = { profiles = ["production"] }
45 | command = "echo"
46 | args = ["running in production profile"]
47 |
--------------------------------------------------------------------------------
/src/lib/storage_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | #[ignore]
5 | fn get_storage_directory_no_env_no_os_dir() {
6 | envmnt::remove("CARGO_MAKE_HOME");
7 |
8 | let directory = get_storage_directory(None, "test.txt", false).unwrap();
9 | let legacy_directory = get_legacy_directory().unwrap();
10 |
11 | assert_eq!(directory, legacy_directory);
12 | }
13 |
14 | #[test]
15 | #[ignore]
16 | fn get_storage_directory_with_env() {
17 | let env_directory = env::current_dir().unwrap();
18 | envmnt::set("CARGO_MAKE_HOME", env_directory.to_str().unwrap());
19 |
20 | let directory = get_storage_directory(None, "test.txt", false).unwrap();
21 |
22 | envmnt::remove("CARGO_MAKE_HOME");
23 |
24 | assert_eq!(directory, env_directory);
25 | }
26 |
27 | #[test]
28 | #[ignore]
29 | fn get_storage_directory_no_env_with_os_dir_file_exists() {
30 | envmnt::remove("CARGO_MAKE_HOME");
31 |
32 | let path = env::current_dir().unwrap();
33 | let mut os_directory = path.join("examples");
34 | let directory = get_storage_directory(Some(os_directory.clone()), "cache.toml", true).unwrap();
35 |
36 | os_directory = os_directory.join("cargo-make");
37 | assert_eq!(directory, os_directory);
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/mod.rs:
--------------------------------------------------------------------------------
1 | //! # sdk
2 | //!
3 | //! Loads the cargo-make duckscript plugin SDK.
4 | //!
5 |
6 | mod cm_plugin_check_task_condition;
7 | mod cm_plugin_force_plugin_clear;
8 | mod cm_plugin_force_plugin_set;
9 | mod cm_plugin_run_custom_task;
10 | mod cm_plugin_run_task;
11 |
12 | use crate::types::{FlowInfo, FlowState, Step};
13 | use duckscript::types::command::Commands;
14 | use duckscript::types::error::ScriptError;
15 | use std::cell::RefCell;
16 | use std::rc::Rc;
17 |
18 | /// Loads all core commands
19 | pub(crate) fn load(
20 | flow_info: &FlowInfo,
21 | flow_state: Rc>,
22 | step: &Step,
23 | commands: &mut Commands,
24 | ) -> Result<(), ScriptError> {
25 | commands.set(cm_plugin_check_task_condition::create(flow_info, step))?;
26 | commands.set(cm_plugin_force_plugin_clear::create(flow_state.clone()))?;
27 | commands.set(cm_plugin_force_plugin_set::create(flow_state.clone(), step))?;
28 | commands.set(cm_plugin_run_custom_task::create(
29 | flow_info,
30 | flow_state.clone(),
31 | step,
32 | ))?;
33 | commands.set(cm_plugin_run_task::create(
34 | flow_info,
35 | flow_state.clone(),
36 | step,
37 | ))?;
38 |
39 | Ok(())
40 | }
41 |
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_force_plugin_set.rs:
--------------------------------------------------------------------------------
1 | //! # cm_run_task
2 | //!
3 | //! Enables to run cargo-make tasks from within duckscript.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "cm_plugin_force_plugin_set_test.rs"]
8 | mod cm_plugin_force_plugin_set_test;
9 |
10 | use crate::types::{FlowState, Step};
11 | use duckscript::types::command::{Command, CommandInvocationContext, CommandResult};
12 | use std::cell::RefCell;
13 | use std::rc::Rc;
14 |
15 | #[derive(Clone)]
16 | pub(crate) struct CommandImpl {
17 | flow_state: Rc>,
18 | step: Step,
19 | }
20 |
21 | impl Command for CommandImpl {
22 | fn name(&self) -> String {
23 | "cm_plugin_force_plugin_set".to_string()
24 | }
25 |
26 | fn clone_and_box(&self) -> Box {
27 | Box::new((*self).clone())
28 | }
29 |
30 | fn run(&self, _context: CommandInvocationContext) -> CommandResult {
31 | self.flow_state.borrow_mut().forced_plugin = self.step.config.plugin.clone();
32 |
33 | CommandResult::Continue(Some("true".to_string()))
34 | }
35 | }
36 |
37 | pub(crate) fn create(flow_state: Rc>, step: &Step) -> Box {
38 | Box::new(CommandImpl {
39 | flow_state,
40 | step: step.clone(),
41 | })
42 | }
43 |
--------------------------------------------------------------------------------
/src/lib/descriptor/cargo_alias_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | fn load_from_file_no_file() {
5 | let tasks = load_from_file("./badfile.toml").unwrap();
6 |
7 | assert!(tasks.is_empty());
8 | }
9 |
10 | #[test]
11 | fn load_from_file_parse_error() {
12 | let tasks = load_from_file("./src/lib/test/cargo/invalid_config.toml").unwrap();
13 |
14 | assert!(tasks.is_empty());
15 | }
16 |
17 | #[test]
18 | fn load_from_file_no_alias_data() {
19 | let tasks = load_from_file("./Cargo.toml").unwrap();
20 |
21 | assert!(tasks.is_empty());
22 | }
23 |
24 | #[test]
25 | fn load_from_file_aliases_found() {
26 | let tasks = load_from_file("./src/lib/test/cargo/config.toml").unwrap();
27 |
28 | assert_eq!(tasks.len(), 4);
29 |
30 | let mut map = HashMap::new();
31 | for pair in &tasks {
32 | map.insert(pair.0.clone(), pair.1.clone());
33 | }
34 |
35 | let mut task = map.get("b2").unwrap();
36 | assert_eq!(task.args.clone().unwrap(), vec!["b2"]);
37 | task = map.get("c2").unwrap();
38 | assert_eq!(task.args.clone().unwrap(), vec!["c2"]);
39 | task = map.get("t2").unwrap();
40 | assert_eq!(task.args.clone().unwrap(), vec!["t2"]);
41 | task = map.get("test_specific").unwrap();
42 | assert_eq!(task.args.clone().unwrap(), vec!["test_specific"]);
43 | }
44 |
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/build-file.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.pre-build-file-increment]
3 | category = "Tools"
4 |
5 | [tasks.build-file-increment]
6 | description = "Increments (or creates) the build number in the build file, defined in CARGO_MAKE_BUILD_NUMBER_FILE environment variable."
7 | category = "Tools"
8 | condition = { env_set = ["CARGO_MAKE_BUILD_NUMBER_FILE"] }
9 | script = '''
10 | #!@duckscript
11 | build_number_file_exists = is_path_exists ${CARGO_MAKE_BUILD_NUMBER_FILE}
12 |
13 | if ${build_number_file_exists}
14 | build_number = readfile ${CARGO_MAKE_BUILD_NUMBER_FILE}
15 | build_number = trim ${build_number}
16 | build_number = calc ${build_number} + 1
17 | else
18 | build_number = set 1
19 | end
20 |
21 | # update build number file
22 | writefile ${CARGO_MAKE_BUILD_NUMBER_FILE} ${build_number}
23 |
24 | # set the CARGO_MAKE_BUILD_NUMBER environment variable
25 | set_env CARGO_MAKE_BUILD_NUMBER ${build_number}
26 | '''
27 |
28 | [tasks.post-build-file-increment]
29 | category = "Tools"
30 |
31 | [tasks.build-file-increment-flow]
32 | description = "Increments (or creates) the build number in the build file, defined in CARGO_MAKE_BUILD_NUMBER_FILE environment variable."
33 | category = "Tools"
34 | dependencies = [
35 | "pre-build-file-increment",
36 | "build-file-increment",
37 | "post-build-file-increment",
38 | ]
39 |
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_check_task_condition.rs:
--------------------------------------------------------------------------------
1 | //! # cm_check_task_condition
2 | //!
3 | //! Enables to run cargo-make tasks from within duckscript.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "cm_plugin_check_task_condition_test.rs"]
8 | mod cm_plugin_check_task_condition_test;
9 |
10 | use crate::runner;
11 | use crate::types::{FlowInfo, Step};
12 | use duckscript::types::command::{Command, CommandInvocationContext, CommandResult};
13 |
14 | #[derive(Clone)]
15 | pub(crate) struct CommandImpl {
16 | flow_info: FlowInfo,
17 | step: Step,
18 | }
19 |
20 | impl Command for CommandImpl {
21 | fn name(&self) -> String {
22 | "cm_plugin_check_task_condition".to_string()
23 | }
24 |
25 | fn clone_and_box(&self) -> Box {
26 | Box::new((*self).clone())
27 | }
28 |
29 | fn run(&self, _context: CommandInvocationContext) -> CommandResult {
30 | let passed = runner::validate_condition(&self.flow_info, &self.step);
31 |
32 | match passed {
33 | Ok(r) => CommandResult::Continue(Some(r.to_string())),
34 | Err(e) => CommandResult::Error(e.to_string()),
35 | }
36 | }
37 | }
38 |
39 | pub(crate) fn create(flow_info: &FlowInfo, step: &Step) -> Box {
40 | Box::new(CommandImpl {
41 | flow_info: flow_info.clone(),
42 | step: step.clone(),
43 | })
44 | }
45 |
--------------------------------------------------------------------------------
/docs/assets/css/style.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | @import "jekyll-theme-cayman";
5 |
6 | body {
7 | width: 100%;
8 | display: flex;
9 | flex-direction: column;
10 |
11 | .page-header {
12 | flex-grow: 0;
13 | width: 100%;
14 | }
15 |
16 | .main-content {
17 | flex-grow: 1;
18 | width: 100%;
19 | max-width: 100%;
20 | margin: 0;
21 | }
22 |
23 | .site-footer-credits {
24 | display: none;
25 | }
26 |
27 | .site {
28 | display: flex;
29 | flex-direction: row;
30 |
31 | .site-nav {
32 | flex-grow: 0;
33 | font-size: 14px;
34 | min-width: 245px;
35 | padding-top: 37px;
36 |
37 | ul ul {
38 | padding-left: 10px;
39 | list-style-type: disc;
40 | }
41 | }
42 |
43 | .site-content {
44 | flex-grow: 1;
45 | overflow-x: hidden;
46 | }
47 | }
48 |
49 | @media screen and (max-width: 800px) {
50 | .main-content {
51 | padding: 0;
52 | }
53 |
54 | .site {
55 | display: block;
56 |
57 | .site-content {
58 | padding: 0 1rem;
59 | }
60 | }
61 |
62 | .site-footer {
63 | padding: 1rem;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/examples/workspace2/Makefile.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
4 |
5 | [tasks.echo]
6 | script = ["echo hello from workspace"]
7 |
8 | [tasks.echo-member]
9 | script = ["echo hello from member"]
10 |
11 | [tasks.echo_top_and_members]
12 | workspace = false
13 | dependencies = ["echo"]
14 | run_task = { name = "echo", fork = true }
15 |
16 | [tasks.echo_top_and_member_1_2]
17 | workspace = false
18 | env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = ["member1", "member2"] }
19 | dependencies = ["echo"]
20 | run_task = { name = "echo", fork = true }
21 |
22 | [tasks.echo_top_and_member_2]
23 | workspace = false
24 | env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = "member2" }
25 | dependencies = ["echo"]
26 | run_task = { name = "echo", fork = true }
27 |
28 | [tasks.workspace_root]
29 | script = [
30 | "echo root at: CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}",
31 | ]
32 |
33 | [tasks.workspace_root_top_and_members]
34 | workspace = false
35 | dependencies = ["workspace_root"]
36 | run_task = { name = "workspace_root", fork = true }
37 |
38 | [tasks.echo_run_task]
39 | run_task = "echo"
40 |
41 | [tasks.composite_with_run_task]
42 | workspace = false
43 | dependencies = ["echo_run_task"]
44 | run_task = { name = "echo-member", fork = true }
45 |
46 | [tasks.varargs]
47 | command = "echo"
48 | args = ["args are:", "${@}"]
49 |
--------------------------------------------------------------------------------
/docs/vscode-example/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "Build",
6 | "detail": "Build the rust project",
7 | "type": "process",
8 | "group": "build",
9 | "command": "cargo",
10 | "args": [
11 | "make",
12 | "build"
13 | ]
14 | },
15 | {
16 | "label": "Clean",
17 | "detail": "Clean the target build directory",
18 | "type": "process",
19 | "group": "build",
20 | "command": "cargo",
21 | "args": [
22 | "make",
23 | "clean"
24 | ]
25 | },
26 | {
27 | "label": "Format",
28 | "detail": "Auto format the code",
29 | "type": "process",
30 | "group": "build",
31 | "command": "cargo",
32 | "args": [
33 | "make",
34 | "format-flow"
35 | ]
36 | },
37 | {
38 | "label": "Test",
39 | "detail": "Run the tests",
40 | "type": "process",
41 | "group": "build",
42 | "command": "cargo",
43 | "args": [
44 | "make",
45 | "test-flow"
46 | ]
47 | },
48 | ],
49 | }
50 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 |
3 |
4 | ## Issues
5 |
6 | Found a bug? Got a question? Want some enhancement?
7 | First place to go is the repository issues section, and I'll try to help as much as possible.
8 |
9 | ## Pull Requests
10 |
11 | Fixed a bug or just want to provided additional functionality?
12 | Simply fork this repository, implement your changes and create a pull request.
13 | Few guidelines regarding pull requests:
14 |
15 | * This repository is integrated with github actions for continuous integration.
16 |
17 | Your pull request build must pass (the build will run automatically).
18 | You can run the following command locally to ensure the build will pass:
19 |
20 | ````sh
21 | cargo make ci-flow
22 | ````
23 |
24 | * There are many automatic unit tests as part of the library which provide full coverage of the functionality. Any fix/enhancement must come with a set of tests to ensure it's working well.
25 |
26 | * _For Windows users_: Few windows specific tests run powershell scripts via cargo-make to test powershell support. For those tests to pass, you need to allow to run PowerShell scripts (see [About Execution Policies](https:/go.microsoft.com/fwlink/?LinkID=135170) for more info). Run in PS:
27 |
28 | ```ps
29 | Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/api/src-files.js:
--------------------------------------------------------------------------------
1 | var srcIndex = new Map(JSON.parse('[["cargo_make",["",[],["main.rs"]]],["cli",["",[["cli_commands",[],["diff_steps.rs","list_steps.rs","mod.rs","print_steps.rs"]],["descriptor",[["makefiles",[],["mod.rs"]]],["cargo_alias.rs","descriptor_deserializer.rs","env.rs","mod.rs"]],["environment",[],["crateinfo.rs","mod.rs"]],["functions",[],["decode_func.rs","getat_func.rs","mod.rs","remove_empty_func.rs","split_func.rs","trim_func.rs"]],["installer",[],["cargo_plugin_installer.rs","crate_installer.rs","crate_version_check.rs","mod.rs","rustup_component_installer.rs"]],["plugin",[["sdk",[],["cm_plugin_check_task_condition.rs","cm_plugin_force_plugin_clear.rs","cm_plugin_force_plugin_set.rs","cm_plugin_run_custom_task.rs","cm_plugin_run_task.rs","mod.rs"]]],["descriptor.rs","mod.rs","runner.rs","types.rs"]],["scriptengine",[["duck_script",[["sdk",[],["cm_run_task.rs","mod.rs"]]],["mod.rs"]]],["generic_script.rs","mod.rs","os_script.rs","rsscript.rs","script_utils.rs","shebang_script.rs","shell_to_batch.rs"]]],["cache.rs","cli.rs","cli_parser.rs","command.rs","completion.rs","condition.rs","config.rs","error.rs","execution_plan.rs","io.rs","legacy.rs","logger.rs","mod.rs","profile.rs","proxy_task.rs","recursion_level.rs","runner.rs","storage.rs","time_summary.rs","toolchain.rs","types.rs","version.rs"]]],["makers",["",[],["makers.rs"]]]]'));
2 | createSrcSidebar();
3 | //{"start":36,"fragment_lengths":[34,1245,33]}
--------------------------------------------------------------------------------
/examples/toolchain.toml:
--------------------------------------------------------------------------------
1 |
2 | [env]
3 | NIGHTLY_VERSION = "2019-07-16"
4 |
5 | [tasks.rustc-version-stable]
6 | toolchain = "stable"
7 | command = "rustc"
8 | args = ["--version"]
9 |
10 | [tasks.rustc-version-stable-edition-2021]
11 | toolchain = { channel = "stable", min_version = "1.56" }
12 | command = "rustc"
13 | args = ["--version"]
14 |
15 | [tasks.rustc-version-nightly]
16 | toolchain = "nightly"
17 | command = "rustc"
18 | args = ["--version"]
19 |
20 | [tasks.rustc-version-flow]
21 | dependencies = [
22 | "rustc-version-stable",
23 | "rustc-version-stable-edition-2021",
24 | "rustc-version-nightly",
25 | ]
26 |
27 | [tasks.echo-cargo-env]
28 | script = '''
29 | echo CARGO=${CARGO}
30 | echo RUSTC=${RUSTC}
31 | echo RUSTDOC=${RUSTDOC}
32 | echo RUSTFLAGS=${RUSTFLAGS}
33 | '''
34 |
35 | [tasks.echo-cargo-stable]
36 | extend = "echo-cargo-env"
37 | toolchain = "stable"
38 |
39 | [tasks.stable]
40 | alias = "echo-cargo-stable"
41 |
42 | [tasks.echo-cargo-nightly]
43 | extend = "echo-cargo-env"
44 | toolchain = "nightly"
45 |
46 | [tasks.nightly]
47 | alias = "echo-cargo-nightly"
48 |
49 | [tasks.echo-cargo-all]
50 | dependencies = ["echo-cargo-stable", "echo-cargo-nightly"]
51 |
52 | [tasks.with_env_vars]
53 | toolchain = "nightly-${NIGHTLY_VERSION}"
54 | command = "rustc"
55 | args = ["--version"]
56 |
57 | [tasks.empty_value]
58 | toolchain = ""
59 | command = "rustc"
60 | args = ["--version"]
61 |
--------------------------------------------------------------------------------
/src/lib/functions/getat_func.rs:
--------------------------------------------------------------------------------
1 | //! # getat_func
2 | //!
3 | //! Split function which returns only the requested item from the created array.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "getat_func_test.rs"]
8 | mod getat_func_test;
9 |
10 | pub(crate) fn invoke(function_args: &Vec) -> Vec {
11 | if function_args.len() != 3 {
12 | error!(
13 | "split expects only 3 arguments (environment variable name, split by character, index)"
14 | );
15 | }
16 |
17 | let env_key = function_args[0].clone();
18 | let split_by = function_args[1].clone();
19 | let index: usize = match function_args[2].parse() {
20 | Ok(value) => value,
21 | Err(error) => {
22 | error!("Invalid index value: {}", &error);
23 | return vec![]; // should not get here
24 | }
25 | };
26 |
27 | if split_by.len() != 1 {
28 | error!("split expects a single character separator");
29 | }
30 |
31 | let split_by_char = split_by.chars().next().unwrap();
32 |
33 | let value = envmnt::get_or(&env_key, "");
34 |
35 | if value.len() > index {
36 | let splitted = value.split(split_by_char);
37 |
38 | let splitted_vec: Vec = splitted.map(|str_value| str_value.to_string()).collect();
39 | let value = splitted_vec[index].clone();
40 |
41 | vec![value]
42 | } else {
43 | vec![]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/lib/storage.rs:
--------------------------------------------------------------------------------
1 | //! # storage
2 | //!
3 | //! Provides storage related utilities such as config/cache directory locations.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "storage_test.rs"]
8 | mod storage_test;
9 |
10 | use crate::legacy;
11 | use std::env;
12 | use std::path::{Path, PathBuf};
13 |
14 | fn get_legacy_directory() -> Option {
15 | legacy::get_cargo_make_home()
16 | }
17 |
18 | pub(crate) fn get_storage_directory(
19 | os_directory: Option,
20 | file_name: &str,
21 | migrate: bool,
22 | ) -> Option {
23 | match env::var("CARGO_MAKE_HOME") {
24 | // if env is defined, it is taken as highest priority
25 | Ok(directory) => Some(PathBuf::from(directory)),
26 | _ => {
27 | match os_directory {
28 | Some(directory) => {
29 | let home_directory = directory.join("cargo-make");
30 |
31 | let file_path = Path::new(&directory).join(file_name);
32 |
33 | // migrate old data to new directory
34 | if !file_path.exists() && migrate {
35 | legacy::migrate(home_directory.clone(), file_name);
36 | }
37 |
38 | Some(home_directory)
39 | }
40 | None => get_legacy_directory(), // in case no dir is defined for system, default to old approach
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/fmt/trait.Display.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Display for CargoMakeError "],["impl Display for ToolchainSpecifier "],["impl Display for TaskIdentifier "],["impl Display for ToolchainBoundedSpecifier "]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[1158]}
--------------------------------------------------------------------------------
/src/lib/config.rs:
--------------------------------------------------------------------------------
1 | //! # config
2 | //!
3 | //! Enable to load/store user level configuration for cargo-make.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "config_test.rs"]
8 | mod config_test;
9 |
10 | use crate::error::CargoMakeError;
11 | use crate::storage;
12 | use crate::types::GlobalConfig;
13 | use fsio::file::read_text_file;
14 | use fsio::path::from_path::FromPath;
15 | use std::path::{Path, PathBuf};
16 |
17 | pub static CONFIG_FILE: &'static str = "config.toml";
18 |
19 | pub fn get_config_directory() -> Option {
20 | let os_directory = dirs_next::config_dir();
21 | storage::get_storage_directory(os_directory, CONFIG_FILE, true)
22 | }
23 |
24 | pub fn load_from_path(directory: PathBuf) -> Result {
25 | let file_path = Path::new(&directory).join(CONFIG_FILE);
26 | debug!("Loading config from: {:#?}", &file_path);
27 |
28 | if file_path.exists() {
29 | let config_str = read_text_file(&file_path)?;
30 | let mut global_config: GlobalConfig = toml::from_str(&config_str)?;
31 |
32 | global_config.file_name = Some(FromPath::from_path(&file_path));
33 |
34 | Ok(global_config)
35 | } else {
36 | Ok(GlobalConfig::new())
37 | }
38 | }
39 |
40 | /// Returns the configuration
41 | pub fn load() -> Result {
42 | match get_config_directory() {
43 | Some(directory) => load_from_path(directory),
44 | None => Ok(GlobalConfig::new()),
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/lib/scriptengine/script_utils_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::io;
3 |
4 | #[test]
5 | fn create_script_file_text() {
6 | let file =
7 | create_script_file(&vec!["test".to_string(), "end".to_string()], ".testfile").unwrap();
8 | assert!(file.ends_with(".testfile"));
9 |
10 | let text = fsio::file::read_text_file(&file).unwrap();
11 |
12 | io::delete_file(&file);
13 |
14 | assert_eq!("test\nend".to_string(), text);
15 | }
16 |
17 | #[test]
18 | fn create_persisted_script_file_text() {
19 | let mut file =
20 | create_persisted_script_file(&vec!["test".to_string(), "end".to_string()], ".testfile")
21 | .unwrap();
22 | assert!(file.ends_with(".testfile"));
23 | let mut text = fsio::file::read_text_file(&file).unwrap();
24 | io::delete_file(&file);
25 | assert_eq!("test\nend".to_string(), text);
26 |
27 | let file1 =
28 | create_persisted_script_file(&vec!["test".to_string(), "end".to_string()], ".testfile")
29 | .unwrap();
30 | assert_eq!(file, file1);
31 | text = fsio::file::read_text_file(&file).unwrap();
32 | assert_eq!("test\nend".to_string(), text);
33 | io::delete_file(&file);
34 |
35 | file = create_persisted_script_file(&vec!["test2".to_string(), "end".to_string()], ".testfile")
36 | .unwrap();
37 | assert_ne!(file, file1);
38 | text = fsio::file::read_text_file(&file).unwrap();
39 | assert_eq!("test2\nend".to_string(), text);
40 | io::delete_file(&file);
41 | }
42 |
--------------------------------------------------------------------------------
/src/lib/functions/trim_func.rs:
--------------------------------------------------------------------------------
1 | //! # trim_func
2 | //!
3 | //! Takes an environment variable name and returns its value trimmed.
4 | //! The value will be removed if empty.
5 | //!
6 |
7 | use crate::error::CargoMakeError;
8 |
9 | #[cfg(test)]
10 | #[path = "trim_func_test.rs"]
11 | mod trim_func_test;
12 |
13 | pub(crate) fn invoke(function_args: &Vec) -> Result, CargoMakeError> {
14 | if function_args.len() > 2 {
15 | return Err(CargoMakeError::Arity("trim expects up to 2 arguments (environment variable name and optionally start/end trim flag)"));
16 | }
17 |
18 | let env_key = function_args[0].clone();
19 |
20 | let value = envmnt::get_or(&env_key, "");
21 |
22 | let trimmed_value = if function_args.len() == 1 {
23 | value.trim().to_string()
24 | } else {
25 | let trim_type = function_args[1].clone();
26 |
27 | match trim_type.as_ref() {
28 | "start" => value.trim_start().to_string(),
29 | "end" => value.trim_end().to_string(),
30 | _ => {
31 | error!("Invalid trim type provided, only start or end are supported.");
32 | return Err(CargoMakeError::MethodCallRestriction(
33 | "Invalid trim type provided, only start or end are supported.",
34 | ));
35 | }
36 | }
37 | };
38 |
39 | if trimmed_value.len() > 0 {
40 | Ok(vec![trimmed_value])
41 | } else {
42 | Ok(vec![])
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/scriptengine/generic_script.rs:
--------------------------------------------------------------------------------
1 | //! # generic_script
2 | //!
3 | //! Runs generic scripts for other languages based on provided config.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "generic_script_test.rs"]
8 | mod generic_script_test;
9 |
10 | use crate::command;
11 | use crate::error::CargoMakeError;
12 | use crate::io::delete_file;
13 | use crate::scriptengine::script_utils::create_script_file;
14 |
15 | fn run_file(
16 | file: &str,
17 | runner: &String,
18 | arguments: Option>,
19 | cli_arguments: &mut Vec,
20 | ) -> Result {
21 | let mut args = match arguments {
22 | Some(values) => values,
23 | None => vec![],
24 | };
25 |
26 | args.push(file.to_string());
27 |
28 | args.append(cli_arguments);
29 |
30 | let exit_code = command::run_command(runner, &Some(args), false)?;
31 | debug!("Executed script, exit code: {}", exit_code);
32 |
33 | Ok(exit_code == 0)
34 | }
35 |
36 | pub(crate) fn execute(
37 | script_text: &Vec,
38 | runner: String,
39 | extension: String,
40 | arguments: Option>,
41 | cli_arguments: &Vec,
42 | validate: bool,
43 | ) -> Result {
44 | let file = create_script_file(script_text, &extension)?;
45 |
46 | let valid = run_file(&file, &runner, arguments, &mut cli_arguments.clone())?;
47 |
48 | delete_file(&file);
49 |
50 | if validate && !valid {
51 | error!("Unable to execute script.");
52 | }
53 |
54 | Ok(valid)
55 | }
56 |
--------------------------------------------------------------------------------
/src/lib/functions/split_func.rs:
--------------------------------------------------------------------------------
1 | //! # split_func
2 | //!
3 | //! Split function which takes an environment variable name and a split by string.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "split_func_test.rs"]
8 | mod split_func_test;
9 |
10 | pub(crate) fn invoke(function_args: &Vec) -> Vec {
11 | let args_count = function_args.len();
12 | if args_count < 2 || args_count > 3 {
13 | error!("split expects two or three arguments (environment variable name, split by character, optional mode: default, remove-empty)");
14 | }
15 |
16 | let env_key = function_args[0].clone();
17 | let split_by = function_args[1].clone();
18 | let mode_name = if args_count == 3 {
19 | &function_args[2]
20 | } else {
21 | "default"
22 | };
23 | let remove_empty = mode_name == "remove-empty";
24 |
25 | if split_by.len() != 1 {
26 | error!("split expects a single character separator");
27 | }
28 |
29 | let split_by_char = split_by.chars().next().unwrap();
30 |
31 | let value = envmnt::get_or(&env_key, "");
32 |
33 | if value.len() > 0 {
34 | let splitted = value.split(split_by_char);
35 |
36 | splitted
37 | .map(|str_value| str_value.to_string())
38 | .filter(|string_value| {
39 | if remove_empty && string_value.is_empty() {
40 | false
41 | } else {
42 | true
43 | }
44 | })
45 | .collect()
46 | } else {
47 | vec![]
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/lib/descriptor/descriptor_deserializer_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::descriptor::makefiles;
3 |
4 | #[test]
5 | fn load_config_base() {
6 | load_config(makefiles::BASE, true).unwrap();
7 | }
8 |
9 | #[test]
10 | fn load_config_stable() {
11 | load_config(makefiles::STABLE, true).unwrap();
12 | }
13 |
14 | #[test]
15 | fn load_config_beta() {
16 | load_config(makefiles::BETA, true).unwrap();
17 | }
18 |
19 | #[test]
20 | #[should_panic]
21 | fn load_config_invalid_validate() {
22 | load_config(
23 | r#"
24 | env_files = []
25 | env_scripts = []
26 |
27 | [config]
28 | init_task = "init"
29 | end_task = "end"
30 |
31 | [env]
32 |
33 | [tasks.empty]
34 | description = "Empty Task"
35 | category2 = "Tools"
36 | "#,
37 | true,
38 | )
39 | .unwrap();
40 | }
41 |
42 | #[test]
43 | fn load_config_invalid_no_validate() {
44 | let config = load_config(
45 | r#"
46 | env_files = []
47 | env_scripts = []
48 |
49 | [config]
50 | init_task = "init"
51 | end_task = "end"
52 |
53 | [env]
54 |
55 | [tasks.empty]
56 | description = "Empty Task"
57 | category2 = "Tools"
58 | "#,
59 | false,
60 | )
61 | .unwrap();
62 |
63 | assert!(config.tasks.contains_key("empty"));
64 | }
65 |
66 | #[test]
67 | fn load_external_config_warning() {
68 | let config = load_external_config(
69 | r#"
70 | [tasks.empty]
71 | description = "Empty Task"
72 | category2 = "Tools"
73 | "#,
74 | "somefile",
75 | )
76 | .unwrap();
77 |
78 | assert!(config.tasks.unwrap().contains_key("empty"));
79 | }
80 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 | on:
3 | push:
4 | tags:
5 | - '*'
6 | env:
7 | CLICOLOR_FORCE: 1
8 | jobs:
9 | build:
10 | name: Publish for ${{ matrix.binary_target }}
11 | runs-on: ${{ matrix.os }}
12 | strategy:
13 | fail-fast: false
14 | matrix:
15 | include:
16 | - os: ubuntu-latest
17 | binary_target: x86_64-unknown-linux-musl
18 | - os: ubuntu-latest
19 | binary_target: x86_64-unknown-linux-gnu
20 | - os: windows-latest
21 | binary_target: x86_64-pc-windows-msvc
22 | - os: macos-latest
23 | binary_target: x86_64-apple-darwin
24 | - os: macos-latest
25 | binary_target: aarch64-apple-darwin
26 | steps:
27 | - name: Install musl tools
28 | if: matrix.os == 'ubuntu-latest'
29 | run: sudo apt-get install musl-tools
30 | - name: Checkout
31 | uses: actions/checkout@v2
32 | - name: Update rust
33 | run: |
34 | rustup override set stable
35 | rustup update stable
36 | rustup target add ${{ matrix.binary_target }}
37 | - name: Build Binary
38 | uses: actions-rs/cargo@v1
39 | with:
40 | command: run
41 | args: --bin cargo-make --target-dir target_ci -- make --env CARGO_MAKE_RELEASE_FLOW_TARGET=${{ matrix.binary_target }} zip-release-ci-flow
42 | - name: Upload Binaries
43 | uses: svenstaro/upload-release-action@v1-release
44 | with:
45 | repo_token: ${{ secrets.GITHUB_TOKEN }}
46 | file: '*.zip'
47 | tag: ${{ github.ref }}
48 | overwrite: true
49 | file_glob: true
50 |
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | //! # cargo-make
2 | //!
3 | //! Rust task runner and build tool.
4 | //! The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.
5 | //! A task is a command or a script to execute.
6 | //! Tasks can have dependencies which are also tasks that will be executed before the task itself.
7 | //! With a simple toml based configuration file, you can define a multi platform build script that can run build, test,
8 | //! documentation generation, bench tests execution, security validations and more by running a single command.
9 | //!
10 | //! ## Installation
11 | //! In order to install, just run the following command
12 | //!
13 | //! ```sh
14 | //! cargo install cargo-make
15 | //! ```
16 | //!
17 | //! This will install cargo-make in your ~/.cargo/bin.
18 | //! Make sure to add ~/.cargo/bin directory to your PATH variable.
19 | //!
20 | //! # Contributing
21 | //! See [contributing guide](https://github.com/sagiegurari/cargo-make/blob/master/.github/CONTRIBUTING.md)
22 | //!
23 | //! # License
24 | //! Developed by Sagie Gur-Ari and licensed under the
25 | //! [Apache 2](https://github.com/sagiegurari/cargo-make/blob/master/LICENSE) open source license.
26 | //!
27 |
28 | use cli::error::SuccessOrCargoMakeError;
29 |
30 | #[cfg(test)]
31 | #[path = "main_test.rs"]
32 | mod main_test;
33 |
34 | fn get_name() -> String {
35 | "make".to_string()
36 | }
37 |
38 | fn main() -> SuccessOrCargoMakeError {
39 | let name = get_name();
40 | match cli::run_cli(name, true) {
41 | Ok(_) => Ok(std::process::ExitCode::SUCCESS).into(),
42 | Err(e) => SuccessOrCargoMakeError::Err(e),
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_run_task.rs:
--------------------------------------------------------------------------------
1 | //! # cm_run_task
2 | //!
3 | //! Enables to run cargo-make tasks from within duckscript.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "cm_plugin_run_task_test.rs"]
8 | mod cm_plugin_run_task_test;
9 |
10 | use crate::runner;
11 | use crate::types::{FlowInfo, FlowState, RunTaskOptions, Step};
12 | use duckscript::types::command::{Command, CommandInvocationContext, CommandResult};
13 | use std::cell::RefCell;
14 | use std::rc::Rc;
15 |
16 | #[derive(Clone)]
17 | pub(crate) struct CommandImpl {
18 | flow_info: FlowInfo,
19 | flow_state: Rc>,
20 | step: Step,
21 | }
22 |
23 | impl Command for CommandImpl {
24 | fn name(&self) -> String {
25 | "cm_plugin_run_task".to_string()
26 | }
27 |
28 | fn clone_and_box(&self) -> Box {
29 | Box::new((*self).clone())
30 | }
31 |
32 | fn run(&self, _context: CommandInvocationContext) -> CommandResult {
33 | let options = RunTaskOptions {
34 | plugins_enabled: false,
35 | };
36 |
37 | if let Err(e) = runner::run_task_with_options(
38 | &self.flow_info,
39 | self.flow_state.clone(),
40 | &self.step,
41 | &options,
42 | ) {
43 | return CommandResult::Error(e.to_string());
44 | }
45 |
46 | CommandResult::Continue(Some("true".to_string()))
47 | }
48 | }
49 |
50 | pub(crate) fn create(
51 | flow_info: &FlowInfo,
52 | flow_state: Rc>,
53 | step: &Step,
54 | ) -> Box {
55 | Box::new(CommandImpl {
56 | flow_info: flow_info.clone(),
57 | flow_state,
58 | step: step.clone(),
59 | })
60 | }
61 |
--------------------------------------------------------------------------------
/examples/plugin.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 | skip_git_env_info = true
5 | skip_rust_env_info = true
6 | skip_crate_env_info = true
7 |
8 | [plugins.impl.simple-plugin]
9 | script = '''
10 | echo task: ${task.name}
11 | echo ${task.as_json}
12 |
13 | taskvars = json_parse ${task.as_json}
14 | echo MY_ENV -> ${taskvars.env.MY_ENV}
15 |
16 | args_string = array_join ${task.args} " "
17 | exec --fail-on-error ${task.command} %{args_string}
18 | '''
19 |
20 | [plugins.aliases]
21 | simple = "simple-plugin"
22 |
23 | [plugins.impl.force]
24 | script = '''
25 | plugin_force_set = get_env PLUGIN_FORCE_SET
26 | plugin_force_set = eq "${plugin_force_set}" 1
27 |
28 | if eq ${task.name} last_for_plugin
29 | echo clearing the forced plugin
30 | cm_plugin_force_plugin_clear
31 | elif ${plugin_force_set}
32 | echo already set forced plugin
33 | else
34 | echo setting forced plugin
35 | cm_plugin_force_plugin_set
36 | set_env PLUGIN_FORCE_SET 1
37 | end
38 |
39 | echo running plugin instead of task: ${task.name}
40 | '''
41 |
42 | [tasks.default]
43 | alias = "simple"
44 |
45 | [tasks.simple]
46 | plugin = "simple"
47 | category = "plugin"
48 | description = "simple task"
49 | env = { "MY_ENV" = "Some Value" }
50 | condition = { env_not_set = ["BAD"] }
51 | command = "echo"
52 | args = ["simple", "task", "${MY_ENV}", "done"]
53 |
54 | [tasks.force_flow]
55 | dependencies = ["force_first", "force_second", "last_for_plugin", "post_force"]
56 |
57 | [tasks.force_first]
58 | plugin = "force"
59 | command = "exit"
60 | args = ["1"]
61 |
62 | [tasks.force_second]
63 | command = "exit"
64 | args = ["1"]
65 |
66 | [tasks.last_for_plugin]
67 | command = "exit"
68 | args = ["1"]
69 |
70 | [tasks.post_force]
71 | command = "echo"
72 | args = ["post force"]
73 |
--------------------------------------------------------------------------------
/src/lib/profile.rs:
--------------------------------------------------------------------------------
1 | //! # profile
2 | //!
3 | //! Profile related utility functions
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "profile_test.rs"]
8 | mod profile_test;
9 |
10 | static PROFILE_ENV_KEY: &str = "CARGO_MAKE_PROFILE";
11 | static DEFAULT_PROFILE_ENV_KEY: &str = "CARGO_MAKE_DEFAULT_PROFILE";
12 | static ADDITIONAL_PROFILES_ENV_KEY: &str = "CARGO_MAKE_ADDITIONAL_PROFILES";
13 | static DEFAULT_PROFILE: &str = "development";
14 |
15 | fn normalize_profile(profile: &str) -> String {
16 | let profile_normalized = profile.to_lowercase();
17 | profile_normalized.trim().to_string()
18 | }
19 |
20 | fn normalize_additional_profiles(profiles: &Vec) -> Vec {
21 | let mut nomralized_profiles = vec![];
22 |
23 | for profile in profiles {
24 | let profile_normalized = normalize_profile(&profile);
25 |
26 | if profile_normalized.len() > 0 {
27 | nomralized_profiles.push(profile_normalized);
28 | }
29 | }
30 |
31 | nomralized_profiles
32 | }
33 |
34 | pub(crate) fn get() -> String {
35 | envmnt::get_or(PROFILE_ENV_KEY, &default_profile())
36 | }
37 |
38 | pub(crate) fn default_profile() -> String {
39 | envmnt::get_or(DEFAULT_PROFILE_ENV_KEY, DEFAULT_PROFILE)
40 | }
41 |
42 | pub(crate) fn set(profile: &str) -> String {
43 | let mut profile_normalized = normalize_profile(&profile);
44 |
45 | if profile_normalized.len() == 0 {
46 | profile_normalized = DEFAULT_PROFILE.to_string();
47 | }
48 |
49 | envmnt::set(PROFILE_ENV_KEY, &profile_normalized);
50 |
51 | get()
52 | }
53 |
54 | pub(crate) fn set_additional(profiles: &Vec) {
55 | let nomralized_profiles = normalize_additional_profiles(&profiles);
56 |
57 | envmnt::set_list(ADDITIONAL_PROFILES_ENV_KEY, &nomralized_profiles);
58 | }
59 |
--------------------------------------------------------------------------------
/docs/api/static.files/normalize-9960930a.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
2 | html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type="button"],[type="reset"],[type="submit"],button{-webkit-appearance:button}[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}
--------------------------------------------------------------------------------
/src/lib/functions/decode_func.rs:
--------------------------------------------------------------------------------
1 | //! # trim_func
2 | //!
3 | //! Takes an environment variable name and returns its mapped value.
4 | //! In case no mapped value if found, the default value will be returned if provided as last argument or if no default value is provided, the original value is returned.
5 | //! The value will be removed if empty.
6 | //!
7 |
8 | #[cfg(test)]
9 | #[path = "decode_func_test.rs"]
10 | mod decode_func_test;
11 |
12 | use crate::environment;
13 |
14 | pub(crate) fn invoke(function_args: &Vec) -> Vec {
15 | if function_args.len() == 0 {
16 | error!("decode expects at least one argument.");
17 | }
18 |
19 | let env_key = function_args[0].clone();
20 | let env_value = envmnt::get_or(&env_key, "");
21 |
22 | let mut mapped_value = None;
23 | let mut found = false;
24 | let mut skip = true;
25 | for item in function_args.iter() {
26 | if skip {
27 | skip = false;
28 | } else if found {
29 | mapped_value = Some(item.to_string());
30 | break;
31 | } else if item.to_string() == env_value {
32 | found = true;
33 | } else {
34 | skip = true;
35 | }
36 | }
37 |
38 | // if no mapped value found and default value provided
39 | let mut output_value = match mapped_value {
40 | Some(value) => value.clone(),
41 | None => {
42 | if function_args.len() % 2 == 0 && function_args.len() > 1 {
43 | function_args[function_args.len() - 1].to_string()
44 | } else {
45 | env_value.clone()
46 | }
47 | }
48 | };
49 |
50 | output_value = environment::expand_value(&output_value);
51 |
52 | if output_value.len() > 0 {
53 | vec![output_value]
54 | } else {
55 | vec![]
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/examples/functions.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 |
5 | [env]
6 | MULTIPLE_VALUES = "1|2|3|4"
7 | MULTIPLE_VALUES_WITH_EMPTY_CELLS = "1|2|||3|4"
8 | TRIM_VALUE = " 123 "
9 | CARGO_MAKE_CLIPPY_ARGS = ""
10 |
11 | [env.ci]
12 | CARGO_MAKE_CLIPPY_ARGS = "--all-features -- -D warnings"
13 |
14 | [tasks.split]
15 | command = "echo"
16 | args = ["@@split(MULTIPLE_VALUES,|)"]
17 |
18 | [tasks.split-remove-empty]
19 | command = "echo"
20 | args = ["@@split(MULTIPLE_VALUES_WITH_EMPTY_CELLS,|,remove-empty)"]
21 |
22 | [tasks.split-with-empty]
23 | command = "echo"
24 | args = ["@@split(MULTIPLE_VALUES_WITH_EMPTY_CELLS,|,default)"]
25 |
26 | [tasks.no-split]
27 | command = "echo"
28 | args = ["${MULTIPLE_VALUES}"]
29 |
30 | [tasks.getat]
31 | command = "echo"
32 | args = ["@@getat(MULTIPLE_VALUES,|,3)"]
33 |
34 | [tasks.remove-empty]
35 | command = "echo"
36 | args = ["1", "@@remove-empty(DOES_NOT_EXIST)", "2"]
37 |
38 | [tasks.trim]
39 | command = "echo"
40 | args = ["@@trim(TRIM_VALUE)"]
41 |
42 | [tasks.trim-start]
43 | command = "echo"
44 | args = ["@@trim(TRIM_VALUE,start)"]
45 |
46 | [tasks.trim-end]
47 | command = "echo"
48 | args = ["@@trim(TRIM_VALUE,end)"]
49 |
50 | [tasks.clippy]
51 | command = "echo"
52 | args = ["clippy", "@@split(CARGO_MAKE_CLIPPY_ARGS, )"]
53 |
54 | [tasks.decode]
55 | command = "echo"
56 | args = [
57 | "Env:",
58 | "${DECODE_ENV_VAR}",
59 | "Decoded:",
60 | "@@decode(DECODE_ENV_VAR,development,dev,ci,test)",
61 | ]
62 |
63 | [tasks.decode-with-default]
64 | command = "echo"
65 | args = [
66 | "Env:",
67 | "${DECODE_ENV_VAR}",
68 | "Decoded:",
69 | "@@decode(DECODE_ENV_VAR,development,dev,ci,test,unknown)",
70 | ]
71 |
72 | [tasks.decode-with-eval]
73 | command = "echo"
74 | args = [
75 | "Env:",
76 | "${DECODE_ENV_VAR}",
77 | "Decoded:",
78 | "@@decode(DECODE_ENV_VAR,test,The current profile is: ${CARGO_MAKE_PROFILE})",
79 | ]
80 |
--------------------------------------------------------------------------------
/src/lib/plugin/descriptor.rs:
--------------------------------------------------------------------------------
1 | //! # descriptor
2 | //!
3 | //! Handles the plugin descriptor section logic.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "descriptor_test.rs"]
8 | mod descriptor_test;
9 |
10 | use crate::plugin::types::{Plugin, Plugins};
11 | use indexmap::IndexMap;
12 |
13 | fn merge_aliases(
14 | base: &IndexMap,
15 | extended: &IndexMap,
16 | ) -> IndexMap {
17 | let mut target = base.clone();
18 | target.extend(
19 | extended
20 | .into_iter()
21 | .map(|(key, value)| (key.clone(), value.clone())),
22 | );
23 |
24 | target
25 | }
26 |
27 | fn merge_plugins_map(
28 | base: &IndexMap,
29 | extended: &IndexMap,
30 | ) -> IndexMap {
31 | let mut target = base.clone();
32 | target.extend(
33 | extended
34 | .into_iter()
35 | .map(|(key, value)| (key.clone(), value.clone())),
36 | );
37 |
38 | target
39 | }
40 |
41 | fn merge_plugins_config_impl(base: Plugins, extended: Plugins) -> Plugins {
42 | let aliases = match base.aliases {
43 | Some(base_aliases) => match extended.aliases {
44 | Some(ref extended_aliases) => Some(merge_aliases(&base_aliases, extended_aliases)),
45 | None => Some(base_aliases),
46 | },
47 | None => extended.aliases,
48 | };
49 |
50 | let plugins = merge_plugins_map(&base.plugins, &extended.plugins);
51 |
52 | Plugins { aliases, plugins }
53 | }
54 |
55 | pub(crate) fn merge_plugins_config(
56 | base: Option,
57 | extended: Option,
58 | ) -> Option {
59 | match base {
60 | Some(base_plugins) => match extended {
61 | Some(extended_plugins) => {
62 | let plugins = merge_plugins_config_impl(base_plugins, extended_plugins);
63 | Some(plugins)
64 | }
65 | None => Some(base_plugins),
66 | },
67 | None => extended,
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/docs/api/static.files/COPYRIGHT-eb44e4cf.txt:
--------------------------------------------------------------------------------
1 | # REUSE-IgnoreStart
2 |
3 | These documentation pages include resources by third parties. This copyright
4 | file applies only to those resources. The following third party resources are
5 | included, and carry their own copyright notices and license terms:
6 |
7 | * Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2):
8 |
9 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/
10 | with Reserved Font Name Fira Sans.
11 |
12 | Copyright (c) 2014, Telefonica S.A.
13 |
14 | Licensed under the SIL Open Font License, Version 1.1.
15 | See FiraSans-LICENSE.txt.
16 |
17 | * rustdoc.css, main.js, and playpen.js:
18 |
19 | Copyright 2015 The Rust Developers.
20 | Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or
21 | the MIT license (LICENSE-MIT.txt) at your option.
22 |
23 | * normalize.css:
24 |
25 | Copyright (c) Nicolas Gallagher and Jonathan Neal.
26 | Licensed under the MIT license (see LICENSE-MIT.txt).
27 |
28 | * Source Code Pro (SourceCodePro-Regular.ttf.woff2,
29 | SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2):
30 |
31 | Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
32 | with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark
33 | of Adobe Systems Incorporated in the United States and/or other countries.
34 |
35 | Licensed under the SIL Open Font License, Version 1.1.
36 | See SourceCodePro-LICENSE.txt.
37 |
38 | * Source Serif 4 (SourceSerif4-Regular.ttf.woff2, SourceSerif4-Bold.ttf.woff2,
39 | SourceSerif4-It.ttf.woff2):
40 |
41 | Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name
42 | 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United
43 | States and/or other countries.
44 |
45 | Licensed under the SIL Open Font License, Version 1.1.
46 | See SourceSerif4-LICENSE.md.
47 |
48 | This copyright file is intended to be distributed with rustdoc output.
49 |
50 | # REUSE-IgnoreEnd
51 |
--------------------------------------------------------------------------------
/src/lib/scriptengine/generic_script_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::test;
3 |
4 | #[test]
5 | fn execute_shell() {
6 | let valid = execute(
7 | &vec!["exit 0".to_string()],
8 | test::get_os_runner(),
9 | test::get_os_extension(),
10 | None,
11 | &vec![],
12 | true,
13 | )
14 | .unwrap();
15 | assert!(valid);
16 | }
17 |
18 | #[test]
19 | #[should_panic]
20 | fn execute_shell_error() {
21 | execute(
22 | &vec!["exit 1".to_string()],
23 | test::get_os_runner(),
24 | test::get_os_extension(),
25 | None,
26 | &vec![],
27 | true,
28 | )
29 | .unwrap();
30 | }
31 |
32 | #[test]
33 | fn execute_shell_error_no_validate() {
34 | let valid = execute(
35 | &vec!["exit 1".to_string()],
36 | test::get_os_runner(),
37 | test::get_os_extension(),
38 | None,
39 | &vec![],
40 | false,
41 | )
42 | .unwrap();
43 | assert!(!valid);
44 | }
45 |
46 | #[test]
47 | fn execute_shell_empty_arguments() {
48 | let valid = execute(
49 | &vec!["exit 0".to_string()],
50 | test::get_os_runner(),
51 | test::get_os_extension(),
52 | Some(vec![]),
53 | &vec![],
54 | true,
55 | )
56 | .unwrap();
57 | assert!(valid);
58 | }
59 |
60 | #[test]
61 | #[cfg(target_os = "linux")]
62 | fn execute_shell_cli_arguments() {
63 | let valid = execute(
64 | &vec!["exit $1".to_string()],
65 | test::get_os_runner(),
66 | test::get_os_extension(),
67 | Some(vec![]),
68 | &vec!["0".to_string()],
69 | true,
70 | )
71 | .unwrap();
72 | assert!(valid);
73 | }
74 |
75 | #[test]
76 | #[should_panic]
77 | #[cfg(target_os = "linux")]
78 | fn execute_shell_cli_arguments_error() {
79 | execute(
80 | &vec!["exit $1".to_string()],
81 | test::get_os_runner(),
82 | test::get_os_extension(),
83 | Some(vec![]),
84 | &vec!["1".to_string()],
85 | true,
86 | )
87 | .unwrap();
88 | }
89 |
--------------------------------------------------------------------------------
/src/lib/descriptor/descriptor_deserializer.rs:
--------------------------------------------------------------------------------
1 | //! # descriptor_deserializer
2 | //!
3 | //! Deserializes and validates the configs.
4 |
5 | #[cfg(test)]
6 | #[path = "descriptor_deserializer_test.rs"]
7 | mod descriptor_deserializer_test;
8 |
9 | use crate::error::CargoMakeError;
10 | use crate::types::{Config, ExternalConfig};
11 |
12 | pub(crate) fn load_config(
13 | descriptor_string: &str,
14 | validate: bool,
15 | ) -> Result {
16 | let config: Config = if validate {
17 | let deserializer = toml::de::Deserializer::new(descriptor_string);
18 |
19 | match serde_ignored::deserialize(deserializer, |path| {
20 | error!("Found unknown key: {}", path);
21 | }) {
22 | Ok(value) => value,
23 | Err(error) => {
24 | error!("Unable to parse internal descriptor: {}", error);
25 | return Err(CargoMakeError::DescriptorParseFailed(error.to_string()));
26 | }
27 | }
28 | } else {
29 | match toml::from_str(descriptor_string) {
30 | Ok(value) => value,
31 | Err(error) => {
32 | error!("Unable to parse internal descriptor: {}", error);
33 | return Err(CargoMakeError::DescriptorParseFailed(error.to_string()));
34 | }
35 | }
36 | };
37 |
38 | Ok(config)
39 | }
40 |
41 | pub(crate) fn load_external_config(
42 | descriptor_string: &str,
43 | file: &str,
44 | ) -> Result {
45 | let deserializer = toml::de::Deserializer::new(descriptor_string);
46 |
47 | match serde_ignored::deserialize(deserializer, |path| {
48 | warn!("Found unknown key: {} in file: {}", path, file);
49 | }) {
50 | Ok(value) => Ok(value),
51 | Err(error) => {
52 | error!("Unable to parse external file: {:#?}, {}", &file, error);
53 | return Err(CargoMakeError::ParseFileFailed(
54 | String::from(file),
55 | error.to_string(),
56 | ));
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/examples/duckscript.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.duckscript]
3 | script_runner = "@duckscript"
4 | script = "echo Hello World!"
5 |
6 | [tasks.duckscript-example]
7 | script_runner = "@duckscript"
8 | script = '''
9 | task_name = get_env CARGO_MAKE_CURRENT_TASK_NAME
10 | echo The currently running cargo make task is: ${task_name}
11 |
12 | # since all env vars are auto loaded as duckscript variables by cargo-make
13 | # you can access them directly
14 | echo The currently running cargo make task is: ${CARGO_MAKE_CURRENT_TASK_NAME}
15 |
16 | cd .. # this changes cargo-make current working directory (cargo-make will revert to original directory after script execution)
17 | pwd
18 | set_env CARGO_MAKE_CURRENT_TASK_NAME tricking_cargo_make
19 | '''
20 |
21 | [tasks.duckscript-shebang-example]
22 | script = '''
23 | #!@duckscript
24 | echo Running duckscript without runner attribute.
25 | '''
26 |
27 | [tasks.run-task-from-duckscript]
28 | script_runner = "@duckscript"
29 | script = '''
30 | echo first invocation of echo1 task:
31 | cm_run_task echo1
32 | echo second invocation of echo1 task:
33 | cm_run_task echo1
34 |
35 | echo running task: echo2:
36 | cm_run_task echo2
37 | '''
38 |
39 | [tasks.before-echo]
40 | command = "echo"
41 | args = ["before echo"]
42 |
43 | [tasks.echo1]
44 | dependencies = ["before-echo"]
45 | command = "echo"
46 | args = ["1"]
47 |
48 | [tasks.echo2]
49 | command = "echo"
50 | args = ["2"]
51 |
52 | [tasks.sleep_wrapper]
53 | run_task = { name = ["sleep", "sleep"] }
54 |
55 | [tasks.sleep]
56 | script = '''
57 | #!@duckscript
58 | sleep 1000
59 | '''
60 |
61 | [tasks.echo-after-sleep]
62 | dependencies = ["sleep"]
63 | run_task = "echo1"
64 |
65 | [tasks.run-async-task-from-duckscript]
66 | script_runner = "@duckscript"
67 | script = '''
68 | echo before invocation
69 | cm_run_task --async echo-after-sleep
70 | echo after invocation
71 | sleep 1500
72 | '''
73 |
74 | [tasks.cli_args]
75 | script = '''
76 | #!@duckscript
77 | all_values = array_join ${@} ", "
78 | echo all args: ${all_values}
79 |
80 | echo some fielded values:
81 | echo 1: ${1}
82 | echo 2: ${2}
83 | echo 3: ${3}
84 | '''
85 |
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/beta.toml:
--------------------------------------------------------------------------------
1 |
2 | env_files = []
3 | env_scripts = []
4 |
5 | [config]
6 |
7 | [env]
8 |
9 | [tasks.coverage-lcov]
10 | description = "WARNING, THIS TASK IS UNTESTED!!!! Installs (if missing) and runs coverage using llvm-cov (not supported on windows/mac)"
11 |
12 | [tasks.coverage-lcov.linux]
13 | install_script = '''
14 | command -v lcov >/dev/null 2>&1 || {
15 | if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
16 | sudo apt-get update || true
17 | sudo apt-get install -y clang llvm-3.9 lcov
18 |
19 | git clone https://github.com/linux-test-project/lcov.git
20 | cd lcov
21 | sudo make install
22 | cd ..
23 | rm -Rf ./lcov
24 | fi
25 | }
26 | '''
27 | script = '''
28 | #based on https://users.rust-lang.org/t/howto-generating-a-branch-coverage-report/8524
29 | if [ -n "$LLVM_VERSION" ]; then
30 | rm -f *.gcda *.gcno
31 |
32 | cargo rustc -- --test -Ccodegen-units=1 -Clink-dead-code -Cpasses=insert-gcov-profiling -Zno-landing-pads "-L/usr/lib/llvm-$LLVM_VERSION/lib/clang/$LLVM_VERSION/lib/linux/" "-lclang_rt.profile-${CARGO_MAKE_RUST_TARGET_ARCH}"
33 |
34 | ls *.gcno
35 |
36 | echo "Running unit tests"
37 | for file in target/debug/deps/${CARGO_MAKE_CRATE_FS_NAME}*
38 | do
39 | "$file" || true
40 | done
41 |
42 | echo "Running integration tests"
43 | for file in target/debug/deps/test_*
44 | do
45 | "$file" || true
46 | done
47 |
48 | ls *.gcda
49 |
50 | echo "#!/bin/sh -e\nllvm-cov gcov $*" >> ./target/llvm-gcov
51 | chmod 777 ./target/llvm-gcov
52 | PATH=$PATH:./target:"/usr/lib/llvm-$LLVM_VERSION/bin"
53 |
54 | LCOVOPTS="--gcov-tool llvm-gcov --rc lcov_branch_coverage=1"
55 | LCOVOPTS="${LCOVOPTS} --rc lcov_excl_line=assert"
56 | lcov ${LCOVOPTS} --capture --directory . --base-directory . -o coverage.lcov
57 | lcov ${LCOVOPTS} --extract coverage.info "$(pwd)/*" -o "${CARGO_MAKE_CRATE_FS_NAME}.lcov"
58 |
59 | genhtml --branch-coverage --demangle-cpp --legend "${CARGO_MAKE_CRATE_FS_NAME}.info" -o target/coverage/
60 | fi
61 | '''
62 |
--------------------------------------------------------------------------------
/examples/plugin_dockerize.toml:
--------------------------------------------------------------------------------
1 |
2 | [config]
3 | skip_core_tasks = true
4 | skip_git_env_info = true
5 | skip_rust_env_info = true
6 | skip_crate_env_info = true
7 |
8 | [plugins.impl.dockerize]
9 | script = '''
10 | plugin_force_set = get_env PLUGIN_FORCE_SET
11 | plugin_force_set = eq "${plugin_force_set}" 1
12 |
13 | if not ${plugin_force_set}
14 | cm_plugin_force_plugin_set
15 | set_env PLUGIN_FORCE_SET 1
16 |
17 | dockerfile = set ""
18 | fn add_docker
19 | dockerfile = set "${dockerfile}${1}\n"
20 | end
21 |
22 | taskjson = json_parse ${task.as_json}
23 | makefile = basename ${taskjson.env.CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE}
24 |
25 | add_docker "FROM debian:stable"
26 | add_docker "RUN mkdir /workdir/"
27 | add_docker "RUN mkdir /workdir/project/"
28 | add_docker "RUN apt-get update"
29 | add_docker "RUN apt-get install -y curl build-essential libssl-dev pkg-config"
30 | add_docker "ENV PATH=\"$PATH:$HOME/.cargo/bin\""
31 | add_docker "RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
32 | add_docker "RUN $HOME/.cargo/bin/cargo install cargo-make"
33 | add_docker "RUN $HOME/.cargo/bin/cargo make --version"
34 | add_docker "RUN echo \"cd ./workdir/project/ && ls -lsa && $HOME/.cargo/bin/cargo make --makefile ${makefile} --profile ${CARGO_MAKE_PROFILE} ${CARGO_MAKE_TASK}\" > ./run.sh"
35 | add_docker "RUN chmod 777 ./run.sh"
36 | add_docker "ADD . /workdir/project/"
37 | add_docker "CMD [\"sh\", \"./run.sh\"]"
38 |
39 | writefile ./Dockerfile ${dockerfile}
40 | exec --fail-on-error docker build --tag cmimg:build ./
41 |
42 | exec --fail-on-error docker run cmimg:build
43 | end
44 | '''
45 |
46 | [tasks.default]
47 | alias = "docker_flow"
48 |
49 | [tasks.docker_flow]
50 | dependencies = ["part1", "part2", "part3"]
51 |
52 | [tasks.base-task]
53 | command = "echo"
54 | args = ["task", "${CARGO_MAKE_CURRENT_TASK_NAME}"]
55 |
56 | [tasks.part1]
57 | plugin = "dockerize"
58 | extend = "base-task"
59 |
60 | [tasks.part2]
61 | extend = "base-task"
62 |
63 | [tasks.part3]
64 | extend = "base-task"
65 |
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/git.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.pre-git-add]
3 | category = "Git"
4 |
5 | [tasks.git-add]
6 | description = "Runs the git add command."
7 | category = "Git"
8 | command = "git"
9 | args = ["add", "."]
10 |
11 | [tasks.post-git-add]
12 | category = "Git"
13 |
14 | [tasks.pre-git-status]
15 | category = "Git"
16 |
17 | [tasks.git-status]
18 | description = "Runs git status command."
19 | category = "Git"
20 | command = "git"
21 | args = ["status"]
22 |
23 | [tasks.post-git-status]
24 | category = "Git"
25 |
26 | [tasks.pre-git-commit]
27 | category = "Git"
28 |
29 | [tasks.git-commit]
30 | description = "Runs git commit command."
31 | category = "Git"
32 | command = "git"
33 | args = ["commit"]
34 |
35 | [tasks.git-commit-message]
36 | description = "Runs git commit command with the message defined in the COMMIT_MSG environment variable."
37 | category = "Git"
38 | condition = { env_set = ["COMMIT_MSG"] }
39 | command = "git"
40 | args = ["commit", "-m", "${COMMIT_MSG}"]
41 |
42 | [tasks.post-git-commit]
43 | category = "Git"
44 |
45 | [tasks.pre-git-push]
46 | category = "Git"
47 |
48 | [tasks.git-push]
49 | description = "Runs git push command."
50 | category = "Git"
51 | command = "git"
52 | args = ["push", "@@split(CARGO_MAKE_GIT_PUSH_ARGS, )"]
53 |
54 | [tasks.post-git-push]
55 | category = "Git"
56 |
57 | [tasks.git-pull]
58 | description = "Runs git pull command."
59 | category = "Git"
60 | command = "git"
61 | args = ["pull"]
62 |
63 | [tasks.git-delete-merged-branches]
64 | description = "Deletes any merged git branches"
65 | category = "Git"
66 | ignore_errors = true
67 | condition = { platforms = ["linux", "mac"] }
68 | script = '''
69 | git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
70 | '''
71 |
72 | [tasks.git-diff-files]
73 | description = "Run diff on two provided files."
74 | category = "Tools"
75 | ignore_errors = true
76 | condition = { env_set = ["CARGO_MAKE_DIFF_FILE1", "CARGO_MAKE_DIFF_FILE2"] }
77 | command = "git"
78 | args = [
79 | "--no-pager",
80 | "diff",
81 | "--no-index",
82 | "${CARGO_MAKE_DIFF_FILE1}",
83 | "${CARGO_MAKE_DIFF_FILE2}",
84 | ]
85 |
--------------------------------------------------------------------------------
/src/lib/functions/trim_func_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | #[should_panic]
5 | fn trim_invoke_empty() {
6 | invoke(&vec![]).unwrap();
7 | }
8 |
9 | #[test]
10 | #[should_panic]
11 | fn trim_invoke_invalid_too_many_args() {
12 | invoke(&vec!["TEST".to_string(), "1".to_string(), "2".to_string()]).unwrap();
13 | }
14 |
15 | #[test]
16 | #[should_panic]
17 | fn trim_invoke_invalid_trim_type() {
18 | invoke(&vec!["TEST".to_string(), "bad".to_string()]).unwrap();
19 | }
20 |
21 | #[test]
22 | fn trim_invoke_exists_with_value() {
23 | envmnt::set("TEST_TRIM_VALID", "abc");
24 |
25 | let output = invoke(&vec!["TEST_TRIM_VALID".to_string()]).unwrap();
26 |
27 | assert_eq!(output, vec!["abc"]);
28 | }
29 |
30 | #[test]
31 | fn trim_invoke_exists_empty() {
32 | envmnt::set("TEST_TRIM_EMPTY", "");
33 |
34 | let output = invoke(&vec!["TEST_TRIM_EMPTY".to_string()]).unwrap();
35 |
36 | assert_eq!(output.len(), 0);
37 | }
38 |
39 | #[test]
40 | fn trim_invoke_not_exists() {
41 | let output = invoke(&vec!["TEST_TRIM_NOT_EXISTS".to_string()]).unwrap();
42 |
43 | assert_eq!(output.len(), 0);
44 | }
45 |
46 | #[test]
47 | fn trim_invoke_all_spaces() {
48 | envmnt::set("TEST_TRIM_ALL_SPACES", "");
49 |
50 | let output = invoke(&vec!["TEST_TRIM_ALL_SPACES".to_string()]).unwrap();
51 |
52 | assert_eq!(output.len(), 0);
53 | }
54 |
55 | #[test]
56 | fn trim_invoke_partial_spaces() {
57 | envmnt::set("TEST_TRIM_PARTIAL_SPACES", " 123 123 ");
58 |
59 | let output = invoke(&vec!["TEST_TRIM_PARTIAL_SPACES".to_string()]).unwrap();
60 |
61 | assert_eq!(output, vec!["123 123"]);
62 | }
63 |
64 | #[test]
65 | fn trim_invoke_trim_start() {
66 | envmnt::set("TEST_TRIM_START", " 123 ");
67 |
68 | let output = invoke(&vec!["TEST_TRIM_START".to_string(), "start".to_string()]).unwrap();
69 |
70 | assert_eq!(output, vec!["123 "]);
71 | }
72 |
73 | #[test]
74 | fn trim_invoke_trim_end() {
75 | envmnt::set("TEST_TRIM_END", " 123 ");
76 |
77 | let output = invoke(&vec!["TEST_TRIM_END".to_string(), "end".to_string()]).unwrap();
78 |
79 | assert_eq!(output, vec![" 123"]);
80 | }
81 |
--------------------------------------------------------------------------------
/src/lib/proxy_task.rs:
--------------------------------------------------------------------------------
1 | use std::env;
2 |
3 | use crate::{logger, profile, types::Task};
4 |
5 | #[cfg(test)]
6 | #[path = "proxy_task_test.rs"]
7 | mod proxy_task_test;
8 |
9 | pub(crate) fn create_proxy_task(
10 | task: &str,
11 | allow_private: bool,
12 | skip_init_end_tasks: bool,
13 | makefile: Option,
14 | cli_args: Option>,
15 | ) -> Task {
16 | //get log level name
17 | let log_level = logger::get_log_level();
18 |
19 | let mut log_level_arg = "--loglevel=".to_string();
20 | log_level_arg.push_str(&log_level);
21 |
22 | //get profile
23 | let profile_name = profile::get();
24 |
25 | let mut profile_arg = "--profile=".to_string();
26 | profile_arg.push_str(&profile_name);
27 |
28 | //setup common args
29 | let mut args = vec![
30 | "make".to_string(),
31 | "--disable-check-for-updates".to_string(),
32 | "--no-on-error".to_string(),
33 | log_level_arg.to_string(),
34 | profile_arg.to_string(),
35 | ];
36 |
37 | if allow_private {
38 | args.push("--allow-private".to_string());
39 | }
40 |
41 | if skip_init_end_tasks {
42 | args.push("--skip-init-end-tasks".to_string());
43 | }
44 |
45 | //get makefile location
46 | let makefile_path_option = match makefile {
47 | Some(makefile_path) => Some(makefile_path),
48 | None => match env::var("CARGO_MAKE_MAKEFILE_PATH") {
49 | Ok(makefile_path) => Some(makefile_path),
50 | _ => None,
51 | },
52 | };
53 | if let Some(makefile_path) = makefile_path_option {
54 | if makefile_path.len() > 0 {
55 | args.push("--makefile".to_string());
56 | args.push(makefile_path);
57 | }
58 | };
59 |
60 | args.push(task.to_string());
61 |
62 | if let Some(cli_args_vec) = cli_args {
63 | if !cli_args_vec.is_empty() {
64 | args.append(&mut cli_args_vec.to_owned());
65 | }
66 | }
67 |
68 | let mut proxy_task = Task::new();
69 | proxy_task.command = Some("cargo".to_string());
70 | proxy_task.args = Some(args);
71 |
72 | proxy_task.get_normalized_task()
73 | }
74 |
--------------------------------------------------------------------------------
/src/lib/descriptor/cargo_alias.rs:
--------------------------------------------------------------------------------
1 | //! # cargo_alias
2 | //!
3 | //! Dynamically creates tasks based on alias information in the cargo config.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "cargo_alias_test.rs"]
8 | mod cargo_alias_test;
9 |
10 | use crate::error::CargoMakeError;
11 | use crate::io;
12 | use crate::types::{InstallCrate, Task};
13 | use std::collections::HashMap;
14 | use std::path::Path;
15 |
16 | #[derive(Serialize, Deserialize, Debug)]
17 | #[serde(untagged)]
18 | enum AliasValue {
19 | String(String),
20 | List(Vec),
21 | }
22 |
23 | #[derive(Serialize, Deserialize, Debug)]
24 | struct CargoConfig {
25 | alias: Option>,
26 | }
27 |
28 | fn load_from_file(file: &str) -> Result, CargoMakeError> {
29 | let file_path = Path::new(file);
30 |
31 | let mut tasks = vec![];
32 | if file_path.exists() {
33 | if file_path.is_file() {
34 | let text = io::read_text_file(&file_path.to_path_buf())?;
35 |
36 | if !text.is_empty() {
37 | let cargo_config: CargoConfig = match toml::from_str(&text) {
38 | Ok(value) => value,
39 | Err(error) => {
40 | warn!("Unable to parse cargo config file, {}", error);
41 | CargoConfig { alias: None }
42 | }
43 | };
44 |
45 | if let Some(aliases) = cargo_config.alias {
46 | for (key, _value) in aliases {
47 | let mut task = Task::new();
48 | task.command = Some("cargo".to_string());
49 | task.args = Some(vec![key.to_string()]);
50 | task.install_crate = Some(InstallCrate::Enabled(false));
51 |
52 | tasks.push((key, task));
53 | }
54 | }
55 | }
56 | } else {
57 | error!("Invalid config file path provided: {}", &file);
58 | }
59 | }
60 |
61 | Ok(tasks)
62 | }
63 |
64 | pub(crate) fn load() -> Result, CargoMakeError> {
65 | load_from_file("./.cargo/config.toml")
66 | }
67 |
--------------------------------------------------------------------------------
/src/lib/config_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use std::env;
3 |
4 | #[test]
5 | fn load_from_path_exists() {
6 | let path: PathBuf = ["examples", "cargo-make"].iter().collect();
7 | let global_config = load_from_path(path).unwrap();
8 |
9 | assert!(global_config.file_name.is_some());
10 | assert_eq!(global_config.log_level.unwrap(), "error".to_string());
11 | assert_eq!(
12 | global_config.default_task_name.unwrap(),
13 | "build".to_string()
14 | );
15 | assert_eq!(
16 | global_config.update_check_minimum_interval.unwrap(),
17 | "daily".to_string()
18 | );
19 | assert!(global_config.search_project_root.unwrap());
20 | }
21 |
22 | #[test]
23 | fn load_from_path_not_exists() {
24 | let path: PathBuf = ["examples2", ".cargo-make"].iter().collect();
25 | let global_config = load_from_path(path).unwrap();
26 |
27 | assert!(global_config.file_name.is_none());
28 | assert!(global_config.log_level.is_none());
29 | assert!(global_config.default_task_name.is_none());
30 | assert!(global_config.update_check_minimum_interval.is_none());
31 | assert!(!global_config.search_project_root.unwrap());
32 | }
33 |
34 | #[test]
35 | #[ignore]
36 | fn load_with_cargo_home() {
37 | let directory: PathBuf = [
38 | env::current_dir().unwrap(),
39 | "examples".into(),
40 | "cargo-make".into(),
41 | ]
42 | .iter()
43 | .collect();
44 | envmnt::set("CARGO_MAKE_HOME", directory.to_str().unwrap());
45 | let global_config = load().unwrap();
46 |
47 | assert!(global_config.file_name.is_some());
48 | assert_eq!(global_config.log_level.unwrap(), "error".to_string());
49 | assert_eq!(
50 | global_config.default_task_name.unwrap(),
51 | "build".to_string()
52 | );
53 | assert_eq!(
54 | global_config.update_check_minimum_interval.unwrap(),
55 | "daily".to_string()
56 | );
57 | assert!(global_config.search_project_root.unwrap());
58 | }
59 |
60 | #[test]
61 | #[ignore]
62 | fn load_without_cargo_home() {
63 | envmnt::remove("CARGO_MAKE_HOME");
64 | let global_config = load().unwrap();
65 |
66 | assert!(global_config.search_project_root.is_some());
67 | }
68 |
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_run_custom_task.rs:
--------------------------------------------------------------------------------
1 | //! # cm_run_task
2 | //!
3 | //! Enables to run cargo-make tasks from within duckscript.
4 | //!
5 |
6 | #[cfg(test)]
7 | #[path = "cm_plugin_run_custom_task_test.rs"]
8 | mod cm_plugin_run_custom_task_test;
9 |
10 | use crate::runner;
11 | use crate::types::{FlowInfo, FlowState, RunTaskOptions, Step, Task};
12 | use duckscript::types::command::{Command, CommandInvocationContext, CommandResult};
13 | use std::cell::RefCell;
14 | use std::rc::Rc;
15 |
16 | #[derive(Clone)]
17 | pub(crate) struct CommandImpl {
18 | flow_info: FlowInfo,
19 | flow_state: Rc>,
20 | step: Step,
21 | }
22 |
23 | impl Command for CommandImpl {
24 | fn name(&self) -> String {
25 | "cm_plugin_run_custom_task".to_string()
26 | }
27 |
28 | fn clone_and_box(&self) -> Box {
29 | Box::new((*self).clone())
30 | }
31 |
32 | fn run(&self, context: CommandInvocationContext) -> CommandResult {
33 | if context.arguments.is_empty() {
34 | CommandResult::Error("No task data provided.".to_string())
35 | } else {
36 | let task: Task = match serde_json::from_str(&context.arguments[0]) {
37 | Ok(value) => value,
38 | Err(error) => return CommandResult::Error(error.to_string()),
39 | };
40 |
41 | let custom_step = Step {
42 | name: self.step.name.clone(),
43 | config: task,
44 | };
45 |
46 | let options = RunTaskOptions {
47 | plugins_enabled: false,
48 | };
49 |
50 | if let Err(e) = runner::run_task_with_options(
51 | &self.flow_info,
52 | self.flow_state.clone(),
53 | &custom_step,
54 | &options,
55 | ) {
56 | return CommandResult::Error(e.to_string());
57 | }
58 |
59 | CommandResult::Continue(Some("true".to_string()))
60 | }
61 | }
62 | }
63 |
64 | pub(crate) fn create(
65 | flow_info: &FlowInfo,
66 | flow_state: Rc>,
67 | step: &Step,
68 | ) -> Box {
69 | Box::new(CommandImpl {
70 | flow_info: flow_info.clone(),
71 | flow_state,
72 | step: step.clone(),
73 | })
74 | }
75 |
--------------------------------------------------------------------------------
/docs/api/makers/all.html:
--------------------------------------------------------------------------------
1 | List of all items in this crate List of all items Functions
--------------------------------------------------------------------------------
/docs/api/cargo_make/all.html:
--------------------------------------------------------------------------------
1 | List of all items in this crate List of all items Functions
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cargo-make"
3 | version = "0.37.24"
4 | authors = ["Sagie Gur-Ari "]
5 | description = "Rust task runner and build tool."
6 | license = "Apache-2.0"
7 | edition = "2021"
8 | documentation = "https://sagiegurari.github.io/cargo-make"
9 | homepage = "https://sagiegurari.github.io/cargo-make"
10 | repository = "https://github.com/sagiegurari/cargo-make.git"
11 | readme = "README.md"
12 | keywords = ["task", "build", "cargo", "plugin", "subcommand"]
13 | categories = [
14 | "command-line-utilities",
15 | "development-tools",
16 | "development-tools::cargo-plugins",
17 | "development-tools::build-utils",
18 | "development-tools::testing",
19 | ]
20 | include = [
21 | "/benches/*",
22 | "/docs/*",
23 | "/examples/*",
24 | "/src/*",
25 | "/tests/*",
26 | "/Cargo.toml",
27 | "/LICENSE",
28 | "/README.md",
29 | "/CHANGELOG.md",
30 | "/Makefile.toml",
31 | "/extra/shell/*",
32 | ]
33 |
34 | [lib]
35 | name = "cli"
36 | path = "src/lib/mod.rs"
37 |
38 | [[bin]]
39 | name = "cargo-make"
40 | path = "src/main.rs"
41 |
42 | [[bin]]
43 | name = "makers"
44 | path = "src/makers.rs"
45 |
46 | [dependencies]
47 | cargo_metadata = "^0.19"
48 | ci_info = "^0.14.14"
49 | cliparser = "^0.1.2"
50 | colored = "^3"
51 | ctrlc = "^3"
52 | dirs-next = "^2"
53 | duckscript = "^0.10"
54 | duckscriptsdk = { version = "^0.11.1", default-features = false }
55 | envmnt = "^0.10.4"
56 | fern = "^0.7"
57 | fsio = { version = "^0.4", features = ["temp-path"] }
58 | git_info = "^0.1.3"
59 | glob = "^0.3.2"
60 | hex = "0.4.3"
61 | home = "^0.5"
62 | ignore = "^0.4"
63 | indexmap = { version = "^2", features = ["serde"] }
64 | itertools = "^0.14"
65 | lenient_semver = "^0.4.2"
66 | log = "^0.4"
67 | once_cell = "^1.21"
68 | petgraph = "^0.8.1"
69 | regex = "^1.11"
70 | run_script = "^0.11"
71 | rust_info = "^0.3.3"
72 | semver = "^1"
73 | serde = "^1"
74 | serde_derive = "^1"
75 | serde_ignored = "^0.1"
76 | serde_json = "^1"
77 | sha2 = "0.10.9"
78 | shell2batch = "^0.4.5"
79 | strip-ansi-escapes = "^0.2"
80 | strum_macros = "0.26.4"
81 | toml = "^0.8"
82 |
83 | [dev-dependencies]
84 | cfg-if = "^1.0.4"
85 | expect-test = "^1"
86 |
87 | [target.'cfg(windows)'.dependencies]
88 | nu-ansi-term = "^0.50"
89 |
90 | [features]
91 | tls-rustls = ["duckscriptsdk/tls-rustls"]
92 | tls-native = ["duckscriptsdk/tls-native"]
93 | tls = ["tls-rustls"] # alias for backward compatibility
94 | default = ["tls-rustls"]
95 |
96 | [profile.release]
97 | codegen-units = 1
98 | lto = true
99 |
--------------------------------------------------------------------------------
/src/lib/mod.rs:
--------------------------------------------------------------------------------
1 | #![deny(
2 | future_incompatible,
3 | keyword_idents,
4 | let_underscore,
5 | nonstandard_style,
6 | unused
7 | )]
8 | #![warn(unknown_lints)]
9 |
10 | //! # cargo-make
11 | //!
12 | //! Rust task runner and build tool.
13 | //! The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.
14 | //! A task is a command or a script to execute.
15 | //! Tasks can have dependencies which are also tasks that will be executed before the task itself.
16 | //! With a simple toml based configuration file, you can define a multi platform build script that can run build, test,
17 | //! documentation generation, bench tests execution, security validations and more by running a single command.
18 | //!
19 | //! ## Installation
20 | //! In order to install, just run the following command
21 | //!
22 | //! ```sh
23 | //! cargo install cargo-make
24 | //! ```
25 | //!
26 | //! This will install cargo-make in your ~/.cargo/bin.
27 | //! Make sure to add ~/.cargo/bin directory to your PATH variable.
28 | //!
29 | //! # Contributing
30 | //! See [contributing guide](https://github.com/sagiegurari/cargo-make/blob/master/.github/CONTRIBUTING.md)
31 | //!
32 | //! # License
33 | //! Developed by Sagie Gur-Ari and licensed under the
34 | //! [Apache 2](https://github.com/sagiegurari/cargo-make/blob/master/LICENSE) open source license.
35 | //!
36 |
37 | // Dependencies used in the binary `makers`:
38 | use crate::error::CargoMakeError;
39 | use crate::types::CliArgs;
40 | #[cfg(windows)]
41 | use nu_ansi_term as _;
42 |
43 | #[macro_use]
44 | extern crate log;
45 | #[macro_use]
46 | extern crate serde_derive;
47 |
48 | #[cfg(test)]
49 | mod test;
50 |
51 | // make types public for docs
52 | pub mod types;
53 |
54 | mod cache;
55 | pub mod cli;
56 | pub mod cli_commands;
57 | pub mod cli_parser;
58 | mod command;
59 | pub mod completion;
60 | mod condition;
61 | pub mod config;
62 | mod descriptor;
63 | mod environment;
64 | pub mod error;
65 | mod execution_plan;
66 | mod functions;
67 | mod installer;
68 | mod io;
69 | mod legacy;
70 | pub mod logger;
71 | mod plugin;
72 | mod profile;
73 | mod proxy_task;
74 | mod recursion_level;
75 | pub mod runner;
76 | mod scriptengine;
77 | mod storage;
78 | mod time_summary;
79 | mod toolchain;
80 | mod version;
81 |
82 | /// Handles the command line arguments and executes the runner.
83 | pub fn run_cli(command_name: String, sub_command: bool) -> Result {
84 | cli::run_cli(command_name, sub_command)
85 | }
86 |
--------------------------------------------------------------------------------
/docs/api/trait.impl/core/cmp/trait.Eq.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var implementors = Object.fromEntries([["cli",[["impl Eq for CargoMakeErrorDiscriminants "],["impl Eq for DependencyIdentifier "],["impl Eq for ToolchainSpecifier "],["impl Eq for UnstableFeature "],["impl Eq for TaskIdentifier "],["impl Eq for TestArg "],["impl Eq for ToolchainBoundedSpecifier "],["impl<T: Eq > Eq for MaybeArray <T>"]]]]);
3 | if (window.register_implementors) {
4 | window.register_implementors(implementors);
5 | } else {
6 | window.pending_implementors = implementors;
7 | }
8 | })()
9 | //{"start":57,"fragment_lengths":[2304]}
--------------------------------------------------------------------------------
/src/lib/time_summary.rs:
--------------------------------------------------------------------------------
1 | //! # time_summary
2 | //!
3 | //! Prints out the time summary for the flow.
4 | //!
5 |
6 | use crate::types::{CliArgs, Config};
7 | use std::cmp::Ordering;
8 | use std::time::SystemTime;
9 |
10 | pub(crate) fn is_time_summary_enabled() -> bool {
11 | envmnt::is("CARGO_MAKE_PRINT_TIME_SUMMARY")
12 | }
13 |
14 | pub(crate) fn add(time_summary: &mut Vec<(String, u128)>, name: &str, start_time: SystemTime) {
15 | match start_time.elapsed() {
16 | Ok(elapsed) => time_summary.push((name.to_string(), elapsed.as_millis())),
17 | _ => (),
18 | };
19 | }
20 |
21 | pub(crate) fn print(time_summary: &Vec<(String, u128)>) {
22 | if is_time_summary_enabled() {
23 | let mut time_summary_sorted = time_summary.clone();
24 | time_summary_sorted
25 | .sort_by(|entry1, entry2| entry2.1.partial_cmp(&entry1.1).unwrap_or(Ordering::Equal));
26 |
27 | let mut total_time = 0;
28 | let mut max_name_size = 0;
29 | for entry in &time_summary_sorted {
30 | total_time = total_time + entry.1;
31 | let name_size = entry.0.len();
32 | if max_name_size < name_size {
33 | max_name_size = name_size;
34 | }
35 | }
36 |
37 | info!("==================Time Summary==================");
38 | for entry in &time_summary_sorted {
39 | let percentage = (entry.1 as f64 / total_time as f64) * 100.0;
40 | let seconds = entry.1 as f64 / 1000.0;
41 |
42 | let percentage_size = if percentage >= 100.0 {
43 | 3
44 | } else if percentage >= 10.0 {
45 | 2
46 | } else {
47 | 1
48 | };
49 | let mut gap_size = 4 - percentage_size;
50 | let value_gap = format!("{: <1$}", "", gap_size);
51 |
52 | let name_size = entry.0.len();
53 | gap_size = max_name_size - name_size + 3;
54 | let name_gap = format!("{: <1$}", "", gap_size);
55 |
56 | info!(
57 | "{}:{}{:.2}%{} {:.2} seconds",
58 | entry.0, name_gap, percentage, value_gap, seconds
59 | );
60 | }
61 | info!("================================================");
62 | }
63 | }
64 |
65 | pub(crate) fn init(config: &Config, cli_args: &CliArgs) {
66 | if config.config.time_summary.unwrap_or(false)
67 | || cli_args.print_time_summary
68 | || envmnt::is("CARGO_MAKE_CI")
69 | {
70 | envmnt::set_bool("CARGO_MAKE_PRINT_TIME_SUMMARY", true);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/docs/api/settings.html:
--------------------------------------------------------------------------------
1 | Settings You need to enable JavaScript be able to update your settings.
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_check_task_condition_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::plugin::runner;
3 | use crate::plugin::types::{Plugin, Plugins};
4 | use crate::test::create_empty_flow_info;
5 | use crate::types::{FlowState, RunTaskOptions, Task, TaskCondition};
6 | use indexmap::IndexMap;
7 | use std::cell::RefCell;
8 | use std::rc::Rc;
9 |
10 | #[test]
11 | fn run_valid() {
12 | let mut plugins = IndexMap::new();
13 | plugins.insert(
14 | "test".to_string(),
15 | Plugin {
16 | script: r#"
17 | value = get_env cm_plugin_check_task_condition_test_valid_env
18 | assert_eq ${value} ""
19 | valid = cm_plugin_check_task_condition
20 | assert_false "${valid}"
21 |
22 | set_env cm_plugin_check_task_condition_test_valid_env 1
23 | valid = cm_plugin_check_task_condition
24 | assert "${valid}"
25 |
26 | set_env cm_plugin_check_task_condition_test_valid_plugin done
27 | "#
28 | .to_string(),
29 | },
30 | );
31 |
32 | let mut task = Task::new();
33 | task.plugin = Some("test".to_string());
34 | task.condition = Some(TaskCondition {
35 | condition_type: None,
36 | fail_message: None,
37 | profiles: None,
38 | os: None,
39 | platforms: None,
40 | channels: None,
41 | env_set: Some(vec![
42 | "cm_plugin_check_task_condition_test_valid_env".to_string()
43 | ]),
44 | env_not_set: None,
45 | env_true: None,
46 | env_false: None,
47 | env: None,
48 | env_not: None,
49 | env_contains: None,
50 | rust_version: None,
51 | files_exist: None,
52 | files_not_exist: None,
53 | files_modified: None,
54 | });
55 |
56 | let mut flow_info = create_empty_flow_info();
57 | flow_info
58 | .config
59 | .tasks
60 | .insert("test".to_string(), task.clone());
61 | flow_info.config.plugins = Some(Plugins {
62 | aliases: None,
63 | plugins,
64 | });
65 |
66 | assert!(!envmnt::exists(
67 | "cm_plugin_check_task_condition_test_valid_plugin"
68 | ));
69 |
70 | let done = runner::run_task(
71 | &flow_info,
72 | Rc::new(RefCell::new(FlowState::new())),
73 | &Step {
74 | name: "test".to_string(),
75 | config: task,
76 | },
77 | &RunTaskOptions {
78 | plugins_enabled: true,
79 | },
80 | );
81 |
82 | assert!(done);
83 | assert!(envmnt::is_equal(
84 | "cm_plugin_check_task_condition_test_valid_plugin",
85 | "done"
86 | ));
87 | }
88 |
--------------------------------------------------------------------------------
/docs/api/help.html:
--------------------------------------------------------------------------------
1 | Help You need to enable JavaScript to use keyboard commands or search.
For more information, browse the rustdoc handbook .
--------------------------------------------------------------------------------
/src/lib/descriptor/makefiles/deprecated.toml:
--------------------------------------------------------------------------------
1 |
2 | [tasks.legacy-migration]
3 | description = "Migrates deprecated environment variables."
4 | category = "Deprecated"
5 | private = true
6 | condition = { env_true = ["CARGO_MAKE_RUN_DEPRECATED_MIGRATION"] }
7 | env = { CARGO_MAKE_RUN_DEPRECATED_MIGRATION = false }
8 | script = '''
9 | #!@duckscript
10 | fn migrate_env
11 | new_var = get_env ${1}
12 | old_var = get_env ${2}
13 |
14 | if is_defined old_var
15 | echo Old environment variable ${2} detected, please use ${1} instead.
16 | set_env ${1} ${old_var}
17 | else if is_defined new_var
18 | set_env ${2} ${new_var}
19 | end
20 | end
21 |
22 | migrate_env CARGO_MAKE_TEST_USE_MULTI_TEST_PHASES CARGO_MAKE_TEST_USE_MUTLI_TEST_PHASES
23 | '''
24 |
25 | [tasks.build-verbose]
26 | description = "Runs the rust compiler with verbose output."
27 | category = "Deprecated"
28 | deprecated = "Use build task with CARGO_MAKE_CARGO_VERBOSE_FLAGS set to --verbose instead."
29 | env = { "CARGO_MAKE_CARGO_VERBOSE_FLAGS" = "${CARGO_MAKE_CARGO_VERBOSE}" }
30 | run_task = "build"
31 |
32 | [tasks.test-verbose]
33 | description = "Runs all available tests with verbose output."
34 | category = "Deprecated"
35 | deprecated = "Use test task with CARGO_MAKE_CARGO_VERBOSE_FLAGS set to --verbose instead."
36 | env = { "CARGO_MAKE_CARGO_VERBOSE_FLAGS" = "${CARGO_MAKE_CARGO_VERBOSE}" }
37 | run_task = "test"
38 |
39 | [tasks.conditioned-check-format]
40 | category = "Deprecated"
41 | deprecated = "Please use task: check-format-ci-flow"
42 | run_task = "check-format-ci-flow"
43 |
44 | [tasks.conditioned-clippy]
45 | category = "Deprecated"
46 | deprecated = "Please use task: clippy-ci-flow"
47 | run_task = "clippy-ci-flow"
48 |
49 | [tasks.bintray-upload]
50 | description = "Uploads the binary artifact from the cargo package/publish output to bintray."
51 | category = "Deprecated"
52 | deprecated = true
53 |
54 | [tasks.bintray-upload.linux]
55 | condition = { env_set = [
56 | "BINTRAY_API_KEY",
57 | "BINTRAY_OWNER_NAME",
58 | "BINTRAY_PACKAGE_NAME",
59 | "CARGO_MAKE_CRATE_NAME",
60 | "CARGO_MAKE_CRATE_VERSION",
61 | ] }
62 | script = '''
63 | curl -T "./target/package/${CARGO_MAKE_CRATE_NAME}-${CARGO_MAKE_CRATE_VERSION}/target/debug/${CARGO_MAKE_CRATE_NAME}" -u${BINTRAY_OWNER_NAME}:${BINTRAY_API_KEY} -H "X-Bintray-Package:${BINTRAY_PACKAGE_NAME}" -H "X-Bintray-Version:v${CARGO_MAKE_CRATE_VERSION}" https://api.bintray.com/content/${BINTRAY_OWNER_NAME}/${CARGO_MAKE_CRATE_NAME}/${CARGO_MAKE_CRATE_NAME}_v${CARGO_MAKE_CRATE_VERSION}?override=1
64 | curl -X POST -u${BINTRAY_OWNER_NAME}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER_NAME}/${CARGO_MAKE_CRATE_NAME}/${BINTRAY_PACKAGE_NAME}/v${CARGO_MAKE_CRATE_VERSION}/publish
65 | '''
66 |
--------------------------------------------------------------------------------
/docs/api/makers/fn.get_name.html:
--------------------------------------------------------------------------------
1 | get_name in makers - Rust
--------------------------------------------------------------------------------
/src/lib/plugin/sdk/cm_plugin_run_task_test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::plugin::runner;
3 | use crate::plugin::types::{Plugin, Plugins};
4 | use crate::test::create_empty_flow_info;
5 | use crate::types::{EnvValue, ScriptValue, Task};
6 | use indexmap::IndexMap;
7 |
8 | #[test]
9 | fn run_valid() {
10 | let mut plugins = IndexMap::new();
11 | plugins.insert(
12 | "test".to_string(),
13 | Plugin {
14 | script: r#"
15 | value = get_env cm_plugin_run_task_test_valid_env
16 | assert_eq ${value} ""
17 | value = get_env cm_plugin_run_task_test_valid_script
18 | assert_eq ${value} ""
19 |
20 | cm_plugin_run_task
21 |
22 | value = get_env cm_plugin_run_task_test_valid_env
23 | assert_eq ${value} 1
24 | value = get_env cm_plugin_run_task_test_valid_script
25 | assert_eq ${value} yes
26 |
27 | set_env cm_plugin_run_task_test_valid_plugin done
28 | "#
29 | .to_string(),
30 | },
31 | );
32 |
33 | let mut task = Task::new();
34 | task.plugin = Some("test".to_string());
35 | task.script_runner = Some("@duckscript".to_string());
36 | task.script = Some(ScriptValue::SingleLine(
37 | r#"
38 | set_env cm_plugin_run_task_test_valid_script yes
39 | "#
40 | .to_string(),
41 | ));
42 | let mut env = IndexMap::new();
43 | env.insert(
44 | "cm_plugin_run_task_test_valid_env".to_string(),
45 | EnvValue::Value("1".to_string()),
46 | );
47 | task.env = Some(env);
48 |
49 | let mut flow_info = create_empty_flow_info();
50 | flow_info
51 | .config
52 | .tasks
53 | .insert("test".to_string(), task.clone());
54 | flow_info.config.plugins = Some(Plugins {
55 | aliases: None,
56 | plugins,
57 | });
58 |
59 | assert!(!envmnt::exists("cm_plugin_run_task_test_valid_env"));
60 | assert!(!envmnt::exists("cm_plugin_run_task_test_valid_script"));
61 | assert!(!envmnt::exists("cm_plugin_run_task_test_valid_plugin"));
62 |
63 | let done = runner::run_task(
64 | &flow_info,
65 | Rc::new(RefCell::new(FlowState::new())),
66 | &Step {
67 | name: "test".to_string(),
68 | config: task,
69 | },
70 | &RunTaskOptions {
71 | plugins_enabled: true,
72 | },
73 | );
74 |
75 | assert!(done);
76 | assert!(envmnt::is_equal("cm_plugin_run_task_test_valid_env", "1"));
77 | assert!(envmnt::is_equal(
78 | "cm_plugin_run_task_test_valid_script",
79 | "yes"
80 | ));
81 | assert!(envmnt::is_equal(
82 | "cm_plugin_run_task_test_valid_plugin",
83 | "done"
84 | ));
85 | }
86 |
--------------------------------------------------------------------------------
/docs/api/cargo_make/fn.get_name.html:
--------------------------------------------------------------------------------
1 | get_name in cargo_make - Rust
--------------------------------------------------------------------------------
/docs/api/static.files/scrape-examples-d508a8a9.js:
--------------------------------------------------------------------------------
1 | "use strict";(function(){const DEFAULT_MAX_LINES=5;const HIDDEN_MAX_LINES=10;function scrollToLoc(elt,loc,isHidden){const lines=elt.querySelector(".src-line-numbers > pre");let scrollOffset;const maxLines=isHidden?HIDDEN_MAX_LINES:DEFAULT_MAX_LINES;if(loc[1]-loc[0]>maxLines){const line=Math.max(0,loc[0]-1);scrollOffset=lines.children[line].offsetTop}else{const halfHeight=elt.offsetHeight/2;const offsetTop=lines.children[loc[0]].offsetTop;const lastLine=lines.children[loc[1]];const offsetBot=lastLine.offsetTop+lastLine.offsetHeight;const offsetMid=(offsetTop+offsetBot)/2;scrollOffset=offsetMid-halfHeight}lines.parentElement.scrollTo(0,scrollOffset);elt.querySelector(".rust").scrollTo(0,scrollOffset)}function createScrapeButton(parent,className,content){const button=document.createElement("button");button.className=className;button.innerText=content;parent.insertBefore(button,parent.firstChild);return button}window.updateScrapedExample=(example,buttonHolder)=>{let locIndex=0;const highlights=Array.prototype.slice.call(example.querySelectorAll(".highlight"));const link=example.querySelector(".scraped-example-title a");let expandButton=null;if(!example.classList.contains("expanded")){expandButton=createScrapeButton(buttonHolder,"expand","↕")}const isHidden=example.parentElement.classList.contains("more-scraped-examples");const locs=example.locs;if(locs.length>1){const next=createScrapeButton(buttonHolder,"next","≻");const prev=createScrapeButton(buttonHolder,"prev","≺");const onChangeLoc=changeIndex=>{removeClass(highlights[locIndex],"focus");changeIndex();scrollToLoc(example,locs[locIndex][0],isHidden);addClass(highlights[locIndex],"focus");const url=locs[locIndex][1];const title=locs[locIndex][2];link.href=url;link.innerHTML=title};prev.addEventListener("click",()=>{onChangeLoc(()=>{locIndex=(locIndex-1+locs.length)%locs.length})});next.addEventListener("click",()=>{onChangeLoc(()=>{locIndex=(locIndex+1)%locs.length})})}if(expandButton){expandButton.addEventListener("click",()=>{if(hasClass(example,"expanded")){removeClass(example,"expanded");scrollToLoc(example,locs[0][0],isHidden)}else{addClass(example,"expanded")}})}};function setupLoc(example,isHidden){example.locs=JSON.parse(example.attributes.getNamedItem("data-locs").textContent);scrollToLoc(example,example.locs[0][0],isHidden)}const firstExamples=document.querySelectorAll(".scraped-example-list > .scraped-example");onEachLazy(firstExamples,el=>setupLoc(el,false));onEachLazy(document.querySelectorAll(".more-examples-toggle"),toggle=>{onEachLazy(toggle.querySelectorAll(".toggle-line, .hide-more"),button=>{button.addEventListener("click",()=>{toggle.open=false})});const moreExamples=toggle.querySelectorAll(".scraped-example");toggle.querySelector("summary").addEventListener("click",()=>{setTimeout(()=>{onEachLazy(moreExamples,el=>setupLoc(el,true))})},{once:true})})})()
--------------------------------------------------------------------------------
/src/lib/scriptengine/duck_script/sdk/cm_run_task.rs:
--------------------------------------------------------------------------------
1 | //! # cm_run_task
2 | //!
3 | //! Enables to run cargo-make tasks from within duckscript.
4 | //!
5 |
6 | use crate::error::CargoMakeError;
7 | use crate::runner;
8 | use crate::types::{FlowInfo, FlowState};
9 | use duckscript::types::command::{Command, CommandInvocationContext, CommandResult};
10 | use std::cell::RefCell;
11 | use std::rc::Rc;
12 | use std::thread;
13 |
14 | #[derive(Clone)]
15 | pub(crate) struct CommandImpl {
16 | flow_info: FlowInfo,
17 | flow_state: Rc>,
18 | }
19 |
20 | impl Command for CommandImpl {
21 | fn name(&self) -> String {
22 | "cm_run_task".to_string()
23 | }
24 |
25 | fn clone_and_box(&self) -> Box {
26 | Box::new((*self).clone())
27 | }
28 |
29 | fn run(&self, context: CommandInvocationContext) -> CommandResult {
30 | if context.arguments.is_empty() {
31 | CommandResult::Error(
32 | CargoMakeError::NotFound(String::from("No task name provided.")).to_string(),
33 | )
34 | } else {
35 | let (task_name, async_run) =
36 | if context.arguments.len() > 0 && context.arguments[0] == "--async" {
37 | (context.arguments[1].clone(), true)
38 | } else {
39 | (context.arguments[0].clone(), false)
40 | };
41 |
42 | if self.flow_info.config.tasks.contains_key(&task_name) {
43 | let mut sub_flow_info = self.flow_info.clone();
44 | sub_flow_info.task = task_name.clone();
45 |
46 | if async_run {
47 | let cloned_flow_state = self.flow_state.borrow().clone();
48 |
49 | thread::spawn(move || -> Result<(), CargoMakeError> {
50 | runner::run_flow(
51 | &sub_flow_info,
52 | Rc::new(RefCell::new(cloned_flow_state)),
53 | true,
54 | )
55 | });
56 | } else {
57 | if let Err(e) = runner::run_flow(&sub_flow_info, self.flow_state.clone(), true)
58 | {
59 | return CommandResult::Error(e.to_string());
60 | }
61 | }
62 |
63 | CommandResult::Continue(Some("true".to_string()))
64 | } else {
65 | CommandResult::Error(
66 | format!("Task: {} not found.", &context.arguments[0]).to_string(),
67 | )
68 | }
69 | }
70 | }
71 | }
72 |
73 | pub(crate) fn create(flow_info: &FlowInfo, flow_state: Rc>) -> Box {
74 | Box::new(CommandImpl {
75 | flow_info: flow_info.clone(),
76 | flow_state,
77 | })
78 | }
79 |
--------------------------------------------------------------------------------