patch-release.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // Make sure we have required command line arguments.
  9. if (process.argv.length < 3) {
  10. let msg = '** Must supply a target package';
  11. process.stderr.write(msg);
  12. process.exit(1);
  13. }
  14. // Extract the desired package target.
  15. let target = process.argv[2];
  16. let packagePath = path.resolve(path.join('packages', target));
  17. if (!fs.existsSync(packagePath)) {
  18. console.log('Invalid package path', packagePath);
  19. process.exit(1);
  20. }
  21. // Perform the patch operations.
  22. console.log('Patching', target, '...');
  23. // Use npm here so this file can be used outside of JupyterLab.
  24. utils.run('npm run build:packages');
  25. utils.run('npm version patch', { cwd: packagePath });
  26. utils.run('npm publish', { cwd: packagePath});
  27. // Update the static folder.
  28. utils.run('npm run build:update');
  29. // Extract the new package info.
  30. let data = utils.readJSONFile(path.join(packagePath, 'package.json'));
  31. let name = data.name;
  32. let version = data.version;
  33. utils.run('npm run integrity');
  34. utils.run('git commit -a -m "Release ' + name + '@' + version + '"');
  35. utils.run('git tag ' + name + '@' + version);
  36. console.log('\n\nFinished, make sure to push the commit and the tag.');