Skip to content

Commit

Permalink
🔧 chore: Fix i18n diff and workflow token
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Oct 10, 2023
1 parent 7513abb commit bdb866c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/issue-check-inactive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ jobs:
uses: actions-cool/issues-helper@v3
with:
actions: 'check-inactive'
token: ${{ secrets.GH_TOKEN }}
inactive-label: 'Inactive'
inactive-day: 30
3 changes: 3 additions & 0 deletions .github/workflows/issue-close-require.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issues'
token: ${{ secrets.GH_TOKEN }}
labels: '✅ Fixed'
inactive-day: 3
body: |
Expand All @@ -28,6 +29,7 @@ jobs:
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issues'
token: ${{ secrets.GH_TOKEN }}
labels: '🤔 Need Reproduce'
inactive-day: 3
body: |
Expand All @@ -38,6 +40,7 @@ jobs:
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issues'
token: ${{ secrets.GH_TOKEN }}
labels: "🙅🏻‍♀️ WON'T DO"
inactive-day: 3
body: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/issue-remove-inactive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ jobs:
uses: actions-cool/issues-helper@v3
with:
actions: 'remove-labels'
token: ${{ secrets.GH_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: 'Inactive'
9 changes: 5 additions & 4 deletions .github/workflows/pre-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment: |
Great PR @${{ github.event.pull_request.user.login }}. The growth of project is inseparable from user feedback and contribution, thanks for your contribution ❤️
🎉 Great PR @${{ github.event.pull_request.user.login }} 🎉

非常棒的 PR @${{ github.event.pull_request.user.login }}. 项目的成长离不开用户反馈和贡献,感谢您的贡献 ❤️
emoji: 'heart'
The growth of project is inseparable from user feedback and contribution, thanks for your contribution ❤️

项目的成长离不开用户反馈和贡献,感谢您的贡献 ❤️
emoji: 'hooray'
pr-emoji: '+1, heart'
close: true
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"@testing-library/jest-dom": "^6",
"@testing-library/react": "^14",
"@types/chroma-js": "^2",
"@types/lodash": "^4",
"@types/lodash-es": "^4",
"@types/mixpanel-browser": "^2",
"@types/node": "^20",
Expand All @@ -146,6 +147,7 @@
"husky": "^8",
"jsdom": "^22",
"lint-staged": "^14",
"lodash": "^4",
"next-pwa": "^5",
"node-fetch": "^3",
"prettier": "^3",
Expand Down
3 changes: 2 additions & 1 deletion scripts/i18nWorkflow/genDiff.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { consola } from 'consola';
import { colors } from 'consola/utils';
import { unset } from 'lodash';
import { existsSync } from 'node:fs';

import {
Expand All @@ -8,7 +9,7 @@ import {
localesResourcesFilepath,
outputLocaleJsonFilepath,
} from './const';
import { diff, readJSON, tagWhite, tagYellow, unset, writeJSON } from './utils';
import { diff, readJSON, tagWhite, tagYellow, writeJSON } from './utils';

export const genDiff = () => {
consola.start(`Diff between Dev/Prod local...`);
Expand Down
12 changes: 3 additions & 9 deletions scripts/i18nWorkflow/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { consola } from 'consola';
import { colors } from 'consola/utils';
import { tocForResources } from 'i18next-resources-for-ts';
import { isObject } from 'lodash';
import { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';

Expand Down Expand Up @@ -58,22 +59,15 @@ export const diff = (obj1: any, obj2: any, prefix: string = ''): string[] => {
let result: string[] = [];
for (const key in obj1) {
if (!obj2[key]) continue;
if (typeof obj1[key] === 'object' && obj1[key] !== null && obj2[key]) {
result = result.concat(diff(obj1[key], obj2[key], `${key}.`));
if (isObject(obj1[key]) && isObject(obj2[key])) {
result = [...result, ...diff(obj1[key], obj2[key], `${prefix}${key}.`)];
} else if (obj1[key] !== obj2[key]) {
result.push(`${prefix}${key}`);
}
}
return result;
};

export const unset = (obj: any, key: string) => {
const keys = key.split('.');
const lastKey = keys.pop();
const lastObj = keys.reduce((obj, key) => (obj[key] = obj[key] || {}), obj);
if (lastKey) delete lastObj[lastKey];
};

export const tagBlue = (text: string) => colors.bgBlueBright(colors.black(` ${text} `));
export const tagYellow = (text: string) => colors.bgYellowBright(colors.black(` ${text} `));
export const tagGreen = (text: string) => colors.bgGreenBright(colors.black(` ${text} `));
Expand Down

0 comments on commit bdb866c

Please sign in to comment.