docs(config): update demo for config, add more logs for app-scripts

closes #9413
This commit is contained in:
Brandy Carney
2017-01-19 13:17:11 -05:00
parent 4f7de63b9a
commit f06398215c
3 changed files with 27 additions and 18 deletions

View File

@ -3,21 +3,21 @@ import { Config, IonicApp, IonicModule, Platform, NavController } from '../../io
if (!window.localStorage) { if (!window.localStorage) {
Object.defineProperty(window, 'localStorage', new (function () { Object.defineProperty(window, 'localStorage', new (function () {
var aKeys = [], oStorage = {}; var aKeys: any[] = [], oStorage = {};
Object.defineProperty(oStorage, 'getItem', { Object.defineProperty(oStorage, 'getItem', {
value: function (sKey) { return sKey ? this[sKey] : null; }, value: function (sKey: number) { return sKey ? this[sKey] : null; },
writable: false, writable: false,
configurable: false, configurable: false,
enumerable: false enumerable: false
}); });
Object.defineProperty(oStorage, 'key', { Object.defineProperty(oStorage, 'key', {
value: function (nKeyId) { return aKeys[nKeyId]; }, value: function (nKeyId: number) { return aKeys[nKeyId]; },
writable: false, writable: false,
configurable: false, configurable: false,
enumerable: false enumerable: false
}); });
Object.defineProperty(oStorage, 'setItem', { Object.defineProperty(oStorage, 'setItem', {
value: function (sKey, sValue) { value: function (sKey: string, sValue: string) {
if (!sKey) { return; } if (!sKey) { return; }
document.cookie = encodeURI(sKey) + '=' + encodeURI(sValue) + '; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/'; document.cookie = encodeURI(sKey) + '=' + encodeURI(sValue) + '; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/';
}, },
@ -31,7 +31,7 @@ if (!window.localStorage) {
enumerable: false enumerable: false
}); });
Object.defineProperty(oStorage, 'removeItem', { Object.defineProperty(oStorage, 'removeItem', {
value: function (sKey) { value: function (sKey: string) {
if (!sKey) { return; } if (!sKey) { return; }
document.cookie = encodeURI(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; document.cookie = encodeURI(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
}, },
@ -40,21 +40,21 @@ if (!window.localStorage) {
enumerable: false enumerable: false
}); });
this.get = function () { this.get = function () {
var iThisIndx; var iThisIndx: number;
for (var sKey in oStorage) { for (var sKey in oStorage) {
iThisIndx = aKeys.indexOf(sKey); iThisIndx = aKeys.indexOf(sKey);
if (iThisIndx === -1) { if (iThisIndx === -1) {
(oStorage as any).setItem(sKey, oStorage[sKey]); (oStorage as any).setItem(sKey, (oStorage as any)[sKey]);
} else { } else {
aKeys.splice(iThisIndx, 1); aKeys.splice(iThisIndx, 1);
} }
delete oStorage[sKey]; delete (oStorage as any)[sKey];
} }
for (aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { (oStorage as any).removeItem(aKeys[0]); } for (aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { (oStorage as any).removeItem(aKeys[0]); }
for (var aCouple, iKey, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) { for (var aCouple: any, iKey: any, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) {
aCouple = aCouples[nIdx].split(/\s*=\s*/); aCouple = aCouples[nIdx].split(/\s*=\s*/);
if (aCouple.length > 1) { if (aCouple.length > 1) {
oStorage[iKey = decodeURI(aCouple[0])] = decodeURI(aCouple[1]); (oStorage as any)[iKey = decodeURI(aCouple[0])] = decodeURI(aCouple[1]);
aKeys.push(iKey); aKeys.push(iKey);
} }
} }
@ -62,10 +62,10 @@ if (!window.localStorage) {
}; };
this.configurable = false; this.configurable = false;
this.enumerable = true; this.enumerable = true;
})()); } as any)());
} }
var CONFIG_DEMO = null; var CONFIG_DEMO: any = null;
if (window.localStorage.getItem('configDemo')) { if (window.localStorage.getItem('configDemo')) {
CONFIG_DEMO = JSON.parse(window.localStorage.getItem('configDemo')); CONFIG_DEMO = JSON.parse(window.localStorage.getItem('configDemo'));
@ -88,6 +88,7 @@ export class ApiDemoPage {
initialConfig: any; initialConfig: any;
constructor(_config: Config, public navCtrl: NavController) { constructor(_config: Config, public navCtrl: NavController) {
this.config = _config.settings(); this.config = _config.settings();
this.initialConfig = this.config;
} }

View File

@ -46,15 +46,20 @@
</button> </button>
</div> </div>
<p class="note">Any config for your app should be passed as the third argument to ionicBootstrap.</p> <p class="note">Any config for your app should be passed as the second argument to <code>IonicModule.forRoot()</code>.</p>
<!-- this has to be formatted weird for pre --> <!-- this has to be formatted weird for pre -->
<pre margin> <pre margin>
<!--ionicBootstrap(MyApp, [], { &#64;NgModule(&#123;
backButtonIcon: "{{initialConfig.backButtonIcon}}" imports: [
iconMode: "{{initialConfig.iconMode}}" IonicModule.forRoot(MyApp, &#123;
tabsPlacement: "{{initialConfig.tabsPlacement}}" backButtonIcon: "{{initialConfig?.backButtonIcon}}"
});--></pre> iconMode: "{{initialConfig?.iconMode}}"
tabsPlacement: "{{initialConfig?.tabsPlacement}}"
&#125;)
]
&#125;)
</pre>
<div padding> <div padding>
<button ion-button block color="secondary" (click)="push()"> <button ion-button block color="secondary" (click)="push()">

View File

@ -196,10 +196,13 @@ export function runAppScripts(folderInfo: any, sassConfigPath: string, appEntryP
scriptArgs.push('--debug'); scriptArgs.push('--debug');
} }
console.log('$ ionic-app-scripts', scriptArgs.join(' '));
try { try {
const scriptsCmd = spawnSync('ionic-app-scripts', scriptArgs); const scriptsCmd = spawnSync('ionic-app-scripts', scriptArgs);
if (scriptsCmd.status !== 0) { if (scriptsCmd.status !== 0) {
console.log(scriptsCmd.stderr.toString());
return Promise.reject(scriptsCmd.stderr.toString()); return Promise.reject(scriptsCmd.stderr.toString());
} }