@xano/cli 1.0.3-beta.9 → 1.0.3

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.
Files changed (29) hide show
  1. package/README.md +3 -69
  2. package/dist/base-command.d.ts +0 -27
  3. package/dist/base-command.js +46 -125
  4. package/dist/commands/auth/index.d.ts +0 -10
  5. package/dist/commands/auth/index.js +9 -146
  6. package/dist/commands/static_host/build/create/index.d.ts +1 -9
  7. package/dist/commands/static_host/build/create/index.js +4 -54
  8. package/dist/commands/static_host/build/get/index.d.ts +1 -1
  9. package/dist/commands/static_host/build/get/index.js +10 -16
  10. package/dist/utils/multidoc-push.js +94 -27
  11. package/dist/utils/reference-checker.js +2 -2
  12. package/oclif.manifest.json +2421 -3382
  13. package/package.json +3 -4
  14. package/dist/commands/static_host/build/delete/index.d.ts +0 -19
  15. package/dist/commands/static_host/build/delete/index.js +0 -114
  16. package/dist/commands/static_host/build/pull/index.d.ts +0 -52
  17. package/dist/commands/static_host/build/pull/index.js +0 -300
  18. package/dist/commands/static_host/build/push/index.d.ts +0 -23
  19. package/dist/commands/static_host/build/push/index.js +0 -225
  20. package/dist/commands/static_host/create/index.d.ts +0 -17
  21. package/dist/commands/static_host/create/index.js +0 -86
  22. package/dist/commands/static_host/deploy/index.d.ts +0 -18
  23. package/dist/commands/static_host/deploy/index.js +0 -105
  24. package/dist/commands/static_host/edit/index.d.ts +0 -23
  25. package/dist/commands/static_host/edit/index.js +0 -151
  26. package/dist/commands/static_host/get/index.d.ts +0 -18
  27. package/dist/commands/static_host/get/index.js +0 -94
  28. package/dist/commands/static_host/migrate/index.d.ts +0 -44
  29. package/dist/commands/static_host/migrate/index.js +0 -205
