@xano/cli 0.0.95-beta.24 → 0.0.95-beta.26

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
@@ -25,7 +25,7 @@ npm install -g @xano/cli
25
25
 
26
26
  3. Pull a workspace to local files:
27
27
  ```bash
28
- xano workspace pull ./my-workspace
28
+ xano workspace pull
29
29
  ```
30
30
 
31
31
  ## Commands
@@ -108,37 +108,40 @@ xano workspace edit <workspace_id> --require-token # Require token for doc
108
108
  xano workspace delete <workspace_id>
109
109
  xano workspace delete <workspace_id> --force
110
110
 
111
- # Pull workspace to local files
112
- xano workspace pull ./my-workspace
113
- xano workspace pull ./my-workspace -b dev # Specific branch
114
- xano workspace pull ./my-workspace --env --records # Include env vars and table records
115
- xano workspace pull ./my-workspace --draft # Include draft changes
116
-
117
- # Push local files to workspace (only changed files by default)
118
- xano workspace push ./my-workspace
119
- xano workspace push ./my-workspace -b dev
120
- xano workspace push ./my-workspace --sync # Full push send all files, not just changed ones
121
- xano workspace push ./my-workspace --sync --delete # Full push + delete remote objects not included
122
- xano workspace push ./my-workspace --dry-run # Preview changes without pushing
123
- xano workspace push ./my-workspace --records # Include table records
124
- xano workspace push ./my-workspace --env # Include environment variables
125
- xano workspace push ./my-workspace --truncate # Truncate tables before import
126
- xano workspace push ./my-workspace --no-transaction # Disable database transaction wrapping
127
- xano workspace push ./my-workspace --no-guids # Skip writing GUIDs back to local files
128
- xano workspace push ./my-workspace --force # Skip preview and confirmation (for CI/CD)
129
- xano workspace push ./my-workspace -i "function/*" # Push only matching files
130
- xano workspace push ./my-workspace -e "table/*" # Push all files except tables
131
- xano workspace push ./my-workspace -i "function/*" -e "**/test*" # Include functions, exclude tests
132
-
133
- # Pull from a git repository to local files
134
- xano workspace git pull ./output -r https://github.com/owner/repo
135
- xano workspace git pull ./output -r https://github.com/owner/repo -b main
136
- xano workspace git pull ./output -r https://github.com/owner/repo/tree/main/path/to/dir
137
- xano workspace git pull ./output -r https://github.com/owner/repo/blob/main/file.xs
138
- xano workspace git pull ./output -r git@github.com:owner/repo.git
139
- xano workspace git pull ./output -r https://gitlab.com/owner/repo/-/tree/master/path
140
- xano workspace git pull ./output -r https://github.com/owner/private-repo -t ghp_xxx
141
- xano workspace git pull ./output -r https://github.com/owner/repo --path subdir
111
+ # Pull workspace to local files (defaults to current directory)
112
+ xano workspace pull
113
+ xano workspace pull -d ./my-workspace # Specify output directory
114
+ xano workspace pull -b dev # Specific branch
115
+ xano workspace pull --env --records # Include env vars and table records
116
+ xano workspace pull --draft # Include draft changes
117
+
118
+ # Push local files to workspace (defaults to current directory, only changed files)
119
+ xano workspace push
120
+ xano workspace push -d ./my-workspace # Push from a specific directory
121
+ xano workspace push -b dev
122
+ xano workspace push --sync # Full push send all files, not just changed ones
123
+ xano workspace push --sync --delete # Full push + delete remote objects not included
124
+ xano workspace push --dry-run # Preview changes without pushing
125
+ xano workspace push --records # Include table records
126
+ xano workspace push --env # Include environment variables
127
+ xano workspace push --truncate # Truncate tables before import
128
+ xano workspace push --no-transaction # Disable database transaction wrapping
129
+ xano workspace push --no-guids # Skip writing GUIDs back to local files
130
+ xano workspace push --force # Skip preview and confirmation (for CI/CD)
131
+ xano workspace push -i "function/*" # Push only matching files
132
+ xano workspace push -e "table/*" # Push all files except tables
133
+ xano workspace push -i "function/*" -e "**/test*" # Include functions, exclude tests
134
+
135
+ # Pull from a git repository to local files (defaults to current directory)
136
+ xano workspace git pull -r https://github.com/owner/repo
137
+ xano workspace git pull -d ./output -r https://github.com/owner/repo
138
+ xano workspace git pull -r https://github.com/owner/repo -b main
139
+ xano workspace git pull -r https://github.com/owner/repo/tree/main/path/to/dir
140
+ xano workspace git pull -r https://github.com/owner/repo/blob/main/file.xs
141
+ xano workspace git pull -r git@github.com:owner/repo.git
142
+ xano workspace git pull -r https://gitlab.com/owner/repo/-/tree/master/path
143
+ xano workspace git pull -r https://github.com/owner/private-repo -t ghp_xxx
144
+ xano workspace git pull -r https://github.com/owner/repo --path subdir
142
145
  ```
143
146
 
144
147
  ### Branches
@@ -229,14 +232,16 @@ xano release import --file ./my-release.tar.gz
229
232
  xano release delete <release_name>
230
233
  xano release delete <release_name> --force
231
234
 
232
- # Pull release to local files
233
- xano release pull ./my-release -r v1.0
234
- xano release pull ./my-release -r v1.0 --env --records
235
+ # Pull release to local files (defaults to current directory)
236
+ xano release pull -r v1.0
237
+ xano release pull -d ./my-release -r v1.0
238
+ xano release pull -r v1.0 --env --records
235
239
 
236
- # Push local files as a new release
237
- xano release push ./my-release -n "v2.0"
238
- xano release push ./my-release -n "v2.0" --hotfix -d "Critical fix"
239
- xano release push ./my-release -n "v2.0" --no-records --no-env
240
+ # Push local files as a new release (defaults to current directory)
241
+ xano release push -n "v2.0"
242
+ xano release push -d ./my-release -n "v2.0"
243
+ xano release push -n "v2.0" --hotfix --description "Critical fix"
244
+ xano release push -n "v2.0" --no-records --no-env
240
245
 
241
246
  # Deploy a release to its workspace as a new branch
242
247
  xano release deploy "v1.0"
@@ -336,17 +341,19 @@ xano tenant impersonate <tenant_name> -o json
336
341
  #### Pull / Push
337
342
 
338
343
  ```bash
