Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improved readability of emoji in sync logs #572

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/core/service/PackageSyncerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@
const log = data && data.log || '';
offset += log.length;
if (data && data.syncDone) {
logs.push(`[${isoNow()}][UP] 🟢 Sync ${fullname} success [${useTime}ms], log: ${logUrl}, offset: ${offset}`);
logs.push(`[${isoNow()}][UP] 🟢🟢🟢🟢🟢 ${registry}/${fullname} 🟢🟢🟢🟢🟢`);
logs.push(`[${isoNow()}][UP] 🎉 Sync ${fullname} success [${useTime}ms], log: ${logUrl}, offset: ${offset}`);
logs.push(`[${isoNow()}][UP] 🔗 ${registry}/${fullname}`);

Check warning on line 207 in app/core/service/PackageSyncerService.ts

View check run for this annotation

Codecov / codecov/patch

app/core/service/PackageSyncerService.ts#L206-L207

Added lines #L206 - L207 were not covered by tests
await this.taskService.appendTaskLog(task, logs.join('\n'));
return;
}
Expand Down Expand Up @@ -298,8 +298,8 @@
}

// update log
logs.push(`[${isoNow()}] 🟢 log: ${logUrl}`);
logs.push(`[${isoNow()}] 🟢🟢🟢🟢🟢 ${url} 🟢🟢🟢🟢🟢`);
logs.push(`[${isoNow()}] 📝 Log URL: ${logUrl}`);
logs.push(`[${isoNow()}] 🔗 ${url}`);
await this.taskService.finishTask(task, TaskState.Success, logs.join('\n'));
this.logger.info('[PackageSyncerService.executeTask:remove-package] taskId: %s, targetName: %s',
task.taskId, task.targetName);
Expand Down Expand Up @@ -690,7 +690,7 @@
const publisher = users.find(user => user.displayName === item._npmUser?.name) || users[0];
const pkgVersion = await this.packageManagerService.publish(publishCmd, publisher);
updateVersions.push(pkgVersion.version);
logs.push(`[${isoNow()}] 🟢 [${syncIndex}] Synced version ${version} success, packageVersionId: ${pkgVersion.packageVersionId}, db id: ${pkgVersion.id}`);
logs.push(`[${isoNow()}] 🎉 [${syncIndex}] Synced version ${version} success, packageVersionId: ${pkgVersion.packageVersionId}, db id: ${pkgVersion.id}`);
} catch (err: any) {
if (err.name === 'ForbiddenError') {
logs.push(`[${isoNow()}] 🐛 [${syncIndex}] Synced version ${version} already exists, skip publish, try to set in local manifest`);
Expand Down Expand Up @@ -885,9 +885,9 @@

// clean cache
await this.cacheService.removeCache(fullname);
logs.push(`[${isoNow()}] 🟢 Clean cache`);
logs.push(`[${isoNow()}] 🟢 log: ${logUrl}`);
logs.push(`[${isoNow()}] 🟢🟢🟢🟢🟢 ${url} 🟢🟢🟢🟢🟢`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yisibl 果然,单测 assert 也一起修改一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好嘞,测试更新了

logs.push(`[${isoNow()}] 🗑️ Clean cache`);
logs.push(`[${isoNow()}] 📝 Log URL: ${logUrl}`);
logs.push(`[${isoNow()}] 🔗 ${url}`);
task.error = lastErrorMessage;
await this.taskService.finishTask(task, TaskState.Success, logs.join('\n'));
this.logger.info('[PackageSyncerService.executeTask:success] taskId: %s, targetName: %s',
Expand Down
12 changes: 6 additions & 6 deletions test/core/service/PackageSyncerService/executeTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
assert(stream);
const log = await TestUtil.readStreamToLog(stream);
// console.log(log);
assert(log.includes('] 🟢🟢🟢🟢🟢'));
assert(log.includes('] 🔗'));
app.mockAgent().assertNoPendingInterceptors();
});

Expand Down Expand Up @@ -333,7 +333,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
assert(stream);
const log = await TestUtil.readStreamToLog(stream);
// console.log(log);
assert(log.includes('] 🟢🟢🟢🟢🟢'));
assert(log.includes('] 🔗'));
app.mockAgent().assertNoPendingInterceptors();
});

Expand Down Expand Up @@ -1161,7 +1161,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
assert(stream);
const log = await TestUtil.readStreamToLog(stream);
// console.log(log);
assert(log.includes('] 🟢🟢🟢🟢🟢 https://registry.npmjs.org/cnpmcore-test-sync-deprecated'));
assert(log.includes('] 🔗 https://registry.npmjs.org/cnpmcore-test-sync-deprecated'));
const { data } = await packageManagerService.listPackageFullManifests('', name);
assert(data!.readme === 'mock readme content');
assert(data!.versions['0.0.0']!.readme === undefined);
Expand Down Expand Up @@ -1633,7 +1633,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
const log = await TestUtil.readStreamToLog(stream);
// console.log(log);
assert(log.includes('📖 Use the latest version(0.0.0) maintainers instead'));
assert(log.includes('] 🟢🟢🟢🟢🟢 '));
assert(log.includes('] 🔗'));
app.mockAgent().assertNoPendingInterceptors();
});

Expand Down Expand Up @@ -1716,7 +1716,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
const log = await TestUtil.readStreamToLog(stream);
// console.log(log);
assert(log.includes('🚧🚧🚧🚧🚧 Syncing from https://registry.npmjs.org/D, '));
assert(log.includes('🟢🟢🟢🟢🟢'));
assert(log.includes('🔗'));
const res = await app.httpRequest()
.get(`/${name}`)
.expect(200)
Expand Down Expand Up @@ -1748,7 +1748,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
const log = await TestUtil.readStreamToLog(stream);
// console.log(log);
assert(log.includes('🚧🚧🚧🚧🚧 Syncing from https://registry.npmjs.org/Buffer, '));
assert(log.includes('🟢🟢🟢🟢🟢'));
assert(log.includes('🔗'));
const res = await app.httpRequest()
.get(`/${name}`)
.expect(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('test/port/controller/PackageSyncController/showSyncTask.test.ts', () =
assert.equal(res.status, 302);
log = await TestUtil.readStreamToLog(res.headers.location);
}
assert.match(log, /🟢🟢🟢🟢🟢/);
assert.match(log, /🔗/);

// check hasInstallScript
res = await app.httpRequest()
Expand Down
Loading