Skip to content

Commit

Permalink
merge v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nklayman authored May 31, 2020
2 parents 1d79761 + 0a2bd12 commit 31d27e9
Show file tree
Hide file tree
Showing 48 changed files with 6,321 additions and 7,502 deletions.
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
extends: 'standard',
ignorePatterns: [
'__tests__/projects/*',
'generator/templates/base/src/background.js'
],
env: {
jest: true
}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ on:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [ '12', '10', '8' ]
node: [ '14', '12', '10' ]
include:
- os: windows-latest
commandPrefix: ''
Expand Down
11 changes: 1 addition & 10 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ __tests__/
.github/
.vscode/
docs/
.dockerignore
.eslintrc.js
.travis.yml
appveyor.yml
deployDocs.js
docker-entrypoint.sh
Dockerfile
jest.config.js
testSetup.js
vue-cli-service-custom-1.tgz
vue-cli-service-custom-2.tgz
vue-cli-service-v3.0.0-rc.2.tgz
jest.config.js
19 changes: 0 additions & 19 deletions Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Build status: [![Build status](https://github.com/nklayman/vue-cli-plugin-electr

## Quick Start:

Open a terminal in the directory of your app created with Vue-CLI 3.
Open a terminal in the directory of your app created with Vue-CLI 3 or 4 (4 is recommended).

Then, install and invoke the generator of vue-cli-plugin-electron-builder by running:

Expand Down Expand Up @@ -43,7 +43,7 @@ To see more documentation, [visit our website](https://nklayman.github.io/vue-cl
## Supporters

| [![Yves Hoppe](https://avatars1.githubusercontent.com/u/897638?s=64&v=4)](https://github.com/yvesh) | [![Andrew LeTourneau](https://avatars2.githubusercontent.com/u/2807807?s=64&v=4)](https://github.com/centerorbit) | [![Mitch Dennet](https://avatars2.githubusercontent.com/u/16268619?s=64&v=4)](https://github.com/mitchdennett) | [![Kasen IO](https://avatars0.githubusercontent.com/u/52365539?s=64)](https://kasen.io) | [![Ivorzk](https://avatars2.githubusercontent.com/u/7390138?s=64)](https://github.com/Ivorzk) | [![Eric Schirtzinger](https://avatars2.githubusercontent.com/u/24927782?s=64)](https://github.com/eschirtz) | [![Alec Armbruster](https://avatars2.githubusercontent.com/u/35377827?s=64)](https://github.com/alectrocute) |
| --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| [Yves Hoppe](https://github.com/yvesh) | [Andrew LeTourneau](https://github.com/centerorbit) | [Mitch Dennet](https://github.com/mitchdennett) | [Kasen IO](https://kasen.io) | [Ivorzk](https://github.com/Ivorzk) | [Eric Schirtzinger](https://github.com/eschirtz) | [Alec Armbruster](https://github.com/alectrocute) |

## Past Supporters
Expand Down
1 change: 0 additions & 1 deletion UPGRADING.md

This file was deleted.

138 changes: 68 additions & 70 deletions __tests__/build.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,79 @@ const portfinder = require('portfinder')
const checkLogs = require('./checkLogs.helper.js')

portfinder.basePort = 9515
const runTests = useTS =>
new Promise(async resolve => {
const { project, projectName } = await create('build', useTS)
const runTests = async (useTS) => {
const { project, projectName } = await create('build', useTS)

const isWin = process.platform === 'win32'
const projectPath = p =>
path.join(process.cwd(), '__tests__/projects/' + projectName, p)
const isWin = process.platform === 'win32'
const projectPath = (p) =>
path.join(process.cwd(), '__tests__/projects/' + projectName, p)

await project.run('vue-cli-service electron:build --x64 --dir')
// Ensure /dist is not modified
expect(project.has('dist')).toBe(false)
// Ensure build successfully outputted files
expect(project.has('dist_electron/bundled/index.html')).toBe(true)
expect(project.has('dist_electron/bundled/favicon.ico')).toBe(true)
expect(project.has('dist_electron/bundled/js')).toBe(true)
expect(project.has('dist_electron/bundled/css')).toBe(true)
expect(project.has('dist_electron/bundled/background.js')).toBe(true)
if (isWin) {
expect(project.has(`dist_electron/win-unpacked/${projectName}.exe`)).toBe(
true
)
} else {
expect(project.has(`dist_electron/linux-unpacked/${projectName}`)).toBe(
true
)
}
// Ensure that setup files were not created
expect(project.has(`dist_electron/${projectName} Setup 0.1.0.exe`)).toBe(
false
await project.run('vue-cli-service electron:build --x64 --dir')
// Ensure /dist is not modified
expect(project.has('dist')).toBe(false)
// Ensure build successfully outputted files
expect(project.has('dist_electron/bundled/index.html')).toBe(true)
expect(project.has('dist_electron/bundled/favicon.ico')).toBe(true)
expect(project.has('dist_electron/bundled/js')).toBe(true)
expect(project.has('dist_electron/bundled/css')).toBe(true)
expect(project.has('dist_electron/bundled/background.js')).toBe(true)
if (isWin) {
expect(project.has(`dist_electron/win-unpacked/${projectName}.exe`)).toBe(
true
)
expect(
project.has(`dist_electron/${projectName}-0.1.0-x86_64.AppImage`)
).toBe(false)
expect(project.has(`dist_electron/${projectName}_0.1.0_amd64`)).toBe(false)
// Launch app with spectron
const app = new Application({
path: `./__tests__/projects/${projectName}/dist_electron/${
isWin ? 'win' : 'linux'
}-unpacked/${projectName}${isWin ? '.exe' : ''}`,
// Make sure tests do not interfere with each other
port: await portfinder.getPortPromise(),
// Increase wait timeout for parallel testing
waitTimeout: 10000
})
await app.start()
const win = app.browserWindow
const client = app.client
await client.waitUntilWindowLoaded()
} else {
expect(project.has(`dist_electron/linux-unpacked/${projectName}`)).toBe(
true
)
}
// Ensure that setup files were not created
expect(project.has(`dist_electron/${projectName} Setup 0.1.0.exe`)).toBe(
false
)
expect(
project.has(`dist_electron/${projectName}-0.1.0-x86_64.AppImage`)
).toBe(false)
expect(project.has(`dist_electron/${projectName}_0.1.0_amd64`)).toBe(false)
// Launch app with spectron
const app = new Application({
path: `./__tests__/projects/${projectName}/dist_electron/${
isWin ? 'win' : 'linux'
}-unpacked/${projectName}${isWin ? '.exe' : ''}`,
// Make sure tests do not interfere with each other
port: await portfinder.getPortPromise(),
// Increase wait timeout for parallel testing
waitTimeout: 10000
})
await app.start()
const win = app.browserWindow
const client = app.client
await client.waitUntilWindowLoaded()

// Check that proper info was logged
await checkLogs({ client, projectName, projectPath, mode: 'build' })
// Check that proper info was logged
await checkLogs({ client, projectName, projectPath, mode: 'build' })

// Window was created
expect(await client.getWindowCount()).toBe(1)
// It is not minimized
expect(await win.isMinimized()).toBe(false)
// Dev tools is not open
expect(await win.isDevToolsOpened()).toBe(false)
// Window is visible
expect(await win.isVisible()).toBe(true)
// Size is correct
const { width, height } = await win.getBounds()
expect(width).toBeGreaterThan(0)
expect(height).toBeGreaterThan(0)
// Load was successful
expect(await app.webContents.isLoading()).toBe(false)
// App is loaded properly
expect(
(await client.getHTML('#app')).indexOf(
`Welcome to Your Vue.js ${useTS ? '+ TypeScript ' : ''}App`
)
).not.toBe(-1)
// Window was created
expect(await client.getWindowCount()).toBe(1)
// It is not minimized
expect(await win.isMinimized()).toBe(false)
// Dev tools is not open
expect(await win.isDevToolsOpened()).toBe(false)
// Window is visible
expect(await win.isVisible()).toBe(true)
// Size is correct
const { width, height } = await win.getBounds()
expect(width).toBeGreaterThan(0)
expect(height).toBeGreaterThan(0)
// Load was successful
expect(await app.webContents.isLoading()).toBe(false)
// App is loaded properly
expect(
(await client.getHTML('#app')).indexOf(
`Welcome to Your Vue.js ${useTS ? '+ TypeScript ' : ''}App`
)
).not.toBe(-1)

await app.stop()
resolve()
})
await app.stop()
}

module.exports.runTests = runTests
38 changes: 19 additions & 19 deletions __tests__/checkLogs.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,38 @@ module.exports = async ({ client, projectPath, projectName, mode }) => {
`dist_electron/${isWin ? 'win' : 'linux'}-unpacked/resources/app.asar`
)

await client.getRenderProcessLogs().then(logs => {
logs.forEach(log => {
// Make sure there are no fatal errors
await client.getRenderProcessLogs().then((logs) => {
logs.forEach((log) => {
// Make sure there are no fatal errors
expect(log.level).not.toBe('SEVERE')
})
let appBaseUrl = logs
// Find BASE_URL log
.find(v => v.message.indexOf('process.env.BASE_URL=') !== -1)
// Find BASE_URL log
.find((v) => v.message.indexOf('process.env.BASE_URL=') !== -1)
// Get just the value
.message.split('=')[1]
// Remove any quotes
appBaseUrl = appBaseUrl.replace('"', '')
// Base url should be root of server or packaged asar
// Base url should be root of server or packaged asar
expect(path.normalize(appBaseUrl)).toBe(
isBuild ? outputPath : path.sep /* Server root */
)

let appStatic = logs
// Find __static log
.find(v => v.message.indexOf('__static=') !== -1)
// Find __static log
.find((v) => v.message.indexOf('__static=') !== -1)
// Get just the value
.message.split('=')[1]
// Remove any quotes
appStatic = appStatic.replace('"', '')
// __static should point to public folder or packaged asar
// __static should point to public folder or packaged asar
expect(path.normalize(appStatic)).toBe(
isBuild ? outputPath : projectPath('public')
)

let vuePath = logs
// Find vuePath log
.find(v => v.message.indexOf('vuePath=') !== -1)
// Find vuePath log
.find((v) => v.message.indexOf('vuePath=') !== -1)
// Get just the value
.message.split('=')[1]
// Remove any quotes
Expand All @@ -51,8 +51,8 @@ module.exports = async ({ client, projectPath, projectName, mode }) => {
}

let mockExternalPath = logs
// Find externalModulePath log
.find(v => v.message.indexOf('mockExternalPath=') !== -1)
// Find externalModulePath log
.find((v) => v.message.indexOf('mockExternalPath=') !== -1)
// Get just the value
.message.split('=')[1]
// Remove any quotes
Expand All @@ -63,22 +63,22 @@ module.exports = async ({ client, projectPath, projectName, mode }) => {
}
})

await client.getMainProcessLogs().then(logs => {
await client.getMainProcessLogs().then((logs) => {
let appStatic = logs
// Find __static log
.find(m => m.indexOf('__static=') !== -1)
// Find __static log
.find((m) => m.indexOf('__static=') !== -1)
// Get just the value
.split('=')[1]
// Remove any quotes
appStatic = appStatic.replace('"', '').split(',')[0]
// __static should point to public folder or packaged asar
// __static should point to public folder or packaged asar
expect(path.normalize(appStatic)).toBe(
isBuild ? outputPath : projectPath('public')
)

let mockExternalPath = logs
// Find externalModulePath log
.find(v => v.indexOf('mockExternalPath=') !== -1)
// Find externalModulePath log
.find((v) => v.indexOf('mockExternalPath=') !== -1)
// Get just the value
.split('=')[1]
// Remove any quotes
Expand Down
Loading

0 comments on commit 31d27e9

Please sign in to comment.