Commits

Rich Manalang [Atlassian] committed 137d0f5

Added support for templates

  • Participants
  • Parent commits ba65e77

Comments (0)

Files changed (4)

File bin/atlas-connect

 
 switch(cmd){
   case "new":
-    generateScaffold(params[0],function(err){
+    generateScaffold(params[0], argv.t, function(err){
       if (!err)
         generateKeys(path.join(process.cwd(),params[0]));
       else

File bin/generator.js

   , ProgressBar = require('progress');
 
 
-exports = module.exports = function(name, cb){
+exports = module.exports = function(name, template, cb){
   var dlUrl = "https://bitbucket.org/atlassian/atlassian-connect-express-template/get/master.zip";
+  if(!template) {
+    template = "default";
+  }
+  switch(template){
+    case "default":
+      break;
+    case "hipchat":
+      dlUrl = "https://bitbucket.org/atlassian/atlassian-connect-express-template/get/"+template+".zip";
+      break;
+    default:
+      console.log(render('template-not-found',{template: template}));
+      return;
+  }
 
   https.get(dlUrl, function(res){
     var data = [], dataLen = 0;
       dataLen += chunk.length;
       bar.tick(chunk.length);
     }).on('end', function(){
+      if (res.statusCode == 404) {
+
+        return;
+      }
       var buf = new Buffer(dataLen);
 
       for (var i=0, len = data.length, pos = 0; i < len; i++) {

File templates/template-not-found.hbs

+{{#red}}The {{#bold}}{{template}}{{/bold}} template doesn't exist. You can choose one of the following templates:
+
+    default  -  Choose this if you're building a JIRA or Confluence Connect add-on.
+                This is the default.
+    hipchat  -  Choose this if you're building a HipChat Connect add-on.
+{{/red}}

File templates/usage.hbs

 
 The most commonly used atlas-connect commands are:
     keygen      Generate public and private RSA keys
-    new         Generate a new Atlassian Connect Add-on scaffold
+    new         Generate a new Atlassian Connect Add-on scaffold. Optionally,
+                pass in the --template (or -t) flag to specify a template.
+                For example, {{#bold}}atlas-connect new -t hipchat my-hipchat-addon{{/bold}}