@virmator/init 14.37.1 → 14.38.0

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/README.md CHANGED
@@ -14,7 +14,10 @@ A default plugin for [virmator](https://www.npmjs.com/package/virmator).
14
14
  - Configs
15
15
  - .github/workflows/build-for-gh-pages.yml
16
16
  - .github/workflows/tagged-release.yml
17
+ - .github/workflows/pr-review-status.yml
18
+ - .github/workflows/pr-review-trigger.yml
17
19
  - .github/workflows/tests.yml
20
+ - configs/pull-request-vir.config.ts
18
21
  - .vscode/settings.json
19
22
  - src/ui/elements/vir-app.element.ts
20
23
  - src/index.html
@@ -0,0 +1,112 @@
1
+ name: pr-review-status
2
+ 'on':
3
+ pull_request_target:
4
+ types:
5
+ - opened
6
+ - reopened
7
+ - assigned
8
+ - unassigned
9
+ - labeled
10
+ - edited
11
+ - synchronize
12
+ - ready_for_review
13
+ - review_requested
14
+ - review_request_removed
15
+ workflow_run:
16
+ workflows:
17
+ - pr-review-trigger
18
+ types:
19
+ - completed
20
+ permissions:
21
+ contents: read
22
+ concurrency:
23
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.head_sha }}
24
+ cancel-in-progress: true
25
+ jobs:
26
+ check-reviews:
27
+ name: Check Review Status
28
+ if: github.event_name == 'pull_request_target'
29
+ permissions:
30
+ actions: write
31
+ contents: read
32
+ pull-requests: write
33
+ issues: write
34
+ runs-on: ubuntu-latest
35
+ timeout-minutes: 5
36
+ steps:
37
+ - name: Checkout trusted workflow source
38
+ uses: actions/checkout@v6.0.2
39
+ with:
40
+ fetch-depth: 0
41
+ ref: ${{ github.event.pull_request.base.sha || github.sha }}
42
+ # pull-request-vir runs `git merge-base` on the pull request head, which checkout does not fetch for fork pull requests.
43
+ # Only the git objects are fetched; nothing from the pull request is checked out or run.
44
+ - name: Fetch pull request head commits
45
+ env:
46
+ PR_NUMBER: ${{ github.event.pull_request.number }}
47
+ run: git fetch --no-tags origin "refs/pull/${PR_NUMBER}/head"
48
+ - name: Run Checks
49
+ uses: electrovir/pull-request-vir@v1.8.4
50
+ with:
51
+ config_file: ./configs/pull-request-vir.config.ts
52
+ refresh-review-status:
53
+ name: Refresh Review Status
54
+ if: github.event_name == 'workflow_run'
55
+ permissions:
56
+ actions: write
57
+ contents: read
58
+ pull-requests: read
59
+ runs-on: ubuntu-latest
60
+ timeout-minutes: 10
61
+ steps:
62
+ - name: Re-run the review status check on the pull request head
63
+ env:
64
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65
+ HEAD_OWNER: ${{ github.event.workflow_run.head_repository.owner.login }}
66
+ HEAD_REF: ${{ github.event.workflow_run.head_branch }}
67
+ HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
68
+ JOB_NAME: Check Review Status
69
+ WORKFLOW_FILE: pr-review-status.yml
70
+ run: |
71
+ function latestRunId() {
72
+ gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/workflows/${WORKFLOW_FILE}/runs" -f event=pull_request_target -f branch="${HEAD_REF}" -f head_sha="${HEAD_SHA}" -f per_page=1 --jq '.workflow_runs[0].id // ""'
73
+ }
74
+
75
+ # `workflow_run.pull_requests` is empty for fork pull requests, so look the pull request up by its head.
76
+ prNumber="$(gh api -X GET "repos/${GITHUB_REPOSITORY}/pulls" -f state=open -f head="${HEAD_OWNER}:${HEAD_REF}" --jq '.[0].number // ""')"
77
+ if [[ -z "$prNumber" ]]; then
78
+ echo "No open pull request for ${HEAD_OWNER}:${HEAD_REF}."
79
+ exit 0
80
+ fi
81
+
82
+ jobId=''
83
+ # The workflows API answers 404 for a workflow file that is not on the default branch yet, and `gh` prints that error body to stdout.
84
+ if ! runId="$(latestRunId 2>/dev/null)"; then
85
+ runId=''
86
+ fi
87
+ if [[ -n "$runId" ]]; then
88
+ jobId="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${runId}/jobs" --jq '.jobs[] | select(.name == env.JOB_NAME) | .id')"
89
+ fi
90
+
91
+ if [[ -z "$jobId" ]]; then
92
+ echo "No ${JOB_NAME} job for ${HEAD_SHA} yet; its own run will publish the verdict."
93
+ exit 0
94
+ fi
95
+
96
+ # A job still in flight may have read the review state before this review landed, so wait for it and re-run it regardless.
97
+ # GitHub also refuses (HTTP 403) to re-run a finished job while other jobs in its run are still going.
98
+ until [[ "$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${runId}" --jq .status)" == 'completed' ]]; do
99
+ sleep 20
100
+ done
101
+
102
+ # A newer run for this pull request cancels this one, and re-running a job here would cancel that newer run in turn.
103
+ # Assigned first so a failed lookup stops the script under `bash -e` rather than reading as a newer run.
104
+ currentHeadSha="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${prNumber}" --jq .head.sha)"
105
+ newestRunId="$(latestRunId)"
106
+ if [[ "$currentHeadSha" != "$HEAD_SHA" || "$newestRunId" != "$runId" ]]; then
107
+ echo "A newer ${WORKFLOW_FILE} run replaced ${runId}; its own ${JOB_NAME} publishes the verdict."
108
+ exit 0
109
+ fi
110
+
111
+ gh api -X POST "repos/${GITHUB_REPOSITORY}/actions/jobs/${jobId}/rerun" --silent
112
+ echo "Re-ran ${JOB_NAME} in run ${runId}."
@@ -0,0 +1,16 @@
1
+ # Fork pull requests get a read-only token on `pull_request_review`, so this only signals pr-review-status,
2
+ # which re-runs its review check from a `workflow_run` trigger instead.
3
+ name: pr-review-trigger
4
+ 'on':
5
+ pull_request_review:
6
+ types:
7
+ - submitted
8
+ - dismissed
9
+ permissions: {}
10
+ jobs:
11
+ review-changed:
12
+ name: Review Changed
13
+ runs-on: ubuntu-latest
14
+ timeout-minutes: 5
15
+ steps:
16
+ - run: echo "Review ${{ github.event.action }} on pull request ${{ github.event.pull_request.number }}."
package/configs/npmrc.txt CHANGED
@@ -17,6 +17,7 @@ min-release-age-exclude[]=catch-exit
17
17
  min-release-age-exclude[]=cli-vir
