Lines 1-62javascript
3 * dsh-win32 CLI: `doctor` diagnoses the known DSH-on-Windows traps.
4 * Current `setup` verifies the official Windows stack and creates a shortcut.
5 * `setup --legacy` installs the old custom presets. Zero dependencies.
8import { execFileSync } from 'node:child_process'
9import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
10import { homedir } from 'node:os'
11import { dirname, join, resolve } from 'node:path'
12import { fileURLToPath } from 'node:url'
13import process from 'node:process'
14import { offerSetupStar, runSetupStarConfirmation } from './setup-consent.mjs'
15// Shared with the runtime so the two never drift; lib/ always ships with bin/.
16import { findGitBash, installPreset, busyboxPath } from '../lib/preset-install.js'
17import { verifyInstalledStack } from '../lib/verify.js'
19const WIN = process.platform === 'win32'
20const DSH_HOME = process.env.DSH_HOME ?? join(homedir(), '.dsh')
21const PRESET_ID = 'minimal-windows'
22const PRESET_SRC = join(dirname(fileURLToPath(import.meta.url)), '..', 'preset', PRESET_ID)
23const REPO = 'https://github.com/sjh9714/dsh-win32'
24const SELF_VERSION = JSON.parse(
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
bin/cli.mjsView on unpkg · L7 25 readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8'),
28const ok = message => console.log(` ok ${message}`)
29const warn = message => console.log(` WARN ${message}`)
30const bad = message => console.log(` FAIL ${message}`)
31const info = message => console.log(` tip ${message}`)
33function tryExec(file, args) {
35 return execFileSync(file, args, { encoding: 'utf8', windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] })
42 if (process.env.ProgramFiles !== undefined) {
43 const candidate = join(process.env.ProgramFiles, 'PowerShell', '7', 'pwsh.exe')
44 if (existsSync(candidate)) return candidate
46 const located = tryExec('where.exe', ['pwsh'])
47 const first = (located ?? '').split(/\r?\n/)[0]?.trim()
48 return first !== undefined && first !== '' ? first : undefined
52 * pnpm backs the profile-directory install: `dsh plugin add` forwards to it,
53 * so a box without pnpm fails the bundle wiring with a bare
54 * "'pnpm' is not recognized" and no hint about what is actually missing (#13).
57 const located = tryExec(WIN ? 'where.exe' : 'which', ['pnpm'])
58 const first = (located ?? '').split(/\r?\n/)[0]?.trim()
59 return first !== undefined && first !== '' ? first : undefined
62const OFFICIAL_WINDOWS_DEPS = [