create-typescript-app 2.21.4 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/blocks/blockKnip.js
CHANGED
|
@@ -9,12 +9,25 @@ import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
|
|
|
9
9
|
import { blockPackageJson } from "./blockPackageJson.js";
|
|
10
10
|
import { blockRemoveFiles } from "./blockRemoveFiles.js";
|
|
11
11
|
import { blockRemoveWorkflows } from "./blockRemoveWorkflows.js";
|
|
12
|
+
import { intakeFileAsJson } from "./intake/intakeFileAsJson.js";
|
|
13
|
+
const zIgnoreDependencies = z.array(z.string());
|
|
12
14
|
const blockKnip = base.createBlock({
|
|
13
15
|
about: {
|
|
14
16
|
name: "Knip"
|
|
15
17
|
},
|
|
16
18
|
addons: {
|
|
17
|
-
ignoreDependencies:
|
|
19
|
+
ignoreDependencies: zIgnoreDependencies.optional()
|
|
20
|
+
},
|
|
21
|
+
intake({ files }) {
|
|
22
|
+
const knipJson = intakeFileAsJson(files, ["knip.json"]);
|
|
23
|
+
if (!knipJson?.ignoreDependencies) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
ignoreDependencies: zIgnoreDependencies.safeParse(
|
|
28
|
+
knipJson.ignoreDependencies
|
|
29
|
+
).data
|
|
30
|
+
};
|
|
18
31
|
},
|
|
19
32
|
produce({ addons }) {
|
|
20
33
|
const { ignoreDependencies } = addons;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import JSON5 from "json5";
|
|
2
|
+
import { intakeFile } from "./intakeFile.js";
|
|
3
|
+
function intakeFileAsJson(files, filePath) {
|
|
4
|
+
const file = intakeFile(files, filePath);
|
|
5
|
+
try {
|
|
6
|
+
return file && JSON5.parse(file[0]);
|
|
7
|
+
} catch {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
intakeFileAsJson
|
|
13
|
+
};
|