Skip to content

Commit 964857c

Browse files
committed
Support for starting from creator projects
1 parent d4ff8d7 commit 964857c

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

lib/ionic/start.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ IonicTask.WRAPPER_REPO_NAME = 'ionic-app-base';
2222

2323
IonicTask.DEFAULT_APP = {
2424
"plugins": [
25-
"org.apache.cordova.device@0.2.12",
26-
"org.apache.cordova.console@0.2.11",
27-
"com.ionic.keyboard@1.0.3"
25+
"org.apache.cordova.device",
26+
"org.apache.cordova.console",
27+
"com.ionic.keyboard"
2828
],
2929
"sass": false
3030
};
@@ -167,6 +167,11 @@ IonicTask.prototype.fetchSeed = function() {
167167
return this.fetchCodepen();
168168
}
169169

170+
if( /creator:/i.test(this.template) ) {
171+
this.seedType = 'creator';
172+
return this.fetchCreatorApp();
173+
}
174+
170175
// Github URL: http://github.com/myrepo/
171176
if( /\/\/github.com\//i.test(this.template) ) {
172177
this.seedType = 'github';
@@ -205,6 +210,32 @@ IonicTask.prototype.loadAppSetup = function() {
205210
};
206211

207212

213+
IonicTask.prototype.fetchCreatorApp = function() {
214+
var self = this;
215+
var appId = this.template.split(':')[1];
216+
var downloadUrl = Ionic.IONIC_DASH + path.join('/api/v1/creator', appId, 'download/html');
217+
var wwwPath = path.join(this.targetPath, 'www');
218+
219+
console.log('\nDownloading Creator Prototype:'.bold, downloadUrl);
220+
221+
var q = Q.defer();
222+
223+
var proxy = process.env.PROXY || null;
224+
225+
request({ url: downloadUrl, proxy: proxy }, function(err, res, html) {
226+
if(!err && res && res.statusCode === 200) {
227+
//html = self.convertTemplates(html);
228+
229+
fs.writeFileSync(path.join(wwwPath, 'index.html'), html, 'utf8');
230+
} else {
231+
console.log('Unable to fetch', err, res.statusCode);
232+
q.reject(res);
233+
}
234+
q.resolve();
235+
});
236+
return Q.all([q]);
237+
};
238+
208239
IonicTask.prototype.fetchCodepen = function() {
209240
var self = this;
210241
var codepenUrl = this.template.split('?')[0].split('#')[0];

0 commit comments

Comments
 (0)