You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.9 KiB

  1. /*******************************
  2. Register PM
  3. *******************************/
  4. /*
  5. Task to register component repos with Package Managers
  6. * Registers component with bower
  7. * Registers component with NPM
  8. */
  9. let
  10. // node dependencies
  11. process = require('child_process'),
  12. fs = require('fs'),
  13. npmPublish = require('@jsdevtools/npm-publish'),
  14. // config
  15. release = require('../config/admin/release'),
  16. config = fs.existsSync(__dirname + '/../config/admin/oauth.js')
  17. ? require('../config/admin/oauth')
  18. : false,
  19. // register components and distributions
  20. repos = release.distributions.concat(release.components),
  21. total = repos.length,
  22. index = -1,
  23. stream,
  24. stepRepo
  25. ;
  26. module.exports = async function(callback) {
  27. console.log('Publishing main repo');
  28. await npmPublish({
  29. package: `./package.json`,
  30. token: config.npmToken,
  31. greaterVersionOnly: true,
  32. debug: function(log) {
  33. console.log(log);
  34. }
  35. });
  36. // Do Git commands synchronously per component, to avoid issues
  37. stepRepo = async function() {
  38. index = index + 1;
  39. if(index >= total) {
  40. callback();
  41. return;
  42. }
  43. let
  44. repo = repos[index].toLowerCase(),
  45. outputDirectory = `${release.outputRoot}${repo}/`,
  46. exec = process.exec,
  47. execSettings = {cwd: outputDirectory},
  48. updateNPM = 'meteor publish;'
  49. ;
  50. /* Register with NPM */
  51. console.info(`NPM Publish "${repo}"`);
  52. console.info(outputDirectory);
  53. await npmPublish({
  54. package: `${outputDirectory}/package.json`,
  55. token: config.npmToken,
  56. greaterVersionOnly: true,
  57. debug: function(log) {
  58. console.log(log);
  59. }
  60. });
  61. /* Register with NPM */
  62. console.info(`Meteor publish "${repo}"`);
  63. console.info(outputDirectory);
  64. exec(updateNPM, execSettings, function(err, stdout, stderr) {
  65. console.log(err, stdout, stderr);
  66. stepRepo();
  67. });
  68. };
  69. stepRepo();
  70. };