@xano/cli 0.0.25 → 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 +849 -2027
- package/package.json +3 -1
- package/dist/commands/auth/index.d.ts +0 -21
- package/dist/commands/auth/index.js +0 -533
- 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
|
@@ -7,6 +7,16 @@ export default class RunEnvGet extends BaseRunCommand {
|
|
|
7
7
|
required: true,
|
|
8
8
|
}),
|
|
9
9
|
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
output: Flags.string({
|
|
13
|
+
char: 'o',
|
|
14
|
+
description: 'Output format',
|
|
15
|
+
required: false,
|
|
16
|
+
default: 'value',
|
|
17
|
+
options: ['value', 'json'],
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
10
20
|
static description = 'Get an environment variable value';
|
|
11
21
|
static examples = [
|
|
12
22
|
`$ xano run env get API_KEY
|
|
@@ -16,20 +26,10 @@ my-secret-api-key
|
|
|
16
26
|
{ "name": "API_KEY", "value": "my-secret-api-key" }
|
|
17
27
|
`,
|
|
18
28
|
];
|
|
19
|
-
static flags = {
|
|
20
|
-
...BaseRunCommand.baseFlags,
|
|
21
|
-
output: Flags.string({
|
|
22
|
-
char: 'o',
|
|
23
|
-
default: 'value',
|
|
24
|
-
description: 'Output format',
|
|
25
|
-
options: ['value', 'json'],
|
|
26
|
-
required: false,
|
|
27
|
-
}),
|
|
28
|
-
};
|
|
29
29
|
async run() {
|
|
30
30
|
const { args, flags } = await this.parse(RunEnvGet);
|
|
31
31
|
// Initialize with project required
|
|
32
|
-
await this.initRunCommandWithProject(flags.profile
|
|
32
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
33
33
|
try {
|
|
34
34
|
const url = this.httpClient.buildProjectUrl('/env', { name: args.name });
|
|
35
35
|
const result = await this.httpClient.get(url);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
2
|
export default class RunEnvList extends BaseRunCommand {
|
|
3
3
|
static args: {};
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
4
|
static flags: {
|
|
7
5
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
6
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
7
|
};
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
11
10
|
run(): Promise<void>;
|
|
12
11
|
}
|
|
@@ -2,6 +2,16 @@ import { Flags } from '@oclif/core';
|
|
|
2
2
|
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
3
|
export default class RunEnvList extends BaseRunCommand {
|
|
4
4
|
static args = {};
|
|
5
|
+
static flags = {
|
|
6
|
+
...BaseRunCommand.baseFlags,
|
|
7
|
+
output: Flags.string({
|
|
8
|
+
char: 'o',
|
|
9
|
+
description: 'Output format',
|
|
10
|
+
required: false,
|
|
11
|
+
default: 'list',
|
|
12
|
+
options: ['list', 'json'],
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
5
15
|
static description = 'List all environment variable keys';
|
|
6
16
|
static examples = [
|
|
7
17
|
`$ xano run env list
|
|
@@ -14,33 +24,25 @@ Environment variables:
|
|
|
14
24
|
{ "env": ["API_KEY", "DATABASE_URL", "DEBUG"] }
|
|
15
25
|
`,
|
|
16
26
|
];
|
|
17
|
-
static flags = {
|
|
18
|
-
...BaseRunCommand.baseFlags,
|
|
19
|
-
output: Flags.string({
|
|
20
|
-
char: 'o',
|
|
21
|
-
default: 'list',
|
|
22
|
-
description: 'Output format',
|
|
23
|
-
options: ['list', 'json'],
|
|
24
|
-
required: false,
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
27
|
async run() {
|
|
28
28
|
const { flags } = await this.parse(RunEnvList);
|
|
29
29
|
// Initialize with project required
|
|
30
|
-
await this.initRunCommandWithProject(flags.profile
|
|
30
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
31
31
|
try {
|
|
32
32
|
const url = this.httpClient.buildProjectUrl('/env/key');
|
|
33
33
|
const result = await this.httpClient.get(url);
|
|
34
34
|
if (flags.output === 'json') {
|
|
35
35
|
this.outputJson(result);
|
|
36
36
|
}
|
|
37
|
-
else if (result.env.length === 0) {
|
|
38
|
-
this.log('No environment variables found.');
|
|
39
|
-
}
|
|
40
37
|
else {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
if (result.env.length === 0) {
|
|
39
|
+
this.log('No environment variables found.');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.log('Environment variables:');
|
|
43
|
+
for (const key of result.env) {
|
|
44
|
+
this.log(` - ${key}`);
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -4,11 +4,10 @@ export default class RunEnvSet extends BaseRunCommand {
|
|
|
4
4
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
value: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
6
|
};
|
|
7
|
-
static description: string;
|
|
8
|
-
static examples: string[];
|
|
9
7
|
static flags: {
|
|
10
8
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
9
|
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
13
12
|
run(): Promise<void>;
|
|
14
13
|
}
|
|
@@ -11,6 +11,9 @@ export default class RunEnvSet extends BaseRunCommand {
|
|
|
11
11
|
required: true,
|
|
12
12
|
}),
|
|
13
13
|
};
|
|
14
|
+
static flags = {
|
|
15
|
+
...BaseRunCommand.baseFlags,
|
|
16
|
+
};
|
|
14
17
|
static description = 'Set an environment variable';
|
|
15
18
|
static examples = [
|
|
16
19
|
`$ xano run env set API_KEY my-secret-key
|
|
@@ -20,19 +23,16 @@ Environment variable 'API_KEY' set successfully!
|
|
|
20
23
|
Environment variable 'DATABASE_URL' set successfully!
|
|
21
24
|
`,
|
|
22
25
|
];
|
|
23
|
-
static flags = {
|
|
24
|
-
...BaseRunCommand.baseFlags,
|
|
25
|
-
};
|
|
26
26
|
async run() {
|
|
27
27
|
const { args, flags } = await this.parse(RunEnvSet);
|
|
28
28
|
// Initialize with project required
|
|
29
|
-
await this.initRunCommandWithProject(flags.profile
|
|
29
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
30
30
|
const input = {
|
|
31
|
+
name: args.name,
|
|
31
32
|
env: {
|
|
32
33
|
name: args.name,
|
|
33
34
|
value: args.value,
|
|
34
35
|
},
|
|
35
|
-
name: args.name,
|
|
36
36
|
};
|
|
37
37
|
try {
|
|
38
38
|
const url = this.httpClient.buildProjectUrl('/env');
|
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
import BaseRunCommand from '../../../lib/base-run-command.js';
|
|
2
2
|
export default class RunExec extends BaseRunCommand {
|
|
3
|
-
static args: {
|
|
4
|
-
path: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
3
|
+
static args: {};
|
|
8
4
|
static flags: {
|
|
9
|
-
args: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
edit: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
env: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
5
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
6
|
stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
edit: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
args: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
env: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
11
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
12
|
};
|
|
13
|
+
static description: string;
|
|
14
|
+
static examples: string[];
|
|
18
15
|
run(): Promise<void>;
|
|
19
|
-
|
|
20
|
-
* Recursively collect all .xs files from a directory, sorted for deterministic ordering.
|
|
21
|
-
*/
|
|
22
|
-
private collectFiles;
|
|
16
|
+
private outputSummary;
|
|
23
17
|
private editFile;
|
|
24
18
|
private isUrl;
|
|
25
|
-
/**
|
|
26
|
-
* Load all .xs files from a directory and combine them into a multidoc.
|
|
27
|
-
*/
|
|
28
|
-
private loadMultidocFromDirectory;
|
|
29
|
-
private outputSummary;
|
|
30
19
|
private readStdin;
|
|
31
20
|
}
|
|
@@ -1,28 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
3
|
import * as fs from 'node:fs';
|
|
4
4
|
import * as os from 'node:os';
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import BaseRunCommand from '../../../lib/base-run-command.js';
|
|
7
7
|
export default class RunExec extends BaseRunCommand {
|
|
8
|
-
static args = {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
static args = {};
|
|
9
|
+
static flags = {
|
|
10
|
+
...BaseRunCommand.baseFlags,
|
|
11
|
+
file: Flags.string({
|
|
12
|
+
char: 'f',
|
|
13
|
+
description: 'Path or URL to file containing XanoScript code',
|
|
11
14
|
required: false,
|
|
15
|
+
exclusive: ['stdin'],
|
|
16
|
+
}),
|
|
17
|
+
stdin: Flags.boolean({
|
|
18
|
+
char: 's',
|
|
19
|
+
description: 'Read XanoScript code from stdin',
|
|
20
|
+
required: false,
|
|
21
|
+
default: false,
|
|
22
|
+
exclusive: ['file'],
|
|
23
|
+
}),
|
|
24
|
+
edit: Flags.boolean({
|
|
25
|
+
char: 'e',
|
|
26
|
+
description: 'Open file in editor before running (requires --file)',
|
|
27
|
+
required: false,
|
|
28
|
+
default: false,
|
|
29
|
+
dependsOn: ['file'],
|
|
30
|
+
}),
|
|
31
|
+
output: Flags.string({
|
|
32
|
+
char: 'o',
|
|
33
|
+
description: 'Output format',
|
|
34
|
+
required: false,
|
|
35
|
+
default: 'summary',
|
|
36
|
+
options: ['summary', 'json'],
|
|
37
|
+
}),
|
|
38
|
+
args: Flags.string({
|
|
39
|
+
char: 'a',
|
|
40
|
+
description: 'Path or URL to JSON file containing input arguments',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
env: Flags.string({
|
|
44
|
+
description: 'Environment variable override (key=value)',
|
|
45
|
+
required: false,
|
|
46
|
+
multiple: true,
|
|
12
47
|
}),
|
|
13
48
|
};
|
|
14
49
|
static description = 'Execute XanoScript code (job or service)';
|
|
15
50
|
static examples = [
|
|
16
|
-
`$ xano run exec script.xs
|
|
17
|
-
Executed successfully!
|
|
18
|
-
...
|
|
19
|
-
`,
|
|
20
|
-
`$ xano run exec ./my-workspace
|
|
21
|
-
# Executes all .xs files in directory as multidoc
|
|
51
|
+
`$ xano run exec -f script.xs
|
|
22
52
|
Executed successfully!
|
|
23
53
|
...
|
|
24
54
|
`,
|
|
25
|
-
`$ xano run exec script.xs --edit
|
|
55
|
+
`$ xano run exec -f script.xs --edit
|
|
26
56
|
# Opens script.xs in $EDITOR, then executes
|
|
27
57
|
Executed successfully!
|
|
28
58
|
...
|
|
@@ -31,102 +61,45 @@ Executed successfully!
|
|
|
31
61
|
Executed successfully!
|
|
32
62
|
...
|
|
33
63
|
`,
|
|
34
|
-
`$ xano run exec script.xs -o json
|
|
64
|
+
`$ xano run exec -f script.xs -o json
|
|
35
65
|
{
|
|
36
66
|
"run": { ... }
|
|
37
67
|
}
|
|
38
68
|
`,
|
|
39
|
-
`$ xano run exec script.xs -a args.json
|
|
69
|
+
`$ xano run exec -f script.xs -a args.json
|
|
40
70
|
# Executes with input arguments from args.json
|
|
41
71
|
Executed successfully!
|
|
42
72
|
...
|
|
43
73
|
`,
|
|
44
|
-
`$ xano run exec script.xs --env API_KEY=secret --env DEBUG=true
|
|
74
|
+
`$ xano run exec -f script.xs --env API_KEY=secret --env DEBUG=true
|
|
45
75
|
# Executes with environment variable overrides
|
|
46
76
|
Executed successfully!
|
|
47
77
|
...
|
|
48
78
|
`,
|
|
49
79
|
];
|
|
50
|
-
static flags = {
|
|
51
|
-
...BaseRunCommand.baseFlags,
|
|
52
|
-
args: Flags.string({
|
|
53
|
-
char: 'a',
|
|
54
|
-
description: 'Path or URL to JSON file containing input arguments',
|
|
55
|
-
required: false,
|
|
56
|
-
}),
|
|
57
|
-
edit: Flags.boolean({
|
|
58
|
-
char: 'e',
|
|
59
|
-
default: false,
|
|
60
|
-
description: 'Open file in editor before running (requires path argument or --file)',
|
|
61
|
-
required: false,
|
|
62
|
-
}),
|
|
63
|
-
env: Flags.string({
|
|
64
|
-
description: 'Environment variable override (key=value)',
|
|
65
|
-
multiple: true,
|
|
66
|
-
required: false,
|
|
67
|
-
}),
|
|
68
|
-
file: Flags.string({
|
|
69
|
-
char: 'f',
|
|
70
|
-
description: 'Path or URL to file containing XanoScript code (deprecated: use path argument instead)',
|
|
71
|
-
exclusive: ['stdin'],
|
|
72
|
-
required: false,
|
|
73
|
-
}),
|
|
74
|
-
output: Flags.string({
|
|
75
|
-
char: 'o',
|
|
76
|
-
default: 'summary',
|
|
77
|
-
description: 'Output format',
|
|
78
|
-
options: ['summary', 'json'],
|
|
79
|
-
required: false,
|
|
80
|
-
}),
|
|
81
|
-
stdin: Flags.boolean({
|
|
82
|
-
char: 's',
|
|
83
|
-
default: false,
|
|
84
|
-
description: 'Read XanoScript code from stdin',
|
|
85
|
-
exclusive: ['file'],
|
|
86
|
-
required: false,
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
80
|
async run() {
|
|
90
|
-
const {
|
|
81
|
+
const { flags } = await this.parse(RunExec);
|
|
91
82
|
// Initialize with project required
|
|
92
|
-
await this.initRunCommandWithProject(flags.profile
|
|
93
|
-
// Determine input source: path argument, --file flag, or --stdin
|
|
94
|
-
const inputPath = args.path || flags.file;
|
|
95
|
-
// Validate --edit flag requirements
|
|
96
|
-
if (flags.edit) {
|
|
97
|
-
if (!inputPath) {
|
|
98
|
-
this.error('--edit requires a file path (either path argument or --file flag)');
|
|
99
|
-
}
|
|
100
|
-
if (this.isUrl(inputPath)) {
|
|
101
|
-
this.error('--edit cannot be used with URLs');
|
|
102
|
-
}
|
|
103
|
-
if (fs.existsSync(inputPath) && fs.statSync(inputPath).isDirectory()) {
|
|
104
|
-
this.error('--edit cannot be used with directories');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
83
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
107
84
|
// Read XanoScript content
|
|
108
85
|
let xanoscript;
|
|
109
|
-
if (
|
|
110
|
-
if (this.isUrl(
|
|
86
|
+
if (flags.file) {
|
|
87
|
+
if (this.isUrl(flags.file)) {
|
|
111
88
|
// Fetch URL content
|
|
112
89
|
try {
|
|
113
|
-
const response = await fetch(
|
|
90
|
+
const response = await fetch(flags.file);
|
|
114
91
|
if (!response.ok) {
|
|
115
92
|
this.error(`Failed to fetch URL: ${response.status} ${response.statusText}`);
|
|
116
93
|
}
|
|
117
94
|
xanoscript = await response.text();
|
|
118
95
|
}
|
|
119
96
|
catch (error) {
|
|
120
|
-
this.error(`Failed to fetch URL '${
|
|
97
|
+
this.error(`Failed to fetch URL '${flags.file}': ${error}`);
|
|
121
98
|
}
|
|
122
99
|
}
|
|
123
|
-
else if (fs.existsSync(inputPath) && fs.statSync(inputPath).isDirectory()) {
|
|
124
|
-
// Handle directory - collect .xs files and create multidoc
|
|
125
|
-
xanoscript = this.loadMultidocFromDirectory(inputPath);
|
|
126
|
-
}
|
|
127
100
|
else if (flags.edit) {
|
|
128
101
|
// If edit flag is set, copy to temp file and open in editor
|
|
129
|
-
const fileToRead = await this.editFile(
|
|
102
|
+
const fileToRead = await this.editFile(flags.file);
|
|
130
103
|
xanoscript = fs.readFileSync(fileToRead, 'utf8');
|
|
131
104
|
// Clean up temp file
|
|
132
105
|
try {
|
|
@@ -138,10 +111,10 @@ Executed successfully!
|
|
|
138
111
|
}
|
|
139
112
|
else {
|
|
140
113
|
try {
|
|
141
|
-
xanoscript = fs.readFileSync(
|
|
114
|
+
xanoscript = fs.readFileSync(flags.file, 'utf8');
|
|
142
115
|
}
|
|
143
116
|
catch (error) {
|
|
144
|
-
this.error(`Failed to read file '${
|
|
117
|
+
this.error(`Failed to read file '${flags.file}': ${error}`);
|
|
145
118
|
}
|
|
146
119
|
}
|
|
147
120
|
}
|
|
@@ -154,7 +127,7 @@ Executed successfully!
|
|
|
154
127
|
}
|
|
155
128
|
}
|
|
156
129
|
else {
|
|
157
|
-
this.error('Either
|
|
130
|
+
this.error('Either --file or --stdin must be specified to provide XanoScript code');
|
|
158
131
|
}
|
|
159
132
|
// Validate xanoscript is not empty
|
|
160
133
|
if (!xanoscript || xanoscript.trim().length === 0) {
|
|
@@ -222,115 +195,13 @@ Executed successfully!
|
|
|
222
195
|
}
|
|
223
196
|
catch (error) {
|
|
224
197
|
if (error instanceof Error) {
|
|
225
|
-
|
|
226
|
-
if (xanoError.response) {
|
|
227
|
-
const responseStr = typeof xanoError.response === 'string'
|
|
228
|
-
? xanoError.response
|
|
229
|
-
: JSON.stringify(xanoError.response, null, 2);
|
|
230
|
-
this.error(`Failed to execute: ${error.message}\n\n${responseStr}`);
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
this.error(`Failed to execute: ${error.message}`);
|
|
234
|
-
}
|
|
198
|
+
this.error(`Failed to execute: ${error.message}`);
|
|
235
199
|
}
|
|
236
200
|
else {
|
|
237
201
|
this.error(`Failed to execute: ${String(error)}`);
|
|
238
202
|
}
|
|
239
203
|
}
|
|
240
204
|
}
|
|
241
|
-
/**
|
|
242
|
-
* Recursively collect all .xs files from a directory, sorted for deterministic ordering.
|
|
243
|
-
*/
|
|
244
|
-
collectFiles(dir) {
|
|
245
|
-
const files = [];
|
|
246
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
247
|
-
for (const entry of entries) {
|
|
248
|
-
const fullPath = path.join(dir, entry.name);
|
|
249
|
-
if (entry.isDirectory()) {
|
|
250
|
-
files.push(...this.collectFiles(fullPath));
|
|
251
|
-
}
|
|
252
|
-
else if (entry.isFile() && entry.name.endsWith('.xs')) {
|
|
253
|
-
files.push(fullPath);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return files.sort();
|
|
257
|
-
}
|
|
258
|
-
// Editor value comes from EDITOR/VISUAL environment variables, not user input
|
|
259
|
-
async editFile(filePath) {
|
|
260
|
-
const editor = process.env.EDITOR || process.env.VISUAL;
|
|
261
|
-
if (!editor) {
|
|
262
|
-
this.error('No editor configured. Please set the EDITOR or VISUAL environment variable.\n' +
|
|
263
|
-
'Example: export EDITOR=vim');
|
|
264
|
-
}
|
|
265
|
-
// Validate editor executable exists
|
|
266
|
-
try {
|
|
267
|
-
execSync(`which ${editor.split(' ')[0]}`, { stdio: 'ignore' });
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
270
|
-
this.error(`Editor '${editor}' not found. Please set EDITOR to a valid editor.\n` +
|
|
271
|
-
'Example: export EDITOR=vim');
|
|
272
|
-
}
|
|
273
|
-
// Read the original file
|
|
274
|
-
let originalContent;
|
|
275
|
-
try {
|
|
276
|
-
originalContent = fs.readFileSync(filePath, 'utf8');
|
|
277
|
-
}
|
|
278
|
-
catch (error) {
|
|
279
|
-
this.error(`Failed to read file '${filePath}': ${error}`);
|
|
280
|
-
}
|
|
281
|
-
// Create a temporary file with the same extension
|
|
282
|
-
const ext = path.extname(filePath);
|
|
283
|
-
const tmpFile = path.join(os.tmpdir(), `xano-edit-${Date.now()}${ext}`);
|
|
284
|
-
// Copy content to temp file
|
|
285
|
-
try {
|
|
286
|
-
fs.writeFileSync(tmpFile, originalContent, 'utf8');
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
this.error(`Failed to create temporary file: ${error}`);
|
|
290
|
-
}
|
|
291
|
-
// Open the editor
|
|
292
|
-
try {
|
|
293
|
-
execSync(`${editor} ${tmpFile}`, { stdio: 'inherit' });
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
try {
|
|
297
|
-
fs.unlinkSync(tmpFile);
|
|
298
|
-
}
|
|
299
|
-
catch {
|
|
300
|
-
// Ignore cleanup errors
|
|
301
|
-
}
|
|
302
|
-
this.error(`Editor exited with an error: ${error}`);
|
|
303
|
-
}
|
|
304
|
-
return tmpFile;
|
|
305
|
-
}
|
|
306
|
-
isUrl(str) {
|
|
307
|
-
return str.startsWith('http://') || str.startsWith('https://');
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Load all .xs files from a directory and combine them into a multidoc.
|
|
311
|
-
*/
|
|
312
|
-
loadMultidocFromDirectory(dir) {
|
|
313
|
-
const resolvedDir = path.resolve(dir);
|
|
314
|
-
if (!fs.existsSync(resolvedDir)) {
|
|
315
|
-
this.error(`Directory not found: ${resolvedDir}`);
|
|
316
|
-
}
|
|
317
|
-
const files = this.collectFiles(resolvedDir);
|
|
318
|
-
if (files.length === 0) {
|
|
319
|
-
this.error(`No .xs files found in ${dir}`);
|
|
320
|
-
}
|
|
321
|
-
// Read each file and join with --- separator
|
|
322
|
-
const documents = [];
|
|
323
|
-
for (const filePath of files) {
|
|
324
|
-
const content = fs.readFileSync(filePath, 'utf8').trim();
|
|
325
|
-
if (content) {
|
|
326
|
-
documents.push(content);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (documents.length === 0) {
|
|
330
|
-
this.error(`All .xs files in ${dir} are empty`);
|
|
331
|
-
}
|
|
332
|
-
return documents.join('\n---\n');
|
|
333
|
-
}
|
|
334
205
|
outputSummary(result) {
|
|
335
206
|
this.log('Executed successfully!');
|
|
336
207
|
this.log('');
|
|
@@ -345,7 +216,7 @@ Executed successfully!
|
|
|
345
216
|
this.log(` Run ID: ${result.run.id}`);
|
|
346
217
|
}
|
|
347
218
|
if (result.run?.session) {
|
|
348
|
-
const
|
|
219
|
+
const session = result.run.session;
|
|
349
220
|
this.log(` Session ID: ${session.id}`);
|
|
350
221
|
this.log(` State: ${session.state}`);
|
|
351
222
|
this.log('');
|
|
@@ -353,7 +224,7 @@ Executed successfully!
|
|
|
353
224
|
// Handle timing info
|
|
354
225
|
const timing = result.run?.result || result.run?.session || result.result;
|
|
355
226
|
if (timing) {
|
|
356
|
-
const formatTime = (time) => time
|
|
227
|
+
const formatTime = (time) => time !== undefined ? `${(time * 1000).toFixed(2)}ms` : undefined;
|
|
357
228
|
const times = [
|
|
358
229
|
{ label: 'Total', value: formatTime(timing.total_time) },
|
|
359
230
|
{ label: 'Boot', value: formatTime(timing.boot_time) },
|
|
@@ -413,6 +284,57 @@ Executed successfully!
|
|
|
413
284
|
this.log(` Error: ${result.run.session.error_msg}`);
|
|
414
285
|
}
|
|
415
286
|
}
|
|
287
|
+
// Editor value comes from EDITOR/VISUAL environment variables, not user input
|
|
288
|
+
async editFile(filePath) {
|
|
289
|
+
const editor = process.env.EDITOR || process.env.VISUAL;
|
|
290
|
+
if (!editor) {
|
|
291
|
+
this.error('No editor configured. Please set the EDITOR or VISUAL environment variable.\n' +
|
|
292
|
+
'Example: export EDITOR=vim');
|
|
293
|
+
}
|
|
294
|
+
// Validate editor executable exists
|
|
295
|
+
try {
|
|
296
|
+
execSync(`which ${editor.split(' ')[0]}`, { stdio: 'ignore' });
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
this.error(`Editor '${editor}' not found. Please set EDITOR to a valid editor.\n` +
|
|
300
|
+
'Example: export EDITOR=vim');
|
|
301
|
+
}
|
|
302
|
+
// Read the original file
|
|
303
|
+
let originalContent;
|
|
304
|
+
try {
|
|
305
|
+
originalContent = fs.readFileSync(filePath, 'utf8');
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
this.error(`Failed to read file '${filePath}': ${error}`);
|
|
309
|
+
}
|
|
310
|
+
// Create a temporary file with the same extension
|
|
311
|
+
const ext = path.extname(filePath);
|
|
312
|
+
const tmpFile = path.join(os.tmpdir(), `xano-edit-${Date.now()}${ext}`);
|
|
313
|
+
// Copy content to temp file
|
|
314
|
+
try {
|
|
315
|
+
fs.writeFileSync(tmpFile, originalContent, 'utf8');
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
this.error(`Failed to create temporary file: ${error}`);
|
|
319
|
+
}
|
|
320
|
+
// Open the editor
|
|
321
|
+
try {
|
|
322
|
+
execSync(`${editor} ${tmpFile}`, { stdio: 'inherit' });
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
try {
|
|
326
|
+
fs.unlinkSync(tmpFile);
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
// Ignore cleanup errors
|
|
330
|
+
}
|
|
331
|
+
this.error(`Editor exited with an error: ${error}`);
|
|
332
|
+
}
|
|
333
|
+
return tmpFile;
|
|
334
|
+
}
|
|
335
|
+
isUrl(str) {
|
|
336
|
+
return str.startsWith('http://') || str.startsWith('https://');
|
|
337
|
+
}
|
|
416
338
|
async readStdin() {
|
|
417
339
|
return new Promise((resolve, reject) => {
|
|
418
340
|
const chunks = [];
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import BaseRunCommand from '../../../lib/base-run-command.js';
|
|
2
2
|
export default class RunInfo extends BaseRunCommand {
|
|
3
3
|
static args: {};
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
4
|
static flags: {
|
|
7
5
|
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
6
|
stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
8
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
9
|
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
13
12
|
run(): Promise<void>;
|
|
14
|
-
private isUrl;
|
|
15
13
|
private outputSummary;
|
|
14
|
+
private isUrl;
|
|
16
15
|
private readStdin;
|
|
17
16
|
}
|