@nlxai/cli 1.2.2-alpha.5 → 1.2.2-alpha.6
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/lib/commands/auth/login.js +14 -1
- package/lib/commands/test.js +1 -1
- package/lib/index.js +4 -1
- package/package.json +2 -2
|
@@ -10,6 +10,15 @@ async function saveTokens(account, tokenData) {
|
|
|
10
10
|
await keytar.setPassword("nlx-cli", account, JSON.stringify(tokenData));
|
|
11
11
|
}
|
|
12
12
|
async function loadTokens() {
|
|
13
|
+
if (process.env.NLX_ACCESS_TOKEN) {
|
|
14
|
+
try {
|
|
15
|
+
console.log("Using access token from NLX_ACCESS_TOKEN environment variable");
|
|
16
|
+
return JSON.parse(atob(process.env.NLX_ACCESS_TOKEN));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
consola.error("Failed to parse NLX_ACCESS_TOKEN:", error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
13
22
|
try {
|
|
14
23
|
const data = fs.readFileSync(ACCOUNTS_PATH, "utf8");
|
|
15
24
|
const accounts = JSON.parse(data);
|
|
@@ -68,7 +77,8 @@ const CLIENT_ID = process.env.AUTH0_CLIENT_ID || "A0qluq7wJQjFjMLle9pvrWWaVHM1QH
|
|
|
68
77
|
const AUDIENCE = process.env.AUTH0_AUDIENCE || "https://nlxdev.us.auth0.com/api/v2/";
|
|
69
78
|
export const loginCommand = new Command("login")
|
|
70
79
|
.description("Authenticate with NLX")
|
|
71
|
-
.
|
|
80
|
+
.option("--print-token", "Print the access token after login (useful for CI)")
|
|
81
|
+
.action(async (opts) => {
|
|
72
82
|
// Step 1: Start device flow
|
|
73
83
|
const deviceCodeRes = await fetch(`https://${AUTH0_DOMAIN}/oauth/device/code`, {
|
|
74
84
|
method: "POST",
|
|
@@ -132,6 +142,9 @@ export const loginCommand = new Command("login")
|
|
|
132
142
|
// Step 4: Store token securely
|
|
133
143
|
tokenData.obtained_at = Math.floor(Date.now() / 1000);
|
|
134
144
|
await saveTokens(userData.email, tokenData);
|
|
145
|
+
if (opts.printToken) {
|
|
146
|
+
console.log("Access token", btoa(JSON.stringify([userData.email, tokenData])));
|
|
147
|
+
}
|
|
135
148
|
consola.success("Login successful! Access token stored securely.");
|
|
136
149
|
});
|
|
137
150
|
// Example usage: get a valid access token
|
package/lib/commands/test.js
CHANGED
|
@@ -22,7 +22,7 @@ export const testCommand = new Command("test")
|
|
|
22
22
|
let { tests } = (await fetchManagementApi(`bots/${applicationId}/conversationTests`, "GET"));
|
|
23
23
|
if (opts.onlyExecuteAtBuild) {
|
|
24
24
|
let total = tests.length;
|
|
25
|
-
tests = tests.filter((test) => test.
|
|
25
|
+
tests = tests.filter((test) => test.executeAtBuild);
|
|
26
26
|
if (tests.length === 0) {
|
|
27
27
|
consola.error("No tests found.");
|
|
28
28
|
process.exit(1);
|
package/lib/index.js
CHANGED
|
@@ -5,15 +5,18 @@ import { dataRequestsCommand } from "./commands/data-requests/index.js";
|
|
|
5
5
|
import { httpCommand } from "./commands/http.js";
|
|
6
6
|
import { testCommand } from "./commands/test.js";
|
|
7
7
|
import { consola } from "consola";
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
|
+
const packageJson = JSON.parse(readFileSync("../../package.json", "utf-8"));
|
|
8
10
|
program.description("Intereact with NLX from the command line");
|
|
9
11
|
program
|
|
10
|
-
.option("-v, --verbose", "
|
|
12
|
+
.option("-v, --verbose", "enable verbose logging")
|
|
11
13
|
.hook("preAction", (thisCommand) => {
|
|
12
14
|
if (thisCommand.opts().verbose) {
|
|
13
15
|
consola.level = 4; // Debug level
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
18
|
program.configureHelp({ showGlobalOptions: true });
|
|
19
|
+
program.version(packageJson.version);
|
|
17
20
|
program.addCommand(authCommand);
|
|
18
21
|
program.addCommand(modalitiesCommand);
|
|
19
22
|
program.addCommand(dataRequestsCommand);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nlxai/cli",
|
|
3
|
-
"version": "1.2.2-alpha.
|
|
3
|
+
"version": "1.2.2-alpha.6",
|
|
4
4
|
"description": "Tools for integrating with NLX apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NLX",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"@vitest/ui": "^3.2.4",
|
|
59
59
|
"vitest": "^3.2.4"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "b69e0d6fe441fe23b7193023f34e24d6c429590e"
|
|
62
62
|
}
|