Permalink
Browse files

modify template

  • Loading branch information...
1 parent e4e197d commit 4935b460df85690e93c80af05d093667d5a51d73 binchen committed Jan 11, 2013
Showing with 110 additions and 92 deletions.
  1. +25 −0 .gitignore
  2. +2 −0 .npmignore
  3. +71 −52 tasks/init/mojito.js
  4. +12 −40 tasks/init/mojito/root/Gruntfile.js
View
@@ -0,0 +1,25 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
+
+# OS generated files #
+ ######################
+.DS_Store
+.DS_Store?
+
+# WebStrom generated files #
+######################
+.idea
+.idea?
View
@@ -0,0 +1,2 @@
+artifacts/
+/node_modules/
View
@@ -1,10 +1,3 @@
-/*
- * grunt-init
- * https://gruntjs.com/
- *
- * Copyright (c) 2012 "Cowboy" Ben Alman, contributors
- * Licensed under the MIT license.
- */
var join = require('path').join;
var child_process = require('child_process');
'use strict';
@@ -14,69 +7,95 @@ exports.description = 'Create mojito project.';
// Template-specific notes to be displayed before question prompts.
exports.notes = 'This template tries to guess file and directory paths, ' +
- 'but you will most likely need to edit the generated Gruntfile.js file before running grunt. '.red +
- '_If you run grunt after generating the Gruntfile, and ' +
- 'it exits with errors, edit the file!_';
+ 'but you will most likely need to edit the generated Gruntfile.js file before running grunt. '.blue;
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = '';
// The actual init template.
exports.template = function (grunt, init, done) {
- init.process({}, [
- // Prompt for these values.
- {
- name:'app_name',
- message:'your app name?',
- default:'mojito_demo',
- warning:''
- },
- {
- name:'type',
- message:'"app", "mojit", or "custom".?',
- default:'app',
- warning:''
- },
- {
- name:'archetype',
- message:'optional template. Possible values are default, full, simple' +
- '"app" types also have a "hybrid" archetype which creates an app and a' +
- 'mojit with common configurations for use with hybrid app. ' +
- 'If the type is "custom" then this is the path to your own archetype' +
- 'directory.?',
- default:'hybrid',
- warning:''
+ var props = {};
+ var mojito_version = grunt.option('mojitoversion');
+ var name = grunt.option('name');
+ var type = grunt.option('type');
+ var archetype = grunt.option('archetype');
+
+
+ if ((typeof name === 'string') && (typeof type === 'string')) {
+ if (!(typeof archetype === 'string')) {
+ archetype = '';
}
- ], function (err, props) {
- child_process.exec(grunt.runtime.getMojito() + " create " + props.type + " " + props.archetype + " " + props.app_name, function (err, stdout, stderr) {
+ props.mojito_version = mojito_version;
+ props.app_name = name;
+ props.type = type;
+ props.archetype = archetype;
+
+ mojitoCreate(grunt.runtime.getMojito(mojito_version), props);
+ } else {
+ init.process({}, [
+ // Prompt for these values.
+ {
+ name:'mojito_version',
+ message:'mojito version?',
+ default:'0.4',
+ warning:''
+ },
+ {
+ name:'app_name',
+ message:'your app name?',
+ default:'mojitodemo',
+ warning:''
+ },
+ {
+ name:'type',
+ message:'"app", "mojit", or "custom".?',
+ default:'app',
+ warning:''
+ },
+ {
+ name:'archetype',
+ message:'optional template. Possible values are default, full, simple' +
+ '"app" types also have a "hybrid" archetype which creates an app and a' +
+ 'mojit with common configurations for use with hybrid app. ' +
+ 'If the type is "custom" then this is the path to your own archetype' +
+ 'directory.?',
+ default:'hybrid',
+ warning:''
+ }
+ ], function (err, props) {
+ mojitoCreate(grunt.runtime.getMojito(props.mojito_version), props);
+ });
+ }
+
+ function mojitoCreate(mojitoPath, props) {
+ child_process.exec(mojitoPath + " create " + props.type + " " + props.archetype + " " + props.app_name, function (err, stdout, stderr) {
if (err) {
grunt.log.error(stderr);
} else {
grunt.log.success(stdout);
- // Files to copy (and process).
- var files = init.filesToCopy(props);
- Object.prototype.renameProperty = function (oldName, newName) {
- // Check for the old property name to avoid a ReferenceError in strict mode.
- if (this.hasOwnProperty(oldName)) {
- this[newName] = this[oldName];
- delete this[oldName];
+ if (props.type === 'app') {
+ // Files to copy (and process).
+ var files = init.filesToCopy(props);
+ Object.prototype.renameProperty = function (oldName, newName) {
+ // Check for the old property name to avoid a ReferenceError in strict mode.
+ if (this.hasOwnProperty(oldName)) {
+ this[newName] = this[oldName];
+ delete this[oldName];
+ }
+ return this;
+ };
+ for (var key in files) {
+ files.renameProperty(key, join(props.app_name, key));
}
- return this;
- };
- for (var key in files) {
- files.renameProperty(key, join(props.app_name, key));
+ // Actually copy (and process) files.
+ init.copyAndProcess(files, props);
}
- // Actually copy (and process) files.
- init.copyAndProcess(files, props);
-
// All done!
done();
}
});
-
-//
- });
+ }
};
@@ -1,77 +1,49 @@
module.exports = function (grunt) {
'use strict';
- // Grunt configuration:
-
grunt.initConfig({
- // Project configuration
- // ---------------------
- // specify mojito configuration
-
mojito:{
- context:'build:debug'
- //release flow if version and snapshotTag is setted
- //version:'1.0.0',
- //snapshotTag:'tag'
+ context:'build:debug',
+ version:'{%= mojito_version %}'
+
},
- //Specify for remote debugger. Instrument file list and settings.
+
debug:{
- serverHost:'localhost',
- serverPort:8080,
- wserverPort:8080,
- fileServerPort:8050,
+ remoteDebug:true,
+ liveEdit:true,
+ httpPort:8000,
instrument:{
- instrumentDir:'artifacts/builds/hybridapp',
instrumentIgnoreDir:['mojito'],
instrumentIgnoreFileRegex:["^mojito.*\.js$", "^LazyLoad.*\.js$", "loader.*\.js"]
}
},
- //specify pakcages to be add to maitai repository, for multi-pakcage used. Reserved.
push:{
packages:[]
},
- //specify arguments for rt
rt:{
iconfile:'',
devorship:'dev',
- simordev:'simulator'//determin the localhost or internet IP
-
- //host:'', //maitail server host
- //port:'', //maitail server port
- //initialtime:'',
- //RT initial waiting time
- //frequency:''
- //RT query maitai frequency.
+ simordev:'simulator'
},
package:{
- iossdk:'iphonesimulator6.0',
-
+ iossdk:'6.0',
apilevel:14
},
launch:{
- //ios
- devicefamily:'iphone', //launch simulator type
- //android. Will remove after setting up avd manager
- avdport:5554,
- device:'avd'
+ devicefamily:'iphone'
},
- //For screwdriver. Reserved.
+
ci:{
svn:'',
branch:''
},
- //For manhattan. Reserved.
+
deploy:{
appfolder:[],
instancename:''
}
});
-
- // Alias the `default` task to run `build:ios` task instead
- // User can manual schedule task
- grunt.registerTask('default', 'build:ios');
-
};

0 comments on commit 4935b46

Please sign in to comment.