-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-deploy.ts
65 lines (57 loc) · 2.3 KB
/
local-deploy.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
import { Command, flags } from '@oclif/command'
import Listr from 'listr'
import path from 'path'
import { buildFramework, buildRepo, deployFrameworkLocally, deployRepoLocally } from '../lib/build'
import { assertIsFrameworkRoot } from '../lib/assertions'
import { listInstalledRepos } from '../lib/repo'
export default class LocalDeploy extends Command {
static description = `Creates a local deploy of the docs containing the currently installed repos
NOTE: This command must be executed from the root of the framework meta-repo.
The repositories must be previously installed in the framework via the "install" command.
All the currently installed repositories will be built and deployed to the destination path.`
static flags = {
help: flags.help({ char: 'h' }),
destination: flags.string({
description: 'The path to the locally deployed docs',
default: path.join('/', 'tmp', 'kuzzle-docs')
})
}
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(LocalDeploy)
const installedRepos = listInstalledRepos()
this.log(`\n 👉 Deploying framework with repos ${installedRepos.map(r => r.name).join(', ')} to ${_flags.destination}\n`)
const tasks = new Listr([
{
title: 'Process Framework',
task: () => new Listr([{
title: 'Build',
task: () => buildFramework()
}, {
title: `Deploy to ${_flags.destination}`,
task: () => deployFrameworkLocally(_flags.destination)
}])
},
...installedRepos.map(repo => ({
title: `Process ${repo.name}`,
task: () => new Listr([{
title: 'Build',
task: () => buildRepo(repo)
}, {
title: `Deploy to ${path.join(_flags.destination, repo.deployPath)}`,
task: () => deployRepoLocally(repo, _flags.destination)
}])
}))
])
await tasks.run()
this.log('\n ✅ All done!')
this.log(' You can now browse the locally deployed docs by launching the following command:\n')
this.log(` http-server ${_flags.destination}\n`)
}
}