@xano/cli 0.0.95-beta.3 → 0.0.95
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 +2 -27
- package/dist/base-command.d.ts +0 -24
- package/dist/base-command.js +0 -37
- package/dist/commands/tenant/create/index.d.ts +3 -1
- package/dist/commands/tenant/create/index.js +28 -6
- package/dist/commands/tenant/get/index.js +2 -2
- package/dist/commands/tenant/list/index.js +2 -2
- package/dist/commands/tenant/push/index.js +34 -0
- package/dist/commands/workspace/push/index.js +0 -26
- package/dist/help.d.ts +1 -2
- package/dist/help.js +1 -39
- package/oclif.manifest.json +2059 -4455
- package/package.json +1 -16
- package/dist/commands/release/deploy/index.d.ts +0 -17
- package/dist/commands/release/deploy/index.js +0 -107
- package/dist/commands/sandbox/env/delete/index.d.ts +0 -14
- package/dist/commands/sandbox/env/delete/index.js +0 -89
- package/dist/commands/sandbox/env/get/index.d.ts +0 -12
- package/dist/commands/sandbox/env/get/index.js +0 -65
- package/dist/commands/sandbox/env/get_all/index.d.ts +0 -13
- package/dist/commands/sandbox/env/get_all/index.js +0 -78
- package/dist/commands/sandbox/env/list/index.d.ts +0 -11
- package/dist/commands/sandbox/env/list/index.js +0 -67
- package/dist/commands/sandbox/env/set/index.d.ts +0 -13
- package/dist/commands/sandbox/env/set/index.js +0 -74
- package/dist/commands/sandbox/env/set_all/index.d.ts +0 -13
- package/dist/commands/sandbox/env/set_all/index.js +0 -86
- package/dist/commands/sandbox/get/index.d.ts +0 -11
- package/dist/commands/sandbox/get/index.js +0 -48
- package/dist/commands/sandbox/impersonate/index.d.ts +0 -5
- package/dist/commands/sandbox/impersonate/index.js +0 -5
- package/dist/commands/sandbox/license/get/index.d.ts +0 -13
- package/dist/commands/sandbox/license/get/index.js +0 -78
- package/dist/commands/sandbox/license/set/index.d.ts +0 -14
- package/dist/commands/sandbox/license/set/index.js +0 -95
- package/dist/commands/sandbox/pull/index.d.ts +0 -17
- package/dist/commands/sandbox/pull/index.js +0 -182
- package/dist/commands/sandbox/push/index.d.ts +0 -18
- package/dist/commands/sandbox/push/index.js +0 -143
- package/dist/commands/sandbox/reset/index.d.ts +0 -12
- package/dist/commands/sandbox/reset/index.js +0 -71
- package/dist/commands/sandbox/review/index.d.ts +0 -13
- package/dist/commands/sandbox/review/index.js +0 -94
- package/dist/commands/sandbox/unit_test/list/index.d.ts +0 -13
- package/dist/commands/sandbox/unit_test/list/index.js +0 -91
- package/dist/commands/sandbox/unit_test/run/index.d.ts +0 -14
- package/dist/commands/sandbox/unit_test/run/index.js +0 -79
- package/dist/commands/sandbox/unit_test/run_all/index.d.ts +0 -13
- package/dist/commands/sandbox/unit_test/run_all/index.js +0 -169
- package/dist/commands/sandbox/workflow_test/delete/index.d.ts +0 -17
- package/dist/commands/sandbox/workflow_test/delete/index.js +0 -61
- package/dist/commands/sandbox/workflow_test/get/index.d.ts +0 -17
- package/dist/commands/sandbox/workflow_test/get/index.js +0 -60
- package/dist/commands/sandbox/workflow_test/list/index.d.ts +0 -12
- package/dist/commands/sandbox/workflow_test/list/index.js +0 -84
- package/dist/commands/sandbox/workflow_test/run/index.d.ts +0 -17
- package/dist/commands/sandbox/workflow_test/run/index.js +0 -77
- package/dist/commands/sandbox/workflow_test/run_all/index.d.ts +0 -12
- package/dist/commands/sandbox/workflow_test/run_all/index.js +0 -155
- package/dist/commands/tenant/unit_test/list/index.d.ts +0 -15
- package/dist/commands/tenant/unit_test/list/index.js +0 -140
- package/dist/commands/tenant/unit_test/run/index.d.ts +0 -16
- package/dist/commands/tenant/unit_test/run/index.js +0 -128
- package/dist/commands/tenant/unit_test/run_all/index.d.ts +0 -15
- package/dist/commands/tenant/unit_test/run_all/index.js +0 -215
- package/dist/commands/tenant/workflow_test/delete/index.d.ts +0 -19
- package/dist/commands/tenant/workflow_test/delete/index.js +0 -110
- package/dist/commands/tenant/workflow_test/get/index.d.ts +0 -19
- package/dist/commands/tenant/workflow_test/get/index.js +0 -112
- package/dist/commands/tenant/workflow_test/list/index.d.ts +0 -14
- package/dist/commands/tenant/workflow_test/list/index.js +0 -133
- package/dist/commands/tenant/workflow_test/run/index.d.ts +0 -19
- package/dist/commands/tenant/workflow_test/run/index.js +0 -126
- package/dist/commands/tenant/workflow_test/run_all/index.d.ts +0 -14
- package/dist/commands/tenant/workflow_test/run_all/index.js +0 -201
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import * as yaml from 'js-yaml';
|
|
3
|
-
import * as fs from 'node:fs';
|
|
4
|
-
import * as path from 'node:path';
|
|
5
|
-
import BaseCommand from '../../../../base-command.js';
|
|
6
|
-
export default class SandboxEnvSetAll extends BaseCommand {
|
|
7
|
-
static description = 'Set all environment variables for a sandbox environment from a YAML file (replaces all existing)';
|
|
8
|
-
static examples = [
|
|
9
|
-
`$ xano sandbox env set_all
|
|
10
|
-
Reads from env_<tenant>.yaml
|
|
11
|
-
`,
|
|
12
|
-
`$ xano sandbox env set_all --file ./my-env.yaml`,
|
|
13
|
-
`$ xano sandbox env set_all -o json`,
|
|
14
|
-
];
|
|
15
|
-
static flags = {
|
|
16
|
-
...BaseCommand.baseFlags,
|
|
17
|
-
clean: Flags.boolean({
|
|
18
|
-
default: false,
|
|
19
|
-
description: 'Remove the source file after successful upload',
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
file: Flags.string({
|
|
23
|
-
char: 'f',
|
|
24
|
-
description: 'Path to env file (default: env_<sandbox_name>.yaml)',
|
|
25
|
-
required: false,
|
|
26
|
-
}),
|
|
27
|
-
output: Flags.string({
|
|
28
|
-
char: 'o',
|
|
29
|
-
default: 'summary',
|
|
30
|
-
description: 'Output format',
|
|
31
|
-
options: ['summary', 'json'],
|
|
32
|
-
required: false,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
async run() {
|
|
36
|
-
const { flags } = await this.parse(SandboxEnvSetAll);
|
|
37
|
-
const { profile } = this.resolveProfile(flags);
|
|
38
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
39
|
-
const tenantName = tenant.name;
|
|
40
|
-
const sourceFilePath = path.resolve(flags.file || `env_${tenantName}.yaml`);
|
|
41
|
-
if (!fs.existsSync(sourceFilePath)) {
|
|
42
|
-
this.error(`File not found: ${sourceFilePath}`);
|
|
43
|
-
}
|
|
44
|
-
const fileContent = fs.readFileSync(sourceFilePath, 'utf8');
|
|
45
|
-
const envMap = yaml.load(fileContent);
|
|
46
|
-
if (!envMap || typeof envMap !== 'object') {
|
|
47
|
-
this.error('Invalid env file format. Expected a YAML map of key: value pairs.');
|
|
48
|
-
}
|
|
49
|
-
const envs = Object.entries(envMap).map(([name, value]) => ({ name, value: String(value) }));
|
|
50
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/env_all`;
|
|
51
|
-
try {
|
|
52
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
53
|
-
body: JSON.stringify({ envs }),
|
|
54
|
-
headers: {
|
|
55
|
-
accept: 'application/json',
|
|
56
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
57
|
-
'Content-Type': 'application/json',
|
|
58
|
-
},
|
|
59
|
-
method: 'PUT',
|
|
60
|
-
}, flags.verbose, profile.access_token);
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const errorText = await response.text();
|
|
63
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
64
|
-
}
|
|
65
|
-
if (flags.output === 'json') {
|
|
66
|
-
const result = await response.json();
|
|
67
|
-
this.log(JSON.stringify(result, null, 2));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.log(`All environment variables updated for sandbox environment ${tenantName} (${envs.length} variables)`);
|
|
71
|
-
}
|
|
72
|
-
if (flags.clean && fs.existsSync(sourceFilePath)) {
|
|
73
|
-
fs.unlinkSync(sourceFilePath);
|
|
74
|
-
this.log(`Removed ${sourceFilePath}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
if (error instanceof Error) {
|
|
79
|
-
this.error(`Failed to set sandbox environment variables: ${error.message}`);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.error(`Failed to set sandbox environment variables: ${String(error)}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../base-command.js';
|
|
2
|
-
export default class SandboxGet extends BaseCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import BaseCommand from '../../../base-command.js';
|
|
3
|
-
export default class SandboxGet extends BaseCommand {
|
|
4
|
-
static description = 'Get your sandbox environment (creates one if it does not exist)';
|
|
5
|
-
static examples = [
|
|
6
|
-
`$ xano sandbox get
|
|
7
|
-
Sandbox Environment: (tc24-abcd-x1y2)
|
|
8
|
-
State: ok
|
|
9
|
-
License: tier1
|
|
10
|
-
`,
|
|
11
|
-
`$ xano sandbox get -o json`,
|
|
12
|
-
];
|
|
13
|
-
static flags = {
|
|
14
|
-
...BaseCommand.baseFlags,
|
|
15
|
-
output: Flags.string({
|
|
16
|
-
char: 'o',
|
|
17
|
-
default: 'summary',
|
|
18
|
-
description: 'Output format',
|
|
19
|
-
options: ['summary', 'json'],
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
};
|
|
23
|
-
async run() {
|
|
24
|
-
const { flags } = await this.parse(SandboxGet);
|
|
25
|
-
const { profile } = this.resolveProfile(flags);
|
|
26
|
-
try {
|
|
27
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
28
|
-
if (flags.output === 'json') {
|
|
29
|
-
this.log(JSON.stringify(tenant, null, 2));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
this.log(`Sandbox Environment: ${tenant.display || tenant.name} (${tenant.name})`);
|
|
33
|
-
if (tenant.state)
|
|
34
|
-
this.log(` State: ${tenant.state}`);
|
|
35
|
-
if (tenant.xano_domain)
|
|
36
|
-
this.log(` Domain: ${tenant.xano_domain}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (error instanceof Error) {
|
|
41
|
-
this.error(`Failed to get sandbox environment: ${error.message}`);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.error(`Failed to get sandbox environment: ${String(error)}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../../base-command.js';
|
|
2
|
-
export default class SandboxLicenseGet extends BaseCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
view: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
};
|
|
12
|
-
run(): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import BaseCommand from '../../../../base-command.js';
|
|
5
|
-
export default class SandboxLicenseGet extends BaseCommand {
|
|
6
|
-
static description = 'Get the license for a sandbox environment';
|
|
7
|
-
static examples = [
|
|
8
|
-
`$ xano sandbox license get
|
|
9
|
-
License saved to license_<tenant>.yaml
|
|
10
|
-
`,
|
|
11
|
-
`$ xano sandbox license get --file ./my-license.yaml`,
|
|
12
|
-
`$ xano sandbox license get --view`,
|
|
13
|
-
`$ xano sandbox license get -o json`,
|
|
14
|
-
];
|
|
15
|
-
static flags = {
|
|
16
|
-
...BaseCommand.baseFlags,
|
|
17
|
-
file: Flags.string({
|
|
18
|
-
char: 'f',
|
|
19
|
-
description: 'Output file path (default: license_<sandbox_name>.yaml)',
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
output: Flags.string({
|
|
23
|
-
char: 'o',
|
|
24
|
-
default: 'summary',
|
|
25
|
-
description: 'Output format',
|
|
26
|
-
options: ['summary', 'json'],
|
|
27
|
-
required: false,
|
|
28
|
-
}),
|
|
29
|
-
view: Flags.boolean({
|
|
30
|
-
default: false,
|
|
31
|
-
description: 'Print license to stdout instead of saving to file',
|
|
32
|
-
required: false,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
async run() {
|
|
36
|
-
const { flags } = await this.parse(SandboxLicenseGet);
|
|
37
|
-
const { profile } = this.resolveProfile(flags);
|
|
38
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
39
|
-
const tenantName = tenant.name;
|
|
40
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/license`;
|
|
41
|
-
try {
|
|
42
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
43
|
-
headers: {
|
|
44
|
-
accept: 'application/json',
|
|
45
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
46
|
-
},
|
|
47
|
-
method: 'GET',
|
|
48
|
-
}, flags.verbose, profile.access_token);
|
|
49
|
-
if (!response.ok) {
|
|
50
|
-
const errorText = await response.text();
|
|
51
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
52
|
-
}
|
|
53
|
-
const license = await response.json();
|
|
54
|
-
const licenseContent = typeof license === 'string' ? license : JSON.stringify(license, null, 2);
|
|
55
|
-
if (flags.view || flags.output === 'json') {
|
|
56
|
-
if (flags.output === 'json') {
|
|
57
|
-
this.log(JSON.stringify(license, null, 2));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
this.log(licenseContent);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const filePath = path.resolve(flags.file || `license_${tenantName}.yaml`);
|
|
65
|
-
fs.writeFileSync(filePath, licenseContent, 'utf8');
|
|
66
|
-
this.log(`License saved to ${filePath}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error instanceof Error) {
|
|
71
|
-
this.error(`Failed to get sandbox environment license: ${error.message}`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
this.error(`Failed to get sandbox environment license: ${String(error)}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../../base-command.js';
|
|
2
|
-
export default class SandboxLicenseSet extends BaseCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
clean: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
value: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
};
|
|
13
|
-
run(): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import BaseCommand from '../../../../base-command.js';
|
|
5
|
-
export default class SandboxLicenseSet extends BaseCommand {
|
|
6
|
-
static description = 'Set/update the license for a sandbox environment';
|
|
7
|
-
static examples = [
|
|
8
|
-
`$ xano sandbox license set
|
|
9
|
-
Reads from license_<tenant>.yaml
|
|
10
|
-
`,
|
|
11
|
-
`$ xano sandbox license set --file ./license.yaml`,
|
|
12
|
-
`$ xano sandbox license set --value 'key: value'`,
|
|
13
|
-
`$ xano sandbox license set -o json`,
|
|
14
|
-
];
|
|
15
|
-
static flags = {
|
|
16
|
-
...BaseCommand.baseFlags,
|
|
17
|
-
clean: Flags.boolean({
|
|
18
|
-
default: false,
|
|
19
|
-
description: 'Remove the source file after successful upload',
|
|
20
|
-
exclusive: ['value'],
|
|
21
|
-
required: false,
|
|
22
|
-
}),
|
|
23
|
-
file: Flags.string({
|
|
24
|
-
char: 'f',
|
|
25
|
-
description: 'Path to license file (default: license_<sandbox_name>.yaml)',
|
|
26
|
-
exclusive: ['value'],
|
|
27
|
-
required: false,
|
|
28
|
-
}),
|
|
29
|
-
output: Flags.string({
|
|
30
|
-
char: 'o',
|
|
31
|
-
default: 'summary',
|
|
32
|
-
description: 'Output format',
|
|
33
|
-
options: ['summary', 'json'],
|
|
34
|
-
required: false,
|
|
35
|
-
}),
|
|
36
|
-
value: Flags.string({
|
|
37
|
-
description: 'Inline license value',
|
|
38
|
-
exclusive: ['file', 'clean'],
|
|
39
|
-
required: false,
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
async run() {
|
|
43
|
-
const { flags } = await this.parse(SandboxLicenseSet);
|
|
44
|
-
const { profile } = this.resolveProfile(flags);
|
|
45
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
46
|
-
const tenantName = tenant.name;
|
|
47
|
-
let licenseValue;
|
|
48
|
-
let sourceFilePath;
|
|
49
|
-
if (flags.value) {
|
|
50
|
-
licenseValue = flags.value;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
sourceFilePath = path.resolve(flags.file || `license_${tenantName}.yaml`);
|
|
54
|
-
if (!fs.existsSync(sourceFilePath)) {
|
|
55
|
-
this.error(`File not found: ${sourceFilePath}`);
|
|
56
|
-
}
|
|
57
|
-
licenseValue = fs.readFileSync(sourceFilePath, 'utf8');
|
|
58
|
-
}
|
|
59
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/license`;
|
|
60
|
-
try {
|
|
61
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
62
|
-
body: JSON.stringify({ value: licenseValue }),
|
|
63
|
-
headers: {
|
|
64
|
-
accept: 'application/json',
|
|
65
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
66
|
-
'Content-Type': 'application/json',
|
|
67
|
-
},
|
|
68
|
-
method: 'POST',
|
|
69
|
-
}, flags.verbose, profile.access_token);
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
const errorText = await response.text();
|
|
72
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
73
|
-
}
|
|
74
|
-
const result = await response.json();
|
|
75
|
-
if (flags.output === 'json') {
|
|
76
|
-
this.log(JSON.stringify(result, null, 2));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.log(`Sandbox environment license updated successfully for ${tenantName}`);
|
|
80
|
-
}
|
|
81
|
-
if (flags.clean && sourceFilePath && fs.existsSync(sourceFilePath)) {
|
|
82
|
-
fs.unlinkSync(sourceFilePath);
|
|
83
|
-
this.log(`Removed ${sourceFilePath}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
if (error instanceof Error) {
|
|
88
|
-
this.error(`Failed to set sandbox environment license: ${error.message}`);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
this.error(`Failed to set sandbox environment license: ${String(error)}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../base-command.js';
|
|
2
|
-
export default class SandboxPull extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
draft: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
-
};
|
|
15
|
-
run(): Promise<void>;
|
|
16
|
-
private sanitizeFilename;
|
|
17
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import snakeCase from 'lodash.snakecase';
|
|
3
|
-
import BaseCommand from '../../../base-command.js';
|
|
4
|
-
import { buildApiGroupFolderResolver, parseDocument } from '../../../utils/document-parser.js';
|
|
5
|
-
import * as fs from 'node:fs';
|
|
6
|
-
import * as path from 'node:path';
|
|
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
|
-
static description = 'Pull documents from your sandbox environment and split into individual files';
|
|
15
|
-
static examples = [
|
|
16
|
-
`$ xano sandbox pull ./my-sandbox
|
|
17
|
-
Pulled 42 documents from sandbox environment tc24-abcd-x1y2 to ./my-sandbox
|
|
18
|
-
`,
|
|
19
|
-
`$ xano sandbox pull ./backup --env --records`,
|
|
20
|
-
];
|
|
21
|
-
static flags = {
|
|
22
|
-
...BaseCommand.baseFlags,
|
|
23
|
-
draft: Flags.boolean({
|
|
24
|
-
default: false,
|
|
25
|
-
description: 'Include draft versions',
|
|
26
|
-
required: false,
|
|
27
|
-
}),
|
|
28
|
-
env: Flags.boolean({
|
|
29
|
-
default: false,
|
|
30
|
-
description: 'Include environment variables',
|
|
31
|
-
required: false,
|
|
32
|
-
}),
|
|
33
|
-
records: Flags.boolean({
|
|
34
|
-
default: false,
|
|
35
|
-
description: 'Include records',
|
|
36
|
-
required: false,
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
async run() {
|
|
40
|
-
const { args, flags } = await this.parse(SandboxPull);
|
|
41
|
-
const { profile } = this.resolveProfile(flags);
|
|
42
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
43
|
-
const tenantName = tenant.name;
|
|
44
|
-
const queryParams = new URLSearchParams({
|
|
45
|
-
env: flags.env.toString(),
|
|
46
|
-
include_draft: flags.draft.toString(),
|
|
47
|
-
records: flags.records.toString(),
|
|
48
|
-
});
|
|
49
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/multidoc?${queryParams.toString()}`;
|
|
50
|
-
let responseText;
|
|
51
|
-
try {
|
|
52
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
53
|
-
headers: {
|
|
54
|
-
accept: 'application/json',
|
|
55
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
56
|
-
},
|
|
57
|
-
method: 'GET',
|
|
58
|
-
}, flags.verbose, profile.access_token);
|
|
59
|
-
if (!response.ok) {
|
|
60
|
-
const errorText = await response.text();
|
|
61
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
62
|
-
}
|
|
63
|
-
responseText = await response.text();
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
if (error instanceof Error) {
|
|
67
|
-
this.error(`Failed to fetch multidoc: ${error.message}`);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.error(`Failed to fetch multidoc: ${String(error)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const rawDocuments = responseText.split('\n---\n');
|
|
74
|
-
const documents = [];
|
|
75
|
-
for (const raw of rawDocuments) {
|
|
76
|
-
const trimmed = raw.trim();
|
|
77
|
-
if (!trimmed) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const parsed = parseDocument(trimmed);
|
|
81
|
-
if (parsed) {
|
|
82
|
-
documents.push(parsed);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (documents.length === 0) {
|
|
86
|
-
this.log('No documents found in response');
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const outputDir = path.resolve(args.directory);
|
|
90
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
91
|
-
const getApiGroupFolder = buildApiGroupFolderResolver(documents, snakeCase);
|
|
92
|
-
const filenameCounters = new Map();
|
|
93
|
-
let writtenCount = 0;
|
|
94
|
-
for (const doc of documents) {
|
|
95
|
-
let typeDir;
|
|
96
|
-
let baseName;
|
|
97
|
-
if (doc.type === 'workspace') {
|
|
98
|
-
typeDir = path.join(outputDir, 'workspace');
|
|
99
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
100
|
-
}
|
|
101
|
-
else if (doc.type === 'workspace_trigger') {
|
|
102
|
-
typeDir = path.join(outputDir, 'workspace', 'trigger');
|
|
103
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
104
|
-
}
|
|
105
|
-
else if (doc.type === 'agent') {
|
|
106
|
-
typeDir = path.join(outputDir, 'ai', 'agent');
|
|
107
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
108
|
-
}
|
|
109
|
-
else if (doc.type === 'mcp_server') {
|
|
110
|
-
typeDir = path.join(outputDir, 'ai', 'mcp_server');
|
|
111
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
112
|
-
}
|
|
113
|
-
else if (doc.type === 'tool') {
|
|
114
|
-
typeDir = path.join(outputDir, 'ai', 'tool');
|
|
115
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
116
|
-
}
|
|
117
|
-
else if (doc.type === 'agent_trigger') {
|
|
118
|
-
typeDir = path.join(outputDir, 'ai', 'agent', 'trigger');
|
|
119
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
120
|
-
}
|
|
121
|
-
else if (doc.type === 'mcp_server_trigger') {
|
|
122
|
-
typeDir = path.join(outputDir, 'ai', 'mcp_server', 'trigger');
|
|
123
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
124
|
-
}
|
|
125
|
-
else if (doc.type === 'table_trigger') {
|
|
126
|
-
typeDir = path.join(outputDir, 'table', 'trigger');
|
|
127
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
128
|
-
}
|
|
129
|
-
else if (doc.type === 'realtime_channel') {
|
|
130
|
-
typeDir = path.join(outputDir, 'realtime', 'channel');
|
|
131
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
132
|
-
}
|
|
133
|
-
else if (doc.type === 'realtime_trigger') {
|
|
134
|
-
typeDir = path.join(outputDir, 'realtime', 'trigger');
|
|
135
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
136
|
-
}
|
|
137
|
-
else if (doc.type === 'api_group') {
|
|
138
|
-
const groupFolder = getApiGroupFolder(doc.name);
|
|
139
|
-
typeDir = path.join(outputDir, 'api', groupFolder);
|
|
140
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
141
|
-
}
|
|
142
|
-
else if (doc.type === 'query' && doc.apiGroup) {
|
|
143
|
-
const groupFolder = getApiGroupFolder(doc.apiGroup);
|
|
144
|
-
const nameParts = doc.name.split('/');
|
|
145
|
-
const leafName = nameParts.pop();
|
|
146
|
-
const folderParts = nameParts.map((part) => snakeCase(part));
|
|
147
|
-
typeDir = path.join(outputDir, 'api', groupFolder, ...folderParts);
|
|
148
|
-
baseName = this.sanitizeFilename(leafName);
|
|
149
|
-
if (doc.verb) {
|
|
150
|
-
baseName = `${baseName}_${doc.verb}`;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
const nameParts = doc.name.split('/');
|
|
155
|
-
const leafName = nameParts.pop();
|
|
156
|
-
const folderParts = nameParts.map((part) => snakeCase(part));
|
|
157
|
-
typeDir = path.join(outputDir, doc.type, ...folderParts);
|
|
158
|
-
baseName = this.sanitizeFilename(leafName);
|
|
159
|
-
if (doc.verb) {
|
|
160
|
-
baseName = `${baseName}_${doc.verb}`;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
fs.mkdirSync(typeDir, { recursive: true });
|
|
164
|
-
const dirKey = path.relative(outputDir, typeDir);
|
|
165
|
-
if (!filenameCounters.has(dirKey)) {
|
|
166
|
-
filenameCounters.set(dirKey, new Map());
|
|
167
|
-
}
|
|
168
|
-
const typeCounters = filenameCounters.get(dirKey);
|
|
169
|
-
const count = typeCounters.get(baseName) || 0;
|
|
170
|
-
typeCounters.set(baseName, count + 1);
|
|
171
|
-
let filename;
|
|
172
|
-
filename = count === 0 ? `${baseName}.xs` : `${baseName}_${count + 1}.xs`;
|
|
173
|
-
const filePath = path.join(typeDir, filename);
|
|
174
|
-
fs.writeFileSync(filePath, doc.content, 'utf8');
|
|
175
|
-
writtenCount++;
|
|
176
|
-
}
|
|
177
|
-
this.log(`Pulled ${writtenCount} documents from sandbox environment ${tenantName} to ${args.directory}`);
|
|
178
|
-
}
|
|
179
|
-
sanitizeFilename(name) {
|
|
180
|
-
return snakeCase(name.replaceAll('"', ''));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../base-command.js';
|
|
2
|
-
export default class SandboxPush extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
transaction: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
truncate: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
-
};
|
|
16
|
-
run(): Promise<void>;
|
|
17
|
-
private collectFiles;
|
|
18
|
-
}
|