Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/tough-comics-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@halfdomelabs/project-builder-web': patch
'@halfdomelabs/react-generators': patch
'@halfdomelabs/core-generators': patch
'@halfdomelabs/ui-components': patch
---

Upgrade Vitest to 3.0.3 and Vite to 6.0.11 (and associated dependencies)
21 changes: 17 additions & 4 deletions packages/core-generators/src/generators/node/vitest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ export const vitestGenerator = createGenerator({
{ name: 'vitest-config', mergeArraysUniquely: true },
);

const vitestConfigFilename = node.isEsm()
? 'vitest.config.ts'
: 'vitest.config.mts';

node.addDevPackages({
vitest: '2.1.1',
'vite-tsconfig-paths': '4.3.2',
vitest: '3.0.3',
'vite-tsconfig-paths': '5.1.4',
});

eslint.getConfig().appendUnique('eslintIgnore', ['vitest.config.ts']);
eslint.getConfig().appendUnique('eslintIgnore', [vitestConfigFilename]);

return {
providers: {
Expand Down Expand Up @@ -124,7 +128,16 @@ export const vitestGenerator = createGenerator({
});

await builder.apply(
vitestConfigFile.renderToAction('vitest.config.ts'),
vitestConfigFile.renderToAction(
'vitest.config.ts',
vitestConfigFilename,
{
id: 'vitest-config',
alternateFullIds: [
'@halfdomelabs/core-generators#node/vitest:vitest.config.ts',
],
},
),
);
},
};
Expand Down
66 changes: 35 additions & 31 deletions packages/core-generators/src/writers/typescript/source-file.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import type { BuilderAction } from '@halfdomelabs/sync';
import type { BuilderAction, WriteFileOptions } from '@halfdomelabs/sync';
import type {
CallExpression,
ExportDeclaration,
Identifier,
SourceFile,
} from 'ts-morph';

import { writeFormattedAction } from '@halfdomelabs/sync';
import { mapValues, uniqWith } from 'es-toolkit';
import { Eta } from 'eta';
import path from 'node:path';
Expand Down Expand Up @@ -553,8 +552,11 @@ interface EtaPreprocessOptions {
data: Record<string, unknown>;
}

interface FileWriteOptions {
shouldNeverOverwrite?: boolean;
interface SourceFileWriteOptions extends WriteFileOptions {
/**
* The id of the file
*/
id?: string;
/**
* Preprocess template with Eta to allow for more powerful templating options
* beyond just find-replace.
Expand Down Expand Up @@ -721,52 +723,54 @@ export class TypescriptSourceFile<
renderToActionFromText(
template: string,
destination: string,
options?: FileWriteOptions,
options?: SourceFileWriteOptions,
): BuilderAction {
return {
execute: async (builder) => {
execute: (builder) => {
const { id, preprocessWithEta, ...rest } = options ?? {};
const fullPath = builder.resolvePath(destination);
if (options?.preprocessWithEta) {
template = this.preprocessWithEta(
template,
options.preprocessWithEta,
);
if (preprocessWithEta) {
template = this.preprocessWithEta(template, preprocessWithEta);
}
const contents = this.renderToText(template, fullPath);
await builder.apply(
writeFormattedAction({
destination,
contents,
...options,
}),
);
builder.writeFile({
id: id ?? fullPath,
filePath: fullPath,
contents,
options: {
shouldFormat: true,
shouldNeverOverwrite: options?.shouldNeverOverwrite,
...rest,
},
});
},
};
}

renderToAction(
templateFile: string,
destination?: string,
options?: FileWriteOptions,
options?: SourceFileWriteOptions,
): BuilderAction {
return {
execute: async (builder) => {
const { id, preprocessWithEta, ...rest } = options ?? {};
const fullPath = builder.resolvePath(destination ?? templateFile);
let template = await builder.readTemplate(templateFile);
if (options?.preprocessWithEta) {
template = this.preprocessWithEta(
template,
options.preprocessWithEta,
);
if (preprocessWithEta) {
template = this.preprocessWithEta(template, preprocessWithEta);
}
const contents = this.renderToText(template, fullPath);
await builder.apply(
writeFormattedAction({
destination: destination ?? templateFile,
contents,
...options,
}),
);
builder.writeFile({
id: id ?? fullPath,
filePath: fullPath,
contents,
options: {
shouldFormat: true,
shouldNeverOverwrite: options?.shouldNeverOverwrite,
...rest,
},
});
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/project-builder-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"tailwindcss": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"vite-plugin-svgr": "4.2.0",
"vite-plugin-svgr": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/react-generators/src/generators/core/react/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export function setupViteNode(node: NodeProvider): void {
'@types/node': `^${nodeVersion}.0.0`,
'@types/react': '18.3.8',
'@types/react-dom': '18.3.0',
'@vitejs/plugin-react': '4.3.1',
vite: '5.4.7',
'vite-plugin-svgr': '4.2.0',
'vite-tsconfig-paths': '4.3.2',
'@vitejs/plugin-react': '4.3.4',
vite: '6.0.11',
'vite-plugin-svgr': '4.3.0',
'vite-tsconfig-paths': '5.1.4',
});
node.addScripts({
dev: 'vite',
Expand Down
31 changes: 16 additions & 15 deletions packages/sync/src/actions/write-formatted-action.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { createBuilderActionCreator } from '@src/output/builder-action.js';

interface Options {
export interface WriteFormattedActionOptions {
id?: string;
destination: string;
contents: string;
shouldNeverOverwrite?: boolean;
}

export const writeFormattedAction = createBuilderActionCreator<[Options]>(
(options: Options) => (builder) => {
const { destination, contents, shouldNeverOverwrite } = options;
export const writeFormattedAction = createBuilderActionCreator<
[WriteFormattedActionOptions]
>((options: WriteFormattedActionOptions) => (builder) => {
const { id, destination, contents, shouldNeverOverwrite } = options;

builder.writeFile({
id: destination,
filePath: destination,
contents,
options: {
shouldFormat: true,
shouldNeverOverwrite,
},
});
},
);
builder.writeFile({
id: id ?? destination,
filePath: destination,
contents,
options: {
shouldFormat: true,
shouldNeverOverwrite,
},
});
});
2 changes: 1 addition & 1 deletion packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"tsc-alias": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"vite-plugin-svgr": "4.2.0",
"vite-plugin-svgr": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
},
Expand Down
Loading
Loading