1
1
import { HydrationInputValues } from "../../../values/types.js" ;
2
2
import { formatIgnoreFile } from "./formatters/formatIgnoreFile.js" ;
3
3
import { formatJson } from "./formatters/formatJson.js" ;
4
+ import { writePackageJson } from "./writePackageJson.js" ;
4
5
5
- export function createRootFiles ( {
6
- author,
7
- description,
8
- email,
9
- owner,
10
- releases,
11
- repository,
12
- unitTests,
13
- } : HydrationInputValues ) {
6
+ export async function createRootFiles ( values : HydrationInputValues ) {
14
7
return {
15
8
".all-contributorsrc" : formatJson ( {
16
9
badgeTemplate :
@@ -22,14 +15,14 @@ export function createRootFiles({
22
15
contributorsSortAlphabetically : true ,
23
16
files : [ "README.md" ] ,
24
17
imageSize : 100 ,
25
- projectName : repository ,
26
- projectOwner : owner ,
18
+ projectName : values . repository ,
19
+ projectOwner : values . owner ,
27
20
repoHost : "https://github.com" ,
28
21
repoType : "github" ,
29
22
} ) ,
30
23
".eslintignore" : formatIgnoreFile ( [
31
24
"!.*" ,
32
- ...( unitTests ? [ "coverage" ] : [ ] ) ,
25
+ ...( values . unitTests ? [ "coverage" ] : [ ] ) ,
33
26
"lib" ,
34
27
"node_modules" ,
35
28
"pnpm-lock.yaml" ,
@@ -106,7 +99,7 @@ module.exports = {
106
99
},
107
100
extends: ["plugin:jsonc/recommended-with-json"],
108
101
},${
109
- unitTests
102
+ values . unitTests
110
103
? `\n{
111
104
files: "**/*.test.ts",
112
105
rules: {
@@ -145,17 +138,17 @@ module.exports = {
145
138
"@typescript-eslint",
146
139
"deprecation",
147
140
"import",
148
- "jsdoc",${ unitTests ? `\n"no-only-tests",` : "" }
141
+ "jsdoc",${ values . unitTests ? `\n"no-only-tests",` : "" }
149
142
"regexp",
150
143
"simple-import-sort",
151
- "typescript-sort-keys",${ unitTests ? `\n"vitest",` : "" }
144
+ "typescript-sort-keys",${ values . unitTests ? `\n"vitest",` : "" }
152
145
],
153
146
root: true,
154
147
rules: {
155
148
// These off/less-strict-by-default rules work well for this repo and we like them on.
156
149
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
157
150
"import/extensions": ["error", "ignorePackages"],${
158
- unitTests ? `\n"no-only-tests/no-only-tests": "error",` : ""
151
+ values . unitTests ? `\n"no-only-tests/no-only-tests": "error",` : ""
159
152
}
160
153
"simple-import-sort/exports": "error",
161
154
"simple-import-sort/imports": "error",
@@ -175,7 +168,7 @@ module.exports = {
175
168
};
176
169
` ,
177
170
".gitignore" : formatIgnoreFile ( [
178
- ...( unitTests ? [ "coverage/" ] : [ ] ) ,
171
+ ...( values . unitTests ? [ "coverage/" ] : [ ] ) ,
179
172
"lib/" ,
180
173
"node_modules/" ,
181
174
] ) ,
@@ -199,7 +192,7 @@ module.exports = {
199
192
} ) ,
200
193
".nvmrc" : `18.16.0\n` ,
201
194
".prettierignore" : formatIgnoreFile ( [
202
- ...( unitTests ? [ "coverage/" ] : [ ] ) ,
195
+ ...( values . unitTests ? [ "coverage/" ] : [ ] ) ,
203
196
"lib/" ,
204
197
"pnpm-lock.yaml" ,
205
198
"" ,
@@ -258,7 +251,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
258
251
ignorePaths : [
259
252
".github" ,
260
253
"CHANGELOG.md" ,
261
- ...( unitTests ? [ "coverage" ] : [ ] ) ,
254
+ ...( values . unitTests ? [ "coverage" ] : [ ] ) ,
262
255
"lib" ,
263
256
"node_modules" ,
264
257
"pnpm-lock.yaml" ,
@@ -287,46 +280,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
287
280
ignoreBinaries : [ "dedupe" , "gh" ] ,
288
281
project : [ "src/**/*.ts!" , "script/**/*.js" ] ,
289
282
} ) ,
290
- "package.json" : formatJson ( {
291
- name : repository ,
292
- description,
293
- repository : {
294
- type : "git" ,
295
- url : `https://github.com/${ owner } /${ repository } ` ,
296
- } ,
297
- license : "MIT" ,
298
- author : { email, name : author } ,
299
- type : "module" ,
300
- main : "./lib/index.js" ,
301
- files : [ "lib/" , "package.json" , "LICENSE.md" , "README.md" ] ,
302
- scripts : {
303
- build : "tsc" ,
304
- format : 'prettier "**/*" --ignore-unknown' ,
305
- "format:write" : "pnpm format --write" ,
306
- lint : "eslint . --max-warnings 0 --report-unused-disable-directives" ,
307
- "lint:knip" : "knip" ,
308
- "lint:md" :
309
- 'markdownlint "**/*.md" ".github/**/*.md" --rules sentences-per-line' ,
310
- "lint:package" : "npmPkgJsonLint ." ,
311
- "lint:packages" : "pnpm dedupe --check" ,
312
- "lint:spelling" : 'cspell "**" ".github/**/*"' ,
313
- prepare : "husky install" ,
314
- ...( releases && {
315
- "should-semantic-release" : "should-semantic-release --verbose" ,
316
- } ) ,
317
- ...( unitTests && { test : "vitest" } ) ,
318
- } ,
319
- "lint-staged" : {
320
- "*" : "prettier --ignore-unknown --write" ,
321
- } ,
322
- packageManager :
"[email protected] " ,
323
- engines : {
324
- node : ">=18" ,
325
- } ,
326
- publishConfig : {
327
- provenance : true ,
328
- } ,
329
- } ) ,
283
+ "package.json" : await writePackageJson ( values ) ,
330
284
"tsconfig.eslint.json" : formatJson ( {
331
285
extends : "./tsconfig.json" ,
332
286
include : [ "." ] ,
@@ -346,7 +300,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
346
300
} ,
347
301
include : [ "src" ] ,
348
302
} ) ,
349
- ...( unitTests && {
303
+ ...( values . unitTests && {
350
304
"vitest.config.ts" : `import { defineConfig } from "vitest/config";
351
305
352
306
export default defineConfig({
0 commit comments