feat(misc): add more logging while running migrations (#27063)
This commit is contained in:
parent
7409aa2e01
commit
adbb861d8c
@ -39,7 +39,15 @@ describe('Lerna Smoke Tests', () => {
|
|||||||
// If this snapshot fails it means that nx repair generators are making assumptions which don't hold true for lerna workspaces
|
// If this snapshot fails it means that nx repair generators are making assumptions which don't hold true for lerna workspaces
|
||||||
it('should complete successfully on a new lerna workspace', async () => {
|
it('should complete successfully on a new lerna workspace', async () => {
|
||||||
let result = runLernaCLI(`repair`);
|
let result = runLernaCLI(`repair`);
|
||||||
result = result.replace(/.*\/node_modules\/.*\n/, ''); // yarn adds "$ /node_modules/.bin/lerna repair" to the output
|
result = result
|
||||||
|
.replace(/.*\/node_modules\/.*\n/, '') // yarn adds "$ /node_modules/.bin/lerna repair" to the output
|
||||||
|
.replace(
|
||||||
|
/Running the following migrations:\n(?:.*\n)*---------------------------------------------------------\n\n/,
|
||||||
|
''
|
||||||
|
) // sorted list of all migrations to be run
|
||||||
|
.replace(/Running migration.*\n/g, '') // start of individual migration run
|
||||||
|
.replace(/Ran .* from .*\n .*\n\n/g, '') // end of individual migration run
|
||||||
|
.replace(/No changes were made\n\n/g, ''); // no changes during individual migration run
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
|
|
||||||
Lerna No changes were necessary. This workspace is up to date!
|
Lerna No changes were necessary. This workspace is up to date!
|
||||||
|
|||||||
@ -1427,7 +1427,14 @@ export async function executeMigrations(
|
|||||||
: 1;
|
: 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.info(`Running the following migrations:`);
|
||||||
|
sortedMigrations.forEach((m) =>
|
||||||
|
logger.info(`- ${m.package}: ${m.name} (${m.description})`)
|
||||||
|
);
|
||||||
|
logger.info(`---------------------------------------------------------\n`);
|
||||||
|
|
||||||
for (const m of sortedMigrations) {
|
for (const m of sortedMigrations) {
|
||||||
|
logger.info(`Running migration ${m.package}: ${m.name}`);
|
||||||
try {
|
try {
|
||||||
const { collection, collectionPath } = readMigrationCollection(
|
const { collection, collectionPath } = readMigrationCollection(
|
||||||
m.package,
|
m.package,
|
||||||
@ -1441,15 +1448,17 @@ export async function executeMigrations(
|
|||||||
m.name
|
m.name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger.info(`Ran ${m.name} from ${m.package}`);
|
||||||
|
logger.info(` ${m.description}\n`);
|
||||||
if (changes.length < 1) {
|
if (changes.length < 1) {
|
||||||
|
logger.info(`No changes were made\n`);
|
||||||
migrationsWithNoChanges.push(m);
|
migrationsWithNoChanges.push(m);
|
||||||
// If no changes are made, continue on without printing anything
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Ran ${m.name} from ${m.package}`);
|
logger.info('Changes:');
|
||||||
logger.info(` ${m.description}\n`);
|
|
||||||
printChanges(changes, ' ');
|
printChanges(changes, ' ');
|
||||||
|
logger.info('');
|
||||||
} else {
|
} else {
|
||||||
const ngCliAdapter = await getNgCompatLayer();
|
const ngCliAdapter = await getNgCompatLayer();
|
||||||
const { madeChanges, loggingQueue } = await ngCliAdapter.runMigration(
|
const { madeChanges, loggingQueue } = await ngCliAdapter.runMigration(
|
||||||
@ -1462,15 +1471,17 @@ export async function executeMigrations(
|
|||||||
isVerbose
|
isVerbose
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger.info(`Ran ${m.name} from ${m.package}`);
|
||||||
|
logger.info(` ${m.description}\n`);
|
||||||
if (!madeChanges) {
|
if (!madeChanges) {
|
||||||
|
logger.info(`No changes were made\n`);
|
||||||
migrationsWithNoChanges.push(m);
|
migrationsWithNoChanges.push(m);
|
||||||
// If no changes are made, continue on without printing anything
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Ran ${m.name} from ${m.package}`);
|
logger.info('Changes:');
|
||||||
logger.info(` ${m.description}\n`);
|
|
||||||
loggingQueue.forEach((log) => logger.info(' ' + log));
|
loggingQueue.forEach((log) => logger.info(' ' + log));
|
||||||
|
logger.info('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldCreateCommits) {
|
if (shouldCreateCommits) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user