-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update shell config system (#294)
* feat: update shell config system Signed-off-by: Chapman Pendery <[email protected]> * fix: use js postinstall hook Signed-off-by: Chapman Pendery <[email protected]> * fix: add header Signed-off-by: Chapman Pendery <[email protected]> --------- Signed-off-by: Chapman Pendery <[email protected]>
- Loading branch information
Showing
10 changed files
with
195 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,9 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import fs from "node:fs"; | ||
|
||
if (fs.existsSync("./build/commands/init.js")) { | ||
const init = (await import("../build/commands/init.js")).default; | ||
init.parse(["--generate-full-configs"], { from: "user" }); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { Command } from "commander"; | ||
import { render } from "../ui/ui-doctor.js"; | ||
|
||
const action = async () => { | ||
await render(); | ||
}; | ||
|
||
const cmd = new Command("doctor"); | ||
cmd.description(`checks the health of this inshellisense installation`); | ||
cmd.action(action); | ||
|
||
export default cmd; |
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,46 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import chalk from "chalk"; | ||
import { checkLegacyConfigs, checkShellConfigs } from "../utils/shell.js"; | ||
|
||
export const render = async () => { | ||
let errors = 0; | ||
errors += await renderLegacyConfigIssues(); | ||
errors += renderShellConfigIssues(); | ||
|
||
process.exit(errors); | ||
}; | ||
|
||
const renderLegacyConfigIssues = async (): Promise<number> => { | ||
const shellsWithLegacyConfigs = await checkLegacyConfigs(); | ||
if (shellsWithLegacyConfigs.length > 0) { | ||
process.stderr.write(chalk.red("•") + chalk.bold(" detected legacy configurations\n")); | ||
process.stderr.write(" the following shells have legacy configurations:\n"); | ||
shellsWithLegacyConfigs.forEach((shell) => { | ||
process.stderr.write(chalk.red(" - ") + shell + "\n"); | ||
}); | ||
process.stderr.write( | ||
chalk.yellow(" remove any inshellisense configurations from your shell profile and re-add them following the instructions in the README\n"), | ||
); | ||
return 1; | ||
} else { | ||
process.stdout.write(chalk.green("✓") + " no legacy configurations found\n"); | ||
} | ||
return 0; | ||
}; | ||
|
||
const renderShellConfigIssues = (): number => { | ||
const shellsWithoutConfigs = checkShellConfigs(); | ||
if (shellsWithoutConfigs.length > 0) { | ||
process.stderr.write(chalk.red("•") + " the following shells do not have configurations:\n"); | ||
shellsWithoutConfigs.forEach((shell) => { | ||
process.stderr.write(chalk.red(" - ") + shell + "\n"); | ||
}); | ||
process.stderr.write(chalk.yellow(" run " + chalk.underline(chalk.cyan("is init --generate-full-configs")) + " to generate new configurations\n")); | ||
return 1; | ||
} else { | ||
process.stdout.write(chalk.green("✓") + " all shells have configurations\n"); | ||
} | ||
return 0; | ||
}; |
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