/
index.js
51 lines (41 loc) · 1.3 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
// @ts-check
"use strict";
const { Command } = require("@lerna/command");
const log = require("npmlog");
const { executeMigrations } = require("nx/src/command-line/migrate");
const migrationsJson = require("../../migrations.json");
module.exports = factory;
function factory(argv) {
return new RepairCommand(argv);
}
class RepairCommand extends Command {
// eslint-disable-next-line class-methods-use-this
initialize() {}
async execute() {
const verbose = 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,
});
});
const migrationsThatMadeNoChanges = await executeMigrations(
process.cwd(),
lernaMigrations,
verbose,
false,
""
);
if (migrationsThatMadeNoChanges.length < lernaMigrations.length) {
// @ts-ignore
this.logger.info("repair", `Successfully repaired your configuration. This workspace is up to date!`);
} else {
// @ts-ignore
this.logger.info("repair", `No changes were necessary. This workspace is up to date!`);
}
}
}
module.exports.RepairCommand = RepairCommand;