Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make compact config and script #172

Merged
merged 8 commits into from
Apr 18, 2019
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
26 changes: 0 additions & 26 deletions .babelrc

This file was deleted.

5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

46 changes: 0 additions & 46 deletions CODE_OF_CONDUCT.md

This file was deleted.

18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ This project use [yarn](https://yarnpkg.com/lang/en/) for package manager.
git clone https://github.com/AhKi/oh-my-desk.git
cd oh-my-desk
```
**Download Dependency**
```
yarn
```

**Start Project**

```
yarn && yarn start
yarn start
```

**Show Unit test coverage**

**Unit test**
```
yarn && yarn test
yarn test
yarn show:coverage // if you want to show coverage
```

**Build**

**Packaging(Make install file)**
```
yarn && yarn package
yarn package
```

## Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('test WebWidget', () => {
it('match times handling event', () => {
configureLoader();

expect(addEventListener).toHaveBeenCalledTimes(2);
expect(addEventListener).toHaveBeenCalledTimes(3);
});

describe('match each handled event ', () => {
Expand Down Expand Up @@ -180,6 +180,18 @@ describe('test WebWidget', () => {
});
break;
}
case 'page-title-updated': {
it('when page title is updated', () => {
wrapper.instance().setState = setState;

mock[1]({ title: 'mock-title' });

expect(setState).toHaveBeenNthCalledWith(1, {
title: 'mock-title',
});
});
break;
}
default: {
throw new Error('Need to add new test case');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ exports[`test WebWidget should match to snapshot when default render 1`] = `
<div
className="WebWidget"
>
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<SideEffect(NullComponent)
defer={true}
encodeSpecialCharacters={true}
title=""
titleAttributes={Object {}}
>
<NullComponent
defer={true}
encodeSpecialCharacters={true}
title=""
titleAttributes={Object {}}
/>
</SideEffect(NullComponent)>
</HelmetWrapper>
<Connect(toJS(WidgetHeader))
currentUrl=""
isLoading={false}
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions config/babel/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { APP_PATH } = require('../path');

module.exports = {
presets: ['@babel/env', '@babel/react'],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
['module-resolver', {
root: [APP_PATH],
alias: {
actions: `${APP_PATH}/actions`,
assets: `${APP_PATH}/assets`,
config: `${APP_PATH}/config`,
constants: `${APP_PATH}/constants`,
components: `${APP_PATH}/components`,
main: `${APP_PATH}/main`,
renderer: `${APP_PATH}/renderer`,
process: `${APP_PATH}/process`,
setting: `${APP_PATH}/renderer/pages/setting`,
widget: `${APP_PATH}/renderer/pages/widget`,
scss: `${APP_PATH}/renderer/scss`,
utils: `${APP_PATH}/utils`,
store: `${APP_PATH}/store`,
},
extensions: ['.js', '.jsx'],
}],
],
};
3 changes: 3 additions & 0 deletions config/babel/babel.jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = require('babel-jest').createTransformer(
require('./babel.config.js'),
);
5 changes: 5 additions & 0 deletions config/babel/babel.register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { CONFIG_PATH } = require('../path');

require('@babel/register')({
configFile: `${CONFIG_PATH}/babel/babel.config.js`,
});
File renamed without changes.
4 changes: 4 additions & 0 deletions config/enzyme.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { configure } = require('enzyme/build');
const Adapter = require('enzyme-adapter-react-16/build');

configure({ adapter: new Adapter() });
10 changes: 7 additions & 3 deletions jest.config.js → config/jest/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
collectCoverageFrom: [
'app/**/*.{js,jsx}',
'<rootDir>/app/**/*.{js,jsx}',
],
moduleNameMapper: {
'\\.(css|scss)$': '<rootDir>/app/__mocks__/styleMock.js',
Expand All @@ -18,10 +18,14 @@ module.exports = {
'^widget(.*)$': '<rootDir>/app/renderer/pages/widget$1',
'^utils(.*)$': '<rootDir>/app/utils$1',
},
transform: {
'^.+\\.jsx?$': '<rootDir>/config/babel/babel.jest.js',
},
rootDir: '../../',
globals: {
__dirname: '/Users/user-name/project/oh-my-desk/app',
__dirname: '<rootDir>',
},
setupTestFrameworkScriptFile: '<rootDir>/enzyme.config.js',
setupTestFrameworkScriptFile: '<rootDir>/config/enzyme.config.js',
snapshotSerializers: [
'enzyme-to-json/serializer',
],
Expand Down
1 change: 1 addition & 0 deletions jest.e2e.config.js → config/jest/jest.e2e.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
'^widget(.*)$': '<rootDir>/app/renderer/pages/widget$1',
'^utils(.*)$': '<rootDir>/app/utils$1',
},
rootDir: '../../',
globals: {
__dirname: '/Users/user-name/project/oh-my-desk/app',
},
Expand Down
6 changes: 6 additions & 0 deletions config/lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
linters: {
'**/*.{js,jsx}': 'eslint',
},
ignore: ['**/*.config.js'],
};
11 changes: 11 additions & 0 deletions config/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

