mirror of
https://github.com/netzbegruenung/Rocket.Chat.Electron.git
synced 2024-05-05 15:33:40 +02:00
Env config added
This commit is contained in:
parent
a1ccc2e37c
commit
5301ed168f
|
@ -5,6 +5,7 @@
|
|||
|
||||
<link href="./stylesheets/main.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<script src="vendor/electron_boilerplate/env_config.js"></script>
|
||||
<script src="vendor/electron_boilerplate/context_menu.js"></script>
|
||||
<script src="vendor/electron_boilerplate/external_links.js"></script>
|
||||
|
||||
|
@ -21,6 +22,9 @@
|
|||
<p class="subtitle">
|
||||
Welcome to <a href="http://electron.atom.io" class="js-external-link">Electron</a> app running on this magnificent <strong id="platform-info"></strong> machine.
|
||||
</p>
|
||||
<p class="subtitle">
|
||||
You are in <strong id="env-name"></strong> environment.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -9,8 +9,9 @@ import { greet } from './hello_world/hello_world';
|
|||
// Node modules are required the same way as always.
|
||||
var os = require('os');
|
||||
|
||||
var greetElement = document.getElementById('greet');
|
||||
greetElement.innerHTML = greet();
|
||||
// window.env contains data from config/env_XXX.json file.
|
||||
var envName = window.env.name;
|
||||
|
||||
var platform = document.getElementById('platform-info');
|
||||
platform.innerHTML = os.platform();
|
||||
document.getElementById('greet').innerHTML = greet();
|
||||
document.getElementById('platform-info').innerHTML = os.platform();
|
||||
document.getElementById('env-name').innerHTML = envName;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
var app = require('app');
|
||||
var BrowserWindow = require('browser-window');
|
||||
var env = require('./vendor/electron_boilerplate/env_config');
|
||||
var windowStateKeeper = require('./vendor/electron_boilerplate/window_state');
|
||||
|
||||
var mainWindow;
|
||||
|
@ -12,6 +13,9 @@ var mainWindowState = windowStateKeeper('main', {
|
|||
height: 600
|
||||
});
|
||||
|
||||
// You have data from config/env_XXX.json file loaded here in case you need it.
|
||||
// console.log(env.name);
|
||||
|
||||
app.on('ready', function () {
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
|
|
15
app/vendor/electron_boilerplate/env_config.js
vendored
Normal file
15
app/vendor/electron_boilerplate/env_config.js
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Loads config/env_XXX.json file and puts it
|
||||
// in proper place for given Electron context.
|
||||
|
||||
'use strict';
|
||||
|
||||
(function () {
|
||||
var jetpack = require('fs-jetpack');
|
||||
if (typeof window === 'object') {
|
||||
// Web browser context, __dirname points to folder where app.html file is.
|
||||
window.env = jetpack.read(__dirname + '/env_config.json', 'json');
|
||||
} else {
|
||||
// Node context
|
||||
module.exports = jetpack.read(__dirname + '/../../env_config.json', 'json');
|
||||
}
|
||||
}());
|
4
config/env_development.json
Normal file
4
config/env_development.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "development",
|
||||
"description": "Add here any environment specific stuff you like."
|
||||
}
|
4
config/env_production.json
Normal file
4
config/env_production.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "production",
|
||||
"description": "Add here any environment specific stuff you like."
|
||||
}
|
4
config/env_test.json
Normal file
4
config/env_test.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "test",
|
||||
"description": "Add here any environment specific stuff you like."
|
||||
}
|
|
@ -16,8 +16,8 @@
|
|||
"scripts": {
|
||||
"postinstall": "cd ./app && npm install",
|
||||
"build": "./node_modules/.bin/gulp build",
|
||||
"release": "./node_modules/.bin/gulp release --target=release",
|
||||
"release": "./node_modules/.bin/gulp release --env=production",
|
||||
"start": "node ./tasks/start",
|
||||
"test": "node ./tasks/start --target=test"
|
||||
"test": "node ./tasks/start --env=test"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,10 +71,9 @@ gulp.task('less', ['clean'], lessTask);
|
|||
gulp.task('less-watch', lessTask);
|
||||
|
||||
|
||||
// Add and customize OS-specyfic and target-specyfic stuff.
|
||||
gulp.task('finalize', ['clean'], function () {
|
||||
var manifest = srcDir.read('package.json', 'json');
|
||||
switch (utils.getBuildTarget()) {
|
||||
switch (utils.getEnvName()) {
|
||||
case 'development':
|
||||
// Add "dev" suffix to name, so Electron will write all
|
||||
// data like cookies and localStorage into separate place.
|
||||
|
@ -91,6 +90,9 @@ gulp.task('finalize', ['clean'], function () {
|
|||
break;
|
||||
}
|
||||
destDir.write('package.json', manifest);
|
||||
|
||||
var configFilePath = projectDir.path('config/env_' + utils.getEnvName() + '.json');
|
||||
destDir.copy(configFilePath, 'env_config.json');
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var runBuild = function () {
|
|||
|
||||
var build = childProcess.spawn(gulpPath, [
|
||||
'build',
|
||||
'--target=' + utils.getBuildTarget(),
|
||||
'--env=' + utils.getEnvName(),
|
||||
'--color'
|
||||
]);
|
||||
|
||||
|
@ -33,7 +33,7 @@ var runBuild = function () {
|
|||
var runGulpWatch = function () {
|
||||
var watch = childProcess.spawn(gulpPath, [
|
||||
'watch',
|
||||
'--target=' + utils.getBuildTarget(),
|
||||
'--env=' + utils.getEnvName(),
|
||||
'--color'
|
||||
]);
|
||||
|
||||
|
|
|
@ -23,6 +23,6 @@ module.exports.replace = function (str, patterns) {
|
|||
return str;
|
||||
};
|
||||
|
||||
module.exports.getBuildTarget = function () {
|
||||
return argv.target || 'development';
|
||||
module.exports.getEnvName = function () {
|
||||
return argv.env || 'development';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue