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