forked from platformatic/platformatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-cli-doc.mjs
executable file
·274 lines (181 loc) · 4.7 KB
/
gen-cli-doc.mjs
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
import { readFile, readdir, writeFile } from 'fs/promises'
import { join } from 'desm'
import path from 'path'
let out = `---
# ATTENTION: This file is automatically generated through script/gen-cli-doc.mjs, do not change it manually!
toc_max_heading_level: 4
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TOCInline from '@theme/TOCInline';
# Platformatic CLI
## Installation and usage
Install the Platformatic CLI as a dependency for your project:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm">
\`\`\`bash
npm install platformatic
\`\`\`
</TabItem>
<TabItem value="yarn" label="Yarn">
\`\`\`bash
yarn add platformatic
\`\`\`
</TabItem>
<TabItem value="pnpm" label="pnpm">
\`\`\`bash
pnpm add platformatic
\`\`\`
</TabItem>
</Tabs>
Once it's installed you can run it with:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm">
\`\`\`bash
npx platformatic
\`\`\`
</TabItem>
<TabItem value="yarn" label="Yarn">
\`\`\`bash
yarn platformatic
\`\`\`
</TabItem>
<TabItem value="pnpm" label="pnpm">
\`\`\`bash
pnpm platformatic
\`\`\`
</TabItem>
</Tabs>
:::info
The \`platformatic\` package can be installed globally, but installing it as a
project dependency ensures that everyone working on the project is using the
same version of the Platformatic CLI.
:::
## Commands
The Platformatic CLI provides the following commands:
<TOCInline toc={toc} minHeadingLevel={3} maxHeadingLevel={4} />
### help
`
// Command: help
const cliHelpDir = join(import.meta.url, '../packages/cli/help')
const cliHelp = path.join(cliHelpDir, 'help.txt')
const cliHelps = await readdir(cliHelpDir)
const mainCliHelp = await readFile(cliHelp, 'utf8')
out += `
${mainCliHelp.trim()}
`;
for (const cliHelp of cliHelps) {
if (cliHelp === 'help.txt') continue
const cliHelpPath = path.join(cliHelpDir, cliHelp)
const content = await readFile(cliHelpPath)
out += `
#### ${cliHelp.replace('.txt', '')}
${content}
`
}
// Command: client
out += `
### client
\`\`\`bash
platformatic client <command>
\`\`\`
`
const clientHelpsDir = join(import.meta.url, '../packages/client-cli/help')
const clientHelps = await readdir(clientHelpsDir)
for (const clientHelp of clientHelps) {
const clientHelpPath = path.join(clientHelpsDir, clientHelp)
const content = await readFile(clientHelpPath)
out += `
#### ${clientHelp.replace('.txt', '')}
${content}
`
}
// Command: composer
out += `
### composer
\`\`\`bash
platformatic composer <command>
\`\`\`
`
const composerHelpsDir = join(import.meta.url, '../packages/composer/help')
const composerHelps = await readdir(composerHelpsDir)
for (const composerHelp of composerHelps) {
const composerHelpPath = path.join(composerHelpsDir, composerHelp)
const content = await readFile(composerHelpPath)
out += `
#### ${composerHelp.replace('.txt', '')}
${content}
`
}
// Command: db
out += `
### db
\`\`\`bash
platformatic db <command>
\`\`\`
`
const dbHelpsDir = join(import.meta.url, '../packages/db/help')
const dbHelps = await readdir(dbHelpsDir)
for (const dbHelp of dbHelps) {
const dbHelpPath = path.join(dbHelpsDir, dbHelp)
const content = await readFile(dbHelpPath)
out += `
#### ${dbHelp.replace('.txt', '')}
${content}
`
}
// Command: service
out += `
### service
\`\`\`bash
platformatic service <command>
\`\`\`
`
const serviceHelpsDir = join(import.meta.url, '../packages/service/help')
const serviceHelps = await readdir(serviceHelpsDir)
for (const serviceHelp of serviceHelps) {
const serviceHelpPath = path.join(serviceHelpsDir, serviceHelp)
const content = await readFile(serviceHelpPath)
out += `
#### ${serviceHelp.replace('.txt', '')}
${content}
`
}
// Command: frontend
out += `
### frontend
\`\`\`bash
platformatic client <url> --frontend --language <language>
\`\`\`
`
const frontendHelpsDir = join(import.meta.url, '../packages/frontend-template/help')
const frontendHelps = path.join(frontendHelpsDir, 'help.txt')
const mainFrontendHelp = await readFile(frontendHelps, 'utf8')
out += `
${mainFrontendHelp.trim()}
`;
// Command: runtime
out += `
### runtime
\`\`\`bash
platformatic runtime <command>
\`\`\`
`
const runtimeHelpsDir = join(import.meta.url, '../packages/runtime/help')
const runtimeHelps = await readdir(runtimeHelpsDir)
for (const runtimeHelp of runtimeHelps) {
const runtimeHelpPath = path.join(runtimeHelpsDir, runtimeHelp)
const content = await readFile(runtimeHelpPath)
out += `
#### ${runtimeHelp.replace('.txt', '')}
${content}
`
}
// Command: start
const startHelp = path.join(cliHelpDir, 'start.txt')
const startCliHelp = await readFile(startHelp, 'utf8')
out += `
### start
${startCliHelp.trim()}
`;
await writeFile(join(import.meta.url, '..', 'docs', 'reference', 'cli.md'), out)