Skip to content

Commit 4c050d6

Browse files
fix: moved hydrate to bin
1 parent 4078393 commit 4c050d6

File tree

4 files changed

+80
-78
lines changed

4 files changed

+80
-78
lines changed

bin/hydrate.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
import { hydrate } from "../lib/hydrate/index.js";
3+
4+
process.exitCode = await hydrate(process.argv.slice(2));

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
},
1414
"type": "module",
1515
"main": "./lib/index.js",
16-
"bin": "./lib/hydrate/index.js",
16+
"bin": "./bin/hydrate.js",
1717
"files": [
18+
"bin/",
1819
"lib/",
1920
"package.json",
2021
"LICENSE.md",

src/hydrate/hydrate.ts

-75
This file was deleted.

src/hydrate/index.ts

+74-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,75 @@
1-
import { hydrate } from "./hydrate.js";
1+
import { parseArgs } from "node:util";
22

3-
process.exitCode = await hydrate(process.argv.slice(2));
3+
import { setupWithInformation } from "../setup/setupWithInformation.js";
4+
import {
5+
skipSpinnerBlock,
6+
successSpinnerBlock,
7+
withSpinner,
8+
} from "../shared/cli/spinners.js";
9+
import { runOrRestore } from "../shared/runOrRestore.js";
10+
import { clearUnnecessaryFiles } from "./steps/clearUnnecessaryFiles.js";
11+
import { finalizeDependencies as finalizeDependencies } from "./steps/finalizeDependencies.js";
12+
import { runCommand } from "./steps/runCommand.js";
13+
import { writeReadme } from "./steps/writeReadme.js";
14+
import { writeStructure } from "./steps/writing/writeStructure.js";
15+
import { getHydrationDefaults } from "./values/getHydrationDefaults.js";
16+
import { augmentWithHydrationValues } from "./values/hydrationInputValues.js";
17+
18+
export async function hydrate(args: string[]) {
19+
const { values: hydrationSkips } = parseArgs({
20+
args,
21+
options: {
22+
"skip-install": { type: "boolean" },
23+
"skip-setup": { type: "boolean" },
24+
},
25+
strict: false,
26+
tokens: true,
27+
});
28+
29+
return await runOrRestore({
30+
args,
31+
defaults: await getHydrationDefaults(),
32+
label: "hydration",
33+
run: async ({ octokit, values }) => {
34+
const hydrationValues = await augmentWithHydrationValues(values);
35+
36+
await withSpinner(clearUnnecessaryFiles, "clearing unnecessary files");
37+
38+
await withSpinner(
39+
() => writeStructure(hydrationValues),
40+
"writing new repository structure"
41+
);
42+
43+
await withSpinner(
44+
() => writeReadme(hydrationValues),
45+
"writing README.md"
46+
);
47+
48+
if (hydrationSkips["skip-install"]) {
49+
skipSpinnerBlock(`Skipping package installations.`);
50+
} else {
51+
await withSpinner(
52+
() => finalizeDependencies(hydrationValues),
53+
"finalizing dependencies"
54+
);
55+
}
56+
57+
await runCommand("pnpm lint --fix", "auto-fixing lint rules");
58+
await runCommand("pnpm format --write", "formatting files");
59+
60+
if (hydrationSkips["skip-setup"]) {
61+
skipSpinnerBlock(`Done hydrating, and skipping setup command.`);
62+
} else {
63+
successSpinnerBlock("Done hydrating. Starting setup command...");
64+
65+
await setupWithInformation({
66+
octokit,
67+
values: {
68+
...hydrationValues,
69+
skipUninstalls: true,
70+
},
71+
});
72+
}
73+
},
74+
});
75+
}

0 commit comments

Comments
 (0)