Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/site/docs-en/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,47 @@ At the end it lists the commits, the files written and the tags created, then de

---

## `ferrflow snapshot`

Stamp every package with pending changes with a throwaway pre-release version, for a PR preview build.

```bash
ferrflow snapshot --tag <SUFFIX> [--from-zero] [--no-git] [--run-hooks]
```

| Flag | Description |
| ---------------- | ------------------------------------------------------------------------ |
| `--tag <SUFFIX>` | Pre-release suffix, e.g. `pr-123`. Must be a valid semver pre-release |
| `--from-zero` | Use `0.0.0-<SUFFIX>.<sha>` instead of the computed next version |
| `--no-git` | Skip the clean working tree check, for checkouts CI already modified |
| `--run-hooks` | Run the `pre_publish` and `post_publish` hooks with the snapshot version |

The next version is computed from every commit since each package's last release, then its pre-release part is replaced: `1.3.0` becomes `1.3.0-pr-123.abc1234`, where `abc1234` is the short HEAD commit. Only versioned files are written, plus lockfiles when `updateLockfiles` is on. There is no changelog, commit, tag or push, and configured publishers do not run, so nothing can move a `latest` dist-tag. With `--dry-run` nothing is written.

It prints one JSON object on stdout:

```json
{
"tag": "pr-123",
"commit": "abc1234",
"dry_run": false,
"packages": [
{
"name": "cli",
"version": "1.3.0-pr-123.abc1234",
"previous_version": "1.2.0"
}
]
}
```

```bash
ferrflow snapshot --tag "pr-$PR_NUMBER" > snapshot.json
npm publish --tag "pr-$PR_NUMBER"
```

---

## `ferrflow check`

Preview what `ferrflow release` would do without making any changes.
Expand Down
41 changes: 41 additions & 0 deletions docs/site/docs-fr/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,47 @@ Avec `releaseCommitMode: "pr"`, le clone reçoit le commit et les tags qui arriv

---

## `ferrflow snapshot`

Donner à chaque package qui a des changements en attente une version de pré-release jetable, pour un build de preview de PR.

```bash
ferrflow snapshot --tag <SUFFIXE> [--from-zero] [--no-git] [--run-hooks]
```

| Option | Description |
| ----------------- | ------------------------------------------------------------------------------------- |
| `--tag <SUFFIXE>` | Suffixe de pré-release, par exemple `pr-123`. Doit être une pré-release semver valide |
| `--from-zero` | Utiliser `0.0.0-<SUFFIXE>.<sha>` au lieu de la prochaine version calculée |
| `--no-git` | Ne pas exiger un working tree propre, pour un checkout déjà modifié par la CI |
| `--run-hooks` | Exécuter les hooks `pre_publish` et `post_publish` avec la version snapshot |

La prochaine version est calculée à partir de tous les commits depuis la dernière release de chaque package, puis sa partie pré-release est remplacée : `1.3.0` devient `1.3.0-pr-123.abc1234`, où `abc1234` est le commit HEAD abrégé. Seuls les fichiers versionnés sont écrits, ainsi que les lockfiles quand `updateLockfiles` est activé. Pas de changelog, de commit, de tag ni de push, et les publishers configurés ne tournent pas, donc rien ne peut déplacer un dist-tag `latest`. Avec `--dry-run`, rien n'est écrit.

La commande affiche un objet JSON sur stdout :

```json
{
"tag": "pr-123",
"commit": "abc1234",
"dry_run": false,
"packages": [
{
"name": "cli",
"version": "1.3.0-pr-123.abc1234",
"previous_version": "1.2.0"
}
]
}
```

```bash
ferrflow snapshot --tag "pr-$PR_NUMBER" > snapshot.json
npm publish --tag "pr-$PR_NUMBER"
```

---

## `ferrflow check`

Prévisualiser ce que `ferrflow release` ferait sans effectuer de changements.
Expand Down
33 changes: 33 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ pub enum Commands {
#[arg(long, help = "Keep the clone and print its path")]
keep: bool,
},
/// Stamp pending packages with a throwaway `<next>-<TAG>.<sha>` version for a PR preview.
/// Writes versioned files only: no changelog, commit, tag or push.
Snapshot {
/// Pre-release suffix, e.g. `pr-123`.
#[arg(long, value_name = "SUFFIX")]
tag: String,
/// Use `0.0.0-<TAG>.<sha>` instead of the computed next version.
#[arg(long)]
from_zero: bool,
/// Skip the clean working tree check.
#[arg(long)]
no_git: bool,
/// Run the pre_publish and post_publish hooks. Configured publishers are not run.
#[arg(long)]
run_hooks: bool,
},
Publish {
packages: Vec<String>,
#[arg(short = 'a', long)]
Expand Down Expand Up @@ -226,6 +242,7 @@ impl Commands {
Commands::Check { .. } => "check",
Commands::Release { .. } => "release",
Commands::ShadowRelease { .. } => "shadow-release",
Commands::Snapshot { .. } => "snapshot",
Commands::Publish { .. } => "publish",
Commands::Changelog => "changelog",
Commands::Init { .. } => "init",
Expand Down Expand Up @@ -317,6 +334,22 @@ impl Cli {
Commands::ShadowRelease { keep } => {
crate::shadow::run(self.config.as_deref(), self.verbose, keep)
}
Commands::Snapshot {
tag,
from_zero,
no_git,
run_hooks,
} => crate::monorepo::snapshot(
self.config.as_deref(),
&crate::monorepo::SnapshotOptions {
tag: &tag,
from_zero,
no_git,
run_hooks,
dry_run: self.dry_run,
verbose: self.verbose,
},
),
Commands::Publish { packages, all } => crate::publish::run(
self.config.as_deref(),
&packages,
Expand Down
10 changes: 6 additions & 4 deletions src/monorepo/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ pub(super) fn plan_json(config_path: Option<&Path>, channel: Option<&str>) -> Re
let repo = open_repo(&std::env::current_dir()?)?;
let root = get_repo_root(&repo)?;
let config = Config::load(&root, config_path)?;
let mut timing = Timing::new(false);
plan_json_at(&root, &config, channel)
}

pub(super) fn plan_json_at(root: &Path, config: &Config, channel: Option<&str>) -> Result<String> {
let out = run_release_logic(
&root,
&config,
root,
config,
true,
false,
true,
Expand All @@ -117,7 +119,7 @@ pub(super) fn plan_json(config_path: Option<&Path>, channel: Option<&str>) -> Re
false,
false,
false,
&mut timing,
&mut Timing::new(false),
)?;

Ok(out.json.unwrap_or_else(|| r#"{"packages":[]}"#.to_string()))
Expand Down
2 changes: 2 additions & 0 deletions src/monorepo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub(crate) mod preview;
mod release;
pub(crate) mod release_output;
pub(crate) mod run;
mod snapshot;
mod types;
mod util;
mod version_source;
Expand All @@ -18,6 +19,7 @@ pub use graph_report::run as graph;
pub use plan_interactive::run as plan_interactive;
pub use release::release;
pub use run::why;
pub use snapshot::{SnapshotOptions, snapshot};

#[cfg(test)]
mod tests;
Loading
Loading