-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat/rollback card (#40) * Doc/wrong annotations * Fix/missing 'last_review' in the data returned by the 'createEmptyCard' function * Fix/incorrect log in record_log * Feat/rollback card utilizing the current card and log * Test/rollback * Test/first repeat (#39) * Feat/forget (#42) * Feat/forget * cherry-pick Feat/grades * Fix/elapsed days (#45) * Fix/ incorrect calculation of elapsed_days in the revlog caused by rollback * pref/remove calculation of last_elapsed_days by rollback * Chore/rollup (#46) * Fix/Circular Dependencies * chore/compilation using Rollup * example/update * Chore/rollup (#47) * pref/remove umd * Chore/rollup (#48) * fix/cannot read properties of undefined in umd.js * pref/remove umd.js * Refactor/remove dotenv (#49) * Fix/forget (#50) * Fix/wrong scheduled_days in forget * Chore/example (#51) * chore/change example * chroe/deploy github pages * Fix/README.md * pref/update workflow * chore/add pr-test-action
- Loading branch information
Showing
31 changed files
with
2,835 additions
and
978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
["@babel/env", {"modules": false}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Build docs | ||
run: pnpm run docs | ||
- name: Copy example folder | ||
run: cp -R example docs/example | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: gh-pages | ||
folder: docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Publish Beta Package to npm.js | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: pnpm/[email protected] | ||
with: | ||
version: 8.7.1 | ||
- run: pnpm install | ||
- run: pnpm lint | ||
- run: pnpm test | ||
- run: pnpm build | ||
- uses: JS-DevTools/npm-publish@v2 | ||
with: | ||
token: ${{secrets.npm_token}} | ||
provenance: true | ||
tag: beta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,25 +6,12 @@ name: Publish Package to npm.js | |
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- master | ||
repository_dispatch: | ||
types: [publish-npm] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: pnpm/[email protected] | ||
with: | ||
version: 8.7.1 | ||
- run: pnpm install | ||
- run: pnpm lint | ||
- run: pnpm test | ||
- run: pnpm build | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
@@ -35,6 +22,8 @@ jobs: | |
with: | ||
version: 8.7.1 | ||
- run: pnpm install | ||
- run: pnpm lint | ||
- run: pnpm test | ||
- run: pnpm build | ||
- uses: JS-DevTools/npm-publish@v2 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: PR Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
checks: write | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
|
||
- uses: pnpm/[email protected] | ||
with: | ||
version: 8.7.1 | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run tests | ||
run: pnpm test | ||
|
||
- name: jest coverage report | ||
uses: ArtiomTr/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check test status | ||
id: test-status | ||
run: echo "::set-output name=status::$(if grep -q 'Test failed' test-results.txt; then echo 'failure'; else echo 'success'; fi)" | ||
|
||
merge: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
if: ${{ needs.test.outputs.status == 'success' }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Trigger npm-publish workflow | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: ishiko732/ts-fsrs | ||
event-type: publish-npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Ref:https://github.com/ishiko732/ts-fsrs/issues/44 | ||
|
||
import { fsrs, FSRS, createEmptyCard, Rating, Grade } from "../src/fsrs"; | ||
|
||
describe("elapsed_days", () => { | ||
const f: FSRS = fsrs(); | ||
|
||
const createDue = new Date(Date.UTC(2023, 9, 18, 14, 32, 3, 370)); | ||
const grades: Grade[] = [ | ||
Rating.Good, | ||
Rating.Again, | ||
Rating.Again, | ||
Rating.Good, | ||
]; | ||
let currentLog = null; | ||
let index = 0; | ||
let card = createEmptyCard(createDue); | ||
test("first repeat[Rating.Good]", () => { | ||
const firstDue = new Date(Date.UTC(2023, 10, 5, 8, 27, 2, 605)); | ||
const sc = f.repeat(card, firstDue); | ||
currentLog = sc[grades[index]].log; | ||
|
||
expect(currentLog.elapsed_days).toEqual(0); | ||
// console.log(sc[grades[index]].log) | ||
card = sc[grades[index]].card; | ||
// console.log(card) | ||
index += 1; | ||
}); | ||
|
||
test("second repeat[Rating.Again]", () => { | ||
// 2023-11-08 15:02:09.791,4.93,2023-11-05 08:27:02.605 | ||
const secondDue = new Date(Date.UTC(2023, 10, 8, 15, 2, 9, 791)); | ||
expect(card).not.toBeNull() | ||
const sc = f.repeat(card, secondDue); | ||
|
||
currentLog = sc[grades[index]].log; | ||
expect(currentLog.elapsed_days).toEqual(secondDue.diff(card.last_review as Date,'days')); // 3 | ||
expect(currentLog.elapsed_days).toEqual(3); // 0 | ||
card = sc[grades[index]].card; | ||
// console.log(card) | ||
// console.log(currentLog) | ||
index += 1; | ||
}); | ||
|
||
test("third repeat[Rating.Again]", () => { | ||
// 2023-11-08 15:02:30.799,4.93,2023-11-08 15:02:09.791 | ||
const secondDue = new Date(Date.UTC(2023, 10, 8, 15, 2, 30, 799)); | ||
expect(card).not.toBeNull() | ||
const sc = f.repeat(card, secondDue); | ||
|
||
currentLog = sc[grades[index]].log; | ||
expect(currentLog.elapsed_days).toEqual(secondDue.diff(card.last_review as Date,'days')); // 0 | ||
expect(currentLog.elapsed_days).toEqual(0); // 0 | ||
// console.log(currentLog); | ||
card = sc[grades[index]].card; | ||
// console.log(card); | ||
index += 1; | ||
}); | ||
|
||
test("fourth repeat[Rating.Good]", () => { | ||
// 2023-11-08 15:04:08.739,4.93,2023-11-08 15:02:30.799 | ||
const secondDue = new Date(Date.UTC(2023, 10, 8, 15, 4, 8, 739)); | ||
expect(card).not.toBeNull() | ||
const sc = f.repeat(card, secondDue); | ||
|
||
currentLog = sc[grades[index]].log; | ||
expect(currentLog.elapsed_days).toEqual(secondDue.diff(card.last_review as Date,'days')); // 0 | ||
expect(currentLog.elapsed_days).toEqual(0); // 0 | ||
// console.log(currentLog); | ||
card = sc[grades[index]].card; | ||
// console.log(card); | ||
index += 1; | ||
}) | ||
}); |
Oops, something went wrong.