├── .gitignore
├── .jshintrc
├── Gruntfile.js
├── LICENSE.txt
├── README.md
├── coverage
└── blanket.js
├── index.js
├── lib
├── constants.js
├── docs
│ └── Web-next-steps.md
└── platform.js
├── package.json
└── test
└── placeholder.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Visual Studio
15 | launch.json
16 | .ntvs_analysis.dat
17 | *.njsproj
18 | *.suo
19 | *.sln
20 | .vs
21 |
22 | # Blanket coverage
23 | coverage.html
24 |
25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26 | .grunt
27 |
28 | # node-waf configuration
29 | .lock-wscript
30 |
31 | # Compiled binary addons (http://nodejs.org/api/addons.html)
32 | build/Release
33 |
34 | # Dependency directory
35 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
36 | node_modules
37 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "curly": true,
3 | "eqeqeq": true,
4 | "immed": true,
5 | "indent": 2,
6 | "latedef": true,
7 | "newcap": true,
8 | "noarg": true,
9 | "sub": true,
10 | "undef": true,
11 | "unused": true,
12 | "boss": true,
13 | "eqnull": true,
14 | "node": true,
15 | "quotmark": "single",
16 |
17 | "globals": {
18 | "after": false,
19 | "before": false,
20 | "afterEach": false,
21 | "beforeEach": false,
22 | "describe": false,
23 | "it": false,
24 | "mocha": false,
25 | "expect": false
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function (grunt) {
4 | // Show elapsed time at the end
5 | require('time-grunt')(grunt);
6 | // Load all grunt tasks
7 | require('load-grunt-tasks')(grunt);
8 |
9 | grunt.initConfig({
10 | jshint: {
11 | options: {
12 | jshintrc: '.jshintrc',
13 | reporter: require('jshint-stylish')
14 | },
15 | gruntfile: {
16 | src: ['Gruntfile.js']
17 | },
18 | js: {
19 | src: ['*.js', 'lib/**/*.js']
20 | },
21 | test: {
22 | src: ['test/**/*.js']
23 | },
24 | teamcity: {
25 | options: {
26 | reporter: require('jshint-teamcity')
27 | },
28 | src: ['*.js', 'lib/**/*.js', 'test/**/*.js', 'Gruntfile.js']
29 | },
30 | },
31 | mochaTest: {
32 | test: {
33 | options: {
34 | reporter: 'spec',
35 | require: 'coverage/blanket'
36 | },
37 | src: ['test/**/*.js']
38 | },
39 | 'html-cov': {
40 | options: {
41 | reporter: 'html-cov',
42 | quiet: true,
43 | captureFile: 'coverage.html'
44 | },
45 | src: ['lib/**/*.js']
46 | },
47 | // The travis-cov reporter will fail the tests if the
48 | // coverage falls below the threshold configured in package.json
49 | 'travis-cov': {
50 | options: {
51 | reporter: 'travis-cov'
52 | },
53 | src: ['lib/**/*.js']
54 | },
55 | 'teamcity-test': {
56 | options: {
57 | reporter: 'mocha-teamcity-reporter'
58 | },
59 | src: ['test/**/*.js']
60 | }
61 | },
62 | watch: {
63 | gruntfile: {
64 | files: '<%= jshint.gruntfile.src %>',
65 | tasks: ['jshint:gruntfile']
66 | },
67 | js: {
68 | files: '<%= jshint.js.src %>',
69 | tasks: ['jshint:js', 'mochaTest']
70 | },
71 | test: {
72 | files: '<%= jshint.test.src %>',
73 | tasks: ['jshint:test', 'mochaTest']
74 | }
75 | }
76 | });
77 |
78 | grunt.registerTask('jshint-all', ['jshint:js', 'jshint:test', 'jshint:gruntfile']);
79 | grunt.registerTask('tests-all', ['mochaTest:test', 'mochaTest:html-cov', 'mochaTest:travis-cov']);
80 |
81 | grunt.registerTask('default', ['jshint-all', 'tests-all']);
82 |
83 | grunt.registerTask('teamcity-tests', ['mochaTest:teamcity-test']);
84 | grunt.registerTask('teamcity-jshint', ['jshint:teamcity']);
85 |
86 | grunt.registerTask('teamcity-build', ['teamcity-jshint', 'teamcity-tests']);
87 | };
88 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | pwabuilder-web
2 |
3 | Copyright (c) Microsoft Corporation
4 |
5 | All rights reserved.
6 |
7 | MIT License
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Please use our [main repository for any issues/bugs/features suggestion](https://github.com/pwa-builder/PWABuilder/issues/new/choose).
2 |
3 | # pwabuilder-web
4 |
5 | ## PWA Builder Web Platform
6 |
7 | Web platform module for [PWA Builder](https://github.com/manifoldjs/ManifoldJS), a tool for creating hosted web applications based on a [W3C Web App manifest](http://www.w3.org/TR/appmanifest/).
8 |
9 | ## Installation
10 |
11 | ```
12 | npm install pwabuilder-web
13 | ```
14 | In node.js:
15 |
16 | ```
17 | var platform = require('pwabuilder-web')
18 | ```
19 |
20 | ## Documentation
21 | To get started, visit our [wiki](https://github.com/manifoldjs/ManifoldJS/wiki).
22 |
23 | ## License
24 |
25 | > pwabuilder-web
26 |
27 | > Copyright (c) Microsoft Corporation
28 |
29 | > All rights reserved.
30 |
31 | > MIT License
32 |
33 | > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
34 |
35 | > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36 |
37 | > THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 |
--------------------------------------------------------------------------------
/coverage/blanket.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var srcDir = path.join(__dirname, '..', 'lib');
3 |
4 | require('blanket')({
5 | // Only files that match the pattern will be instrumented
6 | pattern: srcDir
7 | });
8 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | Platform: require('./lib/platform')
5 | };
6 |
7 |
--------------------------------------------------------------------------------
/lib/constants.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var constants = {
4 | platform: {
5 | id: 'web',
6 | name: 'Web Platform'
7 | }
8 | };
9 |
10 | module.exports = constants;
11 |
--------------------------------------------------------------------------------
/lib/docs/Web-next-steps.md:
--------------------------------------------------------------------------------
1 | # Configuring the manifest in your site
2 |
3 | 1. Upload the manifest.json and the images to the root path of your site.
4 |
5 | 2. Reference the manifest in your page with a link tag:
6 |
7 | ````
8 |
9 | ````
10 |
11 | 3. Add the [ManUp.js](https://github.com/boyofgreen/manUp.js/) polyfill to your site and reference it in your page with a script tag:
12 |
13 | ````
14 |
15 | ````
16 |
17 | 4. Redeploy your site and test it in the different devices.
18 |
--------------------------------------------------------------------------------
/lib/platform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path'),
4 | util = require('util'),
5 | Q = require('q');
6 |
7 | var pwabuilderLib = require('pwabuilder-lib');
8 |
9 | var CustomError = pwabuilderLib.CustomError,
10 | PlatformBase = pwabuilderLib.PlatformBase,
11 | manifestTools = pwabuilderLib.manifestTools,
12 | fileTools = pwabuilderLib.fileTools,
13 | utils = pwabuilderLib.utils;
14 |
15 | var constants = require('./constants');
16 |
17 | function Platform (packageName, platforms) {
18 |
19 | var self = this;
20 |
21 | PlatformBase.call(this, constants.platform.id, constants.platform.name, packageName, __dirname, { isPWA: true, targetFolder: '/' });
22 |
23 | // save platform list
24 | self.platforms = platforms;
25 |
26 | // override create function
27 | self.create = function (w3cManifestInfo, rootDir, options, callback) {
28 | if (w3cManifestInfo.format !== pwabuilderLib.constants.BASE_MANIFEST_FORMAT) {
29 | return Q.reject(new CustomError('The \'' + w3cManifestInfo.format + '\' manifest format is not valid for this platform.'));
30 | }
31 |
32 | self.info('Generating the ' + constants.platform.name + ' app...');
33 |
34 | // if the platform dir doesn't exist, create it
35 | var platformDir = self.getOutputFolder(rootDir);
36 | self.debug('Creating the ' + constants.platform.name + ' app folder...');
37 | return fileTools.mkdirp(platformDir)
38 | // download icons to the app's folder
39 | .then(function () {
40 | return self.downloadIcons(w3cManifestInfo.content, w3cManifestInfo.content.start_url, self.getOutputImagesInfo(platformDir));
41 | })
42 | // copy the documentation
43 | .then(function () {
44 | return self.copyDocumentation(platformDir);
45 | })
46 | // write generation info (telemetry)
47 | .then(function () {
48 | return self.writeGenerationInfo(w3cManifestInfo, platformDir);
49 | })
50 | // persist the platform-specific manifest
51 | .then(function () {
52 | self.debug('Copying the ' + constants.platform.name + ' manifest to the app folder...');
53 | var manifestFilePath = path.join(platformDir, 'manifest.json');
54 | return manifestTools.writeToFile(w3cManifestInfo, manifestFilePath);
55 | })
56 | .nodeify(callback);
57 | };
58 |
59 | self.getManifestIcons = function (manifest) {
60 | return (manifest.icons || []).map(function (icon) { return icon.src; });
61 | };
62 |
63 | self.getManifestIcon = function (manifest, size) {
64 | size = size.trim().toLowerCase();
65 | return (manifest.icons || []).find(function (icon) {
66 | return icon.sizes.split(/\s+/).find(function (iconSize) {
67 | return iconSize.toLowerCase() === size;
68 | });
69 | });
70 | };
71 |
72 | self.getEmbeddedIconFilename = function(manifest, iconFromGetManifestIcons) {
73 | var result;
74 |
75 | manifest.icons.forEach(function(iconInfo) {
76 | if (iconInfo.src === iconFromGetManifestIcons) {
77 | result = iconInfo.fileName;
78 | }
79 | });
80 |
81 | if (!result) {
82 | result = utils.newGuid() + '.webPlatform.png';
83 | }
84 |
85 | return result;
86 | };
87 |
88 | self.updateEmbeddedIconUri = function(manifest, iconFromGetManifestIcons, uri) {
89 | (manifest.icons || []).map(function(icon) {
90 | if (icon.src === iconFromGetManifestIcons) {
91 | icon.src = uri;
92 | icon.type = icon.type || 'image/png';
93 |
94 | delete(icon.fileName);
95 | }
96 | });
97 | };
98 |
99 | self.addManifestIcon = function (manifest, fileName, size) {
100 | if (!manifest.icons) {
101 | manifest.icons = [];
102 | }
103 |
104 | manifest.icons.push({ 'src': fileName, 'sizes': size.toLowerCase().trim()});
105 | };
106 | }
107 |
108 | util.inherits(Platform, PlatformBase);
109 |
110 | module.exports = Platform;
111 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pwabuilder-web",
3 | "version": "2.0.0-rc.2",
4 | "description": "PWA Builder Web Platform",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/manifoldjs/manifoldjs-web.git"
8 | },
9 | "engines": {
10 | "node": ">=0.12.0"
11 | },
12 | "engine-strict": true,
13 | "author": {
14 | "name": "TBD",
15 | "email": "TBD",
16 | "url": "TBD"
17 | },
18 | "license": "MIT",
19 | "licenses": [
20 | {
21 | "type": "MIT",
22 | "url": "https://github.com/manifoldjs/manifoldjs-web/blob/master/LICENSE.txt"
23 | }
24 | ],
25 | "keywords": [
26 | "convert manifest",
27 | "manifest",
28 | "W3C",
29 | "Manifold",
30 | "ManifoldJS",
31 | "PWA",
32 | "PWA Builder",
33 | "Windows"
34 | ],
35 | "dependencies": {
36 | "q": "^1.4.1",
37 | "pwabuilder-lib": "^2.0.0-rc.1"
38 | },
39 | "devDependencies": {
40 | "blanket": "1.1.6",
41 | "grunt": "^0.4.5",
42 | "grunt-cli": "^0.1.13",
43 | "grunt-contrib-jshint": "^0.11.3",
44 | "grunt-contrib-nodeunit": "^0.4.1",
45 | "grunt-contrib-watch": "^0.6.1",
46 | "grunt-mocha-test": "^0.12.7",
47 | "jshint-stylish": "^1.0.0",
48 | "jshint-teamcity": "^1.0.6",
49 | "load-grunt-tasks": "^1.0.0",
50 | "mocha": "^2.1.0",
51 | "mocha-teamcity-reporter": "0.0.4",
52 | "should": "^5.0.1",
53 | "time-grunt": "^1.0.0",
54 | "travis-cov": "^0.2.5"
55 | },
56 | "scripts": {
57 | "test": "grunt",
58 | "debug-tests": "mocha test/**/*.js --debug-brk"
59 | },
60 | "bugs": {
61 | "url": "https://github.com/manifoldjs/manifoldjs-web/issues"
62 | },
63 | "homepage": "https://github.com/manifoldjs/manifoldjs-web"
64 | }
65 |
--------------------------------------------------------------------------------
/test/placeholder.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('PLACEHOLDER', function () {
4 | describe('TO BE DETERMINED', function () {
5 | it('Should implement unit tests');
6 | });
7 | });
--------------------------------------------------------------------------------