339
- # Pull tenant to local files
340
- xano tenant pull ./my-tenant -t <tenant_name>
341
- xano tenant pull ./my-tenant -t <tenant_name> --env --records
342
- xano tenant pull ./my-tenant -t <tenant_name> --draft
343
-
344
- # Push local files to tenant
345
- xano tenant push ./my-tenant -t <tenant_name>
346
- xano tenant push ./my-tenant -t <tenant_name> --records # Include table records
347
- xano tenant push ./my-tenant -t <tenant_name> --env # Include environment variables
348
- xano tenant push ./my-tenant -t <tenant_name> --truncate
349
- xano tenant push ./my-tenant -t <tenant_name> --no-transaction # Disable transaction wrapping
344
+ # Pull tenant to local files (defaults to current directory)
345
+ xano tenant pull -t <tenant_name>
346
+ xano tenant pull -d ./my-tenant -t <tenant_name>
347
+ xano tenant pull -t <tenant_name> --env --records
348
+ xano tenant pull -t <tenant_name> --draft
349
+
350
+ # Push local files to tenant (defaults to current directory)
351
+ xano tenant push -t <tenant_name>
352
+ xano tenant push -d ./my-tenant -t <tenant_name>
353
+ xano tenant push -t <tenant_name> --records # Include table records
354
+ xano tenant push -t <tenant_name> --env # Include environment variables
355
+ xano tenant push -t <tenant_name> --truncate
356
+ xano tenant push -t <tenant_name> --no-transaction # Disable transaction wrapping
350
357
  ```
351
358
 
352
359
  #### Deployments
@@ -457,9 +464,27 @@ Manage your sandbox tenant. Each user has a single sandbox tenant that is auto-p
457
464
  xano sandbox get
458
465
  xano sandbox get -o json
459
466
 
460
- # Push/pull workspace data
461
- xano sandbox push ./my-workspace
462
- xano sandbox pull ./my-tenant
467
+ # Pull sandbox to local files (defaults to current directory)
468
+ xano sandbox pull
469
+ xano sandbox pull -d ./my-sandbox
470
+ xano sandbox pull --env --records
471
+
472
+ # Push local files to sandbox (defaults to current directory, only changed files)
473
+ xano sandbox push
474
+ xano sandbox push -d ./my-workspace # Push from a specific directory
475
+ xano sandbox push --sync # Full push — send all files
476
+ xano sandbox push --sync --delete # Full push + delete remote objects not included
477
+ xano sandbox push --dry-run # Preview changes without pushing
478
+ xano sandbox push --records --env # Include records and environment variables
479
+ xano sandbox push --truncate # Truncate tables before import
480
+ xano sandbox push --no-guids # Skip writing GUIDs back to local files
481
+ xano sandbox push --force # Skip preview and confirmation
482
+ xano sandbox push -i "function/*" # Push only matching files
483
+ xano sandbox push -e "table/*" # Push all files except tables
484
+ xano sandbox push --review # Push and open sandbox review in the browser
485
+
486
+ # Review (open in browser)
487
+ xano sandbox review
463
488
 
464
489
  # Impersonate (open in browser)
465
490
  xano sandbox impersonate
@@ -127,6 +127,8 @@ Push and open sandbox review in the browser
127
127
  const target = {
128
128
  buildDryRunUrl: (params) => `${baseUrl}/multidoc/dry-run?${params.toString()}`,
129
129
  buildPushUrl: (params) => `${baseUrl}/multidoc?${params.toString()}`,
130
+ cliVersion: this.config.version,
131
+ instanceOrigin: profile.instance_origin,
130
132
  label: 'sandbox environment',
131
133
  supportsBranches: false,
132
134
  supportsPartial: false,
@@ -161,6 +161,8 @@ Push functions but exclude test files
161
161
  const target = {
162
162
  buildDryRunUrl: (params) => `${baseUrl}/multidoc/dry-run?${params.toString()}`,
163
163
  buildPushUrl: (params) => `${baseUrl}/multidoc?${params.toString()}`,
164
+ cliVersion: this.config.version,
165
+ instanceOrigin: profile.instance_origin,
164
166
  label: `workspace ${workspaceId}`,
165
167
  supportsBranches: true,
166
168
  supportsPartial: true,
@@ -19,6 +19,10 @@ export interface PushTarget {
19
19
  buildDryRunUrl: (queryParams: URLSearchParams) => null | string;
20
20
  /** Build the actual push URL */
21
21
  buildPushUrl: (queryParams: URLSearchParams) => string;
22
+ /** CLI version string */
23
+ cliVersion: string;
24
+ /** Instance origin URL (e.g., "https://x123-abcd-1234.xano.io") */
25
+ instanceOrigin: string;
22
26
  /** Human-readable label for log messages (e.g., "sandbox environment", "workspace 40") */
23
27
  label: string;
24
28
  /** Does this target support branches? */
@@ -106,9 +106,22 @@ const TYPE_LABELS = {
106
106
  workflow_test: 'Workflow Tests',
107
107
  workspace: 'Workspace Settings',
108
108
  };
109
- function renderPreview(result, willDelete, targetLabel, verbose, partial, log) {
109
+ function renderPreview(result, willDelete, target, verbose, partial, log) {
110
110
  log('');
111
- log(ux.colorize('bold', `=== Push Preview: ${targetLabel} ===`));
111
+ log(ux.colorize('bold', `=== Push Preview: ${target.label} ===`));
112
+ let instanceHost = target.instanceOrigin;
113
+ try {
114
+ instanceHost = new URL(target.instanceOrigin).hostname;
115
+ }
116
+ catch { }
117
+ const contextParts = [
118
+ `instance: ${instanceHost}`,
119
+ ];
120
+ if (result.workspace_name && target.supportsBranches) {
121
+ contextParts.push(`workspace: ${result.workspace_name}`);
122
+ }
123
+ contextParts.push(`cli: v${target.cliVersion}`);
124
+ log(ux.colorize('dim', ` ${contextParts.join(' | ')}`));
112
125
  if (!partial) {
113
126
  log(ux.colorize('red', ' --sync: all documents will be sent, including unchanged'));
114
127
  }
@@ -333,7 +346,7 @@ export async function executePush(ctx, target, flags) {
333
346
  method: 'POST',
334
347
  }, flags.verbose, accessToken);
335
348
  if (!dryRunResponse.ok) {
336
- await handleDryRunError(dryRunResponse, command, flags);
349
+ await handleDryRunError(dryRunResponse, command, flags, target);
337
350
  // If we get here, the user confirmed to proceed without preview
338
351
  }
339
352
  else {
@@ -341,7 +354,7 @@ export async function executePush(ctx, target, flags) {
341
354
  const preview = JSON.parse(dryRunText);
342
355
  dryRunPreview = preview;
343
356
  if (preview && preview.summary) {
344
- renderPreview(preview, shouldDelete, target.label, flags.verbose, isPartial, log);
357
+ renderPreview(preview, shouldDelete, target, flags.verbose, isPartial, log);
345
358
  // Check for bad cross-references using dry-run operations to avoid false positives
346
359
  const badRefs = checkReferences(documentEntries, preview.operations);
347
360
  if (badRefs.length > 0) {
@@ -572,9 +585,22 @@ export async function executePush(ctx, target, flags) {
572
585
  log(`Pushed ${pushedCount} documents to ${target.label} from ${relative(process.cwd(), inputDir) || inputDir} in ${elapsed}s`);
573
586
  }
574
587
  // ── Error Handlers ──────────────────────────────────────────────────────────
575
- async function handleDryRunError(response, command, flags) {
588
+ async function handleDryRunError(response, command, flags, target) {
576
589
  const log = command.log.bind(command);
577
590
  if (response.status === 404) {
591
+ const errorText = await response.text();
592
+ try {
593
+ const errorJson = JSON.parse(errorText);
594
+ if (errorJson.message) {
595
+ command.error(errorJson.message);
596
+ }
597
+ }
598
+ catch {
599
+ // Not JSON
600
+ }
601
+ if (target.supportsBranches) {
602
+ command.error('Workspace not found. Check the workspace ID and try again.');
603
+ }
578
604
  log('');
579
605
  log(ux.colorize('dim', 'Push preview not yet available on this instance.'));
580
606
  log('');
@@ -597,10 +623,7 @@ async function handleDryRunError(response, command, flags) {
597
623
  log('');
598
624
  log(ux.colorize('dim', "Note: Free plan instances don't include sandbox environments, so direct push is always enabled."));
599
625
  log('');
600
- // Exit cleanly — this is workspace-specific, but harmless for sandbox since
601
- // sandbox won't receive this error
602
- command.exit(0);
603
- return;
626
+ process.exit(0);
604
627
  }
605
628
  }
606
629
  catch {
@@ -196,8 +196,8 @@ function extractSchemaFields(content) {
196
196
  if (blockStart < 0 || blockEnd < 0)
197
197
  return fields;
198
198
  const schemaBlock = content.slice(blockStart, blockEnd);
199
- // Match field declarations: "type name" or "type name?" or "type name?=default"
200
- const fieldRegex = /^\s*\w+\s+(\w+)[?\s{]/gm;
199
+ // Match field declarations: "type name" or "type? name" or "type name?=default"
200
+ const fieldRegex = /^\s*\w+\??\s+(\w+)[?\s{]/gm;
201
201
  let match;
202
202
  while ((match = fieldRegex.exec(schemaBlock)) !== null) {
203
203
  fields.add(match[1]);