Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit107f7ca

Browse files
rsk2rickstaa
rsk2
andauthored
Feature/grs 1955 change commonjs imports (anuraghazra#1995)
* GRS-1955: Using ES6 import/export in src files* GRS-1955: Using ES6 import/export in test files* GRS-1955: Using ES6 import/export in themes index.js* GRS-1955: Readding blank line at end of top-languages-card.js* feat: fix test es6 import errorsThis commit makes sure jest is set-up to support es6. It also fixesseveral test errors and sorts the imports.* test: update test node versionThis commit makes sure node 16 is used in the github actions.* refactor: run prettierCo-authored-by: rickstaa <rick.staa@outlook.com>
1 parent4073512 commit107f7ca

File tree

49 files changed

+338
-475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+338
-475
lines changed

‎.github/workflows/generate-theme-doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
-name:setup node
1717
uses:actions/setup-node@v1
1818
with:
19-
node-version:"12.x"
19+
node-version:"16.x"
2020

2121
-name:npm install, generate readme
2222
run:|

‎.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
-name:Setup Node
1919
uses:actions/setup-node@v1
2020
with:
21-
node-version:"12.x"
21+
node-version:"16.x"
2222

2323
-name:Install & Test
2424
run:|

‎api/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
require("dotenv").config();
2-
const{
1+
import{
32
renderError,
43
parseBoolean,
54
parseArray,
65
clampValue,
76
CONSTANTS,
8-
}=require("../src/common/utils");
9-
constfetchStats=require("../src/fetchers/stats-fetcher");
10-
constrenderStatsCard=require("../src/cards/stats-card");
11-
constblacklist=require("../src/common/blacklist");
12-
const{ isLocaleAvailable}=require("../src/translations");
7+
}from"../src/common/utils";
8+
importfetchStatsfrom"../src/fetchers/stats-fetcher";
9+
importrenderStatsCardfrom"../src/cards/stats-card";
10+
importblacklistfrom"../src/common/blacklist";
11+
import{isLocaleAvailable}from"../src/translations";
12+
import*asdotenvfrom"dotenv";
1313

14-
module.exports=async(req,res)=>{
14+
dotenv.config();
15+
16+
exportdefaultasync(req,res)=>{
1517
const{
1618
username,
1719
hide,

‎api/pin.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
require("dotenv").config();
2-
const{
1+
import{
32
renderError,
43
parseBoolean,
54
clampValue,
65
CONSTANTS,
7-
}=require("../src/common/utils");
8-
constfetchRepo=require("../src/fetchers/repo-fetcher");
9-
constrenderRepoCard=require("../src/cards/repo-card");
10-
constblacklist=require("../src/common/blacklist");
11-
const{ isLocaleAvailable}=require("../src/translations");
6+
}from"../src/common/utils";
7+
importfetchRepofrom"../src/fetchers/repo-fetcher";
8+
importrenderRepoCardfrom"../src/cards/repo-card";
9+
importblacklistfrom"../src/common/blacklist";
10+
import{isLocaleAvailable}from"../src/translations";
1211

13-
module.exports=async(req,res)=>{
12+
exportdefaultasync(req,res)=>{
1413
const{
1514
username,
1615
repo,

‎api/top-langs.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
require("dotenv").config();
2-
const{
1+
import{
32
renderError,
43
clampValue,
54
parseBoolean,
65
parseArray,
76
CONSTANTS,
8-
}=require("../src/common/utils");
9-
constfetchTopLanguages=require("../src/fetchers/top-languages-fetcher");
10-
constrenderTopLanguages=require("../src/cards/top-languages-card");
11-
constblacklist=require("../src/common/blacklist");
12-
const{ isLocaleAvailable}=require("../src/translations");
7+
}from"../src/common/utils";
8+
importfetchTopLanguagesfrom"../src/fetchers/top-languages-fetcher";
9+
import{renderTopLanguages}from"../src/cards/top-languages-card";
10+
importblacklistfrom"../src/common/blacklist";
11+
import{isLocaleAvailable}from"../src/translations";
12+
import*asdotenvfrom"dotenv";
1313

14-
module.exports=async(req,res)=>{
14+
dotenv.config();
15+
16+
exportdefaultasync(req,res)=>{
1517
const{
1618
username,
1719
hide,

‎api/wakatime.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
require("dotenv").config();
2-
const{
1+
import{
32
renderError,
43
parseBoolean,
54
clampValue,
65
parseArray,
76
CONSTANTS,
8-
}=require("../src/common/utils");
9-
const{ isLocaleAvailable}=require("../src/translations");
10-
const{ fetchWakatimeStats}=require("../src/fetchers/wakatime-fetcher");
11-
constwakatimeCard=require("../src/cards/wakatime-card");
7+
}from"../src/common/utils";
8+
import{isLocaleAvailable}from"../src/translations";
9+
importfetchWakatimeStatsfrom"../src/fetchers/wakatime-fetcher";
10+
importwakatimeCardfrom"../src/cards/wakatime-card";
11+
import*asdotenvfrom"dotenv";
1212

13-
module.exports=async(req,res)=>{
13+
dotenv.config();
14+
15+
exportdefaultasync(req,res)=>{
1416
const{
1517
username,
1618
title_color,

‎jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
module.exports={
1+
exportdefault{
22
clearMocks:true,
3+
transform:{},
4+
testEnvironment:"jsdom",
35
};

‎package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"version":"1.0.0",
44
"description":"Dynamically generate stats for your github readmes",
55
"main":"index.js",
6+
"type":"module",
67
"scripts": {
7-
"test":"jest --coverage",
8-
"test:watch":"jest --watch",
8+
"test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
9+
"test:watch":"node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
10+
"test:update:snapshot":"node --experimental-vm-modules node_modules/jest/bin/jest.js -u",
911
"theme-readme-gen":"node scripts/generate-theme-doc",
1012
"preview-theme":"node scripts/preview-theme",
1113
"generate-langs-json":"node scripts/generate-langs-json",
@@ -20,14 +22,15 @@
2022
"devDependencies": {
2123
"@actions/core":"^1.2.4",
2224
"@actions/github":"^4.0.0",
23-
"@testing-library/dom":"^7.20.0",
24-
"@testing-library/jest-dom":"^5.11.0",
25+
"@testing-library/dom":"^8.17.1",
26+
"@testing-library/jest-dom":"^5.16.5",
27+
"jest-environment-jsdom":"^29.0.3",
28+
"jest":"^29.0.3",
2529
"@uppercod/css-to-object":"^1.1.1",
2630
"axios-mock-adapter":"^1.18.1",
2731
"color-contrast-checker":"^2.1.0",
2832
"hjson":"^3.2.2",
2933
"husky":"^4.2.5",
30-
"jest":"^26.1.0",
3134
"js-yaml":"^4.1.0",
3235
"lodash.snakecase":"^4.1.1",
3336
"parse-diff":"^0.7.0",
@@ -38,6 +41,7 @@
3841
"dotenv":"^8.2.0",
3942
"emoji-name-map":"^1.2.8",
4043
"github-username-regex":"^1.0.0",
44+
"upgrade":"^1.1.0",
4145
"word-wrap":"^1.2.3"
4246
},
4347
"husky": {

‎scripts/generate-langs-json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
constfs=require("fs");
2-
constjsYaml=require("js-yaml");
3-
constaxios=require("axios");
1+
importaxiosfrom"axios";
2+
importfsfrom"fs";
3+
importjsYamlfrom"js-yaml";
44

55
constLANGS_FILEPATH="./src/common/languageColors.json";
66

‎scripts/generate-theme-doc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
consttheme=require("../themes/index");
2-
constfs=require("fs");
1+
importfsfrom"fs";
2+
import{themes}from"../themes/index";
33

44
constTARGET_FILE="./themes/README.md";
55
constREPO_CARD_LINKS_FLAG="<!-- REPO_CARD_LINKS -->";
@@ -54,7 +54,7 @@ const createStatMdLink = (theme) => {
5454
};
5555

5656
constgenerateLinks=(fn)=>{
57-
returnObject.keys(theme)
57+
returnObject.keys(themes)
5858
.map((name)=>fn(name))
5959
.join("");
6060
};
@@ -65,7 +65,7 @@ const createTableItem = ({ link, label, isRepoCard }) => {
6565
};
6666
constgenerateTable=({ isRepoCard})=>{
6767
constrows=[];
68-
constthemes=Object.keys(theme).filter(
68+
constthemes=Object.keys(themes).filter(
6969
(name)=>name!==(!isRepoCard ?"default_repocard" :"default"),
7070
);
7171

‎scripts/preview-theme.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
constcore=require("@actions/core");
2-
constgithub=require("@actions/github");
3-
constparse=require("parse-diff");
4-
constHjson=require("hjson");
5-
constsnakeCase=require("lodash.snakecase");
6-
constColorContrastChecker=require("color-contrast-checker");
1+
importcorefrom"@actions/core";
2+
importgithubfrom"@actions/github";
3+
importColorContrastCheckerfrom"color-contrast-checker";
4+
import*asdotenvfrom"dotenv";
5+
importHjsonfrom"hjson";
6+
importsnakeCasefrom"lodash.snakecase";
7+
importparsefrom"parse-diff";
78

8-
require("dotenv").config();
9+
dotenv.config();
910

1011
constOWNER="anuraghazra";
1112
constREPO="github-readme-stats";
@@ -76,10 +77,10 @@ function getGrsLink(colors) {
7677
}
7778

7879
constthemeContribGuidelines=`
79-
\rHi, thanks for the theme contribution, please read our theme [contribution guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution).
80+
\rHi, thanks for the theme contribution, please read our theme [contribution guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution).
8081
\rWe are currently only accepting color combinations from any VSCode theme or themes which have good color combination to minimize bloating the themes collection.
8182
82-
\r> Also note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization)
83+
\r> Also note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization)
8384
`;
8485

8586
asyncfunctionrun(){
@@ -128,7 +129,7 @@ async function run() {
128129
issue_number:pullRequestId,
129130
body:`
130131
\r**${COMMENT_TITLE}**
131-
132+
132133
\rCannot create theme preview
133134
134135
${themeContribGuidelines}
@@ -167,16 +168,16 @@ async function run() {
167168
owner:OWNER,
168169
repo:REPO,
169170
body:`
170-
\r**${COMMENT_TITLE}**
171-
171+
\r**${COMMENT_TITLE}**
172+
172173
\r${warnings.map((warning)=>`- :warning:${warning}\n`).join("")}
173174
174175
\ntitle_color: <code>#${titleColor}</code> | icon_color: <code>#${iconColor}</code> | text_color: <code>#${textColor}</code> | bg_color: <code>#${bgColor}</code>
175-
176+
176177
\r[Preview Link](${url})
177178
178179
\r[![](${url})](${url})
179-
180+
180181
${themeContribGuidelines}
181182
`,
182183
});

‎scripts/push-theme-readme.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ git checkout -b $BRANCH_NAME
1111
git add --all
1212
git commit --message"docs(theme): Auto update theme readme"||exit 0
1313
git remote add origin-$BRANCH_NAME https://${PERSONAL_TOKEN}@github.com/${GH_REPO}.git
14-
git push --force --quiet --set-upstream origin-$BRANCH_NAME$BRANCH_NAME
14+
git push --force --quiet --set-upstream origin-$BRANCH_NAME$BRANCH_NAME

‎src/calculateRank.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ function calculateRank({
5757
issues*ISSUES_OFFSET+
5858
stargazers*STARS_OFFSET+
5959
prs*PRS_OFFSET+
60-
followers*FOLLOWERS_OFFSET+
61-
totalRepos*REPO_OFFSET
60+
followers*FOLLOWERS_OFFSET+
61+
totalRepos*REPO_OFFSET
6262
)/100;
6363

6464
constnormalizedScore=normalcdf(score,TOTAL_VALUES,ALL_OFFSETS)*100;
@@ -74,4 +74,5 @@ function calculateRank({
7474
return{ level,score:normalizedScore};
7575
}
7676

77-
module.exports=calculateRank;
77+
export{calculateRank};
78+
exportdefaultcalculateRank;

‎src/cards/repo-card.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
//@ts-check
2-
const{
3-
kFormatter,
2+
import{Card}from"../common/Card";
3+
import{I18n}from"../common/I18n";
4+
import{icons}from"../common/icons";
5+
import{
46
encodeHTML,
5-
getCardColors,
67
flexLayout,
7-
wrapTextMultiline,
8+
getCardColors,
9+
kFormatter,
810
measureText,
911
parseEmojis,
10-
}=require("../common/utils");
11-
constI18n=require("../common/I18n");
12-
constCard=require("../common/Card");
13-
consticons=require("../common/icons");
14-
const{ repoCardLocales}=require("../translations");
12+
wrapTextMultiline,
13+
}from"../common/utils";
14+
import{repoCardLocales}from"../translations";
1515

1616
/**
1717
*@param {string} label
@@ -185,4 +185,5 @@ const renderRepoCard = (repo, options = {}) => {
185185
`);
186186
};
187187

188-
module.exports=renderRepoCard;
188+
export{renderRepoCard};
189+
exportdefaultrenderRepoCard;

‎src/cards/stats-card.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//@ts-check
2-
constI18n=require("../common/I18n");
3-
constCard=require("../common/Card");
4-
consticons=require("../common/icons");
5-
const{ getStyles}=require("../getStyles");
6-
const{ statCardLocales}=require("../translations");
7-
const{
8-
kFormatter,
9-
flexLayout,
2+
import{Card}from"../common/Card";
3+
import{I18n}from"../common/I18n";
4+
import{icons}from"../common/icons";
5+
import{
106
clampValue,
11-
measureText,
7+
flexLayout,
128
getCardColors,
13-
}=require("../common/utils");
9+
kFormatter,
10+
measureText,
11+
}from"../common/utils";
12+
import{getStyles}from"../getStyles";
13+
import{statCardLocales}from"../translations";
1414

1515
constcreateTextNode=({
1616
icon,
@@ -300,4 +300,5 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
300300
`);
301301
};
302302

303-
module.exports=renderStatsCard;
303+
export{renderStatsCard};
304+
exportdefaultrenderStatsCard;

‎src/cards/top-languages-card.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//@ts-check
2-
constCard=require("../common/Card");
3-
constI18n=require("../common/I18n");
4-
const{langCardLocales}=require("../translations");
5-
const{ createProgressNode}=require("../common/createProgressNode");
6-
const{
2+
import{Card}from"../common/Card";
3+
import{createProgressNode}from"../common/createProgressNode";
4+
import{I18n}from"../common/I18n";
5+
import{
6+
chunkArray,
77
clampValue,
8-
getCardColors,
98
flexLayout,
9+
getCardColors,
1010
lowercaseTrim,
1111
measureText,
12-
chunkArray,
13-
}=require("../common/utils");
12+
}from"../common/utils";
13+
import{langCardLocales}from"../translations";
1414

1515
constDEFAULT_CARD_WIDTH=300;
1616
constMIN_CARD_WIDTH=230;
@@ -311,5 +311,4 @@ const renderTopLanguages = (topLangs, options = {}) => {
311311
`);
312312
};
313313

314-
module.exports=renderTopLanguages;
315-
module.exports.MIN_CARD_WIDTH=MIN_CARD_WIDTH;
314+
export{renderTopLanguages,MIN_CARD_WIDTH};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp