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

Node.js v22 対応 #1057

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
node-version: "22.13.0"
Copy link
Author

Choose a reason for hiding this comment

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

LTSの最新のバージョンに固定するように修正しました(ローカル環境のNode.jsとバージョンを固定化するため)が、問題あればコメントください。

Copy link

Choose a reason for hiding this comment

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

ローカル環境のNode.jsとバージョンが違うことで問題を生む可能性がありそうですね
そういう点で固定化するのは良いと思います 👍
あるいはこういうとき別の対処として package.json あるいは .nvmrc や .node-version-file を指定してワークツリーの目立つところのに配置して他のツールのサポート(e.g. nvm、mise)を受けられるようにしてみるのもいいかも
一度ご検討くださいませ

具体例:

    - uses: actions/setup-node@v4
      with:
        node-version-file: package.json
:

https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file

Copy link
Author

Choose a reason for hiding this comment

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

ファイル指定できること知見でした!ありがとうございます。package.jsonを参照する形に修正しました

cache: yarn
- name: install
run: yarn
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ All notable changes to this project will be documented in this file.
## [2025]

### Added

- Deep Linking support from Blackboard (OU)

## [2024]

### Added

- Version management feature (NII)
- Tag/note registration (OU)
- Word cloud (OU)
Expand All @@ -19,6 +21,7 @@ All notable changes to this project will be documented in this file.
## [2023]

### Added

- Video thumbnail display
- Viewing status timeline (OU)
- Names and Role Provisioning Services support (OU)
Expand All @@ -28,12 +31,14 @@ All notable changes to this project will be documented in this file.
- Deep Linking support

### Changed

- Removal of IP address-based client authentication
- Video interaction log improvement (NII)

## [2022]

### Added

- Keyword registration (NII)
- Multiple author registration (NII)
- License registration (NII)
Expand All @@ -50,6 +55,7 @@ All notable changes to this project will be documented in this file.
## [2021]

### Added

- LTI 1.1 authentication from Blackboard (OU)
- Viewing history (OU)
- Learning analytics (OU)
Expand All @@ -68,6 +74,7 @@ All notable changes to this project will be documented in this file.
## [2020]

### Added

- RDB support (NII)
- LTI 1.1 authentication from Moodle (NII)
- Role-based access control (NII)
Expand All @@ -76,14 +83,18 @@ All notable changes to this project will be documented in this file.
- Video interaction log output (NII)

### Changed

- Complete migration from PHP to TypeScript

## Development

- The initial development of this project was carried out by NII.

## Note

- Contribution attributions vary due to differences in documentation practices.

## Organization Abbreviations

- NII: National Institute of Informatics
- OU: Osaka University
- OU: Osaka University
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Contributors listed below have made various contributions to different aspects o
- National Institute of Informatics (2020 - )
- NPO Consortium TIES (2020 - )
- Osaka University (2021 - )
- Kumamoto University (2021 - )
- Kumamoto University (2021 - )
2 changes: 1 addition & 1 deletion README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ MIT

## funding

永続的な開発を続けるために、寄付を歓迎します。
永続的な開発を続けるために、寄付を歓迎します。
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ![ロゴ](docs/assets/chibichilo_s.png)CHiBi-CHiLO
# ![ロゴ](docs/assets/chibichilo_s.png)CHiBi-CHiLO

[English](README-en.md) | [日本語](README-ja.md)

Expand All @@ -9,9 +9,11 @@ LMS と外部接続する[LTI ツールプロバイダー](https://www.imsglobal
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fnpocccties%2Fchibichilo&env=SESSION_SECRET,DATABASE_URL)

## License

This project is released under the MIT License. The full text can be found in the [LICENSE file](LICENSE).

## Contributors

We appreciate contributions to this project. A list of all contributors can be found in the [CONTRIBUTORS file](CONTRIBUTORS.md).

