UNPKG

3.8 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 .action(async (options) => {
28 // Make sure we are logged in.
29 if (utils.checkStatus('npm whoami') !== 0) {
30 console.error('Please run `npm login`');
31 }
32 const distDir = './dist';
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 else {
39 // Still clean the dist directory.
40 if (fs.existsSync(distDir)) {
41 fs.removeSync(distDir);
42 }
43 }
44 // Publish JS to the appropriate tag.
45 const curr = utils.getPythonVersion();
46 if (curr.indexOf('rc') === -1 && curr.indexOf('a') === -1) {
47 utils.run('lerna publish from-package -m "Publish"');
48 }
49 else {
50 utils.run('lerna publish from-package --npm-tag=next -m "Publish"');
51 }
52 // Fix up any tagging issues.
53 const basePath = path.resolve('.');
54 const paths = utils.getLernaPaths(basePath).sort();
55 const cmds = await Promise.all(paths.map(update_dist_tag_1.handlePackage));
56 cmds.forEach(cmdList => {
57 cmdList.forEach(cmd => {
58 utils.run(cmd);
59 });
60 });
61 // Update core mode. This cannot be done until the JS packages are
62 // released.
63 utils.run('node buildutils/lib/update-core-mode.js');
64 // Make the Python release.
65 utils.run('python setup.py sdist');
66 utils.run('python setup.py bdist_wheel');
67 utils.run('python -m pip install -U twine');
68 utils.run('twine check dist/*');
69 const files = fs.readdirSync(distDir);
70 const hashes = new Map();
71 files.forEach(file => {
72 const shasum = crypto.createHash('sha256');
73 const hash = shasum.update(fs.readFileSync(path.join(distDir, file)));
74 hashes.set(file, hash.digest('hex'));
75 });
76 const hashString = Array.from(hashes.entries())
77 .map(entry => `${entry[0]}: ${entry[1]}`)
78 .join('" -m "');
79 // Make the commit and the tag.
80 utils.run(`git commit -am "Publish ${curr}" -m "SHA256 hashes:" -m "${hashString}"`);
81 utils.run(`git tag v${curr}`);
82 // Prompt the user to finalize.
83 console.debug('*'.repeat(40));
84 console.debug('*'.repeat(40));
85 console.debug('Ready to publish!');
86 console.debug('Run these command when ready:');
87 console.debug('twine upload dist/*');
88 console.debug('git push origin <BRANCH> --tags');
89 // Emit a system beep.
90 process.stdout.write('\x07');
91});
92commander_1.default.parse(process.argv);
93//# sourceMappingURL=publish.js.map
\No newline at end of file