@xano/cli 1.0.3-beta.8 → 1.0.3-beta.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/README.md CHANGED
@@ -70,6 +70,14 @@ uses the live branch, and `-p ""` uses the default profile name. With all four
70
70
  set alongside `--no-browser`, the only input is pasting the code from the
71
71
  browser — useful for scripted or remote setups.
72
72
 
73
+ When stdin is piped (not a TTY), `--no-browser` reads the code directly from
74
+ stdin instead of prompting, so scripts and AI agents can complete the flow
75
+ without an interactive terminal:
76
+
77
+ ```bash
78
+ echo "$CODE" | xano auth --no-browser -i my-instance -w 5 -b dev -p staging
79
+ ```
80
+
73
81
  If you can't run `xano auth` at all, you can always create a profile manually
74
82
  with a Metadata API token from the Xano dashboard — see
75
83
  [Profiles](#profiles) below.
@@ -19,6 +19,7 @@ export default class Auth extends Command {
19
19
  private fetchWorkspaces;
20
20
  private promptForToken;
21
21
  private promptProfileName;
22
+ private readTokenFromStdin;
22
23
  private resolveBranch;
23
24
  private resolveInstance;
24
25
  private resolveWorkspace;
@@ -25,6 +25,8 @@ To authenticate, open the following URL in any browser:
25
25
  ? Paste the code shown in your browser: ****`,
26
26
  `$ xano auth --no-browser --instance my-instance --workspace 5 --branch dev --profile staging
27
27
  (non-interactive: only the pasted code is prompted for)`,
28
+ `$ echo "$CODE" | xano auth --no-browser --instance my-instance --workspace 5 --branch dev --profile staging
29
+ (fully scripted: the code is read from piped stdin, no prompt at all)`,
28
30
  ];
29
31
  static flags = {
30
32
  branch: Flags.string({
@@ -248,6 +250,17 @@ To authenticate, open the following URL in any browser:
248
250
  this.log('');
249
251
  this.log(` ${authUrl}`);
250
252
  this.log('');
253
+ // Piped (non-TTY) stdin: read the code directly instead of prompting, so
254
+ // scripts and agents can do `echo $CODE | xano auth --no-browser ...`.
255
+ // The masked inquirer prompt below requires an interactive terminal.
256
+ if (!process.stdin.isTTY) {
257
+ const piped = await this.readTokenFromStdin();
258
+ if (!piped) {
259
+ this.error('No code received on stdin. Pipe the code shown in the browser, e.g. `echo "$CODE" | xano auth --no-browser ...`');
260
+ }
261
+ this.log('Read code from stdin.');
262
+ return piped;
263
+ }
251
264
  try {
252
265
  await open(authUrl);
253
266
  }
@@ -284,6 +297,17 @@ To authenticate, open the following URL in any browser:
284
297
  ]);
285
298
  return profileName.trim() || 'default';
286
299
  }
300
+ readTokenFromStdin() {
301
+ return new Promise((resolve) => {
302
+ let data = '';
303
+ process.stdin.setEncoding('utf8');
304
+ process.stdin.on('data', (chunk) => {
305
+ data += chunk;
306
+ });
307
+ process.stdin.on('end', () => resolve(data.trim()));
308
+ process.stdin.on('error', () => resolve(data.trim()));
309
+ });
310
+ }
287
311
  async resolveBranch(branches, flagValue) {
288
312
  if (flagValue !== undefined) {
289
313
  // An empty value means "skip and use live branch" (same as the picker's skip option)