-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.ts
46 lines (40 loc) · 1.6 KB
/
dev.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
import { Command, flags } from '@oclif/command'
import { assertIsFrameworkRoot } from '../lib/assertions'
import { devRepo } from '../lib/build'
import { ENV_REPO } from '../lib/constants'
import { resolveRepoList } from '../lib/repo'
export default class Dev extends Command {
static description = `Launches the dev server for the documentation of a repo.
NOTE: This command must be executed from the root of the framework meta-repo.
The repository must be previously installed in the framework via the "install" command.
The repository can be specified via the --repo flag, the KUZDOC_REPO environment
variable, or via the interactive prompt (only the installed repositories are listed).`
static flags = {
help: flags.help({ char: 'h' }),
repo: flags.string({
description: `The name of repository to scan. If not specified, kuzdoc will ask a prompt.
Environment variable: $${ENV_REPO}`,
default: process.env[ENV_REPO]
}),
}
async run() {
try {
assertIsFrameworkRoot(process.cwd())
} catch (error) {
this.log('⛔️ Aborting.')
this.log(`It doesn't seem that you are executing this command from the root of the framework repo ${process.cwd()}: ${error.message}`)
return
}
const { flags: _flags } = this.parse(Dev)
const repoList = await resolveRepoList(_flags.repo, true, false)
if (repoList.length === 0) {
this.log(`\n 🤷♂️ No repo resolved from ${_flags.repo}.\n`)
return
}
const repo = repoList[0]
if (_flags.repo) {
this.log(`\n 👉 Resolved repo ${repo.name}\n`)
}
await devRepo(repo)
}
}