Skip to content

Commit 1061273

Browse files
committed
feat(cmd): add use command
+ small refactoring
1 parent 816eaa4 commit 1061273

File tree

12 files changed

+101
-61
lines changed

12 files changed

+101
-61
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "deployer"
3-
version = "2.0.0-beta-6"
3+
version = "2.0.0-beta-7"
44
edition = "2024"
55

66
[[bin]]

DOCS.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ depl watch my-pipe # watch `my-pipe` Pipeline and re-run
3535

3636
### Console Interface (TUI)
3737

38-
Deployer has support for a high-end terminal-based customizer, allowing you to forget about manually writing Actions and Pipelines for your projects. Just try to create an Action or Pipeline and Deployer will ask you about everything.
38+
Deployer has support for a high-end terminal-based customizer, allowing you to forget about manually writing actions and Pipelines for your projects. Just try to create an action or Pipeline and Deployer will ask you about everything.
3939

4040
### Logs
4141

@@ -47,7 +47,7 @@ In the Deployer build caches folder, there is a `logs` folder that contains proj
4747

4848
Action is the main entity of Deployer. Actions as part of pipelines are used to build, install, and deploy processes. However, an action itself cannot be assigned to a project, that's what pipelines are for (see below).
4949

50-
In the Deployer's Action Registry or project's actions list, an action looks like a construction:
50+
In the Deployer's action Registry or project's actions list, an action looks like a construction:
5151

