From 893b94040e2eaf9e0e8af07c5a3059efe3204129 Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Fri, 26 Feb 2016 08:45:25 -0600 Subject: [PATCH 1/8] Fix app var name reference --- app/js/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/js/app.js b/app/js/app.js index c347943..b37163c 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -7,7 +7,7 @@ var buildTools = angular.module('BuildTools', [ 'ionic', 'BuildTools.services' ]); -buildToolsServices.run(function($ionicPlatform) { +buildTools.run(function ($ionicPlatform) { $ionicPlatform.ready(function() { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) From 08dc09a4d0b86c2685c9b8b049b89fe42bee9762 Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Fri, 26 Feb 2016 08:56:58 -0600 Subject: [PATCH 2/8] Use 'ionic resources' instead of convert.sh script --- app/res/README.md | 12 ----- app/res/convert.sh | 124 --------------------------------------------- gulpfile.js | 40 ++++++--------- 3 files changed, 15 insertions(+), 161 deletions(-) delete mode 100644 app/res/README.md delete mode 100755 app/res/convert.sh diff --git a/app/res/README.md b/app/res/README.md deleted file mode 100644 index 8528c5a..0000000 --- a/app/res/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Icons and Splash Screens - -The `convert.sh` script in this directory takes the base icon and splash PNGs and generates the appropriate sizes for the different platforms. - -Run it from the project root as follows: - - cd ./app/res/ && sh convert.sh - -The icon and splash screen generation used in this project is based primarily on two open source projects: - - * https://gist.github.com/LinusU/7515016 - * https://github.com/tlvince/phonegap-icon-splash-generator \ No newline at end of file diff --git a/app/res/convert.sh b/app/res/convert.sh deleted file mode 100755 index 84d26ca..0000000 --- a/app/res/convert.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# Generate PhoneGap icon and splash screens -# Based on https://gist.github.com/LinusU/7515016 -# and https://github.com/tlvince/phonegap-icon-splash-generator - -# devices=android,bada,bada-wac,blackberry,ios,webos,windows-phone -devices=android,ios -eval mkdir -p "{icons,screens}/{$devices}" - -# Show the user some progress by outputing all commands being run. -set -x - -# base file to use for the icons -ICON="base-icon.png" -# base file to use for the splash screens -SPLASH="base-splash.png" -# background color to use for the splash screens -BGCOLOR="#FFFFFF" - -# address warning: convert: iCCP: Not recognizing known sRGB profile that has been edited -convert $ICON -strip $ICON -convert $SPLASH -strip $SPLASH - -# ICON GENERATION -# Explicitly set background in case image is transparent (see: #3) -convert="convert -background none" - -# test to see whether the icons will change at all -$convert $ICON -resize 36x36 "temp.png" -DIFF=`compare -metric RMSE icons/android/icon-36-ldpi.png temp.png NULL: 2>&1` -NOCHANGE="0 (0)" -if [ "$DIFF" != "$NOCHANGE" ] - then - echo 'Icon has changed' - - $convert $ICON -resize 36x36 "icons/android/icon-36-ldpi.png" - $convert $ICON -resize 72x72 "icons/android/icon-72-hdpi.png" - $convert $ICON -resize 48x48 "icons/android/icon-48-mdpi.png" - $convert $ICON -resize 96x96 "icons/android/icon-96-xhdpi.png" - $convert $ICON -resize 29x29 "icons/ios/icon-29.png" - convert $ICON -resize 58 "icons/ios/icon-29-2x.png" - $convert $ICON -resize 40x40 "icons/ios/icon-40.png" - $convert $ICON -resize 50x50 "icons/ios/icon-50.png" - $convert $ICON -resize 57x57 "icons/ios/icon-57.png" - $convert $ICON -resize 58x58 "icons/ios/icon-58.png" - convert $ICON -resize 60 "icons/ios/icon-60.png" - $convert $ICON -resize 72x72 "icons/ios/icon-72.png" - $convert $ICON -resize 76x76 "icons/ios/icon-76.png" - $convert $ICON -resize 80x80 "icons/ios/icon-80.png" - $convert $ICON -resize 80 "icons/ios/icon-40-2x.png" - $convert $ICON -resize 100 "icons/ios/icon-50-2x.png" - $convert $ICON -resize 114 "icons/ios/icon-57-2x.png" - $convert $ICON -resize 120 "icons/ios/icon-60-2x.png" - $convert $ICON -resize 144 "icons/ios/icon-72-2x.png" - $convert $ICON -resize 152 "icons/ios/icon-76-2x.png" - $convert $ICON -resize 100x100 "icons/ios/icon-100.png" - $convert $ICON -resize 144x144 "icons/ios/icon-144.png" - $convert $ICON -resize 114x114 "icons/ios/icon-114.png" - $convert $ICON -resize 120x120 "icons/ios/icon-120.png" - $convert $ICON -resize 152x152 "icons/ios/icon-152.png" - # $convert "$1" -resize 128x128 "icon/icon.png" - # $convert "$1" -resize 128x128 "$3/res/icon/bada/icon-128.png" - # $convert "$1" -resize 48x48 "$3/res/icon/bada-wac/icon-48-type5.png" - # $convert "$1" -resize 80x80 "$3/res/icon/bada-wac/icon-80-type4.png" - # $convert "$1" -resize 50x50 "$3/res/icon/bada-wac/icon-50-type3.png" - # $convert "$1" -resize 80x80 "$3/res/icon/blackberry/icon-80.png" - # $convert "$1" -resize 64x64 "$3/res/icon/webos/icon-64.png" - # $convert "$1" -resize 48x48 "$3/res/icon/windows-phone/icon-48.png" - # $convert "$1" -resize 173x173 "$3/res/icon/windows-phone/icon-173-tile.png" - # $convert "$1" -resize 62x62 "$3/res/icon/windows-phone/icon-62-tile.png" - else - echo 'Icon has not changed' -fi -rm 'temp.png' - - -# # SPLASH SCREEN GENERATION -convert="convert $SPLASH -background $BGCOLOR -gravity center" - -# test to see whether the splash screen will change at all -$convert -resize 512x512 -extent 1280x720 "temp.png" -DIFF=`compare -metric RMSE screens/android/screen-xhdpi-landscape.png temp.png NULL: 2>&1` -NOCHANGE="0 (0)" -if [ "$DIFF" != "$NOCHANGE" ] - then - echo 'Splash screen has changed' - - $convert -resize 512x512 -extent 1280x720 "screens/android/screen-xhdpi-landscape.png" - $convert -resize 256x256 -extent 480x800 "screens/android/screen-hdpi-portrait.png" - $convert -resize 128x128 -extent 320x200 "screens/android/screen-ldpi-landscape.png" - $convert -resize 512x512 -extent 720x1280 "screens/android/screen-xhdpi-portrait.png" - $convert -resize 256x256 -extent 320x480 "screens/android/screen-mdpi-portrait.png" - $convert -resize 256x256 -extent 480x320 "screens/android/screen-mdpi-landscape.png" - $convert -resize 128x128 -extent 200x320 "screens/android/screen-ldpi-portrait.png" - $convert -resize 512x512 -extent 800x480 "screens/android/screen-hdpi-landscape.png" - # iPhone - $convert -resize 256x256 -extent 320x480 "screens/ios/screen-iphone-portrait.png" - $convert -resize 512x512 -extent 960x640 "screens/ios/screen-iphone-landscape-2x.png" - $convert -resize 256x256 -extent 480x320 "screens/ios/screen-iphone-landscape.png" - $convert -resize 512x512 -extent 640x960 "screens/ios/screen-iphone-portrait-2x.png" - $convert -resize 512x512 -extent 640x1136 "screens/ios/screen-iphone-portrait-568h-2x.png" - # iPad - iOS7+ - $convert -resize 512x512 -extent 768x1024 "screens/ios/screen-ipad-portrait.png" - $convert -resize 1024x1024 -extent 1536x2048 "screens/ios/screen-ipad-portrait-2x.png" - $convert -resize 512x512 -extent 1024x768 "screens/ios/screen-ipad-landscape.png" - $convert -resize 1024x1024 -extent 2048x1536 "screens/ios/screen-ipad-landscape-2x.png" - # iPad - iOS6 - # $convert -resize 512x512 -extent 768x1004 "screens/ios/screen-ipad-portrait_ios6.png" - # $convert -resize 1024x1024 -extent 1536x2008 "screens/ios/screen-ipad-portrait-2x_ios6.png" - # $convert -resize 512x512 -extent 1024x748 "screens/ios/screen-ipad-landscape_ios6.png" - # $convert -resize 1024x1024 -extent 2048x1496 "screens/ios/screen-ipad-landscape-2x_ios6.png" - # Other platforms - # $convert -resize 256x256 -extent 480x800 "$3/res/screens/bada/screen-portrait.png" - # $convert -resize 128x128 -extent 320x480 "$3/res/screens/bada-wac/screen-type3.png" - # $convert -resize 256x256 -extent 480x800 "$3/res/screens/bada-wac/screen-type4.png" - # $convert -resize 128x128 -extent 240x400 "$3/res/screens/bada-wac/screen-type5.png" - # $convert -resize 256x256 -extent 480x800 "$3/res/screens/bada-wac/screen-type5.png" - # $convert -resize 128x128 -extent 225x225 "$3/res/screens/blackberry/screen-225.png" - # convert "$1" -resize 64x64 "$3/res/screens/webos/screen-64.png" - # $convert -resize 256x256 -extent 480x800 "$3/res/screens/windows-phone/screen-portrait.jpg" - else - echo 'Splash screen has not changed' -fi -rm 'temp.png' diff --git a/gulpfile.js b/gulpfile.js index d1da024..0ead502 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,7 +32,6 @@ var source_paths = { scripts: ['./app/js/**/*.js'], templates: ['./app/templates/**/*.html'], images: ['./app/img/**/*.*'], - resources: ['./app/res/**/*.png'], index_page: ['./app/index.html'] }; // the destination paths @@ -41,7 +40,6 @@ var dest_paths = { scripts: './www/js/', templates: './www/templates/', images: './www/img/', - resources: './www/res/', index_page: './www/index.html', root: './www/', release_builds: './release_builds' @@ -116,22 +114,19 @@ gulp.task('compile-images', function() { }); // compile resources (icons) -gulp.task('compile-resources', function() { - exec('cd ./app/res/ && sh convert.sh'); - - return gulp.src(source_paths.resources) - .pipe(changed(dest_paths.resources)) - .pipe(gulp.dest(dest_paths.resources)); -}); - -gulp.task('compile-all', ['compile-scripts', - 'compile-sass', - 'compile-css', - 'compile-templates', - 'compile-index', - 'compile-images', - 'compile-resources' - ]); +gulp.task('compile-resources', function () { + return exec('ionic resources') +}) + +gulp.task('compile-all', [ + 'compile-scripts', + 'compile-sass', + 'compile-css', + 'compile-templates', + 'compile-index', + 'compile-images', + 'compile-resources' +]) // compile everything after cleaning the build gulp.task('compile', ['build-clean'], function(){ @@ -165,13 +160,8 @@ gulp.task('clean-scripts', function() { gulp.task('clean-templates', function() { return gulp.src(dest_paths.templates, {read: false}) - .pipe(clean({force: true})); -}); - -gulp.task('clean-resources', function() { - return gulp.src(dest_paths.resources, {read: false}) - .pipe(clean({force: true})); -}); + .pipe(clean({force: true})) +}) gulp.task('clean-index', function() { return gulp.src(dest_paths.index_page, {read: false}) From 11d26f763a6f55474f61175278cb5dbd3ab94b78 Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Fri, 26 Feb 2016 09:00:19 -0600 Subject: [PATCH 3/8] The hooks are no longer needed, since we're using 'ionic resources' --- hooks/.gitignore | 0 hooks/README.md | 83 --------- hooks/after_prepare/icons_and_splash.js | 231 ------------------------ 3 files changed, 314 deletions(-) delete mode 100644 hooks/.gitignore delete mode 100644 hooks/README.md delete mode 100755 hooks/after_prepare/icons_and_splash.js diff --git a/hooks/.gitignore b/hooks/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/hooks/README.md b/hooks/README.md deleted file mode 100644 index d2563ea..0000000 --- a/hooks/README.md +++ /dev/null @@ -1,83 +0,0 @@ - -# Cordova Hooks - -This directory may contain scripts used to customize cordova commands. This -directory used to exist at `.cordova/hooks`, but has now been moved to the -project root. Any scripts you add to these directories will be executed before -and after the commands corresponding to the directory name. Useful for -integrating your own build systems or integrating with version control systems. - -__Remember__: Make your scripts executable. - -## Hook Directories -The following subdirectories will be used for hooks: - - after_build/ - after_compile/ - after_docs/ - after_emulate/ - after_platform_add/ - after_platform_rm/ - after_platform_ls/ - after_plugin_add/ - after_plugin_ls/ - after_plugin_rm/ - after_plugin_search/ - after_prepare/ - after_run/ - after_serve/ - before_build/ - before_compile/ - before_docs/ - before_emulate/ - before_platform_add/ - before_platform_rm/ - before_platform_ls/ - before_plugin_add/ - before_plugin_ls/ - before_plugin_rm/ - before_plugin_search/ - before_prepare/ - before_run/ - before_serve/ - pre_package/ <-- Windows 8 and Windows Phone only. - -## Script Interface - -All scripts are run from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables: - -* CORDOVA_VERSION - The version of the Cordova-CLI. -* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios). -* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer) -* CORDOVA_HOOK - Path to the hook that is being executed. -* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate) - -If a script returns a non-zero exit code, then the parent cordova command will be aborted. - - -## Writing hooks - -We highly recommend writting your hooks using Node.js so that they are -cross-platform. Some good examples are shown here: - -[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/) - diff --git a/hooks/after_prepare/icons_and_splash.js b/hooks/after_prepare/icons_and_splash.js deleted file mode 100755 index e8fe303..0000000 --- a/hooks/after_prepare/icons_and_splash.js +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/env node - -(function() { - 'use strict'; - - var cordova_util = require('cordova-lib/src/cordova/util'); - var projectRoot = cordova_util.isCordova(process.cwd()); - var projectXml = cordova_util.projectConfig(projectRoot); - var projectPlatforms = cordova_util.listPlatforms(projectRoot); - var CordovaConfigParser, - projectConfig; - - if ( typeof cordova_util.config_parser === 'undefined' ) { - CordovaConfigParser = require('cordova-lib/src/configparser/ConfigParser.js'); - projectConfig = new CordovaConfigParser(projectXml); - } else { - projectConfig = new cordova_util.config_parser(projectXml); - } - - var fs = require ('fs'); - var path = require('path'); - - var platformDir = { - ios: { - icon: '{$projectName}/Resources/icons', - splash: '{$projectName}/Resources/splash', - platformsDir: 'ios', - nameMap: { - - // iOS >= 7 Settings icon - // iOS <= 6.1 Small icon for Spotlight search results and Settings (recommended) iPhone - 'icon-29.png': 'icon-small.png', - 'icon-29-2x.png': 'icon-small@2x.png', - - // iOS >= 7 Spotlight search results icon (recommended) - 'icon-40.png': 'icon-40.png', - 'icon-40-2x.png': 'icon-40@2x.png', - - // iOS <= 6.1 Small icon for Spotlight search results and Settings (recommended) iPad - 'icon-50.png': 'icon-50.png', - 'icon-50-2x.png': 'icon-50@2x.png', - - // iOS <= 6.1 App icon (required) iPhone - 'icon-57.png': 'icon.png', - 'icon-57-2x.png': 'icon@2x.png', - - // iOS >= 7 App icon (required) iPhone - 'icon-60.png': 'icon-60.png', - 'icon-60-2x.png': 'icon-60@2x.png', - - // iOS <= 6.1 App icon (required) iPad - 'icon-72.png': 'icon-72.png', - 'icon-72-2x.png': 'icon-72@2x.png', - - // iOS 7 App icon (required) iPad - 'icon-76.png': 'icon-76.png', - 'icon-76-2x.png': 'icon-76@2x.png', - - // iOS Splash Screens - // 'screen-iphone-landscape.png': 'Default~iphone.png', - 'screen-ipad-portrait.png': 'Default-Portrait~ipad.png', - 'screen-ipad-portrait-2x.png': 'Default-Portrait@2x~ipad.png', - 'screen-ipad-landscape-2x.png': 'Default-Landscape@2x~ipad.png', - 'screen-ipad-landscape.png': 'Default-Landscape~ipad.png', - - // 'screen-ipad-portrait_ios6.png': 'Default-Portrait~ipad_ios6.png', - // 'screen-ipad-portrait-2x_ios6.png': 'Default-Portrait@2x~ipad_ios6.png', - // 'screen-ipad-landscape-2x_ios6.png': 'Default-Landscape@2x~ipad_ios6.png', - // 'screen-ipad-landscape_ios6.png': 'Default-Landscape~ipad_ios6.png', - - 'screen-iphone-portrait.png': 'Default~iphone.png', - 'screen-iphone-portrait-2x.png': 'Default@2x~iphone.png', - 'screen-iphone-portrait-568h-2x.png': 'Default-568h@2x~iphone.png', - } - }, - android: { - icon:'res/drawable-{$density}', - splash:'res/drawable-{$density}', - platformsDir: 'android', - nameMap: { - 'icon-36-ldpi.png': 'icon.png', - 'icon-48-mdpi.png': 'icon.png', - 'icon-72-hdpi.png': 'icon.png', - 'icon-96-xhdpi.png': 'icon.png', - 'screen-ldpi-portrait.png': 'ic_launcher.png', - 'screen-mdpi-portrait.png': 'ic_launcher.png', - 'screen-hdpi-portrait.png': 'ic_launcher.png', - 'screen-xhdpi-portrait.png': 'ic_launcher.png', - 'screen-ldpi-landscape.png': 'ic_launcher.png', - 'screen-mdpi-landscape.png': 'ic_launcher.png', - 'screen-hdpi-landscape.png': 'ic_launcher.png', - 'screen-xhdpi-landscape.png': 'ic_launcher.png' - } - }, - blackberry10: {}, - winphone: { - icon:'.', - splash:'.', - platformsDir: 'wp8', - nameMap: { - 'icon-62.png': 'ApplicationIcon.png', - 'tile-173.png': 'Background.png', - 'SplashScreenImage.png': 'SplashScreenImage.jpg', - 'screen-portrait-800h.jpg': 'SplashScreenImage.jpg' - } - } - }; - - function copyAsset (scope, node) { - - var platform = node.attrib['gap:platform']; - var density = node.attrib['gap:density']; - var assetDirTmpl = platformDir[platform] && platformDir[platform][scope]; - - if (!assetDirTmpl) { - throw new Error('Platform and density not supported: ' + platform + ', ' + density); - } - - var dict = { - projectName: projectConfig.name(), - density: density - }; - - var assetDir = assetDirTmpl.replace(/{\$([^}]+)}/, function (match, p1) { - return dict[p1]; - }); - - var srcPath = path.join(projectRoot, 'www', node.attrib.src); - var fileName = srcPath.match(/[^\/]+$/)[0]; - if (platformDir[platform] && platformDir[platform].nameMap && platformDir[platform].nameMap[fileName]) { - fileName = platformDir[platform].nameMap[fileName]; - } else { - throw new Error('Unknown icon name - '+fileName+' for platform ' + platform); - } - var dstPath = path.join(projectRoot, 'platforms', platform, assetDir, fileName); - - if (!fs.existsSync (dstPath)) { - console.warn ('template file ' + dstPath + ' does not exist and will not be replaced' ); - return; - } - - console.log ('copying from '+srcPath+' to the '+dstPath); - // so, here we start to copy asset - fs.stat (srcPath, function (err, stats) { - if (err) { - throw err; - } - var r = fs.createReadStream(srcPath); - r.on ('open', function () { - r.pause(); - var w = fs.createWriteStream(dstPath); - w.on ('open', function () { - r.pipe(w); - r.resume(); - }); - w.on ('error', function() { - throw new Error('Cannot write file'); - }); - }); - r.on ('error', function() { - throw new Error('Cannot read file'); - }); - }); - } - - var allicons = projectConfig.doc.findall('icon'); - if (allicons.length === 0 ) { - console.warn( 'No icons to install, missing icon specs in config.xml' ); - } else { - console.log( 'Update all icons for project: ' + projectConfig.name() ); - } - - allicons.map(function (node) { - if (/\/$/.test(node.attrib.src) && node.attrib['gap:platform'] === undefined && node.attrib['gap:density'] === undefined) { - - if (~projectPlatforms.indexOf('android')) { - // Android - copyAsset('icon', { attrib: { 'gap:platform': 'android', src: node.attrib.src + 'android/icon-36-ldpi.png', 'gap:density': 'ldpi' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'android', src: node.attrib.src + 'android/icon-48-mdpi.png', 'gap:density': 'mdpi' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'android', src: node.attrib.src + 'android/icon-72-hdpi.png', 'gap:density': 'hdpi' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'android', src: node.attrib.src + 'android/icon-96-xhdpi.png', 'gap:density': 'xhdpi' } }); - } - - if (~projectPlatforms.indexOf('ios')) { - // iOS >= 7 Settings icon - // iOS <= 6.1 Small icon for Spotlight search results and Settings (recommended) iPhone - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-29.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-29-2x.png' } }); - - // iOS >= 7 Spotlight search results icon (recommended) - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-40.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-40-2x.png' } }); - - // iOS <= 6.1 Small icon for Spotlight search results and Settings (recommended) iPad - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-50.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-50-2x.png' } }); - - // iOS <= 6.1 App icon (required) iPhone - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-57.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-57-2x.png' } }); - - // iOS >= 7 App icon (required) iPhone - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-60.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-60-2x.png' } }); - - // iOS <= 6.1 App icon (required) iPad - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-72.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-72-2x.png' } }); - - // iOS 7 App icon (required) iPad - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-76.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'ios', src: node.attrib.src + 'ios/icon-76-2x.png' } }); - } - - if (~projectPlatforms.indexOf('wp8')) { - copyAsset('icon', { attrib: { 'gap:platform': 'winphone', src: node.attrib.src + 'wp/icon-62.png' } }); - copyAsset('icon', { attrib: { 'gap:platform': 'winphone', src: node.attrib.src + 'wp/tile-173.png' } }); - } - - } else { - copyAsset ('icon', node); - } - }); - - projectConfig.doc.findall('*').filter(function (node) { - return (node.tag === 'gap:splash'); - }).map(function (node) { - copyAsset ('splash', node); - }); - -})(); \ No newline at end of file From 70fbb979363578b6e9e66851bc37feb1a972afe4 Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Thu, 14 Jul 2016 07:49:38 -0500 Subject: [PATCH 4/8] Add font compilation --- .gitignore | 15 ++++++++++++++- gulpfile.js | 14 ++++++++++++-- package.json | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b6318ae..3a88ce9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ +# Specifies intentionally untracked files to ignore when using Git +# http://git-scm.com/docs/gitignore + node_modules/ +plugins/ +resources/android +resources/ios + *.log .DS_Store @@ -7,4 +14,10 @@ www/js/* www/css/* www/img/* www/templates/* -www/index.html \ No newline at end of file +www/index.html +www/fonts/* +www/dist/* +platforms/android/assets +platforms/android/res +platforms/ios/**/Resources +coverage diff --git a/gulpfile.js b/gulpfile.js index 0ead502..d52e1f9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,6 +29,7 @@ var Q = require('q'); var source_paths = { sass: ['./app/scss/**/*.scss'], css: ['./app/scss/**/*.css'], + fonts: ['./app/fonts/*'], scripts: ['./app/js/**/*.js'], templates: ['./app/templates/**/*.html'], images: ['./app/img/**/*.*'], @@ -37,6 +38,7 @@ var source_paths = { // the destination paths var dest_paths = { css: './www/css/', + fonts: './www/fonts/', scripts: './www/js/', templates: './www/templates/', images: './www/img/', @@ -79,8 +81,15 @@ gulp.task('compile-css', function() { })) .pipe(rename({ extname: '.min.css' })) .pipe(gulp.dest(dest_paths.css)) - .pipe(connect.reload()); -}); + .pipe(connect.reload()) +}) + +gulp.task('compile-fonts', function () { + return gulp.src(source_paths.fonts) + .pipe(changed(dest_paths.fonts)) + .pipe(gulp.dest(dest_paths.fonts)) + .pipe(connect.reload()) +}) gulp.task('compile-scripts', function() { return gulp.src(source_paths.scripts) @@ -122,6 +131,7 @@ gulp.task('compile-all', [ 'compile-scripts', 'compile-sass', 'compile-css', + 'compile-fonts', 'compile-templates', 'compile-index', 'compile-images', diff --git a/package.json b/package.json index 0a8efaf..036dd0d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "gulp-open": "^0.2.8", "gulp-preprocess": "^1.0.1", "gulp-rename": "^1.2.0", - "gulp-sass": "^0.7.1", + "gulp-sass": ">=0.7.1", "gulp-tag-version": "^1.2.1", "gulp-util": "^2.2.14", "jshint-stylish": "^0.2.0", From 88f7370b72dbc5f707c65b35708b3de71259509d Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Thu, 14 Jul 2016 09:27:34 -0500 Subject: [PATCH 5/8] A bunch of misc updates. --- gulpfile.js | 530 +++++++++++++++++++++++++++++---------------------- package.json | 6 +- 2 files changed, 309 insertions(+), 227 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d52e1f9..0eb0d2c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,29 +1,36 @@ -var gulp = require('gulp'); -var gutil = require('gulp-util'); -var bower = require('bower'); -var concat = require('gulp-concat'); -var sass = require('gulp-sass'); -var minifyCss = require('gulp-minify-css'); -var rename = require('gulp-rename'); -var sh = require('shelljs'); -require('shelljs/global'); -var preprocess = require('gulp-preprocess'); -var runSequence = require('run-sequence'); -var argv = require('yargs').argv; -var jshint = require('gulp-jshint'); -var stylish = require('jshint-stylish'); -var changed = require('gulp-changed'); -var connect = require('gulp-connect'); -var open = require("gulp-open"); -var clean = require('gulp-clean'); -var rename = require("gulp-rename"); -var moment = require("moment"); -var bump = require('gulp-bump'); -var semver = require('semver'); -var git = require('gulp-git'); -var filter = require('gulp-filter'); -var tag_version = require('gulp-tag-version'); -var Q = require('q'); +var gulp = require('gulp') +var gutil = require('gulp-util') +var bower = require('bower') +var sass = require('gulp-sass') +var cleanCSS = require('gulp-clean-css') +var rename = require('gulp-rename') +require('shelljs/global') +var preprocess = require('gulp-preprocess') +var runSequence = require('run-sequence') +var argv = require('yargs').argv +var jshint = require('gulp-jshint') +var stylish = require('jshint-stylish') +var changed = require('gulp-changed') +var connect = require('gulp-connect') +var open = require('gulp-open') +var clean = require('gulp-clean') +var moment = require('moment') +var bump = require('gulp-bump') +var semver = require('semver') +var git = require('gulp-git') +var filter = require('gulp-filter') +var tag_version = require('gulp-tag-version') +var Q = require('q') +var browserify = require('browserify') +var source = require('vinyl-source-stream') +var buffer = require('vinyl-buffer') +var sourcemaps = require('gulp-sourcemaps') +var watchify = require('watchify') +var assign = require('lodash.assign') +var plumber = require('gulp-plumber') +var babel = require('gulp-babel') + +const ifaces = require('os').networkInterfaces() // the source paths var source_paths = { @@ -31,52 +38,71 @@ var source_paths = { css: ['./app/scss/**/*.css'], fonts: ['./app/fonts/*'], scripts: ['./app/js/**/*.js'], + bundle: './www/js/app.js', templates: ['./app/templates/**/*.html'], images: ['./app/img/**/*.*'], index_page: ['./app/index.html'] -}; +} // the destination paths var dest_paths = { css: './www/css/', fonts: './www/fonts/', scripts: './www/js/', + bundle: './www/dist/', templates: './www/templates/', images: './www/img/', index_page: './www/index.html', root: './www/', release_builds: './release_builds' -}; +} + +var lookupIpAddress = null +for (var dev in ifaces) { + if (dev !== 'en1' && dev !== 'en0' && dev !== 'en5') { + continue + } + ifaces[dev].forEach(function (details) { + if (details.family === 'IPv4') { + lookupIpAddress = details.address + } + }) +} +const ipAddress = lookupIpAddress +if (ipAddress === undefined) { + exit(1) +} // the options used by gulp-open when booting the test server var open_options = { - url: "http://localhost:8080" -}; + port: 8000, + host: 'http://localhost' +} gulp.task('default', function(){ - runSequence('compile', 'serve'); -}); + runSequence('compile', 'serve') +}) -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // COMPILATION TASKS -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// -gulp.task('compile-sass', function() { +gulp.task('compile-sass', function () { return gulp.src(source_paths.sass) .pipe(changed(dest_paths.css)) .pipe(sass()) .pipe(gulp.dest(dest_paths.css)) - .pipe(minifyCss({ + .pipe(cleanCSS({ keepSpecialComments: 0 })) .pipe(rename({ extname: '.min.css' })) .pipe(gulp.dest(dest_paths.css)) - .pipe(connect.reload()); -}); + .pipe(connect.reload()) +}) gulp.task('compile-css', function() { return gulp.src(source_paths.css) .pipe(changed(dest_paths.css)) .pipe(gulp.dest(dest_paths.css)) - .pipe(minifyCss({ + .pipe(cleanCSS({ keepSpecialComments: 0 })) .pipe(rename({ extname: '.min.css' })) @@ -91,36 +117,51 @@ gulp.task('compile-fonts', function () { .pipe(connect.reload()) }) -gulp.task('compile-scripts', function() { +gulp.task('copy-scripts', function () { return gulp.src(source_paths.scripts) .pipe(changed(dest_paths.scripts)) - .pipe(preprocess()) + .pipe(preprocess({ context: { IP_ADDRESS: ipAddress } })) .pipe(gulp.dest(dest_paths.scripts)) - .pipe(connect.reload()); -}); +}) + +gulp.task('browserify', ['copy-scripts'], function () { + return browserify(source_paths.bundle, { + debug: true, + transform: ['debowerify'] + }) + .external('angular') + .external('ionic') + .bundle().on('error', gutil.log) + .pipe(source('bundle.js')) + .pipe(gulp.dest(dest_paths.bundle)) +}) +gulp.task('compile-scripts', ['browserify'], function () { + return gulp.src(dest_paths.bundle) + .pipe(connect.reload()) +}) -gulp.task('compile-templates', function() { +gulp.task('compile-templates', function () { return gulp.src(source_paths.templates) .pipe(changed(dest_paths.templates)) .pipe(preprocess()) .pipe(gulp.dest(dest_paths.templates)) - .pipe(connect.reload()); -}); + .pipe(connect.reload()) +}) -gulp.task('compile-index', function() { +gulp.task('compile-index', function () { return gulp.src(source_paths.index_page) .pipe(changed(dest_paths.root)) .pipe(preprocess({context: {RELEASE: argv.release}})) .pipe(gulp.dest(dest_paths.root)) - .pipe(connect.reload()); -}); + .pipe(connect.reload()) +}) -gulp.task('compile-images', function() { +gulp.task('compile-images', function () { return gulp.src(source_paths.images) .pipe(changed(dest_paths.images)) .pipe(gulp.dest(dest_paths.images)) - .pipe(connect.reload()); -}); + .pipe(connect.reload()) +}) // compile resources (icons) gulp.task('compile-resources', function () { @@ -139,238 +180,275 @@ gulp.task('compile-all', [ ]) // compile everything after cleaning the build -gulp.task('compile', ['build-clean'], function(){ - var deferred = Q.defer(); +gulp.task('compile', ['build-clean'], function () { + var deferred = Q.defer() - runSequence('compile-all', function(){ - deferred.resolve(); - }); + runSequence('compile-all', function () { + deferred.resolve() + }) - return deferred.promise; -}); + return deferred.promise +}) -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // CLEAN TASKS -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// -gulp.task('clean-styles', function() { +gulp.task('clean-styles', function () { return gulp.src(dest_paths.css, {read: false}) - .pipe(clean({force: true})); -}); + .pipe(clean({force: true})) +}) -gulp.task('clean-images', function() { +gulp.task('clean-images', function () { return gulp.src(dest_paths.images, {read: false}) - .pipe(clean({force: true})); -}); + .pipe(clean({force: true})) +}) -gulp.task('clean-scripts', function() { +gulp.task('clean-scripts', function () { return gulp.src(dest_paths.scripts, {read: false}) - .pipe(clean({force: true})); -}); + .pipe(clean({force: true})) +}) -gulp.task('clean-templates', function() { +gulp.task('clean-templates', function () { return gulp.src(dest_paths.templates, {read: false}) .pipe(clean({force: true})) }) -gulp.task('clean-index', function() { +gulp.task('clean-index', function () { return gulp.src(dest_paths.index_page, {read: false}) - .pipe(clean({force: true})); -}); + .pipe(clean({force: true})) +}) -gulp.task('build-clean', ['clean-scripts', - 'clean-styles', - 'clean-templates', - 'clean-images', - 'clean-resources' - ]); +gulp.task('build-clean', [ + 'clean-scripts', + 'clean-styles', + 'clean-templates', + 'clean-images', +]) -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // WATCH TASKS -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// -gulp.task('watch-sass', function(){ - return gulp.watch(source_paths.sass, ['compile-sass']); -}); +gulp.task('watch-sass', function () { + return gulp.watch(source_paths.sass, ['compile-sass']) +}) -gulp.task('watch-css', function(){ - return gulp.watch(source_paths.css, ['compile-css']); -}); +gulp.task('watch-css', function () { + return gulp.watch(source_paths.css, ['compile-css']) +}) -gulp.task('watch-scripts', function(){ - return gulp.watch(source_paths.scripts, ['compile-scripts']); -}); +gulp.task('watch-fonts', function () { + return gulp.watch(source_paths.fonts, ['compile-fonts']) +}) +gulp.task('watch-scripts', function () { + return gulp.watch(source_paths.scripts, ['compile-scripts']) +}) -gulp.task('watch-templates', function(){ - return gulp.watch(source_paths.templates, ['compile-templates']); -}); +gulp.task('watch-templates', function () { + return gulp.watch(source_paths.templates, ['compile-templates']) +}) -gulp.task('watch-index_page', function(){ - return gulp.watch(source_paths.index_page, ['compile-index']); -}); +gulp.task('watch-index_page', function () { + return gulp.watch(source_paths.index_page, ['compile-index']) +}) -gulp.task('watch-images', function(){ - return gulp.watch(source_paths.images, ['compile-images']); -}); +gulp.task('watch-images', function () { + return gulp.watch(source_paths.images, ['compile-images']) +}) -gulp.task('watch', function() { +gulp.task('watch', function () { runSequence([ 'watch-sass', - 'watch-css', - 'watch-scripts', - 'watch-templates', - 'watch-index_page', - 'watch-images' - ]); -}); - -/////////////////////////////////////////////////////// + 'watch-css', + 'watch-scripts', + 'watch-templates', + 'watch-index_page', + 'watch-images' + ]) +}) + +// ///////////////////////////////////////////////////// // LOCAL SERVER TASKS -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // start a livereload-enable server after compiling // TODO: add 'compile' back as a dependency when sync/async issues fixed -gulp.task('run-server', [], function() { +gulp.task('run-server', [], function () { return connect.server({ root: 'www', + port: open_options.port, livereload: true - }); -}); + }) +}) // open browser after starting server -gulp.task('open-browser', ['run-server'], function() { - return gulp.src(dest_paths.root + "index.html") - .pipe(open("", open_options)); -}); +gulp.task('open-browser', ['run-server'], function () { + const url = open_options.host + ':' + open_options.port + return gulp.src(dest_paths.root + 'index.html') + .pipe(open('', {url: url})) +}) // compile then boot up the ionic site in a browser -gulp.task('serve', ['open-browser', 'watch']); +gulp.task('serve', ['open-browser', 'watch']) -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // BUILD TASKS -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // set the debuggable flag in the AndroidManifest.xml for release or debug // move the manifest file into the build path -gulp.task('process-android-build-config', function() { - if(!argv.android) { - return false; +gulp.task('process-android-build-config', function () { + if (!argv.android) { + return false } - var srcManifestFile = ['./lib/AndroidManifest.xml']; - var destManifestFile = './platforms/android/'; + var srcManifestFile = ['./lib/AndroidManifest.xml'] + var destManifestFile = './platforms/android/' return gulp.src(srcManifestFile) .pipe(preprocess({context: {RELEASE: argv.release}})) - .pipe(gulp.dest(destManifestFile)); -}); + .pipe(gulp.dest(destManifestFile)) +}) // build a debug native version after compiling // TODO: add 'compile' back as a dependency when sync/async issues fixed -gulp.task('build-debug', ['process-android-build-config'], function() { +gulp.task('build-debug', ['process-android-build-config'], function () { // do the ionic ios build - if(argv.ios) { + if (argv.ios) { if (exec('ionic build ios').code !== 0) { - echo('Error: iOS build failed'); - exit(1); + echo('Error: iOS build failed') + exit(1) } } // do the ionic android build - if(argv.android) { + if (argv.android) { if (exec('ionic build android').code !== 0) { - echo('Error: Android build failed'); - exit(1); + echo('Error: Android build failed') + exit(1) + } + } +}) + +// build for deploying to attached device +gulp.task('build-device', ['process-android-build-config'], function () { + // do the ionic ios build + if (argv.ios) { + if (exec('ionic build ios --device').code !== 0) { + echo('Error iOS device build failed') + exit(1) } } -}); +// FIXME: do android device build +}) // build a release native version after compiling // TODO: add 'compile' back as a dependency when sync/async issues fixed -gulp.task('build-release', ['process-android-build-config'], function() { +gulp.task('build-release', ['process-android-build-config'], function () { // remove the console plugin - exec("cordova plugin rm org.apache.cordova.console"); + exec('cordova plugin rm org.apache.cordova.console') // do the ionic ios build - if(argv.ios) { + if (argv.ios) { if (exec('cordova build --release ios').code !== 0) { - echo('Error: iOS build failed'); - exit(1); + echo('Error: iOS build failed') + exit(1) } } // do the ionic android build - if(argv.android) { + if (argv.android) { // clean the android build folders: gulp.src('./platforms/android/ant-build/', {read: false}) - .pipe(clean({force: true})); + .pipe(clean({force: true})) gulp.src('./platforms/android/ant-gen/', {read: false}) - .pipe(clean({force: true})); + .pipe(clean({force: true})) gulp.src('./platforms/android/out/', {read: false}) - .pipe(clean({force: true})); + .pipe(clean({force: true})) if (exec('cordova build --release android').code !== 0) { - echo('Error: Android build failed'); - exit(1); - } - else { + echo('Error: Android build failed') + exit(1) + } else { // copy the release output to release-builds/ // TODO: change the below to match your expected release filename return gulp.src(['./platforms/android/ant-build/release.apk']) - .pipe(rename(function (path) { - // see https://github.com/hparra/gulp-rename for info on rename fields - path.basename += moment().format('MMDDYYYY-hhmmss'); - })) - // do any other processing needed - .pipe(gulp.dest(dest_paths.release_builds)); + .pipe(rename(function (path) { + // see https://github.com/hparra/gulp-rename for info on rename fields + path.basename += moment().format('MMDDYYYY-hhmmss') + })) + // do any other processing needed + .pipe(gulp.dest(dest_paths.release_builds)) } } - // re-add the console plugin - // exec("cordova plugin add org.apache.cordova.console"); -}); +// re-add the console plugin +// exec("cordova plugin add org.apache.cordova.console") +}) // fire up the emulator, depending on what flags passed -gulp.task('run-emulator', function() { +gulp.task('run-emulator', function () { // should we trigger the emulator? - if(!argv.run) { - return false; + if (!argv.run) { + return false } // start the ios emulator - if(argv.ios) { + if (argv.ios) { if (exec('ionic emulate ios').code !== 0) { - echo('Error: iOS run failed'); - exit(1); + echo('Error: iOS run failed') + exit(1) } } // start the android emulator - if(argv.android) { + if (argv.android) { if (exec('ionic emulate android').code !== 0) { - echo('Error: Android run failed'); - exit(1); + echo('Error: Android run failed') + exit(1) } } -}); +}) -gulp.task('build', function() { - // are we building a debug or release version? - if(argv.release) { - runSequence('build-release', 'run-emulator'); +// deploy to a device, if 'device' given +gulp.task('run-device', function () { + // should we trigger the device? + if (!argv.run) { + return false } - else { - runSequence('build-debug', 'run-emulator'); + + // deploy to connected IOS device + if (argv.ios) { + if (exec('ios-deploy --debug --bundle platforms/ios/build/device/IPED.app --no-wifi').code !== 0) { + echo('Error: ios device run failed') + exit(1) + } + } + +// FIXME: figure out for android +}) + +gulp.task('build', function () { + // are we building a debug or release version? + // force a compile so any important changes (BUILD_TARGET, say) + // will be correct in deployed files + if (argv.release) { + runSequence('compile', 'build-release', 'run-emulator') + } else if (argv.device) { + runSequence('compile', 'build-device', 'run-device') + } else { + runSequence('compile', 'build-debug', 'run-emulator') } -}); +}) -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // MISC TASKS -/////////////////////////////////////////////////////// +// ///////////////////////////////////////////////////// // used for bumping versions and getting the version info // `fs` is used instead of require to prevent caching in watch (require caches) -var fs = require('fs'); +var fs = require('fs') var getPackageJson = function () { - return JSON.parse(fs.readFileSync('./package.json', 'utf8')); -}; + return JSON.parse(fs.readFileSync('./package.json', 'utf8')) +} /** * Bumping version number and tagging the repository with it. @@ -394,75 +472,75 @@ var getPackageJson = function () { * To bump the version numbers accordingly after you did a patch, * introduced a feature or made a backwards-incompatible release. */ -function inc(importance) { - var deferred = Q.defer(); +function inc (importance) { + var deferred = Q.defer() // reget package - var pkg = getPackageJson(); + var pkg = getPackageJson() // get existing version - var oldVer = pkg.version; + var oldVer = pkg.version // increment version - var newVer = semver.inc(oldVer, importance); + var newVer = semver.inc(oldVer, importance) // json filter - var jsonFilter = filter('**/*.json'); + var jsonFilter = filter('**/*.json') // TODO: change /platforms/ios/project/ in the below to match your Cordova project name // bump the version number in the xml config files - replacement = 'sed -i \'\' -e \'s/version=\"'+ oldVer + '\"/version=\"' + newVer + '\"/\' ./config.xml' - exec(replacement); - replacement2 = 'sed -i \'\' -e \'s/version=\"'+ oldVer + '\"/version=\"' + newVer + '\"/\' ./platforms/ios/project/config.xml' - exec(replacement2); - replacement3 = 'sed -i \'\' -e \'s/android:versionName=\"'+ oldVer + '\"/android:versionName=\"' + newVer + '\"/\' ./lib/AndroidManifest.xml' - exec(replacement3); + replacement = 'sed -i \'\' -e \'s/version="' + oldVer + '"/version="' + newVer + '"/\' ./config.xml' + exec(replacement) + replacement2 = 'sed -i \'\' -e \'s/version="' + oldVer + '"/version="' + newVer + '"/\' ./platforms/ios/project/config.xml' + exec(replacement2) + replacement3 = 'sed -i \'\' -e \'s/android:versionName="' + oldVer + '"/android:versionName="' + newVer + '"/\' ./lib/AndroidManifest.xml' + exec(replacement3) // get all the files to bump version in gulp.src(['./package.json', './bower.json', './config.xml', './platforms/ios/project/config.xml', './lib/AndroidManifest.xml']) - // filter only the json files - .pipe(jsonFilter) - // bump the version number in the json files - .pipe(bump({version: newVer})) - // save json files back to filesystem - .pipe(gulp.dest('./')) - // restore full stream - .pipe(jsonFilter.restore()) - // commit the changed version number - .pipe(git.commit('bump app version to ' + newVer)) - // read only one file to get the version number - .pipe(filter('package.json')) - // **tag it in the repository** - .pipe(tag_version()); - - return deferred.promise; + // filter only the json files + .pipe(jsonFilter) + // bump the version number in the json files + .pipe(bump({version: newVer})) + // save json files back to filesystem + .pipe(gulp.dest('./')) + // restore full stream + .pipe(jsonFilter.restore()) + // commit the changed version number + .pipe(git.commit('bump app version to ' + newVer)) + // read only one file to get the version number + .pipe(filter('package.json')) + // **tag it in the repository** + .pipe(tag_version()) + + return deferred.promise } -gulp.task('patch', function() { return inc('patch'); }) -gulp.task('feature', function() { return inc('minor'); }) -gulp.task('release', function() { return inc('major'); }) -gulp.task('prerelease', function() { return inc('prerelease'); }) +gulp.task('patch', function () { return inc('patch'); }) +gulp.task('feature', function () { return inc('minor'); }) +gulp.task('release', function () { return inc('major'); }) +gulp.task('prerelease', function () { return inc('prerelease'); }) // run source scripts through JSHint -gulp.task('lint', function() { +gulp.task('lint', function () { return gulp.src(source_paths.scripts) .pipe(jshint()) - .pipe(jshint.reporter(stylish)); -}); + .pipe(jshint.reporter(stylish)) +}) -gulp.task('install', ['git-check'], function() { +gulp.task('install', ['git-check'], function () { return bower.commands.install() - .on('log', function(data) { - gutil.log('bower', gutil.colors.cyan(data.id), data.message); - }); -}); + .on('log', function (data) { + gutil.log('bower', gutil.colors.cyan(data.id), data.message) + }) +}) -gulp.task('git-check', function(done) { +gulp.task('git-check', function (done) { if (!which('git')) { console.log( ' ' + gutil.colors.red('Git is not installed.'), '\n Git, the version control system, is required to download Ionic.', '\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.', - '\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.' - ); - process.exit(1); + "\n Once git is installed, run '" + gutil.colors.cyan('gulp install') + "' again." + ) + process.exit(1) } - done(); -}); \ No newline at end of file + done() +}) diff --git a/package.json b/package.json index 036dd0d..dc45d4f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,11 @@ "name": "ionic-project", "version": "1.0.0", "description": "An Ionic project", - "dependencies": {}, + "dependencies": { + "cordova": "^6.0.0", + "cordova-lib": "^6.0.0", + "gulp": "^3.9.1" + }, "devDependencies": { "bower": "^1.3.3", "gulp": "^3.5.6", From 347d49dd9019755443802833b45bd0406fd14827 Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Thu, 14 Jul 2016 12:25:12 -0500 Subject: [PATCH 6/8] Convert to use browserify and require() for angular stuff --- app/index.html | 7 +--- app/js/app.js | 58 ++++++++++++++------------- app/js/controllers.js | 4 +- app/js/controllers/ApplicationCtrl.js | 11 ++++- app/js/services.js | 3 +- app/js/services/Session.js | 6 ++- app/templates/login.html | 1 + gulpfile.js | 5 +-- package.json | 13 +++++- 9 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 app/templates/login.html diff --git a/app/index.html b/app/index.html index 97f87c2..8a17f12 100644 --- a/app/index.html +++ b/app/index.html @@ -21,12 +21,6 @@ - - - - - - + diff --git a/app/js/app.js b/app/js/app.js index b37163c..78143ef 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -1,42 +1,46 @@ // angular.module is a global place for creating, registering and retrieving Angular modules // 'buildTools' is the name of this angular module example (also set in a attribute in index.html) // the 2nd parameter is an array of 'requires' -var buildTools = angular.module('BuildTools', [ 'ionic', - 'BuildTools.config', - 'BuildTools.controllers', - 'BuildTools.services' - ]); +// + +require('./controllers.js') +require('./services.js') + +var buildTools = angular.module('BuildTools', [ 'ionic', + 'BuildTools.config', + 'BuildTools.controllers', + 'BuildTools.services' +]) buildTools.run(function ($ionicPlatform) { - $ionicPlatform.ready(function() { + $ionicPlatform.ready(function () { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) - if(window.cordova && window.cordova.plugins.Keyboard) { - cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); + if (window.cordova && window.cordova.plugins.Keyboard) { + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true) } - if(window.StatusBar) { + if (window.StatusBar) { // org.apache.cordova.statusbar required - StatusBar.styleDefault(); + StatusBar.styleDefault() } - }); + }) }) -// Configure Ionic -.config(function($stateProvider, $urlRouterProvider) { - - // Ionic uses AngularUI Router which uses the concept of states - // Learn more here: https://github.com/angular-ui/ui-router - // Set up the various states which the app can be in. - // Each state's controller can be found in controllers.js - $stateProvider + // Configure Ionic + .config(function ($stateProvider, $urlRouterProvider) { + // Ionic uses AngularUI Router which uses the concept of states + // Learn more here: https://github.com/angular-ui/ui-router + // Set up the various states which the app can be in. + // Each state's controller can be found in controllers.js + $stateProvider - .state('login', { - url: "/login", - templateUrl: "templates/login.html", - controller: 'LoginCtrl' - }) + .state('login', { + url: '/login', + templateUrl: 'templates/login.html', + controller: 'LoginCtrl' + }) - // if none of the above states are matched, use this as the fallback - $urlRouterProvider.otherwise("/login"); + // if none of the above states are matched, use this as the fallback + $urlRouterProvider.otherwise('/login') -}); + }) diff --git a/app/js/controllers.js b/app/js/controllers.js index 0b2a290..671750b 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2,4 +2,6 @@ * See controllers/ for the individual Controller definitions */ -var buildToolsCtrl = angular.module('BuildTools.controllers', ['ionic', 'BuildTools.config']); +module.exports = angular.module('BuildTools.controllers', ['ionic', 'BuildTools.config']) + .controller('ApplicationCtrl', require('./controllers/ApplicationCtrl')) + .controller('LoginCtrl', require('./controllers/LoginCtrl')) diff --git a/app/js/controllers/ApplicationCtrl.js b/app/js/controllers/ApplicationCtrl.js index 5d678b7..d0046df 100644 --- a/app/js/controllers/ApplicationCtrl.js +++ b/app/js/controllers/ApplicationCtrl.js @@ -1,4 +1,11 @@ -buildToolsCtrl.controller('ApplicationCtrl', function($scope, Config) { +function ApplicationCtrl ($scope, Config) { // your code here + var foo = (a) => a + 1 -}); \ No newline at end of file + var bar = foo(3) + + console.log('bar:', bar) + +} + +module.exports = ['$scope', 'Config', ApplicationCtrl] diff --git a/app/js/services.js b/app/js/services.js index 80052d5..201ef66 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -2,4 +2,5 @@ * See services/ for the individual Service definitions. */ -var buildToolsServices = angular.module('BuildTools.services', ['BuildTools.config']); +module.exports = angular.module('BuildTools.services', ['BuildTools.config']) + .service('SessionService', require('./services/Session')) diff --git a/app/js/services/Session.js b/app/js/services/Session.js index 2559d71..64d4347 100644 --- a/app/js/services/Session.js +++ b/app/js/services/Session.js @@ -1,3 +1,5 @@ -buildToolsServices.service('Session', function () { +function SessionService () { // your code here -}); \ No newline at end of file +} + +module.exports = [SessionService] diff --git a/app/templates/login.html b/app/templates/login.html new file mode 100644 index 0000000..535ae76 --- /dev/null +++ b/app/templates/login.html @@ -0,0 +1 @@ +
This is the login page.
diff --git a/gulpfile.js b/gulpfile.js index 0eb0d2c..5cf8397 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -26,7 +26,6 @@ var source = require('vinyl-source-stream') var buffer = require('vinyl-buffer') var sourcemaps = require('gulp-sourcemaps') var watchify = require('watchify') -var assign = require('lodash.assign') var plumber = require('gulp-plumber') var babel = require('gulp-babel') @@ -77,7 +76,7 @@ var open_options = { host: 'http://localhost' } -gulp.task('default', function(){ +gulp.task('default', function () { runSequence('compile', 'serve') }) @@ -98,7 +97,7 @@ gulp.task('compile-sass', function () { .pipe(connect.reload()) }) -gulp.task('compile-css', function() { +gulp.task('compile-css', function () { return gulp.src(source_paths.css) .pipe(changed(dest_paths.css)) .pipe(gulp.dest(dest_paths.css)) diff --git a/package.json b/package.json index dc45d4f..407f136 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,19 @@ "dependencies": { "cordova": "^6.0.0", "cordova-lib": "^6.0.0", - "gulp": "^3.9.1" + "debowerify": "^1.5.0", + "gulp": "^3.9.1", + "lodash": "^4.13.1", + "ng-cordova": "^0.1.27-alpha" }, "devDependencies": { "bower": "^1.3.3", "gulp": "^3.5.6", + "gulp-babel": "^6.1.2", "gulp-bump": "^0.3.0", "gulp-changed": "^0.3.0", "gulp-clean": "^0.3.1", + "gulp-clean-css": "^2.0.11", "gulp-concat": "^2.2.0", "gulp-connect": "^2.0.5", "gulp-filter": "^2.0.2", @@ -20,17 +25,23 @@ "gulp-jshint": "^1.6.1", "gulp-minify-css": "^0.3.0", "gulp-open": "^0.2.8", + "gulp-plumber": "^1.1.0", "gulp-preprocess": "^1.0.1", "gulp-rename": "^1.2.0", "gulp-sass": ">=0.7.1", + "gulp-sourcemaps": "^1.6.0", "gulp-tag-version": "^1.2.1", "gulp-util": "^2.2.14", "jshint-stylish": "^0.2.0", + "lodash": "^4.13.1", "moment": "^2.10.2", "q": "^1.3.0", "run-sequence": "^0.3.6", "semver": "^4.3.3", "shelljs": "^0.3.0", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0", + "watchify": "^3.7.0", "yargs": "^1.2.2" } } From 8da02942b57a02bb740e572d70ff3c921fd42ede Mon Sep 17 00:00:00 2001 From: Andrew Schamp Date: Fri, 15 Jul 2016 07:27:04 -0500 Subject: [PATCH 7/8] Got rid of bower I think --- app/index.html | 4 +--- app/js/app.js | 14 ++++++++++++- app/js/controllers/LoginCtrl.js | 11 +++++++++++ app/scss/ionic.app.scss | 4 ++-- bower.json | 8 -------- gulpfile.js | 5 ++--- package.json | 35 ++++++++++++++++++++++++++++----- 7 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 app/js/controllers/LoginCtrl.js delete mode 100644 bower.json diff --git a/app/index.html b/app/index.html index 8a17f12..305051e 100644 --- a/app/index.html +++ b/app/index.html @@ -13,14 +13,12 @@ - + - -