trainfabric 0.1.3 → 0.1.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.cjs +55 -18
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -8891,23 +8891,58 @@ 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.3";
8894
+ var CLI_VERSION = "0.1.4";
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");
8898
8898
  var KEYCHAIN_SERVICE = "trainfabric-cli";
8899
- function printLoginBanner() {
8900
- const logo = [
8901
- " _______ __ _ _ _ ____ _____",
8902
- " |__ __| [ | (_) | | (_) / __ \\ |_ _|",
8903
- " | |_ __ _ _ _ __ | | ____ _ _ __ _ __ | |_ _ __ _ _ __ | | | | | | ",
8904
- " | | '__| | | | '_ \\ | |/ / _` | '_ \\| '_ \\ | __| |/ _` | '_ \\ | | | | | | ",
8905
- " | | | | |_| | | | || < (_| | |_) | |_) | | |_| | (_| | | | | | |__| |_ | | ",
8906
- " |_|_| \\__,_|_| |_| |_|\\_\\| .__/| .__/ \\__|_|\\__,_|_| |_| \\____/|_____|",
8907
- " | | | | "
8908
- ];
8899
+ var LOGIN_BANNER_LINES = [
8900
+ "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557",
8901
+ "\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D",
8902
+ " \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 ",
8903
+ " \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 ",
8904
+ " \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557",
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
+ ];
8907
+ var LOGIN_BANNER_POOL = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&*<>?+=/\\|~";
8908
+ function scrambleLine(line, progress) {
8909
+ const lockUntil = Math.floor(line.length * progress);
8910
+ return [...line].map((char, index) => {
8911
+ if (char === " " || index <= lockUntil) {
8912
+ return char;
8913
+ }
8914
+ return LOGIN_BANNER_POOL[Math.floor(Math.random() * LOGIN_BANNER_POOL.length)];
8915
+ }).join("");
8916
+ }
8917
+ async function printLoginBanner() {
8909
8918
  console.log("");
8910
- for (const row of logo) {
8919
+ if (!process.stdout.isTTY) {
8920
+ for (const row of LOGIN_BANNER_LINES) {
8921
+ console.log(row);
8922
+ }
8923
+ console.log(" TrainFabric CLI Login");
8924
+ console.log("");
8925
+ return;
8926
+ }
8927
+ process.stdout.write("\x1B[?25l");
8928
+ for (let frame = 0; frame <= 20; frame += 1) {
8929
+ if (frame > 0) {
8930
+ process.stdout.write(`\x1B[${LOGIN_BANNER_LINES.length}A`);
8931
+ }
8932
+ const progress = frame / 20;
8933
+ for (const row of LOGIN_BANNER_LINES) {
8934
+ process.stdout.write(`${scrambleLine(row, progress)}
8935
+ `);
8936
+ }
8937
+ await (0, import_promises2.setTimeout)(frame < 14 ? 32 : 18);
8938
+ }
8939
+ process.stdout.write("\x1B[?25h");
8940
+ console.log(" TrainFabric CLI Login");
8941
+ console.log("");
8942
+ }
8943
+ function printStaticLoginBanner() {
8944
+ console.log("");
8945
+ for (const row of LOGIN_BANNER_LINES) {
8911
8946
  console.log(row);
8912
8947
  }
8913
8948
  console.log(" TrainFabric CLI Login");
@@ -9216,7 +9251,9 @@ function createClient(config) {
9216
9251
  });
9217
9252
  }
9218
9253
  async function login(config) {
9219
- printLoginBanner();
9254
+ await printLoginBanner().catch(() => {
9255
+ printStaticLoginBanner();
9256
+ });
9220
9257
  const loginClient = new TrainingClient({ baseUrl: config.baseUrl });
9221
9258
  const server = import_node_http.default.createServer();
9222
9259
  const closeServer = () => {
@@ -9234,12 +9271,12 @@ async function login(config) {
9234
9271
  resolve(address.port);
9235
9272
  });
9236
9273
  });
9237
- const callbackUrl = `http://127.0.0.1:${port}/callback`;
9238
- const loginUrl = await runSpinnerUntil("Preparing browser login", () => loginClient.auth.browserLoginUrl(callbackUrl));
9239
- console.log("Waiting for authentication in your browser...");
9240
- console.log(`Callback URL: ${callbackUrl}`);
9241
- openBrowser(loginUrl.authorizationUrl);
9242
9274
  try {
9275
+ const callbackUrl = `http://127.0.0.1:${port}/callback`;
9276
+ const loginUrl = await runSpinnerUntil("Preparing browser login", () => loginClient.auth.browserLoginUrl(callbackUrl));
9277
+ console.log("Waiting for authentication in your browser...");
9278
+ console.log(`Callback URL: ${callbackUrl}`);
9279
+ openBrowser(loginUrl.authorizationUrl);
9243
9280
  const tokenResult = await Promise.race([
9244
9281
  new Promise((resolve, reject) => {
9245
9282
  const timeoutId = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trainfabric",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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",