Skip to content

Latest commit

 

History

History
59 lines (37 loc) · 2.03 KB

File metadata and controls

59 lines (37 loc) · 2.03 KB

Shared Feature Code

This directory contains code that is shared across multiple features.

Structure

scripts/
├── lib/
│   └── common-setup.sh         # Source of truth for user selection helper
└── sync-common-setup.sh         # Script to deploy helper to all features

Maintenance

The Source of Truth

scripts/lib/common-setup.sh is the single source of truth for the user selection helper function. All modifications should be made to this file.

Deploying Changes

Due to the devcontainer CLI's packaging behavior (each feature is packaged independently), the helper must be present in each feature's directory at packaging time. This is handled automatically by CI — all workflows run scripts/sync-common-setup.sh after checkout and before packaging.

The copies are .gitignored — only the source file is tracked in git.

Workflow

  1. Edit: Make changes to scripts/lib/common-setup.sh
  2. Test: Run bash test/_global/test-common-setup.sh to verify
  3. Commit: Only the source file needs to be committed

Why Copies?

The devcontainer CLI packages each feature independently:

  • Parent directories are not included in the build context
  • Hidden directories (.common) are not included
  • Sibling directories are not accessible

Therefore, each feature needs its own copy of the helper to ensure it's available at runtime during feature installation.

Testing

Tests are located in test/_global/ and source from the canonical scripts/lib/common-setup.sh:

bash test/_global/test-common-setup.sh

Local Development

To generate the copies locally (e.g., for testing features outside CI):

./scripts/sync-common-setup.sh

Future

This approach is a workaround for the current limitation. The devcontainer spec has a proposal for an include property in devcontainer-feature.json that would allow native code sharing (see devcontainers/spec#129). Once implemented, this sync mechanism can be removed.