diff --git a/package.json b/package.json index 459dbd7..b4419f2 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@changesets/cli": "^2.26.2", "@types/jest": "^29.5.10", "@types/node": "^20.8.9", + "diy-log": "^2.5.1", "gulp": "^4.0.2", "jest": "^29.7.0", "minimist": "^1.2.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 32ce505..4b033d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true @@ -20,6 +20,9 @@ importers: '@types/node': specifier: ^20.8.9 version: 20.16.10 + diy-log: + specifier: ^2.5.1 + version: 2.5.1 gulp: specifier: ^4.0.2 version: 4.0.2 @@ -174,6 +177,9 @@ importers: gulp-rename: specifier: ^2.0.0 version: 2.0.0 + gulp-renew: + specifier: workspace:^ + version: link:../../plugins/renew gulp-rev: specifier: ^9.0.0 version: 9.0.0 @@ -198,9 +204,6 @@ importers: html-minifier-terser: specifier: ^7.2.0 version: 7.2.0 - istextorbinary: - specifier: ^9.5.0 - version: 9.5.0 merge2: specifier: ^1.4.1 version: 1.4.1 @@ -216,9 +219,6 @@ importers: postcss-preset-env: specifier: ^10.0.0 version: 10.0.5(postcss@8.4.47) - replacestream: - specifier: ^4.0.3 - version: 4.0.3 rimraf: specifier: ^5.0.1 version: 5.0.1 @@ -309,6 +309,9 @@ importers: plugins/renew: dependencies: + '@types/node': + specifier: '*' + version: 20.16.10 istextorbinary: specifier: ^9.5.0 version: 9.5.0 @@ -4564,7 +4567,6 @@ packages: dependencies: picocolors: 1.1.0 time-stamp: 2.2.0 - dev: false /doctypes@1.1.0: resolution: {integrity: sha512-LLBi6pEqS6Do3EKQ3J0NqHWV5hhb78Pi8vvESYwyOy2c31ZEZVdtitdzsQsKb7878PEERhzUk0ftqGhG6Mz+pQ==} @@ -10642,7 +10644,6 @@ packages: /time-stamp@2.2.0: resolution: {integrity: sha512-zxke8goJQpBeEgD82CXABeMh0LSJcj7CXEd0OHOg45HgcofF7pxNwZm9+RknpxpDhwN4gFpySkApKfFYfRQnUA==} engines: {node: '>=0.10.0'} - dev: false /timed-out@4.0.1: resolution: {integrity: sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA==} diff --git a/scripts/changelog.js b/scripts/changelog.js index ab6380b..68400aa 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -1,5 +1,6 @@ const simpleGit = require('simple-git') const { promisify } = require('util') +const log = require('diy-log') const git = simpleGit() @@ -7,7 +8,7 @@ const git = simpleGit() async function getCommitsSince(commitId) { const log = promisify(git.log.bind(git)) const logOptions = { - from: commitId + from: commitId, } try { @@ -31,7 +32,7 @@ async function getCommitsSinceLatestTag() { } const logOptions = { - from: latestTag + from: latestTag, } try { @@ -44,9 +45,9 @@ async function getCommitsSinceLatestTag() { } // 格式化 commit 记录 -function formatCommits(commits, filter = commit => commit) { +function formatCommits(commits, filter = (commit) => commit) { const regex = /\(([^)]+)\)/ - return commits.filter(filter).map(commit => { + return commits.filter(filter).map((commit) => { const { message } = commit const match = message.match(regex) @@ -56,7 +57,7 @@ function formatCommits(commits, filter = commit => commit) { date: commit.date, message: message, package: match ? match[1].toLowerCase() : '', - text: match ? message.replace(match[0], '').trim() : '' + text: match ? message.replace(match[0], '').trim() : '', } }) } @@ -66,7 +67,7 @@ function formatCommits(commits, filter = commit => commit) { try { // const commits = await getCommitsSince('4ac1e7a') const commits = await getCommitsSinceLatestTag() - const formattedCommits = formatCommits(commits, commit => { + const formattedCommits = formatCommits(commits, (commit) => { return moduleRegex.test(commit.message) }).reduce((acc, commit) => { if (!commit.package) throw new Error('No package found in commit message: ' + commit.message) @@ -74,12 +75,19 @@ function formatCommits(commits, filter = commit => commit) { acc[commit.package] = [] } acc[commit.package].push( - `- ${commit.text} ([${commit.hash.slice(0, 7)}](https://github.com/Meqn/pipflow/commit/${commit.hash}))` + `- ${commit.text} ([${commit.hash.slice(0, 7)}](https://github.com/Meqn/pipflow/commit/${ + commit.hash + }))` ) return acc }, {}) - console.log('Commit messages:', formatCommits(commits).map(commit => commit.message)) - console.log('Commits:', formattedCommits) + console.log( + 'Commit messages:', + formatCommits(commits).map((commit) => commit.message) + ) + Object.entries(formattedCommits).forEach(([key, value]) => { + log.tag.warn('\n' + value.join('\n'), key) + }) } catch (error) { console.error('error:', error.message) }