Skip to content

Comments

Add SKIP=true installer mode to preserve existing files#893

Open
justin808 wants to merge 4 commits intomainfrom
codex/issue-889-skip-installer
Open

Add SKIP=true installer mode to preserve existing files#893
justin808 wants to merge 4 commits intomainfrom
codex/issue-889-skip-installer

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Feb 15, 2026

Summary

  • add SKIP=true support to installer file operations in lib/install/template.rb
  • add matching SKIP=true behavior for binstub copying in lib/install/binstubs.rb
  • update install docs to describe FORCE=true vs SKIP=true

Behavior

  • FORCE=true: overwrite conflicting files
  • SKIP=true: keep existing files and only create missing files
  • if both are set, FORCE wins

Closes #889.

Validation

  • Could not run bundle-based checks locally because this environment is Ruby 2.6.10 while this repo requires Ruby >= 2.7.

Summary by CodeRabbit

  • New Features

    • Added SKIP=true installer mode: preserves existing files and only creates missing ones when used. FORCE=true still overwrites.
  • Documentation

    • Updated installation guidance to document three file-handling options: interactive approval, FORCE=true to overwrite, or SKIP=true to preserve files. FORCE takes precedence if both are set.

@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

Walkthrough

Adds a SKIP=true installer mode that causes file operations to skip existing files instead of overwriting; README and CHANGELOG updated. Installer code now selects { force: true }, { skip: true }, or {} based on ENV when invoking Thor file helpers.

Changes

Cohort / File(s) Summary
Documentation
README.md, CHANGELOG.md
Documented new SKIP=true installer mode and precedence rule (FORCE takes precedence if both set).
Installer logic
lib/install/binstubs.rb, lib/install/template.rb
Replaced previous FORCE-only option with a multi-branch condition that yields { force: true } if ENV["FORCE"], { skip: true } if ENV["SKIP"], or {} otherwise; updated file-copy calls to use the new conflict_option variable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through lines of code at night,
SKIP a clash, keep the old one tight,
FORCE can trump when sparks ignite,
Missing pieces set just right,
A little hop, and all is bright. 🥕

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (13 files):

