/
build.ts
95 lines (77 loc) · 2.59 KB
/
build.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
import { Command, flags } from '@oclif/command';
import {
installPatternLabDependencies,
runPatternLabBuild,
runStylesBuild,
} from '../../docker/gesso';
import { dryRunFlag, verboseFlag } from '../../flags';
import runParallelProcesses, {
NamedCommand,
} from '../../process/runParallelProcesses';
import findProject from '../../project/findProject';
export default class ThemeBuild extends Command {
static description = '[DEPRECATED] run gesso-related build tasks';
static flags = {
help: flags.help({ char: 'h' }),
'dry-run': dryRunFlag,
css: flags.boolean({ description: 'build CSS' }),
'pattern-lab': flags.boolean({ description: 'build PL' }),
verbose: verboseFlag,
};
async run() {
process.emitWarning(
`The "theme:build" command is deprecated and will be removed in a later release.
For more information, please see https://github.com/forumone/generator-web-starter/wiki/Gesso-2.x-Container-Migration.`,
);
const { flags } = this.parse(ThemeBuild);
const dryRun = flags['dry-run'];
const verbose = flags['verbose'];
const project = await findProject();
if (project === null || project.type !== 'compose') {
return this.error(
'Could not find a docker-compose.yml file in the current directory or any parent',
{ exit: 1 },
);
}
// If this is true, then the user specified either both --css and --pattern-lab,
// or neither.
const buildBoth = flags.css === flags['pattern-lab'];
const buildStyles = buildBoth || flags.css;
const buildPatternLab = buildBoth || flags['pattern-lab'];
const install = await installPatternLabDependencies(project);
const stylesCommand = runStylesBuild(project);
const patternLabCommand = runPatternLabBuild(project);
if (dryRun) {
install.dryRun();
if (buildStyles) {
stylesCommand.dryRun();
}
if (buildPatternLab) {
patternLabCommand.dryRun();
}
return;
}
// Run verbose output immediately before command execution.
if (verbose) {
install.dryRun();
}
await install.run();
const processes: NamedCommand[] = [];
if (buildStyles) {
processes.push({ ...stylesCommand, name: 'gesso' });
}
if (buildPatternLab) {
processes.push({ ...patternLabCommand, name: 'pattern-lab' });
}
// Run verbose output immediately before command execution.
if (verbose) {
if (buildStyles) {
stylesCommand.dryRun();
}
if (buildPatternLab) {
patternLabCommand.dryRun();
}
}
await runParallelProcesses(processes);
}
}