These documents serve to ensure transparency and equality among all participants in the project, accurately reflecting each member's involvement and the collective nature of the project.
These documents serve to ensure transparency and equality among all participants in the project, accurately reflecting each member's involvement and the collective nature of the project.
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
volumes:
- postgres_data_v15:/var/lib/postgresql/data
app:
image: "node:18.17.1-alpine3.18"
image: "node:22.13.0-alpine3.21"
environment:
FRONTEND_ORIGIN: "http://localhost:3000"
SESSION_SECRET: super_secret_characters_for_session
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"storybook": "storybook dev -s ./public"
},
"engines": {
"node": "^16.13.0 || ^18.12.0 || ^20.0.0"
"node": "^18.12.0 || ^20.0.0 || ^22.13.0"
},
"dependencies": {
"@twemoji/api": "^15.0.3"
Expand Down
8 changes: 7 additions & 1 deletion server/utils/activity/upsertActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ function countTimeRange(
log.endMs < range.endMs &&
log.endMs - range.startMs > ACTIVITY_COUNT_INTERVAL_THRESHOLD_MS)
) {
if (range.count === undefined) {
Copy link
Author

Choose a reason for hiding this comment

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

Node.js v22関係なくおそらくlintが落ちていたようなので、修正しました(他のCIが通ることを検証したかったため)。

range.count = 0;
}
Copy link

Choose a reason for hiding this comment

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

一瞬だけ検討してみるくらいでOKですがこのように短く書いても読みやすい(個人差ありなので任意)かも

Suggested change
if (range.count === undefined) {
range.count = 0;
}
range.count ??= 0;

Copy link
Author

Choose a reason for hiding this comment

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

修正しました!

range.count += 1;
}
});
Expand Down Expand Up @@ -350,7 +353,10 @@ async function upsertActivity({
}

const timeRanges = merge(exists?.timeRanges ?? [], activity.timeRanges);
const timeRangeLogs = concatAndMerge(recentTimeRangeLogs, activity.timeRanges);
const timeRangeLogs = concatAndMerge(
recentTimeRangeLogs,
activity.timeRanges
);
const purgedTimeRangeLogs = purge(recentTimeRangeLogs, activity.timeRanges);

timeRangeCounts = countTimeRange(timeRangeCounts, purgedTimeRangeLogs);
Expand Down
135 changes: 69 additions & 66 deletions server/utils/book/importBooksUtil.ts
Copy link
Author

Choose a reason for hiding this comment

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

差分はformatの改行のみです。

Original file line number Diff line number Diff line change
Expand Up @@ -517,78 +517,81 @@ class ImportBooksUtil {
return;
}
zipfile.readEntry();
zipfile.on("entry", (entry) => {
// ディレクトリは fileName が '/' で終わっている
if (/\/$/.test(entry.fileName)) {
zipfile.readEntry();
} else {
const filename = path.join(this.tmpdir, entry.fileName);
const dirname = path.dirname(filename);
zipfile.openReadStream(entry, (err, readStream) => {
if (err) {
this.errors.push(`openReadStreamでエラーが発生しました。\n${err}`);
zipfile.readEntry();
return;
}
try {
if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true });
}
readStream.on("end", () => {
zipfile.readEntry();
});
const ws = fs.createWriteStream(filename);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readStream.pipe(ws).on("error", (err: any) => {
zipfile
.on("entry", (entry) => {
// ディレクトリは fileName が '/' で終わっている
if (/\/$/.test(entry.fileName)) {
zipfile.readEntry();
} else {
const filename = path.join(this.tmpdir, entry.fileName);
const dirname = path.dirname(filename);
zipfile.openReadStream(entry, (err, readStream) => {
if (err) {
this.errors.push(
`zip解凍中にファイルの書き込みに失敗しました。\n${err}`
`openReadStreamでエラーが発生しました。\n${err}`
);
zipfile.readEntry();
return;
}
try {
if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true });
}
readStream.on("end", () => {
zipfile.readEntry();
});
const ws = fs.createWriteStream(filename);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readStream.pipe(ws).on("error", (err: any) => {
this.errors.push(
`zip解凍中にファイルの書き込みに失敗しました。\n${err}`
);
readStream.destroy();
zipfile.readEntry();
});
} catch (err) {
this.errors.push(`zip解凍中に例外が発生しました。\n${err}`);
readStream.destroy();
zipfile.readEntry();
});
} catch (err) {
this.errors.push(`zip解凍中に例外が発生しました。\n${err}`);
readStream.destroy();
zipfile.readEntry();
}
});
}
})
.on("close", () => {
this.unzippedFiles = recursive(this.tmpdir);
const jsonfiles: string[] = this.unzippedFiles.filter((filename) =>
filename.toLowerCase().endsWith(".json")
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const jsons: any[] = [];
if (jsonfiles.length) {
for (const jsonfile of jsonfiles) {
try {
const json = JSON.parse(fs.readFileSync(jsonfile).toString());
jsons.push(...(Array.isArray(json) ? json : [json]));
} catch (e) {
this.errors.push(
`入力されたjsonテキストを解釈できません。\n${e}`
);
}
});
}
})
.on("close", () => {
this.unzippedFiles = recursive(this.tmpdir);
const jsonfiles: string[] = this.unzippedFiles.filter((filename) =>
filename.toLowerCase().endsWith(".json")
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const jsons: any[] = [];
if (jsonfiles.length) {
for (const jsonfile of jsonfiles) {
try {
const json = JSON.parse(fs.readFileSync(jsonfile).toString());
jsons.push(...(Array.isArray(json) ? json : [json]));
} catch (e) {
this.errors.push(
`入力されたjsonテキストを解釈できません。\n${e}`
);
}
}
} else {
this.errors.push("jsonファイルがありません。");
}
} else {
this.errors.push("jsonファイルがありません。");
}
if (this.errors.length) {
resolve({});
} else {
resolve(jsons);
}
})
.on("error", (error) => {
try {
resolve(JSON.parse(fs.readFileSync(file).toString()));
} catch (e) {
this.errors.push(`ファイルがzipではありません。\n${error}`);
resolve({});
}
});
if (this.errors.length) {
resolve({});
} else {
resolve(jsons);
}
})
.on("error", (error) => {
try {
resolve(JSON.parse(fs.readFileSync(file).toString()));
} catch (e) {
this.errors.push(`ファイルがzipではありません。\n${error}`);
resolve({});
}
});
});
});
}
Expand Down