@localess/cli 0.0.6-dev.20260307163319 → 0.0.6-dev.20260308224905

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.js CHANGED
@@ -28,13 +28,14 @@ var import_commander8 = require("commander");
28
28
 
29
29
  // src/commands/login/index.ts
30
30
  var import_commander = require("commander");
31
+ var import_prompts = require("@inquirer/prompts");
31
32
 
32
33
  // src/utils.ts
33
34
  var RESET = "\x1B[0m";
34
35
  var FG_BLUE = "\x1B[34m";
35
- function dotToNestedObject(input) {
36
+ function dotToNestedObject(input2) {
36
37
  const result = {};
37
- for (const [key, value] of Object.entries(input)) {
38
+ for (const [key, value] of Object.entries(input2)) {
38
39
  const parts = key.split(".");
39
40
  let current = result;
40
41
  for (let i = 0; i < parts.length; i++) {
@@ -466,35 +467,36 @@ async function clearSession() {
466
467
  }
467
468
 
468
469
  // src/commands/login/index.ts
469
- var loginCommand = new import_commander.Command("login").description("Login to Localess CLI").option("-t, --token <token>", "Token to login to Localess CLI").option("-s, --space <space>", "Space ID to login to").option("-o, --origin <origin>", "Origin of the Localess instance").action(async (options) => {
470
+ var loginCommand = new import_commander.Command("login").description("Login to Localess CLI").option("-o, --origin <origin>", "Origin of the Localess instance").option("-s, --space <space>", "Space ID to login to").option("-t, --token <token>", "Token to login to Localess CLI").action(async (options) => {
470
471
  const session = await getSession();
471
472
  if (session.isLoggedIn && session.method === "file") {
472
- console.log('Already logged in. If you want to log in with different credentials, please log out first using "localess logout" command.');
473
+ console.log("Already logged in.");
474
+ console.log('If you want to log in with different credentials, please log out first using "localess logout" command.');
473
475
  return;
474
476
  }
475
- if (options.origin && options.space && options.token) {
476
- const client = localessClient({
477
- origin: options.origin,
478
- spaceId: options.space,
479
- token: options.token
480
- });
481
- try {
482
- const space = await client.getSpace();
483
- console.log(`Successfully logged in to space: ${space.name} (${space.id})`);
484
- await persistSession({
485
- origin: options.origin,
486
- space: options.space,
487
- token: options.token
488
- });
489
- } catch (e) {
490
- console.error("Login failed");
491
- }
492
- } else if (session.isLoggedIn && session.method === "env") {
493
- console.log("Already logged in with environment variables.");
494
- console.log("If you want to log in with different credentials, Please provide all required options: --origin, --space, and --token");
495
- } else {
496
- console.log("Please provide all required options: --origin, --space, and --token");
497
- console.log("Or set the following environment variables: LOCALESS_ORIGIN, LOCALESS_SPACE, and LOCALESS_TOKEN");
477
+ const origin = options.origin ?? await (0, import_prompts.input)({
478
+ message: "Origin of the Localess instance:",
479
+ required: true
480
+ });
481
+ const space = options.space ?? await (0, import_prompts.input)({
482
+ message: "Space ID:",
483
+ required: true
484
+ });
485
+ const token = options.token ?? await (0, import_prompts.password)({
486
+ message: "Token:",
487
+ mask: true
488
+ });
489
+ const client = localessClient({
490
+ origin,
491
+ spaceId: space,
492
+ token
493
+ });
494
+ try {
495
+ const spaceData = await client.getSpace();
496
+ console.log(`Successfully logged in to space: ${spaceData.name} (${spaceData.id})`);
497
+ await persistSession({ origin, space, token });
498
+ } catch (e) {
499
+ console.error("Login failed");
498
500
  }
499
501
  });
500
502
 
package/dist/index.mjs CHANGED
@@ -5,13 +5,14 @@ import { Command as Command8 } from "commander";
5
5
 
6
6
  // src/commands/login/index.ts
7
7
  import { Command } from "commander";
8
+ import { input, password } from "@inquirer/prompts";
8
9
 
9
10
  // src/utils.ts
10
11
  var RESET = "\x1B[0m";
11
12
  var FG_BLUE = "\x1B[34m";
12
- function dotToNestedObject(input) {
13
+ function dotToNestedObject(input2) {
13
14
  const result = {};
14
- for (const [key, value] of Object.entries(input)) {
15
+ for (const [key, value] of Object.entries(input2)) {
15
16
  const parts = key.split(".");
16
17
  let current = result;
17
18
  for (let i = 0; i < parts.length; i++) {
@@ -443,35 +444,36 @@ async function clearSession() {
443
444
  }
444
445
 
445
446
  // src/commands/login/index.ts
446
- var loginCommand = new Command("login").description("Login to Localess CLI").option("-t, --token <token>", "Token to login to Localess CLI").option("-s, --space <space>", "Space ID to login to").option("-o, --origin <origin>", "Origin of the Localess instance").action(async (options) => {
447
+ var loginCommand = new Command("login").description("Login to Localess CLI").option("-o, --origin <origin>", "Origin of the Localess instance").option("-s, --space <space>", "Space ID to login to").option("-t, --token <token>", "Token to login to Localess CLI").action(async (options) => {
447
448
  const session = await getSession();
448
449
  if (session.isLoggedIn && session.method === "file") {
449
- console.log('Already logged in. If you want to log in with different credentials, please log out first using "localess logout" command.');
450
+ console.log("Already logged in.");
451
+ console.log('If you want to log in with different credentials, please log out first using "localess logout" command.');
450
452
  return;
451
453
  }
452
- if (options.origin && options.space && options.token) {
453
- const client = localessClient({
454
- origin: options.origin,
455
- spaceId: options.space,
456
- token: options.token
457
- });
458
- try {
459
- const space = await client.getSpace();
460
- console.log(`Successfully logged in to space: ${space.name} (${space.id})`);
461
- await persistSession({
462
- origin: options.origin,
463
- space: options.space,
464
- token: options.token
465
- });
466
- } catch (e) {
467
- console.error("Login failed");
468
- }
469
- } else if (session.isLoggedIn && session.method === "env") {
470
- console.log("Already logged in with environment variables.");
471
- console.log("If you want to log in with different credentials, Please provide all required options: --origin, --space, and --token");
472
- } else {
473
- console.log("Please provide all required options: --origin, --space, and --token");
474
- console.log("Or set the following environment variables: LOCALESS_ORIGIN, LOCALESS_SPACE, and LOCALESS_TOKEN");
454
+ const origin = options.origin ?? await input({
455
+ message: "Origin of the Localess instance:",
456
+ required: true
457
+ });
458
+ const space = options.space ?? await input({
459
+ message: "Space ID:",
460
+ required: true
461
+ });
462
+ const token = options.token ?? await password({
463
+ message: "Token:",
464
+ mask: true
465
+ });
466
+ const client = localessClient({
467
+ origin,
468
+ spaceId: space,
469
+ token
470
+ });
471
+ try {
472
+ const spaceData = await client.getSpace();
473
+ console.log(`Successfully logged in to space: ${spaceData.name} (${spaceData.id})`);
474
+ await persistSession({ origin, space, token });
475
+ } catch (e) {
476
+ console.error("Login failed");
475
477
  }
476
478
  });
477
479
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/cli",
3
- "version": "0.0.6-dev.20260307163319",
3
+ "version": "0.0.6-dev.20260308224905",
4
4
  "description": "Localess Command Line.",
5
5
  "keywords": [
6
6
  "localess",
@@ -40,6 +40,7 @@
40
40
  },
41
41
  "license": "MIT",
42
42
  "dependencies": {
43
+ "@inquirer/prompts": "^8.3.0",
43
44
  "commander": "^14.0.3",
44
45
  "chalk": "^5.6.2",
45
46
  "openapi-typescript": "^7.12.0",