diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..db57776 --- /dev/null +++ b/.babelrc @@ -0,0 +1,16 @@ +{ + "presets": [ + [ + "latest", { + "es2015": { + "modules": false + } + } + ], + "react", + "stage-0" + ], + "plugins": [ + "react-hot-loader/babel" + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..22f869e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b9ea64 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +out +dist +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + + +#IDE +.idea diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..12445f6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Kenny Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b1b06fe --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Awesome Mac App + +[![](./icns/logo.svg)](https://github.com/jaywcjlove/amac) + +## Screenshots + +![](./icns/app.png) + +## Development + +To develop, run the self-reloading build: + +Get the code + +```bash +$ git clone https://github.com/jaywcjlove/amac.git +$ cd amac +$ npm install # or yarn install +``` + +To develop, run the self-reloading build: + +```bash +# Run the app +$ npm run app + +# Restart the app automatically every time code changes. +# Useful during development. +$ npm run dev +$ npm run app:dev +``` + +`npm run dev` will live-reload the frontend so you don't need to refresh. If you change main.js however, you'll have to restart electron to reload your changes. + +## Package the app + +Builds app binaries for Mac. + +```bash +$ npm run package +``` + +## License + +Licensed under the [MIT](./LICENSE) License. \ No newline at end of file diff --git a/build/pack b/build/pack new file mode 100755 index 0000000..b135e62 --- /dev/null +++ b/build/pack @@ -0,0 +1,33 @@ +#!/usr/bin/env node +const packager = require('electron-packager') +const path = require('path') +const pkg = require('../package') + +// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md +packager({ + dir: path.join(__dirname, '..'), + appCopyright: '© 2017, kenny wang', + asar: true, + overwrite: true, + electronVersion: pkg.electronVersion, + icon: path.join(__dirname, '..', 'icns', 'icon'), + out: path.join(__dirname, '..', 'out'), + ignore:true, + platform: 'mas', + appBundleId: `wang.kenny.${pkg.name}`, + appCategoryType: 'public.app-category.developer-tools', + osxSign: { + type: process.env.NODE_ENV === 'production' ? 'distribution' : 'development', + entitlements: path.join(__dirname, '..', 'parent.plist'), + 'entitlements-inherit': path.join(__dirname, '..', 'child.plist') + } +},function (err, res) { + if (err) { + console.log(err) + process.exit(0); + return ; + // throw err; + } + + const app = path.join(res[0], `${pkg.productName}.app`) +}) diff --git a/build/webpack.config.js b/build/webpack.config.js new file mode 100644 index 0000000..9d64114 --- /dev/null +++ b/build/webpack.config.js @@ -0,0 +1,118 @@ +const webpack = require('webpack') +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const path = require('path') + + +const extractCSS = new ExtractTextPlugin('css/[contenthash].css') +const extractLESS = new ExtractTextPlugin('css/[contenthash].css') + +module.exports = { + entry: { + 'app': [ + 'babel-polyfill', + 'react-hot-loader/patch', + 'webpack/hot/only-dev-server', + './src/index' + ] + }, + output: { + path: path.resolve(process.cwd(), './dist'), + filename: '[name].js', + publicPath: '/' + }, + module: { + rules: [ + { + exclude: [ + /\.html$/, + // We have to write /\.(js|jsx)(\?.*)?$/ rather than just /\.(js|jsx)$/ + // because you might change the hot reloading server from the custom one + // to Webpack's built-in webpack-dev-server/client?/, which would not + // get properly excluded by /\.(js|jsx)$/ because of the query string. + // Webpack 2 fixes this, but for now we include this hack. + // https://github.com/facebookincubator/create-react-app/issues/1713 + /\.(js|jsx)(\?.*)?$/, + /\.css$/, + /\.less$/, + /\.json$/, + /\.svg$/, + /\.png$/, + /\.(jpe?g)$/, + ], + use:[{ + loader: 'file-loader', + query: { + name: '[name].[ext]' + } + }] + }, + { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, + { + test: /\.(css|less)$/, + exclude: /node_modules/, + use: [ + 'style-loader', + { + loader: 'css-loader', + options: { + minimize: true, + importLoaders: 2, + sourceMap: true + }, + }, + 'less-loader', + ] + }, + + // { + // test: /\.less$/, + // use: extractLESS.extract({ + // use:[ + // { + // loader:'css-loader', + // options: { + // // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader + // importLoaders: 1 + // } + // }, + // 'less-loader' + // ] + // }), + // }, + { + // "css-loader" 可以解析CSS中的路径,并添加资源作为依赖关系。 + // "style-loader" 将CSS转换为注入