Proposal: pin `getProjectName` precedence behavior with tests
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- docker-compose, typescript
Direzione di ricerca
Inizia da getProjectName in src/spec-node/dockerCompose.ts, poi leggi i blocchi describe esistenti di compose-with-name in cli.up.test.ts e la relativa copertura in dockerComposeUtils.test.ts. Esegui prima i test di integrazione pertinenti. Il lavoro è completo quando i test diretti coprono COMPOSE_PROJECT_NAME, la ricerca di .env, il fallback al semplice nome di base e la sanitizzazione dei caratteri di toProjectName senza modificare la precedenza stabilita.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi — I've been reading getProjectName in src/spec-node/dockerCompose.ts carefully while contributing to the Zed editor's dev container support (zed-industries/zed), which recently switched from shelling out to @devcontainers/cli to a native Rust implementation. (I'm an outside contributor doing small things there; the Zed team does the heavy lifting.)
The port mirrors this function's precedence ladder quite closely: COMPOSE_PROJECT_NAME env → workspace .env file → explicit top-level name: on the merged compose config → ${workspaceFolderBasename}_devcontainer when the first compose file's directory is <workspace>/.devcontainer → otherwise plain basename of that directory, all passed through toProjectName's lowercase-and-strip-[^-_a-z0-9] sanitization — because divergence produces duplicate compose projects for the same folder when both tools touch it. The fix for this just landed in Zed PR #54302 (tracking issue #54255).
The precedence is crisp in the code but mostly implied, rather than asserted by tests. The existing integration coverage in cli.up.test.ts pins three of the five rungs: explicit name: in a fragment, name: with ${env} substitution (including the CUSTOM_NAME=devcontainer edge case that forces the raw-fragment rescan), and the _devcontainer suffix when the compose file sits under .devcontainer/. The remaining rungs — COMPOSE_PROJECT_NAME from the environment, the .env file lookup, and the "plain basename, no suffix" fallback for compose files outside .devcontainer/ — don't appear to have direct tests. Same fortoProjectName's character class as a contract.
One related observation: the spec on containers.dev is silent on compose project-name derivation — the Docker Compose section covers dockerComposeFile, service, and runServices, but nothing about how the project name is chosen, COMPOSE_PROJECT_NAME, or multi-tool interop around it. So getProjectName in this repo is the de facto contract that any other implementation has to match if the two are ever going to coexist on the same folder. That makes pinning it with tests a little more load-bearing than it might look from inside the CLI's own use.
The question: would you be open, in principle, to pinning this behavior with tests? I'd be happy to contribute them. Either:
-
Unit tests alongside
dockerComposeUtils.test.ts— possibly needs a small
refactor to pull the env/.env/config-name reasoning out of the
cliHost-dependent shell ofgetProjectName, or -
Integration tests with new fixtures for the three missing rungs, matching
the style of the existingcompose-with-name*describe blocks in
cli.up.test.ts.
Or both, or a different shape — I'd rather ask than cold-drop a PR with the wrong approach. The motivation is durability: a CI-enforced invariant here is a nicer long-term mitigation than a doc comment in the Rust port saying "mirrors the reference CLI as of commit X".
No rush, and no problem if the answer is "not a priority / won't review" — in that case I'll close this and I figure Zed can keep on mirroring.
- Lingua principale
- TypeScript
- Stelle
- 3k
- Fork
- 461
- Merge medio
- 18m
- PR unite (30g)
- 5
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di devcontainers/cli
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
devcontainers/cli#1203 ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
devcontainers/cli#1178 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
devcontainers/cli#1308 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
devcontainers/cli#1307 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
devcontainers/cli#1305 ·
Tutte le issue di devcontainers/cli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modelcontextprotocol/inspector#2458 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
carbon-design-system/ibm-products#9907 ·