UNPKG

3.73 kBJavaScriptView Raw
1"use strict";
2/*-----------------------------------------------------------------------------
3| Copyright (c) Jupyter Development Team.
4| Distributed under the terms of the Modified BSD License.
5|----------------------------------------------------------------------------*/
6var __importDefault = (this && this.__importDefault) || function (mod) {
7 return (mod && mod.__esModule) ? mod : { "default": mod };
8};
9var __importStar = (this && this.__importStar) || function (mod) {
10 if (mod && mod.__esModule) return mod;
11 var result = {};
12 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
13 result["default"] = mod;
14 return result;
15};
16Object.defineProperty(exports, "__esModule", { value: true });
17const commander_1 = __importDefault(require("commander"));
18const crypto = __importStar(require("crypto"));
19const fs = __importStar(require("fs-extra"));
20const path = __importStar(require("path"));
21const update_dist_tag_1 = require("./update-dist-tag");
22const utils = __importStar(require("./utils"));
23// Specify the program signature.
24commander_1.default
25 .description('Publish the JS packages and prep the Python package')
26 .option('--skip-build', 'Skip the clean and build step (if there was a network error during a JS publish)')
27 .option('--skip-publish', 'Skip the npm publish step (if there was an error during the python build process)')
28 .action(async (options) => {
29 // Make sure we are logged in.
30 if (utils.checkStatus('npm whoami') !== 0) {
31 console.error('Please run `npm login`');
32 }
33 // Optionally clean and build the python packages.
34 if (!options.skipBuild) {
35 // Ensure a clean state.
36 utils.run('npm run clean:slate');
37 }
38 const curr = utils.getPythonVersion();
39 if (!options.skipPublish) {
40 // Publish JS to the appropriate tag.
41 if (curr.indexOf('rc') === -1 && curr.indexOf('a') === -1) {
42 utils.run('lerna publish from-package -m "Publish"');
43 }
44 else {
45 utils.run('lerna publish from-package --npm-tag=next -m "Publish"');
46 }
47 // Fix up any tagging issues.
48 const basePath = path.resolve('.');
49 const paths = utils.getLernaPaths(basePath).sort();
50 const cmds = await Promise.all(paths.map(update_dist_tag_1.handlePackage));
51 cmds.forEach(cmdList => {
52 cmdList.forEach(cmd => {
53 utils.run(cmd);
54 });
55 });
56 }
57 // Update core mode. This cannot be done until the JS packages are
58 // released.
59 utils.run('node buildutils/lib/update-core-mode.js');
60 // Make the Python release.
61 utils.run('python setup.py sdist');
62 utils.run('python setup.py bdist_wheel');
63 utils.run('python -m pip install -U twine');
64 utils.run('twine check dist/*');
65 const files = fs.readdirSync('./dist/');
66 const hashes = new Map();
67 files.forEach(file => {
68 const shasum = crypto.createHash('sha256');
69 const hash = shasum.update(fs.readFileSync('./dist/' + file));
70 hashes.set(file, hash.digest('hex'));
71 });
72 const hashString = Array.from(hashes.entries())
73 .map(entry => `${entry[0]}: ${entry[1]}`)
74 .join('" -m "');
75 // Prompt the user to finalize.
76 console.log('*'.repeat(40));
77 console.log('*'.repeat(40));
78 console.log('Ready to publish!');
79 console.log('Run these command when ready:');
80 console.log(`git commit -am "Publish ${curr}" -m "SHA256 hashes:" -m "${hashString}"`);
81 console.log(`git tag v${curr}`);
82 console.log('twine upload dist/*');
83 console.log('git push origin <BRANCH> --tags');
84});
85commander_1.default.parse(process.argv);
86//# sourceMappingURL=publish.js.map
\No newline at end of file