trainfabric 0.1.7 → 0.1.9
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.
- package/dist/index.cjs +47 -28
- 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.
|
|
8894
|
+
var CLI_VERSION = "0.1.9";
|
|
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,48 @@ 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;
|
|
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[${lines.length}A`);
|
|
8958
|
+
for (const row of lines) {
|
|
8959
|
+
process.stdout.write(`${row}
|
|
8960
|
+
`);
|
|
8961
|
+
}
|
|
8962
|
+
process.stdout.write("\x1B[?25h");
|
|
8963
|
+
console.log(" TrainFabric CLI Login");
|
|
8964
|
+
console.log("");
|
|
8965
|
+
}
|
|
8966
|
+
function printStaticLoginBanner() {
|
|
8967
|
+
console.log("");
|
|
8968
|
+
for (const row of getLoginBannerLines()) {
|
|
8969
|
+
console.log(row);
|
|
8970
|
+
}
|
|
8971
|
+
console.log(" TrainFabric CLI Login");
|
|
8972
|
+
console.log("");
|
|
8973
|
+
}
|
|
8932
8974
|
function sleep(ms) {
|
|
8933
8975
|
return (0, import_promises3.setTimeout)(ms);
|
|
8934
8976
|
}
|
|
@@ -8942,36 +8984,21 @@ async function promptApiKey() {
|
|
|
8942
8984
|
}
|
|
8943
8985
|
}
|
|
8944
8986
|
let apiKey = "";
|
|
8945
|
-
let frame = 0;
|
|
8946
8987
|
let closed = false;
|
|
8947
|
-
const lines = getLoginBannerLines();
|
|
8948
|
-
const frameCount = 40;
|
|
8949
|
-
const totalLines = lines.length + 4;
|
|
8950
8988
|
const redraw = () => {
|
|
8951
|
-
|
|
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;
|
|
8989
|
+
process.stdout.write(`\r\x1B[2KPaste your TrainFabric API key: ${"*".repeat(apiKey.length)}`);
|
|
8963
8990
|
};
|
|
8991
|
+
await printLoginBanner().catch(() => printStaticLoginBanner());
|
|
8964
8992
|
return await new Promise((resolve, reject) => {
|
|
8965
8993
|
const cleanup = () => {
|
|
8966
8994
|
if (closed) {
|
|
8967
8995
|
return;
|
|
8968
8996
|
}
|
|
8969
8997
|
closed = true;
|
|
8970
|
-
clearInterval(timer);
|
|
8971
8998
|
process.stdin.off("data", onData);
|
|
8972
8999
|
process.stdin.setRawMode(false);
|
|
8973
9000
|
process.stdin.pause();
|
|
8974
|
-
process.stdout.write("\
|
|
9001
|
+
process.stdout.write("\n");
|
|
8975
9002
|
};
|
|
8976
9003
|
const onData = (chunk) => {
|
|
8977
9004
|
const value = chunk.toString("utf8");
|
|
@@ -8993,18 +9020,10 @@ async function promptApiKey() {
|
|
|
8993
9020
|
apiKey += value.replace(/[\r\n]/g, "");
|
|
8994
9021
|
redraw();
|
|
8995
9022
|
};
|
|
8996
|
-
|
|
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");
|
|
9023
|
+
redraw();
|
|
9004
9024
|
process.stdin.setRawMode(true);
|
|
9005
9025
|
process.stdin.resume();
|
|
9006
9026
|
process.stdin.on("data", onData);
|
|
9007
|
-
const timer = setInterval(redraw, 37);
|
|
9008
9027
|
});
|
|
9009
9028
|
}
|
|
9010
9029
|
async function runSpinnerUntil(label, action) {
|