Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ VelarOS HTML Artifacts is a dependency-free browser runtime with a small TypeScr

## Install

Authenticate npm for the private `@velaros-ai` GitHub Packages scope, then install:
`@velaros-ai/html-artifacts` is a public package hosted on GitHub Packages. GitHub's
npm registry currently still requires authentication to install public packages:
use a personal access token (classic) with at least `read:packages` locally, or the
repository-authorized `GITHUB_TOKEN` in GitHub Actions. Map the `@velaros-ai` scope
to `https://npm.pkg.github.com`, provide the token, then install:

```bash
npm install @velaros-ai/html-artifacts
Expand Down
6 changes: 5 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ VelarOS HTML Artifacts 是一个零运行时依赖的浏览器库。它统一负

## 安装

为 GitHub Packages 的私有 `@velaros-ai` scope 配置 npm 认证后安装:
`@velaros-ai/html-artifacts` 是托管在 GitHub Packages 上的公开包。GitHub 的 npm
registry 当前安装公开包仍然需要认证:本地使用至少具有 `read:packages` 权限的
personal access token(classic),GitHub Actions 使用已获仓库授权的
`GITHUB_TOKEN`。将 `@velaros-ai` scope 映射到
`https://npm.pkg.github.com`,提供 token 后安装:

```bash
npm install @velaros-ai/html-artifacts
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@velaros-ai/html-artifacts",
"version": "0.1.2",
"version": "0.1.3",
"description": "A framework-neutral streaming HTML artifact protocol and sandboxed iframe runtime.",
"keywords": [
"ai",
Expand Down
37 changes: 37 additions & 0 deletions scripts/check-package-contract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { fileURLToPath } from 'node:url'

const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const manifest = JSON.parse(await readFile(path.join(repositoryRoot, 'package.json'), 'utf8'))
const readme = await readFile(path.join(repositoryRoot, 'README.md'), 'utf8')
const chineseReadme = await readFile(
path.join(repositoryRoot, 'README.zh-CN.md'),
'utf8'
)
const documentation = await readFile(
path.join(repositoryRoot, 'docs/api.zh-CN.md'),
'utf8'
Expand All @@ -29,6 +34,38 @@ for (const field of ['description', 'license', 'repository']) {
if (!manifest.engines?.node) throw new Error(`${manifest.name} is missing a Node.js engine range`)
if (manifest.sideEffects === undefined) throw new Error(`${manifest.name} must declare sideEffects`)
if (!manifest.files?.includes('docs')) throw new Error(`${manifest.name} does not publish docs`)
if (manifest.publishConfig?.access !== 'public') {
throw new Error(`${manifest.name} must publish with public access`)
}
if (manifest.publishConfig?.registry !== 'https://npm.pkg.github.com') {
throw new Error(`${manifest.name} must publish through GitHub Packages`)
}

const privatePackageClaims = [
/\bprivate\b[^\n]{0,80}@velaros-ai/iu,
/@velaros-ai[^\n]{0,80}\bprivate\b/iu,
/私有[^\n]{0,80}@velaros-ai/u,
/@velaros-ai[^\n]{0,80}私有/u,
]
for (const [fileName, contents] of [
['README.md', readme],
['README.zh-CN.md', chineseReadme],
['docs/api.zh-CN.md', documentation],
]) {
for (const pattern of privatePackageClaims) {
if (pattern.test(contents)) {
throw new Error(`${fileName} must not describe the public package or scope as private`)
}
}
}
if (!readme.includes('public package') || !readme.includes('read:packages')) {
throw new Error('README.md must document public package visibility and GitHub npm authentication')
}
if (!chineseReadme.includes('公开包') || !chineseReadme.includes('read:packages')) {
throw new Error(
'README.zh-CN.md must document public package visibility and GitHub npm authentication'
)
}
for (const section of requiredDocumentSections) {
if (!documentation.includes(`## ${section}`)) {
throw new Error(`${manifest.name} API documentation is missing "${section}"`)
Expand Down
Loading