This commit is contained in:
ryan-the-crayon
2024-12-06 15:02:58 -05:00
committed by GitHub
parent 39c044bce1
commit b36f3e778d
3 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,14 @@
import { type SimpleLogger } from "@lmstudio/lms-common";
import { type LMStudioClient } from "@lmstudio/sdk";
import chalk from "chalk";
export async function ensureAuthenticated(client: LMStudioClient, logger: SimpleLogger) {
await client.repository.ensureAuthenticated({
onAuthenticationUrl: url => {
logger.info("Authentication required. Please visit the following URL to authenticate:");
logger.info();
logger.info(chalk.greenBright(` ${url}`));
logger.info();
},
});
}

View File

@ -4,6 +4,7 @@ import { command, positional, string, type Type } from "cmd-ts";
import { resolve } from "path";
import { createClient, createClientArgs } from "../createClient.js";
import { createDownloadPbUpdater } from "../downloadPbUpdater.js";
import { ensureAuthenticated } from "../ensureAuthenticated.js";
import { exists } from "../exists.js";
import { createLogger, logLevelArgs } from "../logLevel.js";
import { optionalPositional } from "../optionalPositional.js";
@ -51,6 +52,7 @@ export const pull = command({
handler: async args => {
const logger = createLogger(args);
const client = await createClient(logger, args);
await ensureAuthenticated(client, logger);
const { owner, name } = args.artifactIdentifier;
let path = args.path;
let autoNamed: boolean;

View File

@ -1,6 +1,7 @@
import { command } from "cmd-ts";
import { cwd } from "process";
import { createClient, createClientArgs } from "../createClient.js";
import { ensureAuthenticated } from "../ensureAuthenticated.js";
import { findProjectFolderOrExit } from "../findProjectFolder.js";
import { createLogger, logLevelArgs } from "../logLevel.js";
@ -14,6 +15,7 @@ export const push = command({
handler: async args => {
const logger = createLogger(args);
const client = await createClient(logger, args);
await ensureAuthenticated(client, logger);
const projectPath = await findProjectFolderOrExit(logger, cwd());
await client.repository.pushArtifact({
path: projectPath,