Skip to content

Commit 3c4826e

Browse files
sirdeggenclaude
andauthored
Improve SonarCloud quality ratings (#35)
* Improve SonarCloud quality ratings * Set read-only mode for copied package manifests * Remove write bits from copied Docker resources * make code easier to read. Signed-off-by: Deggen <d.kellenschwiler@bsvassociation.org> * Fix HTTPWalletJSON originator handling * Fix all SonarCloud issues in PR #35 - Remove await from socket.emit() call (critical: non-Promise await) - Replace ternary with nullish coalescing in Engine.ts - Remove 30+ unnecessary type assertions in BTMS.ts (aliased string/number types) - Add --ignore-scripts to npm ci in all 18 package push.yaml workflows - Fix Dockerfile: add --ignore-scripts, pin tsx/typescript versions, merge RUN layers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix BTMS locking script hex conversion --------- Signed-off-by: Deggen <d.kellenschwiler@bsvassociation.org> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1b84dc4 commit 3c4826e

87 files changed

Lines changed: 1082 additions & 713 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ on:
66
pull_request:
77
branches: [main]
88

9-
permissions:
10-
contents: read
11-
pull-requests: read
12-
139
jobs:
1410
build-and-test:
1511
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pull-requests: read
1615
strategy:
1716
fail-fast: false
1817
matrix:
1918
node-version: [24.x]
2019

2120
steps:
22-
- uses: actions/checkout@v6
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2322
with:
2423
fetch-depth: 0
2524

26-
- uses: pnpm/action-setup@v6
25+
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6
2726

2827
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v6
28+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
3029
with:
3130
node-version: ${{ matrix.node-version }}
3231
cache: pnpm
@@ -56,7 +55,7 @@ jobs:
5655
5756
- name: Upload SDK coverage to Codecov
5857
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
59-
uses: codecov/codecov-action@v5
58+
uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5
6059
with:
6160
token: ${{ secrets.CODECOV_TOKEN }}
6261
files: packages/sdk/coverage/lcov.info
@@ -67,19 +66,21 @@ jobs:
6766

6867
- name: SonarCloud scan
6968
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
70-
uses: SonarSource/sonarqube-scan-action@v7
69+
uses: SonarSource/sonarqube-scan-action@c7ee0f9df90b7aa20e8dcf9695dcfe2e7da5b4f2 # v7
7170
env:
7271
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7372

7473
conformance:
7574
name: Conformance Vectors
7675
runs-on: ubuntu-latest
7776
needs: [build-and-test]
77+
permissions:
78+
contents: read
7879
steps:
79-
- uses: actions/checkout@v6
80+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
8081

81-
- uses: pnpm/action-setup@v6
82-
- uses: actions/setup-node@v6
82+
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6
83+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
8384
with:
8485
node-version: 24
8586
cache: pnpm
@@ -94,7 +95,7 @@ jobs:
9495

9596
- name: Upload conformance reports
9697
if: always()
97-
uses: actions/upload-artifact@v7
98+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
9899
with:
99100
name: conformance-report
100101
path: conformance/reports/
@@ -104,7 +105,7 @@ jobs:
104105
# See conformance/GO_PLAN.md for migration status.
105106
- name: Publish conformance vectors
106107
if: github.ref == 'refs/heads/main'
107-
uses: actions/upload-artifact@v7
108+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
108109
with:
109110
name: conformance-vectors
110111
path: conformance/vectors/

.github/workflows/codegen.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ on:
66
branches: [main]
77
workflow_dispatch:
88

9-
permissions:
10-
contents: write
11-
129
jobs:
1310
generate:
1411
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
1514
steps:
16-
- uses: actions/checkout@v6
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1716

1817
# ── Go types (oapi-codegen) ───────────────────────────────────────────
1918
# NOTE: oapi-codegen does not yet support OpenAPI 3.1 nullable syntax
2019
# (type: [string, null]). Steps are continue-on-error until resolved.
2120
# Upstream: https://github.com/oapi-codegen/oapi-codegen/issues/373
22-
- uses: actions/setup-go@v5
21+
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
2322
with:
2423
go-version: '1.22'
2524
- name: Install oapi-codegen
@@ -47,7 +46,7 @@ jobs:
4746
> conformance/generated/messaging/types.gen.go
4847
4948
# ── TypeScript types (openapi-typescript) ────────────────────────────
50-
- uses: actions/setup-node@v6
49+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
5150
with:
5251
node-version: '24'
5352
- name: Generate TS types from overlay spec
@@ -67,7 +66,7 @@ jobs:
6766
-o conformance/generated/messaging/types.gen.d.ts
6867
6968
# ── Python types (datamodel-code-generator / pydantic v2) ────────────
70-
- uses: actions/setup-python@v6
69+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
7170
with:
7271
python-version: '3.12'
7372
- name: Install datamodel-code-generator
@@ -118,7 +117,7 @@ jobs:
118117
EOF
119118
120119
# ── Single commit for all generated files ────────────────────────────
121-
- uses: stefanzweifel/git-auto-commit-action@v5
120+
- uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5
122121
with:
123122
commit_message: "chore(codegen): regenerate types from OpenAPI specs"
124123
file_pattern: "conformance/generated/**"

.github/workflows/conformance.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
ts-runner:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v6
14-
- uses: actions/setup-node@v6
13+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
14+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
1515
with:
1616
node-version: '24'
17-
- uses: pnpm/action-setup@v6
17+
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6
1818
- name: Install deps
1919
run: pnpm install --no-frozen-lockfile
2020
- name: Build TS SDK
@@ -28,7 +28,7 @@ jobs:
2828
working-directory: ${{ github.workspace }}/conformance/runner/ts
2929
- name: Upload TS conformance reports
3030
if: always()
31-
uses: actions/upload-artifact@v7
31+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
3232
with:
3333
name: ts-conformance-reports
3434
path: conformance/reports/
@@ -38,7 +38,7 @@ jobs:
3838
# See conformance/GO_PLAN.md for migration status.
3939
- name: Publish conformance vectors
4040
if: github.ref == 'refs/heads/main'
41-
uses: actions/upload-artifact@v7
41+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
4242
with:
4343
name: conformance-vectors
4444
path: conformance/vectors/

.github/workflows/docs-deploy.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,23 @@ on:
1111
- '.github/workflows/docs-deploy.yml'
1212
workflow_dispatch:
1313

14-
permissions:
15-
contents: read
16-
pages: write
17-
id-token: write
18-
1914
concurrency:
2015
group: pages
2116
cancel-in-progress: false
2217

2318
jobs:
2419
build:
2520
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
2623
steps:
27-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2825
with:
2926
fetch-depth: 0
3027

31-
- uses: pnpm/action-setup@v6
28+
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6
3229

33-
- uses: actions/setup-node@v6
30+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
3431
with:
3532
node-version: '24'
3633
cache: 'pnpm'
@@ -52,18 +49,21 @@ jobs:
5249
env:
5350
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5451

55-
- uses: actions/configure-pages@v5
52+
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
5653

57-
- uses: actions/upload-pages-artifact@v3
54+
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
5855
with:
5956
path: docs-site/dist
6057

6158
deploy:
6259
needs: build
6360
runs-on: ubuntu-latest
61+
permissions:
62+
pages: write
63+
id-token: write
6464
environment:
6565
name: github-pages
6666
url: ${{ steps.deployment.outputs.page_url }}
6767
steps:
6868
- id: deployment
69-
uses: actions/deploy-pages@v5
69+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
id-token: write # required for npm OIDC provenance
1515

1616
steps:
17-
- uses: actions/checkout@v6
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1818
with:
1919
fetch-depth: 0
2020

21-
- uses: pnpm/action-setup@v6
21+
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6
2222

23-
- uses: actions/setup-node@v6
23+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2424
with:
2525
node-version: 24
2626
registry-url: https://registry.npmjs.org

docs-site/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<meta name="theme-color" content="#0c0c14" />
7-
<link rel="preconnect" href="https://fonts.googleapis.com" />
8-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet" />
107
<title>ts-stack</title>
118
</head>
129
<body>

docs-site/scripts/check-links.mjs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,29 @@ function walk(dir) {
2424
const files = walk(DOCS_ROOT)
2525
let errors = 0
2626

27+
function extractMarkdownLinks(content) {
28+
const links = []
29+
let offset = 0
30+
while (offset < content.length) {
31+
const labelEnd = content.indexOf('](', offset)
32+
if (labelEnd === -1) break
33+
34+
const linkStart = labelEnd + 2
35+
const linkEnd = content.indexOf(')', linkStart)
36+
if (linkEnd === -1) break
37+
38+
links.push(content.slice(linkStart, linkEnd))
39+
offset = linkEnd + 1
40+
}
41+
return links
42+
}
43+
2744
for (const file of files) {
2845
const content = readFileSync(file, 'utf8')
2946
const dir = dirname(file)
3047

31-
const linkPattern = /\[([^\]]*)\]\(([^)]+)\)/g
32-
let match
33-
while ((match = linkPattern.exec(content)) !== null) {
34-
const href = match[2].split('#')[0].split('?')[0]
48+
for (const link of extractMarkdownLinks(content)) {
49+
const href = link.split('#')[0].split('?')[0]
3550
if (!href) continue
3651
if (href.startsWith('http') || href.startsWith('//') || href.startsWith('mailto:')) continue
3752
if (!href.endsWith('.md') && !href.includes('/')) continue

docs-site/scripts/fetch-typedoc.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
2-
import { execSync } from 'child_process'
3-
import { existsSync, mkdirSync, rmSync } from 'fs'
2+
import { execFileSync } from 'child_process'
3+
import { cpSync, existsSync, mkdirSync, rmSync } from 'fs'
44
import { resolve, dirname } from 'path'
55
import { fileURLToPath } from 'url'
66

@@ -14,24 +14,24 @@ if (!existsSync(DIST)) {
1414
process.exit(0)
1515
}
1616

17-
function run(cmd, opts = {}) {
18-
console.log(`$ ${cmd}`)
19-
execSync(cmd, { stdio: 'inherit', cwd: ROOT, ...opts })
17+
function run(command, args, opts = {}) {
18+
console.log(`$ ${[command, ...args].join(' ')}`)
19+
execFileSync(command, args, { stdio: 'inherit', cwd: ROOT, ...opts })
2020
}
2121

2222
try {
2323
if (existsSync(TMP)) rmSync(TMP, { recursive: true })
2424
mkdirSync(TMP, { recursive: true })
2525

26-
run('git fetch origin gh-pages --depth=1')
26+
run('git', ['fetch', 'origin', 'gh-pages', '--depth=1'])
2727

2828
try {
29-
run(`git --work-tree="${TMP}" checkout origin/gh-pages -- api/`)
29+
run('git', ['--work-tree', TMP, 'checkout', 'origin/gh-pages', '--', 'api/'])
3030
const apiSrc = resolve(TMP, 'api')
3131
const apiDst = resolve(DIST, 'api')
3232
if (existsSync(apiSrc)) {
3333
if (existsSync(apiDst)) rmSync(apiDst, { recursive: true })
34-
run(`cp -R "${apiSrc}" "${apiDst}"`)
34+
cpSync(apiSrc, apiDst, { recursive: true })
3535
console.log('TypeDoc /api/ merged into dist/')
3636
} else {
3737
console.log('No api/ directory in gh-pages — skipping')

docs-site/src/components/Mermaid.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useRef, useState } from 'react'
1+
import { useEffect, useId, useRef, useState } from 'react'
22
import styles from './Mermaid.module.css'
33

44
interface Props {
@@ -7,6 +7,7 @@ interface Props {
77

88
export default function Mermaid({ code }: Props) {
99
const ref = useRef<HTMLDivElement>(null)
10+
const renderId = useId().replaceAll(':', '')
1011
const [error, setError] = useState<string | null>(null)
1112

1213
useEffect(() => {
@@ -35,7 +36,7 @@ export default function Mermaid({ code }: Props) {
3536
fontFamily: "'JetBrains Mono', monospace",
3637
})
3738

38-
const id = 'mermaid-' + Math.random().toString(36).slice(2)
39+
const id = `mermaid-${renderId}`
3940
mermaid
4041
.render(id, code)
4142
.then(({ svg }) => {

docs-site/src/components/SearchBox.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
}
8181

8282
.resultExcerpt {
83-
display: block;
8483
font-size: 0.8rem;
8584
color: var(--dev-text-dim);
8685
line-height: 1.4;

0 commit comments

Comments
 (0)