555
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

6 anos atrás
5 anos atrás
6 anos atrás
5 anos atrás
6 anos atrás
6 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
6 anos atrás
5 anos atrás
6 anos atrás
5 anos atrás
6 anos atrás
5 anos atrás
6 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. 
  2. // --------------
  3. // elxr
  4. // A cli tool for elixr.
  5. const { spawn } = require('child_process');
  6. const cliargs = require('../elxr/cliargs'); // Use minimist...
  7. const processedArgs = cliargs(process.argv.slice(2));
  8. console.dir(processedArgs)
  9. var cli = 'elxr';
  10. var ver = '#unversioned';
  11. var help = '#unkown list of commands... please refer dveloper documentation for ' + cli;
  12. // grep -qxF 'alias elxr="node elxr/index.js"' ~/.bash_profile || echo 'alias elxr="node elxr/index.js"' >> ~/.bash_profile
  13. // nodeShellExec('echo', ['elxr'], { inherit : true}) //, {stdio: "inherit"}
  14. var dbForLabel = function(label){
  15. var dbsForLabel = {
  16. devmysql : 'mysql'
  17. , development : 'mssql'
  18. , production : 'mssql'
  19. }
  20. return dbsForLabel[label] || 'mysql'
  21. }
  22. var __runcmd = function(label){
  23. var op = {
  24. 'h' : ()=>{ console.log(cli + ' ' + ver + ' ' + help); return '-h' }
  25. , 'start' : (label)=>{
  26. console.log('Starting Elixir Server.');
  27. var env = Object.assign({}, process.env); // Shallow clone it.
  28. // console.dir(env)
  29. env.NODE_ENV = label;
  30. env.DEBUG = 'loopback:connector:' + dbForLabel(label)
  31. nodeShellExec('node', ['--inspect=9228', 'sage-rw/server.js'], {
  32. inherit : true,
  33. shell: true, detached: true,
  34. cwd : 'loopback',
  35. env: env,
  36. shell : true
  37. })
  38. nodeShellExec('node', ['--inspect=9227', 'sage-r/server.js'], {
  39. inherit : true,
  40. shell: true, detached: true,
  41. cwd : 'loopback',
  42. env: env,
  43. shell : true
  44. })
  45. // nodeShellExec('node', ['--inspect=9226', ' bin/www'], {
  46. // inherit : true,
  47. // shell: true, detached: true,
  48. // cwd : 'qms/server',
  49. // env: env,
  50. // shell : true
  51. // })
  52. nodeShellExec('ember', ['s'], {
  53. inherit : true,
  54. shell: true, detached: true,
  55. cwd : 'qms/',
  56. env: env,
  57. shell : true
  58. })
  59. }
  60. , 'g' : ()=>{
  61. if(processedArgs.h) {
  62. console.log('elxr g [modelname] => generate a model named [modelname]');
  63. console.log('elxr g => regenerate all known models');
  64. return
  65. }
  66. // var child = nodeShellExec('mkdir', ['-p', label], { inherit : true} );
  67. // console.log('Starting directory: ' + process.cwd());
  68. // try {
  69. // child = child.on('close', () => { process.chdir(label) } );
  70. // console.log('New directory: ' + process.cwd());
  71. // }
  72. // catch (err) {
  73. // console.log('chdir: ' + err);
  74. // }
  75. // child.on('close', function(){
  76. // var options = {
  77. // shell : true
  78. // , inherit : true
  79. // // , cwd : '' + process.cwd
  80. // // , env : process.env
  81. // };
  82. // nodeShellExec('git', ['init'], { inherit : true});
  83. nodeShellExec('pwd', { inherit : true});
  84. //$ "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1" http://localhost:4200/tests/index.html?grep=loopback
  85. nodeShellExec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", [
  86. "--profile-directory=Profile 1"
  87. , 'http://localhost:4200/tests/index.html?grep=model convert ember to loopback' + '&filter=none' /*+ '&filter=model convert ember to loopback'*/]);
  88. // nodeShellExec('npm', ['init', '-y'], options);
  89. // nodeShellExec('npm', ['init', '-y'], options);
  90. // })
  91. }
  92. }
  93. return op[label] ? op[label]() : op['start'](label);
  94. }
  95. // mysqldump --add-drop-table --no-data -u root -p db_name | grep 'DROP TABLE' ) > drop_all_tables.sql
  96. // mysql -u root -p db_name < drop_all_tables.sql
  97. var mysql = '../xampp/mysql/bin/mysql'
  98. var mysqldump = '../xampp/mysql/bin/mysqldump'
  99. __runcmd(processedArgs.label || processedArgs._[0] || 'h');
  100. // nodeShellExec('git', ['status']);
  101. function nodeShellExec() {
  102. const child = spawn(...arguments);
  103. // use child.stdout.setEncoding('utf8'); if you want text chunks
  104. child.stdout.setEncoding('utf8');
  105. // console.log('here')
  106. child.stdout.on('data', (chunk) => console.log(chunk));
  107. child.on('error', (chunk) => console.error(chunk));
  108. child.stderr.pipe(process.stderr);
  109. child.on('close', (code) => console.log(`child process ${Array.from(arguments)[0]} exited with code ${code}`));
  110. return child;
  111. }