Workspace prompt rejects existing folders entered with ~, quotes or escaped spaces
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
- Ambito
- cli
Direzione di ricerca
Inizia con validateWorkspace() e saveWorkspace() in lib/cli.js; al momento entrambi rimuovono gli spazi iniziali e finali dal valore del prompt e lo risolvono come percorso. Segui come viene usata nei test l’iniezione della piattaforma esistente, poi aggiungi test per la tilde, i percorsi tra virgolette, gli spazi con escape e i messaggi di errore. Il lavoro è completo quando gli input validi di cartelle esistenti funzionano in entrambi i prompt e la configurazione memorizza il percorso assoluto semplice.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The README's Quick start says:
On the first launch, enter the folder that contains your projects, for example:
~/projects/
Entering ~/projects at that prompt is rejected, even when the folder exists:
That directory does not exist or is not accessible.
The prompt only trims the input and passes it to path.resolve(). Nothing expands ~, because the shell never sees text typed into a prompt, so ~/projects resolves to <current directory>/~/projects. For the same reason, two other common forms of an existing path are rejected:
- quoted paths (
"…"or'…'). Windows Explorer's Copy as path always adds double quotes, and many terminals quote a dragged folder whose path contains spaces; - escaped spaces (
my\ projects), which some terminals produce when a folder is dragged in.
This applies to the first-run prompt and to Change workspace. dws --workspace ~/projects works because the shell expands the path before the CLI receives it.
Steps to reproduce
-
Create two workspaces, one matching the README example and one with a space in its name:
mkdir -p ~/projects/storefront ~/"my projects"/app echo '{"scripts":{"dev":"echo dev"}}' > ~/projects/storefront/package.json echo '{"scripts":{"hello":"echo hello"}}' > ~/"my projects"/app/package.json -
Start the published CLI with an empty configuration file, which triggers the first-run prompt:
DEV_WORKSPACE_CONFIG=/tmp/dws-first-run.json \ npx -p @modulane/[email protected] dws -
At Workspace path, enter each of these values, replacing
/home/youwith your home directory:~/projects ~/my projects "/home/you/my projects" '/home/you/my projects' /home/you/my\ projects
Actual behaviour
Every value is rejected:
? Workspace path ~/projects
> That directory does not exist or is not accessible.
Only the bare absolute path (/home/you/my projects) is accepted. Choosing Change workspace from the project list and entering ~/projects gives the same error.
Expected behaviour
Each input resolves to the existing folder, and the configuration stores the plain absolute path.
When a path really doesn't exist, the error names the path that was checked, for example No directory at /current/dir/~/projects, so the cause is obvious.
Where
validateWorkspace()andsaveWorkspace()call onlytrim()andpath.resolve().
Suggested fix
Add a single helper that resolves the prompt input, used by both functions:
- Trim the input. If the path exists as typed, use it unchanged, so a folder whose real name contains quotes or backslashes keeps working.
- Otherwise, try a normalised form:
- remove one pair of matching surrounding quotes;
- expand a leading
~(alone, or followed by/, or by\on Windows) withos.homedir(); - on non-Windows platforms only, turn
\into a space. On Windows,\is the path separator.
- Use the error message above when neither form exists.
Each case can be unit-tested, including Windows-style input through the existing platform injection pattern.
This also helps the planned first-run experience in ROADMAP.md, which suggests ~/dev and ~/projects and keeps "Enter another path" as an option.
I'm happy to open a PR for this.
Environment
@modulane/dev-workspace-cli0.5.0 from npm.lib/is identical onmainat dfccb6b.- Node.js 22.22.2, Linux x64. Windows and macOS were not tested; the code path is the same on every platform.
- Lingua principale
- JavaScript
- Stelle
- 0
- Fork
- 0
- Merge medio
- 7m
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 modulane/dev-workspace-cli
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
-
Proposal: harden the release workflowForse già presa @GregoireF l’ha presa oggi. Apertaenhancement good first issue
modulane/dev-workspace-cli#7 · 1 commento · 2 assegnatari ·
Tutte le issue di modulane/dev-workspace-cli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
flarum/framework#5301 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
AOSSIE-Org/BabyNest#284 ·
I maintainer di solito rispondono entro 1 giorno
-
status:untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
midnightntwrk/servicedesk#275 ·
I maintainer di solito rispondono entro 1 giorno