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 semver_1 = __importDefault(require("semver"));
|
19 | const path_1 = __importDefault(require("path"));
|
20 | const utils = __importStar(require("./utils"));
|
21 |
|
22 |
|
23 |
|
24 | function getDeps(pkgName, lut) {
|
25 | const deps = new Set();
|
26 | for (const name in lut) {
|
27 | if ('@jupyterlab/' + pkgName in lut[name]) {
|
28 | const otherName = name.replace('@jupyterlab/', '');
|
29 | deps.add(otherName);
|
30 | const otherDeps = getDeps(otherName, lut);
|
31 | otherDeps.forEach(dep => {
|
32 | deps.add(dep);
|
33 | });
|
34 | }
|
35 | }
|
36 | return deps;
|
37 | }
|
38 | exports.getDeps = getDeps;
|
39 |
|
40 | commander_1.default
|
41 | .description('Bump the major version of JS package(s)')
|
42 | .arguments('<package> [others...]')
|
43 | .option('--force', 'Force the upgrade')
|
44 | .option('--dry-run', 'Show what would be executed')
|
45 | .action((pkg, others, options) => {
|
46 | others.push(pkg);
|
47 | const toBump = new Set();
|
48 | const ignoreBump = new Set();
|
49 | const maybeBump = (pkg) => {
|
50 | if (pkg in toBump || pkg in ignoreBump) {
|
51 | return;
|
52 | }
|
53 | const version = utils.getJSVersion(pkg);
|
54 | if (semver_1.default.minor(version) === 0 && semver_1.default.prerelease(version)) {
|
55 | console.warn(`${pkg} has already been bumped`);
|
56 | ignoreBump.add(pkg);
|
57 | }
|
58 | else {
|
59 | toBump.add(pkg);
|
60 | }
|
61 | };
|
62 | others.forEach(pkg => {
|
63 | maybeBump(pkg);
|
64 | });
|
65 |
|
66 | const lut = {};
|
67 | utils.getCorePaths().forEach(corePath => {
|
68 | const pkgDataPath = path_1.default.join(corePath, 'package.json');
|
69 | const data = utils.readJSONFile(pkgDataPath);
|
70 | lut[data.name] = data.dependencies || {};
|
71 | });
|
72 |
|
73 | Array.from(toBump).forEach(val => {
|
74 | const deps = getDeps(val, lut);
|
75 | deps.forEach(dep => {
|
76 | maybeBump(dep);
|
77 | });
|
78 | });
|
79 | if (!toBump.size) {
|
80 | console.warn('No packages found to bump!');
|
81 | return;
|
82 | }
|
83 | const pyVersion = utils.getPythonVersion();
|
84 | let preId = '';
|
85 | if (pyVersion.includes('a')) {
|
86 | preId = 'alpha';
|
87 | }
|
88 | else if (pyVersion.includes('rc')) {
|
89 | preId = 'rc';
|
90 | }
|
91 | else {
|
92 | throw new Error('Cannot bump JS packages until we switch to prerelease mode');
|
93 | }
|
94 | const pkgs = Array.from(toBump).join(',');
|
95 | let cmd = `lerna version premajor --preid=${preId} --force-publish=${pkgs} --no-push`;
|
96 | if (options.force) {
|
97 | cmd += ' --yes';
|
98 | }
|
99 | if (options.dryRun) {
|
100 | console.debug('Would run:');
|
101 | console.debug(cmd);
|
102 | return;
|
103 | }
|
104 | utils.run(cmd);
|
105 | });
|
106 | commander_1.default.parse(process.argv);
|
107 |
|
\ | No newline at end of file |