-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
498 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
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,8 @@ | ||
{ | ||
"rules": { | ||
"no-console": "off", | ||
"global-require": "off", | ||
"import/no-dynamic-require": "off", | ||
"import/no-extraneous-dependencies": "off" | ||
} | ||
} |
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,30 @@ | ||
// Check if the renderer and main bundles are built | ||
import path from 'path'; | ||
import chalk from 'chalk'; | ||
import fs from 'fs'; | ||
|
||
const mainPath = path.join(__dirname, '..', '..', 'app', 'main.prod.js'); | ||
const rendererPath = path.join( | ||
__dirname, | ||
'..', | ||
'..', | ||
'app', | ||
'dist', | ||
'renderer.prod.js' | ||
); | ||
|
||
if (!fs.existsSync(mainPath)) { | ||
throw new Error( | ||
chalk.whiteBright.bgRed.bold( | ||
'The main process is not built yet. Build it by running "yarn build-main"' | ||
) | ||
); | ||
} | ||
|
||
if (!fs.existsSync(rendererPath)) { | ||
throw new Error( | ||
chalk.whiteBright.bgRed.bold( | ||
'The renderer process is not built yet. Build it by running "yarn build-renderer"' | ||
) | ||
); | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,49 @@ | ||
// @flow | ||
import fs from 'fs'; | ||
import chalk from 'chalk'; | ||
import { execSync } from 'child_process'; | ||
import { dependencies } from '../../package.json'; | ||
|
||
(() => { | ||
if (!dependencies) return; | ||
|
||
if (dependencies) { | ||
const dependenciesKeys = Object.keys(dependencies); | ||
const nativeDeps = fs | ||
.readdirSync('node_modules') | ||
.filter((folder) => fs.existsSync(`node_modules/${folder}/binding.gyp`)); | ||
|
||
.filter(folder => fs.existsSync(`node_modules/${folder}/binding.gyp`)); | ||
try { | ||
// Find the reason for why the dependency is installed. If it is installed | ||
// because of a devDependency then that is okay. Warn when it is installed | ||
// because of a dependency | ||
const dependenciesObject = JSON.parse( | ||
const { dependencies: dependenciesObject } = JSON.parse( | ||
execSync(`npm ls ${nativeDeps.join(' ')} --json`).toString() | ||
); | ||
const rootDependencies = Object.keys(dependenciesObject.dependencies); | ||
const filteredRootDependencies = rootDependencies.filter((rootDependency) => | ||
const rootDependencies = Object.keys(dependenciesObject); | ||
const filteredRootDependencies = rootDependencies.filter(rootDependency => | ||
dependenciesKeys.includes(rootDependency) | ||
); | ||
|
||
if (filteredRootDependencies.length > 0) { | ||
const plural = filteredRootDependencies.length > 1; | ||
console.log(` | ||
${chalk.whiteBright.bgYellow.bold('Webpack does not work with native dependencies.')} | ||
${chalk.whiteBright.bgYellow.bold( | ||
'Webpack does not work with native dependencies.' | ||
)} | ||
${chalk.bold(filteredRootDependencies.join(', '))} ${ | ||
plural ? 'are native dependencies' : 'is a native dependency' | ||
} and should be installed inside of the "./app" folder. | ||
First uninstall the packages from "./package.json": | ||
${chalk.whiteBright.bgGreen.bold('npm uninstall your-package')} | ||
${chalk.bold('Then, instead of installing the package to the root "./package.json":')} | ||
${chalk.whiteBright.bgRed.bold('npm install your-package --save')} | ||
${chalk.bold('Install the package to "./app/package.json"')} | ||
${chalk.whiteBright.bgGreen.bold('cd ./app && npm install your-package --save')} | ||
Read more about native dependencies at: | ||
First, uninstall the packages from "./package.json": | ||
${chalk.whiteBright.bgGreen.bold('yarn remove your-package')} | ||
${chalk.bold( | ||
'Then, instead of installing the package to the root "./package.json":' | ||
)} | ||
${chalk.whiteBright.bgRed.bold('yarn add your-package')} | ||
${chalk.bold('Install the package to "./app/package.json"')} | ||
${chalk.whiteBright.bgGreen.bold('cd ./app && yarn add your-package')} | ||
Read more about native dependencies at: | ||
${chalk.bold( | ||
'https://github.com/chentsulin/electron-react-boilerplate/wiki/Module-Structure----Two-package.json-Structure' | ||
'https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure' | ||
)} | ||
`); | ||
|
||
`); | ||
process.exit(1); | ||
} | ||
} catch (e) { | ||
console.log('Native dependencies could not be checked'); | ||
} | ||
})(); | ||
} |
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 |
---|---|---|
@@ -1,19 +1,16 @@ | ||
// @flow | ||
import chalk from 'chalk'; | ||
import detectPort from 'detect-port'; | ||
|
||
(function CheckPortInUse() { | ||
const port: string = process.env.PORT || '1212'; | ||
const port = process.env.PORT || '1212'; | ||
|
||
detectPort(port, (err: ?Error, availablePort: number) => { | ||
if (port !== String(availablePort)) { | ||
throw new Error( | ||
chalk.whiteBright.bgRed.bold( | ||
`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm run dev` | ||
) | ||
); | ||
} else { | ||
process.exit(0); | ||
} | ||
}); | ||
})(); | ||
detectPort(port, (err, availablePort) => { | ||
if (port !== String(availablePort)) { | ||
throw new Error( | ||
chalk.whiteBright.bgRed.bold( | ||
`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 yarn dev` | ||
) | ||
); | ||
} else { | ||
process.exit(0); | ||
} | ||
}); |
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 @@ | ||
if (!/yarn\.js$/.test(process.env.npm_execpath || '')) { | ||
console.warn( | ||
"\u001b[33mYou don't seem to be using yarn. This could produce unexpected results.\u001b[39m" | ||
); | ||
} |
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,7 @@ | ||
import path from 'path'; | ||
import rimraf from 'rimraf'; | ||
|
||
export default function deleteSourceMaps() { | ||
rimraf.sync(path.join(__dirname, '../../app/dist/*.js.map')); | ||
rimraf.sync(path.join(__dirname, '../../app/*.js.map')); | ||
} |
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 |
---|---|---|
@@ -1,19 +1,22 @@ | ||
// @flow | ||
import path from 'path'; | ||
import { execSync } from 'child_process'; | ||
import fs from 'fs'; | ||
import dependencies from '../../app/package.json'; | ||
import { dependencies } from '../../app/package.json'; | ||
|
||
const nodeModulesPath = path.join(__dirname, '..', '..', 'app', 'node_modules'); | ||
|
||
if (Object.keys(dependencies || {}).length > 0 && fs.existsSync(nodeModulesPath)) { | ||
if ( | ||
Object.keys(dependencies || {}).length > 0 && | ||
fs.existsSync(nodeModulesPath) | ||
) { | ||
const electronRebuildCmd = | ||
'../node_modules/.bin/electron-rebuild --parallel --force --types prod,dev,optional --module-dir .'; | ||
|
||
const cmd = | ||
process.platform === 'win32' ? electronRebuildCmd.replace(/\//g, '\\') : electronRebuildCmd; | ||
|
||
process.platform === 'win32' | ||
? electronRebuildCmd.replace(/\//g, '\\') | ||
: electronRebuildCmd; | ||
execSync(cmd, { | ||
cwd: path.join(__dirname, '..', '..', 'app'), | ||
stdio: 'inherit' | ||
}); | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "plugin:testcafe/recommended", | ||
"env": { | ||
"jest/globals": true | ||
}, | ||
"plugins": ["jest", "testcafe"], | ||
"rules": { | ||
"jest/no-disabled-tests": "warn", | ||
"jest/no-focused-tests": "error", | ||
"jest/no-identical-title": "error", | ||
"no-console": "off" | ||
} | ||
} |
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,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`actions should decrement should create decrement action 1`] = ` | ||
Object { | ||
"type": "DECREMENT_COUNTER", | ||
} | ||
`; | ||
|
||
exports[`actions should increment should create increment action 1`] = ` | ||
Object { | ||
"type": "INCREMENT_COUNTER", | ||
} | ||
`; |
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,45 @@ | ||
import { spy } from 'sinon'; | ||
import * as actions from '../../app/actions/counter'; | ||
|
||
describe('actions', () => { | ||
it('should increment should create increment action', () => { | ||
expect(actions.increment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should decrement should create decrement action', () => { | ||
expect(actions.decrement()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should incrementIfOdd should create increment action', () => { | ||
const fn = actions.incrementIfOdd(); | ||
expect(fn).toBeInstanceOf(Function); | ||
const dispatch = spy(); | ||
const getState = () => ({ counter: 1 }); | ||
fn(dispatch, getState); | ||
expect(dispatch.calledWith({ type: actions.INCREMENT_COUNTER })).toBe(true); | ||
}); | ||
|
||
it('should incrementIfOdd shouldnt create increment action if counter is even', () => { | ||
const fn = actions.incrementIfOdd(); | ||
const dispatch = spy(); | ||
const getState = () => ({ counter: 2 }); | ||
fn(dispatch, getState); | ||
expect(dispatch.called).toBe(false); | ||
}); | ||
|
||
// There's no nice way to test this at the moment... | ||
it('should incrementAsync', () => { | ||
return new Promise(resolve => { | ||
const fn = actions.incrementAsync(1); | ||
expect(fn).toBeInstanceOf(Function); | ||
const dispatch = spy(); | ||
fn(dispatch); | ||
setTimeout(() => { | ||
expect(dispatch.calledWith({ type: actions.INCREMENT_COUNTER })).toBe( | ||
true | ||
); | ||
resolve(); | ||
}, 5); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.