patch-release.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*-----------------------------------------------------------------------------
  2. | Copyright (c) Jupyter Development Team.
  3. | Distributed under the terms of the Modified BSD License.
  4. |----------------------------------------------------------------------------*/
  5. import * as fs from 'fs-extra';
  6. import * as path from 'path';
  7. import * as utils from './utils';
  8. import { publish, prepublish } from './publish';
  9. // Make sure we have required command line arguments.
  10. if (process.argv.length < 3) {
  11. let msg = '** Must supply a target package';
  12. process.stderr.write(msg);
  13. process.exit(1);
  14. }
  15. prepublish();
  16. // Extract the desired package target(s).
  17. process.argv.slice(2).forEach(target => {
  18. let packagePath = path.resolve(path.join('packages', target));
  19. if (!fs.existsSync(packagePath)) {
  20. console.log('Invalid package path', packagePath);
  21. process.exit(1);
  22. }
  23. // Perform the patch operations.
  24. console.log('Patching', target, '...');
  25. utils.run('npm version patch', { cwd: packagePath });
  26. utils.run('npm publish', { cwd: packagePath });
  27. // Extract the new package info.
  28. let data = utils.readJSONFile(path.join(packagePath, 'package.json'));
  29. let name = data.name;
  30. let version = data.version;
  31. // Make the release commit
  32. utils.run('git commit -a -m "Release ' + name + '@' + version + '"');
  33. utils.run('git tag ' + name + '@' + version);
  34. });
  35. // Patch the python version
  36. // Ensure bump2version is installed (active fork of bumpversion)
  37. utils.run('python -m pip install bump2version');
  38. utils.run('bumpversion patch'); // switches to alpha
  39. utils.run('bumpversion release'); // switches to rc
  40. utils.run('bumpversion release'); // switches to final.
  41. // Publish the python package.
  42. publish();