18
18
  min-release-age-exclude[]=cluster-vir
19
19
  min-release-age-exclude[]=config-vir
20
+ min-release-age-exclude[]=create-ensure-service
20
21
  min-release-age-exclude[]=cron-vir
21
22
  min-release-age-exclude[]=csv-sql-engine
22
23
  min-release-age-exclude[]=date-vir
@@ -27,11 +28,13 @@ min-release-age-exclude[]=device-navigation
27
28
  min-release-age-exclude[]=docker-vir
28
29
  min-release-age-exclude[]=element-book
29
30
  min-release-age-exclude[]=element-vir
31
+ min-release-age-exclude[]=ensure-service
30
32
  min-release-age-exclude[]=execute-in-browser
31
33
  min-release-age-exclude[]=fsm-vir
32
34
  min-release-age-exclude[]=fuzzy-vir
33
35
  min-release-age-exclude[]=gamepad-type
34
36
  min-release-age-exclude[]=html-spec-tags
37
+ min-release-age-exclude[]=hub-vir
35
38
  min-release-age-exclude[]=i18n-vir
36
39
  min-release-age-exclude[]=indexed-vir
37
40
  min-release-age-exclude[]=input-device-handler
@@ -0,0 +1,30 @@
1
+ import type {Config} from 'pull-request-vir';
2
+
3
+ /**
4
+ * Read straight from `process.env` because the action imports this file without installing this
5
+ * repo's dependencies, so runtime imports would fail.
6
+ */
7
+ const repoOwner = process.env.GITHUB_REPOSITORY_OWNER;
8
+ if (!repoOwner) {
9
+ throw new Error('Missing GITHUB_REPOSITORY_OWNER env var.');
10
+ }
11
+
12
+ export const config: Config = {
13
+ assignToAuthor: true,
14
+ blockNoMerge: true,
15
+ ignoreDraft: true,
16
+ reviewRules: [
17
+ {
18
+ autoAdd: true,
19
+ users: [
20
+ repoOwner,
21
+ ],
22
+ required: 1,
23
+ userOverrides: {
24
+ [repoOwner]: {
25
+ required: 0,
26
+ },
27
+ },
28
+ },
29
+ ],
30
+ };
package/dist/init.d.ts CHANGED
@@ -46,6 +46,32 @@ export declare const virmatorInitPlugin: Readonly<Readonly<{
46
46
  };
