-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathinitializeWithOptions.ts
63 lines (57 loc) · 1.92 KB
/
initializeWithOptions.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
import { withSpinner, withSpinners } from "../shared/cli/spinners.js";
import { GitHubAndOptions } from "../shared/options/readOptions.js";
import { addOwnerAsAllContributor } from "../steps/addOwnerAsAllContributor.js";
import { clearChangelog } from "../steps/clearChangelog.js";
import { initializeGitHubRepository } from "../steps/initializeGitHubRepository/index.js";
import { removeSetupScripts } from "../steps/removeSetupScripts.js";
import { resetGitTags } from "../steps/resetGitTags.js";
import { runCommands } from "../steps/runCommands.js";
import { uninstallPackages } from "../steps/uninstallPackages.js";
import { updateAllContributorsTable } from "../steps/updateAllContributorsTable.js";
import { updateLocalFiles } from "../steps/updateLocalFiles.js";
import { updateReadme } from "../steps/updateReadme.js";
export async function initializeWithOptions({
github,
options,
}: GitHubAndOptions) {
await withSpinners("Initializing local files", [
[
"Updating local files",
async () => {
await updateLocalFiles(options);
},
],
["Updating README.md", updateReadme],
["Clearing changelog", clearChangelog],
[
"Updating all-contributors table",
async () => {
await updateAllContributorsTable(options);
},
],
["Resetting Git tags", resetGitTags],
]);
if (!options.excludeAllContributors) {
await withSpinner("Updating existing contributor details", async () => {
await addOwnerAsAllContributor(options.owner);
});
}
if (github) {
await withSpinner("Initializing GitHub repository", async () => {
await initializeGitHubRepository(github.octokit, options);
});
}
if (!options.skipRemoval) {
await withSpinner("Removing setup scripts", removeSetupScripts);
}
if (!options.skipUninstall) {
await withSpinner(
"Uninstalling initialization-only packages",
uninstallPackages,
);
}
await runCommands("Cleaning up files", [
"pnpm lint --fix",
"pnpm format --write",
]);
}