publish.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* -----------------------------------------------------------------------------
  2. | Copyright (c) Jupyter Development Team.
  3. | Distributed under the terms of the Modified BSD License.
  4. |----------------------------------------------------------------------------*/
  5. import commander from 'commander';
  6. import * as path from 'path';
  7. import { handlePackage } from './update-dist-tag';
  8. import * as utils from './utils';
  9. // Specify the program signature.
  10. commander
  11. .description('Publish the JS packages')
  12. .option(
  13. '--skip-build',
  14. 'Skip the clean and build step (if there was a network error during a JS publish'
  15. )
  16. .option('--dry-run', 'Do not actually push any assets')
  17. .action(async (options: any) => {
  18. if (!options.skipBuild) {
  19. utils.run('jlpm run build:packages');
  20. }
  21. if (!options.dryRun) {
  22. // Make sure we are logged in.
  23. if (utils.checkStatus('npm whoami') !== 0) {
  24. console.error('Please run `npm login`');
  25. }
  26. }
  27. // Publish JS to the appropriate tag.
  28. const curr = utils.getPythonVersion();
  29. let cmd = 'lerna publish from-package ';
  30. if (options.dryRun) {
  31. cmd += '--no-git-tag-version --no-push ';
  32. }
  33. if (curr.indexOf('rc') === -1 && curr.indexOf('a') === -1) {
  34. utils.run(`${cmd} -m "Publish"`);
  35. } else {
  36. utils.run(`${cmd} --dist-tag=next -m "Publish"`);
  37. }
  38. // Fix up any tagging issues.
  39. const basePath = path.resolve('.');
  40. const paths = utils.getLernaPaths(basePath).sort();
  41. const cmds = await Promise.all(paths.map(handlePackage));
  42. cmds.forEach(cmdList => {
  43. cmdList.forEach(cmd => {
  44. if (!options.dryRun) {
  45. utils.run(cmd);
  46. } else {
  47. throw new Error(`Tag is out of sync: ${cmd}`);
  48. }
  49. });
  50. });
  51. // Emit a system beep.
  52. process.stdout.write('\x07');
  53. });
  54. commander.parse(process.argv);