trainfabric 0.1.5 → 0.1.6

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.cjs +23 -45
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -8891,7 +8891,7 @@ function buildComputeSpec(options) {
8891
8891
 
8892
8892
  // src/index.ts
8893
8893
  var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
8894
- var CLI_VERSION = "0.1.5";
8894
+ var CLI_VERSION = "0.1.6";
8895
8895
  var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
8896
8896
  var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
8897
8897
  var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
@@ -8905,6 +8905,18 @@ var LOGIN_BANNER_LINES = [
8905
8905
  " \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D"
8906
8906
  ];
8907
8907
  var LOGIN_BANNER_POOL = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&*<>?+=/\\|~";
8908
+ var LOGIN_BANNER_COMPACT_LINES = [
8909
+ "######### ######## ###### #### ## ## ######## ###### ######## ######## #### ######",
8910
+ " ### ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ##",
8911
+ " ### ######## ######## ## ## ## ## ###### ######## ######## ######## ## ##",
8912
+ " ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##",
8913
+ " ### ## ## ## ## #### ## #### ## ## ## ######## ## ## #### ######"
8914
+ ];
8915
+ function getLoginBannerLines() {
8916
+ const columns = process.stdout.columns ?? 120;
8917
+ const maxWideLine = Math.max(...LOGIN_BANNER_LINES.map((line) => line.length));
8918
+ return columns > maxWideLine + 2 ? LOGIN_BANNER_LINES : LOGIN_BANNER_COMPACT_LINES;
8919
+ }
8908
8920
  function scrambleLine(line, progress) {
8909
8921
  const lockUntil = Math.floor(line.length * progress);
8910
8922
  return [...line].map((char, index) => {
@@ -8914,44 +8926,8 @@ function scrambleLine(line, progress) {
8914
8926
  return LOGIN_BANNER_POOL[Math.floor(Math.random() * LOGIN_BANNER_POOL.length)];
8915
8927
  }).join("");
8916
8928
  }
8917
- function renderLoginBanner(progress) {
8918
- return LOGIN_BANNER_LINES.map((row) => scrambleLine(row, progress));
8919
- }
8920
- async function printLoginBanner() {
8921
- console.log("");
8922
- if (!process.stdout.isTTY) {
8923
- for (const row of LOGIN_BANNER_LINES) {
8924
- console.log(row);
8925
- }
8926
- console.log(" TrainFabric CLI Login");
8927
- console.log("");
8928
- return;
8929
- }
8930
- process.stdout.write("\x1B[?25l");
8931
- const frameCount = 40;
8932
- const totalFrames = frameCount * 3;
8933
- for (let frame = 0; frame <= totalFrames; frame += 1) {
8934
- if (frame > 0) {
8935
- process.stdout.write(`\x1B[${LOGIN_BANNER_LINES.length}A`);
8936
- }
8937
- const progress = frame % frameCount / frameCount;
8938
- for (const row of renderLoginBanner(progress)) {
8939
- process.stdout.write(`${row}
8940
- `);
8941
- }
8942
- await (0, import_promises3.setTimeout)(85);
8943
- }
8944
- process.stdout.write("\x1B[?25h");
8945
- console.log(" TrainFabric CLI Login");
8946
- console.log("");
8947
- }
8948
- function printStaticLoginBanner() {
8949
- console.log("");
8950
- for (const row of LOGIN_BANNER_LINES) {
8951
- console.log(row);
8952
- }
8953
- console.log(" TrainFabric CLI Login");
8954
- console.log("");
8929
+ function renderLoginBanner(progress, lines = getLoginBannerLines()) {
8930
+ return lines.map((row) => scrambleLine(row, progress));
8955
8931
  }
8956
8932
  function sleep(ms) {
8957
8933
  return (0, import_promises3.setTimeout)(ms);
@@ -8968,11 +8944,13 @@ async function promptApiKey() {
8968
8944
  let apiKey = "";
8969
8945
  let frame = 0;
8970
8946
  let closed = false;
8971
- const totalLines = LOGIN_BANNER_LINES.length + 4;
8947
+ const lines = getLoginBannerLines();
8948
+ const frameCount = 40;
8949
+ const totalLines = lines.length + 4;
8972
8950
  const redraw = () => {
8973
- const progress = frame % 48 / 48;
8951
+ const progress = frame % frameCount / frameCount;
8974
8952
  process.stdout.write(`\x1B[${totalLines}A`);
8975
- for (const row of renderLoginBanner(progress)) {
8953
+ for (const row of renderLoginBanner(progress, lines)) {
8976
8954
  process.stdout.write(`\x1B[2K${row}
8977
8955
  `);
8978
8956
  }
@@ -8992,6 +8970,7 @@ async function promptApiKey() {
8992
8970
  clearInterval(timer);
8993
8971
  process.stdin.off("data", onData);
8994
8972
  process.stdin.setRawMode(false);
8973
+ process.stdin.pause();
8995
8974
  process.stdout.write("\x1B[?25h\n");
8996
8975
  };
8997
8976
  const onData = (chunk) => {
@@ -9014,7 +8993,7 @@ async function promptApiKey() {
9014
8993
  apiKey += value.replace(/[\r\n]/g, "");
9015
8994
  redraw();
9016
8995
  };
9017
- for (const row of LOGIN_BANNER_LINES) {
8996
+ for (const row of lines) {
9018
8997
  console.log(row);
9019
8998
  }
9020
8999
  console.log(" TrainFabric CLI Login");
@@ -9025,7 +9004,7 @@ async function promptApiKey() {
9025
9004
  process.stdin.setRawMode(true);
9026
9005
  process.stdin.resume();
9027
9006
  process.stdin.on("data", onData);
9028
- const timer = setInterval(redraw, 160);
9007
+ const timer = setInterval(redraw, 75);
9029
9008
  });
9030
9009
  }
9031
9010
  async function runSpinnerUntil(label, action) {
@@ -9319,7 +9298,6 @@ function createClient(config) {
9319
9298
  });
9320
9299
  }
9321
9300
  async function login(config) {
9322
- await printLoginBanner().catch(() => printStaticLoginBanner());
9323
9301
  const apiKey = await promptApiKey();
9324
9302
  if (!apiKey) {
9325
9303
  throw new Error("API key is required.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trainfabric",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Trainfabric CLI for launching GPU training jobs on the hosted Trainfabric backend.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",