Skip to content

Commit 57dcb62

Browse files
feat: allow description to safely include HTML tags
1 parent 1fb4791 commit 57dcb62

14 files changed

+296
-121
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"execa": "^9.5.2",
5050
"git-remote-origin-url": "^4.0.0",
5151
"git-url-parse": "^16.0.0",
52+
"html-to-text": "^9.0.5",
5253
"image-size": "^1.2.0",
5354
"input-from-file": "0.1.0-alpha.4",
5455
"input-from-file-json": "0.1.0-alpha.4",
@@ -79,6 +80,7 @@
7980
"@release-it/conventional-changelog": "9.0.3",
8081
"@types/eslint-plugin-markdown": "2.0.2",
8182
"@types/git-url-parse": "9.0.3",
83+
"@types/html-to-text": "^9.0.4",
8284
"@types/js-yaml": "4.0.9",
8385
"@types/node": "22.10.2",
8486
"@types/parse-author": "2.0.3",

pnpm-lock.yaml

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/next/base.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ export const base = createBase({
156156
)?.stdout?.toString();
157157
});
158158

159+
const readme = lazyValue(async () => await readFileSafe("README.md", ""));
160+
159161
// TODO: Make these all use take
160162

161163
const gitDefaults = tryCatchLazyValueAsync(async () =>
@@ -196,7 +198,7 @@ export const base = createBase({
196198
author,
197199
bin: async () => (await packageData()).bin,
198200
contributors: allContributors,
199-
description: async () => await readDescription(packageData),
201+
description: async () => await readDescription(packageData, readme),
200202
documentation,
201203
email: async () => readEmails(npmDefaults, packageAuthor),
202204
funding: readFunding,
@@ -220,7 +222,7 @@ export const base = createBase({
220222
options.repository ??
221223
(await gitDefaults())?.name ??
222224
(await packageData()).name,
223-
...readDefaultsFromReadme(),
225+
...readDefaultsFromReadme(readme, options.repository),
224226
version,
225227
};
226228
},

src/next/blocks/blockPackageJson.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as htmlToText from "html-to-text";
12
import removeUndefinedObjects from "remove-undefined-objects";
23
import sortPackageJson from "sort-package-json";
34
import { z } from "zod";
@@ -44,6 +45,7 @@ export const blockPackageJson = base.createBlock({
4445
...options.packageData?.devDependencies,
4546
...addons.properties.devDependencies,
4647
};
48+
const description = htmlToText.convert(options.description);
4749

4850
return {
4951
files: {
@@ -56,7 +58,7 @@ export const blockPackageJson = base.createBlock({
5658
dependencies: Object.keys(dependencies).length
5759
? dependencies
5860
: undefined,
59-
description: options.description,
61+
description,
6062
devDependencies: Object.keys(devDependencies).length
6163
? devDependencies
6264
: undefined,

0 commit comments

Comments
 (0)