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

electron refactor symlink and webpack #392

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ nativescript/src/**/*.js
nativescript/src/**/*.js.map
nativescript/*.d.ts
!nativescript/src/references.d.ts
electron/app
electron/config
electron/node_modules
electron/platforms
electron/src/app
electron/src/**/*.js
electron/src/**/*.js.map
electron/*.d.ts
!electron/src/references.d.ts
desktop
gulpfile.js
gulpfile.js.map
Expand Down
40 changes: 40 additions & 0 deletions electron/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var path = require('path');
var zlib = require('zlib');


// Helper functions

function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}

function gzipMaxLevel(buffer, callback) {
return zlib['gzip'](buffer, {level: 9}, callback);
}

function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}

function rootNode(args) {
args = Array.prototype.slice.call(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}

function prependExt(extensions, args) {
args = args || [];
if (!Array.isArray(args)) { args = [args] }
return extensions.reduce(function(memo, val) {
return memo.concat(val, args.map(function(prefix) {
return prefix + val;
}));
}, ['']);
}

exports.hasProcessFlag = hasProcessFlag;
exports.gzipMaxLevel = gzipMaxLevel;
exports.root = root;
exports.rootNode = rootNode;
exports.prependExt = prependExt;
exports.prepend = prependExt;
123 changes: 123 additions & 0 deletions electron/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
module.exports = function (config) {
var testWebpackConfig = require('./webpack.test.js')({ env: 'test' });

var configuration = {

// base path that will be used to resolve all patterns (e.g. files, exclude)
basePath: '',

/*
* Frameworks to use
*
* available frameworks: https://npmjs.org/browse/keyword/karma-adapter
*/
frameworks: ['jasmine'],

// list of files to exclude
exclude: [],

client: {
captureConsole: false
},

/*
* list of files / patterns to load in the browser
*
* we are building the test environment in ./spec-bundle.js
*/
files: [
{ pattern: './config/spec-bundle.js', watched: false },
{ pattern: './src/assets/**/*', watched: false, included: false, served: true, nocache: false }
],

/*
* By default all assets are served at http://localhost:[PORT]/base/
*/
proxies: {
"/assets/": "/base/src/assets/"
},

/*
* preprocess matching files before serving them to the browser
* available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
*/
preprocessors: { './config/spec-bundle.js': ['coverage', 'webpack', 'sourcemap'] },

// Webpack Config at ./webpack.test.js
webpack: testWebpackConfig,

coverageReporter: {
type: 'in-memory'
},

remapCoverageReporter: {
'text-summary': null,
json: './coverage/coverage.json',
html: './coverage/html'
},

// Webpack please don't spam the console when running in karma!
webpackMiddleware: {
// webpack-dev-middleware configuration
// i.e.
noInfo: true,
// and use stats to turn off verbose output
stats: {
// options i.e.
chunks: false
}
},

/*
* test results reporter to use
*
* possible values: 'dots', 'progress'
* available reporters: https://npmjs.org/browse/keyword/karma-reporter
*/
reporters: ['mocha', 'coverage', 'remap-coverage'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

/*
* level of logging
* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
*/
logLevel: config.LOG_WARN,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

/*
* start these browsers
* available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
*/
browsers: [
'Chrome'
],

customLaunchers: {
ChromeTravisCi: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},

/*
* Continuous Integration mode
* if true, Karma captures browsers, runs the tests and exits
*/
singleRun: true
};

if (process.env.TRAVIS) {
configuration.browsers = [
'ChromeTravisCi'
];
}

config.set(configuration);
};
58 changes: 58 additions & 0 deletions electron/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"use strict";

var packager = require('electron-packager');
const pkg = require('./package.json');
const argv = require('minimist')(process.argv.slice(2));
const devDeps = Object.keys(pkg.devDependencies);

const appName = argv.name || pkg.productName;
const shouldUseAsar = argv.asar || false;
const shouldBuildAll = argv.all || false;
const arch = argv.arch || 'all';
const platform = argv.platform || 'darwin';

const DEFAULT_OPTS = {
dir: './src/app',
name: appName,
asar: shouldUseAsar,
ignore: [
].concat(devDeps.map(name => `/node_modules/${name}($|/)`))
};

const icon = './src/app/dist/assets/app-icon';

if (icon) {
DEFAULT_OPTS.icon = icon;
}

pack(platform, arch, function done(err, appPath) {
console.log(err);
});

