mirror of
https://github.com/lmstudio-ai/lms.git
synced 2025-09-19 21:40:02 +08:00
Transition to rollup to support exports (#106)
* Use .js for imports * WIP * WIP * Finish transitioning to esm * Disable experimental commands * Bring back bootstrap
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"bin": "dist/index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"watch": "tsc -w",
|
||||
@ -15,10 +16,10 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@lmstudio/lms-common": "^0.6.1",
|
||||
"@lmstudio/lms-es-plugin-runner": "^0.0.1",
|
||||
"@lmstudio/lms-isomorphic": "^0.3.2",
|
||||
"@lmstudio/lms-lmstudio": "^0.0.13",
|
||||
"@lmstudio/sdk": "^0.2.0",
|
||||
"@lmstudio/lms-es-plugin-runner": "^0.0.1",
|
||||
"boxen": "^5.1.2",
|
||||
"chalk": "^4.1.2",
|
||||
"cmd-ts": "^0.13.0",
|
||||
|
@ -1,5 +1,11 @@
|
||||
import { Signal, type Setter, type SimpleLogger } from "@lmstudio/lms-common";
|
||||
import { isAvailable, type StripNotAvailable } from "@lmstudio/lms-common/dist/LazySignal";
|
||||
import {
|
||||
isAvailable,
|
||||
Signal,
|
||||
type Setter,
|
||||
type SimpleLogger,
|
||||
type StripNotAvailable,
|
||||
} from "@lmstudio/lms-common";
|
||||
|
||||
import { existsSync, writeFileSync } from "fs";
|
||||
import { mkdir, readFile, watch } from "fs/promises";
|
||||
import path from "path";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { type SimpleLogger } from "@lmstudio/lms-common";
|
||||
import { type ZodSchema } from "zod";
|
||||
import { FileData } from "./FileData";
|
||||
import { FileData } from "./FileData.js";
|
||||
|
||||
export class SimpleFileData<TData> extends FileData<TData, TData> {
|
||||
public constructor(
|
||||
|
@ -2,7 +2,7 @@ import { SimpleLogger } from "@lmstudio/lms-common";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { z } from "zod";
|
||||
import { SimpleFileData } from "./SimpleFileData";
|
||||
import { SimpleFileData } from "./SimpleFileData.js";
|
||||
|
||||
export async function getCliPref(logger?: SimpleLogger) {
|
||||
const cliPrefSchema = z.object({
|
||||
|
@ -6,9 +6,9 @@ import { option, optional, string } from "cmd-ts";
|
||||
import { readFile } from "fs/promises";
|
||||
import { homedir } from "os";
|
||||
import path from "path";
|
||||
import { type LogLevelArgs } from "./logLevel";
|
||||
import { checkHttpServer } from "./subcommands/server";
|
||||
import { refinedNumber } from "./types/refinedNumber";
|
||||
import { type LogLevelArgs } from "./logLevel.js";
|
||||
import { checkHttpServer } from "./subcommands/server.js";
|
||||
import { refinedNumber } from "./types/refinedNumber.js";
|
||||
|
||||
interface AppInstallLocation {
|
||||
path: string;
|
||||
|
24
src/index.ts
24
src/index.ts
@ -1,15 +1,15 @@
|
||||
import { run, subcommands } from "cmd-ts";
|
||||
import { bootstrap } from "./subcommands/bootstrap";
|
||||
import { create } from "./subcommands/create";
|
||||
import { get } from "./subcommands/get";
|
||||
import { importCmd } from "./subcommands/importCmd";
|
||||
import { ls, ps } from "./subcommands/list";
|
||||
import { load } from "./subcommands/load";
|
||||
import { log } from "./subcommands/log";
|
||||
import { server } from "./subcommands/server";
|
||||
import { status } from "./subcommands/status";
|
||||
import { unload } from "./subcommands/unload";
|
||||
import { printVersion, version } from "./subcommands/version";
|
||||
import { bootstrap } from "./subcommands/bootstrap.js";
|
||||
import { create } from "./subcommands/create.js";
|
||||
import { get } from "./subcommands/get.js";
|
||||
import { importCmd } from "./subcommands/importCmd.js";
|
||||
import { ls, ps } from "./subcommands/list.js";
|
||||
import { load } from "./subcommands/load.js";
|
||||
import { log } from "./subcommands/log.js";
|
||||
import { server } from "./subcommands/server.js";
|
||||
import { status } from "./subcommands/status.js";
|
||||
import { unload } from "./subcommands/unload.js";
|
||||
import { printVersion, version } from "./subcommands/version.js";
|
||||
|
||||
if (process.argv.length === 2) {
|
||||
printVersion();
|
||||
@ -32,8 +32,8 @@ const cli = subcommands({
|
||||
// dev,
|
||||
// push,
|
||||
import: importCmd,
|
||||
version,
|
||||
bootstrap,
|
||||
version,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { installCli } from "@lmstudio/lms-lmstudio/dist/installCli";
|
||||
import { installCli } from "@lmstudio/lms-lmstudio/install-cli";
|
||||
import { command } from "cmd-ts";
|
||||
import { platform } from "os";
|
||||
|
||||
|
@ -15,8 +15,8 @@ import { join } from "path";
|
||||
import * as tar from "tar";
|
||||
import util from "util";
|
||||
import { z } from "zod";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { ProgressBar } from "../ProgressBar";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
import { ProgressBar } from "../ProgressBar.js";
|
||||
|
||||
const execAsync = util.promisify(exec);
|
||||
const illegalPathChars = ["/", "\\", ":", "*", "?", '"', "<", ">", "|"];
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { SimpleLogger, text, Validator } from "@lmstudio/lms-common";
|
||||
import { EsPluginRunnerWatcher, UtilBinary } from "@lmstudio/lms-es-plugin-runner";
|
||||
import { pluginManifestSchema } from "@lmstudio/lms-shared-types/dist/PluginManifest";
|
||||
import { EsPluginRunnerWatcher } from "@lmstudio/lms-es-plugin-runner/runner-watcher";
|
||||
import { UtilBinary } from "@lmstudio/lms-es-plugin-runner/util-binary";
|
||||
import { pluginManifestSchema } from "@lmstudio/lms-shared-types";
|
||||
import {
|
||||
type LMStudioClient,
|
||||
type PluginManifest,
|
||||
@ -11,12 +12,12 @@ import { boolean, command, flag } from "cmd-ts";
|
||||
import { cp, mkdir, readFile } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import { cwd } from "process";
|
||||
import { askQuestion } from "../confirm";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { exists } from "../exists";
|
||||
import { findProjectFolderOrExit } from "../findProjectFolder";
|
||||
import { pluginsFolderPath } from "../lmstudioPaths";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { askQuestion } from "../confirm.js";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { exists } from "../exists.js";
|
||||
import { findProjectFolderOrExit } from "../findProjectFolder.js";
|
||||
import { pluginsFolderPath } from "../lmstudioPaths.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
type PluginProcessStatus = "stopped" | "starting" | "running" | "restarting";
|
||||
|
||||
|
@ -5,12 +5,12 @@ import { type ModelSearchResultDownloadOption, type ModelSearchResultEntry } fro
|
||||
import chalk from "chalk";
|
||||
import { boolean, command, flag, option, optional, positional, string } from "cmd-ts";
|
||||
import inquirer from "inquirer";
|
||||
import { askQuestion } from "../confirm";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { formatSizeBytes1000 } from "../formatSizeBytes1000";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { ProgressBar } from "../ProgressBar";
|
||||
import { refinedNumber } from "../types/refinedNumber";
|
||||
import { askQuestion } from "../confirm.js";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { formatSizeBytes1000 } from "../formatSizeBytes1000.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
import { ProgressBar } from "../ProgressBar.js";
|
||||
import { refinedNumber } from "../types/refinedNumber.js";
|
||||
|
||||
function formatRemainingTime(timeSeconds: number) {
|
||||
const seconds = timeSeconds % 60;
|
||||
|
@ -16,8 +16,8 @@ import inquirerPrompt from "inquirer-autocomplete-prompt";
|
||||
import { homedir } from "os";
|
||||
import { basename, dirname, join } from "path";
|
||||
import { z } from "zod";
|
||||
import { getCliPref } from "../cliPref";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { getCliPref } from "../cliPref.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
const userRepoType: Type<string, [string, string]> = {
|
||||
async from(str) {
|
||||
|
@ -3,10 +3,10 @@ import { type DownloadedModel } from "@lmstudio/sdk";
|
||||
import chalk from "chalk";
|
||||
import { command, flag } from "cmd-ts";
|
||||
import columnify from "columnify";
|
||||
import { architectureInfoLookup } from "../architectureStylizations";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { formatSizeBytes1000, formatSizeBytesWithColor1000 } from "../formatSizeBytes1000";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { architectureInfoLookup } from "../architectureStylizations.js";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { formatSizeBytes1000, formatSizeBytesWithColor1000 } from "../formatSizeBytes1000.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
function loadedCheckBoxed(count: number) {
|
||||
if (count === 0) {
|
||||
|
@ -10,13 +10,13 @@ import { boolean, command, flag, option, optional, positional, string, type Type
|
||||
import fuzzy from "fuzzy";
|
||||
import inquirer from "inquirer";
|
||||
import inquirerPrompt from "inquirer-autocomplete-prompt";
|
||||
import { getCliPref } from "../cliPref";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { formatElapsedTime } from "../formatElapsedTime";
|
||||
import { formatSizeBytes1000 } from "../formatSizeBytes1000";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { ProgressBar } from "../ProgressBar";
|
||||
import { refinedNumber } from "../types/refinedNumber";
|
||||
import { getCliPref } from "../cliPref.js";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { formatElapsedTime } from "../formatElapsedTime.js";
|
||||
import { formatSizeBytes1000 } from "../formatSizeBytes1000.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
import { ProgressBar } from "../ProgressBar.js";
|
||||
import { refinedNumber } from "../types/refinedNumber.js";
|
||||
|
||||
const gpuOptionType: Type<string, LLMLlamaAccelerationOffloadRatio> = {
|
||||
async from(str) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { type DiagnosticsLogEventData } from "@lmstudio/lms-shared-types";
|
||||
import chalk from "chalk";
|
||||
import { command, flag, subcommands } from "cmd-ts";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
const stream = command({
|
||||
name: "stream",
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { command } from "cmd-ts";
|
||||
import { cwd } from "process";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { findProjectFolderOrExit } from "../findProjectFolder";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { findProjectFolderOrExit } from "../findProjectFolder.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
export const push = command({
|
||||
name: "push",
|
||||
|
@ -3,8 +3,8 @@ import { command, flag, number, option, optional, subcommands } from "cmd-ts";
|
||||
import { mkdir, readFile, writeFile } from "fs/promises";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { wakeUpService } from "../createClient";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { wakeUpService } from "../createClient.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
type HttpServerCtl =
|
||||
| {
|
||||
|
@ -2,10 +2,10 @@ import { text } from "@lmstudio/lms-common";
|
||||
import boxen from "boxen";
|
||||
import chalk from "chalk";
|
||||
import { command } from "cmd-ts";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { formatSizeBytesWithColor1000 } from "../formatSizeBytes1000";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { checkHttpServer, getServerConfig } from "./server";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { formatSizeBytesWithColor1000 } from "../formatSizeBytes1000.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
import { checkHttpServer, getServerConfig } from "./server.js";
|
||||
|
||||
export const status = command({
|
||||
name: "status",
|
||||
|
@ -5,8 +5,8 @@ import { boolean, command, flag, optional, positional, string } from "cmd-ts";
|
||||
import fuzzy from "fuzzy";
|
||||
import inquirer from "inquirer";
|
||||
import inquirerPrompt from "inquirer-autocomplete-prompt";
|
||||
import { createClient, createClientArgs } from "../createClient";
|
||||
import { createLogger, logLevelArgs } from "../logLevel";
|
||||
import { createClient, createClientArgs } from "../createClient.js";
|
||||
import { createLogger, logLevelArgs } from "../logLevel.js";
|
||||
|
||||
export const unload = command({
|
||||
name: "unload",
|
||||
|
@ -3,8 +3,9 @@
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"strict": true,
|
||||
"module": "CommonJS",
|
||||
"target": "ES2021",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"declaration": true,
|
||||
"incremental": true,
|
||||
"noImplicitOverride": true,
|
||||
|
Reference in New Issue
Block a user