Skip to content

refactor: extract gitignore helpers out of scaffold.ts #882

@amrmelsayed

Description

@amrmelsayed

Context

packages/codev/src/lib/scaffold.ts was originally extracted in Maintenance Run 0004 to deduplicate logic shared between codev init and codev adopt — its header still says "Scaffold utilities for codev init and adopt commands". Since then it has drifted:

"Scaffold" implies creating new project structure, but the file now also handles in-place repair of existing projects. The name no longer matches the contents.

Proposed change

Extract gitignore-related helpers into a new file:

packages/codev/src/lib/gitignore.ts

Moves:

  • CODEV_GITIGNORE_ENTRIES constant
  • FULL_GITIGNORE_CONTENT constant
  • createGitignore() (used by init)
  • updateGitignore() (used by adopt)
  • backfillGitignore() (used by update)
  • The internal parseEntryLines() helper
  • The BackfillGitignoreResult / BackfillGitignoreOptions / UpdateGitignoreResult types

scaffold.ts keeps only the genuine scaffolding helpers — createUserDirs, copyConsultTypes, copyResourceTemplates, copyRootFiles, copyRoles, copyProtocols, copySkills, createProjectsDir, copyDirRecursive.

Acceptance criteria

  • New file packages/codev/src/lib/gitignore.ts contains all gitignore-related exports listed above
  • scaffold.ts no longer references gitignore behavior
  • Import sites updated (init.ts, adopt.ts, update.ts, the test files)
  • Existing test coverage moved to a new gitignore.test.ts (or split out of scaffold.test.ts) — no test deleted or weakened, only relocated
  • tsc clean, full test suite green

Out of scope

  • No behavior change. This is a pure file move + import update.
  • No renaming of the functions themselves.
  • Not pruning scaffold.ts further (e.g. moving copyRoles to a roles.ts file). One refactor at a time.

Discovered while

Reviewing PR #881 (issue #880). The file's name vs. its current contents came up during post-merge discussion.

Metadata

Metadata

Assignees

Labels

area/coreArea: shared core library / forge abstraction (packages/core, packages/codev/src/lib)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions