-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathindex.ts
44 lines (40 loc) · 1.19 KB
/
index.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 { ModeRunner } from "../bin/mode.js";
import { outro } from "../shared/cli/outro.js";
import { StatusCodes } from "../shared/codes.js";
import { ensureGitRepository } from "../shared/ensureGitRepository.js";
import { generateNextSteps } from "../shared/generateNextSteps.js";
import { readOptions } from "../shared/options/readOptions.js";
import { runOrRestore } from "../shared/runOrRestore.js";
import { initializeWithOptions } from "./initializeWithOptions.js";
export const initialize: ModeRunner = async (args) => {
const inputs = await readOptions(args, "initialize");
if (inputs.cancelled) {
return {
code: StatusCodes.Cancelled,
error: inputs.error,
options: inputs.options,
};
}
await ensureGitRepository();
return {
code: await runOrRestore({
run: async () => {
await initializeWithOptions(inputs);
outro([
{
label: "You may consider committing these changes:",
lines: [
`git add -A`,
`git commit -m "feat: initialized repo ✨`,
`git push`,
],
variant: "code",
},
...generateNextSteps(inputs.options),
]);
},
skipRestore: inputs.options.skipRestore,
}),
options: inputs.options,
};
};