@tensorify.io/cli
Version:
Official CLI for Tensorify.io - Build, test, and deploy machine learning plugins
44 lines (38 loc) âĸ 1.27 kB
text/typescript
import { Command } from "commander";
import chalk from "chalk";
import { authService } from "../auth/auth-service";
import { updateConfig } from "../auth/session-storage";
export const loginCommand = new Command("login")
.description("Authenticate with Tensorify.io")
.option("-d, --dev", "Use development environment")
.action(async (options) => {
try {
console.log(
chalk.blue("đ Starting authentication with Tensorify.io...")
);
const isDev = options.dev || process.env.NODE_ENV === "development";
await authService.login(isDev);
// Save development environment preference
await updateConfig({
isDev,
lastUsedEnv: isDev ? "dev" : "prod",
});
if (isDev) {
console.log(
chalk.green(
"â
Successfully authenticated with development environment!"
)
);
console.log(
chalk.blue(
"âšī¸ Development environment will be used for subsequent commands"
)
);
} else {
console.log(chalk.green("â
Successfully authenticated!"));
}
} catch (error: any) {
console.error(chalk.red("â Authentication failed:"), error.message);
process.exit(1);
}
});