-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable.ts
More file actions
66 lines (54 loc) · 1.89 KB
/
executable.ts
File metadata and controls
66 lines (54 loc) · 1.89 KB
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
#!/usr/bin/env node
import * as fs from "node:fs";
import { logger } from "./logger";
import type { Metadata } from "./types";
import { version as renovateVersion } from "renovate/package.json";
import {
buildRenovateMetadata,
discoverAndProcessThroughGitHubApp,
discoverAndProcessThroughRenovate,
run,
setupRenovate,
} from "./index";
run().then();
export async function runDreamyAction(): Promise<void> {
const outDir: string = process.env.OUT_DIR ?? "out";
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true });
} else if (!fs.statSync(outDir).isDirectory()) {
logger.error(`The expected OUT_DIR, \`${outDir}\` was not a directory`);
process.exit(1);
}
const renovateMetadata = buildRenovateMetadata(renovateVersion);
const metadata: Metadata = {
renovate: renovateMetadata,
};
if ((process.env.RG_GITHUB_APP_ID ?? "") !== "") {
await discoverAndProcessThroughGitHubApp(outDir, metadata);
} else {
const config = await setupRenovate();
if (config.platform !== undefined) {
metadata.renovate.platform = config.platform;
}
if (config.platform === "local") {
const platform = process.env.RG_LOCAL_PLATFORM ?? "";
if (platform === "") {
logger.error(
"Running as local platform, but platform has not been set - make sure you specify RG_LOCAL_PLATFORM",
);
process.exit(1);
}
metadata.renovate.platform = platform;
const organisation = process.env.RG_LOCAL_ORGANISATION ?? "";
const repository = process.env.RG_LOCAL_REPO ?? "";
if (organisation === "" || repository === "") {
logger.error(
`Running as local platform, but the repository name is defined as ${organisation}/${repository} - have you set RG_LOCAL_ORGANISATION and RG_LOCAL_REPO as appropriate?`,
);
process.exit(1);
}
config.repository = `${organisation}/${repository}`;
}
await discoverAndProcessThroughRenovate(config, outDir, metadata);
}
}