5252
```yaml
5353
info: upx@0.1.0
@@ -78,7 +78,7 @@ requirements:
7878
# if this path exists, the requirement is considered satisfied
7979
- type: exists
8080
path: /usr/bin/mold
81-
# if this check is passed, the requirement will be considered satisfied (for details, see below - Action `Check`)
81+
# if this check is passed, the requirement will be considered satisfied (for details, see below - action `Check`)
8282
- type: check_success
8383
command:
8484
cmd: /usr/bin/python -V
@@ -99,7 +99,7 @@ There are 7 action categories:
9999
6. Actions of synchronization build folders - from current to remote host `sync_to_remote` and vice versa `sync_from_remote`
100100
7. `interrupt` (when a user needs to perform some actions by hand before continue a pipeline)
101101

102-
The concept of a custom command, a command for the terminal shell, is fundamental. The `custom`, `observe`, and the three main categories of Actions contain one or more custom commands inside.
102+
The concept of a custom command, a command for the terminal shell, is fundamental. The `custom`, `observe`, and the three main categories of actions contain one or more custom commands inside.
103103

104104
#### 1.1. Custom command
105105

@@ -268,7 +268,7 @@ When a patch is applied, Deployer displays the number of times it has been appli
268268

269269
#### 1.4. Actions of synchronization run folders - from current to remote host `sync_to_remote` and vice versa `sync_from_remote`
270270

271-
Sometimes you need to synchronize build files between remote hosts and the current host. For example, when some actions must be performed on one host, and some on another. To do this, you can use the built-in Actions `sync_to_remote` and `sync_from_remote`.
271+
Sometimes you need to synchronize build files between remote hosts and the current host. For example, when some actions must be performed on one host, and some on another. To do this, you can use the built-in actions `sync_to_remote` and `sync_from_remote`.
272272

273273
#### 1.5. Other actions - `interrupt`, `observe` and `test`
274274

@@ -344,9 +344,9 @@ Building and execution occur as follows:
344344
5. Deployer on the host machine runs Deployer in the container and performs complete pipeline execution.
345345

346346
> [!NOTE]
347-
> When building in containers, Deployer does not support Actions `interrupt`, `observe`, `add_to_storage` and `use_from_storage`, and when running - Actions `add_to_storage` and `use_from_storage`.
347+
> When building in containers, Deployer does not support actions `interrupt`, `observe`, `add_to_storage` and `use_from_storage`, and when running - actions `add_to_storage` and `use_from_storage`.
348348
>
349-
> To solve problems of synchronizing files or performing I/O operations, you can use a pipeline with containerized build options inside another pipeline, which can then use the Actions you need.
349+
> To solve problems of synchronizing files or performing I/O operations, you can use a pipeline with containerized build options inside another pipeline, which can then use the actions you need.
350350

351351
> [!NOTE]
352352
> To prevent building Deployer before your project, switch to `shell` pipeline driver.

MIGRATIONS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Migrations will be applied automatically.
2020

2121
## From `1.4.1` to `1.4.2`
2222

23-
1. Manually check all your `add_to_storage` Actions (`AutoVersionExtractFromRule`): them now look like this:
23+
1. Manually check all your `add_to_storage` actions (`AutoVersionExtractFromRule`): them now look like this:
2424

2525
```json
2626
[
@@ -57,10 +57,10 @@ Formally, you should now specify `type` field of `auto_version_rule` object.
5757

5858
Migrations will be almost fully applied automatically on configuration save. Deployer will be able to work with old configuration formats (`"version": 2`).
5959

60-
1. All Actions will be typed internally with `type` field and `snake_case` (example: `{ "type": "build", ... }`).
60+
1. All actions will be typed internally with `type` field and `snake_case` (example: `{ "type": "build", ... }`).
6161
2. `deploy-config.json` and `deploy-global.json` will be upgraded to `"version": 3`.
6262
3. Variables, requirements, placements and other structs are changed, see the documentation.
63-
4. Check Action will become Test, original Test will be migrated into PostBuild.
63+
4. Check action will become Test, original Test will be migrated into PostBuild.
6464

6565
### Need manual changes:
6666

@@ -74,5 +74,5 @@ Migrations will be almost fully applied automatically on configuration save. Dep
7474
## From `<=1.2.1` to `1.3.0`
7575

7676
1. Edit `deploy-config.json` and rename `inplace_artifacts_into_project_root` to `place_artifacts_into_project_root`.
77-
2. Remove `tags` field inside your deploy-like and `Observe` Actions.
77+
2. Remove `tags` field inside your deploy-like and `Observe` actions.
7878
3. `deploy-config.json` and `deploy-global.json` will be upgraded to `"version": 2`.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ actions:
9696
used: upx@0.1.0
9797
```
9898

99-
Note that you can change the inner content of Actions inside Pipelines, and also can change the inner content of Pipelines and their Actions if these Pipelines assigned to your project. The changes will not affect Actions and Pipelines from Deployer's Registries.
99+
Note that you can change the inner content of actions inside Pipelines, and also can change the inner content of Pipelines and their actions if these Pipelines assigned to your project. The changes will not affect actions and Pipelines from Deployer's Registries.
100100

101101
You can view your actions and pipelines and get it in YAML by simple commands:
102102

@@ -108,7 +108,7 @@ depl cat action upx@0.1.0
108108
depl cat pipeline pack@0.1.0
109109
```
110110

111-
And, of course, load Actions and Pipelines from YAML files by:
111+
And, of course, load actions and Pipelines from YAML files by:
112112

113113
```bash
114114
depl new action -f {your config}
@@ -122,7 +122,7 @@ depl init
122122
depl edit .
123123
```
124124

125-
You should add some actions and specify project variables that you'll use. For our example, add simple variable with `target/release/my-app` value. Also add `cargo-release@0.1.0` and `upx@0.1.0` actions from Actions Registry. And not forget to add `Cargo.lock` file and `target` folder to cache files to prevent syncing project folder cache with run folder cache (without specifying this; see `depl run --help` for more).
125+
You should add some actions and specify project variables that you'll use. For our example, add simple variable with `target/release/my-app` value. Also add `cargo-release@0.1.0` and `upx@0.1.0` actions from actions Registry. And not forget to add `Cargo.lock` file and `target` folder to cache files to prevent syncing project folder cache with run folder cache (without specifying this; see `depl run --help` for more).
126126

127127
After all you will get this `.depl/config.yaml`:
128128

@@ -199,7 +199,7 @@ depl run -fc
199199
# or explicitly specify the project pipeline's short name - `build-and-compress`
200200
depl run pack
201201

202-
# create pipeline with `Observe` Action and start development server with auto-rebuild
202+
# create pipeline with `Observe` action and start development server with auto-rebuild
203203
depl watch build-and-deploy-devel
204204
```
205205

TODO.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
- [x] Add `depl cd` command to change current directory to one of run directories
66
- [x] Make `depl export` command:
77
1. [x] for exporting Pipelines to `bash` scripts
8-
2. [x] for exporting (and importing with merging) Actions & Pipelines Registries
8+
2. [x] for exporting (and importing with merging) actions & Pipelines Registries
99
3. [x] for exporting Pipelines to CI/CD (GitHub Actions & GitLab CI) configurations
10-
- [x] Add `--skip N` argument to skip N Actions inside selected Pipelines, if you exactly know that they have no need to re-run after changes
10+
- [x] Add `--skip N` argument to skip N actions inside selected Pipelines, if you exactly know that they have no need to re-run after changes
1111
- [x] Add `--no-clear` argument to disable screen clear on `run`/`watch`
12-
- [x] Go to more declarative way to define project configuration (ver. 6 & Deployer v2.0)
12+
- [x] Go to more declarative way to define project configuration (ver. 7 & Deployer v2.0)
1313
1. [x] Remove targets, programming languages and actions variability
1414
2. [x] Rename `Actions` & `Pipelines` to `actions` and `pipelines`
1515
3. [x] Split `configs.rs` to `project.rs` and `globals.rs`
@@ -34,3 +34,4 @@
3434
- [x] Add `info` field to requirements to inform users about commands or links to install them
3535
- [x] Unify `edit`, `cat` & `rm` commands behavior
3636
- [ ] Add possibility to setup variables inside each pipeline independently
37+
- [x] Add `use` command to synchronize content (with `subfolder` argument)

src/actions.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::rw::read_checked;
3737
/// Used action.
3838
#[derive(Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Clone)]
3939
pub struct UsedAction {
40-
/// Description of the Action.
40+
/// Description of the action.
4141
#[serde(skip_serializing_if = "Option::is_none")]
4242
pub title: Option<String>,
4343
/// Action defined in the project config.
@@ -62,7 +62,7 @@ impl UsedAction {
6262
))
6363
}
6464

65-
/// Returns mutable slice to all custom commands in this Action.
65+
/// Returns mutable slice to all custom commands in this action.
6666
pub fn commands<'project>(
6767
&'project self,
6868
definitions: &'project BTreeSet<DefinedAction>,
@@ -117,7 +117,7 @@ impl PartialOrd for DefinedAction {
117117
}
118118

119119
impl DefinedAction {
120-
/// Returns mutable slice to all custom commands in this Action.
120+
/// Returns mutable slice to all custom commands in this action.
121121
pub fn commands(&self) -> anyhow::Result<Vec<&CustomCommand>> {
122122
let cmds = match &self.action {
123123
Action::Interrupt
@@ -225,7 +225,7 @@ pub enum Action {
225225
/// Action to run tests.
226226
Test(TestAction),
227227

228-
/// Action to run observers (`btop`, Jaeger, Prometheus, Grafana, etc.).
228+
/// Action to run observers (`btop`, `gdb`, some `docker` containers, foreground benchmarks, Jaeger, Prometheus, Grafana, etc.).
229229
Observe(ObserveAction),
230230

231231
/// Action to copy content with given info from Deployer's storage.
@@ -239,7 +239,7 @@ pub enum Action {
239239
}
240240

241241
impl Action {
242-
/// Interrupt Action.
242+
/// Interrupt action.
243243
pub fn interrupt() -> anyhow::Result<(bool, Vec<String>)> {
244244
println!();
245245
inquire_reorder::Confirm::new(i18n::INTERRUPT)
@@ -249,7 +249,7 @@ impl Action {
249249
Ok((true, vec![]))
250250
}
251251

252-
/// Runs the Action with given project options and run environment.
252+
/// Runs the action with given project options and run environment.
253253
pub async fn run_with(
254254
&self,
255255
config: &DeployerProjectOptions,
@@ -316,7 +316,7 @@ impl Action {
316316
}
317317
}
318318

319-
/// Prints all available Actions on the screen.
319+
/// Prints all available actions on the screen.
320320
pub fn list_actions(globals: &DeployerGlobalConfig) {
321321
println!("{}", i18n::ACTIONS_AVAILABLE);
322322

@@ -347,7 +347,7 @@ fn choose_action<'a>(actions_registry: &'a BTreeSet<DefinedAction>, prompt: &str
347347
.ok_or(anyhow!("No such action!"))
348348
}
349349

350-
/// Removes selected Action.
350+
/// Removes selected action.
351351
pub fn remove_action(globals: &mut DeployerGlobalConfig, args: RemoveActionArgs) -> anyhow::Result<()> {
352352
let action = if let Some(info) = args.info {
353353
let info = info.to_info()?;
@@ -374,7 +374,7 @@ pub fn remove_action(globals: &mut DeployerGlobalConfig, args: RemoveActionArgs)
374374
Ok(())
375375
}
376376

377-
/// Adds new Action.
377+
/// Adds new action.
378378
pub fn new_action(globals: &mut DeployerGlobalConfig, args: &NewActionArgs) -> anyhow::Result<DefinedAction> {
379379
if let Some(from_file) = &args.from {
380380
let action = read_checked::<DefinedAction>(from_file)
@@ -391,7 +391,7 @@ pub fn new_action(globals: &mut DeployerGlobalConfig, args: &NewActionArgs) -> a
391391
Ok(defined_action)
392392
}
393393

394-
/// Prints Action as YAML.
394+
/// Prints action as YAML.
395395
pub fn cat_action(globals: &DeployerGlobalConfig, args: CatActionArgs) -> anyhow::Result<()> {
396396
let action = if let Some(info) = args.info {
397397
let info = info.to_info()?;
@@ -411,7 +411,7 @@ pub fn cat_action(globals: &DeployerGlobalConfig, args: CatActionArgs) -> anyhow
411411
Ok(())
412412
}
413413

414-
/// Edits the Action.
414+
/// Edits the action.
415415
pub fn edit_action(globals: &mut DeployerGlobalConfig, args: EditActionArgs) -> anyhow::Result<()> {
416416
let mut action = if let Some(info) = args.info {
417417
let info = info.to_info()?;

src/actions/storage_add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! AddToStorage Action.
1+
//! `AddToStorage` action module.
22
//!
33
//! Based on automatic rule to extract version from project, allows you to
44
//! load your artifacts as content to Deployer's storage.

src/actions/storage_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Storage use's module.
1+
//! `UseFromStorage` action module.
22
33
use serde::{Deserialize, Serialize};
44
use std::path::PathBuf;

src/ansible.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn make_inventory(
126126
Ok(())
127127
}
128128

129-
/// Makes Ansible playbook from given Pipeline.
129+
/// Makes Ansible playbook from given pipeline.
130130
pub async fn make_playbook(
131131
config: &DeployerProjectOptions,
132132
env: &RunEnvironment<'_>,
@@ -232,7 +232,7 @@ pub async fn make_playbook(
232232
Ok(playbook_name)
233233
}
234234

235-
/// Runs given Pipeline with Ansible.
235+
/// Runs given pipeline with Ansible.
236236
pub async fn execute_pipeline_with_ansible(
237237
config: &DeployerProjectOptions,
238238
env: &RunEnvironment<'_>,

0 commit comments

Comments
 (0)