1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const command_1 = require("@oclif/command");
|
4 | const debug_1 = require("../lib/debug");
|
5 | const packages_1 = require("../lib/packages");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | class Hoist extends command_1.Command {
|
11 | |
12 |
|
13 |
|
14 | async run() {
|
15 | const { args, flags } = this.parse(Hoist);
|
16 | flags.packageName = []
|
17 | .concat(flags.packageName)
|
18 | .concat(flags['package-name'])
|
19 | .concat(flags.package)
|
20 | .filter(Boolean);
|
21 | if (!flags.packageName.length) {
|
22 | delete flags.packageName;
|
23 | }
|
24 | flags.failFast = flags.failFast || flags['fail-fast'];
|
25 | const options = Object.assign({}, args, flags);
|
26 | await packages_1.apply({
|
27 | before: (packages) => {
|
28 | console.log(packages);
|
29 | return debug_1.format `Hoisting ${packages.length} packages`;
|
30 | },
|
31 | beforeEach: (packageName) => debug_1.format `Hoisting deps from ${packageName}`,
|
32 | afterEach: (packageName, error) => {
|
33 | if (error) {
|
34 | return debug_1.format `Failed to hoist deps from ${packageName}`;
|
35 | }
|
36 | return debug_1.format `Hoisted deps from ${packageName}`;
|
37 | },
|
38 | after: (packages, errors) => {
|
39 | if (errors.length) {
|
40 | return `Failed to hoist deps in ${errors.length} packages`;
|
41 | }
|
42 | return debug_1.format `Hoisted ${packages.length} packages`;
|
43 | },
|
44 | }, async (packageName) => {
|
45 | return packages_1.hoist(packageName, options);
|
46 | }, options);
|
47 | }
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 | Hoist.description = 'Migrate dependencies and dev dependencies from a sub package to the root package.json';
|
53 |
|
54 |
|
55 |
|
56 | Hoist.flags = {
|
57 | failFast: command_1.flags.boolean({
|
58 | description: 'Fail upon encountering a package that cannot be hoisted, rather than running all to completion',
|
59 | }),
|
60 | 'fail-fast': command_1.flags.boolean({
|
61 | description: 'Alias of --failFast',
|
62 | }),
|
63 | packageName: command_1.flags.string({
|
64 | char: 'p',
|
65 | description: 'The package against which to run this command. May be specified more than once.',
|
66 | multiple: true,
|
67 | }),
|
68 | package: command_1.flags.string({
|
69 | description: 'alias of --packageName',
|
70 | multiple: true,
|
71 | }),
|
72 | 'package-name': command_1.flags.string({
|
73 | description: 'alias of --packageName',
|
74 | multiple: true,
|
75 | }),
|
76 | risky: command_1.flags.boolean({
|
77 | description: 'Indicates if clark should attempt to reconcile semver mismatches.',
|
78 | }),
|
79 | silent: command_1.flags.boolean({
|
80 | char: 's',
|
81 | description: 'Indicates nothing should be printed to the stdout',
|
82 | }),
|
83 | };
|
84 | exports.default = Hoist;
|
85 |
|
\ | No newline at end of file |