Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI errors #517

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log

## 2024-10-25 - Version 0.13.0
## 2024-01-28 - CLI Version 0.13.1

- Fix issues with interactive CLI prompts [#517](https://github.com/hypermodeinc/modus/pull/517)

## 2024-10-25 - Version 0.13.0 (all components)

_NOTE: This is the first fully open-source release, using the name "Modus" for the framework.
"Hypermode" still refers to the company and the commercial hosting platform - but not the framework.
Expand Down
4 changes: 3 additions & 1 deletion cli/src/commands/new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export default class NewCommand extends Command {
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
} else {
throw err;
}
}
}
Expand Down Expand Up @@ -217,7 +219,7 @@ export default class NewCommand extends Command {

let updateSDK = false;
if (!installedSdkVersion) {
const confirmed = inquirer.confirm({
const confirmed = await inquirer.confirm({
message: `You do not have the ${sdkText} installed. Would you like to install it now?`,
default: true,
});
Expand Down
68 changes: 32 additions & 36 deletions cli/src/commands/runtime/remove/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,62 +40,58 @@ export default class RuntimeRemoveCommand extends Command {
static examples = ["modus runtime remove v0.0.0", "modus runtime remove all"];

async run(): Promise<void> {
const { args, flags } = await this.parse(RuntimeRemoveCommand);
if (!args.version) {
this.logError(`No runtime version specified. Run ${chalk.whiteBright("modus runtime remove <version>")}, or ${chalk.whiteBright("modus runtime remove all")}`);
return;
}
try {
const { args, flags } = await this.parse(RuntimeRemoveCommand);
if (!args.version) {
this.logError(`No runtime version specified. Run ${chalk.whiteBright("modus runtime remove <version>")}, or ${chalk.whiteBright("modus runtime remove all")}`);
return;
}

if (args.version.toLowerCase() === "all") {
const versions = await vi.getInstalledRuntimeVersions();
if (versions.length === 0) {
this.log(chalk.yellow("No Modus runtimes are installed."));
this.exit(1);
} else if (!flags.force) {
try {
if (args.version.toLowerCase() === "all") {
const versions = await vi.getInstalledRuntimeVersions();
if (versions.length === 0) {
this.log(chalk.yellow("No Modus runtimes are installed."));
this.exit(1);
} else if (!flags.force) {
const confirmed = await inquirer.confirm({
message: "Are you sure you want to remove all Modus runtimes?",
default: false,
});
if (!confirmed) {
this.abort();
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
}
}
}

for (const version of versions) {
await this.removeRuntime(version);
}
} else if (!args.version.startsWith("v")) {
this.logError("Version must start with 'v'.");
this.exit(1);
} else {
const runtimeText = `Modus Runtime ${args.version}`;
const isInstalled = await vi.runtimeVersionIsInstalled(args.version);
if (!isInstalled) {
this.log(chalk.yellow(runtimeText + "is not installed."));
for (const version of versions) {
await this.removeRuntime(version);
}
} else if (!args.version.startsWith("v")) {
this.logError("Version must start with 'v'.");
this.exit(1);
} else if (!flags.force) {
try {
} else {
const runtimeText = `Modus Runtime ${args.version}`;
const isInstalled = await vi.runtimeVersionIsInstalled(args.version);
if (!isInstalled) {
this.log(chalk.yellow(runtimeText + "is not installed."));
this.exit(1);
} else if (!flags.force) {
const confirmed = await inquirer.confirm({
message: `Are you sure you want to remove ${runtimeText}?`,
default: false,
});
if (!confirmed) {
this.abort();
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
}
}
}

await this.removeRuntime(args.version);
await this.removeRuntime(args.version);
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
} else {
throw err;
}
}
}

Expand Down
130 changes: 60 additions & 70 deletions cli/src/commands/sdk/remove/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,107 +50,97 @@ export default class SDKRemoveCommand extends Command {
static examples = ["modus sdk remove assemblyscript v0.0.0", "modus sdk remove all"];

async run(): Promise<void> {
const { args, flags } = await this.parse(SDKRemoveCommand);
if (!args.version) {
this.logError(`No SDK specified! Run ${chalk.whiteBright("modus sdk remove <name> [version]")}, or ${chalk.whiteBright("modus sdk remove all")}`);
return;
}
try {
const { args, flags } = await this.parse(SDKRemoveCommand);
if (!args.version) {
this.logError(`No SDK specified! Run ${chalk.whiteBright("modus sdk remove <name> [version]")}, or ${chalk.whiteBright("modus sdk remove all")}`);
return;
}

if (args.name.toLowerCase() === "all") {
let found = false;
for (const sdk of Object.values(SDK)) {
const versions = await vi.getInstalledSdkVersions(sdk);
if (versions.length > 0) {
found = true;
break;
if (args.name.toLowerCase() === "all") {
let found = false;
for (const sdk of Object.values(SDK)) {
const versions = await vi.getInstalledSdkVersions(sdk);
if (versions.length > 0) {
found = true;
break;
}
}
if (!found) {
this.log(chalk.yellow("No Modus SDKs are installed."));
this.exit(1);
}
}
if (!found) {
this.log(chalk.yellow("No Modus SDKs are installed."));
this.exit(1);
}

if (!flags.force) {
try {
const confirmed = inquirer.confirm({
if (!flags.force) {
const confirmed = await inquirer.confirm({
message: "Are you sure you want to remove all Modus SDKs?",
default: false,
});
if (!confirmed) {
this.abort();
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
}
}
}

for (const sdk of Object.values(SDK)) {
const versions = await vi.getInstalledSdkVersions(sdk);
for (const version of versions) {
await this.removeSDK(sdk, version);
for (const sdk of Object.values(SDK)) {
const versions = await vi.getInstalledSdkVersions(sdk);
for (const version of versions) {
await this.removeSDK(sdk, version);
}
}
}

if (flags.runtimes) {
const versions = await vi.getInstalledRuntimeVersions();
for (const version of versions) {
await this.removeRuntime(version);
if (flags.runtimes) {
const versions = await vi.getInstalledRuntimeVersions();
for (const version of versions) {
await this.removeRuntime(version);
}
}
}
} else {
const sdk = parseSDK(args.name);
if (args.version.toLowerCase() === "all") {
const versions = await vi.getInstalledSdkVersions(sdk);
if (versions.length === 0) {
this.log(chalk.yellow(`No Modus ${sdk} SDKs are installed.`));
this.exit(1);
} else if (!flags.force) {
try {
const confirmed = inquirer.confirm({
} else {
const sdk = parseSDK(args.name);
if (args.version.toLowerCase() === "all") {
const versions = await vi.getInstalledSdkVersions(sdk);
if (versions.length === 0) {
this.log(chalk.yellow(`No Modus ${sdk} SDKs are installed.`));
this.exit(1);
} else if (!flags.force) {
const confirmed = await inquirer.confirm({
message: `Are you sure you want to remove all Modus ${sdk} SDKs?`,
default: false,
});
if (!confirmed) {
this.abort();
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
}
}
}

for (const version of versions) {
await this.removeSDK(sdk, version);
}
} else if (!args.version.startsWith("v")) {
this.logError("Version must start with 'v'.");
this.exit(1);
} else {
const sdkText = `Modus ${sdk} SDK ${args.version}`;
const isInstalled = await vi.sdkVersionIsInstalled(sdk, args.version);
if (!isInstalled) {
this.log(chalk.yellow(sdkText + "is not installed."));
for (const version of versions) {
await this.removeSDK(sdk, version);
}
} else if (!args.version.startsWith("v")) {
this.logError("Version must start with 'v'.");
this.exit(1);
} else if (!flags.force) {
try {
const confirmed = inquirer.confirm({
} else {
const sdkText = `Modus ${sdk} SDK ${args.version}`;
const isInstalled = await vi.sdkVersionIsInstalled(sdk, args.version);
if (!isInstalled) {
this.log(chalk.yellow(sdkText + "is not installed."));
this.exit(1);
} else if (!flags.force) {
const confirmed = await inquirer.confirm({
message: `Are you sure you want to remove ${sdkText}?`,
default: false,
});
if (!confirmed) {
this.abort();
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
}
}
}

await this.removeSDK(sdk, args.version);
await this.removeSDK(sdk, args.version);
}
}
} catch (err: any) {
if (err.name === "ExitPromptError") {
this.abort();
} else {
throw err;
}
}
}
Expand Down