-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pnpmpnpmpnpmpnpm
- Loading branch information
Showing
23 changed files
with
196 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import path from 'node:path'; | ||
|
||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import { findTemplate } from '../../src/api/init-scripts/find-template'; | ||
|
||
describe('findTemplate', () => { | ||
/** | ||
* Note: this test suite does not mock `require.resolve`. Instead, it uses | ||
* fixture dependencies defined in this module's package.json file to | ||
* actually resolve a local template. | ||
* | ||
* If you modify the fixtures, you may need to re-run `yarn install` in order | ||
* for the fixtures to be installed in your local `node_modules`. | ||
*/ | ||
describe('local modules', () => { | ||
it('should find an @electron-forge/template based on name', async () => { | ||
await expect(findTemplate('fixture')).resolves.toEqual({ name: 'electron-forge-template-fixture' }); | ||
}); | ||
it('should find an @electron-forge/template based on name', async () => { | ||
await expect(findTemplate('fixture-two')).resolves.toEqual({ name: 'electron-forge-template-fixture' }); | ||
}); | ||
it('should find an @electron-forge/template based on name', async () => { | ||
await expect(findTemplate('electron-forge-template-fixture-two')).resolves.toEqual({ name: 'electron-forge-template-fixture' }); | ||
}); | ||
}); | ||
|
||
/** | ||
* For global modules, we re-route the global NPM `node_modules` directory to | ||
* a folder in our fixture directory. Note that the folder _needs_ to be called | ||
* `node_modules` in order for the `require.resolve` custom path to work. | ||
*/ | ||
describe('global modules', () => { | ||
vi.mock(import('global-dirs'), async (importOriginal) => { | ||
const mod = await importOriginal(); | ||
return { | ||
default: { | ||
...mod.default, | ||
npm: { | ||
...mod.default.npm, | ||
packages: path.resolve(__dirname, '..', 'fixture', 'global-stub', 'node_modules'), | ||
}, | ||
}, | ||
}; | ||
}); | ||
it('should find an @electron-forge/template based on name', async () => { | ||
await expect(findTemplate('global')).resolves.toEqual({ name: 'electron-forge-template-fixture-global' }); | ||
}); | ||
it('should find an electron-forge-template based on name', async () => { | ||
await expect(findTemplate('global-two')).resolves.toEqual({ name: 'electron-forge-template-fixture-global' }); | ||
}); | ||
}); | ||
|
||
it('should error if there are no valid templates', async () => { | ||
await expect(findTemplate('non-existent-template')).rejects.toThrowError('Failed to locate custom template: "non-existent-template".'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/api/core/spec/fixture/electron-forge-template-fixture/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { name: 'electron-forge-template-fixture' }; |
5 changes: 5 additions & 0 deletions
5
packages/api/core/spec/fixture/electron-forge-template-fixture/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"main": "index.js", | ||
"type": "commonjs", | ||
"version": "13.3.7" | ||
} |
1 change: 1 addition & 0 deletions
1
...s/api/core/spec/fixture/global-stub/node_modules/@electron-forge/template-global/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
...i/core/spec/fixture/global-stub/node_modules/@electron-forge/template-global/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...pi/core/spec/fixture/global-stub/node_modules/electron-forge-template-global-two/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
...ore/spec/fixture/global-stub/node_modules/electron-forge-template-global-two/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { app, BrowserWindow } from 'electron'; | ||
import path from 'node:path'; | ||
import started from 'electron-squirrel-startup'; | ||
|
||
// Handle creating/removing shortcuts on Windows when installing/uninstalling. | ||
if (started) { | ||
app.quit(); | ||
} | ||
|
||
const createWindow = () => { | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.js'), | ||
}, | ||
}); | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadFile(path.join(__dirname, 'index.html')); | ||
|
||
// Open the DevTools. | ||
mainWindow.webContents.openDevTools(); | ||
}; | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.whenReady().then(() => { | ||
createWindow(); | ||
|
||
// On OS X it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
app.on('activate', () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); | ||
}); | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
// for applications and their menu bar to stay active until the user quits | ||
// explicitly with Cmd + Q. | ||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
// In this file you can include the rest of your app's specific main process | ||
// code. You can also put them in separate files and import them here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.