Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
hyperframes/scripts/player-cdn-pin.test.ts at main · SamSammane/hyperframes · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
SamSammane
hyperframes
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
hyperframes
/
scripts
/
player-cdn-pin.test.ts
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
82 lines (74 loc) · 3.02 KB
main
Breadcrumbs
hyperframes
/
scripts
/
player-cdn-pin.test.ts
Copy path
Top
File metadata and controls
Code
Blame
82 lines (74 loc) · 3.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import
{
test
}
from
"node:test"
;
import
assert
from
"node:assert/strict"
;
import
{
execFileSync
}
from
"node:child_process"
;
import
{
readFileSync
}
from
"node:fs"
;
import
{
join
,
resolve
}
from
"node:path"
;
/**
* Every CDN reference to the player must ask for `latest`.
*
* A pinned line here fails silently and indefinitely. The catalog page still
* renders on the build the pin names, so nothing looks broken: the only symptom
* is that a fix published to npm never appears on the docs, which surfaces as
* "that bug is still there" weeks later rather than as a red check. That is
* exactly how the pin sat one minor line behind after a release, across 175
* generated pages and three hand-written files nobody thought to grep.
*
* The reference lives in 178 places because each generated page carries a
* self-contained `srcDoc` document, so this asserts on the whole tree rather
* than on the four sources a reader would think to check.
*/
const
ROOT
=
resolve
(
import
.
meta
.
dirname
,
".."
)
;
const
PLAYER_CDN
=
/
c
d
n
\.
j
s
d
e
l
i
v
r
\.
n
e
t
\/
n
p
m
\/
@
h
y
p
e
r
f
r
a
m
e
s
\/
p
l
a
y
e
r
@
(
[
^
/
"
'
`
\s
]
+
)
/
g
;
const
TEXT_FILE
=
/
\.
(
m
d
x
?
|
[
j
t
]
s
x
?
|
h
t
m
l
|
j
s
o
n
)
$
/
;
// The generator interpolates the range, so its source reads as a template
// rather than a literal version. Its value is asserted separately below.
const
TEMPLATE_REFERENCE
=
"${playerVersionRange}"
;
/**
* Tracked files only, via git rather than a directory walk: it is one call, and
* it skips `node_modules` and build output for free because they are ignored.
*/
function
trackedTextFiles
(
)
:
string
[
]
{
const
listing
=
execFileSync
(
"git"
,
[
"ls-files"
,
"-z"
,
"docs"
,
"scripts"
,
"packages"
,
"registry"
]
,
{
cwd
:
ROOT
,
encoding
:
"utf-8"
,
maxBuffer
:
64
*
1024
*
1024
,
}
,
)
;
return
listing
.
split
(
"\0"
)
.
filter
(
(
file
)
=>
TEXT_FILE
.
test
(
file
)
)
;
}
function
pinnedReferences
(
)
:
{
file
:
string
;
version
:
string
}
[
]
{
const
found
:
{
file
:
string
;
version
:
string
}
[
]
=
[
]
;
for
(
const
file
of
trackedTextFiles
(
)
)
{
const
text
=
readFileSync
(
join
(
ROOT
,
file
)
,
"utf-8"
)
;
for
(
const
match
of
text
.
matchAll
(
PLAYER_CDN
)
)
{
found
.
push
(
{
file
,
version
:
match
[
1
]
as
string
}
)
;
}
}
return
found
;
}
test
(
"every player CDN reference asks for latest"
,
(
)
=>
{
const
references
=
pinnedReferences
(
)
;
// A guard that passes because it matched nothing is worse than no guard.
assert
.
ok
(
references
.
length
>
100
,
`expected the catalog pages to reference the player CDN, found
${
references
.
length
}
`
,
)
;
const
pinned
=
references
.
filter
(
(
r
)
=>
r
.
version
!==
"latest"
&&
r
.
version
!==
TEMPLATE_REFERENCE
,
)
;
assert
.
deepEqual
(
pinned
,
[
]
,
`pinned player versions found. Use @latest instead:\n
${
pinned
.
map
(
(
r
)
=>
`
${
r
.
file
}
: @
${
r
.
version
}
`
)
.
join
(
"\n"
)
}
`
,
)
;
}
)
;
test
(
"the generator emits latest, so regenerating cannot reintroduce a pin"
,
(
)
=>
{
const
generator
=
readFileSync
(
join
(
ROOT
,
"scripts/generate-catalog-pages.ts"
)
,
"utf-8"
)
;
const
range
=
generator
.
match
(
/
c
o
n
s
t
p
l
a
y
e
r
V
e
r
s
i
o
n
R
a
n
g
e
=
"
(
[
^
"
]
+
)
"
/
)
?.
[
1
]
;
assert
.
equal
(
range
,
"latest"
)
;
}
)
;
You can’t perform that action at this time.