@xano/cli 0.0.14 → 0.0.16
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 +115 -14
- package/dist/commands/profile/create/index.d.ts +2 -0
- package/dist/commands/profile/create/index.js +15 -0
- package/dist/commands/profile/edit/index.d.ts +6 -0
- package/dist/commands/profile/edit/index.js +50 -1
- package/dist/commands/profile/list/index.js +5 -0
- package/dist/commands/profile/project/index.d.ts +6 -0
- package/dist/commands/profile/project/index.js +54 -0
- package/dist/commands/profile/token/index.d.ts +6 -0
- package/dist/commands/profile/token/index.js +54 -0
- package/dist/commands/profile/wizard/index.d.ts +2 -0
- package/dist/commands/profile/wizard/index.js +108 -0
- package/dist/commands/run/env/delete/index.d.ts +13 -0
- package/dist/commands/run/env/delete/index.js +65 -0
- package/dist/commands/run/env/get/index.d.ts +13 -0
- package/dist/commands/run/env/get/index.js +52 -0
- package/dist/commands/run/env/list/index.d.ts +11 -0
- package/dist/commands/run/env/list/index.js +58 -0
- package/dist/commands/run/env/set/index.d.ts +13 -0
- package/dist/commands/run/env/set/index.js +51 -0
- package/dist/commands/{ephemeral/run/job → run/exec}/index.d.ts +4 -3
- package/dist/commands/run/exec/index.js +353 -0
- package/dist/commands/{ephemeral/run/service → run/info}/index.d.ts +3 -5
- package/dist/commands/run/info/index.js +160 -0
- package/dist/commands/run/projects/create/index.d.ts +13 -0
- package/dist/commands/run/projects/create/index.js +75 -0
- package/dist/commands/run/projects/delete/index.d.ts +13 -0
- package/dist/commands/run/projects/delete/index.js +65 -0
- package/dist/commands/run/projects/list/index.d.ts +12 -0
- package/dist/commands/run/projects/list/index.js +66 -0
- package/dist/commands/run/projects/update/index.d.ts +15 -0
- package/dist/commands/run/projects/update/index.js +86 -0
- package/dist/commands/run/secrets/delete/index.d.ts +13 -0
- package/dist/commands/run/secrets/delete/index.js +65 -0
- package/dist/commands/run/secrets/get/index.d.ts +13 -0
- package/dist/commands/run/secrets/get/index.js +52 -0
- package/dist/commands/run/secrets/list/index.d.ts +11 -0
- package/dist/commands/run/secrets/list/index.js +62 -0
- package/dist/commands/run/secrets/set/index.d.ts +15 -0
- package/dist/commands/run/secrets/set/index.js +74 -0
- package/dist/commands/run/sessions/delete/index.d.ts +13 -0
- package/dist/commands/run/sessions/delete/index.js +65 -0
- package/dist/commands/run/sessions/get/index.d.ts +13 -0
- package/dist/commands/run/sessions/get/index.js +72 -0
- package/dist/commands/run/sessions/list/index.d.ts +12 -0
- package/dist/commands/run/sessions/list/index.js +64 -0
- package/dist/commands/run/sessions/start/index.d.ts +13 -0
- package/dist/commands/run/sessions/start/index.js +56 -0
- package/dist/commands/run/sessions/stop/index.d.ts +13 -0
- package/dist/commands/run/sessions/stop/index.js +56 -0
- package/dist/commands/run/sink/get/index.d.ts +13 -0
- package/dist/commands/run/sink/get/index.js +63 -0
- package/dist/commands/workspace/pull/index.d.ts +28 -0
- package/dist/commands/workspace/pull/index.js +238 -0
- package/dist/commands/workspace/push/index.d.ts +19 -0
- package/dist/commands/workspace/push/index.js +163 -0
- package/dist/lib/base-run-command.d.ts +42 -0
- package/dist/lib/base-run-command.js +75 -0
- package/dist/lib/run-http-client.d.ts +58 -0
- package/dist/lib/run-http-client.js +136 -0
- package/dist/lib/run-types.d.ts +226 -0
- package/dist/lib/run-types.js +5 -0
- package/oclif.manifest.json +1470 -218
- package/package.json +1 -1
- package/dist/commands/ephemeral/run/job/index.js +0 -311
- package/dist/commands/ephemeral/run/service/index.js +0 -287
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import BaseRunCommand from '../../../lib/base-run-command.js';
|
|
4
|
+
export default class RunInfo extends BaseRunCommand {
|
|
5
|
+
static args = {};
|
|
6
|
+
static flags = {
|
|
7
|
+
...BaseRunCommand.baseFlags,
|
|
8
|
+
file: Flags.string({
|
|
9
|
+
char: 'f',
|
|
10
|
+
description: 'Path or URL to file containing XanoScript code',
|
|
11
|
+
required: false,
|
|
12
|
+
exclusive: ['stdin'],
|
|
13
|
+
}),
|
|
14
|
+
stdin: Flags.boolean({
|
|
15
|
+
char: 's',
|
|
16
|
+
description: 'Read XanoScript code from stdin',
|
|
17
|
+
required: false,
|
|
18
|
+
default: false,
|
|
19
|
+
exclusive: ['file'],
|
|
20
|
+
}),
|
|
21
|
+
output: Flags.string({
|
|
22
|
+
char: 'o',
|
|
23
|
+
description: 'Output format',
|
|
24
|
+
required: false,
|
|
25
|
+
default: 'summary',
|
|
26
|
+
options: ['summary', 'json'],
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
static description = 'Get information about a XanoScript document (type, inputs, env vars)';
|
|
30
|
+
static examples = [
|
|
31
|
+
`$ xano run info -f script.xs
|
|
32
|
+
Document Info:
|
|
33
|
+
Type: job
|
|
34
|
+
Inputs:
|
|
35
|
+
- name (string, required)
|
|
36
|
+
- count (number, optional)
|
|
37
|
+
Environment Variables:
|
|
38
|
+
- API_KEY
|
|
39
|
+
- DEBUG
|
|
40
|
+
`,
|
|
41
|
+
`$ cat script.xs | xano run info --stdin
|
|
42
|
+
Document Info:
|
|
43
|
+
Type: service
|
|
44
|
+
Inputs: none
|
|
45
|
+
Environment Variables: none
|
|
46
|
+
`,
|
|
47
|
+
`$ xano run info -f script.xs -o json
|
|
48
|
+
{ "type": "job", "input": { "name": {...} }, "env": ["API_KEY"] }
|
|
49
|
+
`,
|
|
50
|
+
];
|
|
51
|
+
async run() {
|
|
52
|
+
const { flags } = await this.parse(RunInfo);
|
|
53
|
+
// Initialize with project required
|
|
54
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
55
|
+
// Read XanoScript content
|
|
56
|
+
let xanoscript;
|
|
57
|
+
if (flags.file) {
|
|
58
|
+
if (this.isUrl(flags.file)) {
|
|
59
|
+
// Fetch URL content
|
|
60
|
+
try {
|
|
61
|
+
const response = await fetch(flags.file);
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
this.error(`Failed to fetch URL: ${response.status} ${response.statusText}`);
|
|
64
|
+
}
|
|
65
|
+
xanoscript = await response.text();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.error(`Failed to fetch URL '${flags.file}': ${error}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
try {
|
|
73
|
+
xanoscript = fs.readFileSync(flags.file, 'utf8');
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
this.error(`Failed to read file '${flags.file}': ${error}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (flags.stdin) {
|
|
81
|
+
try {
|
|
82
|
+
xanoscript = await this.readStdin();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
this.error(`Failed to read from stdin: ${error}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.error('Either --file or --stdin must be specified to provide XanoScript code');
|
|
90
|
+
}
|
|
91
|
+
// Validate xanoscript is not empty
|
|
92
|
+
if (!xanoscript || xanoscript.trim().length === 0) {
|
|
93
|
+
this.error('XanoScript content is empty');
|
|
94
|
+
}
|
|
95
|
+
// Get document info via API
|
|
96
|
+
try {
|
|
97
|
+
const url = this.httpClient.buildProjectUrl('/doc/info');
|
|
98
|
+
const result = await this.httpClient.post(url, { doc: xanoscript });
|
|
99
|
+
if (flags.output === 'json') {
|
|
100
|
+
this.outputJson(result);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.outputSummary(result);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (error instanceof Error) {
|
|
108
|
+
this.error(`Failed to get document info: ${error.message}`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.error(`Failed to get document info: ${String(error)}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
outputSummary(result) {
|
|
116
|
+
this.log('Document Info:');
|
|
117
|
+
this.log(` Type: ${result.type}`);
|
|
118
|
+
this.log('');
|
|
119
|
+
// Display inputs
|
|
120
|
+
this.log(' Inputs:');
|
|
121
|
+
if (result.input && Object.keys(result.input).length > 0) {
|
|
122
|
+
for (const [name, config] of Object.entries(result.input)) {
|
|
123
|
+
const configStr = typeof config === 'object' ? JSON.stringify(config) : String(config);
|
|
124
|
+
this.log(` - ${name}: ${configStr}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.log(' (none)');
|
|
129
|
+
}
|
|
130
|
+
this.log('');
|
|
131
|
+
// Display environment variables
|
|
132
|
+
this.log(' Environment Variables:');
|
|
133
|
+
if (result.env && result.env.length > 0) {
|
|
134
|
+
for (const envVar of result.env) {
|
|
135
|
+
this.log(` - ${envVar}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.log(' (none)');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
isUrl(str) {
|
|
143
|
+
return str.startsWith('http://') || str.startsWith('https://');
|
|
144
|
+
}
|
|
145
|
+
async readStdin() {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
const chunks = [];
|
|
148
|
+
process.stdin.on('data', (chunk) => {
|
|
149
|
+
chunks.push(chunk);
|
|
150
|
+
});
|
|
151
|
+
process.stdin.on('end', () => {
|
|
152
|
+
resolve(Buffer.concat(chunks).toString('utf8'));
|
|
153
|
+
});
|
|
154
|
+
process.stdin.on('error', (error) => {
|
|
155
|
+
reject(error);
|
|
156
|
+
});
|
|
157
|
+
process.stdin.resume();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunProjectsCreate extends BaseRunCommand {
|
|
3
|
+
static args: {};
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
description: 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
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunProjectsCreate extends BaseRunCommand {
|
|
4
|
+
static args = {};
|
|
5
|
+
static flags = {
|
|
6
|
+
...BaseRunCommand.baseFlags,
|
|
7
|
+
name: Flags.string({
|
|
8
|
+
char: 'n',
|
|
9
|
+
description: 'Project name',
|
|
10
|
+
required: true,
|
|
11
|
+
}),
|
|
12
|
+
description: Flags.string({
|
|
13
|
+
char: 'd',
|
|
14
|
+
description: 'Project description',
|
|
15
|
+
required: false,
|
|
16
|
+
default: '',
|
|
17
|
+
}),
|
|
18
|
+
output: Flags.string({
|
|
19
|
+
char: 'o',
|
|
20
|
+
description: 'Output format',
|
|
21
|
+
required: false,
|
|
22
|
+
default: 'summary',
|
|
23
|
+
options: ['summary', 'json'],
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
static description = 'Create a new project';
|
|
27
|
+
static examples = [
|
|
28
|
+
`$ xano run projects create -n "My Project"
|
|
29
|
+
Project created successfully!
|
|
30
|
+
ID: abc123-def456-ghi789
|
|
31
|
+
Name: My Project
|
|
32
|
+
`,
|
|
33
|
+
`$ xano run projects create -n "My Project" -d "Description here"
|
|
34
|
+
Project created successfully!
|
|
35
|
+
ID: abc123-def456-ghi789
|
|
36
|
+
Name: My Project
|
|
37
|
+
`,
|
|
38
|
+
`$ xano run projects create -n "My Project" -o json
|
|
39
|
+
{ "id": "abc123-def456-ghi789", "name": "My Project", ... }
|
|
40
|
+
`,
|
|
41
|
+
];
|
|
42
|
+
async run() {
|
|
43
|
+
const { flags } = await this.parse(RunProjectsCreate);
|
|
44
|
+
// Initialize (no project required for creating projects)
|
|
45
|
+
await this.initRunCommand(flags.profile);
|
|
46
|
+
const input = {
|
|
47
|
+
name: flags.name,
|
|
48
|
+
description: flags.description || '',
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
const url = this.httpClient.buildUrl('/project');
|
|
52
|
+
const project = await this.httpClient.post(url, input);
|
|
53
|
+
if (flags.output === 'json') {
|
|
54
|
+
this.outputJson(project);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.log('Project created successfully!');
|
|
58
|
+
this.log(` ID: ${project.id}`);
|
|
59
|
+
this.log(` Name: ${project.name}`);
|
|
60
|
+
if (project.description) {
|
|
61
|
+
this.log(` Description: ${project.description}`);
|
|
62
|
+
}
|
|
63
|
+
this.log(` Access: ${project.access}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof Error) {
|
|
68
|
+
this.error(`Failed to create project: ${error.message}`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.error(`Failed to create project: ${String(error)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunProjectsDelete extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
projectId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunProjectsDelete extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
projectId: Args.string({
|
|
6
|
+
description: 'Project ID to delete',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
force: Flags.boolean({
|
|
13
|
+
char: 'f',
|
|
14
|
+
description: 'Skip confirmation prompt',
|
|
15
|
+
required: false,
|
|
16
|
+
default: false,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
static description = 'Delete a project';
|
|
20
|
+
static examples = [
|
|
21
|
+
`$ xano run projects delete abc123-def456
|
|
22
|
+
Are you sure you want to delete project 'abc123-def456'? (y/N)
|
|
23
|
+
Project deleted successfully!
|
|
24
|
+
`,
|
|
25
|
+
`$ xano run projects delete abc123-def456 --force
|
|
26
|
+
Project deleted successfully!
|
|
27
|
+
`,
|
|
28
|
+
];
|
|
29
|
+
async run() {
|
|
30
|
+
const { args, flags } = await this.parse(RunProjectsDelete);
|
|
31
|
+
// Initialize (no project required)
|
|
32
|
+
await this.initRunCommand(flags.profile);
|
|
33
|
+
// Confirm deletion unless --force is used
|
|
34
|
+
if (!flags.force) {
|
|
35
|
+
const readline = await import('node:readline');
|
|
36
|
+
const rl = readline.createInterface({
|
|
37
|
+
input: process.stdin,
|
|
38
|
+
output: process.stdout,
|
|
39
|
+
});
|
|
40
|
+
const confirmed = await new Promise((resolve) => {
|
|
41
|
+
rl.question(`Are you sure you want to delete project '${args.projectId}'? (y/N) `, (answer) => {
|
|
42
|
+
rl.close();
|
|
43
|
+
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
if (!confirmed) {
|
|
47
|
+
this.log('Deletion cancelled.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const url = this.httpClient.buildUrl(`/project/${args.projectId}`);
|
|
53
|
+
await this.httpClient.delete(url);
|
|
54
|
+
this.log('Project deleted successfully!');
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
this.error(`Failed to delete project: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.error(`Failed to delete project: ${String(error)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunProjectsList extends BaseRunCommand {
|
|
3
|
+
static args: {};
|
|
4
|
+
static flags: {
|
|
5
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
private outputTable;
|
|
12
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunProjectsList extends BaseRunCommand {
|
|
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: 'table',
|
|
12
|
+
options: ['table', 'json'],
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
static description = 'List all projects';
|
|
16
|
+
static examples = [
|
|
17
|
+
`$ xano run projects list
|
|
18
|
+
ID NAME ACCESS
|
|
19
|
+
abc123-def456-ghi789 My Project private
|
|
20
|
+
xyz789-uvw456-rst123 Test Project public
|
|
21
|
+
`,
|
|
22
|
+
`$ xano run projects list -o json
|
|
23
|
+
[
|
|
24
|
+
{ "id": "abc123-def456-ghi789", "name": "My Project", ... }
|
|
25
|
+
]
|
|
26
|
+
`,
|
|
27
|
+
];
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(RunProjectsList);
|
|
30
|
+
// Initialize (no project required for listing projects)
|
|
31
|
+
await this.initRunCommand(flags.profile);
|
|
32
|
+
try {
|
|
33
|
+
const url = this.httpClient.buildUrl('/project');
|
|
34
|
+
const projects = await this.httpClient.get(url);
|
|
35
|
+
if (flags.output === 'json') {
|
|
36
|
+
this.outputJson(projects);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.outputTable(projects);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
this.error(`Failed to list projects: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.error(`Failed to list projects: ${String(error)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
outputTable(projects) {
|
|
52
|
+
if (projects.length === 0) {
|
|
53
|
+
this.log('No projects found.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Print header
|
|
57
|
+
this.log('ID NAME ACCESS');
|
|
58
|
+
this.log('-'.repeat(75));
|
|
59
|
+
for (const project of projects) {
|
|
60
|
+
const id = project.id.padEnd(36);
|
|
61
|
+
const name = project.name.slice(0, 24).padEnd(25);
|
|
62
|
+
const access = project.access;
|
|
63
|
+
this.log(`${id} ${name} ${access}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunProjectsUpdate extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
projectId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
static description: string;
|
|
13
|
+
static examples: string[];
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunProjectsUpdate extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
projectId: Args.string({
|
|
6
|
+
description: 'Project ID to update',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
name: Flags.string({
|
|
13
|
+
char: 'n',
|
|
14
|
+
description: 'New project name',
|
|
15
|
+
required: false,
|
|
16
|
+
}),
|
|
17
|
+
description: Flags.string({
|
|
18
|
+
char: 'd',
|
|
19
|
+
description: 'New project description',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
output: Flags.string({
|
|
23
|
+
char: 'o',
|
|
24
|
+
description: 'Output format',
|
|
25
|
+
required: false,
|
|
26
|
+
default: 'summary',
|
|
27
|
+
options: ['summary', 'json'],
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
static description = 'Update a project';
|
|
31
|
+
static examples = [
|
|
32
|
+
`$ xano run projects update abc123-def456 -n "New Name"
|
|
33
|
+
Project updated successfully!
|
|
34
|
+
ID: abc123-def456
|
|
35
|
+
Name: New Name
|
|
36
|
+
`,
|
|
37
|
+
`$ xano run projects update abc123-def456 -d "New description"
|
|
38
|
+
Project updated successfully!
|
|
39
|
+
ID: abc123-def456
|
|
40
|
+
Description: New description
|
|
41
|
+
`,
|
|
42
|
+
`$ xano run projects update abc123-def456 -n "New Name" -o json
|
|
43
|
+
{ "id": "abc123-def456", "name": "New Name", ... }
|
|
44
|
+
`,
|
|
45
|
+
];
|
|
46
|
+
async run() {
|
|
47
|
+
const { args, flags } = await this.parse(RunProjectsUpdate);
|
|
48
|
+
// Initialize (no project required)
|
|
49
|
+
await this.initRunCommand(flags.profile);
|
|
50
|
+
// Check if any update flags were provided
|
|
51
|
+
if (!flags.name && flags.description === undefined) {
|
|
52
|
+
this.error('At least one of --name or --description must be provided');
|
|
53
|
+
}
|
|
54
|
+
const input = {};
|
|
55
|
+
if (flags.name) {
|
|
56
|
+
input.name = flags.name;
|
|
57
|
+
}
|
|
58
|
+
if (flags.description !== undefined) {
|
|
59
|
+
input.description = flags.description;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const url = this.httpClient.buildUrl(`/project/${args.projectId}`);
|
|
63
|
+
const project = await this.httpClient.patch(url, input);
|
|
64
|
+
if (flags.output === 'json') {
|
|
65
|
+
this.outputJson(project);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.log('Project updated successfully!');
|
|
69
|
+
this.log(` ID: ${project.id}`);
|
|
70
|
+
this.log(` Name: ${project.name}`);
|
|
71
|
+
if (project.description) {
|
|
72
|
+
this.log(` Description: ${project.description}`);
|
|
73
|
+
}
|
|
74
|
+
this.log(` Access: ${project.access}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof Error) {
|
|
79
|
+
this.error(`Failed to update project: ${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.error(`Failed to update project: ${String(error)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSecretsDelete extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSecretsDelete extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
name: Args.string({
|
|
6
|
+
description: 'Secret name',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
force: Flags.boolean({
|
|
13
|
+
char: 'f',
|
|
14
|
+
description: 'Skip confirmation prompt',
|
|
15
|
+
required: false,
|
|
16
|
+
default: false,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
static description = 'Delete a secret';
|
|
20
|
+
static examples = [
|
|
21
|
+
`$ xano run secrets delete docker-registry
|
|
22
|
+
Are you sure you want to delete secret 'docker-registry'? (y/N)
|
|
23
|
+
Secret 'docker-registry' deleted successfully!
|
|
24
|
+
`,
|
|
25
|
+
`$ xano run secrets delete docker-registry --force
|
|
26
|
+
Secret 'docker-registry' deleted successfully!
|
|
27
|
+
`,
|
|
28
|
+
];
|
|
29
|
+
async run() {
|
|
30
|
+
const { args, flags } = await this.parse(RunSecretsDelete);
|
|
31
|
+
// Initialize with project required
|
|
32
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
33
|
+
// Confirm deletion unless --force is used
|
|
34
|
+
if (!flags.force) {
|
|
35
|
+
const readline = await import('node:readline');
|
|
36
|
+
const rl = readline.createInterface({
|
|
37
|
+
input: process.stdin,
|
|
38
|
+
output: process.stdout,
|
|
39
|
+
});
|
|
40
|
+
const confirmed = await new Promise((resolve) => {
|
|
41
|
+
rl.question(`Are you sure you want to delete secret '${args.name}'? (y/N) `, (answer) => {
|
|
42
|
+
rl.close();
|
|
43
|
+
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
if (!confirmed) {
|
|
47
|
+
this.log('Deletion cancelled.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const url = this.httpClient.buildProjectUrl('/secret');
|
|
53
|
+
await this.httpClient.delete(url, { name: args.name });
|
|
54
|
+
this.log(`Secret '${args.name}' deleted successfully!`);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
this.error(`Failed to delete secret: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.error(`Failed to delete secret: ${String(error)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSecretsGet extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
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
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSecretsGet extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
name: Args.string({
|
|
6
|
+
description: 'Secret name',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
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
|
+
};
|
|
20
|
+
static description = 'Get a secret value';
|
|
21
|
+
static examples = [
|
|
22
|
+
`$ xano run secrets get docker-registry
|
|
23
|
+
{"auths":{"ghcr.io":{"auth":"..."}}}
|
|
24
|
+
`,
|
|
25
|
+
`$ xano run secrets get docker-registry -o json
|
|
26
|
+
{ "name": "docker-registry", "type": "kubernetes.io/dockerconfigjson", "value": "..." }
|
|
27
|
+
`,
|
|
28
|
+
];
|
|
29
|
+
async run() {
|
|
30
|
+
const { args, flags } = await this.parse(RunSecretsGet);
|
|
31
|
+
// Initialize with project required
|
|
32
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
33
|
+
try {
|
|
34
|
+
const url = this.httpClient.buildProjectUrl('/secret', { name: args.name });
|
|
35
|
+
const result = await this.httpClient.get(url);
|
|
36
|
+
if (flags.output === 'json') {
|
|
37
|
+
this.outputJson(result);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.log(result.value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
this.error(`Failed to get secret: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.error(`Failed to get secret: ${String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSecretsList extends BaseRunCommand {
|
|
3
|
+
static args: {};
|
|
4
|
+
static flags: {
|
|
5
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|