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 utils = __importStar(require("./utils"));
|
19 |
|
20 | commander_1.default
|
21 | .description('Update the version and publish')
|
22 | .option('--dry-run', 'Dry run')
|
23 | .option('--force', 'Force the upgrade')
|
24 | .arguments('<spec>')
|
25 | .action((spec, opts) => {
|
26 |
|
27 | const prev = utils.getPythonVersion();
|
28 |
|
29 | const options = ['major', 'minor', 'release', 'build'];
|
30 | if (options.indexOf(spec) === -1) {
|
31 | throw new Error(`Version spec must be one of: ${options}`);
|
32 | }
|
33 | if (prev.indexOf('a') === -1 &&
|
34 | prev.indexOf('b') === -1 &&
|
35 | prev.indexOf('rc') === -1 &&
|
36 | spec === 'release') {
|
37 | throw new Error('Use "major" or "minor" to switch back to alpha release');
|
38 | }
|
39 | if (prev.indexOf('a') === -1 &&
|
40 | prev.indexOf('b') === -1 &&
|
41 | prev.indexOf('rc') === -1 &&
|
42 | spec === 'build') {
|
43 | throw new Error('Cannot increment a build on a final release');
|
44 | }
|
45 |
|
46 | utils.prebump();
|
47 |
|
48 | if (opts.dryRun) {
|
49 | utils.run(`bumpversion --dry-run --verbose ${spec}`);
|
50 | return;
|
51 | }
|
52 |
|
53 |
|
54 | if (prev.indexOf('a') !== -1 && spec === 'major') {
|
55 |
|
56 | utils.run(`bumpversion ${spec}`);
|
57 |
|
58 | utils.postbump();
|
59 | return;
|
60 | }
|
61 |
|
62 | let lernaVersion = 'preminor';
|
63 | if (spec === 'build') {
|
64 | lernaVersion = 'prerelease';
|
65 |
|
66 | }
|
67 | else if (spec === 'release' && prev.indexOf('a') !== -1) {
|
68 | lernaVersion = 'prerelease --preid=beta';
|
69 |
|
70 | }
|
71 | else if (spec === 'release' && prev.indexOf('b') !== -1) {
|
72 | lernaVersion = 'prerelease --preid=rc';
|
73 |
|
74 | }
|
75 | else if (spec === 'release' && prev.indexOf('rc') !== -1) {
|
76 | lernaVersion = 'patch';
|
77 | }
|
78 | if (lernaVersion === 'preminor') {
|
79 | lernaVersion += ' --preid=alpha';
|
80 | }
|
81 | let cmd = `lerna version -m \"New version\" --force-publish=* --no-push ${lernaVersion}`;
|
82 | if (opts.force) {
|
83 | cmd += ' --yes';
|
84 | }
|
85 | const oldVersion = utils.run('git rev-parse HEAD', {
|
86 | stdio: 'pipe',
|
87 | encoding: 'utf8'
|
88 | }, true);
|
89 |
|
90 |
|
91 |
|
92 | if (lernaVersion === 'preminor') {
|
93 | for (let i = 0; i < 10; i++) {
|
94 | utils.run(cmd);
|
95 | }
|
96 | }
|
97 | else {
|
98 | utils.run(cmd);
|
99 | }
|
100 | const newVersion = utils.run('git rev-parse HEAD', {
|
101 | stdio: 'pipe',
|
102 | encoding: 'utf8'
|
103 | }, true);
|
104 | if (oldVersion === newVersion) {
|
105 |
|
106 | throw new Error('Lerna aborted');
|
107 | }
|
108 |
|
109 | utils.run(`bumpversion ${spec}`);
|
110 |
|
111 | utils.postbump();
|
112 | });
|
113 | commander_1.default.parse(process.argv);
|
114 |
|
\ | No newline at end of file |