trainfabric 0.1.7 → 0.1.8

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 +42 -28
  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.7";
8894
+ var CLI_VERSION = "0.1.8";
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");
@@ -8929,6 +8929,43 @@ function scrambleLine(line, progress) {
8929
8929
  function renderLoginBanner(progress, lines = getLoginBannerLines()) {
8930
8930
  return lines.map((row) => scrambleLine(row, progress));
8931
8931
  }
8932
+ async function printLoginBanner() {
8933
+ console.log("");
8934
+ const lines = getLoginBannerLines();
8935
+ if (!process.stdout.isTTY) {
8936
+ for (const row of lines) {
8937
+ console.log(row);
8938
+ }
8939
+ console.log(" TrainFabric CLI Login");
8940
+ console.log("");
8941
+ return;
8942
+ }
8943
+ process.stdout.write("\x1B[?25l");
8944
+ const frameCount = 40;
8945
+ const totalFrames = frameCount;
8946
+ for (let frame = 0; frame <= totalFrames; frame += 1) {
8947
+ if (frame > 0) {
8948
+ process.stdout.write(`\x1B[${lines.length}A`);
8949
+ }
8950
+ const progress = frame % frameCount / frameCount;
8951
+ for (const row of renderLoginBanner(progress, lines)) {
8952
+ process.stdout.write(`${row}
8953
+ `);
8954
+ }
8955
+ await (0, import_promises3.setTimeout)(37);
8956
+ }
8957
+ process.stdout.write("\x1B[?25h");
8958
+ console.log(" TrainFabric CLI Login");
8959
+ console.log("");
8960
+ }
8961
+ function printStaticLoginBanner() {
8962
+ console.log("");
8963
+ for (const row of getLoginBannerLines()) {
8964
+ console.log(row);
8965
+ }
8966
+ console.log(" TrainFabric CLI Login");
8967
+ console.log("");
8968
+ }
8932
8969
  function sleep(ms) {
8933
8970
  return (0, import_promises3.setTimeout)(ms);
8934
8971
  }
@@ -8942,36 +8979,21 @@ async function promptApiKey() {
8942
8979
  }
8943
8980
  }
8944
8981
  let apiKey = "";
8945
- let frame = 0;
8946
8982
  let closed = false;
8947
- const lines = getLoginBannerLines();
8948
- const frameCount = 40;
8949
- const totalLines = lines.length + 4;
8950
8983
  const redraw = () => {
8951
- const progress = frame % frameCount / frameCount;
8952
- process.stdout.write(`\x1B[${totalLines}A`);
8953
- for (const row of renderLoginBanner(progress, lines)) {
8954
- process.stdout.write(`\x1B[2K${row}
8955
- `);
8956
- }
8957
- process.stdout.write("\x1B[2K TrainFabric CLI Login\n");
8958
- process.stdout.write("\x1B[2K\n");
8959
- process.stdout.write(`\x1B[2KPaste your TrainFabric API key: ${"*".repeat(apiKey.length)}
8960
- `);
8961
- process.stdout.write("\x1B[2KPress Enter to continue.\n");
8962
- frame += 1;
8984
+ process.stdout.write(`\r\x1B[2KPaste your TrainFabric API key: ${"*".repeat(apiKey.length)}`);
8963
8985
  };
8986
+ await printLoginBanner().catch(() => printStaticLoginBanner());
8964
8987
  return await new Promise((resolve, reject) => {
8965
8988
  const cleanup = () => {
8966
8989
  if (closed) {
8967
8990
  return;
8968
8991
  }
8969
8992
  closed = true;
8970
- clearInterval(timer);
8971
8993
  process.stdin.off("data", onData);
8972
8994
  process.stdin.setRawMode(false);
8973
8995
  process.stdin.pause();
8974
- process.stdout.write("\x1B[?25h\n");
8996
+ process.stdout.write("\n");
8975
8997
  };
8976
8998
  const onData = (chunk) => {
8977
8999
  const value = chunk.toString("utf8");
@@ -8993,18 +9015,10 @@ async function promptApiKey() {
8993
9015
  apiKey += value.replace(/[\r\n]/g, "");
8994
9016
  redraw();
8995
9017
  };
8996
- for (const row of lines) {
8997
- console.log(row);
8998
- }
8999
- console.log(" TrainFabric CLI Login");
9000
- console.log("");
9001
- console.log("Paste your TrainFabric API key: ");
9002
- console.log("Press Enter to continue.");
9003
- process.stdout.write("\x1B[?25l");
9018
+ redraw();
9004
9019
  process.stdin.setRawMode(true);
9005
9020
  process.stdin.resume();
9006
9021
  process.stdin.on("data", onData);
9007
- const timer = setInterval(redraw, 37);
9008
9022
  });
9009
9023
  }
9010
9024
  async function runSpinnerUntil(label, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trainfabric",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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",