-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathstepzen.ts
136 lines (133 loc) · 3.54 KB
/
stepzen.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Fig completion specs for StepZen CLI
// Manually coded from https://stepzen.com/docs/cli/cli-commands
// Coded on stepzen/0.9.33 CLI version
const endpointsGenerator: Fig.Generator = {
script: ["stepzen", "list", "schemas"],
postProcess: (output) => {
try {
return JSON.parse(output).map((endpoint: string) => {
return {
name: endpoint,
description: "StepZen endpoint",
} as Fig.Suggestion;
}) as Fig.Suggestion[];
} catch (e) {
return [];
}
},
};
const importSchemasGenerator: Fig.Generator = {
script: [
"curl",
"https://api.github.com/repos/steprz/stepzen-schemas/contents",
],
postProcess: (output) => {
try {
return JSON.parse(output)
.filter((repo: { name: string; type: string }) => {
return repo.type == "dir" && !repo.name.startsWith(".");
})
.map((repo: { name: string }) => {
return {
name: repo.name,
description: "Stepzen schema",
icon: "📦",
} as Fig.Suggestion;
}) as Fig.Suggestion[];
} catch (e) {
return [];
}
},
};
const completionSpec: Fig.Spec = {
name: "StepZen",
description:
"The StepZen CLI is the primary way to build, deploy and test your schemas on StepZen",
subcommands: [
{
name: "help",
description: "Display help for StepZen",
args: {
name: "command",
description: "Command name for which to display help",
},
},
{
name: "login",
description: "Login to StepZen",
},
{
name: "logout",
description: "Logout of StepZen",
},
{
name: "start",
description: "Deploy, watch and develop your API",
options: [
{
name: "--dir",
description: "The working directory for StepZen assets",
requiresSeparator: true,
args: {
name: "path",
description: "Path to StepZen directory",
template: "folders",
},
},
{
name: "--endpoint",
description: "The folder/endpoint to deploy to",
requiresSeparator: true,
args: {
name: "endpoint",
description: "The StepZen endpoint",
generators: endpointsGenerator,
},
},
{
name: "--port",
description: "The port number to use for the GraphiQL explorer",
requiresSeparator: true,
args: {
name: "port",
description: "A port to run on",
},
},
],
},
{
name: "import",
description: "Import pre-configured schemas to Your API",
args: {
name: "name",
description: "The name of the generator to import",
generators: importSchemasGenerator,
},
options: [
{
name: "--dir",
description: "The directory to which the schema will be imported",
requiresSeparator: true,
args: {
name: "path",
description: "Path to directory",
template: "folders",
},
},
],
},
{
name: "list",
description:
"List the assets of a specified type that are linked to the StepZen account",
args: {
name: "type",
description: "The type of asset to list (schemas or configurationsets)",
suggestions: ["schemas", "configurationsets"],
},
},
],
// Only uncomment if stepzen takes an argument
// args: {}
};
export default completionSpec;