47
47
  readonly required: false;
48
48
  };
49
+ readonly ghPrReviewStatus: {
50
+ readonly copyFromPath: string;
51
+ readonly copyToPath: string;
52
+ readonly env: {
53
+ readonly node: true;
54
+ readonly web: true;
55
+ };
56
+ readonly packageType: {
57
+ readonly package: true;
58
+ readonly "mono-root": true;
59
+ };
60
+ readonly required: false;
61
+ };
62
+ readonly ghPrReviewTrigger: {
63
+ readonly copyFromPath: string;
64
+ readonly copyToPath: string;
65
+ readonly env: {
66
+ readonly node: true;
67
+ readonly web: true;
68
+ };
69
+ readonly packageType: {
70
+ readonly package: true;
71
+ readonly "mono-root": true;
72
+ };
73
+ readonly required: false;
74
+ };
49
75
  readonly ghTestsNode: {
50
76
  readonly copyFromPath: string;
51
77
  readonly copyToPath: string;
@@ -70,6 +96,19 @@ export declare const virmatorInitPlugin: Readonly<Readonly<{
70
96
  };
71
97
  readonly required: false;
72
98
  };
99
+ readonly pullRequestVirConfig: {
100
+ readonly copyFromPath: string;
101
+ readonly copyToPath: string;
102
+ readonly env: {
103
+ readonly node: true;
104
+ readonly web: true;
105
+ };
106
+ readonly packageType: {
107
+ readonly package: true;
108
+ readonly "mono-root": true;
109
+ };
110
+ readonly required: false;
111
+ };
73
112
  readonly vscodeSettings: {
74
113
  readonly copyFromPath: string;
75
114
  readonly copyToPath: string;
@@ -332,6 +371,32 @@ export declare const virmatorInitPlugin: Readonly<Readonly<{
332
371
  };
333
372
  readonly required: false;
334
373
  };
374
+ readonly ghPrReviewStatus: {
375
+ readonly copyFromPath: string;
376
+ readonly copyToPath: string;
377
+ readonly env: {
378
+ readonly node: true;
379
+ readonly web: true;
380
+ };
381
+ readonly packageType: {
382
+ readonly package: true;
383
+ readonly "mono-root": true;
384
+ };
385
+ readonly required: false;
386
+ };
387
+ readonly ghPrReviewTrigger: {
388
+ readonly copyFromPath: string;
389
+ readonly copyToPath: string;
390
+ readonly env: {
391
+ readonly node: true;
392
+ readonly web: true;
393
+ };
394
+ readonly packageType: {
395
+ readonly package: true;
396
+ readonly "mono-root": true;
397
+ };
398
+ readonly required: false;
399
+ };
335
400
  readonly ghTestsNode: {
336
401
  readonly copyFromPath: string;
337
402
  readonly copyToPath: string;
@@ -356,6 +421,19 @@ export declare const virmatorInitPlugin: Readonly<Readonly<{
356
421
  };
357
422
  readonly required: false;
358
423
  };
424
+ readonly pullRequestVirConfig: {
425
+ readonly copyFromPath: string;
426
+ readonly copyToPath: string;
427
+ readonly env: {
428
+ readonly node: true;
429
+ readonly web: true;
430
+ };
431
+ readonly packageType: {
432
+ readonly package: true;
433
+ readonly "mono-root": true;
434
+ };
435
+ readonly required: false;
436
+ };
359
437
  readonly vscodeSettings: {
360
438
  readonly copyFromPath: string;
361
439
  readonly copyToPath: string;
package/dist/init.js CHANGED
@@ -19,6 +19,17 @@ const deps = {
19
19
  },
20
20
  type: NpmDepType.Dev,
21
21
  },
