1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
7 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
8 | };
|
9 | var __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 | };
|
16 | Object.defineProperty(exports, "__esModule", { value: true });
|
17 | const commander_1 = __importDefault(require("commander"));
|
18 | const crypto = __importStar(require("crypto"));
|
19 | const fs = __importStar(require("fs-extra"));
|
20 | const path = __importStar(require("path"));
|
21 | const update_dist_tag_1 = require("./update-dist-tag");
|
22 | const utils = __importStar(require("./utils"));
|
23 |
|
24 | commander_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 |
|
30 | if (utils.checkStatus('npm whoami') !== 0) {
|
31 | console.error('Please run `npm login`');
|
32 | }
|
33 |
|
34 | if (!options.skipBuild) {
|
35 |
|
36 | utils.run('npm run clean:slate');
|
37 | }
|
38 | const curr = utils.getPythonVersion();
|
39 | if (!options.skipPublish) {
|
40 |
|
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 |
|
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 |
|
58 |
|
59 | utils.run('node buildutils/lib/update-core-mode.js');
|
60 |
|
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 |
|
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 | });
|
85 | commander_1.default.parse(process.argv);
|
86 |
|
\ | No newline at end of file |