atomic-cli.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env node
  2. "use strict";
  3. // https://github.com/yeoman/update-notifier
  4. // https://github.com/tj/commander.js
  5. var path = require("path");
  6. var program = require('commander');
  7. var cli = require("atomic-cli")
  8. var open = require("open");
  9. var prompt = require('prompt');
  10. prompt.message = "";
  11. prompt.delimiter = "";
  12. program
  13. .version('0.0.1')
  14. .parse(process.argv);
  15. // activation command
  16. program
  17. .command('activate')
  18. .description('activate')
  19. .action(function(folder){
  20. prompt.start();
  21. prompt.get([ { description: 'Please confirm EULA agreement (Y)es, (N)o, or (V)iew', default: "Y", name: "eulaconfirm" }], function (err, result) {
  22. var eulaconfirm = result.eulaconfirm.toLowerCase();
  23. if (eulaconfirm == 'y') {
  24. prompt.get([ { description: 'Please enter Product Key or (G)et free key: ', name: "productkey" }], function (err, result) {
  25. var productkey = result.productkey.toLowerCase();
  26. if (productkey == 'g') {
  27. console.log ("Opening Atomic Store in default browser window");
  28. open("https://store.atomicgameengine.com/site");
  29. } else {
  30. cli.activate(productkey);
  31. }
  32. });
  33. } else if (eulaconfirm == 'v') {
  34. console.log ("Opening EULA in default browser window");
  35. open("https://github.com/AtomicGameEngine/AtomicGameEngine/blob/master/LICENSE.md");
  36. }
  37. });
  38. });
  39. // deactivation
  40. program
  41. .command('deactivate')
  42. .description('deactivates and returns a product activation to the server')
  43. .action(function(){
  44. cli.deactivate();
  45. });
  46. // new project command
  47. program
  48. .command('new <folder>')
  49. .description('creates a new project in the specified folder')
  50. .action(function(folder){
  51. cli.newProject(folder)
  52. .then(function () {
  53. console.log("New Atomic project created in " + path.resolve(folder));
  54. })
  55. .catch(function (error) {
  56. console.error("Error: Could not create " + path.resolve(folder));
  57. process.exit(1);
  58. });
  59. });
  60. program
  61. .command('add <platform>')
  62. .description('adds a platform to the project')
  63. .action(function(platform){
  64. cli.addPlatform(platform)
  65. .then(function () {
  66. })
  67. .catch(function (error) {
  68. process.exit(1);
  69. });
  70. });
  71. program
  72. .command('run <platform> [no-build]')
  73. .description('runs the project on a specified platform')
  74. .action(function(platform){
  75. cli.run(platform)
  76. .then(function () {
  77. })
  78. .catch(function (error) {
  79. process.exit(1);
  80. });
  81. });
  82. program
  83. .command('edit [path-to-project]')
  84. .description('edits the project in the cwd or on at a specified path')
  85. .action(function(options){
  86. cli.atomiceditor(["-project", process.cwd()], {output:true});
  87. });
  88. program.parse(process.argv);
  89. if (!program.args.length) program.help();