Skip to content
Merged
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
16 changes: 14 additions & 2 deletions templates/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exports.Template = Object.create(PackageTemplate, {
value:function (command) {
command = PackageTemplate.addOptions.call(this, command);
command.option('-n, --name <name>', 'application name (required)');
command.option('-d, --description <description>', 'application description (optional)');
command.option('-c, --copyright [path]', 'copyright file');
return command;
}
Expand All @@ -32,10 +33,16 @@ exports.Template = Object.create(PackageTemplate, {
didSetOptions: {
value:function (options) {
if (options.name) {
options.originalName = options.name;
options.name = this.validateName(options.name);
} else {
throw new ArgumentError("Required name option missing");
}
if (options.description) {
options.description = this.validateDescription(options.description);
} else {
options.description = options.originalName + " Application";
}
if (options.copyright) {
options.copyright = this.validateCopyright(options.copyright);
}
Expand All @@ -52,6 +59,13 @@ exports.Template = Object.create(PackageTemplate, {
}
},

validateDescription: {
value: function(description) {
// ensure names are safe to use as npm package names
return removeDiacritics(description);
}
},

validateCopyright: {
value: function(path) {
return fs.readFileSync(path, "utf-8");
Expand All @@ -63,6 +77,4 @@ exports.Template = Object.create(PackageTemplate, {
return process.cwd();
}
}


});
2 changes: 2 additions & 0 deletions templates/app/__name__/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<html>
<head>
<meta charset="utf-8">
<link rel=manifest href=./manifest.json>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0, minimal-ui">
<meta name="apple-mobile-web-app-title" content="{{name}}">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- For iPad with high-resolution Retina display running iOS ≥ 7: -->
Expand Down
27 changes: 27 additions & 0 deletions templates/app/__name__/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"lang": "en",
"name": "{{name}}",
"short_name": "{{name}}",
"description": "{{description}}",
"start_url": "./?utm_source=homescreen",
"icons": [
{
"src": "./assets/icons/apple-touch-icon-120x120-precomposed.png",
"sizes": "120x120",
"type": "image/png"
},
{
"src": "./assets/icons/apple-touch-icon-152x152-precomposed.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "./assets/icons/apple-touch-icon-76x76-precomposed.png",
"sizes": "76x76",
"type": "image/png"
}
],
"theme_color": "#000",
"background_color": "#fff",
"display": "standalone"
}
1 change: 1 addition & 0 deletions templates/app/__name__/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "{{name}}",
"version": "0.1.0",
"description": "{{description}}",
"dependencies": {
"montage": "~17.0.11",
"digit": "~3.0.0"
Expand Down
17 changes: 16 additions & 1 deletion test/templates/app-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ describe("app template", function () {
template.didSetOptions(options);
expect(options.name).toEqual("my-app");
});
it("should accept camelCased name", function () {
options.name = "MyApp";
template.didSetOptions(options);
expect(options.name).toEqual("my-app");
});
it("should convert spaces to dashes in names", function () {
options.name = "My App";
template.didSetOptions(options);
Expand All @@ -91,6 +96,16 @@ describe("app template", function () {
template.didSetOptions(options);
expect(options.name).toEqual("rateau");
});
it("should generate description", function () {
options.name = "MyApp";
template.didSetOptions(options);
expect(options.description).toEqual("MyApp Application");
});
it("should generate description", function () {
options.name = "MyApp";
options.description = "Test description";
template.didSetOptions(options);
expect(options.description).toEqual("Test description");
});
});

});