@xano/cli 0.0.94 → 0.0.95-beta.10
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 +28 -1
- package/dist/base-command.d.ts +25 -0
- package/dist/base-command.js +37 -0
- package/dist/commands/auth/index.js +1 -1
- package/dist/commands/profile/create/index.js +2 -2
- package/dist/commands/profile/edit/index.js +2 -2
- package/dist/commands/profile/me/index.js +21 -2
- package/dist/commands/profile/wizard/index.js +3 -3
- package/dist/commands/profile/workspace/set/index.js +1 -1
- package/dist/commands/release/deploy/index.d.ts +17 -0
- package/dist/commands/release/deploy/index.js +107 -0
- package/dist/commands/sandbox/env/delete/index.d.ts +14 -0
- package/dist/commands/sandbox/env/delete/index.js +87 -0
- package/dist/commands/sandbox/env/get/index.d.ts +12 -0
- package/dist/commands/sandbox/env/get/index.js +63 -0
- package/dist/commands/sandbox/env/get_all/index.d.ts +13 -0
- package/dist/commands/sandbox/env/get_all/index.js +76 -0
- package/dist/commands/sandbox/env/list/index.d.ts +11 -0
- package/dist/commands/sandbox/env/list/index.js +65 -0
- package/dist/commands/sandbox/env/set/index.d.ts +13 -0
- package/dist/commands/sandbox/env/set/index.js +72 -0
- package/dist/commands/sandbox/env/set_all/index.d.ts +13 -0
- package/dist/commands/sandbox/env/set_all/index.js +84 -0
- package/dist/commands/sandbox/get/index.d.ts +11 -0
- package/dist/commands/sandbox/get/index.js +61 -0
- package/dist/commands/sandbox/impersonate/index.d.ts +5 -0
- package/dist/commands/sandbox/impersonate/index.js +5 -0
- package/dist/commands/sandbox/license/get/index.d.ts +13 -0
- package/dist/commands/sandbox/license/get/index.js +76 -0
- package/dist/commands/sandbox/license/set/index.d.ts +14 -0
- package/dist/commands/sandbox/license/set/index.js +93 -0
- package/dist/commands/sandbox/pull/index.d.ts +17 -0
- package/dist/commands/sandbox/pull/index.js +180 -0
- package/dist/commands/sandbox/push/index.d.ts +18 -0
- package/dist/commands/sandbox/push/index.js +141 -0
- package/dist/commands/sandbox/reset/index.d.ts +12 -0
- package/dist/commands/sandbox/reset/index.js +69 -0
- package/dist/commands/sandbox/review/index.d.ts +13 -0
- package/dist/commands/sandbox/review/index.js +92 -0
- package/dist/commands/sandbox/unit_test/list/index.d.ts +13 -0
- package/dist/commands/sandbox/unit_test/list/index.js +89 -0
- package/dist/commands/sandbox/unit_test/run/index.d.ts +14 -0
- package/dist/commands/sandbox/unit_test/run/index.js +77 -0
- package/dist/commands/sandbox/unit_test/run_all/index.d.ts +13 -0
- package/dist/commands/sandbox/unit_test/run_all/index.js +167 -0
- package/dist/commands/sandbox/workflow_test/delete/index.d.ts +17 -0
- package/dist/commands/sandbox/workflow_test/delete/index.js +59 -0
- package/dist/commands/sandbox/workflow_test/get/index.d.ts +17 -0
- package/dist/commands/sandbox/workflow_test/get/index.js +58 -0
- package/dist/commands/sandbox/workflow_test/list/index.d.ts +12 -0
- package/dist/commands/sandbox/workflow_test/list/index.js +82 -0
- package/dist/commands/sandbox/workflow_test/run/index.d.ts +17 -0
- package/dist/commands/sandbox/workflow_test/run/index.js +75 -0
- package/dist/commands/sandbox/workflow_test/run_all/index.d.ts +12 -0
- package/dist/commands/sandbox/workflow_test/run_all/index.js +153 -0
- package/dist/commands/tenant/create/index.d.ts +2 -2
- package/dist/commands/tenant/create/index.js +23 -11
- 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 +0 -34
- package/dist/commands/tenant/unit_test/list/index.d.ts +15 -0
- package/dist/commands/tenant/unit_test/list/index.js +140 -0
- package/dist/commands/tenant/unit_test/run/index.d.ts +16 -0
- package/dist/commands/tenant/unit_test/run/index.js +128 -0
- package/dist/commands/tenant/unit_test/run_all/index.d.ts +15 -0
- package/dist/commands/tenant/unit_test/run_all/index.js +215 -0
- package/dist/commands/tenant/workflow_test/delete/index.d.ts +19 -0
- package/dist/commands/tenant/workflow_test/delete/index.js +110 -0
- package/dist/commands/tenant/workflow_test/get/index.d.ts +19 -0
- package/dist/commands/tenant/workflow_test/get/index.js +112 -0
- package/dist/commands/tenant/workflow_test/list/index.d.ts +14 -0
- package/dist/commands/tenant/workflow_test/list/index.js +133 -0
- package/dist/commands/tenant/workflow_test/run/index.d.ts +19 -0
- package/dist/commands/tenant/workflow_test/run/index.js +126 -0
- package/dist/commands/tenant/workflow_test/run_all/index.d.ts +14 -0
- package/dist/commands/tenant/workflow_test/run_all/index.js +201 -0
- package/dist/commands/workspace/edit/index.d.ts +1 -0
- package/dist/commands/workspace/edit/index.js +16 -6
- package/dist/commands/workspace/get/index.js +9 -7
- package/dist/commands/workspace/list/index.d.ts +1 -0
- package/dist/commands/workspace/list/index.js +14 -7
- package/dist/commands/workspace/push/index.js +30 -2
- package/dist/help.d.ts +2 -1
- package/dist/help.js +39 -1
- package/oclif.manifest.json +4701 -2272
- package/package.json +17 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
export default class SandboxEnvList extends BaseCommand {
|
|
4
|
+
static description = 'List environment variable keys for a sandbox environment';
|
|
5
|
+
static examples = [
|
|
6
|
+
`$ xano sandbox env list
|
|
7
|
+
Environment variables for sandbox environment:
|
|
8
|
+
- DATABASE_URL
|
|
9
|
+
- API_KEY
|
|
10
|
+
`,
|
|
11
|
+
`$ xano sandbox env list -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(SandboxEnvList);
|
|
25
|
+
const { profile } = this.resolveProfile(flags);
|
|
26
|
+
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/env_key`;
|
|
27
|
+
try {
|
|
28
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
29
|
+
headers: {
|
|
30
|
+
accept: 'application/json',
|
|
31
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
32
|
+
},
|
|
33
|
+
method: 'GET',
|
|
34
|
+
}, flags.verbose, profile.access_token);
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const errorText = await response.text();
|
|
37
|
+
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
38
|
+
}
|
|
39
|
+
const data = (await response.json());
|
|
40
|
+
if (flags.output === 'json') {
|
|
41
|
+
this.log(JSON.stringify(data, null, 2));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const envVars = data.env || [];
|
|
45
|
+
if (envVars.length === 0) {
|
|
46
|
+
this.log(`No environment variables found for sandbox environment`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.log(`Environment variables for sandbox environment:`);
|
|
50
|
+
for (const envVar of envVars) {
|
|
51
|
+
this.log(` - ${envVar.name}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
this.error(`Failed to list sandbox environment variables: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.error(`Failed to list sandbox environment variables: ${String(error)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseCommand from '../../../../base-command.js';
|
|
2
|
+
export default class SandboxEnvSet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
value: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
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
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
export default class SandboxEnvSet extends BaseCommand {
|
|
4
|
+
static description = 'Set (create or update) an environment variable for a sandbox environment';
|
|
5
|
+
static examples = [
|
|
6
|
+
`$ xano sandbox env set --name DATABASE_URL --value postgres://localhost:5432/mydb
|
|
7
|
+
Environment variable 'DATABASE_URL' set
|
|
8
|
+
`,
|
|
9
|
+
`$ xano sandbox env set --name DATABASE_URL --value postgres://localhost:5432/mydb -o json`,
|
|
10
|
+
];
|
|
11
|
+
static flags = {
|
|
12
|
+
...BaseCommand.baseFlags,
|
|
13
|
+
name: Flags.string({
|
|
14
|
+
char: 'n',
|
|
15
|
+
description: 'Environment variable name',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
output: Flags.string({
|
|
19
|
+
char: 'o',
|
|
20
|
+
default: 'summary',
|
|
21
|
+
description: 'Output format',
|
|
22
|
+
options: ['summary', 'json'],
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
value: Flags.string({
|
|
26
|
+
description: 'Environment variable value',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
async run() {
|
|
31
|
+
const { flags } = await this.parse(SandboxEnvSet);
|
|
32
|
+
const { profile } = this.resolveProfile(flags);
|
|
33
|
+
const envName = flags.name;
|
|
34
|
+
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/env/${envName}`;
|
|
35
|
+
const body = {
|
|
36
|
+
env: {
|
|
37
|
+
name: envName,
|
|
38
|
+
value: flags.value,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
43
|
+
body: JSON.stringify(body),
|
|
44
|
+
headers: {
|
|
45
|
+
accept: 'application/json',
|
|
46
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
},
|
|
49
|
+
method: 'PATCH',
|
|
50
|
+
}, flags.verbose, profile.access_token);
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
const errorText = await response.text();
|
|
53
|
+
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
54
|
+
}
|
|
55
|
+
if (flags.output === 'json') {
|
|
56
|
+
const result = await response.json();
|
|
57
|
+
this.log(JSON.stringify(result, null, 2));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.log(`Environment variable '${envName}' set for sandbox environment`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
this.error(`Failed to set sandbox environment variable: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.error(`Failed to set sandbox environment variable: ${String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseCommand from '../../../../base-command.js';
|
|
2
|
+
export default class SandboxEnvSetAll 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
|
+
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
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 sourceFilePath = path.resolve(flags.file || `env.yaml`);
|
|
39
|
+
if (!fs.existsSync(sourceFilePath)) {
|
|
40
|
+
this.error(`File not found: ${sourceFilePath}`);
|
|
41
|
+
}
|
|
42
|
+
const fileContent = fs.readFileSync(sourceFilePath, 'utf8');
|
|
43
|
+
const envMap = yaml.load(fileContent);
|
|
44
|
+
if (!envMap || typeof envMap !== 'object') {
|
|
45
|
+
this.error('Invalid env file format. Expected a YAML map of key: value pairs.');
|
|
46
|
+
}
|
|
47
|
+
const envs = Object.entries(envMap).map(([name, value]) => ({ name, value: String(value) }));
|
|
48
|
+
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/env_all`;
|
|
49
|
+
try {
|
|
50
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
51
|
+
body: JSON.stringify({ envs }),
|
|
52
|
+
headers: {
|
|
53
|
+
accept: 'application/json',
|
|
54
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
55
|
+
'Content-Type': 'application/json',
|
|
56
|
+
},
|
|
57
|
+
method: 'PUT',
|
|
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
|
+
if (flags.output === 'json') {
|
|
64
|
+
const result = await response.json();
|
|
65
|
+
this.log(JSON.stringify(result, null, 2));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.log(`All environment variables updated for sandbox environment (${envs.length} variables)`);
|
|
69
|
+
}
|
|
70
|
+
if (flags.clean && fs.existsSync(sourceFilePath)) {
|
|
71
|
+
fs.unlinkSync(sourceFilePath);
|
|
72
|
+
this.log(`Removed ${sourceFilePath}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof Error) {
|
|
77
|
+
this.error(`Failed to set sandbox environment variables: ${error.message}`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.error(`Failed to set sandbox environment variables: ${String(error)}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
if (tenant.sandbox_expires_at) {
|
|
38
|
+
const expiresAt = new Date(tenant.sandbox_expires_at);
|
|
39
|
+
if (!isNaN(expiresAt.getTime())) {
|
|
40
|
+
const msLeft = expiresAt.getTime() - Date.now();
|
|
41
|
+
if (msLeft > 0) {
|
|
42
|
+
const minsLeft = Math.ceil(msLeft / 60_000);
|
|
43
|
+
this.log(` Session expires: ${expiresAt.toLocaleString()} (${minsLeft} min remaining)`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.log(` Session expires: ${expiresAt.toLocaleString()} (expired)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error instanceof Error) {
|
|
54
|
+
this.error(`Failed to get sandbox environment: ${error.message}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.error(`Failed to get sandbox environment: ${String(error)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 apiUrl = `${profile.instance_origin}/api:meta/sandbox/license`;
|
|
39
|
+
try {
|
|
40
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
41
|
+
headers: {
|
|
42
|
+
accept: 'application/json',
|
|
43
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
44
|
+
},
|
|
45
|
+
method: 'GET',
|
|
46
|
+
}, flags.verbose, profile.access_token);
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
const errorText = await response.text();
|
|
49
|
+
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
50
|
+
}
|
|
51
|
+
const license = await response.json();
|
|
52
|
+
const licenseContent = typeof license === 'string' ? license : JSON.stringify(license, null, 2);
|
|
53
|
+
if (flags.view || flags.output === 'json') {
|
|
54
|
+
if (flags.output === 'json') {
|
|
55
|
+
this.log(JSON.stringify(license, null, 2));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.log(licenseContent);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const filePath = path.resolve(flags.file || `license.yaml`);
|
|
63
|
+
fs.writeFileSync(filePath, licenseContent, 'utf8');
|
|
64
|
+
this.log(`License saved to ${filePath}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof Error) {
|
|
69
|
+
this.error(`Failed to get sandbox environment license: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.error(`Failed to get sandbox environment license: ${String(error)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
let licenseValue;
|
|
46
|
+
let sourceFilePath;
|
|
47
|
+
if (flags.value) {
|
|
48
|
+
licenseValue = flags.value;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
sourceFilePath = path.resolve(flags.file || `license.yaml`);
|
|
52
|
+
if (!fs.existsSync(sourceFilePath)) {
|
|
53
|
+
this.error(`File not found: ${sourceFilePath}`);
|
|
54
|
+
}
|
|
55
|
+
licenseValue = fs.readFileSync(sourceFilePath, 'utf8');
|
|
56
|
+
}
|
|
57
|
+
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/license`;
|
|
58
|
+
try {
|
|
59
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
60
|
+
body: JSON.stringify({ value: licenseValue }),
|
|
61
|
+
headers: {
|
|
62
|
+
accept: 'application/json',
|
|
63
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
},
|
|
66
|
+
method: 'POST',
|
|
67
|
+
}, flags.verbose, profile.access_token);
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
const errorText = await response.text();
|
|
70
|
+
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
71
|
+
}
|
|
72
|
+
const result = await response.json();
|
|
73
|
+
if (flags.output === 'json') {
|
|
74
|
+
this.log(JSON.stringify(result, null, 2));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.log(`Sandbox environment license updated successfully`);
|
|
78
|
+
}
|
|
79
|
+
if (flags.clean && sourceFilePath && fs.existsSync(sourceFilePath)) {
|
|
80
|
+
fs.unlinkSync(sourceFilePath);
|
|
81
|
+
this.log(`Removed ${sourceFilePath}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof Error) {
|
|
86
|
+
this.error(`Failed to set sandbox environment license: ${error.message}`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.error(`Failed to set sandbox environment license: ${String(error)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|