@llmops/cli 0.6.10 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +17 -41
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { command, run, string } from "@drizzle-team/brocli";
3
3
  import { logger } from "@llmops/core";
4
- import { createDatabaseFromConnection, detectDatabaseType, getMigrations } from "@llmops/core/db";
5
4
  import { existsSync } from "node:fs";
6
5
  import yoctoSpinner from "yocto-spinner";
7
- import chalk from "chalk";
8
6
  import prompts from "prompts";
9
7
  import { loadConfig } from "c12";
10
8
  import path from "node:path";
@@ -21,17 +19,6 @@ const getConfig = async ({ cwd, configPath }) => {
21
19
 
22
20
  //#endregion
23
21
  //#region src/commands/migrate.ts
24
- /**
25
- * @fileoverview This file defines the 'migrate' command for the CLI application.
26
- * Steps:
27
- * 1. Look for package.json and @llmops/sdk in the current directory.
28
- * 2. Check if the @llmops/sdk version works with the current CLI version.
29
- * 3. If compatible, check for the config file passed as an argument.
30
- * 4. If the config file exists, read and parse it.
31
- * 5. If not passed, look for default config file locations.
32
- * 6. Use zod to validate the existing configuration schema.
33
- * 7. If valid, get the db adapter from the config.
34
- */
35
22
  const migrateCommand = command({
36
23
  name: "migrate",
37
24
  desc: "Run database migrations based on LLMOps configuration",
@@ -59,46 +46,35 @@ const migrateCommand = command({
59
46
  logger.error("No valid LLMOps configuration found.");
60
47
  process.exit(1);
61
48
  }
62
- if (!config.database) {
63
- logger.error("No database configuration found.");
49
+ const telemetry = config.telemetry;
50
+ const store = Array.isArray(telemetry) ? telemetry[0] : telemetry;
51
+ if (!store || !store._pool) {
52
+ logger.error("No telemetry store with database found. Configure pgStore in your config.");
64
53
  process.exit(1);
65
54
  }
66
- const schema = config.schema ?? "llmops";
67
- const db = await createDatabaseFromConnection(config.database, { schema });
68
- if (!db) {
69
- logger.error("Failed to create database connection.");
70
- process.exit(1);
71
- }
72
- const dbType = detectDatabaseType(config.database);
73
- if (!dbType) {
74
- logger.error("Could not detect database type.");
75
- process.exit(1);
76
- }
77
- const spinner = yoctoSpinner({ text: "preparing migration..." }).start();
78
- const { toBeAdded, toBeCreated, runMigrations } = await getMigrations(db, dbType, { schema });
79
- if (!toBeAdded.length && !toBeCreated.length) {
80
- spinner.stop();
81
- console.log("🚀 No migrations needed.");
82
- process.exit(0);
83
- }
84
- spinner.stop();
85
- console.log(`🔑 The migration will affect the following:`);
86
- for (const table of [...toBeCreated, ...toBeAdded]) console.log("->", chalk.magenta(Object.keys(table.fields).join(", ")), chalk.white("fields on"), chalk.yellow(`${table.table}`), chalk.white("table."));
87
55
  let migrate = opts.yes;
88
56
  if (!opts.yes) migrate = (await prompts({
89
57
  type: "confirm",
90
58
  name: "migrate",
91
- message: "Do you want to proceed with the migration?",
59
+ message: "Do you want to run pending migrations?",
92
60
  initial: false
93
61
  })).migrate;
94
62
  if (!migrate) {
95
63
  console.log("Migration cancelled.");
96
64
  process.exit(0);
97
65
  }
98
- spinner.start("migrating...");
99
- await runMigrations();
100
- spinner.stop();
101
- console.log("✅ Migration completed successfully.");
66
+ const spinner = yoctoSpinner({ text: "running migrations..." }).start();
67
+ try {
68
+ const { runMigrations } = await import("@llmops/sdk/store/pg");
69
+ const { applied } = await runMigrations(store._pool, store._schema ?? "llmops");
70
+ spinner.stop();
71
+ if (applied.length === 0) console.log("🚀 No pending migrations.");
72
+ else console.log(`✅ Applied ${applied.length} migration(s): ${applied.join(", ")}`);
73
+ } catch (error) {
74
+ spinner.stop();
75
+ logger.error(`Migration failed: ${error}`);
76
+ process.exit(1);
77
+ }
102
78
  process.exit(0);
103
79
  }
104
80
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/cli",
3
- "version": "0.6.10",
3
+ "version": "1.0.0-beta.10",
4
4
  "type": "module",
5
5
  "description": "LLMOps CLI - A pluggable LLMOps toolkit for TypeScript teams",
6
6
  "license": "Apache-2.0",
@@ -45,8 +45,8 @@
45
45
  "kysely": "^0.28.8",
46
46
  "prompts": "^2.4.2",
47
47
  "yocto-spinner": "^1.0.0",
48
- "@llmops/core": "^0.6.10",
49
- "@llmops/sdk": "^0.6.10"
48
+ "@llmops/core": "^1.0.0-beta.10",
49
+ "@llmops/sdk": "^1.0.0-beta.10"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/pg": "^8.15.6",