const ROOT_PATH = path.join(__dirname, '..');

module.exports = {
ROOT_PATH,
APP_PATH: path.join(ROOT_PATH, 'app'),
BUILD_PATH: path.join(ROOT_PATH, 'build'),
CONFIG_PATH: path.join(ROOT_PATH, 'config'),
TEST_PATH: path.join(ROOT_PATH, 'test'),
};
59 changes: 33 additions & 26 deletions webpack.basic.config.js → config/webpack/webpack.basic.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { APP_PATH, ROOT_PATH, CONFIG_PATH } = require('../path');

module.exports = {
entry: {
widget: './app/renderer/pages/widget/index.jsx',
preloadScript: './app/renderer/pages/widget/preloadScript.js',
preference: './app/renderer/pages/preference/index.jsx',
search: './app/renderer/pages/search/index.jsx',
widget: path.join(APP_PATH, 'renderer/pages/widget/index.jsx'),
preloadScript: path.join(APP_PATH, 'renderer/pages/widget/preloadScript.js'),
preference: path.join(APP_PATH, 'renderer/pages/preference/index.jsx'),
search: path.join(APP_PATH, 'renderer/pages/search/index.jsx'),
},
target: 'electron-renderer',
module: {
Expand All @@ -16,14 +17,22 @@ module.exports = {
{
test: /\.jsx?$/,
include: [
path.join(__dirname, '/app'),
APP_PATH,
],
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
configFile: path.join(CONFIG_PATH, 'babel/babel.config.js'),
},
},
{
loader: 'eslint-loader',
options: {
configFile: path.join(CONFIG_PATH, '.eslintrc'),
},
},
'eslint-loader',
]
},
{
Expand All @@ -37,7 +46,7 @@ module.exports = {
loader: 'sass-resources-loader',
options: {
resources: [
path.join(__dirname, 'app/renderer/scss', '**/_*.scss'),
path.join(APP_PATH, 'renderer/scss', '**/_*.scss'),
],
},
}
Expand All @@ -48,7 +57,7 @@ module.exports = {
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
publicPath: process.env.NODE_ENV === 'development' ? path.join(__dirname) : undefined,
publicPath: process.env.NODE_ENV === 'development' ? ROOT_PATH : undefined,
outputPath: process.env.NODE_ENV === 'development' ? '/' : undefined,
},
},
Expand All @@ -63,45 +72,43 @@ module.exports = {
new HtmlWebpackPlugin({
chunks: ['widget'],
filename: 'widget.html',
template: path.join(__dirname, './app/renderer/pages/widget/widget.html'),
template: path.join(APP_PATH, 'renderer/pages/widget/widget.html'),
inject: 'body',
}),
new HtmlWebpackPlugin({
chunks: ['preference'],
filename: 'preference.html',
template: path.join(__dirname, './app/renderer/pages/preference/preference.html'),
template: path.join(APP_PATH, 'renderer/pages/preference/preference.html'),
inject: 'body',
}),
new HtmlWebpackPlugin({
chunks: ['search'],
filename: 'search.html',
template: path.join(__dirname, './app/renderer/pages/search/search.html'),
template: path.join(APP_PATH, 'renderer/pages/search/search.html'),
inject: 'body',
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
IS_DEVTOOLS: JSON.stringify(process.env.IS_DEVTOOLS),
},
'__DEV__': process.env.NODE_ENV === 'development',
'__PROD__': process.env.NODE_ENV === 'production',
}),
],
resolve: {
alias: {
actions: path.resolve(__dirname, 'app/actions'),
assets: path.resolve(__dirname, 'app/assets'),
config: path.resolve(__dirname, 'app/config.js'),
constants: path.resolve(__dirname, 'app/constants'),
components: path.resolve(__dirname, 'app/components'),
main: path.resolve(__dirname, 'app/main'),
renderer: path.resolve(__dirname, 'app/renderer'),
process: path.resolve(__dirname, 'app/process'),
setting: path.resolve(__dirname, 'app/renderer/pages/setting'),
widget: path.resolve(__dirname, 'app/renderer/pages/widget'),
scss: path.resolve(__dirname, 'app/renderer/scss'),
utils: path.resolve(__dirname, 'app/utils'),
store: path.resolve(__dirname, 'app/store'),
actions: `${APP_PATH}/actions`,
assets: `${APP_PATH}/assets`,
config: `${APP_PATH}/config`,
constants: `${APP_PATH}/constants`,
components: `${APP_PATH}/components`,
main: `${APP_PATH}/main`,
renderer: `${APP_PATH}/renderer`,
process: `${APP_PATH}/process`,
setting: `${APP_PATH}/setting`,
widget: `${APP_PATH}/pages/widget`,
scss: `${APP_PATH}/renderer/scss`,
utils: `${APP_PATH}/utils`,
store: `${APP_PATH}/store`,
},
extensions: ['.js', '.jsx'],
},
Expand Down
Loading