@@ -1,94 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import BaseCommand from '../../../base-command.js';
3
- export default class StaticHostGet extends BaseCommand {
4
- static args = {
5
- static_host: Args.string({
6
- description: 'Static Host name',
7
- required: true,
8
- }),
9
- };
10
- static description = 'Get a single static host\'s details (name, git config, dev/prod environments)';
11
- static examples = [
12
- `$ xano static_host get newsite
13
- Static Host: newsite
14
- ID: 5
15
- Dev: https://newsite-dev-....dev.xano.io (v2)
16
- `,
17
- `$ xano static_host get newsite -w 40 -o json`,
18
- ];
19
- static flags = {
20
- ...BaseCommand.baseFlags,
21
- output: Flags.string({
22
- char: 'o',
23
- default: 'summary',
24
- description: 'Output format',
25
- options: ['summary', 'json'],
26
- required: false,
27
- }),
28
- workspace: Flags.string({
29
- char: 'w',
30
- description: 'Workspace ID (optional if set in profile)',
31
- required: false,
32
- }),
33
- };
34
- async run() {
35
- const { args, flags } = await this.parse(StaticHostGet);
36
- const { profile, profileName } = this.resolveProfile(flags);
37
- let workspaceId;
38
- if (flags.workspace) {
39
- workspaceId = flags.workspace;
40
- }
41
- else if (profile.workspace) {
42
- workspaceId = profile.workspace;
43
- }
44
- else {
45
- this.error(`Workspace ID is required. Either:\n` +
46
- ` 1. Provide it as a flag: xano static_host get <static_host> -w <workspace_id>\n` +
47
- ` 2. Set it in your profile using: xano profile edit ${profileName} -w <workspace_id>`);
48
- }
49
- const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/static_host/${args.static_host}`;
50
- try {
51
- const response = await this.verboseFetch(apiUrl, {
52
- headers: {
53
- accept: 'application/json',
54
- Authorization: `Bearer ${profile.access_token}`,
55
- },
56
- method: 'GET',
57
- }, flags.verbose, profile.access_token);
58
- if (!response.ok) {
59
- const message = await this.parseApiError(response, `Failed to get static host '${args.static_host}'`);
60
- this.error(message);
61
- }
62
- const host = (await response.json());
63
- if (flags.output === 'json') {
64
- this.log(JSON.stringify(host, null, 2));
65
- }
66
- else {
67
- this.log(`Static Host: ${host.name}`);
68
- this.log(`ID: ${host.id}`);
69
- if (host.description)
70
- this.log(`Description: ${host.description}`);
71
- if (host.git?.repo)
72
- this.log(`Git: ${host.git.repo}`);
73
- this.logEnv('Dev', host.dev);
74
- this.logEnv('Prod', host.prod);
75
- }
76
- }
77
- catch (error) {
78
- if (error instanceof Error) {
79
- this.error(`Failed to get static host: ${error.message}`);
80
- }
81
- else {
82
- this.error(`Failed to get static host: ${String(error)}`);
83
- }
84
- }
85
- }
86
- /** Print a one-line summary for a dev/prod env if it has been deployed. */
87
- logEnv(label, env) {
88
- if (!env?.default_url)
89
- return;
90
- const modeInfo = env.mode ? ` (${env.mode})` : '';
91
- const custom = env.custom_url ? ` [custom: ${env.custom_url}]` : '';
92
- this.log(`${label}: ${env.default_url}${modeInfo}${custom}`);
93
- }
94
- }
@@ -1,44 +0,0 @@
1
- import BaseCommand from '../../../base-command.js';
2
- export interface StaticHostEnv {
3
- canonical?: null | string;
4
- mode?: null | string;
5
- }
6
- export interface StaticHost {
7
- dev?: StaticHostEnv;
8
- id: number;
9
- name: string;
10
- prod?: StaticHostEnv;
11
- }
12
- export default class StaticHostMigrate extends BaseCommand {
13
- static args: {
14
- static_host: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
15
- };
16
- static description: string;
17
- static examples: string[];
18
- static flags: {
19
- all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
- 'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
- env: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
23
- workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
- config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
- profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
- verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
27
- };
28
- run(): Promise<void>;
29
- /** List all static hosts in the workspace (paginates until exhausted). */
30
- private listHosts;
31
- /** Discover v1 hosts and migrate each, with a per-host report. */
32
- private migrateAll;
33
- /** POST the meta migrate endpoint for one host. Throws on a non-OK response. */
34
- private migrateHost;
35
- /** Migrate a single named host and report the result. */
36
- private migrateOne;
37
- }
38
- /** An env still needs migration when it's been deployed (has a canonical) but isn't yet v2. */
39
- export declare function envNeedsMigration(e?: StaticHostEnv): boolean;
40
- /**
41
- * A host still needs migration when an env of interest is v1. When --env is given,
42
- * only that env is considered; otherwise either env being v1 qualifies the host.
43
- */
44
- export declare function isV1(host: StaticHost, env?: string): boolean;
@@ -1,205 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import BaseCommand from '../../../base-command.js';
3
- export default class StaticHostMigrate extends BaseCommand {
4
- static args = {
5
- static_host: Args.string({
6
- description: 'Static Host name to migrate (omit when using --all)',
7
- required: false,
8
- }),
9
- };
10
- static description = 'Migrate a static host to instance-managed (v2) hosting. Reparents the Ingress, verifies it, clears master, and marks the host v2.';
11
- static examples = [
12
- `$ xano static_host migrate newsite
13
- Migrated 'newsite' to v2
14
- `,
15
- `$ xano static_host migrate newsite --env dev
16
- Migrated 'newsite' (dev) to v2
17
- `,
18
- `$ xano static_host migrate --all
19
- Migrating 3 v1 host(s)...
20
- ✓ newsite
21
- ✓ marketing
22
- ✗ legacy — <error>
23
- `,
24
- `$ xano static_host migrate --all --dry-run
25
- Would migrate 3 v1 host(s): newsite, marketing, legacy
26
- `,
27
- ];
28
- static flags = {
29
- ...BaseCommand.baseFlags,
30
- all: Flags.boolean({
31
- default: false,
32
- description: 'Migrate every host still on v1 in the workspace',
33
- required: false,
34
- }),
35
- 'dry-run': Flags.boolean({
36
- default: false,
37
- description: 'List the hosts that would be migrated without changing anything',
38
- required: false,
39
- }),
40
- env: Flags.string({
41
- description: 'Which environment to migrate (migrates both if omitted)',
42
- options: ['dev', 'prod'],
43
- required: false,
44
- }),
45
- output: Flags.string({
46
- char: 'o',
47
- default: 'summary',
48
- description: 'Output format',
49
- options: ['summary', 'json'],
50
- required: false,
51
- }),
52
- workspace: Flags.string({
53
- char: 'w',
54
- description: 'Workspace ID (optional if set in profile)',
55
- required: false,
56
- }),
57
- };
58
- async run() {
59
- const { args, flags } = await this.parse(StaticHostMigrate);
60
- if (!flags.all && !args.static_host) {
61
- this.error('Provide a static host name, or use --all to migrate every v1 host.');
62
- }
63
- if (flags.all && args.static_host) {
64
- this.error('Use either a static host name or --all, not both.');
65
- }
66
- const { profile, profileName } = this.resolveProfile(flags);
67
- let workspaceId;
68
- if (flags.workspace) {
69
- workspaceId = flags.workspace;
70
- }
71
- else if (profile.workspace) {
72
- workspaceId = profile.workspace;
73
- }
74
- else {
75
- this.error(`Workspace ID is required. Either:\n` +
76
- ` 1. Provide it as a flag: xano static_host migrate <static_host> -w <workspace_id>\n` +
77
- ` 2. Set it in your profile using: xano profile edit ${profileName} -w <workspace_id>`);
78
- }
79
- if (flags.all) {
80
- await this.migrateAll(profile, workspaceId, flags);
81
- return;
82
- }
83
- await this.migrateOne(profile, workspaceId, args.static_host, flags);
84
- }
85
- /** List all static hosts in the workspace (paginates until exhausted). */
86
- async listHosts(profile, workspaceId, verbose) {
87
- const hosts = [];
88
- const perPage = 100;
89
- for (let page = 1;; page++) {
90
- const listUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/static_host?page=${page}&per_page=${perPage}`;
91
- // eslint-disable-next-line no-await-in-loop
92
- const response = await this.verboseFetch(listUrl, {
93
- headers: {
94
- accept: 'application/json',
95
- Authorization: `Bearer ${profile.access_token}`,
96
- },
97
- method: 'GET',
98
- }, verbose, profile.access_token);
99
- if (!response.ok) {
100
- const errorText = await response.text(); // eslint-disable-line no-await-in-loop
101
- this.error(`Failed to list static hosts: ${response.status} ${response.statusText}\n${errorText}`);
102
- }
103
- const data = (await response.json()); // eslint-disable-line no-await-in-loop
104
- const pageHosts = Array.isArray(data)
105
- ? data
106
- : data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)
107
- ? data.items
108
- : [];
109
- hosts.push(...pageHosts);
110
- if (pageHosts.length < perPage)
111
- break;
112
- }
113
- return hosts;
114
- }
115
- /** Discover v1 hosts and migrate each, with a per-host report. */
116
- async migrateAll(profile, workspaceId, flags) {
117
- const hosts = await this.listHosts(profile, workspaceId, flags.verbose);
118
- const v1Hosts = hosts.filter((h) => isV1(h, flags.env));
119
- if (v1Hosts.length === 0) {
120
- this.log('No v1 hosts to migrate — all hosts are already instance-managed (v2).');
121
- return;
122
- }
123
- if (flags['dry-run']) {
124
- const names = v1Hosts.map((h) => h.name);
125
- if (flags.output === 'json') {
126
- this.log(JSON.stringify({ dryRun: true, wouldMigrate: names }, null, 2));
127
- }
128
- else {
129
- this.log(`Would migrate ${names.length} v1 host(s): ${names.join(', ')}`);
130
- }
131
- return;
132
- }
133
- if (flags.output !== 'json') {
134
- this.log(`Migrating ${v1Hosts.length} v1 host(s)...`);
135
- }
136
- const results = [];
137
- for (const host of v1Hosts) {
138
- try {
139
- // eslint-disable-next-line no-await-in-loop
140
- await this.migrateHost(profile, workspaceId, host.name, flags.env, flags.verbose);
141
- results.push({ migrated: true, static_host: host.name });
142
- if (flags.output !== 'json')
143
- this.log(` ✓ ${host.name}`);
144
- }
145
- catch (error) {
146
- const message = error instanceof Error ? error.message : String(error);
147
- results.push({ error: message, migrated: false, static_host: host.name });
148
- if (flags.output !== 'json')
149
- this.log(` ✗ ${host.name} — ${message}`);
150
- }
151
- }
152
- if (flags.output === 'json') {
153
- this.log(JSON.stringify({ results }, null, 2));
154
- }
155
- else {
156
- const ok = results.filter((r) => r.migrated).length;
157
- const failed = results.length - ok;
158
- this.log(`Done: ${ok} migrated${failed > 0 ? `, ${failed} failed` : ''}.`);
159
- }
160
- }
161
- /** POST the meta migrate endpoint for one host. Throws on a non-OK response. */
162
- async migrateHost(profile, workspaceId, staticHost, env, verbose) {
163
- const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/static_host/${staticHost}/migrate`;
164
- const response = await this.verboseFetch(apiUrl, {
165
- body: JSON.stringify(env ? { env } : {}),
166
- headers: {
167
- accept: 'application/json',
168
- Authorization: `Bearer ${profile.access_token}`,
169
- 'Content-Type': 'application/json',
170
- },
171
- method: 'POST',
172
- }, verbose, profile.access_token);
173
- if (!response.ok) {
174
- const message = await this.parseApiError(response, `Migrate failed for '${staticHost}'`);
175
- throw new Error(message);
176
- }
177
- return (await response.json());
178
- }
179
- /** Migrate a single named host and report the result. */
180
- async migrateOne(profile, workspaceId, staticHost, flags) {
181
- const result = await this.migrateHost(profile, workspaceId, staticHost, flags.env, flags.verbose);
182
- const envSuffix = flags.env ? ` (${flags.env})` : '';
183
- if (flags.output === 'json') {
184
- this.log(JSON.stringify({ env: flags.env ?? null, migrated: true, static_host: staticHost, ...result }, null, 2));
185
- }
186
- else {
187
- this.log(`Migrated '${staticHost}'${envSuffix} to v2`);
188
- }
189
- }
190
- }
191
- /** An env still needs migration when it's been deployed (has a canonical) but isn't yet v2. */
192
- export function envNeedsMigration(e) {
193
- return Boolean(e?.canonical) && e?.mode !== 'v2';
194
- }
195
- /**
196
- * A host still needs migration when an env of interest is v1. When --env is given,
197
- * only that env is considered; otherwise either env being v1 qualifies the host.
198
- */
199
- export function isV1(host, env) {
200
- if (env === 'dev')
201
- return envNeedsMigration(host.dev);
202
- if (env === 'prod')
203
- return envNeedsMigration(host.prod);
204
- return envNeedsMigration(host.dev) || envNeedsMigration(host.prod);
205
- }