@xano/cli 1.0.5 → 1.0.6-beta.1
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 +57 -0
- package/dist/base-command.d.ts +2 -0
- package/dist/base-command.js +10 -4
- package/dist/commands/ephemeral/create/index.d.ts +18 -0
- package/dist/commands/ephemeral/create/index.js +103 -0
- package/dist/commands/ephemeral/delete/index.d.ts +18 -0
- package/dist/commands/ephemeral/delete/index.js +99 -0
- package/dist/commands/ephemeral/edit/index.d.ts +18 -0
- package/dist/commands/ephemeral/edit/index.js +109 -0
- package/dist/commands/ephemeral/get/index.d.ts +21 -0
- package/dist/commands/ephemeral/get/index.js +125 -0
- package/dist/commands/ephemeral/impersonate/index.d.ts +19 -0
- package/dist/commands/ephemeral/impersonate/index.js +112 -0
- package/dist/commands/ephemeral/list/index.d.ts +19 -0
- package/dist/commands/ephemeral/list/index.js +122 -0
- package/dist/commands/ephemeral/pull/index.d.ts +25 -0
- package/dist/commands/ephemeral/pull/index.js +249 -0
- package/dist/commands/ephemeral/push/index.d.ts +25 -0
- package/dist/commands/ephemeral/push/index.js +144 -0
- package/dist/commands/ephemeral/static_host/build/delete/index.d.ts +20 -0
- package/dist/commands/ephemeral/static_host/build/delete/index.js +121 -0
- package/dist/commands/ephemeral/static_host/build/get/index.d.ts +18 -0
- package/dist/commands/ephemeral/static_host/build/get/index.js +137 -0
- package/dist/commands/ephemeral/static_host/build/list/index.d.ts +19 -0
- package/dist/commands/ephemeral/static_host/build/list/index.js +158 -0
- package/dist/commands/ephemeral/static_host/build/pull/index.d.ts +53 -0
- package/dist/commands/ephemeral/static_host/build/pull/index.js +308 -0
- package/dist/commands/ephemeral/static_host/build/push/index.d.ts +24 -0
- package/dist/commands/ephemeral/static_host/build/push/index.js +250 -0
- package/dist/commands/ephemeral/static_host/create/index.d.ts +18 -0
- package/dist/commands/ephemeral/static_host/create/index.js +92 -0
- package/dist/commands/ephemeral/static_host/deploy/index.d.ts +19 -0
- package/dist/commands/ephemeral/static_host/deploy/index.js +112 -0
- package/dist/commands/ephemeral/static_host/edit/index.d.ts +24 -0
- package/dist/commands/ephemeral/static_host/edit/index.js +158 -0
- package/dist/commands/ephemeral/static_host/get/index.d.ts +19 -0
- package/dist/commands/ephemeral/static_host/get/index.js +101 -0
- package/dist/commands/ephemeral/static_host/list/index.d.ts +18 -0
- package/dist/commands/ephemeral/static_host/list/index.js +152 -0
- package/oclif.manifest.json +4369 -2352
- package/package.json +10 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
export default class EphemeralStaticHostList extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
tenant_name: Args.string({
|
|
6
|
+
description: 'Ephemeral tenant name',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = 'List all static hosts for an ephemeral tenant from the Xano Metadata API';
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano ephemeral static_host list e4f2-9ab1-xyz1 -w 40
|
|
13
|
+
Available static hosts:
|
|
14
|
+
- my-static-host (ID: 1)
|
|
15
|
+
- another-host (ID: 2)
|
|
16
|
+
`,
|
|
17
|
+
`$ xano ephemeral static_host list e4f2-9ab1-xyz1 --profile production
|
|
18
|
+
Available static hosts:
|
|
19
|
+
- my-static-host (ID: 1)
|
|
20
|
+
- another-host (ID: 2)
|
|
21
|
+
`,
|
|
22
|
+
`$ xano ephemeral static_host list e4f2-9ab1-xyz1 -w 40 --output json
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
"id": 1,
|
|
26
|
+
"name": "my-static-host",
|
|
27
|
+
"domain": "example.com"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
`,
|
|
31
|
+
`$ xano ephemeral static_host list e4f2-9ab1-xyz1 -p staging -o json --page 2
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
"id": 3,
|
|
35
|
+
"name": "static-host-3"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
`,
|
|
39
|
+
];
|
|
40
|
+
static flags = {
|
|
41
|
+
...BaseCommand.baseFlags,
|
|
42
|
+
output: Flags.string({
|
|
43
|
+
char: 'o',
|
|
44
|
+
default: 'summary',
|
|
45
|
+
description: 'Output format',
|
|
46
|
+
options: ['summary', 'json'],
|
|
47
|
+
required: false,
|
|
48
|
+
}),
|
|
49
|
+
page: Flags.integer({
|
|
50
|
+
default: 1,
|
|
51
|
+
description: 'Page number for pagination',
|
|
52
|
+
required: false,
|
|
53
|
+
}),
|
|
54
|
+
per_page: Flags.integer({
|
|
55
|
+
default: 50,
|
|
56
|
+
description: 'Number of results per page',
|
|
57
|
+
required: false,
|
|
58
|
+
}),
|
|
59
|
+
workspace: Flags.string({
|
|
60
|
+
char: 'w',
|
|
61
|
+
description: 'Workspace ID (optional if set in profile)',
|
|
62
|
+
required: false,
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
async run() {
|
|
66
|
+
const { args, flags } = await this.parse(EphemeralStaticHostList);
|
|
67
|
+
const { profile, profileName } = this.resolveProfile(flags);
|
|
68
|
+
const tenantName = args.tenant_name;
|
|
69
|
+
// Determine workspace_id from flag or profile
|
|
70
|
+
let workspaceId;
|
|
71
|
+
if (flags.workspace) {
|
|
72
|
+
workspaceId = flags.workspace;
|
|
73
|
+
}
|
|
74
|
+
else if (profile.workspace) {
|
|
75
|
+
workspaceId = profile.workspace;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.error(`Workspace ID is required. Either:\n` +
|
|
79
|
+
` 1. Provide it as a flag: xano ephemeral static_host list <tenant_name> -w <workspace_id>\n` +
|
|
80
|
+
` 2. Set it in your profile using: xano profile:edit ${profileName} -w <workspace_id>`);
|
|
81
|
+
}
|
|
82
|
+
// Build query parameters
|
|
83
|
+
const queryParams = new URLSearchParams({
|
|
84
|
+
page: flags.page.toString(),
|
|
85
|
+
});
|
|
86
|
+
// Only add per_page if it's not the default value
|
|
87
|
+
if (flags.per_page !== 50) {
|
|
88
|
+
queryParams.append('per_page', flags.per_page.toString());
|
|
89
|
+
}
|
|
90
|
+
// Construct the API URL
|
|
91
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}/static_host?${queryParams.toString()}`;
|
|
92
|
+
// Fetch static hosts from the API
|
|
93
|
+
try {
|
|
94
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
95
|
+
headers: {
|
|
96
|
+
'accept': 'application/json',
|
|
97
|
+
'Authorization': `Bearer ${profile.access_token}`,
|
|
98
|
+
},
|
|
99
|
+
method: 'GET',
|
|
100
|
+
}, flags.verbose, profile.access_token);
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
const errorText = await response.text();
|
|
103
|
+
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
104
|
+
}
|
|
105
|
+
const data = await response.json();
|
|
106
|
+
// Handle different response formats
|
|
107
|
+
let staticHosts;
|
|
108
|
+
if (Array.isArray(data)) {
|
|
109
|
+
staticHosts = data;
|
|
110
|
+
}
|
|
111
|
+
else if (data && typeof data === 'object' && 'static_hosts' in data && Array.isArray(data.static_hosts)) {
|
|
112
|
+
staticHosts = data.static_hosts;
|
|
113
|
+
}
|
|
114
|
+
else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
|
|
115
|
+
staticHosts = data.items;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.error('Unexpected API response format');
|
|
119
|
+
}
|
|
120
|
+
// Output results
|
|
121
|
+
if (flags.output === 'json') {
|
|
122
|
+
this.log(JSON.stringify(staticHosts, null, 2));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// summary format
|
|
126
|
+
if (staticHosts.length === 0) {
|
|
127
|
+
this.log('No static hosts found');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.log('Available static hosts:');
|
|
131
|
+
for (const host of staticHosts) {
|
|
132
|
+
if (host.id === undefined) {
|
|
133
|
+
this.log(` - ${host.name}`);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const domainInfo = host.domain ? ` - ${host.domain}` : '';
|
|
137
|
+
this.log(` - ${host.name} (ID: ${host.id})${domainInfo}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (error instanceof Error) {
|
|
145
|
+
this.error(`Failed to fetch static hosts: ${error.message}`);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.error(`Failed to fetch static hosts: ${String(error)}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|