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
|
||||
it('should complete successfully on a new lerna workspace', async () => {
|
||||
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(`
|
||||
|
||||
Lerna No changes were necessary. This workspace is up to date!
|
||||
|
||||
@ -1427,7 +1427,14 @@ export async function executeMigrations(
|
||||
: 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) {
|
||||
logger.info(`Running migration ${m.package}: ${m.name}`);
|
||||
try {
|
||||
const { collection, collectionPath } = readMigrationCollection(
|
||||
m.package,
|
||||
@ -1441,15 +1448,17 @@ export async function executeMigrations(
|
||||
m.name
|
||||
);
|
||||
|
||||
logger.info(`Ran ${m.name} from ${m.package}`);
|
||||
logger.info(` ${m.description}\n`);
|
||||
if (changes.length < 1) {
|
||||
logger.info(`No changes were made\n`);
|
||||
migrationsWithNoChanges.push(m);
|
||||
// If no changes are made, continue on without printing anything
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.info(`Ran ${m.name} from ${m.package}`);
|
||||
logger.info(` ${m.description}\n`);
|
||||
logger.info('Changes:');
|
||||
printChanges(changes, ' ');
|
||||
logger.info('');
|
||||
} else {
|
||||
const ngCliAdapter = await getNgCompatLayer();
|
||||
const { madeChanges, loggingQueue } = await ngCliAdapter.runMigration(
|
||||
@ -1462,15 +1471,17 @@ export async function executeMigrations(
|
||||
isVerbose
|
||||
);
|
||||
|
||||
logger.info(`Ran ${m.name} from ${m.package}`);
|
||||
logger.info(` ${m.description}\n`);
|
||||
if (!madeChanges) {
|
||||
logger.info(`No changes were made\n`);
|
||||
migrationsWithNoChanges.push(m);
|
||||
// If no changes are made, continue on without printing anything
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.info(`Ran ${m.name} from ${m.package}`);
|
||||
logger.info(` ${m.description}\n`);
|
||||
logger.info('Changes:');
|
||||
loggingQueue.forEach((log) => logger.info(' ' + log));
|
||||
logger.info('');
|
||||
}
|
||||
|
||||
if (shouldCreateCommits) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user