/
save.ts
44 lines (33 loc) · 1.4 KB
/
save.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
import { WordpressCli } from '../../wordpress-cli';
import {Command, flags} from '@oclif/command'
import { BlipConf, DockerMachine } from '@lime.it/blip-core'
import Listr = require('listr')
import { join } from 'path'
import { environment } from '../../environment'
import { WorkspaceTaskContext, MachineListTaskContext, isWorkingAsExtracted } from '../../utils'
import { mkdirp, createWriteStream, ensureDir } from 'fs-extra';
export default class TemplateWordpressSave extends Command {
static description = 'Saves the current wordpress instance state to a loadable package'
static flags = {
help: flags.help({char: 'h'}),
name: flags.string({char: 'n', description: 'Commit name', required: false, default: 'commit'})
}
static args = []
async run() {
const {args, flags} = this.parse(TemplateWordpressSave)
const commitName = `${new Date().getTime()}-${flags.name}`;
const commitFilePath = join(environment.repoPath, `${commitName}.tar.gz`);
const tasks = new Listr([
{
title: `Commiting status to ${commitName}`,
task: async (ctx:any) => {
await ensureDir(environment.repoPath);
const stream = createWriteStream(commitFilePath);
await WordpressCli.exportToWritestream(stream, await isWorkingAsExtracted() == false);
stream.close();
}
}
]);
await tasks.run();
}
}