function pack(plat, arch, cb) {
// there is no darwin ia32 electron
if (plat === 'darwin' && arch === 'ia32') return;

const iconObj = {
icon: DEFAULT_OPTS.icon + (() => {
let extension = '.png';
if (plat === 'darwin') {
extension = '.icns';
} else if (plat === 'win32') {
extension = '.ico';
}
return extension;
})()
};

const opts = Object.assign({}, DEFAULT_OPTS, iconObj, {
platform: plat,
arch,
prune: true,
all: shouldBuildAll,
'app-version': pkg.version || DEFAULT_OPTS.version,
out: `release/${plat}-${arch}`
});

packager(opts, cb);
}
73 changes: 73 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "angular-seed-advanced",
"main": "app.js",
"version": "0.0.0",
"nativescript": {
"id": "com.yourdomain.nativescript",
"tns-ios": {
"version": "2.5.0"
},
"tns-android": {
"version": "2.5.0"
}
},
"scripts": {
"preinstall": "mkdirp app",
"clean": "rimraf platforms node_modules lib hooks app && mkdirp app",
"ns-bundle": "ns-bundle",
"start-android-bundle": "npm run ns-bundle --android --start-app",
"start-ios-bundle": "npm run ns-bundle --ios --start-app",
"build-android-bundle": "npm run ns-bundle --android --build-app",
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
},
"dependencies": {
"@angular/animations": "~4.0.0",
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/core": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/platform-browser-dynamic": "~4.0.0",
"@angular/router": "~4.0.0",
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "^2.0.0",
"@ngrx/store": "^2.2.1",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "0.0.3",
"angulartics2": "^1.6.4",
"lodash": "^4.17.4",
"nativescript-angular": "1.5.0",
"nativescript-dev-webpack": "^0.3.1",
"nativescript-theme-core": "^1.0.3",
"ngrx-store-freeze": "0.1.9",
"reflect-metadata": "^0.1.8",
"rxjs": "~5.2.0",
"tns-core-modules": "^2.5.2",
"url": "0.10.3",
"zone.js": "~0.8.2"
},
"devDependencies": {
"@angular/compiler-cli": "~4.0.0",
"@ngrx/store-devtools": "^3.2.4",
"@ngtools/webpack": "~1.3.0",
"@types/lodash": "4.14.59",
"@types/jasmine": "^2.5.47",
"babel-traverse": "6.20.0",
"babel-types": "6.20.0",
"babylon": "6.14.1",
"copy-webpack-plugin": "~4.0.1",
"extract-text-webpack-plugin": "~2.1.0",
"fs-extra": "^2.1.2",
"htmlparser2": "^3.9.2",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.1",
"nativescript-dev-android-snapshot": "^0.*.*",
"nativescript-dev-webpack": "^0.3.6",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.0.2",
"typescript": "~2.1.4",
"webpack": "2.3.2",
"webpack-sources": "~0.2.3"
}
}
Empty file added electron/src/_common.scss
Empty file.
Empty file added electron/src/app.scss
Empty file.
7 changes: 7 additions & 0 deletions electron/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// nativescript
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

// app
import { ElectronModule } from './electron.module';

platformBrowserDynamic().bootstrapModule(ElectronModule);
6 changes: 6 additions & 0 deletions electron/src/assets/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"Edsger Dijkstra",
"Donald Knuth",
"Alan Turing",
"Grace Hopper"
]
Binary file added electron/src/assets/favicon/favicon-DEV.ico
Binary file not shown.
Binary file added electron/src/assets/favicon/favicon-PROD.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions electron/src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"HOME": "у дома",
"ABOUT": "около",
"HELLO": "Здравей",
"LOVE_TECH": "Обичам технологиите!",
"ABOUT_ADD": "Искаш повече? Добавете ги себе си!",
"ABOUT_REWARD": "За награда, тук е списък на страхотни компютърни специалисти:",
"INPUT_HINT": "Въвеждане на нов компютърен специалист...",
"ADD_BTN_TEXT": "Добави",
"SUCCESS_MSG": "Вашият разполагане на ъгловото Seed Advanced работи перфектно."
}
11 changes: 11 additions & 0 deletions electron/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"HOME": "Home",
"ABOUT": "About",
"HELLO": "Hello",
"LOVE_TECH": "I love technology!",
"ABOUT_ADD": "You want more? Add them yourself!",
"ABOUT_REWARD": "For reward, here is a list of awesome computer scientists:",
"INPUT_HINT": "Enter a new computer scientist...",
"ADD_BTN_TEXT": "Add",
"SUCCESS_MSG": "Your deployment of Angular Seed Advanced worked perfectly."
}
11 changes: 11 additions & 0 deletions electron/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"HOME": "Casa",
"ABOUT": "Acerca de",
"HELLO": "Hola",
"LOVE_TECH": "Me encanta la tecnología!",
"ABOUT_ADD": "¿Quieres más? Añadir a ti mismo!",
"ABOUT_REWARD": "Para recompensa, aquí hay una lista de científicos informáticos impresionantes:",
"INPUT_HINT": "Introduzca un nuevo científico de la computación...",
"ADD_BTN_TEXT": "Añadir",
"SUCCESS_MSG": "Su despliegue de Angular avanzada Semilla funcionó a la perfección."
}
11 changes: 11 additions & 0 deletions electron/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"HOME": "Accueil",
"ABOUT": "À propos",
"HELLO": "Bonjour",
"LOVE_TECH": "J'adore la technologie !",
"ABOUT_ADD": "Vous en voulez plus? Ajoutez-les vous-même !",
"ABOUT_REWARD": "En récompense, voici une liste de géniaux informaticiens :",
"INPUT_HINT": "Ajouter un nouvel informaticien...",
"ADD_BTN_TEXT": "Ajouter",
"SUCCESS_MSG": "Votre déploiement d'Angular Seed Advanced a parfaitement fonctionné."
}
11 changes: 11 additions & 0 deletions electron/src/assets/i18n/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"HOME": "Главная",
"ABOUT": "Справка",
"HELLO": "Здравствуйте",
"LOVE_TECH": "Я люблю технологию!",
"ABOUT_ADD": "Хочешь больше? Добавь их самостоятельно!",
"ABOUT_REWARD": "В награду, вот список классных компьютерных ученых:",
"INPUT_HINT": "Введите нового ученого...",
"ADD_BTN_TEXT": "Добавить",
"SUCCESS_MSG": "Ваш Angular Seed Advanced развернут отлично."
}
Binary file added electron/src/assets/logo.icns
Binary file not shown.
Binary file added electron/src/assets/logo.ico
Binary file not shown.
Loading