From 77df01f92d78153fb9df902a798451e1c048934f Mon Sep 17 00:00:00 2001 From: Sidney Bofah Date: Mon, 26 Jan 2015 08:59:25 +0100 Subject: [PATCH] FMigrated from diegonetto's custom starter templates to the official Ionic templates. This involves some regex magic, but works for the current versions. Goal should be to build the head of index.html 100% from scratch, or creating pull requests on the official Ionic templates for reliable script insertion points. --- app/index.js | 33 +++++++++++++++++++++++++-------- utils/starters.js | 6 +++--- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/index.js b/app/index.js index adf769c..69cccce 100644 --- a/app/index.js +++ b/app/index.js @@ -76,7 +76,7 @@ module.exports = generators.Base.extend({ this.prompt([{ type: 'list', name: 'starter', - message: 'Which starter template [T] or example app [A] would you like to use?', + message: 'Which starter template would you like to use?', choices: _.pluck(ionicUtils.starters.templates, 'name'), default: defaultIndex }], function (props) { @@ -160,7 +160,10 @@ module.exports = generators.Base.extend({ if (error) { done(error); } - remote.directory('app', 'app'); + + // Template remote initialization: Copy from remote root folder (.) to working directory (/app) + remote.directory('.', 'app'); + this.starterCache = remote.cachePath; done(); }.bind(this); @@ -182,9 +185,10 @@ module.exports = generators.Base.extend({ appJs: function appJs() { var appPath = path.join(process.cwd(), 'app'); - var scriptPrefix = 'scripts' + path.sep; + var scriptPrefix = 'js' + path.sep; var scripts = [scriptPrefix + 'config.js']; + this.fs.store.each(function (file, index) { if (file.path.indexOf('.js') !== -1) { @@ -195,12 +199,25 @@ module.exports = generators.Base.extend({ } }); - this.indexFile = this.appendScripts(this.indexFile, 'scripts/scripts.js', scripts); + //this.indexFile = this.appendScripts(this.indexFile, 'scripts/scripts.js', scripts); }, createIndexHtml: function createIndexHtml() { - this.indexFile = this.indexFile.replace(/'/g, "'"); - this.write(path.join(this.appPath, 'index.html'), this.indexFile); + + // Regex: CSS + this.indexFile = this.indexFile.replace(/lib\/ionic\/css/g,"bower_components\/ionic/release\/css"); + + // Regex: Third party scripts (vendor.js) + this.indexFile = this.indexFile.replace(/