22
+ 'pull-request-vir': {
23
+ env: {
24
+ [RuntimeEnv.Node]: true,
25
+ [RuntimeEnv.Web]: true,
26
+ },
27
+ packageType: {
28
+ [PackageType.TopPackage]: true,
29
+ [PackageType.MonoRoot]: true,
30
+ },
31
+ type: NpmDepType.Dev,
32
+ },
22
33
  runstorm: {
23
34
  env: {
24
35
  [RuntimeEnv.Node]: true,
@@ -102,6 +113,32 @@ export const virmatorInitPlugin = defineVirmatorPlugin(import.meta.dirname, {
102
113
  },
103
114
  required: false,
104
115
  },
116
+ ghPrReviewStatus: {
117
+ copyFromPath: join('configs', 'github', 'workflows', 'pr-review-status.yml'),
118
+ copyToPath: join('.github', 'workflows', 'pr-review-status.yml'),
119
+ env: {
120
+ [RuntimeEnv.Node]: true,
121
+ [RuntimeEnv.Web]: true,
122
+ },
123
+ packageType: {
124
+ [PackageType.TopPackage]: true,
125
+ [PackageType.MonoRoot]: true,
126
+ },
127
+ required: false,
128
+ },
129
+ ghPrReviewTrigger: {
130
+ copyFromPath: join('configs', 'github', 'workflows', 'pr-review-trigger.yml'),
131
+ copyToPath: join('.github', 'workflows', 'pr-review-trigger.yml'),
132
+ env: {
133
+ [RuntimeEnv.Node]: true,
134
+ [RuntimeEnv.Web]: true,
135
+ },
136
+ packageType: {
137
+ [PackageType.TopPackage]: true,
138
+ [PackageType.MonoRoot]: true,
139
+ },
140
+ required: false,
141
+ },
105
142
  ghTestsNode: {
106
143
  copyFromPath: join('configs', 'github', 'workflows', 'tests-node.yml'),
107
144
  copyToPath: join('.github', 'workflows', 'tests.yml'),
@@ -126,6 +163,19 @@ export const virmatorInitPlugin = defineVirmatorPlugin(import.meta.dirname, {
126
163
  },
127
164
  required: false,
128
165
  },
166
+ pullRequestVirConfig: {
167
+ copyFromPath: join('configs', 'pull-request-vir.config.ts'),
168
+ copyToPath: join('configs', 'pull-request-vir.config.ts'),
169
+ env: {
170
+ [RuntimeEnv.Node]: true,
171
+ [RuntimeEnv.Web]: true,
172
+ },
173
+ packageType: {
174
+ [PackageType.TopPackage]: true,
175
+ [PackageType.MonoRoot]: true,
176
+ },
177
+ required: false,
178
+ },
129
179
  vscodeSettings: {
130
180
  copyFromPath: join('configs', 'vscode', 'settings.json'),
131
181
  copyToPath: join('.vscode', 'settings.json'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/init",
3
- "version": "14.37.1",
3
+ "version": "14.38.0",
4
4
  "description": "Default init plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -31,16 +31,17 @@
31
31
  "test:update": "npm test"
32
32
  },
33
33
  "dependencies": {
34
- "@augment-vir/assert": "^32.4.1",
35
- "@augment-vir/common": "^32.4.1",
36
- "@augment-vir/node": "^32.4.1",
37
- "@virmator/core": "^14.37.1",
38
- "simple-git": "^3.36.0"
34
+ "@augment-vir/assert": "^32.5.0",
35
+ "@augment-vir/common": "^32.5.0",
36
+ "@augment-vir/node": "^32.5.0",
37
+ "@virmator/core": "^14.38.0",
38
+ "simple-git": "^4.0.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@types/node": "^26.6.2",
41
+ "@types/node": "^26.6.5",
42
42
  "element-vir": "^27.0.2",
43
43
  "mono-vir": "^2.5.1",
44
+ "pull-request-vir": "^1.8.4",
44
45
  "runstorm": "^1.1.0",
45
46
  "tsx": "^4.23.15"
46
47
  },