-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: check registry for guidepup sub key * feat: handle listing, creation, and update of reg key * fix: downgrade `regedit` REF: kessler/node-regedit#110 * ci: add resolution fix for ci * fix: only perform resolution fix for macos * feat: add portable nvda zip * feat: add nvda download * feat: unzip portable nvda * feat: use `decompress` package * chore: disable macos-12
- Loading branch information
Showing
16 changed files
with
528 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { execSync } from "child_process"; | ||
|
||
if (process.platform === "darwin") { | ||
try { | ||
execSync( | ||
`"/Library/Application Support/VMware Tools/vmware-resolutionSet" 1920 1080` | ||
); | ||
} catch (_) { | ||
// swallow | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,13 @@ If you are using GitHub Actions, check out the dedicated [`guidepup/setup-action | |
uses: guidepup/[email protected] | ||
``` | ||
## Debugging | ||
## Recording | ||
If you are encountering errors in CI you can pass a `--record` flag to the command which will output a screen-recording of the setup to a `./recordings/` directory. | ||
If you are encountering errors in CI for MacOS you can pass a `--record` flag to the command which will output a screen-recording of the setup to a `./recordings/` directory. | ||
|
||
## NVDA Installation | ||
|
||
When running on windows a portable NVDA instance compatible with Guidepup will be installed to a temporary directory. The location of this installation directory is stored in the Windows registry under the key `HKCU\Software\Guidepup\Nvda`. | ||
|
||
## See Also 🐶 | ||
|
||
|
@@ -53,7 +57,7 @@ Check out some of the other Guidepup modules: | |
Support: | ||
|
||
- [x] VoiceOver on MacOS | ||
- [ ] NVDA on Windows | ||
- [x] NVDA on Windows | ||
- [ ] VoiceOver on iOS | ||
- [ ] Talkback on Android | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/env node | ||
require("../lib/"); | ||
require("../lib"); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { version } = require("../../package.json"); | ||
|
||
export const VERSIONED_KEY = `guidepup_nvda_${version}`; | ||
export const SUB_KEY_GUIDEPUP_NVDA = "HKCU\\Software\\Guidepup\\Nvda"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { promisified as regedit } from "regedit"; | ||
import { SUB_KEY_GUIDEPUP_NVDA } from "./constants"; | ||
import { ERR_WINDOWS_UNABLE_TO_UPDATE_REGISTRY } from "../errors"; | ||
|
||
export async function createNvdaRegistryKey() { | ||
try { | ||
await regedit.createKey([SUB_KEY_GUIDEPUP_NVDA]); | ||
} catch { | ||
throw new Error(ERR_WINDOWS_UNABLE_TO_UPDATE_REGISTRY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { promisified as regedit } from "regedit"; | ||
import { SUB_KEY_GUIDEPUP_NVDA } from "./constants"; | ||
import { ERR_WINDOWS_UNABLE_TO_ACCESS_REGISTRY } from "../errors"; | ||
|
||
export async function getNvdaRegistryData() { | ||
try { | ||
const { | ||
[SUB_KEY_GUIDEPUP_NVDA]: { exists, values }, | ||
} = await regedit.list([SUB_KEY_GUIDEPUP_NVDA]); | ||
|
||
return { exists, values }; | ||
} catch { | ||
throw new Error(ERR_WINDOWS_UNABLE_TO_ACCESS_REGISTRY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import decompress from "decompress"; | ||
import { get } from "https"; | ||
import { createWriteStream, mkdtempSync, rmSync } from "fs"; | ||
import { join } from "path"; | ||
import { tmpdir } from "os"; | ||
import { ERR_WINDOWS_FAILED_TO_INSTALL_NVDA } from "../errors"; | ||
|
||
const appName = "guidepup_nvda"; | ||
const sourceUrl = `https://raw.githubusercontent.com/guidepup/setup/feat/add-nvda-setup/downloads/${appName}.zip`; | ||
|
||
export async function installNvda(): Promise<string> { | ||
const destinationBaseDirectory = mkdtempSync(join(tmpdir(), `${appName}_`)); | ||
const destinationDirectory = join(destinationBaseDirectory, appName); | ||
const destinationZip = join(destinationBaseDirectory, `${appName}.zip`); | ||
const fileZip = createWriteStream(destinationZip); | ||
|
||
function removeAll() { | ||
try { | ||
rmSync(destinationBaseDirectory, { recursive: true }); | ||
} catch { | ||
// swallow | ||
} | ||
} | ||
|
||
function removeZip() { | ||
try { | ||
rmSync(destinationZip, { recursive: true }); | ||
} catch { | ||
// swallow | ||
} | ||
} | ||
|
||
try { | ||
await new Promise<void>((resolve, reject) => { | ||
function onSuccess() { | ||
fileZip.close((error) => { | ||
if (error) { | ||
return reject(error); | ||
} | ||
|
||
resolve(); | ||
}); | ||
} | ||
|
||
const request = get(sourceUrl, (response) => response.pipe(fileZip)); | ||
request.on("error", reject); | ||
fileZip.on("finish", onSuccess); | ||
fileZip.on("error", reject); | ||
}); | ||
|
||
await decompress(destinationZip, destinationBaseDirectory); | ||
|
||
removeZip(); | ||
} catch { | ||
removeAll(); | ||
|
||
throw new Error(ERR_WINDOWS_FAILED_TO_INSTALL_NVDA); | ||
} | ||
|
||
return destinationDirectory; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { existsSync } from "fs"; | ||
import { VERSIONED_KEY } from "./constants"; | ||
|
||
export function isNvdaInstalled({ exists, values }) { | ||
if (!exists) { | ||
return false; | ||
} | ||
|
||
const path = values[VERSIONED_KEY]?.value; | ||
|
||
if (!path) { | ||
return false; | ||
} | ||
|
||
return existsSync(path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { getNvdaRegistryData } from "./getNvdaRegistryData"; | ||
import { isNvdaInstalled } from "./isNvdaInstalled"; | ||
import { createNvdaRegistryKey } from "./createNvdaRegistryKey"; | ||
import { installNvda } from "./installNvda"; | ||
import { updateNvdaRegistryData } from "./updateNvdaRegistryData"; | ||
|
||
export async function setup(): Promise<void> { | ||
const { exists, values } = await getNvdaRegistryData(); | ||
|
||
if (isNvdaInstalled({ exists, values })) { | ||
return; | ||
} | ||
|
||
if (!exists) { | ||
await createNvdaRegistryKey(); | ||
} | ||
|
||
const nvdaDirectory = await installNvda(); | ||
|
||
await updateNvdaRegistryData({ nvdaDirectory }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { promisified as regedit } from "regedit"; | ||
import { SUB_KEY_GUIDEPUP_NVDA, VERSIONED_KEY } from "./constants"; | ||
import { ERR_WINDOWS_UNABLE_TO_UPDATE_REGISTRY } from "../errors"; | ||
|
||
export async function updateNvdaRegistryData({ nvdaDirectory }) { | ||
try { | ||
await regedit.putValue({ | ||
[SUB_KEY_GUIDEPUP_NVDA]: { | ||
[VERSIONED_KEY]: { | ||
value: nvdaDirectory, | ||
type: "REG_SZ", | ||
}, | ||
}, | ||
}); | ||
} catch { | ||
throw new Error(ERR_WINDOWS_UNABLE_TO_UPDATE_REGISTRY); | ||
} | ||
} |
Oops, something went wrong.