@xano/cli 0.0.24 → 0.0.26
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/dist/base-command.d.ts +1 -3
- package/dist/base-command.js +5 -12
- package/dist/commands/function/create/index.d.ts +6 -7
- package/dist/commands/function/create/index.js +55 -55
- package/dist/commands/function/edit/index.d.ts +10 -11
- package/dist/commands/function/edit/index.js +162 -155
- package/dist/commands/function/get/index.d.ts +5 -6
- package/dist/commands/function/get/index.js +60 -55
- package/dist/commands/function/list/index.d.ts +5 -6
- package/dist/commands/function/list/index.js +52 -52
- package/dist/commands/profile/create/index.d.ts +6 -6
- package/dist/commands/profile/create/index.js +37 -37
- package/dist/commands/profile/delete/index.d.ts +2 -2
- package/dist/commands/profile/delete/index.js +9 -9
- package/dist/commands/profile/edit/index.d.ts +7 -8
- package/dist/commands/profile/edit/index.js +48 -48
- package/dist/commands/profile/get-default/index.js +1 -1
- package/dist/commands/profile/list/index.d.ts +2 -2
- package/dist/commands/profile/list/index.js +9 -9
- package/dist/commands/profile/me/index.d.ts +3 -4
- package/dist/commands/profile/me/index.js +21 -21
- package/dist/commands/profile/project/index.js +1 -1
- package/dist/commands/profile/set-default/index.js +1 -1
- package/dist/commands/profile/token/index.js +1 -1
- package/dist/commands/profile/wizard/index.d.ts +4 -5
- package/dist/commands/profile/wizard/index.js +108 -142
- package/dist/commands/run/env/delete/index.d.ts +2 -3
- package/dist/commands/run/env/delete/index.js +10 -10
- package/dist/commands/run/env/get/index.d.ts +2 -3
- package/dist/commands/run/env/get/index.js +11 -11
- package/dist/commands/run/env/list/index.d.ts +2 -3
- package/dist/commands/run/env/list/index.js +19 -17
- package/dist/commands/run/env/set/index.d.ts +2 -3
- package/dist/commands/run/env/set/index.js +5 -5
- package/dist/commands/run/exec/index.d.ts +8 -19
- package/dist/commands/run/exec/index.js +108 -186
- package/dist/commands/run/info/index.d.ts +4 -5
- package/dist/commands/run/info/index.js +27 -27
- package/dist/commands/run/projects/create/index.d.ts +3 -4
- package/dist/commands/run/projects/create/index.js +23 -23
- package/dist/commands/run/projects/delete/index.d.ts +2 -3
- package/dist/commands/run/projects/delete/index.js +10 -10
- package/dist/commands/run/projects/list/index.d.ts +2 -3
- package/dist/commands/run/projects/list/index.js +12 -12
- package/dist/commands/run/projects/update/index.d.ts +3 -4
- package/dist/commands/run/projects/update/index.js +21 -21
- package/dist/commands/run/secrets/delete/index.d.ts +2 -3
- package/dist/commands/run/secrets/delete/index.js +10 -10
- package/dist/commands/run/secrets/get/index.d.ts +2 -3
- package/dist/commands/run/secrets/get/index.js +11 -11
- package/dist/commands/run/secrets/list/index.d.ts +2 -3
- package/dist/commands/run/secrets/list/index.js +24 -22
- package/dist/commands/run/secrets/set/index.d.ts +3 -4
- package/dist/commands/run/secrets/set/index.js +16 -16
- package/dist/commands/run/sessions/delete/index.d.ts +2 -3
- package/dist/commands/run/sessions/delete/index.js +10 -10
- package/dist/commands/run/sessions/get/index.d.ts +2 -3
- package/dist/commands/run/sessions/get/index.js +11 -11
- package/dist/commands/run/sessions/list/index.d.ts +2 -3
- package/dist/commands/run/sessions/list/index.js +11 -11
- package/dist/commands/run/sessions/start/index.d.ts +2 -3
- package/dist/commands/run/sessions/start/index.js +11 -11
- package/dist/commands/run/sessions/stop/index.d.ts +2 -3
- package/dist/commands/run/sessions/stop/index.js +11 -11
- package/dist/commands/run/sink/get/index.d.ts +2 -3
- package/dist/commands/run/sink/get/index.js +11 -11
- package/dist/commands/static_host/build/create/index.d.ts +4 -5
- package/dist/commands/static_host/build/create/index.js +33 -33
- package/dist/commands/static_host/build/get/index.d.ts +4 -5
- package/dist/commands/static_host/build/get/index.js +20 -20
- package/dist/commands/static_host/build/list/index.d.ts +3 -4
- package/dist/commands/static_host/build/list/index.js +31 -31
- package/dist/commands/static_host/list/index.d.ts +3 -4
- package/dist/commands/static_host/list/index.js +31 -31
- package/dist/commands/workspace/list/index.d.ts +2 -3
- package/dist/commands/workspace/list/index.js +15 -15
- package/dist/commands/workspace/pull/index.d.ts +4 -5
- package/dist/commands/workspace/pull/index.js +52 -47
- package/dist/commands/workspace/push/index.d.ts +0 -1
- package/dist/commands/workspace/push/index.js +4 -4
- package/dist/help.d.ts +1 -1
- package/dist/lib/base-run-command.d.ts +6 -6
- package/dist/lib/base-run-command.js +6 -8
- package/dist/lib/run-http-client.d.ts +18 -24
- package/dist/lib/run-http-client.js +61 -96
- package/dist/lib/run-types.d.ts +80 -80
- package/oclif.manifest.json +888 -2031
- package/package.json +5 -2
- package/dist/commands/branch/create/index.d.ts +0 -17
- package/dist/commands/branch/create/index.js +0 -164
- package/dist/commands/branch/delete/index.d.ts +0 -18
- package/dist/commands/branch/delete/index.js +0 -156
- package/dist/commands/branch/edit/index.d.ts +0 -19
- package/dist/commands/branch/edit/index.js +0 -166
- package/dist/commands/branch/get/index.d.ts +0 -16
- package/dist/commands/branch/get/index.js +0 -135
- package/dist/commands/branch/list/index.d.ts +0 -18
- package/dist/commands/branch/list/index.js +0 -138
- package/dist/commands/branch/set-live/index.d.ts +0 -18
- package/dist/commands/branch/set-live/index.js +0 -155
- package/dist/commands/workspace/create/index.d.ts +0 -14
- package/dist/commands/workspace/create/index.js +0 -131
- package/dist/commands/workspace/delete/index.d.ts +0 -20
- package/dist/commands/workspace/delete/index.js +0 -141
- package/dist/commands/workspace/edit/index.d.ts +0 -22
- package/dist/commands/workspace/edit/index.js +0 -176
- package/dist/commands/workspace/get/index.d.ts +0 -18
- package/dist/commands/workspace/get/index.js +0 -136
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import BaseCommand from '../../../base-command.js';
|
|
2
2
|
export default class StaticHostList extends BaseCommand {
|
|
3
3
|
static args: {};
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
4
|
static flags: {
|
|
5
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
6
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
7
|
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
8
|
per_page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
9
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
10
|
};
|
|
11
|
+
static description: string;
|
|
12
|
+
static examples: string[];
|
|
14
13
|
run(): Promise<void>;
|
|
15
14
|
private loadCredentials;
|
|
16
15
|
}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import * as yaml from 'js-yaml';
|
|
3
2
|
import * as fs from 'node:fs';
|
|
4
3
|
import * as os from 'node:os';
|
|
5
4
|
import * as path from 'node:path';
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
6
|
import BaseCommand from '../../../base-command.js';
|
|
7
7
|
export default class StaticHostList extends BaseCommand {
|
|
8
8
|
static args = {};
|
|
9
|
+
static flags = {
|
|
10
|
+
...BaseCommand.baseFlags,
|
|
11
|
+
workspace: Flags.string({
|
|
12
|
+
char: 'w',
|
|
13
|
+
description: 'Workspace ID (optional if set in profile)',
|
|
14
|
+
required: false,
|
|
15
|
+
}),
|
|
16
|
+
output: Flags.string({
|
|
17
|
+
char: 'o',
|
|
18
|
+
description: 'Output format',
|
|
19
|
+
required: false,
|
|
20
|
+
default: 'summary',
|
|
21
|
+
options: ['summary', 'json'],
|
|
22
|
+
}),
|
|
23
|
+
page: Flags.integer({
|
|
24
|
+
description: 'Page number for pagination',
|
|
25
|
+
required: false,
|
|
26
|
+
default: 1,
|
|
27
|
+
}),
|
|
28
|
+
per_page: Flags.integer({
|
|
29
|
+
description: 'Number of results per page',
|
|
30
|
+
required: false,
|
|
31
|
+
default: 50,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
9
34
|
static description = 'List all static hosts in a workspace from the Xano Metadata API';
|
|
10
35
|
static examples = [
|
|
11
36
|
`$ xano static_host:list -w 40
|
|
@@ -36,31 +61,6 @@ Available static hosts:
|
|
|
36
61
|
]
|
|
37
62
|
`,
|
|
38
63
|
];
|
|
39
|
-
static flags = {
|
|
40
|
-
...BaseCommand.baseFlags,
|
|
41
|
-
output: Flags.string({
|
|
42
|
-
char: 'o',
|
|
43
|
-
default: 'summary',
|
|
44
|
-
description: 'Output format',
|
|
45
|
-
options: ['summary', 'json'],
|
|
46
|
-
required: false,
|
|
47
|
-
}),
|
|
48
|
-
page: Flags.integer({
|
|
49
|
-
default: 1,
|
|
50
|
-
description: 'Page number for pagination',
|
|
51
|
-
required: false,
|
|
52
|
-
}),
|
|
53
|
-
per_page: Flags.integer({
|
|
54
|
-
default: 50,
|
|
55
|
-
description: 'Number of results per page',
|
|
56
|
-
required: false,
|
|
57
|
-
}),
|
|
58
|
-
workspace: Flags.string({
|
|
59
|
-
char: 'w',
|
|
60
|
-
description: 'Workspace ID (optional if set in profile)',
|
|
61
|
-
required: false,
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
64
|
async run() {
|
|
65
65
|
const { flags } = await this.parse(StaticHostList);
|
|
66
66
|
// Get profile name (default or from flag/env)
|
|
@@ -106,11 +106,11 @@ Available static hosts:
|
|
|
106
106
|
// Fetch static hosts from the API
|
|
107
107
|
try {
|
|
108
108
|
const response = await fetch(apiUrl, {
|
|
109
|
+
method: 'GET',
|
|
109
110
|
headers: {
|
|
110
111
|
'accept': 'application/json',
|
|
111
112
|
'Authorization': `Bearer ${profile.access_token}`,
|
|
112
113
|
},
|
|
113
|
-
method: 'GET',
|
|
114
114
|
});
|
|
115
115
|
if (!response.ok) {
|
|
116
116
|
const errorText = await response.text();
|
|
@@ -143,13 +143,13 @@ Available static hosts:
|
|
|
143
143
|
else {
|
|
144
144
|
this.log('Available static hosts:');
|
|
145
145
|
for (const host of staticHosts) {
|
|
146
|
-
if (host.id
|
|
147
|
-
this.log(` - ${host.name}`);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
146
|
+
if (host.id !== undefined) {
|
|
150
147
|
const domainInfo = host.domain ? ` - ${host.domain}` : '';
|
|
151
148
|
this.log(` - ${host.name} (ID: ${host.id})${domainInfo}`);
|
|
152
149
|
}
|
|
150
|
+
else {
|
|
151
|
+
this.log(` - ${host.name}`);
|
|
152
|
+
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import BaseCommand from '../../../base-command.js';
|
|
2
2
|
export default class WorkspaceList extends BaseCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
3
|
static flags: {
|
|
6
4
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
5
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
6
|
};
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
10
9
|
run(): Promise<void>;
|
|
11
10
|
private loadCredentials;
|
|
12
11
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import * as yaml from 'js-yaml';
|
|
3
2
|
import * as fs from 'node:fs';
|
|
4
3
|
import * as os from 'node:os';
|
|
5
4
|
import * as path from 'node:path';
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
6
|
import BaseCommand from '../../../base-command.js';
|
|
7
7
|
export default class WorkspaceList extends BaseCommand {
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
output: Flags.string({
|
|
11
|
+
char: 'o',
|
|
12
|
+
description: 'Output format',
|
|
13
|
+
required: false,
|
|
14
|
+
default: 'summary',
|
|
15
|
+
options: ['summary', 'json'],
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
8
18
|
static description = 'List all workspaces from the Xano Metadata API';
|
|
9
19
|
static examples = [
|
|
10
20
|
`$ xano workspace:list
|
|
@@ -43,16 +53,6 @@ Available workspaces:
|
|
|
43
53
|
}
|
|
44
54
|
`,
|
|
45
55
|
];
|
|
46
|
-
static flags = {
|
|
47
|
-
...BaseCommand.baseFlags,
|
|
48
|
-
output: Flags.string({
|
|
49
|
-
char: 'o',
|
|
50
|
-
default: 'summary',
|
|
51
|
-
description: 'Output format',
|
|
52
|
-
options: ['summary', 'json'],
|
|
53
|
-
required: false,
|
|
54
|
-
}),
|
|
55
|
-
};
|
|
56
56
|
async run() {
|
|
57
57
|
const { flags } = await this.parse(WorkspaceList);
|
|
58
58
|
// Get profile name (default or from flag/env)
|
|
@@ -77,11 +77,11 @@ Available workspaces:
|
|
|
77
77
|
// Fetch workspaces from the API
|
|
78
78
|
try {
|
|
79
79
|
const response = await fetch(apiUrl, {
|
|
80
|
+
method: 'GET',
|
|
80
81
|
headers: {
|
|
81
82
|
'accept': 'application/json',
|
|
82
83
|
'Authorization': `Bearer ${profile.access_token}`,
|
|
83
84
|
},
|
|
84
|
-
method: 'GET',
|
|
85
85
|
});
|
|
86
86
|
if (!response.ok) {
|
|
87
87
|
const errorText = await response.text();
|
|
@@ -111,11 +111,11 @@ Available workspaces:
|
|
|
111
111
|
else {
|
|
112
112
|
this.log('Available workspaces:');
|
|
113
113
|
for (const workspace of workspaces) {
|
|
114
|
-
if (workspace.id
|
|
115
|
-
this.log(` - ${workspace.name}`);
|
|
114
|
+
if (workspace.id !== undefined) {
|
|
115
|
+
this.log(` - ${workspace.name} (ID: ${workspace.id})`);
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
|
-
this.log(` - ${workspace.name}
|
|
118
|
+
this.log(` - ${workspace.name}`);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -3,17 +3,15 @@ export default class Pull extends BaseCommand {
|
|
|
3
3
|
static args: {
|
|
4
4
|
directory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
6
|
static flags: {
|
|
7
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
8
|
env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
9
|
records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
10
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
11
|
};
|
|
12
|
+
static description: string;
|
|
13
|
+
static examples: string[];
|
|
15
14
|
run(): Promise<void>;
|
|
16
|
-
private loadCredentials;
|
|
17
15
|
/**
|
|
18
16
|
* Parse a single document to extract its type, name, and optional verb.
|
|
19
17
|
* Skips leading comment lines (starting with //) to find the first
|
|
@@ -26,4 +24,5 @@ export default class Pull extends BaseCommand {
|
|
|
26
24
|
* characters that are unsafe in filenames.
|
|
27
25
|
*/
|
|
28
26
|
private sanitizeFilename;
|
|
27
|
+
private loadCredentials;
|
|
29
28
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import * as yaml from 'js-yaml';
|
|
3
2
|
import * as fs from 'node:fs';
|
|
4
3
|
import * as os from 'node:os';
|
|
5
4
|
import * as path from 'node:path';
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
6
|
import BaseCommand from '../../../base-command.js';
|
|
7
7
|
export default class Pull extends BaseCommand {
|
|
8
8
|
static args = {
|
|
@@ -11,6 +11,24 @@ export default class Pull extends BaseCommand {
|
|
|
11
11
|
required: true,
|
|
12
12
|
}),
|
|
13
13
|
};
|
|
14
|
+
static flags = {
|
|
15
|
+
...BaseCommand.baseFlags,
|
|
16
|
+
workspace: Flags.string({
|
|
17
|
+
char: 'w',
|
|
18
|
+
description: 'Workspace ID (optional if set in profile)',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
env: Flags.boolean({
|
|
22
|
+
description: 'Include environment variables',
|
|
23
|
+
required: false,
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
records: Flags.boolean({
|
|
27
|
+
description: 'Include records',
|
|
28
|
+
required: false,
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
14
32
|
static description = 'Pull a workspace multidoc from the Xano Metadata API and split into individual files';
|
|
15
33
|
static examples = [
|
|
16
34
|
`$ xano workspace pull ./my-workspace
|
|
@@ -23,24 +41,6 @@ Pulled 15 documents to ./output
|
|
|
23
41
|
Pulled 58 documents to ./backup
|
|
24
42
|
`,
|
|
25
43
|
];
|
|
26
|
-
static flags = {
|
|
27
|
-
...BaseCommand.baseFlags,
|
|
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
|
-
workspace: Flags.string({
|
|
39
|
-
char: 'w',
|
|
40
|
-
description: 'Workspace ID (optional if set in profile)',
|
|
41
|
-
required: false,
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
44
|
async run() {
|
|
45
45
|
const { args, flags } = await this.parse(Pull);
|
|
46
46
|
// Get profile name (default or from flag/env)
|
|
@@ -79,16 +79,16 @@ Pulled 58 documents to ./backup
|
|
|
79
79
|
records: flags.records.toString(),
|
|
80
80
|
});
|
|
81
81
|
// Construct the API URL
|
|
82
|
-
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/multidoc?${queryParams.toString()}`;
|
|
82
|
+
const apiUrl = `${profile.instance_origin}/api:meta/beta/workspace/${workspaceId}/multidoc?${queryParams.toString()}`;
|
|
83
83
|
// Fetch multidoc from the API
|
|
84
84
|
let responseText;
|
|
85
85
|
try {
|
|
86
86
|
const response = await fetch(apiUrl, {
|
|
87
|
+
method: 'GET',
|
|
87
88
|
headers: {
|
|
88
89
|
'accept': 'application/json',
|
|
89
90
|
'Authorization': `Bearer ${profile.access_token}`,
|
|
90
91
|
},
|
|
91
|
-
method: 'GET',
|
|
92
92
|
});
|
|
93
93
|
if (!response.ok) {
|
|
94
94
|
const errorText = await response.text();
|
|
@@ -147,34 +147,18 @@ Pulled 58 documents to ./backup
|
|
|
147
147
|
typeCounters.set(baseName, count + 1);
|
|
148
148
|
// Append numeric suffix for duplicates
|
|
149
149
|
let filename;
|
|
150
|
-
|
|
150
|
+
if (count === 0) {
|
|
151
|
+
filename = `${baseName}.xs`;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
filename = `${baseName}_${count + 1}.xs`;
|
|
155
|
+
}
|
|
151
156
|
const filePath = path.join(typeDir, filename);
|
|
152
157
|
fs.writeFileSync(filePath, doc.content, 'utf8');
|
|
153
158
|
writtenCount++;
|
|
154
159
|
}
|
|
155
160
|
this.log(`Pulled ${writtenCount} documents to ${args.directory}`);
|
|
156
161
|
}
|
|
157
|
-
loadCredentials() {
|
|
158
|
-
const configDir = path.join(os.homedir(), '.xano');
|
|
159
|
-
const credentialsPath = path.join(configDir, 'credentials.yaml');
|
|
160
|
-
// Check if credentials file exists
|
|
161
|
-
if (!fs.existsSync(credentialsPath)) {
|
|
162
|
-
this.error(`Credentials file not found at ${credentialsPath}\n` +
|
|
163
|
-
`Create a profile using 'xano profile:create'`);
|
|
164
|
-
}
|
|
165
|
-
// Read credentials file
|
|
166
|
-
try {
|
|
167
|
-
const fileContent = fs.readFileSync(credentialsPath, 'utf8');
|
|
168
|
-
const parsed = yaml.load(fileContent);
|
|
169
|
-
if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
|
|
170
|
-
this.error('Credentials file has invalid format.');
|
|
171
|
-
}
|
|
172
|
-
return parsed;
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
this.error(`Failed to parse credentials file: ${error}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
162
|
/**
|
|
179
163
|
* Parse a single document to extract its type, name, and optional verb.
|
|
180
164
|
* Skips leading comment lines (starting with //) to find the first
|
|
@@ -217,7 +201,7 @@ Pulled 58 documents to ./backup
|
|
|
217
201
|
if (verbMatch) {
|
|
218
202
|
verb = verbMatch[1];
|
|
219
203
|
}
|
|
220
|
-
return {
|
|
204
|
+
return { type, name, verb, content };
|
|
221
205
|
}
|
|
222
206
|
/**
|
|
223
207
|
* Sanitize a document name for use as a filename.
|
|
@@ -226,8 +210,29 @@ Pulled 58 documents to ./backup
|
|
|
226
210
|
*/
|
|
227
211
|
sanitizeFilename(name) {
|
|
228
212
|
return name
|
|
229
|
-
.
|
|
230
|
-
.
|
|
231
|
-
.
|
|
213
|
+
.replace(/"/g, '')
|
|
214
|
+
.replace(/\s+/g, '_')
|
|
215
|
+
.replace(/[<>:"/\\|?*]/g, '_');
|
|
216
|
+
}
|
|
217
|
+
loadCredentials() {
|
|
218
|
+
const configDir = path.join(os.homedir(), '.xano');
|
|
219
|
+
const credentialsPath = path.join(configDir, 'credentials.yaml');
|
|
220
|
+
// Check if credentials file exists
|
|
221
|
+
if (!fs.existsSync(credentialsPath)) {
|
|
222
|
+
this.error(`Credentials file not found at ${credentialsPath}\n` +
|
|
223
|
+
`Create a profile using 'xano profile:create'`);
|
|
224
|
+
}
|
|
225
|
+
// Read credentials file
|
|
226
|
+
try {
|
|
227
|
+
const fileContent = fs.readFileSync(credentialsPath, 'utf8');
|
|
228
|
+
const parsed = yaml.load(fileContent);
|
|
229
|
+
if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
|
|
230
|
+
this.error('Credentials file has invalid format.');
|
|
231
|
+
}
|
|
232
|
+
return parsed;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
this.error(`Failed to parse credentials file: ${error}`);
|
|
236
|
+
}
|
|
232
237
|
}
|
|
233
238
|
}
|
|
@@ -8,7 +8,6 @@ export default class Push extends BaseCommand {
|
|
|
8
8
|
static flags: {
|
|
9
9
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
11
|
};
|
|
13
12
|
run(): Promise<void>;
|
|
14
13
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import * as yaml from 'js-yaml';
|
|
3
2
|
import * as fs from 'node:fs';
|
|
4
3
|
import * as os from 'node:os';
|
|
5
4
|
import * as path from 'node:path';
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
6
|
import BaseCommand from '../../../base-command.js';
|
|
7
7
|
export default class Push extends BaseCommand {
|
|
8
8
|
static args = {
|
|
@@ -89,17 +89,17 @@ Pushed 58 documents from ./backup
|
|
|
89
89
|
}
|
|
90
90
|
const multidoc = documents.join('\n---\n');
|
|
91
91
|
// Construct the API URL
|
|
92
|
-
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/multidoc`;
|
|
92
|
+
const apiUrl = `${profile.instance_origin}/api:meta/beta/workspace/${workspaceId}/multidoc`;
|
|
93
93
|
// POST the multidoc to the API
|
|
94
94
|
try {
|
|
95
95
|
const response = await fetch(apiUrl, {
|
|
96
|
-
|
|
96
|
+
method: 'POST',
|
|
97
97
|
headers: {
|
|
98
98
|
'accept': 'application/json',
|
|
99
99
|
'Authorization': `Bearer ${profile.access_token}`,
|
|
100
100
|
'Content-Type': 'text/x-xanoscript',
|
|
101
101
|
},
|
|
102
|
-
|
|
102
|
+
body: multidoc,
|
|
103
103
|
});
|
|
104
104
|
if (!response.ok) {
|
|
105
105
|
const errorText = await response.text();
|
package/dist/help.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Help as BaseHelp
|
|
1
|
+
import { Command, Help as BaseHelp } from '@oclif/core';
|
|
2
2
|
import { CommandHelp as BaseCommandHelp } from '@oclif/core/help';
|
|
3
3
|
/**
|
|
4
4
|
* Custom CommandHelp class that extends the default to display environment variables
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
import BaseCommand from '../base-command.js';
|
|
5
5
|
import { RunHttpClient } from './run-http-client.js';
|
|
6
6
|
export interface ProfileConfig {
|
|
7
|
-
access_token: string;
|
|
8
7
|
account_origin?: string;
|
|
9
|
-
branch?: string;
|
|
10
8
|
instance_origin: string;
|
|
9
|
+
access_token: string;
|
|
10
|
+
workspace?: string;
|
|
11
|
+
branch?: string;
|
|
11
12
|
project?: string;
|
|
12
13
|
run_base_url?: string;
|
|
13
|
-
workspace?: string;
|
|
14
14
|
}
|
|
15
15
|
export interface CredentialsFile {
|
|
16
|
-
default?: string;
|
|
17
16
|
profiles: {
|
|
18
17
|
[key: string]: ProfileConfig;
|
|
19
18
|
};
|
|
19
|
+
default?: string;
|
|
20
20
|
}
|
|
21
21
|
export default abstract class BaseRunCommand extends BaseCommand {
|
|
22
22
|
protected httpClient: RunHttpClient;
|
|
@@ -25,11 +25,11 @@ export default abstract class BaseRunCommand extends BaseCommand {
|
|
|
25
25
|
/**
|
|
26
26
|
* Initialize the run command with profile and HTTP client
|
|
27
27
|
*/
|
|
28
|
-
protected initRunCommand(profileFlag?: string
|
|
28
|
+
protected initRunCommand(profileFlag?: string): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* Initialize with project required
|
|
31
31
|
*/
|
|
32
|
-
protected initRunCommandWithProject(profileFlag?: string
|
|
32
|
+
protected initRunCommandWithProject(profileFlag?: string): Promise<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Load credentials from file
|
|
35
35
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base command for all run commands
|
|
3
3
|
*/
|
|
4
|
-
import * as yaml from 'js-yaml';
|
|
5
4
|
import * as fs from 'node:fs';
|
|
6
5
|
import * as os from 'node:os';
|
|
7
6
|
import * as path from 'node:path';
|
|
7
|
+
import * as yaml from 'js-yaml';
|
|
8
8
|
import BaseCommand from '../base-command.js';
|
|
9
9
|
import { DEFAULT_RUN_BASE_URL, RunHttpClient } from './run-http-client.js';
|
|
10
10
|
export default class BaseRunCommand extends BaseCommand {
|
|
@@ -14,7 +14,7 @@ export default class BaseRunCommand extends BaseCommand {
|
|
|
14
14
|
/**
|
|
15
15
|
* Initialize the run command with profile and HTTP client
|
|
16
16
|
*/
|
|
17
|
-
async initRunCommand(profileFlag
|
|
17
|
+
async initRunCommand(profileFlag) {
|
|
18
18
|
this.profileName = profileFlag || this.getDefaultProfile();
|
|
19
19
|
const credentials = this.loadCredentials();
|
|
20
20
|
if (!(this.profileName in credentials.profiles)) {
|
|
@@ -27,21 +27,19 @@ export default class BaseRunCommand extends BaseCommand {
|
|
|
27
27
|
}
|
|
28
28
|
const baseUrl = this.profile.run_base_url || DEFAULT_RUN_BASE_URL;
|
|
29
29
|
this.httpClient = new RunHttpClient({
|
|
30
|
-
authToken: this.profile.access_token,
|
|
31
30
|
baseUrl,
|
|
32
|
-
|
|
31
|
+
authToken: this.profile.access_token,
|
|
33
32
|
projectId: this.profile.project,
|
|
34
|
-
verbose,
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* Initialize with project required
|
|
39
37
|
*/
|
|
40
|
-
async initRunCommandWithProject(profileFlag
|
|
41
|
-
await this.initRunCommand(profileFlag
|
|
38
|
+
async initRunCommandWithProject(profileFlag) {
|
|
39
|
+
await this.initRunCommand(profileFlag);
|
|
42
40
|
if (!this.profile.project) {
|
|
43
41
|
this.error(`Profile '${this.profileName}' is missing project. ` +
|
|
44
|
-
`
|
|
42
|
+
`Update your profile with 'xano profile:edit --project <project-id>'`);
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
/**
|
|
@@ -2,49 +2,43 @@
|
|
|
2
2
|
* HTTP client for Xano Run API
|
|
3
3
|
* Based on @xano/run-sdk HttpClient
|
|
4
4
|
*/
|
|
5
|
-
export declare const DEFAULT_RUN_BASE_URL = "https://app.
|
|
5
|
+
export declare const DEFAULT_RUN_BASE_URL = "https://app.xano.com/";
|
|
6
6
|
export interface RunHttpClientConfig {
|
|
7
|
-
authToken: string;
|
|
8
7
|
baseUrl: string;
|
|
9
|
-
|
|
8
|
+
authToken: string;
|
|
10
9
|
projectId?: string;
|
|
11
|
-
verbose?: boolean;
|
|
12
10
|
}
|
|
13
11
|
export declare class RunHttpClient {
|
|
14
12
|
private readonly config;
|
|
15
13
|
constructor(config: RunHttpClientConfig);
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
15
|
+
* Get the project ID
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
getProjectId(): string | undefined;
|
|
20
18
|
/**
|
|
21
|
-
* Build
|
|
19
|
+
* Build headers for a request
|
|
22
20
|
*/
|
|
23
|
-
|
|
21
|
+
getHeaders(contentType?: string): HeadersInit;
|
|
24
22
|
/**
|
|
25
23
|
* Build a URL with optional query parameters
|
|
26
24
|
*/
|
|
27
25
|
buildUrl(path: string, queryParams?: Record<string, unknown>): string;
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
delete<T>(url: string, body?: unknown): Promise<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Make a GET request
|
|
27
|
+
* Build a URL scoped to the current project
|
|
34
28
|
*/
|
|
35
|
-
|
|
29
|
+
buildProjectUrl(path: string, queryParams?: Record<string, unknown>): string;
|
|
36
30
|
/**
|
|
37
|
-
* Build
|
|
31
|
+
* Build a URL scoped to a specific session
|
|
38
32
|
*/
|
|
39
|
-
|
|
33
|
+
buildSessionUrl(sessionId: string, path?: string, queryParams?: Record<string, unknown>): string;
|
|
40
34
|
/**
|
|
41
|
-
*
|
|
35
|
+
* Make an HTTP request
|
|
42
36
|
*/
|
|
43
|
-
|
|
37
|
+
request<T>(url: string, options: RequestInit): Promise<T>;
|
|
44
38
|
/**
|
|
45
|
-
* Make a
|
|
39
|
+
* Make a GET request
|
|
46
40
|
*/
|
|
47
|
-
|
|
41
|
+
get<T>(url: string): Promise<T>;
|
|
48
42
|
/**
|
|
49
43
|
* Make a POST request with JSON body
|
|
50
44
|
*/
|
|
@@ -54,11 +48,11 @@ export declare class RunHttpClient {
|
|
|
54
48
|
*/
|
|
55
49
|
postXanoScript<T>(url: string, code: string): Promise<T>;
|
|
56
50
|
/**
|
|
57
|
-
* Make
|
|
51
|
+
* Make a PATCH request
|
|
58
52
|
*/
|
|
59
|
-
|
|
53
|
+
patch<T>(url: string, body: unknown): Promise<T>;
|
|
60
54
|
/**
|
|
61
|
-
*
|
|
55
|
+
* Make a DELETE request
|
|
62
56
|
*/
|
|
63
|
-
|
|
57
|
+
delete<T>(url: string, body?: unknown): Promise<T>;
|
|
64
58
|
}
|