@goldskycom/cli 0.1.2 → 0.2.0

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.js +31 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -40518,7 +40518,30 @@ var import_chalk = __toESM(require_source());
40518
40518
  var import_readline = __toESM(require("readline"));
40519
40519
  var import_axios = __toESM(require_axios4());
40520
40520
  var import_ora = __toESM(require_ora());
40521
+ async function checkToken(token, opts) {
40522
+ applyAuthToken(token);
40523
+ console.log();
40524
+ const spinner = (0, import_ora.default)("Validating API Token").start();
40525
+ try {
40526
+ const response = await import_axios.default.get(`${opts.apiHost}/auth/check_token`, {
40527
+ headers: {
40528
+ Authorization: `Bearer ${token}`
40529
+ },
40530
+ validateStatus: (_) => true
40531
+ });
40532
+ if (response.status === 200 && response.data.success) {
40533
+ await saveAuthToken(token);
40534
+ spinner.succeed(`${import_chalk.default.bold(`Logged in to project '${response.data.project.name}'`)} You can now run any authenticated commands on Goldsky from this computer`);
40535
+ return;
40536
+ }
40537
+ } catch (ex) {
40538
+ }
40539
+ spinner.fail(`${import_chalk.default.bold("Login failed")}. Make sure you entered your API token correctly - or contact Goldsky for more assistance`);
40540
+ }
40521
40541
  async function login(opts) {
40542
+ if (opts.token) {
40543
+ return checkToken(opts.token, opts);
40544
+ }
40522
40545
  const rl = import_readline.default.createInterface({
40523
40546
  input: process.stdin,
40524
40547
  output: process.stdout
@@ -40526,24 +40549,7 @@ async function login(opts) {
40526
40549
  rl.stdoutMuted = true;
40527
40550
  rl.question("Enter or paste in your Goldsky API token: ", async (token) => {
40528
40551
  rl.close();
40529
- applyAuthToken(token);
40530
- console.log();
40531
- const spinner = (0, import_ora.default)("Validating API Token").start();
40532
- try {
40533
- const response = await import_axios.default.get(`${opts.apiHost}/auth/check_token`, {
40534
- headers: {
40535
- Authorization: `Bearer ${token}`
40536
- },
40537
- validateStatus: (_) => true
40538
- });
40539
- if (response.status === 200 && response.data.success) {
40540
- await saveAuthToken(token);
40541
- spinner.succeed(`${import_chalk.default.bold(`Logged in to project '${response.data.project.name}'`)} You can now run any authenticated commands on Goldsky from this computer`);
40542
- return;
40543
- }
40544
- } catch (ex) {
40545
- }
40546
- spinner.fail(`${import_chalk.default.bold("Login failed")}. Make sure you entered your API token correctly - or contact Goldsky for more assistance`);
40552
+ await checkToken(token, opts);
40547
40553
  });
40548
40554
  rl._writeToOutput = () => {
40549
40555
  if (process.stdout.isTTY) {
@@ -40559,11 +40565,12 @@ async function logout(_opts) {
40559
40565
  // src/commands/login.ts
40560
40566
  var command2 = "login";
40561
40567
  var describe = "Log in to Goldsky to enable running authenticated CLI commands";
40562
- var builder = (yargs) => yargs.version(false);
40563
- var handler = async ({ apiHost }) => {
40564
- await login({
40565
- apiHost
40566
- });
40568
+ var builder = (yargs) => yargs.option("token", {
40569
+ describe: "CLI Auth Token",
40570
+ type: "string"
40571
+ });
40572
+ var handler = async ({ apiHost, token }) => {
40573
+ await login({ apiHost, token });
40567
40574
  };
40568
40575
 
40569
40576
  // src/commands/logout.ts
@@ -41198,7 +41205,7 @@ var import_chalk11 = __toESM(require_source());
41198
41205
 
41199
41206
  // package.json
41200
41207
  var name = "@goldskycom/cli";
41201
- var version = "0.1.2";
41208
+ var version = "0.2.0";
41202
41209
  var description = "The Goldsky CLI to deploy subgraphs, index & transform blockchain data, configure webhooks, and access your data in real-time.";
41203
41210
  var main = "dist/index.js";
41204
41211
  var keywords = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldskycom/cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "The Goldsky CLI to deploy subgraphs, index & transform blockchain data, configure webhooks, and access your data in real-time.",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [