MVP build process

This commit is contained in:
Gregory Schier 2016-04-19 23:09:46 -07:00
parent 71e4d1658e
commit 3378a03e0c
11 changed files with 85 additions and 36 deletions

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
node_modules
.idea
dist
dist/*
builds/*
npm-debug.log
*.db*

View File

@ -6,6 +6,7 @@
</head>
<body>
<div id="root"></div>
<script src="./node_modules/pouchdb/dist/pouchdb.js"></script>
<script>
(function () {
const script = document.createElement('script');

View File

@ -1,6 +1,7 @@
'use strict';
// Don't npm install this (it breaks). Rely on the global one.
import electron from 'electron';
const electron = require('electron');
const app = electron.app; // Module to control application life.
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
@ -26,7 +27,7 @@ app.on('ready', () => {
});
// and load the app.html of the app.
mainWindow.loadURL(`file://${__dirname}/app/app.html`);
mainWindow.loadURL(`file://${__dirname}/app.html`);
// Open the DevTools.
// if (IS_DEV) {

View File

@ -1,12 +1,15 @@
import PouchDB from 'pouchdb';
// import PouchDB from 'pouchdb';
import * as methods from '../constants/global';
import {generateId} from './util'
import pouchDBFind from 'pouchdb-find'
// Add plugins
// We have to include the web version of PouchDB in app.html because
// the NodeJS version defaults to LevelDB which is hard (impossible?)
// to get working in Electron apps
PouchDB.plugin(pouchDBFind);
let db = new PouchDB('insomnia.db');
let db = new PouchDB('insomnia.db', {adapter: 'websql'});
// For browser console debugging
global.db = db;

View File

@ -71,3 +71,4 @@ render(
<Provider store={store}><App /></Provider>,
document.getElementById('root')
);

15
app/package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "insomnia",
"productName": "Insomnia REST Client",
"description": "The best REST API Client",
"homepage": "http://insomnia.rest",
"licence": "MIT",
"version": "3.0.0",
"main": "app.js",
"dependencies": {
"nunjucks": "^1.3.4",
"pouchdb": "^5.3.1",
"pouchdb-find": "^0.9.0",
"request": "^2.71.0"
}
}

View File

@ -12,17 +12,13 @@
"classnames": "^2.2.3",
"codemirror": "^5.12.0",
"jsonschema": "^1.1.0",
"nunjucks": "^1.3.4",
"pouchdb": "^5.3.1",
"pouchdb-find": "^0.9.0",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-redux": "^4.4.1",
"react-tabs": "^0.5.3",
"redux": "^3.3.1",
"redux-logger": "^2.6.1",
"redux-thunk": "^2.0.1",
"request": "^2.71.0"
"redux-thunk": "^2.0.1"
},
"devDependencies": {
"babel-core": "^6.7.2",
@ -36,11 +32,16 @@
"babel-preset-react-hmre": "^1.1.1",
"concurrently": "^2.0.0",
"css-loader": "^0.23.1",
"del": "^2.2.0",
"electron-builder": "^3.6.1",
"electron-packager": "^7.0.0",
"electron-prebuilt": "^0.37.6",
"express": "latest",
"file-loader": "^0.8.5",
"jest": "^0.1.40",
"jest-cli": "^0.9.2",
"json-loader": "^0.5.4",
"minimist": "latest",
"node-sass": "^3.4.2",
"react-addons-test-utils": "^0.14.7",
"react-hot-loader": "^1.3.0",
@ -54,13 +55,20 @@
"webpack-hot-middleware": "^2.10.0",
"webpack-target-electron-renderer": "^0.4.0"
},
"build": {
"app-bundle-id": "rest.insomnia.app",
"app-category-type": "public.app-category.productivity",
"iconUrl": "(windows only)"
},
"scripts": {
"start-hot": "HOT=1 NODE_ENV=development electron -r babel-register ./electron.js",
"start-hot": "HOT=1 NODE_ENV=development electron -r babel-register ./app/app.js",
"hot-server": "node -r babel-register ./webpack/server.js",
"dev": "concurrently --kill-others \"npm run hot-server\" \"npm run start-hot\"",
"test": "jest $@",
"package": "./scripts/package"
},
"package": "./scripts/package",
"package-all": "npm run package -- --all",
"postinstall": "cd node_modules/leveldown && HOME=~/.electron-gyp node-gyp rebuild --target=0.36.10 --arch=x64 --dist-url=https://atom.io/download/atom-shell"
},
"jest": {
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/redux-thunk",

View File

@ -2,8 +2,17 @@
#? Package the app
rm -r dist/*
webpack --config webpack/webpack.config.production.js
# cp -r node_modules electron.js package.json dist/
cp electron.js package.json dist/
cd dist
NODE_ENV=production npm install
NODE_ENV=production node -r babel-register ./node_modules/.bin/webpack --config ./webpack/webpack.config.production.js
cp app/package.json app/app.js dist/
cp -r app/node_modules dist/
# cd dist/; NODE_ENV=production npm install; cd ..
node -r babel-register node_modules/electron-packager/cli.js \
dist \
Insomnia \
--platform=darwin \
--arch=x64 \
--out=builds \
--overwrite

11
scripts/package.js Normal file
View File

@ -0,0 +1,11 @@
import packager from 'electron-packager'
const options = {
arch: 'x64',
platform: 'darwin',
dir: './dist'
};
packager(options, (err, appPaths) => {
console.log(err, appPaths);
});

View File

@ -59,14 +59,10 @@ export default {
extensions: ['', '.js', '.json', '.jsx'],
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main']
},
plugins: [
new webpack.ExternalsPlugin('commonjs', [
'request',
'nunjucks',
'pouchdb',
'pouchdb-find'
])
externals: [
'request'
],
plugins: [],
target: 'electron-renderer'
};

View File

@ -1,12 +1,15 @@
import * as base from './webpack.config.base'
import webpack from 'webpack'
import baseConfig from './webpack.config.base'
base.plugins = base.plugins.concat([
new webpack.DefinePlugin({
__DEV__: false,
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
]);
module.exports = base;
export default {
...baseConfig,
plugins: [
...baseConfig.plugins,
new webpack.DefinePlugin({
__DEV__: false,
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
]
}