Skip to content

Commit f96d631

Browse files
authored
Merge pull request #83 from montagejs/features/app-manifest
add manifest.json and index.html use in app template
2 parents 0a66132 + ae86e2a commit f96d631

File tree

5 files changed

+60
-3
lines changed

5 files changed

+60
-3
lines changed

templates/app.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ exports.Template = Object.create(PackageTemplate, {
2424
value:function (command) {
2525
command = PackageTemplate.addOptions.call(this, command);
2626
command.option('-n, --name <name>', 'application name (required)');
27+
command.option('-d, --description <description>', 'application description (optional)');
2728
command.option('-c, --copyright [path]', 'copyright file');
2829
return command;
2930
}
@@ -32,10 +33,16 @@ exports.Template = Object.create(PackageTemplate, {
3233
didSetOptions: {
3334
value:function (options) {
3435
if (options.name) {
36+
options.originalName = options.name;
3537
options.name = this.validateName(options.name);
3638
} else {
3739
throw new ArgumentError("Required name option missing");
3840
}
41+
if (options.description) {
42+
options.description = this.validateDescription(options.description);
43+
} else {
44+
options.description = options.originalName + " Application";
45+
}
3946
if (options.copyright) {
4047
options.copyright = this.validateCopyright(options.copyright);
4148
}
@@ -52,6 +59,13 @@ exports.Template = Object.create(PackageTemplate, {
5259
}
5360
},
5461

62+
validateDescription: {
63+
value: function(description) {
64+
// ensure names are safe to use as npm package names
65+
return removeDiacritics(description);
66+
}
67+
},
68+
5569
validateCopyright: {
5670
value: function(path) {
5771
return fs.readFileSync(path, "utf-8");
@@ -63,6 +77,4 @@ exports.Template = Object.create(PackageTemplate, {
6377
return process.cwd();
6478
}
6579
}
66-
67-
6880
});

templates/app/__name__/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<html>
55
<head>
66
<meta charset="utf-8">
7+
<link rel=manifest href=./manifest.json>
78
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0, minimal-ui">
9+
<meta name="apple-mobile-web-app-title" content="{{name}}">
810
<meta name="mobile-web-app-capable" content="yes">
911
<meta name="apple-mobile-web-app-capable" content="yes">
1012
<!-- For iPad with high-resolution Retina display running iOS ≥ 7: -->
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"lang": "en",
3+
"name": "{{name}}",
4+
"short_name": "{{name}}",
5+
"description": "{{description}}",
6+
"start_url": "./?utm_source=homescreen",
7+
"icons": [
8+
{
9+
"src": "./assets/icons/apple-touch-icon-120x120-precomposed.png",
10+
"sizes": "120x120",
11+
"type": "image/png"
12+
},
13+
{
14+
"src": "./assets/icons/apple-touch-icon-152x152-precomposed.png",
15+
"sizes": "152x152",
16+
"type": "image/png"
17+
},
18+
{
19+
"src": "./assets/icons/apple-touch-icon-76x76-precomposed.png",
20+
"sizes": "76x76",
21+
"type": "image/png"
22+
}
23+
],
24+
"theme_color": "#000",
25+
"background_color": "#fff",
26+
"display": "standalone"
27+
}

templates/app/__name__/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "{{name}}",
33
"version": "0.1.0",
4+
"description": "{{description}}",
45
"dependencies": {
56
"montage": "~17.0.11",
67
"digit": "~3.0.0"

test/templates/app-spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ describe("app template", function () {
7575
template.didSetOptions(options);
7676
expect(options.name).toEqual("my-app");
7777
});
78+
it("should accept camelCased name", function () {
79+
options.name = "MyApp";
80+
template.didSetOptions(options);
81+
expect(options.name).toEqual("my-app");
82+
});
7883
it("should convert spaces to dashes in names", function () {
7984
options.name = "My App";
8085
template.didSetOptions(options);
@@ -91,6 +96,16 @@ describe("app template", function () {
9196
template.didSetOptions(options);
9297
expect(options.name).toEqual("rateau");
9398
});
99+
it("should generate description", function () {
100+
options.name = "MyApp";
101+
template.didSetOptions(options);
102+
expect(options.description).toEqual("MyApp Application");
103+
});
104+
it("should generate description", function () {
105+
options.name = "MyApp";
106+
options.description = "Test description";
107+
template.didSetOptions(options);
108+
expect(options.description).toEqual("Test description");
109+
});
94110
});
95-
96111
});

0 commit comments

Comments
 (0)