-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.ts
56 lines (54 loc) · 1.56 KB
/
main.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
import type { WriteStream } from 'fs';
import { determineInitialParameters } from './initial-parameters.js';
import { followMonorepoWorkflow } from './monorepo-workflow-operations.js';
/**
* The main function for this tool. Designed to not access `process.argv`,
* `process.env`, `process.cwd()`, `process.stdout`, or `process.stderr`
* directly so as to be more easily testable.
*
* @param args - The arguments.
* @param args.argv - The name of this executable and its arguments (as obtained
* via `process.argv`).
* @param args.cwd - The directory in which this executable was run.
* @param args.stdout - A stream that can be used to write to standard out.
* @param args.stderr - A stream that can be used to write to standard error.
*/
export async function main({
argv,
cwd,
stdout,
stderr,
}: {
argv: string[];
cwd: string;
stdout: Pick<WriteStream, 'write'>;
stderr: Pick<WriteStream, 'write'>;
}) {
const {
project,
tempDirectoryPath,
reset,
releaseType,
defaultBranch,
fetchRemote,
} = await determineInitialParameters({ argv, cwd, stderr });
if (project.isMonorepo) {
stdout.write(
'Project appears to have workspaces. Following monorepo workflow.\n',
);
await followMonorepoWorkflow({
project,
tempDirectoryPath,
firstRemovingExistingReleaseSpecification: reset,
releaseType,
defaultBranch,
stdout,
stderr,
fetchRemote,
});
} else {
stdout.write(
'Project does not appear to have any workspaces. Following polyrepo workflow.\n',
);
}
}