@boltic/cli 1.0.38 → 1.0.39

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/cli.js CHANGED
@@ -17,9 +17,69 @@ const createCLI = (consoleUrl, apiUrl, serviceName, env) => {
17
17
  login: {
18
18
  description: "Authenticate the user and save access token",
19
19
  action: async (args) => {
20
- // Support PAT-based login via flag: `boltic login --pat`
21
- if (args.includes("--pat")) {
22
- await AuthCommands.handlePatLogin();
20
+ // Support PAT-based login via flags, e.g.:
21
+ // boltic login --pat XXXXX --account_id YYYYYY
22
+ // boltic login --pat=XXXXX --account-id=YYYYYY
23
+ let patFromArg;
24
+ let accountIdFromArg;
25
+ let hasPatFlag = false;
26
+ let hasAccountIdFlag = false;
27
+
28
+ for (let i = 0; i < args.length; i++) {
29
+ const arg = args[i];
30
+
31
+ if (arg === "--pat") {
32
+ hasPatFlag = true;
33
+ if (
34
+ i + 1 < args.length &&
35
+ !args[i + 1].startsWith("--")
36
+ ) {
37
+ patFromArg = args[i + 1];
38
+ i++;
39
+ }
40
+ continue;
41
+ }
42
+
43
+ if (arg === "--account_id" || arg === "--account-id") {
44
+ hasAccountIdFlag = true;
45
+ if (
46
+ i + 1 < args.length &&
47
+ !args[i + 1].startsWith("--")
48
+ ) {
49
+ accountIdFromArg = args[i + 1];
50
+ i++;
51
+ }
52
+ continue;
53
+ }
54
+
55
+ if (arg.startsWith("--pat=")) {
56
+ hasPatFlag = true;
57
+ patFromArg = arg.split("=")[1];
58
+ continue;
59
+ }
60
+
61
+ if (
62
+ arg.startsWith("--account_id=") ||
63
+ arg.startsWith("--account-id=")
64
+ ) {
65
+ hasAccountIdFlag = true;
66
+ accountIdFromArg = arg.split("=")[1];
67
+ continue;
68
+ }
69
+ }
70
+
71
+ // If any PAT-related flag is present, delegate to PAT login handler.
72
+ // `handlePatLogin` will decide whether to prompt based on which values are provided.
73
+ if (
74
+ hasPatFlag ||
75
+ hasAccountIdFlag ||
76
+ patFromArg ||
77
+ accountIdFromArg
78
+ ) {
79
+ await AuthCommands.handlePatLogin(
80
+ patFromArg,
81
+ accountIdFromArg
82
+ );
23
83
  return;
24
84
  }
25
85
 
package/commands/login.js CHANGED
@@ -29,6 +29,55 @@ const execute = async (args) => {
29
29
  return;
30
30
  }
31
31
 
32
+ // Special handling for `boltic login` to support PAT-based login via flags:
33
+ // boltic login --pat XXXXX --account_id YYYYYY
34
+ if (subCommand === "login") {
35
+ const options = args.slice(1);
36
+ let patFromArg;
37
+ let accountIdFromArg;
38
+
39
+ for (let i = 0; i < options.length; i++) {
40
+ const arg = options[i];
41
+
42
+ if (arg === "--pat" && i + 1 < options.length) {
43
+ patFromArg = options[i + 1];
44
+ i++;
45
+ continue;
46
+ }
47
+
48
+ if (
49
+ (arg === "--account_id" || arg === "--account-id") &&
50
+ i + 1 < options.length
51
+ ) {
52
+ accountIdFromArg = options[i + 1];
53
+ i++;
54
+ continue;
55
+ }
56
+
57
+ if (arg.startsWith("--pat=")) {
58
+ patFromArg = arg.split("=")[1];
59
+ continue;
60
+ }
61
+
62
+ if (
63
+ arg.startsWith("--account_id=") ||
64
+ arg.startsWith("--account-id=")
65
+ ) {
66
+ accountIdFromArg = arg.split("=")[1];
67
+ continue;
68
+ }
69
+ }
70
+
71
+ // If PAT flags are provided, use PAT-based login. Otherwise, fall back to browser-based login.
72
+ if (patFromArg || accountIdFromArg) {
73
+ await handlePatLogin(patFromArg, accountIdFromArg);
74
+ return;
75
+ }
76
+
77
+ await handleLogin();
78
+ return;
79
+ }
80
+
32
81
  await commands[subCommand].action(args.slice(1));
33
82
  };
34
83
 
@@ -179,31 +228,51 @@ async function handleLogin() {
179
228
 
180
229
  // Handle PAT-based login command
181
230
  async function handlePatLogin(patFromArg, accountIdFromArg) {
182
- let pat = patFromArg;
183
- let accountId = accountIdFromArg;
231
+ let pat = patFromArg && patFromArg.trim();
232
+ let accountId = accountIdFromArg && accountIdFromArg.trim();
233
+
234
+ // If both values are provided via CLI flags, do not prompt at all.
235
+ if (pat && accountId) {
236
+ try {
237
+ await storeSecret("pat", pat);
238
+ await storeSecret("account_id", accountId);
239
+ console.log(
240
+ chalk.green(
241
+ "\n✅ PAT token and Account ID stored securely. They will be used for future organization-related requests.\n"
242
+ )
243
+ );
244
+ } catch (error) {
245
+ console.error(
246
+ chalk.red(
247
+ `\n❌ Failed to store PAT credentials: ${error.message || error}\n`
248
+ )
249
+ );
250
+ }
251
+ return;
252
+ }
184
253
 
185
254
  if (!pat) {
186
255
  console.log(chalk.cyan("\n🔐 Personal Access Token (PAT) login\n"));
187
- pat = await askQuestion("Enter your PAT token: ");
256
+ pat = (await askQuestion("Enter your PAT token: ")).trim();
188
257
  }
189
258
 
190
- if (!pat || !pat.trim()) {
259
+ if (!pat) {
191
260
  console.log(chalk.red("\n❌ PAT token cannot be empty.\n"));
192
261
  return;
193
262
  }
194
263
 
195
264
  if (!accountId) {
196
- accountId = await askQuestion("Enter your Account ID: ");
265
+ accountId = (await askQuestion("Enter your Account ID: ")).trim();
197
266
  }
198
267
 
199
- if (!accountId || !accountId.trim()) {
268
+ if (!accountId) {
200
269
  console.log(chalk.red("\n❌ Account ID cannot be empty.\n"));
201
270
  return;
202
271
  }
203
272
 
204
273
  try {
205
- await storeSecret("pat", pat.trim());
206
- await storeSecret("account_id", accountId.trim());
274
+ await storeSecret("pat", pat);
275
+ await storeSecret("account_id", accountId);
207
276
  console.log(
208
277
  chalk.green(
209
278
  "\n✅ PAT token and Account ID stored securely. They will be used for future organization-related requests.\n"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boltic/cli",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "A powerful CLI tool for managing Boltic Workflow integrations - create, sync, test, and publish integrations with ease",
5
5
  "main": "index.js",
6
6
  "bin": {