Skip to content
Open
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
24 changes: 24 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"singleQuote": true,
"printWidth": 80,
"sortPackageJson": false,
"ignorePatterns": [
".nyc_output",
"dist/",
"docs/",
"packages/tsconfig.json",
"packages/*/*/dist",
"packages/*/*/doc",
"packages/*/*/index.d.ts",
"packages/*/*/index.ts",
"packages/*/*/README.md",
"packages/*/*/tsconfig.json",
"packages/*/*/typedoc.json",
"packages/api/core/spec/fixture/api-tester/package.json",
"packages/api/core/spec/fixture/bad_external_forge_config/bad.js",
"packages/plugin/webpack/spec/**/.webpack",
".links",
"/.nx/cache",
"/.nx/workspace-data"
]
}
18 changes: 0 additions & 18 deletions .prettierignore

This file was deleted.

6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"oxc.oxc-vscode",
"esbenp.prettier-vscode",
"vitest.explorer"
]
"recommendations": ["oxc.oxc-vscode", "vitest.explorer"]
}
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"build:watch": "tsc -b packages --watch",
"docs": "yarn build && typedoc",
"lerna:version": "./tools/version.sh",
"lint:js": "prettier --check . --experimental-cli && oxlint",
"lint:js": "oxfmt --check . && oxlint",
"lint:markdown": "markdownlint-cli2 \"**/*.md\"",
"lint:markdown-js": "lint-roller-markdown-standard --root . --ignore-path .markdownlintignore --semi \"**/*.md\"",
"lint:markdown-links": "lint-roller-markdown-links --root . --ignore-path .markdownlintignore \"**/*.md\"",
"lint": "npm run lint:js && npm run lint:markdown && npm run lint:markdown-js && npm run lint:markdown-links",
"lint:fix": "prettier --write . --experimental-cli && oxlint --fix",
"lint:fix": "oxfmt --write . && oxlint --fix",
"knip": "knip --no-config-hints && knip --production --no-config-hints",
"prepack": "yarn build",
"test": "xvfb-maybe vitest run --project fast --project slow --project slow-verdaccio",
Expand Down Expand Up @@ -58,8 +58,8 @@
"lint-staged": "^12.1.7",
"listr2": "^7.0.2",
"markdownlint-cli2": "^0.19.1",
"oxfmt": "^0.41.0",
"oxlint": "^1.51.0",
"prettier": "^3.6.2",
"ref-napi": "^3.0.3",
"tsx": "^4.21.0",
"typedoc": "0.25.13",
Expand All @@ -80,15 +80,12 @@
"electron-wix-msi": "^5.1.3"
},
"lint-staged": {
"*.{html,json,md,yml}": "prettier --write --experimental-cli",
"*.{html,json,md,yml}": "oxfmt --write",
"*.{js,ts, cjs, mjs, cts, mts}": [
"prettier --write --experimental-cli",
"oxfmt --write",
"oxlint --fix"
]
},
"prettier": {
"singleQuote": true
},
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f",
"dependenciesMeta": {
"@bitdisaster/exe-icon-extractor": {
Expand Down
9 changes: 3 additions & 6 deletions packages/plugin/webpack/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export interface WebpackPluginEntryPointBase {
nodeIntegration?: boolean;
}

export interface WebpackPluginEntryPointLocalWindow
extends WebpackPluginEntryPointBase {
export interface WebpackPluginEntryPointLocalWindow extends WebpackPluginEntryPointBase {
/**
* Relative or absolute path to the HTML template file for this entry point.
*/
Expand All @@ -52,16 +51,14 @@ export interface WebpackPluginEntryPointLocalWindow
preload?: WebpackPreloadEntryPoint;
}

export interface WebpackPluginEntryPointPreloadOnly
extends WebpackPluginEntryPointBase {
export interface WebpackPluginEntryPointPreloadOnly extends WebpackPluginEntryPointBase {
/**
* Information about the preload script for this entry point.
*/
preload: WebpackPreloadEntryPoint;
}

export interface WebpackPluginEntryPointNoWindow
extends WebpackPluginEntryPointBase {
export interface WebpackPluginEntryPointNoWindow extends WebpackPluginEntryPointBase {
/**
* Relative or absolute path to the main JS file for this entry point.
*/
Expand Down
16 changes: 15 additions & 1 deletion packages/template/base/src/BaseTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const currentForgeVersion = fs.readJSONSync(

const d = debug('electron-forge:template:base');
const tmplDir = path.resolve(import.meta.dirname, '../tmpl');
const rootOxfmtrcPath = path.resolve(
import.meta.dirname,
'../../../../.oxfmtrc.json',
);

export class BaseTemplate implements ForgeTemplate {
public templateDir = tmplDir;
Expand Down Expand Up @@ -107,6 +111,15 @@ export class BaseTemplate implements ForgeTemplate {
path.resolve(directory, 'src', file),
);
}

// Dynamically write .oxfmtrc.json from root config, excluding ignorePatterns
const oxfmtrc = await fs.readJson(rootOxfmtrcPath);
delete oxfmtrc.ignorePatterns;
await fs.writeJson(
path.resolve(directory, '.oxfmtrc.json'),
oxfmtrc,
{ spaces: 2 },
);
},
},
{
Expand Down Expand Up @@ -177,12 +190,13 @@ export class BaseTemplate implements ForgeTemplate {

async updateFileByLine(
inputPath: string,
lineHandler: (line: string) => string,
lineHandler: (line: string) => string | null,
outputPath?: string | undefined,
): Promise<void> {
const fileContents = (await fs.readFile(inputPath, 'utf8'))
.split('\n')
.map(lineHandler)
.filter((line): line is string => line !== null)
.join('\n');
await fs.writeFile(outputPath || inputPath, fileContents);
if (outputPath !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/template/base/tmpl/_gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ typings/
# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache
# Optional oxlint cache
.oxlintcache

# Optional REPL history
.node_repl_history
Expand Down
10 changes: 5 additions & 5 deletions packages/template/base/tmpl/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "",
"productName": "",
"version": "1.0.0",
"private": true,
"description": "My Electron application description",
"keywords": [],
"license": "MIT",
"author": "",
"exports": "./src/index.js",
"private": true,
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish"
},
"keywords": [],
"author": "",
"license": "MIT"
"productName": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ describe('ViteTypeScriptTemplate', () => {

beforeAll(async () => {
dir = await testUtils.ensureTestDirIsNonexistent();
await init({
dir,
template: path.resolve(import.meta.dirname, '..'),
interactive: false,
electronVersion: '38.2.2',
});
});

afterAll(async () => {
Expand All @@ -30,19 +36,10 @@ describe('ViteTypeScriptTemplate', () => {
});

describe('template files are copied to project', () => {
it('should succeed in initializing the typescript template', async () => {
await init({
dir,
template: path.resolve(import.meta.dirname, '..'),
interactive: false,
electronVersion: '38.2.2',
});
});

it.each([
'package.json',
'tsconfig.json',
'.eslintrc.json',
'.oxlintrc.json',
'forge.config.ts',
'vite.main.config.ts',
'vite.preload.config.ts',
Expand Down
14 changes: 11 additions & 3 deletions packages/template/vite-typescript/src/ViteTypeScriptTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ViteTypeScriptTemplate extends BaseTemplate {
// Copy tsconfig with a small set of presets
await this.copyTemplateFile(directory, 'tsconfig.json');

// Copy eslint config with recommended settings
await this.copyTemplateFile(directory, '.eslintrc.json');
// Copy oxc.rs config with recommended settings
await this.copyTemplateFile(directory, '.oxlintrc.json');

// Remove index.js and replace with main.ts
await fs.remove(filePath('index.js'));
Expand Down Expand Up @@ -67,12 +67,20 @@ class ViteTypeScriptTemplate extends BaseTemplate {
await this.updateFileByLine(
path.join(directory, 'index.html'),
(line) => {
if (line.includes('link rel="stylesheet"')) return '';
if (line.includes('link rel="stylesheet"')) return null;
if (line.includes('</body>'))
return ' <script type="module" src="/src/renderer.ts"></script>\n </body>';
return line;
},
);

// update package.json
const packageJSONPath = path.resolve(directory, 'package.json');
const packageJSON = await fs.readJson(packageJSONPath);
packageJSON.main = '.vite/build/main.js';
await fs.writeJson(packageJSONPath, packageJSON, {
spaces: 2,
});
},
},
];
Expand Down
22 changes: 0 additions & 22 deletions packages/template/vite-typescript/tmpl/.eslintrc.json

This file was deleted.

6 changes: 6 additions & 0 deletions packages/template/vite-typescript/tmpl/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
"no-unused-vars": "warn",
"unicorn/no-empty-file": "off"
}
}
9 changes: 3 additions & 6 deletions packages/template/vite-typescript/tmpl/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"main": ".vite/build/main.js",
"scripts": {
"lint": "eslint --ext .ts,.tsx .",
"lint": "oxlint && oxfmt --check .",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@electron-forge/plugin-vite": "ELECTRON_FORGE/VERSION",
"@types/electron-squirrel-startup": "^1.0.2",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.25.0",
"eslint-import-resolver-typescript": "^4.4.4",
"oxfmt": "^0.41.0",
"oxlint": "^1.0.0",
"typescript": "^5.9.2",
"vite": "^7.2.4"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/template/vite/src/ViteTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ViteTemplate extends BaseTemplate {
await this.updateFileByLine(
path.join(directory, 'index.html'),
(line) => {
if (line.includes('link rel="stylesheet"')) return '';
if (line.includes('link rel="stylesheet"')) return null;
if (line.includes('</body>'))
return ' <script type="module" src="/src/renderer.js"></script>\n </body>';
return line;
Expand Down
2 changes: 1 addition & 1 deletion packages/template/vite/tmpl/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"main": ".vite/build/main.js",
"devDependencies": {
"@electron/fuses": "^2.0.0",
"@electron-forge/plugin-vite": "ELECTRON_FORGE/VERSION",
"@electron/fuses": "^2.0.0",
"vite": "^7.2.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ describe('WebpackTypeScriptTemplate', () => {

beforeAll(async () => {
dir = await testUtils.ensureTestDirIsNonexistent();
});

it('should succeed in initializing the typescript template', async () => {
await init({
dir,
template: path.join(import.meta.dirname, '..'),
Expand All @@ -32,7 +29,7 @@ describe('WebpackTypeScriptTemplate', () => {
describe('template files are copied to project', () => {
it.each([
'tsconfig.json',
'.eslintrc.json',
'.oxlintrc.json',
'forge.config.ts',
'webpack.main.config.ts',
'webpack.renderer.config.ts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class WebpackTypeScriptTemplate extends BaseTemplate {
await this.updateFileByLine(
path.resolve(directory, 'src', 'index.html'),
(line) => {
if (line.includes('link rel="stylesheet"')) return '';
if (line.includes('link rel="stylesheet"')) return null;
return line;
},
);

// Copy tsconfig with a small set of presets
await this.copyTemplateFile(directory, 'tsconfig.json');

// Copy eslint config with recommended settings
await this.copyTemplateFile(directory, '.eslintrc.json');
// Copy oxc.rs config with recommended settings
await this.copyTemplateFile(directory, '.oxlintrc.json');

// Remove index.js and replace with index.ts
await fs.remove(filePath('index.js'));
Expand All @@ -65,6 +65,14 @@ class WebpackTypeScriptTemplate extends BaseTemplate {
path.join(directory, 'src'),
'preload.ts',
);

// update package.json
const packageJSONPath = path.resolve(directory, 'package.json');
const packageJSON = await fs.readJson(packageJSONPath);
packageJSON.main = '.webpack/main';
await fs.writeJson(packageJSONPath, packageJSON, {
spaces: 2,
});
},
},
];
Expand Down
Loading