Skip to content

Commit a2c2747

Browse files
committed
First draft of redesigned command-line.schema.json
1 parent ba78121 commit a2c2747

File tree

1 file changed

+189
-131
lines changed

1 file changed

+189
-131
lines changed

apps/rush-lib/src/schemas/command-line.schema.json

Lines changed: 189 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -3,158 +3,216 @@
33
"title": "Rush command-line.json config file",
44
"description": "For use with the Rush tool, this file defines custom command line commands. See http://rushjs.io for details.",
55

6-
"type": "object",
7-
"additionalProperties": false,
8-
9-
"properties": {
10-
"$schema": {
11-
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
12-
"type": "string"
6+
"definitions": {
7+
"baseCommand": {
8+
"type": "object",
9+
"additionalProperties": false,
10+
"required": [ "commandKind", "name", "summary", "description" ],
11+
"properties": {
12+
"commandKind": {
13+
"title": "Command Kind",
14+
"description": "Indicates the kind of command: \"bulk\" commands are run separately for each project; \"global\" commands are run once for the entire repository.",
15+
"type": "string",
16+
"enum": [ "bulk", "global" ]
17+
},
18+
"name": {
19+
"title": "Custom Command Name",
20+
"description": "The name of the custom command, which can be invoked via \"rush <name>\"",
21+
"type": "string"
22+
},
23+
"summary": {
24+
"title": "Custom Command Summary",
25+
"description": "A short summary of the custom command, which will appear when printing command line usage (e.g. \"rush --help\")",
26+
"type": "string"
27+
},
28+
"description": {
29+
"title": "Custom Command Description",
30+
"description": "A detailed description of the command, which appears when requesting help for the command (e.g. \"rush --help my-command\"). If omitted, the summary will be used.",
31+
"type": "string"
32+
}
33+
}
1334
},
14-
15-
"customCommands": {
16-
"title": "Custom Commands",
17-
"description": "A list of custom commands that can be invoked from the Rush command line",
18-
"type": "array",
19-
"items": {
20-
"title": "Custom Command",
21-
"type": "object",
22-
"additionalProperties": false,
23-
"required": [ "name", "summary", "documentation", "parallelized" ],
24-
"properties": {
25-
"name": {
26-
"title": "Custom Command Name",
27-
"description": "The name of the custom command, which can be invoked via \"rush <name>\"",
28-
"type": "string"
29-
},
30-
"summary": {
31-
"title": "Custom Command Summary",
32-
"description": "A short summary of the custom command, which will appear when printing command line usage (e.g. \"rush --help\")",
33-
"type": "string"
34-
},
35-
"documentation": {
36-
"title": "Custom Command Documentation",
37-
"description": "A detailed description of the command, which appears when requesting command-line help for this command. If omitted, the summary will be used.",
38-
"type": "string"
39-
},
40-
"parallelized": {
41-
"title": "Is Parallelized",
42-
"description": "Describes whether or not this command can be run in parallel (with multiple instances running on several projects simultaneously). Defaults to 'true'.",
43-
"type": "boolean"
44-
},
45-
"ignoreMissingScript": {
46-
"title": "Ignore missing script",
47-
"description": "Normally Rush requires that each project's package.json has a \"script\" entry matching the custom command name. To disable this check, set \"ignoreMissingScript\" to true.",
48-
"type": "boolean"
35+
"bulkCommand": {
36+
"allof": [
37+
{ "$ref": "#/definitions/baseCommand" },
38+
{
39+
"type": "object",
40+
"additionalProperties": false,
41+
"required": [ "parallelized" ],
42+
"properties": {
43+
"commandKind": {
44+
"enum": [ "bulk" ]
45+
},
46+
"parallelized": {
47+
"title": "Parallelized",
48+
"description": "Describes whether or not this command can be run in parallel (i.e. executed simultaneously for multiple projects).",
49+
"type": "boolean"
50+
},
51+
"ignoreMissingScript": {
52+
"title": "Ignore Missing Script",
53+
"description": "Normally Rush requires that each project's package.json has a \"scripts\" entry matching the custom command name. To disable this check, set \"ignoreMissingScript\" to true.",
54+
"type": "boolean"
55+
}
4956
}
5057
}
51-
}
58+
]
59+
},
60+
"globalCommand": {
61+
"allof": [
62+
{ "$ref": "#/definitions/baseCommand" },
63+
{
64+
"type": "object",
65+
"additionalProperties": false,
66+
"required": [ "scriptPath" ],
67+
"properties": {
68+
"commandKind": {
69+
"enum": [ "global" ]
70+
},
71+
"scriptPath": {
72+
"title": "Script Path",
73+
"description": "The relative path to a JavaScript file that will be invoked using the NodeJS engine. The path is relative to the repository root folder that contains rush.json.",
74+
"type": "string"
75+
}
76+
}
77+
}
78+
]
5279
},
5380

54-
"customOptions": {
55-
"title": "Custom Options",
56-
"description": "A list of custom options that can be associated with commands",
81+
"baseParameter": {
5782
"type": "object",
5883
"additionalProperties": false,
59-
"patternProperties": {
60-
"^--[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$": {
61-
"title": "Custom Option",
84+
"required": [ "parameterKind", "longName", "description", "associatedCommands" ],
85+
"properties": {
86+
"parameterKind": {
87+
"title": "Parameter Kind",
88+
"description": "Indicates the kind of syntax for this command-line parameter: \"flag\" or \"choice\"",
89+
"type": "string",
90+
"enum": [ "flag", "choice" ]
91+
},
92+
"longName": {
93+
"title": "Long Name",
94+
"description": "The name the parameter (e.g. \"--verbose\"). This is a required field.",
95+
"type": "string",
96+
"pattern": "^-(-[a-z0-9]+)+$"
97+
},
98+
"shortName": {
99+
"title": "Short Name",
100+
"description": "A optional short form of the parameter (e.g. \"-v\" instead of \"--verbose\")",
101+
"type": "string",
102+
"pattern": "^-[a-zA-Z]$"
103+
},
104+
"description": {
105+
"title": "Custom Parameter Description",
106+
"description": "A detailed description of the parameter, which appears when requesting help for the command (e.g. \"rush --help my-command\").",
107+
"type": "string"
108+
},
109+
"associatedCommands": {
110+
"title": "Associated Commands",
111+
"description": "A list of custom commands and/or built-in Rush commands that this parameter may be used with",
112+
"type": "array",
113+
"minItems": 1,
114+
"items": {
115+
"type": "string"
116+
}
117+
}
118+
}
119+
},
120+
"flagParameter": {
121+
"allof": [
122+
{ "$ref": "#/definitions/baseParameter" },
123+
{
62124
"type": "object",
63-
64-
"required": [
65-
"description",
66-
"associatedCommands"
67-
],
68-
125+
"additionalProperties": false,
126+
"required": [ ],
69127
"properties": {
70-
"description": {
71-
"title": "Description",
128+
"parameterKind": {
129+
"enum": [ "flag" ]
130+
}
131+
}
132+
}
133+
]
134+
},
135+
"choiceParameter": {
136+
"allof": [
137+
{ "$ref": "#/definitions/baseParameter" },
138+
{
139+
"type": "object",
140+
"additionalProperties": false,
141+
"required": [ "scriptPath", "alternatives" ],
142+
"properties": {
143+
"parameterKind": {
144+
"enum": [ "choice" ]
145+
},
146+
"scriptPath": {
147+
"title": "Script Path",
148+
"description": "The relative path to a JavaScript file that will be invoked using the NodeJS engine. The path is relative to the repository root folder that contains rush.json.",
72149
"type": "string"
73150
},
74-
75-
"associatedCommands": {
76-
"title": "Supported Commands",
77-
"description": "A list of commands which this option can be used with",
151+
"alternatives": {
152+
"title": "Alternatives",
153+
"description": "A list of alternative argument values that can be chosen for this parameter.",
78154
"type": "array",
79155
"minItems": 1,
80156
"items": {
81-
"type": "string"
157+
"type": "object",
158+
"additionalProperties": false,
159+
"required": [ "name", "description" ],
160+
"properties": {
161+
"name": {
162+
"title": "Name of Alternative",
163+
"description": "A token that is one of the alternatives that can be used with the choice parameter, e.g. \"vanilla\" in \"--flavor vanilla\"",
164+
"type": "string"
165+
},
166+
"description": {
167+
"title": "Description of Alternative",
168+
"description": "A detailed description for the alternative that will be shown in the command-line help.",
169+
"type": "string"
170+
}
171+
}
82172
}
83173
},
84-
85-
"shortName": {
86-
"title": "Shortened Name",
87-
"description": "A optional shortened value for the flag (e.g. --verbose might become -v)",
88-
"type": "string",
89-
"pattern": "^-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"
90-
},
91-
92-
"optionType": {
93-
"type": "string",
94-
"enum": [
95-
"flag",
96-
"enum"
97-
]
174+
"defaultValue": {
175+
"title": "Default Value",
176+
"description": "If the parameter is omitted from the command line, this value will be inserted by default",
177+
"type": "string"
98178
}
99-
},
179+
}
180+
}
181+
]
182+
}
183+
},
100184

101-
"oneOf": [
102-
{
103-
"type": "object",
104-
"required": [ "optionType" ],
105-
"properties": {
106-
"optionType": {
107-
"type": "string",
108-
"enum": [
109-
"flag"
110-
]
111-
}
112-
}
113-
},
114-
{
115-
"type": "object",
116-
"required": [ "optionType", "enumValues" ],
117-
"properties": {
118-
"optionType": {
119-
"type": "string",
120-
"enum": [
121-
"enum"
122-
]
123-
},
185+
"type": "object",
186+
"additionalProperties": false,
124187

125-
"enumValues": {
126-
"title": "Enum Values",
127-
"description": "A list of possible options for this flag",
128-
"type": "array",
129-
"minItems": 1,
188+
"properties": {
189+
"$schema": {
190+
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
191+
"type": "string"
192+
},
130193

131-
"items": {
132-
"type": "object",
133-
"additionalProperties": false,
134-
"required": [ "name", "description" ],
135-
"properties": {
136-
"name": {
137-
"title": "Name",
138-
"type": "string"
139-
},
140-
"description": {
141-
"title": "Description",
142-
"type": "string"
143-
}
144-
}
145-
}
146-
},
194+
"commands": {
195+
"title": "Custom Commands",
196+
"description": "A list of custom commands that affect all projects in the repository. These commands are invoked from the Rush command line.",
197+
"type": "array",
198+
"items": {
199+
"oneof": [
200+
{ "$ref": "#/definitions/bulkCommand" },
201+
{ "$ref": "#/definitions/globalCommand" }
202+
]
203+
}
204+
},
147205

148-
"defaultValue": {
149-
"title": "Default Value",
150-
"description": "If this flag is omitted, use this value by default",
151-
"type": "string"
152-
}
153-
}
154-
}
155-
]
156-
}
206+
"parameters": {
207+
"title": "Custom Parameters",
208+
"description": "A list of custom command-line parameters that can be associated with custom commands and Rush's built-in commands.",
209+
"type": "array",
210+
"items": {
211+
"oneof": [
212+
{ "$ref": "#/definitions/flagParameter" },
213+
{ "$ref": "#/definitions/choiceParameter" }
214+
]
157215
}
158216
}
159217
}
160-
}
218+
}

0 commit comments

Comments
 (0)