@llmops/cli 1.0.0-beta.3 → 1.0.0-beta.4

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 +14 -30
  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 { 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 telemetry store from the config.
34
- */
35
22
  const migrateCommand = command({
36
23
  name: "migrate",
37
24
  desc: "Run database migrations based on LLMOps configuration",
@@ -61,36 +48,33 @@ const migrateCommand = command({
61
48
  }
62
49
  const telemetry = config.telemetry;
63
50
  const store = Array.isArray(telemetry) ? telemetry[0] : telemetry;
64
- if (!store || !store._db) {
51
+ if (!store || !store._pool) {
65
52
  logger.error("No telemetry store with database found. Configure pgStore in your config.");
66
53
  process.exit(1);
67
54
  }
68
- const db = store._db;
69
- const spinner = yoctoSpinner({ text: "preparing migration..." }).start();
70
- const { toBeAdded, toBeCreated, runMigrations } = await getMigrations(db, "postgres", { schema: "llmops" });
71
- if (!toBeAdded.length && !toBeCreated.length) {
72
- spinner.stop();
73
- console.log("🚀 No migrations needed.");
74
- process.exit(0);
75
- }
76
- spinner.stop();
77
- console.log(`🔑 The migration will affect the following:`);
78
- 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."));
79
55
  let migrate = opts.yes;
80
56
  if (!opts.yes) migrate = (await prompts({
81
57
  type: "confirm",
82
58
  name: "migrate",
83
- message: "Do you want to proceed with the migration?",
59
+ message: "Do you want to run pending migrations?",
84
60
  initial: false
85
61
  })).migrate;
86
62
  if (!migrate) {
87
63
  console.log("Migration cancelled.");
88
64
  process.exit(0);
89
65
  }
90
- spinner.start("migrating...");
91
- await runMigrations();
92
- spinner.stop();
93
- 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
+ }
94
78
  process.exit(0);
95
79
  }
96
80
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/cli",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
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/sdk": "^1.0.0-beta.3",
49
- "@llmops/core": "^1.0.0-beta.3"
48
+ "@llmops/core": "^1.0.0-beta.4",
49
+ "@llmops/sdk": "^1.0.0-beta.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/pg": "^8.15.6",