@xano/cli 0.0.95-beta.23 → 0.0.95-beta.25
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 +78 -53
- package/dist/commands/release/pull/index.d.ts +1 -3
- package/dist/commands/release/pull/index.js +18 -15
- package/dist/commands/release/push/index.d.ts +1 -3
- package/dist/commands/release/push/index.js +18 -19
- package/dist/commands/sandbox/pull/index.d.ts +1 -3
- package/dist/commands/sandbox/pull/index.js +15 -12
- package/dist/commands/sandbox/push/index.d.ts +11 -6
- package/dist/commands/sandbox/push/index.js +149 -136
- package/dist/commands/tenant/pull/index.d.ts +1 -3
- package/dist/commands/tenant/pull/index.js +19 -18
- package/dist/commands/workspace/git/pull/index.d.ts +1 -3
- package/dist/commands/workspace/git/pull/index.js +18 -17
- package/dist/commands/workspace/pull/index.d.ts +1 -3
- package/dist/commands/workspace/pull/index.js +20 -21
- package/dist/commands/workspace/push/index.d.ts +6 -18
- package/dist/commands/workspace/push/index.js +85 -747
- package/dist/utils/multidoc-push.d.ts +63 -0
- package/dist/utils/multidoc-push.js +674 -0
- package/dist/utils/reference-checker.js +2 -2
- package/oclif.manifest.json +2121 -2015
- package/package.json +1 -1
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
|
|
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
|
|
113
|
-
xano workspace pull ./my-workspace
|
|
114
|
-
xano workspace pull
|
|
115
|
-
xano workspace pull
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
xano workspace push
|
|
120
|
-
xano workspace push ./my-workspace
|
|
121
|
-
xano workspace push
|
|
122
|
-
xano workspace push
|
|
123
|
-
xano workspace push
|
|
124
|
-
xano workspace push
|
|
125
|
-
xano workspace push
|
|
126
|
-
xano workspace push
|
|
127
|
-
xano workspace push
|
|
128
|
-
xano workspace push
|
|
129
|
-
xano workspace push
|
|
130
|
-
xano workspace push
|
|
131
|
-
xano workspace push
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
xano workspace git pull
|
|
137
|
-
xano workspace git pull ./output -r https://github.com/owner/repo
|
|
138
|
-
xano workspace git pull
|
|
139
|
-
xano workspace git pull
|
|
140
|
-
xano workspace git pull
|
|
141
|
-
xano workspace git pull
|
|
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
|
|
234
|
-
xano release pull ./my-release -r v1.0
|
|
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
|
|
238
|
-
xano release push ./my-release -n "v2.0"
|
|
239
|
-
xano release push
|
|
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
|
|
341
|
-
xano tenant pull ./my-tenant -t <tenant_name>
|
|
342
|
-
xano tenant pull
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
xano tenant push
|
|
347
|
-
xano tenant push ./my-tenant -t <tenant_name>
|
|
348
|
-
xano tenant push
|
|
349
|
-
xano tenant push
|
|
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
|
-
#
|
|
461
|
-
xano sandbox
|
|
462
|
-
xano sandbox pull ./my-
|
|
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
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import BaseCommand from '../../../base-command.js';
|
|
2
2
|
export default class ReleasePull extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
3
|
static description: string;
|
|
7
4
|
static examples: string[];
|
|
8
5
|
static flags: {
|
|
6
|
+
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
7
|
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
8
|
records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
9
|
release: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
2
|
import * as yaml from 'js-yaml';
|
|
3
3
|
import * as fs from 'node:fs';
|
|
4
4
|
import * as path from 'node:path';
|
|
@@ -6,26 +6,29 @@ import snakeCase from 'lodash.snakecase';
|
|
|
6
6
|
import BaseCommand from '../../../base-command.js';
|
|
7
7
|
import { buildApiGroupFolderResolver, parseDocument } from '../../../utils/document-parser.js';
|
|
8
8
|
export default class ReleasePull extends BaseCommand {
|
|
9
|
-
static args = {
|
|
10
|
-
directory: Args.string({
|
|
11
|
-
description: 'Output directory for pulled documents',
|
|
12
|
-
required: true,
|
|
13
|
-
}),
|
|
14
|
-
};
|
|
15
9
|
static description = 'Pull a release multidoc from the Xano Metadata API and split into individual files';
|
|
16
10
|
static examples = [
|
|
17
|
-
`$ xano release pull
|
|
11
|
+
`$ xano release pull -r v1.0
|
|
12
|
+
Pulled 42 documents from release 'v1.0' to current directory
|
|
13
|
+
`,
|
|
14
|
+
`$ xano release pull -d ./my-release -r v1.0
|
|
18
15
|
Pulled 42 documents from release 'v1.0' to ./my-release
|
|
19
16
|
`,
|
|
20
|
-
`$ xano release pull ./output -r v1.0 -w 40
|
|
17
|
+
`$ xano release pull -d ./output -r v1.0 -w 40
|
|
21
18
|
Pulled 15 documents from release 'v1.0' to ./output
|
|
22
19
|
`,
|
|
23
|
-
`$ xano release pull
|
|
24
|
-
Pulled 58 documents from release 'v1.0'
|
|
20
|
+
`$ xano release pull -r v1.0 --profile production --env --records
|
|
21
|
+
Pulled 58 documents from release 'v1.0'
|
|
25
22
|
`,
|
|
26
23
|
];
|
|
27
24
|
static flags = {
|
|
28
25
|
...BaseCommand.baseFlags,
|
|
26
|
+
directory: Flags.string({
|
|
27
|
+
char: 'd',
|
|
28
|
+
default: '.',
|
|
29
|
+
description: 'Output directory for pulled documents (defaults to current directory)',
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
29
32
|
env: Flags.boolean({
|
|
30
33
|
default: false,
|
|
31
34
|
description: 'Include environment variables',
|
|
@@ -48,7 +51,7 @@ Pulled 58 documents from release 'v1.0' to ./backup
|
|
|
48
51
|
}),
|
|
49
52
|
};
|
|
50
53
|
async run() {
|
|
51
|
-
const {
|
|
54
|
+
const { flags } = await this.parse(ReleasePull);
|
|
52
55
|
// Get profile name (default or from flag/env)
|
|
53
56
|
const profileName = flags.profile || this.getDefaultProfile();
|
|
54
57
|
// Load credentials
|
|
@@ -76,7 +79,7 @@ Pulled 58 documents from release 'v1.0' to ./backup
|
|
|
76
79
|
}
|
|
77
80
|
else {
|
|
78
81
|
this.error(`Workspace ID is required. Either:\n` +
|
|
79
|
-
` 1. Provide it as a flag: xano release pull
|
|
82
|
+
` 1. Provide it as a flag: xano release pull -r <release_name> -w <workspace_id>\n` +
|
|
80
83
|
` 2. Set it in your profile using: xano profile:edit ${profileName} -w <workspace_id>`);
|
|
81
84
|
}
|
|
82
85
|
const releaseName = flags.release;
|
|
@@ -132,7 +135,7 @@ Pulled 58 documents from release 'v1.0' to ./backup
|
|
|
132
135
|
return;
|
|
133
136
|
}
|
|
134
137
|
// Resolve the output directory
|
|
135
|
-
const outputDir = path.resolve(
|
|
138
|
+
const outputDir = path.resolve(flags.directory);
|
|
136
139
|
// Create the output directory if it doesn't exist
|
|
137
140
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
138
141
|
// Resolve api_group names to unique folder names, disambiguating collisions
|
|
@@ -238,7 +241,7 @@ Pulled 58 documents from release 'v1.0' to ./backup
|
|
|
238
241
|
fs.writeFileSync(filePath, doc.content, 'utf8');
|
|
239
242
|
writtenCount++;
|
|
240
243
|
}
|
|
241
|
-
this.log(`Pulled ${writtenCount} documents from release '${releaseName}' to ${
|
|
244
|
+
this.log(`Pulled ${writtenCount} documents from release '${releaseName}' to ${flags.directory}`);
|
|
242
245
|
}
|
|
243
246
|
loadCredentials() {
|
|
244
247
|
const credentialsPath = this.getCredentialsPath();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import BaseCommand from '../../../base-command.js';
|
|
2
2
|
export default class ReleasePush extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
3
|
static description: string;
|
|
7
4
|
static examples: string[];
|
|
8
5
|
static flags: {
|
|
9
6
|
description: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
8
|
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
9
|
hotfix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
10
|
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
2
|
import * as yaml from 'js-yaml';
|
|
3
3
|
import * as fs from 'node:fs';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
5
|
import BaseCommand from '../../../base-command.js';
|
|
6
6
|
import { findFilesWithGuid } from '../../../utils/document-parser.js';
|
|
7
7
|
export default class ReleasePush extends BaseCommand {
|
|
8
|
-
static args = {
|
|
9
|
-
directory: Args.string({
|
|
10
|
-
description: 'Directory containing .xs documents to create the release from',
|
|
11
|
-
required: true,
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
8
|
static description = 'Create a new release from local XanoScript files via the multidoc endpoint';
|
|
15
9
|
static examples = [
|
|
16
|
-
`$ xano release push
|
|
17
|
-
Created release: v1.0 - ID: 10
|
|
10
|
+
`$ xano release push -n "v1.0"
|
|
11
|
+
Created release: v1.0 - ID: 10 (from current directory)
|
|
18
12
|
`,
|
|
19
|
-
`$ xano release push ./output -n "v2.0" -w 40
|
|
13
|
+
`$ xano release push -d ./output -n "v2.0" -w 40 --description "Major update"
|
|
20
14
|
Created release: v2.0 - ID: 15
|
|
21
15
|
`,
|
|
22
|
-
`$ xano release push ./backup -n "v1.1-hotfix" --hotfix --profile production
|
|
16
|
+
`$ xano release push -d ./backup -n "v1.1-hotfix" --hotfix --profile production
|
|
23
17
|
Created release: v1.1-hotfix - ID: 20
|
|
24
18
|
`,
|
|
25
|
-
`$ xano release push
|
|
19
|
+
`$ xano release push -n "v1.0" --no-records --no-env
|
|
26
20
|
Create release from schema only, skip records and environment variables
|
|
27
21
|
`,
|
|
28
|
-
`$ xano release push
|
|
22
|
+
`$ xano release push -n "v1.0" -o json
|
|
29
23
|
Output release details as JSON
|
|
30
24
|
`,
|
|
31
25
|
];
|
|
32
26
|
static flags = {
|
|
33
27
|
...BaseCommand.baseFlags,
|
|
34
28
|
description: Flags.string({
|
|
35
|
-
char: 'd',
|
|
36
29
|
default: '',
|
|
37
30
|
description: 'Release description',
|
|
38
31
|
required: false,
|
|
39
32
|
}),
|
|
33
|
+
directory: Flags.string({
|
|
34
|
+
char: 'd',
|
|
35
|
+
default: '.',
|
|
36
|
+
description: 'Directory containing .xs documents to create the release from (defaults to current directory)',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
40
39
|
env: Flags.boolean({
|
|
41
40
|
allowNo: true,
|
|
42
41
|
default: true,
|
|
@@ -73,7 +72,7 @@ Output release details as JSON
|
|
|
73
72
|
}),
|
|
74
73
|
};
|
|
75
74
|
async run() {
|
|
76
|
-
const {
|
|
75
|
+
const { flags } = await this.parse(ReleasePush);
|
|
77
76
|
// Get profile name (default or from flag/env)
|
|
78
77
|
const profileName = flags.profile || this.getDefaultProfile();
|
|
79
78
|
// Load credentials
|
|
@@ -101,11 +100,11 @@ Output release details as JSON
|
|
|
101
100
|
}
|
|
102
101
|
else {
|
|
103
102
|
this.error(`Workspace ID is required. Either:\n` +
|
|
104
|
-
` 1. Provide it as a flag: xano release push
|
|
103
|
+
` 1. Provide it as a flag: xano release push -n <name> -w <workspace_id>\n` +
|
|
105
104
|
` 2. Set it in your profile using: xano profile:edit ${profileName} -w <workspace_id>`);
|
|
106
105
|
}
|
|
107
106
|
// Resolve the input directory
|
|
108
|
-
const inputDir = path.resolve(
|
|
107
|
+
const inputDir = path.resolve(flags.directory);
|
|
109
108
|
if (!fs.existsSync(inputDir)) {
|
|
110
109
|
this.error(`Directory not found: ${inputDir}`);
|
|
111
110
|
}
|
|
@@ -115,7 +114,7 @@ Output release details as JSON
|
|
|
115
114
|
// Collect all .xs files from the directory tree
|
|
116
115
|
const files = this.collectFiles(inputDir);
|
|
117
116
|
if (files.length === 0) {
|
|
118
|
-
this.error(`No .xs files found in ${
|
|
117
|
+
this.error(`No .xs files found in ${flags.directory}`);
|
|
119
118
|
}
|
|
120
119
|
// Read each file and track file path alongside content
|
|
121
120
|
const documentEntries = [];
|
|
@@ -126,7 +125,7 @@ Output release details as JSON
|
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
if (documentEntries.length === 0) {
|
|
129
|
-
this.error(`All .xs files in ${
|
|
128
|
+
this.error(`All .xs files in ${flags.directory} are empty`);
|
|
130
129
|
}
|
|
131
130
|
const multidoc = documentEntries.map((d) => d.content).join('\n---\n');
|
|
132
131
|
// Construct the API URL with query params
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import BaseCommand from '../../../base-command.js';
|
|
2
2
|
export default class SandboxPull extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
3
|
static description: string;
|
|
7
4
|
static examples: string[];
|
|
8
5
|
static flags: {
|
|
6
|
+
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
7
|
draft: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
8
|
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
9
|
records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
2
|
import snakeCase from 'lodash.snakecase';
|
|
3
3
|
import BaseCommand from '../../../base-command.js';
|
|
4
4
|
import { buildApiGroupFolderResolver, parseDocument } from '../../../utils/document-parser.js';
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
export default class SandboxPull extends BaseCommand {
|
|
8
|
-
static args = {
|
|
9
|
-
directory: Args.string({
|
|
10
|
-
description: 'Output directory for pulled documents',
|
|
11
|
-
required: true,
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
8
|
static description = 'Pull documents from your sandbox environment and split into individual files';
|
|
15
9
|
static examples = [
|
|
16
|
-
`$ xano sandbox pull
|
|
10
|
+
`$ xano sandbox pull
|
|
11
|
+
Pulled 42 documents from sandbox environment to current directory
|
|
12
|
+
`,
|
|
13
|
+
`$ xano sandbox pull -d ./my-sandbox
|
|
17
14
|
Pulled 42 documents from sandbox environment to ./my-sandbox
|
|
18
15
|
`,
|
|
19
|
-
`$ xano sandbox pull
|
|
16
|
+
`$ xano sandbox pull --env --records`,
|
|
20
17
|
];
|
|
21
18
|
static flags = {
|
|
22
19
|
...BaseCommand.baseFlags,
|
|
20
|
+
directory: Flags.string({
|
|
21
|
+
char: 'd',
|
|
22
|
+
default: '.',
|
|
23
|
+
description: 'Output directory for pulled documents (defaults to current directory)',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
23
26
|
draft: Flags.boolean({
|
|
24
27
|
default: false,
|
|
25
28
|
description: 'Include draft versions',
|
|
@@ -37,7 +40,7 @@ Pulled 42 documents from sandbox environment to ./my-sandbox
|
|
|
37
40
|
}),
|
|
38
41
|
};
|
|
39
42
|
async run() {
|
|
40
|
-
const {
|
|
43
|
+
const { flags } = await this.parse(SandboxPull);
|
|
41
44
|
const { profile } = this.resolveProfile(flags);
|
|
42
45
|
const queryParams = new URLSearchParams({
|
|
43
46
|
env: flags.env.toString(),
|
|
@@ -86,7 +89,7 @@ Pulled 42 documents from sandbox environment to ./my-sandbox
|
|
|
86
89
|
this.log('No documents found in response');
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
89
|
-
const outputDir = path.resolve(
|
|
92
|
+
const outputDir = path.resolve(flags.directory);
|
|
90
93
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
91
94
|
const getApiGroupFolder = buildApiGroupFolderResolver(documents, snakeCase);
|
|
92
95
|
const filenameCounters = new Map();
|
|
@@ -174,7 +177,7 @@ Pulled 42 documents from sandbox environment to ./my-sandbox
|
|
|
174
177
|
fs.writeFileSync(filePath, doc.content, 'utf8');
|
|
175
178
|
writtenCount++;
|
|
176
179
|
}
|
|
177
|
-
this.log(`Pulled ${writtenCount} documents from sandbox environment to ${
|
|
180
|
+
this.log(`Pulled ${writtenCount} documents from sandbox environment to ${flags.directory}`);
|
|
178
181
|
}
|
|
179
182
|
sanitizeFilename(name) {
|
|
180
183
|
return snakeCase(name.replaceAll('"', ''));
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import BaseCommand from '../../../base-command.js';
|
|
2
2
|
export default class SandboxPush extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
3
|
static description: string;
|
|
7
4
|
static examples: string[];
|
|
8
5
|
static flags: {
|
|
6
|
+
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
exclude: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
guids: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
include: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
14
|
records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
review: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
sync: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
17
|
transaction: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
18
|
truncate: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
19
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -15,7 +21,6 @@ export default class SandboxPush extends BaseCommand {
|
|
|
15
21
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
22
|
};
|
|
17
23
|
run(): Promise<void>;
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private renderBadReferences;
|
|
24
|
+
private openReview;
|
|
25
|
+
private getFrontendUrl;
|
|
21
26
|
}
|