/
index.js
56 lines (45 loc) · 1.47 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-check
"use strict";
const { Command } = require("@lerna/command");
const log = require("npmlog");
const { repair } = require("nx/src/command-line/repair");
const migrationsJson = require("../../migrations.json");
module.exports = factory;
function factory(argv) {
return new RepairCommand(argv);
}
class RepairCommand extends Command {
constructor(argv) {
super(argv, { skipValidations: true });
}
// eslint-disable-next-line class-methods-use-this
initialize() {}
async execute() {
this.configureNxOutput();
const verbose = this.options?.verbose ? true : log.level === "verbose";
const lernaMigrations = Object.entries(migrationsJson.generators).map(([name, migration]) => {
return /** @type {const} */ ({
package: "lerna",
cli: "nx",
name,
description: migration.description,
version: migration.version,
});
});
await repair({ verbose }, lernaMigrations);
}
configureNxOutput() {
try {
// eslint-disable-next-line global-require
const nxOutput = require("nx/src/utils/output");
nxOutput.output.cliName = "Lerna";
nxOutput.output.formatCommand = (taskId) => taskId;
return nxOutput;
} catch (err) {
this.logger.error("There was a critical issue when trying to execute the repair command.");
// Rethrow so that the lerna logger can automatically handle the unexpected error
throw err;
}
}
}
module.exports.RepairCommand = RepairCommand;