Skip to content

Commit 2945e54

Browse files
committed
feat: upgrade npm deps
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent e8afca6 commit 2945e54

8 files changed

Lines changed: 420 additions & 303 deletions

File tree

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"ci": "npm run lint:fix && npm run build && npm run test:ci"
2525
},
2626
"devDependencies": {
27-
"@biomejs/biome": "^2.4.8",
28-
"@commitlint/cli": "^21.0.1",
29-
"@commitlint/config-nx-scopes": "^21.0.1",
27+
"@biomejs/biome": "^2.5.2",
28+
"@commitlint/cli": "^21.2.0",
29+
"@commitlint/config-nx-scopes": "^21.2.0",
3030
"lerna": "^9.0.7",
3131
"rimraf": "^6.1.3",
3232
"typescript": "^6.0.3"

packages/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
"url": "https://github.com/escemi-tech/ts-dev-tools/issues"
4848
},
4949
"dependencies": {
50-
"@biomejs/biome": "^2.4.8",
51-
"@commitlint/cli": "^21.0.1",
52-
"@commitlint/config-conventional": "^21.0.2",
50+
"@biomejs/biome": "^2.5.2",
51+
"@commitlint/cli": "^21.2.0",
52+
"@commitlint/config-conventional": "^21.2.0",
5353
"@types/node": "^26.1.0",
54-
"@vitest/coverage-v8": "^4.1.6",
54+
"@vitest/coverage-v8": "^4.1.9",
5555
"typescript": "^6.0.3",
56-
"vitest": "^4.1.6"
56+
"vitest": "^4.1.9"
5757
},
5858
"devDependencies": {
5959
"ts-node": "^10.9.2"

packages/core/src/__snapshots__/core.e2e.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ exports[`E2E - core > Simple project > Installs core package 4`] = `
127127
"linter": {
128128
"enabled": true,
129129
"rules": {
130-
"recommended": true
130+
"preset": "recommended"
131131
}
132132
},
133133
"javascript": {

packages/core/src/install/migrations/20260311120000-migrate-to-biome.spec.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,94 @@ export default tsDevToolsCore;
458458
].join("\n"),
459459
);
460460
});
461+
462+
it("should migrate the current vite react-ts starter links to biome-compatible code", async () => {
463+
const sourceDirPath = join(testProjectDir, "src");
464+
mkdirSync(sourceDirPath, { recursive: true });
465+
466+
const appFilePath = join(sourceDirPath, "App.tsx");
467+
FileService.putFileContent(
468+
appFilePath,
469+
[
470+
"function App() {",
471+
" return (",
472+
" <>",
473+
' <a href="https://vite.dev/" target="_blank">',
474+
" Explore Vite",
475+
" </a>",
476+
' <a href="https://react.dev/" target="_blank">',
477+
' <img className="button-icon" src={reactLogo} alt="" />',
478+
" Learn more",
479+
" </a>",
480+
" </>",
481+
" )",
482+
"}",
483+
"",
484+
"export default App",
485+
"",
486+
].join("\n"),
487+
);
488+
489+
await up(testProjectDir);
490+
491+
expect(FileService.getFileContent(appFilePath)).toBe(
492+
[
493+
"function App() {",
494+
" return (",
495+
" <>",
496+
' <a href="https://vite.dev/" target="_blank" rel="noopener">',
497+
" Explore Vite",
498+
" </a>",
499+
' <a href="https://react.dev/" target="_blank" rel="noopener">',
500+
' <img className="button-icon" src={reactLogo} alt="" />',
501+
" Explore React docs",
502+
" </a>",
503+
" </>",
504+
" )",
505+
"}",
506+
"",
507+
"export default App",
508+
"",
509+
].join("\n"),
510+
);
511+
});
512+
513+
it("should migrate common vite svg assets to biome-compatible code", async () => {
514+
const publicDirPath = join(testProjectDir, "public");
515+
mkdirSync(publicDirPath, { recursive: true });
516+
517+
const faviconFilePath = join(publicDirPath, "favicon.svg");
518+
FileService.putFileContent(
519+
faviconFilePath,
520+
'<svg xmlns="http://www.w3.org/2000/svg"><path d="M0 0"/></svg>',
521+
);
522+
523+
const iconsFilePath = join(publicDirPath, "icons.svg");
524+
FileService.putFileContent(
525+
iconsFilePath,
526+
[
527+
'<svg xmlns="http://www.w3.org/2000/svg">',
528+
' <symbol id="documentation-icon"></symbol>',
529+
"</svg>",
530+
"",
531+
].join("\n"),
532+
);
533+
534+
await up(testProjectDir);
535+
536+
expect(FileService.getFileContent(faviconFilePath)).toBe(
537+
'<svg xmlns="http://www.w3.org/2000/svg"><title>Vite favicon</title><path d="M0 0"/></svg>',
538+
);
539+
expect(FileService.getFileContent(iconsFilePath)).toBe(
540+
[
541+
'<svg xmlns="http://www.w3.org/2000/svg">',
542+
" <title>Vite icon sprite</title>",
543+
' <symbol id="documentation-icon"></symbol>',
544+
"</svg>",
545+
"",
546+
].join("\n"),
547+
);
548+
});
461549
});
462550

463551
describe("hooks", () => {

packages/core/src/install/migrations/20260311120000-migrate-to-biome.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ if (!rootElement) {
5757
createRoot(rootElement).render(`;
5858
const VITE_REACT_BUTTON_PATTERN = "<button onClick={";
5959
const VITE_REACT_BUTTON_REPLACEMENT = '<button type="button" onClick={';
60+
const VITE_REACT_DOCS_LINK_TEXT_PATTERN =
61+
/(href="https:\/\/react\.dev\/"[^>]*>[\s\S]*?)Learn more([\s\S]*?<\/a>)/;
6062

6163
export const up: MigrationUpFunction = async (
6264
absoluteProjectDir: string,
@@ -188,6 +190,14 @@ function migrateCommonViteStarterFiles(absoluteProjectDir: string): void {
188190
join(absoluteProjectDir, "src", "App.tsx"),
189191
migrateViteReactTsAppFile,
190192
);
193+
updateFileContent(
194+
join(absoluteProjectDir, "public", "favicon.svg"),
195+
(content) => addTitleToSvg(content, "Vite favicon"),
196+
);
197+
updateFileContent(
198+
join(absoluteProjectDir, "public", "icons.svg"),
199+
(content) => addTitleToSvg(content, "Vite icon sprite"),
200+
);
191201
}
192202

193203
function updateFileContent(
@@ -230,19 +240,45 @@ function migrateViteReactTsMainFile(content: string): string {
230240

231241
function migrateViteReactTsAppFile(content: string): string {
232242
return replaceExactPattern(
233-
addRelNoopenerToBlankTargetLinks(content),
243+
replaceReactDocsLinkText(addRelNoopenerToBlankTargetLinks(content)),
234244
VITE_REACT_BUTTON_PATTERN,
235245
VITE_REACT_BUTTON_REPLACEMENT,
236246
);
237247
}
238248

249+
function replaceReactDocsLinkText(content: string): string {
250+
return content.replace(
251+
VITE_REACT_DOCS_LINK_TEXT_PATTERN,
252+
"$1Explore React docs$2",
253+
);
254+
}
255+
239256
function addRelNoopenerToBlankTargetLinks(content: string): string {
240257
return content.replaceAll(
241258
/target="_blank"(?![^>]*\srel=)/g,
242259
'target="_blank" rel="noopener"',
243260
);
244261
}
245262

263+
function addTitleToSvg(content: string, title: string): string {
264+
if (content.includes("<title>")) {
265+
return content;
266+
}
267+
268+
const openingTagMatch = content.match(/^<svg\b[^>]*>/);
269+
270+
if (!openingTagMatch) {
271+
return content;
272+
}
273+
274+
const [openingTag] = openingTagMatch;
275+
const titleMarkup = content.includes("\n")
276+
? `${openingTag}\n <title>${title}</title>`
277+
: `${openingTag}<title>${title}</title>`;
278+
279+
return content.replace(openingTag, titleMarkup);
280+
}
281+
246282
function replaceExactPattern(
247283
content: string,
248284
pattern: string,

packages/core/src/tests/test-project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { copyFileSync, symlinkSync } from "node:fs";
22
import { tmpdir } from "node:os";
3-
import { join, relative, resolve } from "node:path";
3+
import { basename, join, relative, resolve } from "node:path";
44
import {
55
copyFolder,
66
deleteFolderRecursive,
@@ -73,7 +73,7 @@ export async function createTestProject(
7373
): Promise<string> {
7474
await recreateFolderRecursive(testDirPath);
7575

76-
const cacheName = testProjectGenerator.name;
76+
const cacheName = `${basename(testDirPath)}-${testProjectGenerator.name}`;
7777
const testCacheDirPath = getTestCacheDirPath(packageName, cacheName);
7878
if (useCache && testCacheDirExists(packageName, cacheName)) {
7979
await copyFolder(testCacheDirPath, testDirPath);

packages/react/src/__snapshots__/react.e2e.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ exports[`E2E - react > Simple project > Installs react package 5`] = `
160160
"linter": {
161161
"enabled": true,
162162
"rules": {
163-
"recommended": true
163+
"preset": "recommended"
164164
}
165165
},
166166
"javascript": {

0 commit comments

Comments
 (0)