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('rc') === -1 &&
|
35 | spec === 'release') {
|
36 | throw new Error('Use "major" or "minor" to switch back to alpha release');
|
37 | }
|
38 | if (prev.indexOf('a') === -1 &&
|
39 | prev.indexOf('rc') === -1 &&
|
40 | spec === 'build') {
|
41 | throw new Error('Cannot increment a build on a final release');
|
42 | }
|
43 |
|
44 | utils.prebump();
|
45 |
|
46 | if (opts.dryRun) {
|
47 | utils.run(`bumpversion --dry-run --verbose ${spec}`);
|
48 | return;
|
49 | }
|
50 |
|
51 |
|
52 | if (prev.indexOf('a') !== -1 && spec === 'major') {
|
53 |
|
54 | utils.run(`bumpversion ${spec}`);
|
55 |
|
56 | utils.postbump();
|
57 | return;
|
58 | }
|
59 |
|
60 | let lernaVersion = 'preminor';
|
61 | if (spec === 'build') {
|
62 | lernaVersion = 'prerelease';
|
63 |
|
64 | }
|
65 | else if (spec === 'release' && prev.indexOf('a') !== -1) {
|
66 | lernaVersion = 'prerelease --preid=rc';
|
67 |
|
68 | }
|
69 | else if (spec === 'release' && prev.indexOf('rc') !== -1) {
|
70 | lernaVersion = 'patch';
|
71 | }
|
72 | let cmd = `lerna version -m \"New version\" --force-publish=* --no-push ${lernaVersion}`;
|
73 | if (opts.force) {
|
74 | cmd += ' --yes';
|
75 | }
|
76 | let oldVersion = utils.run('git rev-parse HEAD', {
|
77 | stdio: 'pipe',
|
78 | encoding: 'utf8'
|
79 | }, true);
|
80 | utils.run(cmd);
|
81 | let newVersion = utils.run('git rev-parse HEAD', {
|
82 | stdio: 'pipe',
|
83 | encoding: 'utf8'
|
84 | }, true);
|
85 | if (oldVersion === newVersion) {
|
86 |
|
87 | throw new Error('Lerna aborted');
|
88 | }
|
89 |
|
90 | utils.run(`bumpversion ${spec}`);
|
91 |
|
92 | utils.postbump();
|
93 | });
|
94 | commander_1.default.parse(process.argv);
|
95 |
|
\ | No newline at end of file |