Skip to content

Commit fdafe78

Browse files
author
Gery Hirschfeld
committed
adds cordova setup
1 parent 0167d67 commit fdafe78

File tree

6 files changed

+308
-278
lines changed

6 files changed

+308
-278
lines changed

config/init-cordova.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

config/setup-mobile.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const exec = require('child_process').exec;
2+
const ncp = require('ncp').ncp;
3+
const rimraf = require('rimraf');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
const pkg = require(path.join(process.cwd(), 'package.json'));
8+
// const cordovaTemp = path.join(process.cwd(), 'cordova');
9+
const root = path.join(process.cwd());
10+
const cmd = `cordova create cordova ${pkg.identifier} "${pkg.title}"`;
11+
12+
// Run command to create cordova in a temporary directory
13+
exec(cmd, (error) => {
14+
if (error) throw error;
15+
16+
// Remove cordovas www folder
17+
rimraf(`${root}/cordova/www`, (error) => {
18+
if (error) throw error;
19+
20+
// Create symlink www to point to dist
21+
fs.symlink(`${root}/dist`, `${root}/cordova/www`, 'dir', (error) => {
22+
if (error) throw error;
23+
});
24+
});
25+
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@
117117
"babel-preset-es2015-loose-native-modules": "1.0.0",
118118
"babel-preset-stage-1": "6.16.0",
119119
"babel-register": "6.16.3",
120+
"chalk": "^1.1.3",
120121
"compression-webpack-plugin": "0.3.1",
121122
"concurrently": "3.1.0",
122123
"cross-env": "3.1.2",
123124
"favicons-webpack-plugin": "0.0.7",
125+
"fs": "0.0.1-security",
124126
"http-server": "0.9.0",
125127
"ignore-loader": "0.1.1",
126128
"intl": "1.2.5",
@@ -133,7 +135,8 @@
133135
"karma-remap-istanbul": "0.2.1",
134136
"karma-sourcemap-loader": "0.3.7",
135137
"karma-webpack": "1.8.0",
136-
"rimraf": "2.5.4",
138+
"ncp": "^2.0.0",
139+
"rimraf": "^2.5.4",
137140
"typescript": "2.0.3",
138141
"wait-on": "1.5.3",
139142
"webpack": "2.1.0-beta.22",

src/app/app.ts

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1+
import { inject } from 'aurelia-framework';
12
import { Router, RouterConfiguration } from 'aurelia-router';
3+
import { I18N } from 'aurelia-i18n';
24

5+
@inject(I18N, 'AppConfig')
36
export class App {
4-
public router: Router;
7+
public router: Router;
58

6-
public configureRouter(config: RouterConfiguration, router: Router): void {
7-
config.title = 'Aurelia';
8-
config.map([
9-
{
10-
route: ['', 'welcome'],
11-
name: 'welcome',
12-
moduleId: './modules/welcome/welcome',
13-
nav: true,
14-
title: 'Welcome'
15-
},
16-
{
17-
route: 'users',
18-
name: 'users',
19-
moduleId: './modules/users/users',
20-
nav: true,
21-
title: 'Github Users'
22-
},
23-
{
24-
route: 'child-router',
25-
name: 'child-router',
26-
moduleId: './modules/child-router/child-router',
27-
nav: true,
28-
title: 'Child Router'
29-
}
30-
]);
9+
constructor(
10+
private i18n: I18N,
11+
private appConfig: AppConfig.IAppConfig
12+
) { }
3113

32-
this.router = router;
33-
}
14+
public configureRouter(config: RouterConfiguration, router: Router): void {
15+
config.title = this.i18n.tr('TITLE');
16+
if (this.appConfig.PLATFORM === 'web') {
17+
config.options.pushState = true;
18+
}
19+
config.map([
20+
{
21+
route: ['', 'welcome'],
22+
name: 'welcome',
23+
moduleId: './modules/welcome/welcome',
24+
nav: true,
25+
title: 'Welcome'
26+
},
27+
{
28+
route: 'users',
29+
name: 'users',
30+
moduleId: './modules/users/users',
31+
nav: true,
32+
title: 'Github Users'
33+
},
34+
{
35+
route: 'child-router',
36+
name: 'child-router',
37+
moduleId: './modules/child-router/child-router',
38+
nav: true,
39+
title: 'Child Router'
40+
}
41+
]);
42+
43+
this.router = router;
44+
}
3445
}

src/index.ejs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>">
1010
<meta name="version" content="<%= htmlWebpackPlugin.options.version %>">
1111
<meta name="author" content="<%= htmlWebpackPlugin.options.author %>">
12+
13+
<% if (htmlWebpackPlugin.options.platform === 'mobile') { %>
14+
<!-- Cordova -->
15+
<script src="cordova.js"></script>
16+
<% } %>
17+
<% if (htmlWebpackPlugin.options.platform === 'web') { %>
1218
<base href="<%= htmlWebpackPlugin.options.baseUrl %>">
13-
<!-- imported CSS are concatenated and added automatically -->
19+
<% } %>
1420
</head>
1521

1622
<body aurelia-app="main">
@@ -25,4 +31,4 @@
2531
<% } %>
2632
</body>
2733

28-
</html>
34+
</html>

0 commit comments

Comments
 (0)