⚔️ CHANGELOG.md (content)
⚔️ README.md (content)
⚔️ docs/precompile_hook.md (content)
⚔️ lib/install/binstubs.rb (content)
⚔️ lib/install/template.rb (content)
⚔️ lib/shakapacker/dev_server_runner.rb (content)
⚔️ lib/shakapacker/runner.rb (content)
⚔️ package/rules/file.ts (content)
⚔️ spec/shakapacker/dev_server_runner_spec.rb (content)
⚔️ spec/shakapacker/rspack_runner_spec.rb (content)
⚔️ spec/shakapacker/runner_build_config_spec.rb (content)
⚔️ spec/shakapacker/webpack_runner_spec.rb (content)
⚔️ test/package/rules/file.test.js (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding SKIP=true mode to preserve existing files during installation, which matches the core objective.
Linked Issues check ✅ Passed The code changes fully implement the requirements from issue #889: SKIP=true support in template.rb and binstubs.rb with proper precedence handling when both FORCE and SKIP are set.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing SKIP=true mode. README updates, code implementations in template.rb and binstubs.rb, and CHANGELOG entry are all in-scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/issue-889-skip-installer
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch codex/issue-889-skip-installer
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 15, 2026

Greptile Summary

Adds SKIP=true environment variable support to the Shakapacker installer, complementing the existing FORCE=true option. When SKIP=true is set, the installer preserves existing files and only creates missing ones — useful for re-running the installer without overwriting customized configs.

  • lib/install/template.rb and lib/install/binstubs.rb both updated with identical if/elsif/else logic that passes { skip: true } to Thor's copy_file and directory methods
  • FORCE takes precedence over SKIP when both are set (via if/elsif ordering)
  • README updated with concise documentation of both options
  • Note: The CHANGELOG.md was not updated for this user-visible feature, which the project's CLAUDE.md guidelines recommend

Confidence Score: 4/5

  • This PR is safe to merge — it adds a well-understood Thor option with minimal code changes and no risk to existing behavior.
  • The changes are small, focused, and use Thor's built-in skip option correctly. The if/elsif structure properly handles precedence. The only concerns are stylistic (variable naming) and a missing CHANGELOG entry.
  • No files require special attention. Both template.rb and binstubs.rb have identical, straightforward changes.

Important Files Changed

Filename Overview
lib/install/template.rb Adds SKIP=true env var support alongside existing FORCE=true for copy_file operations, using Thor's built-in skip option. FORCE takes precedence when both are set. Variable name force_option is now slightly misleading since it can hold a skip option.
lib/install/binstubs.rb Mirrors the same SKIP=true support for the directory binstub copy operation. Logic is identical to template.rb, keeping the two files consistent.
README.md Updates install documentation to describe the new SKIP=true option alongside FORCE=true. Clear and concise wording.

Flowchart

flowchart TD
    A[shakapacker:install] --> B{ENV FORCE set?}
    B -->|Yes| C["force_option = { force: true }"]
    B -->|No| D{ENV SKIP set?}
    D -->|Yes| E["force_option = { skip: true }"]
    D -->|No| F["force_option = {}"]
    C --> G[copy_file / directory]
    E --> G
    F --> G
    G -->|force: true| H[Overwrite existing files]
    G -->|skip: true| I[Keep existing, create missing]
    G -->|empty| J[Prompt user on conflict]
Loading

Last reviewed commit: 9c86f17

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 10 to 16
force_option = if ENV["FORCE"]
{ force: true }
elsif ENV["SKIP"]
{ skip: true }
else
{}
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name is now misleading

The variable force_option can now hold { skip: true }, making the name misleading. Consider renaming to something more general like conflict_option or file_conflict_option to reflect that it handles both force and skip behaviors.

Suggested change
force_option = if ENV["FORCE"]
{ force: true }
elsif ENV["SKIP"]
{ skip: true }
else
{}
end
conflict_option = if ENV["FORCE"]
{ force: true }
elsif ENV["SKIP"]
{ skip: true }
else
{}
end

Note: This would also require updating the three references to force_option on lines 40, 62, and the corresponding variable in lib/install/binstubs.rb (line 10).

Context Used: Context from dashboard - CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

README.md Outdated
```

Before initiating the installation process, ensure you have committed all the changes. While installing Shakapacker, there might be some conflict between the existing file content and what Shakapacker tries to copy. You can either approve all the prompts for overriding these files or use the `FORCE=true` environment variable before the installation command to force the override without any prompt.
Before initiating the installation process, ensure you have committed all the changes. While installing Shakapacker, there might be some conflict between the existing file content and what Shakapacker tries to copy. You can either approve all the prompts for overriding these files, use `FORCE=true` to overwrite without prompting, or use `SKIP=true` to preserve existing files and only create missing ones.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider documenting FORCE+SKIP precedence

The PR description states that FORCE wins when both are set, which is a useful detail for users. Consider adding this to the documentation, e.g.: "If both are set, FORCE=true takes precedence."

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@justin808 justin808 force-pushed the codex/issue-889-skip-installer branch from 9c86f17 to a9509c2 Compare February 15, 2026 22:17
@justin808
Copy link
Member Author

@claude review this PR.

@claude
Copy link

claude bot commented Feb 16, 2026

Claude finished @justin808's task in 1m 44s —— View job


Code Review Complete

I've reviewed PR #893 which adds SKIP=true installer mode to preserve existing files. Here's my analysis:


Overall Assessment

The implementation is clean, focused, and functional. The logic correctly handles the new SKIP=true option alongside the existing FORCE=true behavior. The changes are minimal and follow existing patterns in the codebase.


Critical Issue: Missing CHANGELOG Entry

BLOCKING - According to CLAUDE.md, this PR requires a CHANGELOG.md entry:

Update CHANGELOG.md for user-visible changes only (features, bug fixes, breaking changes, deprecations, performance improvements)

This is a user-visible feature that should be documented. Based on the existing format in CHANGELOG.md, it should be added to the ## [Unreleased] section under ### Added:

Suggested entry:

### Added

- **Added SKIP=true installer option to preserve existing files**. [PR #893](https://github.com/shakacode/shakapacker/pull/893) by [justin808](https://github.com/justin808). When running `bundle exec rake shakapacker:install`, you can now use `SKIP=true` to preserve existing files and only create missing ones, complementing the existing `FORCE=true` option. If both are set, `FORCE` takes precedence.

Fix this →


Code Quality Observations

1. Variable Naming (Minor - Not Blocking)

The variable name force_option is now semantically misleading since it can hold { skip: true }. Greptile's suggestion to rename it to conflict_option or file_conflict_option would improve clarity:

lib/install/template.rb:10-16 and lib/install/binstubs.rb:1-7

# Current (slightly misleading):
force_option = if ENV["FORCE"]
  { force: true }
elsif ENV["SKIP"]
  { skip: true }
else
  {}
end

# Suggested (clearer):
conflict_option = if ENV["FORCE"]
  { force: true }
elsif ENV["SKIP"]
  { skip: true }
else
  {}
end

This would require updating 3 usages in template.rb (lines 40, 62) and 1 usage in binstubs.rb (line 10).

2. Documentation Enhancement (Optional)

The README.md documentation is clear, but could mention the precedence behavior as noted in the PR description:

README.md:169

# Current:
You can either approve all the prompts for overriding these files, use `FORCE=true` to overwrite without prompting, or use `SKIP=true` to preserve existing files and only create missing ones.

# Suggested addition:
You can either approve all the prompts for overriding these files, use `FORCE=true` to overwrite without prompting, or use `SKIP=true` to preserve existing files and only create missing ones. If both are set, `FORCE=true` takes precedence.

Positive Observations

Correct precedence logic - FORCE takes priority over SKIP via if/elsif ordering
Consistent implementation - Same logic in both template.rb and binstubs.rb
Proper trailing newlines - All files comply with linting requirements
Uses Thor's built-in options - Leverages { skip: true } correctly
Minimal changes - Focused scope with no extraneous modifications
Clear documentation - README accurately describes the new option


Testing Recommendations

Since the PR notes that bundle-based checks couldn't be run locally due to Ruby version constraints, consider testing:

  1. SKIP=true bundle exec rake shakapacker:install - verify existing files are preserved
  2. FORCE=true bundle exec rake shakapacker:install - verify existing behavior still works
  3. SKIP=true FORCE=true bundle exec rake shakapacker:install - verify FORCE wins
  4. Fresh install with neither flag - verify prompts still appear

Summary

Recommendation: Request CHANGELOG.md update before merging. The code implementation itself is solid and ready.

Required:

  • Add CHANGELOG.md entry (see suggested text above)

Optional improvements:

  • Rename force_optionconflict_option for clarity
  • Document FORCE/SKIP precedence in README

| Branch: codex/issue-889-skip-installer

justin808 and others added 2 commits February 15, 2026 22:15
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Renames the variable to better reflect its purpose now that it handles
both FORCE and SKIP modes. Adds a note that FORCE takes precedence
when both are set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@lib/install/template.rb`:
- Around line 10-16: The code currently treats any set ENV["SKIP"] or
ENV["FORCE"] as truthy (so "false" or "0" still activates), so update the
conflict_option logic to test for explicit truthy strings (e.g. check
ENV["SKIP"] && %w[true 1 yes].include?(ENV["SKIP"].to_s.downcase)) and do the
same for ENV["FORCE"] (or extract a small helper like truthy_env?(name)) so only
intended values like "true"/"1"/"yes" enable skip/force in the conflict_option
branch.
🧹 Nitpick comments (1)
lib/install/binstubs.rb (1)

1-7: Duplicated conflict_option logic with template.rb.

This block is identical to lines 10–16 in template.rb. Consider extracting it into a shared helper (e.g., in lib/install/shared.rb or a small utility module) to keep the two files in sync. Not urgent since the block is small, but it would prevent future divergence.

Comment on lines +10 to +16
conflict_option = if ENV["FORCE"]
{ force: true }
elsif ENV["SKIP"]
{ skip: true }
else
{}
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

ENV["SKIP"] is truthy for any value, including "false" or "0".

ENV["SKIP"] returns a non-nil string for any set value, so SKIP=false bundle exec rake shakapacker:install would still activate skip mode. Consider checking for explicit truthy values to match the documented SKIP=true usage. The same applies to ENV["FORCE"], though that's pre-existing behavior.

Proposed fix
-conflict_option = if ENV["FORCE"]
+conflict_option = if ENV["FORCE"] == "true"
   { force: true }
-elsif ENV["SKIP"]
+elsif ENV["SKIP"] == "true"
   { skip: true }
 else
   {}
 end
🤖 Prompt for AI Agents
In `@lib/install/template.rb` around lines 10 - 16, The code currently treats any
set ENV["SKIP"] or ENV["FORCE"] as truthy (so "false" or "0" still activates),
so update the conflict_option logic to test for explicit truthy strings (e.g.
check ENV["SKIP"] && %w[true 1 yes].include?(ENV["SKIP"].to_s.downcase)) and do
the same for ENV["FORCE"] (or extract a small helper like truthy_env?(name)) so
only intended values like "true"/"1"/"yes" enable skip/force in the
conflict_option branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SKIP env var to installer for preserving existing config files

1 participant