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 | .action(async (options) => {
|
28 |
|
29 | if (utils.checkStatus('npm whoami') !== 0) {
|
30 | console.error('Please run `npm login`');
|
31 | }
|
32 | const distDir = './dist';
|
33 |
|
34 | if (!options.skipBuild) {
|
35 |
|
36 | utils.run('npm run clean:slate');
|
37 | }
|
38 | else {
|
39 |
|
40 | if (fs.existsSync(distDir)) {
|
41 | fs.removeSync(distDir);
|
42 | }
|
43 | }
|
44 |
|
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 |
|
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 |
|
62 |
|
63 | utils.run('node buildutils/lib/update-core-mode.js');
|
64 |
|
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 |
|
80 | utils.run(`git commit -am "Publish ${curr}" -m "SHA256 hashes:" -m "${hashString}"`);
|
81 | utils.run(`git tag v${curr}`);
|
82 |
|
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 |
|
90 | process.stdout.write('\x07');
|
91 | });
|
92 | commander_1.default.parse(process.argv);
|
93 |
|
\ | No newline at end of file |