@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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xano/cli",
|
|
3
3
|
"description": "CLI for Xano's Metadata API",
|
|
4
|
-
"version": "0.0.95
|
|
4
|
+
"version": "0.0.95",
|
|
5
5
|
"author": "Sean Montgomery",
|
|
6
6
|
"bin": {
|
|
7
7
|
"xano": "./bin/run.js"
|
|
@@ -66,15 +66,6 @@
|
|
|
66
66
|
"branch": {
|
|
67
67
|
"description": "Manage workspace branches"
|
|
68
68
|
},
|
|
69
|
-
"sandbox": {
|
|
70
|
-
"description": "Manage your sandbox environment"
|
|
71
|
-
},
|
|
72
|
-
"sandbox:unit_test": {
|
|
73
|
-
"description": "Manage and run unit tests for your sandbox environment"
|
|
74
|
-
},
|
|
75
|
-
"sandbox:workflow_test": {
|
|
76
|
-
"description": "Manage and run workflow tests for your sandbox environment"
|
|
77
|
-
},
|
|
78
69
|
"function": {
|
|
79
70
|
"description": "Manage reusable functions in a workspace"
|
|
80
71
|
},
|
|
@@ -96,12 +87,6 @@
|
|
|
96
87
|
"tenant:backup": {
|
|
97
88
|
"description": "Manage tenant backups"
|
|
98
89
|
},
|
|
99
|
-
"tenant:unit_test": {
|
|
100
|
-
"description": "Manage and run unit tests for tenants"
|
|
101
|
-
},
|
|
102
|
-
"tenant:workflow_test": {
|
|
103
|
-
"description": "Manage and run workflow tests for tenants"
|
|
104
|
-
},
|
|
105
90
|
"unit_test": {
|
|
106
91
|
"description": "Manage and run unit tests"
|
|
107
92
|
},
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../base-command.js';
|
|
2
|
-
export default class ReleaseDeploy extends BaseCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
release_name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
set_live: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
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
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import BaseCommand from '../../../base-command.js';
|
|
3
|
-
export default class ReleaseDeploy extends BaseCommand {
|
|
4
|
-
static args = {
|
|
5
|
-
release_name: Args.string({
|
|
6
|
-
description: 'Name of the release to deploy',
|
|
7
|
-
required: true,
|
|
8
|
-
}),
|
|
9
|
-
};
|
|
10
|
-
static description = 'Deploy a release to its workspace as a new branch';
|
|
11
|
-
static examples = [
|
|
12
|
-
`$ xano release deploy "v1.0"
|
|
13
|
-
Deployed release "v1.0" to workspace 40 (branch: v1.0, set live)
|
|
14
|
-
`,
|
|
15
|
-
`$ xano release deploy "v1.0" --branch "restore-v1" --no-set_live`,
|
|
16
|
-
`$ xano release deploy "v1.0" -w 40 -o json`,
|
|
17
|
-
];
|
|
18
|
-
static flags = {
|
|
19
|
-
...BaseCommand.baseFlags,
|
|
20
|
-
branch: Flags.string({
|
|
21
|
-
char: 'b',
|
|
22
|
-
description: 'Branch label for the new branch (defaults to release branch name)',
|
|
23
|
-
required: false,
|
|
24
|
-
}),
|
|
25
|
-
output: Flags.string({
|
|
26
|
-
char: 'o',
|
|
27
|
-
default: 'summary',
|
|
28
|
-
description: 'Output format',
|
|
29
|
-
options: ['summary', 'json'],
|
|
30
|
-
required: false,
|
|
31
|
-
}),
|
|
32
|
-
set_live: Flags.boolean({
|
|
33
|
-
default: false,
|
|
34
|
-
description: 'Set the new branch as live',
|
|
35
|
-
required: false,
|
|
36
|
-
}),
|
|
37
|
-
workspace: Flags.string({
|
|
38
|
-
char: 'w',
|
|
39
|
-
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
40
|
-
required: false,
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
async run() {
|
|
44
|
-
const { args, flags } = await this.parse(ReleaseDeploy);
|
|
45
|
-
const profileName = flags.profile || this.getDefaultProfile();
|
|
46
|
-
const credentials = this.loadCredentialsFile();
|
|
47
|
-
if (!credentials || !(profileName in credentials.profiles)) {
|
|
48
|
-
this.error(`Profile '${profileName}' not found.\n` + `Create a profile using 'xano profile create'`);
|
|
49
|
-
}
|
|
50
|
-
const profile = credentials.profiles[profileName];
|
|
51
|
-
if (!profile.instance_origin) {
|
|
52
|
-
this.error(`Profile '${profileName}' is missing instance_origin`);
|
|
53
|
-
}
|
|
54
|
-
if (!profile.access_token) {
|
|
55
|
-
this.error(`Profile '${profileName}' is missing access_token`);
|
|
56
|
-
}
|
|
57
|
-
const workspaceId = flags.workspace || profile.workspace;
|
|
58
|
-
if (!workspaceId) {
|
|
59
|
-
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
60
|
-
}
|
|
61
|
-
const releaseName = encodeURIComponent(args.release_name);
|
|
62
|
-
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release/${releaseName}/deploy`;
|
|
63
|
-
const body = {
|
|
64
|
-
set_live: flags.set_live,
|
|
65
|
-
};
|
|
66
|
-
if (flags.branch)
|
|
67
|
-
body.branch = flags.branch;
|
|
68
|
-
this.warn('This may take a few minutes. Please be patient.');
|
|
69
|
-
const startTime = Date.now();
|
|
70
|
-
try {
|
|
71
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
72
|
-
body: JSON.stringify(body),
|
|
73
|
-
headers: {
|
|
74
|
-
accept: 'application/json',
|
|
75
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
},
|
|
78
|
-
method: 'POST',
|
|
79
|
-
}, flags.verbose, profile.access_token);
|
|
80
|
-
if (!response.ok) {
|
|
81
|
-
const errorText = await response.text();
|
|
82
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
83
|
-
}
|
|
84
|
-
const release = (await response.json());
|
|
85
|
-
if (flags.output === 'json') {
|
|
86
|
-
this.log(JSON.stringify(release, null, 2));
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
90
|
-
const branchLabel = flags.branch || release.branch || 'default';
|
|
91
|
-
const liveStatus = flags.set_live ? ', set live' : '';
|
|
92
|
-
this.log(`Deployed release "${release.name}" to workspace ${workspaceId} (branch: ${branchLabel}${liveStatus})`);
|
|
93
|
-
if (release.description)
|
|
94
|
-
this.log(` Description: ${release.description}`);
|
|
95
|
-
this.log(` Time: ${elapsed}s`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
if (error instanceof Error) {
|
|
100
|
-
this.error(`Failed to deploy release: ${error.message}`);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
this.error(`Failed to deploy release: ${String(error)}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../../base-command.js';
|
|
2
|
-
export default class SandboxEnvDelete extends BaseCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, 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
|
-
private confirm;
|
|
14
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import BaseCommand from '../../../../base-command.js';
|
|
3
|
-
export default class SandboxEnvDelete extends BaseCommand {
|
|
4
|
-
static description = 'Delete an environment variable from a sandbox environment';
|
|
5
|
-
static examples = [
|
|
6
|
-
`$ xano sandbox env delete --name DATABASE_URL
|
|
7
|
-
Are you sure you want to delete environment variable 'DATABASE_URL'? (y/N) y
|
|
8
|
-
Environment variable 'DATABASE_URL' deleted
|
|
9
|
-
`,
|
|
10
|
-
`$ xano sandbox env delete --name DATABASE_URL --force`,
|
|
11
|
-
`$ xano sandbox env delete --name DATABASE_URL -f -o json`,
|
|
12
|
-
];
|
|
13
|
-
static flags = {
|
|
14
|
-
...BaseCommand.baseFlags,
|
|
15
|
-
force: Flags.boolean({
|
|
16
|
-
char: 'f',
|
|
17
|
-
default: false,
|
|
18
|
-
description: 'Skip confirmation prompt',
|
|
19
|
-
required: false,
|
|
20
|
-
}),
|
|
21
|
-
name: Flags.string({
|
|
22
|
-
char: 'n',
|
|
23
|
-
description: 'Environment variable name',
|
|
24
|
-
required: true,
|
|
25
|
-
}),
|
|
26
|
-
output: Flags.string({
|
|
27
|
-
char: 'o',
|
|
28
|
-
default: 'summary',
|
|
29
|
-
description: 'Output format',
|
|
30
|
-
options: ['summary', 'json'],
|
|
31
|
-
required: false,
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
async run() {
|
|
35
|
-
const { flags } = await this.parse(SandboxEnvDelete);
|
|
36
|
-
const { profile } = this.resolveProfile(flags);
|
|
37
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
38
|
-
const tenantName = tenant.name;
|
|
39
|
-
const envName = flags.name;
|
|
40
|
-
if (!flags.force) {
|
|
41
|
-
const confirmed = await this.confirm(`Are you sure you want to delete environment variable '${envName}' from sandbox environment ${tenantName}?`);
|
|
42
|
-
if (!confirmed) {
|
|
43
|
-
this.log('Deletion cancelled.');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/env/${envName}`;
|
|
48
|
-
try {
|
|
49
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
50
|
-
headers: {
|
|
51
|
-
accept: 'application/json',
|
|
52
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
53
|
-
},
|
|
54
|
-
method: 'DELETE',
|
|
55
|
-
}, flags.verbose, profile.access_token);
|
|
56
|
-
if (!response.ok) {
|
|
57
|
-
const errorText = await response.text();
|
|
58
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
59
|
-
}
|
|
60
|
-
if (flags.output === 'json') {
|
|
61
|
-
this.log(JSON.stringify({ deleted: true, env_name: envName, tenant_name: tenantName }, null, 2));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
this.log(`Environment variable '${envName}' deleted from sandbox environment ${tenantName}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (error instanceof Error) {
|
|
69
|
-
this.error(`Failed to delete sandbox environment variable: ${error.message}`);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this.error(`Failed to delete sandbox environment variable: ${String(error)}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async confirm(message) {
|
|
77
|
-
const readline = await import('node:readline');
|
|
78
|
-
const rl = readline.createInterface({
|
|
79
|
-
input: process.stdin,
|
|
80
|
-
output: process.stdout,
|
|
81
|
-
});
|
|
82
|
-
return new Promise((resolve) => {
|
|
83
|
-
rl.question(`${message} (y/N) `, (answer) => {
|
|
84
|
-
rl.close();
|
|
85
|
-
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../../base-command.js';
|
|
2
|
-
export default class SandboxEnvGet 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
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import BaseCommand from '../../../../base-command.js';
|
|
3
|
-
export default class SandboxEnvGet extends BaseCommand {
|
|
4
|
-
static description = 'Get a single environment variable for a sandbox environment';
|
|
5
|
-
static examples = [
|
|
6
|
-
`$ xano sandbox env get --name DATABASE_URL
|
|
7
|
-
postgres://localhost:5432/mydb
|
|
8
|
-
`,
|
|
9
|
-
`$ xano sandbox env get --name DATABASE_URL -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
|
-
};
|
|
26
|
-
async run() {
|
|
27
|
-
const { flags } = await this.parse(SandboxEnvGet);
|
|
28
|
-
const { profile } = this.resolveProfile(flags);
|
|
29
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
30
|
-
const tenantName = tenant.name;
|
|
31
|
-
const envName = flags.name;
|
|
32
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/env/${envName}`;
|
|
33
|
-
try {
|
|
34
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
35
|
-
headers: {
|
|
36
|
-
accept: 'application/json',
|
|
37
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
38
|
-
},
|
|
39
|
-
method: 'GET',
|
|
40
|
-
}, flags.verbose, profile.access_token);
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
const errorText = await response.text();
|
|
43
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
44
|
-
}
|
|
45
|
-
const envVar = (await response.json());
|
|
46
|
-
if (flags.output === 'json') {
|
|
47
|
-
this.log(JSON.stringify(envVar, null, 2));
|
|
48
|
-
}
|
|
49
|
-
else if (envVar) {
|
|
50
|
-
this.log(envVar.value);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
this.log(`Environment variable '${envName}' not found for sandbox environment ${tenantName}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
if (error instanceof Error) {
|
|
58
|
-
this.error(`Failed to get sandbox environment variable: ${error.message}`);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.error(`Failed to get sandbox environment variable: ${String(error)}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../../base-command.js';
|
|
2
|
-
export default class SandboxEnvGetAll 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 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 SandboxEnvGetAll extends BaseCommand {
|
|
7
|
-
static description = 'Get all environment variables for a sandbox environment and save to a YAML file';
|
|
8
|
-
static examples = [
|
|
9
|
-
`$ xano sandbox env get_all
|
|
10
|
-
Environment variables saved to env_<tenant>.yaml
|
|
11
|
-
`,
|
|
12
|
-
`$ xano sandbox env get_all --file ./my-env.yaml`,
|
|
13
|
-
`$ xano sandbox env get_all --view`,
|
|
14
|
-
`$ xano sandbox env get_all -o json`,
|
|
15
|
-
];
|
|
16
|
-
static flags = {
|
|
17
|
-
...BaseCommand.baseFlags,
|
|
18
|
-
file: Flags.string({
|
|
19
|
-
char: 'f',
|
|
20
|
-
description: 'Output file path (default: env_<sandbox_name>.yaml)',
|
|
21
|
-
required: false,
|
|
22
|
-
}),
|
|
23
|
-
output: Flags.string({
|
|
24
|
-
char: 'o',
|
|
25
|
-
default: 'summary',
|
|
26
|
-
description: 'Output format',
|
|
27
|
-
options: ['summary', 'json'],
|
|
28
|
-
required: false,
|
|
29
|
-
}),
|
|
30
|
-
view: Flags.boolean({
|
|
31
|
-
default: false,
|
|
32
|
-
description: 'Print environment variables to stdout instead of saving to file',
|
|
33
|
-
required: false,
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
36
|
-
async run() {
|
|
37
|
-
const { flags } = await this.parse(SandboxEnvGetAll);
|
|
38
|
-
const { profile } = this.resolveProfile(flags);
|
|
39
|
-
const tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
40
|
-
const tenantName = tenant.name;
|
|
41
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/env_all`;
|
|
42
|
-
try {
|
|
43
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
44
|
-
headers: {
|
|
45
|
-
accept: 'application/json',
|
|
46
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
47
|
-
},
|
|
48
|
-
method: 'GET',
|
|
49
|
-
}, flags.verbose, profile.access_token);
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
const errorText = await response.text();
|
|
52
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
53
|
-
}
|
|
54
|
-
const envMap = (await response.json());
|
|
55
|
-
if (flags.output === 'json') {
|
|
56
|
-
this.log(JSON.stringify(envMap, null, 2));
|
|
57
|
-
}
|
|
58
|
-
else if (flags.view) {
|
|
59
|
-
const envYaml = yaml.dump(envMap, { lineWidth: -1, sortKeys: true });
|
|
60
|
-
this.log(envYaml.trimEnd());
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const filePath = path.resolve(flags.file || `env_${tenantName}.yaml`);
|
|
64
|
-
const envYaml = yaml.dump(envMap, { lineWidth: -1, sortKeys: true });
|
|
65
|
-
fs.writeFileSync(filePath, envYaml, 'utf8');
|
|
66
|
-
this.log(`Environment variables saved to ${filePath}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error instanceof Error) {
|
|
71
|
-
this.error(`Failed to get sandbox environment variables: ${error.message}`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
this.error(`Failed to get sandbox environment variables: ${String(error)}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import BaseCommand from '../../../../base-command.js';
|
|
2
|
-
export default class SandboxEnvList 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,67 +0,0 @@
|
|
|
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 tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
27
|
-
const tenantName = tenant.name;
|
|
28
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/env_key`;
|
|
29
|
-
try {
|
|
30
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
31
|
-
headers: {
|
|
32
|
-
accept: 'application/json',
|
|
33
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
34
|
-
},
|
|
35
|
-
method: 'GET',
|
|
36
|
-
}, flags.verbose, profile.access_token);
|
|
37
|
-
if (!response.ok) {
|
|
38
|
-
const errorText = await response.text();
|
|
39
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
40
|
-
}
|
|
41
|
-
const data = (await response.json());
|
|
42
|
-
if (flags.output === 'json') {
|
|
43
|
-
this.log(JSON.stringify(data, null, 2));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const envVars = data.env || [];
|
|
47
|
-
if (envVars.length === 0) {
|
|
48
|
-
this.log(`No environment variables found for sandbox environment ${tenantName}`);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
this.log(`Environment variables for sandbox environment ${tenantName}:`);
|
|
52
|
-
for (const envVar of envVars) {
|
|
53
|
-
this.log(` - ${envVar.name}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
if (error instanceof Error) {
|
|
60
|
-
this.error(`Failed to list sandbox environment variables: ${error.message}`);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.error(`Failed to list sandbox environment variables: ${String(error)}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
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 tenant = await this.getOrCreateSandbox(profile, flags.verbose);
|
|
34
|
-
const tenantName = tenant.name;
|
|
35
|
-
const envName = flags.name;
|
|
36
|
-
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/tenant/${tenantName}/env/${envName}`;
|
|
37
|
-
const body = {
|
|
38
|
-
env: {
|
|
39
|
-
name: envName,
|
|
40
|
-
value: flags.value,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
try {
|
|
44
|
-
const response = await this.verboseFetch(apiUrl, {
|
|
45
|
-
body: JSON.stringify(body),
|
|
46
|
-
headers: {
|
|
47
|
-
accept: 'application/json',
|
|
48
|
-
Authorization: `Bearer ${profile.access_token}`,
|
|
49
|
-
'Content-Type': 'application/json',
|
|
50
|
-
},
|
|
51
|
-
method: 'PATCH',
|
|
52
|
-
}, flags.verbose, profile.access_token);
|
|
53
|
-
if (!response.ok) {
|
|
54
|
-
const errorText = await response.text();
|
|
55
|
-
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
56
|
-
}
|
|
57
|
-
if (flags.output === 'json') {
|
|
58
|
-
const result = await response.json();
|
|
59
|
-
this.log(JSON.stringify(result, null, 2));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.log(`Environment variable '${envName}' set for sandbox environment ${tenantName}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
if (error instanceof Error) {
|
|
67
|
-
this.error(`Failed to set sandbox environment variable: ${error.message}`);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.error(`Failed to set sandbox environment variable: ${String(error)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|