@pocketprep/types 1.19.43 → 1.19.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/scripts/pick-version.js +14 -0
- package/.github/workflows/npm-publish.yml +38 -1
- package/API/StudyStats.d.ts +21 -0
- package/API/index.d.ts +1 -0
- package/README.md +7 -0
- package/package.json +4 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Usage: node pick-version.js <version on npm> <version in package.json>
|
|
2
|
+
// Publishes the package.json version only when a PR raised its major or minor; otherwise bumps npm's patch.
|
|
3
|
+
const [ published, requested ] = process.argv.slice(2).map(version => version.split('.').map(Number))
|
|
4
|
+
|
|
5
|
+
const raisesMajor = requested[0] > published[0]
|
|
6
|
+
const raisesMinor = requested[0] === published[0] && requested[1] > published[1]
|
|
7
|
+
|
|
8
|
+
if (raisesMajor || raisesMinor) {
|
|
9
|
+
// respect the major/minor version bump that's already been committed
|
|
10
|
+
console.log(requested.join('.'))
|
|
11
|
+
} else {
|
|
12
|
+
// just bump the patch version
|
|
13
|
+
console.log([ published[0], published[1], published[2] + 1 ].join('.'))
|
|
14
|
+
}
|
|
@@ -7,18 +7,55 @@ on:
|
|
|
7
7
|
push:
|
|
8
8
|
branches:
|
|
9
9
|
- master
|
|
10
|
+
# Only changes that reach consumers should publish; README/CI-only merges would otherwise ship an identical patch
|
|
11
|
+
paths:
|
|
12
|
+
- '**.ts'
|
|
13
|
+
- index.js
|
|
14
|
+
- package.json
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
|
|
17
|
+
# Back-to-back merges must take turns, or both runs would pick the same patch version
|
|
18
|
+
concurrency:
|
|
19
|
+
group: npm-publish
|
|
20
|
+
cancel-in-progress: false
|
|
10
21
|
|
|
11
22
|
jobs:
|
|
12
23
|
build-and-publish:
|
|
13
24
|
runs-on: ubuntu-latest
|
|
25
|
+
permissions:
|
|
26
|
+
contents: write
|
|
14
27
|
steps:
|
|
28
|
+
# Check out the tip of master rather than the triggering commit, so a queued run
|
|
29
|
+
# sees the version commit pushed by the run before it
|
|
15
30
|
- uses: actions/checkout@v2
|
|
31
|
+
with:
|
|
32
|
+
ref: master
|
|
16
33
|
- uses: actions/setup-node@v2
|
|
17
34
|
with:
|
|
18
35
|
node-version: 24.22.1
|
|
19
36
|
registry-url: https://registry.npmjs.org/
|
|
20
37
|
- run: npm ci
|
|
21
38
|
- run: npm run lint
|
|
39
|
+
- name: Pick version
|
|
40
|
+
id: version
|
|
41
|
+
run: |
|
|
42
|
+
published=$(npm view @pocketprep/types version)
|
|
43
|
+
requested=$(node -p "require('./package.json').version")
|
|
44
|
+
version=$(node .github/scripts/pick-version.js "$published" "$requested")
|
|
45
|
+
echo "npm has $published, package.json has $requested, publishing $version"
|
|
46
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
47
|
+
- name: Commit version
|
|
48
|
+
run: |
|
|
49
|
+
npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version
|
|
50
|
+
if git diff --quiet -- package.json package-lock.json; then
|
|
51
|
+
exit 0
|
|
52
|
+
fi
|
|
53
|
+
git config user.name "github-actions[bot]"
|
|
54
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
55
|
+
git add package.json package-lock.json
|
|
56
|
+
git commit -m "v${{ steps.version.outputs.version }}"
|
|
57
|
+
git push origin master
|
|
58
|
+
# Publish after the push so a rejected push leaves nothing on npm, and a rerun starts clean
|
|
22
59
|
- run: npm publish
|
|
23
60
|
env:
|
|
24
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
61
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TMockExamStudyStats, TStudyStats } from '../Study/Cloud'
|
|
2
|
+
|
|
3
|
+
export interface FetchStudyStatsParams {
|
|
4
|
+
examMetadataId: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The caller's study stats for one exam version. The same shape the Parse server returns under
|
|
9
|
+
* `studyStats` from `fetchUserData-v2` and `recordQuiz-v2`, so a client renders either source
|
|
10
|
+
* with one code path.
|
|
11
|
+
*/
|
|
12
|
+
export interface FetchStudyStatsResponse {
|
|
13
|
+
studyStats: {
|
|
14
|
+
standard: Omit<TStudyStats, 'examCommunityAverage'>
|
|
15
|
+
mockExam?: {
|
|
16
|
+
overall: TMockExamStudyStats
|
|
17
|
+
byMockExamId: { [mockExamId: string]: TMockExamStudyStats }
|
|
18
|
+
}
|
|
19
|
+
combined: Omit<TStudyStats, 'examCommunityAverage'>
|
|
20
|
+
}
|
|
21
|
+
}
|
package/API/index.d.ts
CHANGED
package/README.md
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
# Pocket Prep Types
|
|
2
2
|
One repo, under TypeScript, with reuse and strict typing for all.
|
|
3
|
+
|
|
4
|
+
## Versioning
|
|
5
|
+
Don't bump the version for routine changes. Merging to `master` publishes to npm with the next patch version and
|
|
6
|
+
commits that version back to `master`.
|
|
7
|
+
|
|
8
|
+
For a minor or major release, run `npm run minor` or `npm run major` in your PR. The publish workflow uses that
|
|
9
|
+
version as written.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pocketprep/types",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.44",
|
|
4
4
|
"description": "Pocket Prep type declarations",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"lint": "eslint '**/*.ts'",
|
|
20
20
|
"types-copy": "pwd | pbcopy",
|
|
21
|
-
"patch": "npm version patch --no-git-tag-version"
|
|
21
|
+
"patch": "npm version patch --no-git-tag-version",
|
|
22
|
+
"minor": "npm version minor --no-git-tag-version",
|
|
23
|
+
"major": "npm version major --no-git-tag-version"
|
|
22
24
|
},
|
|
23
25
|
"homepage": "https://github.com/Pocket-Prep/types#readme",
|
|
24
26
|
"dependencies": {
|