Skip to content

Commit 4b1d084

Browse files
fix: preserve existing package.json dependency versions as minimums (#1999)
<!-- πŸ‘‹ Hi, thanks for sending a PR to create-typescript-app! 🎁. Please fill out all fields below and make sure each item is true and [x] checked. Otherwise we may not be able to review your PR. --> ## PR Checklist - [x] Addresses an existing open issue: fixes #1997 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Uses the `semver` package to avoid using new dependency versions if they're smaller than existing ones. As a nice-to-have, not-strictly-necessary cleanup, removes the Base distinction between "full" package data and what's used in Blocks. It's just `packageData` now. No more `packageDataFull`. 🎁
1 parent 841dacc commit 4b1d084

File tree

8 files changed

+529
-156
lines changed

8 files changed

+529
-156
lines changed

β€Žpackage.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"parse-package-name": "^1.0.0",
5959
"remove-dependencies": "^0.1.0",
6060
"remove-undefined-objects": "^6.0.0",
61+
"semver": "^7.7.1",
6162
"set-github-repository-labels": "^0.2.0",
6263
"sort-keys": "^5.1.0",
6364
"sort-package-json": "^3.0.0",
@@ -77,6 +78,7 @@
7778
"@types/lodash": "4.17.16",
7879
"@types/node": "22.13.10",
7980
"@types/parse-author": "2.0.3",
81+
"@types/semver": "^7.5.8",
8082
"@vitest/coverage-v8": "3.0.9",
8183
"@vitest/eslint-plugin": "1.1.38",
8284
"all-contributors-cli": "6.26.1",

β€Žpnpm-lock.yaml

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

β€Žsrc/base.ts

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { readNpmDefaults } from "./options/readNpmDefaults.js";
2626
import { readOwner } from "./options/readOwner.js";
2727
import { readPackageAuthor } from "./options/readPackageAuthor.js";
2828
import { readPackageData } from "./options/readPackageData.js";
29-
import { readPackageDataFull } from "./options/readPackageDataFull.js";
3029
import { readPnpm } from "./options/readPnpm.js";
3130
import { readRepository } from "./options/readRepository.js";
3231
import { readRulesetId } from "./options/readRulesetId.js";
@@ -169,9 +168,7 @@ export const base = createBase({
169168
.describe("package version to publish as and store in `package.json`"),
170169
},
171170
prepare({ options, take }) {
172-
const getAccess = lazyValue(
173-
async () => await readAccess(getPackageDataFull),
174-
);
171+
const getAccess = lazyValue(async () => await readAccess(getPackageData));
175172

176173
const getAllContributors = lazyValue(
177174
async () => await readAllContributors(take),
@@ -182,12 +179,12 @@ export const base = createBase({
182179
await readAuthor(getPackageAuthor, getNpmDefaults, options.owner),
183180
);
184181

185-
const getBin = lazyValue(async () => (await getPackageDataFull()).bin);
182+
const getBin = lazyValue(async () => (await getPackageData()).bin);
186183

187184
const getEmoji = lazyValue(async () => await readEmoji(getDescription));
188185

189186
const getDescription = lazyValue(
190-
async () => await readDescription(getPackageDataFull, getReadme),
187+
async () => await readDescription(getPackageData, getReadme),
191188
);
192189

193190
const getDocumentation = lazyValue(
@@ -227,16 +224,10 @@ export const base = createBase({
227224

228225
const getLogo = lazyValue(async () => await readLogo(getReadme));
229226

230-
const getPackageData = lazyValue(
231-
async () => await readPackageData(getPackageDataFull),
232-
);
233-
234-
const getPackageDataFull = lazyValue(
235-
async () => await readPackageDataFull(take),
236-
);
227+
const getPackageData = lazyValue(async () => await readPackageData(take));
237228

238229
const getNode = lazyValue(
239-
async () => await readNode(getNvmrc, getPackageDataFull),
230+
async () => await readNode(getNvmrc, getPackageData),
240231
);
241232

242233
const getNpmDefaults = lazyValue(
@@ -260,18 +251,17 @@ export const base = createBase({
260251
);
261252

262253
const getPackageAuthor = lazyValue(
263-
async () => await readPackageAuthor(getPackageDataFull),
254+
async () => await readPackageAuthor(getPackageData),
264255
);
265256

266-
const getPnpm = lazyValue(async () => await readPnpm(getPackageDataFull));
257+
const getPnpm = lazyValue(async () => await readPnpm(getPackageData));
267258

268259
const getReadme = lazyValue(
269260
async () => await readFileSafe("README.md", ""),
270261
);
271262

272263
const getRepository = lazyValue(
273-
async () =>
274-
await readRepository(getGitDefaults, getPackageDataFull, options),
264+
async () => await readRepository(getGitDefaults, getPackageData, options),
275265
);
276266

277267
const getRulesetId = lazyValue(
@@ -286,9 +276,7 @@ export const base = createBase({
286276
async () => await readUsage(getEmoji, getReadme, getRepository),
287277
);
288278

289-
const getVersion = lazyValue(
290-
async () => (await getPackageDataFull()).version,
291-
);
279+
const getVersion = lazyValue(async () => (await getPackageData()).version);
292280

293281
return {
294282
access: getAccess,

0 commit comments

Comments
Β (0)