Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions crates/aube/src/commands/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub async fn run(args: CiArgs) -> miette::Result<()> {
pnpmfile: None,
global_pnpmfile: None,
ignore_scripts,
dry_run: false,
lockfile_only: false,
merge_git_branch_lockfiles: false,
dangerously_allow_all_builds: false,
Expand Down
1 change: 1 addition & 0 deletions crates/aube/src/commands/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ pub async fn run(
pnpmfile: None,
global_pnpmfile: None,
ignore_scripts: false,
dry_run: false,
lockfile_only: false,
merge_git_branch_lockfiles: false,
dangerously_allow_all_builds: false,
Expand Down
10 changes: 10 additions & 0 deletions crates/aube/src/commands/install/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pub struct InstallArgs {
/// Bypasses the `allowBuilds` allowlist. Do not use in CI.
#[arg(long)]
pub dangerously_allow_all_builds: bool,
/// Resolve and report what would happen without writing the lockfile
/// or linking node_modules.
#[arg(long, conflicts_with = "lockfile_only")]
pub dry_run: bool,
/// Re-resolve lockfile entries whose spec drifted from package.json.
///
/// Leaves everything else pinned at its locked version. Unchanged
Expand Down Expand Up @@ -272,6 +276,7 @@ impl InstallArgs {
pnpmfile: self.pnpmfile,
global_pnpmfile: self.global_pnpmfile,
ignore_scripts: self.ignore_scripts,
dry_run: self.dry_run,
lockfile_only: self.lockfile_only,
merge_git_branch_lockfiles: self.merge_git_branch_lockfiles,
dangerously_allow_all_builds: self.dangerously_allow_all_builds,
Expand Down Expand Up @@ -328,6 +333,10 @@ pub struct InstallOptions {
/// `install`, `postinstall`, `prepare`) *and* every dependency's
/// lifecycle scripts, regardless of `allowBuilds`.
pub ignore_scripts: bool,
/// `--dry-run`: resolve dependencies and report the planned lockfile
/// shape without writing lockfiles, node_modules, install state, or
/// lifecycle outputs.
pub dry_run: bool,
/// `--lockfile-only`: resolve and write the lockfile, but skip
/// linking `node_modules` and running lifecycle scripts. Useful
/// for CI workflows that only need to refresh the lockfile.
Expand Down Expand Up @@ -439,6 +448,7 @@ impl InstallOptions {
pnpmfile: None,
global_pnpmfile: None,
ignore_scripts: false,
dry_run: false,
lockfile_only: false,
merge_git_branch_lockfiles: false,
dangerously_allow_all_builds: false,
Expand Down
89 changes: 66 additions & 23 deletions crates/aube/src/commands/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ pub async fn run(opts: InstallOptions) -> miette::Result<()> {
aube_util::diag::instant(aube_util::diag::Category::Install, "begin", None);
let _diag_install = aube_util::diag::Span::new(aube_util::diag::Category::Install, "total");

apply_force_state_reset(&cwd, &opts)?;
if try_install_fast_path(&cwd, &opts, mode, modules_cache_sweep_is_default(&cwd)) {
if !opts.dry_run {
apply_force_state_reset(&cwd, &opts)?;
}
if !opts.dry_run
&& try_install_fast_path(&cwd, &opts, mode, modules_cache_sweep_is_default(&cwd))
{
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return Ok(());
}

Expand Down Expand Up @@ -210,13 +214,15 @@ pub async fn run(opts: InstallOptions) -> miette::Result<()> {
if opts.network_mode == aube_registry::NetworkMode::Offline {
runtime_settings.network = aube_runtime::NetworkMode::Offline;
}
crate::runtime::ensure(
&cwd,
Some(&manifest),
runtime_settings,
crate::runtime::lockfile_node_pin(&cwd, &manifest).as_ref(),
)
.await?;
if !opts.dry_run {
crate::runtime::ensure(
&cwd,
Some(&manifest),
runtime_settings,
crate::runtime::lockfile_node_pin(&cwd, &manifest).as_ref(),
)
.await?;
}
super::configure_script_settings(&settings_ctx, Some("install"));

let layout::InstallLayoutConfig {
Expand All @@ -236,13 +242,15 @@ pub async fn run(opts: InstallOptions) -> miette::Result<()> {
opts.strict_no_lockfile,
)?;

merge_branch_lockfiles_if_needed(
&cwd,
&manifest,
&settings_ctx,
lockfile_enabled,
opts.merge_git_branch_lockfiles,
)?;
if !opts.dry_run {
merge_branch_lockfiles_if_needed(
&cwd,
&manifest,
&settings_ctx,
lockfile_enabled,
opts.merge_git_branch_lockfiles,
)?;
}

// Resolve the install-wide networking / integrity knobs once up
// front so every downstream fetch site (the lockfile path, the
Expand Down Expand Up @@ -335,7 +343,11 @@ pub async fn run(opts: InstallOptions) -> miette::Result<()> {
// that will be linked, matching pnpm's recursive install
// behavior. Runs before the progress UI starts so script output
// cannot collide with the progress display.
if !opts.ignore_scripts && !lockfile_only_effective && !opts.skip_root_lifecycle {
if !opts.dry_run
&& !opts.ignore_scripts
&& !lockfile_only_effective
&& !opts.skip_root_lifecycle
{
let phase_start = std::time::Instant::now();
for (importer_path, importer_manifest) in &lifecycle_manifests {
let project_dir = importer_project_dir(&cwd, importer_path);
Expand Down Expand Up @@ -421,14 +433,44 @@ pub async fn run(opts: InstallOptions) -> miette::Result<()> {

// `--lockfile-only` short-circuit. Resolves (or reuses a fresh
// lockfile), writes the new lockfile, and exits before any tarball
// fetch / link / lifecycle work. Runs *before* the FrozenMode
// match so it bypasses drift hard-errors entirely — pnpm's
// `--lockfile-only` regenerates regardless of frozen mode, and
// we'd otherwise be preempted by the auto-CI Frozen default.
// fetch / link / lifecycle work. Runs *before* the FrozenMode match
// so lockfile-only bypasses drift hard-errors entirely — pnpm's
// `--lockfile-only` regenerates regardless of frozen mode, and we'd
// otherwise be preempted by the auto-CI Frozen default.
// `enableModulesDir=false` follows the same short-circuit so
// projects that persistently disable node_modules materialization
// share the exact same control flow.
if lockfile_only_effective {
// share the exact same control flow. `--dry-run` reuses the resolve
// and report path without writing the lockfile; unlike
// `--lockfile-only`, explicit frozen mode still validates drift.
if lockfile_only_effective || opts.dry_run {
if opts.dry_run && matches!(mode, FrozenMode::Frozen) {
match resolve::select_lockfile_result(resolve::SelectLockfileInput {
lockfile_enabled,
mode,
cwd: &cwd,
lockfile_dir: &lockfile_dir,
lockfile_importer_key: &lockfile_importer_key,
manifest: &manifest,
manifests: &manifests,
ws_config: &ws_config_shared,
workspace_catalogs: &workspace_catalogs,
is_workspace_project,
lockfile_pre_parse: lockfile_pre_parse.as_ref(),
})? {
Ok(_) => {}
Err(aube_lockfile::Error::NotFound(_)) => {
return Err(miette!(
"no lockfile found and --frozen-lockfile is set\n\
help: commit pnpm-lock.yaml to your repository, or run \
`{} --no-frozen-lockfile` to generate one",
aube_util::cmd("install")
));
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}
Err(e) => {
return Err(miette::Report::new(e)).wrap_err("failed to parse lockfile");
}
}
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
resolve::run_lockfile_only(resolve::LockfileOnlyInput {
cwd: &cwd,
mode,
Expand Down Expand Up @@ -456,6 +498,7 @@ pub async fn run(opts: InstallOptions) -> miette::Result<()> {
minimum_release_age_override: opts.minimum_release_age_override,
ws_package_versions: &ws_package_versions,
ignore_scripts: opts.ignore_scripts,
write_lockfile: !opts.dry_run,
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
prog_ref,
})
.await?;
Expand Down
12 changes: 12 additions & 0 deletions crates/aube/src/commands/install/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub(super) struct LockfileOnlyInput<'a> {
pub minimum_release_age_override: Option<u64>,
pub ws_package_versions: &'a HashMap<String, String>,
pub ignore_scripts: bool,
pub write_lockfile: bool,
pub prog_ref: Option<&'a InstallProgress>,
}

Expand Down Expand Up @@ -93,6 +94,7 @@ pub(super) async fn run_lockfile_only(input: LockfileOnlyInput<'_>) -> miette::R
minimum_release_age_override,
ws_package_versions,
ignore_scripts,
write_lockfile,
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
prog_ref,
} = input;

Expand Down Expand Up @@ -292,6 +294,16 @@ pub(super) async fn run_lockfile_only(input: LockfileOnlyInput<'_>) -> miette::R
// (`optional: true`, `transitivePeerDependencies`) so `--lockfile-only`
// output stays byte-identical to a regular install.
crate::commands::prepare_resolved_graph_for_lockfile_write(&mut graph);
if !write_lockfile {
if let Some(p) = prog_ref {
p.finish(true);
}
eprintln!(
"Dry run: resolved {} package(s); lockfile and node_modules were not modified",
graph.packages.len()
);
return Ok(());
}
if shared_workspace_lockfile || !has_workspace {
let lo_written = write_lockfile_dir_remapped(
lockfile_dir,
Expand Down
18 changes: 18 additions & 0 deletions test/install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,24 @@ JSON
assert [ ! -e node_modules ]
}

@test "aube install --dry-run resolves without writing lockfile or node_modules" {
echo '{"name":"test","version":"1.0.0","dependencies":{"is-odd":"^3.0.1"}}' >package.json
run aube install --dry-run
assert_success
assert_output --partial "Dry run: resolved"
assert [ ! -e aube-lock.yaml ]
assert [ ! -e node_modules ]
}

@test "aube install --dry-run --frozen-lockfile fails without lockfile" {
echo '{"name":"test","version":"1.0.0","dependencies":{"is-odd":"^3.0.1"}}' >package.json
run aube install --dry-run --frozen-lockfile
assert_failure
assert_output --partial "no lockfile found and --frozen-lockfile is set"
assert [ ! -e aube-lock.yaml ]
assert [ ! -e node_modules ]
}

@test "aube install --lockfile-only is a no-op when lockfile is fresh" {
_setup_basic_fixture
# Lockfile already exists in fixture; --lockfile-only should detect
Expand Down
22 changes: 22 additions & 0 deletions test/lockfile_settings.bats
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ teardown() {
assert_output --partial 'incompatible with lockfile=false'
}

@test "lockfile=false + --dry-run resolves without lockfile-only conflict" {
cat >package.json <<-'EOF'
{
"name": "test-dry-run-no-lockfile",
"version": "1.0.0",
"dependencies": { "is-odd": "3.0.1" }
}
EOF
cat >>.npmrc <<-'EOF'

lockfile=false
EOF
run aube install --dry-run
assert_success
assert_output --partial "Dry run: resolved"
refute_output --partial "--lockfile-only is incompatible with lockfile=false"
run test -e aube-lock.yaml
assert_failure
run test -e node_modules
assert_failure
}

# `--frozen-lockfile` ("fail hard if the lockfile doesn't match") makes
# no sense without a lockfile. Without this check the install falls
# through to the catch-all Err(NotFound) arm and errors with the
Expand Down
Loading