Skip to content

Commit 8f54a98

Browse files
committed
feat: Changed sudo request to command request to support additional options
1 parent c4f60c0 commit 8f54a98

5 files changed

Lines changed: 21 additions & 18 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-schemas",
3-
"version": "1.0.86-beta1",
3+
"version": "1.0.86-beta5",
44
"description": "",
55
"type": "module",
66
"main": "dist/index.js",
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
3-
"$id": "https://www.codifycli.com/sudo-request.json",
3+
"$id": "https://www.codifycli.com/command-request.json",
44
"title": "Command request",
55
"description": "Request the core CLI to perform a command. This is required for sudo and interactive",
66
"type": "object",
@@ -9,10 +9,6 @@
99
"type": "string",
1010
"description": "The command that is requesting sudo"
1111
},
12-
"type": {
13-
"enum": ["sudo", "interactive"],
14-
"description": "The request type. Right now only sudo and interactive are supported"
15-
},
1612
"options": {
1713
"type": "object",
1814
"description": "The options for codifySpawn that is needed to run the command",
@@ -24,11 +20,23 @@
2420
"argv0": {
2521
"type": "string",
2622
"description": "Arguments to pass in"
23+
},
24+
"requiresRoot": {
25+
"type": "boolean",
26+
"description": "Whether or not this command needs to be run in root"
27+
},
28+
"interactive": {
29+
"type": "boolean",
30+
"description": "Whether or not this command needs to be run in interactive mode"
31+
},
32+
"stdin": {
33+
"type": "boolean",
34+
"description": "Whether or not this command requires stdin"
2735
}
2836
},
2937
"additionalProperties": true
3038
}
3139
},
32-
"required": ["command", "type"],
40+
"required": ["command"],
3341
"additionalProperties": false
3442
}

src/messages/command-request-data-schema.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ describe('Get resources response data schema', () => {
1515
const validate = ajv.compile(schema);
1616
expect(validate({
1717
command: 'abc def',
18-
type: 'sudo'
1918
})).to.be.true;
2019
})
2120

2221
it("Allows options to be set for the command", () => {
2322
const validate = ajv.compile(schema);
2423
expect(validate({
2524
command: 'abc def',
26-
type: 'interactive',
2725
options: {
2826
cwd: '.',
27+
interactive: true,
2928
}
3029
})).to.be.true;
3130
})
@@ -34,7 +33,6 @@ describe('Get resources response data schema', () => {
3433
const validate = ajv.compile(schema);
3534
expect(validate({
3635
command: 'abc def',
37-
type: 'sudo',
3836
options: {
3937
cwd: '.',
4038
requiresRoot: true,
@@ -47,9 +45,9 @@ describe('Get resources response data schema', () => {
4745
const validate = ajv.compile(schema);
4846
expect(validate({
4947
command: 'abc def',
50-
type: 'interactive',
5148
options: {
5249
cwd: '.',
50+
requiresRoot: true,
5351
},
5452
additional: {}
5553
})).to.be.false;

src/messages/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export enum MessageCmd {
33
VALIDATE = 'validate',
44
PLAN = 'plan',
55
APPLY = 'apply',
6-
SUDO_REQUEST = 'sudo_request',
6+
COMMAND_REQUEST = 'command_request',
77
PRESS_KEY_TO_CONTINUE_REQUEST = 'press_key_to_continue_request',
88
CODIFY_CREDENTIALS_REQUEST = 'codify_credentials_request'
99
}

src/types/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,13 @@ export interface InitializeResponseData {
183183
resourceDefinitions: Array<ResourceDefinition>;
184184
}
185185

186-
export enum CommandRequestType {
187-
SUDO = 'sudo',
188-
INTERACTIVE = 'interactive'
189-
}
190-
191186
export interface CommandRequestData {
192187
command: string;
193-
type: CommandRequestType,
194188
options: {
195189
cwd?: string;
190+
interactive?: boolean;
191+
requiresRoot?: boolean;
192+
stdin?: boolean;
196193
} & Omit<SpawnOptions, 'stdio' | 'shell' | 'detached'>
197194
}
198195

0 commit comments

Comments
 (0)