Skip to content

Commit a4a87ab

Browse files
committed
chore(release): verify package contents for beta publish
1 parent bd6da3f commit a4a87ab

File tree

4 files changed

+127
-4
lines changed

4 files changed

+127
-4
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ tests/results/
4040
test-update.ts
4141
repomix-output.xml
4242
scripts/
43+
tui/node_modules/
4344
tui/package-lock.json
4445
tui/types/

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "@tarquinen/opencode-dcp",
4-
"version": "3.2.4-beta0",
4+
"version": "3.2.6-beta0",
55
"type": "module",
66
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
77
"main": "./dist/index.js",
@@ -20,10 +20,25 @@
2020
"server",
2121
"tui"
2222
],
23+
"files": [
24+
"dist/",
25+
"index.ts",
26+
"lib/**/*.ts",
27+
"tui/index.tsx",
28+
"tui/data/*.ts",
29+
"tui/routes/*.tsx",
30+
"tui/shared/*.ts",
31+
"tui/slots/*.tsx",
32+
"README.md",
33+
"LICENSE",
34+
"dcp.schema.json"
35+
],
2336
"scripts": {
2437
"clean": "rm -rf dist",
2538
"build": "npm run clean && tsc",
26-
"prepublishOnly": "npm run build",
39+
"verify:package": "node scripts/verify-package.mjs",
40+
"check:package": "npm run build && npm run verify:package",
41+
"prepublishOnly": "npm run check:package",
2742
"dev": "opencode plugin dev",
2843
"typecheck": "tsc --noEmit",
2944
"tui:link-host-runtime": "node scripts/link-tui-host-runtime.mjs",

scripts/verify-package.mjs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { execFileSync } from "node:child_process"
2+
import { existsSync, readFileSync } from "node:fs"
3+
4+
const repoRoot = new URL("../", import.meta.url)
5+
const packageJsonPath = new URL("./package.json", repoRoot)
6+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"))
7+
8+
const requiredRepoFiles = [
9+
"dist/index.js",
10+
"dist/index.d.ts",
11+
"dist/lib/config.js",
12+
"dist/tui/index.d.ts",
13+
"index.ts",
14+
"lib/config.ts",
15+
"tui/index.tsx",
16+
"tui/data/context.ts",
17+
"tui/routes/summary.tsx",
18+
"tui/shared/names.ts",
19+
"tui/shared/theme.ts",
20+
"tui/shared/types.ts",
21+
"tui/slots/sidebar-content.tsx",
22+
"README.md",
23+
"LICENSE",
24+
"dcp.schema.json",
25+
]
26+
27+
const requiredTarballFiles = [
28+
"package.json",
29+
"dist/index.js",
30+
"dist/index.d.ts",
31+
"dist/lib/config.js",
32+
"dist/tui/index.js",
33+
"dist/tui/index.d.ts",
34+
"index.ts",
35+
"lib/config.ts",
36+
"tui/index.tsx",
37+
"tui/data/context.ts",
38+
"tui/routes/summary.tsx",
39+
"tui/shared/names.ts",
40+
"tui/shared/theme.ts",
41+
"tui/shared/types.ts",
42+
"tui/slots/sidebar-content.tsx",
43+
"README.md",
44+
"LICENSE",
45+
"dcp.schema.json",
46+
]
47+
48+
const forbiddenTarballPatterns = [
49+
/^tui\/node_modules\//,
50+
/^node_modules\//,
51+
/^tests\//,
52+
/^scripts\//,
53+
/^docs\//,
54+
/^assets\//,
55+
/^notes\//,
56+
/^\.github\//,
57+
/^package-lock\.json$/,
58+
]
59+
60+
const fail = (message) => {
61+
console.error(`package verification failed: ${message}`)
62+
process.exit(1)
63+
}
64+
65+
for (const relativePath of requiredRepoFiles) {
66+
const absolutePath = new URL(`./${relativePath}`, repoRoot)
67+
if (!existsSync(absolutePath)) {
68+
fail(`missing required repo file '${relativePath}'`)
69+
}
70+
}
71+
72+
if (packageJson.exports?.["./tui"]?.import !== "./tui/index.tsx") {
73+
fail("expected package.json exports['./tui'].import to be './tui/index.tsx'")
74+
}
75+
76+
if (packageJson.exports?.["."]?.import !== "./dist/index.js") {
77+
fail("expected package.json exports['.'].import to be './dist/index.js'")
78+
}
79+
80+
const packOutput = execFileSync("npm", ["pack", "--dry-run", "--json"], {
81+
cwd: repoRoot,
82+
encoding: "utf8",
83+
})
84+
85+
const packResult = JSON.parse(packOutput)
86+
if (!Array.isArray(packResult) || packResult.length !== 1 || !Array.isArray(packResult[0]?.files)) {
87+
fail("unexpected npm pack JSON output")
88+
}
89+
90+
const tarballFiles = new Set(packResult[0].files.map((entry) => entry.path))
91+
92+
for (const relativePath of requiredTarballFiles) {
93+
if (!tarballFiles.has(relativePath)) {
94+
fail(`tarball is missing required file '${relativePath}'`)
95+
}
96+
}
97+
98+
for (const relativePath of tarballFiles) {
99+
for (const pattern of forbiddenTarballPatterns) {
100+
if (pattern.test(relativePath)) {
101+
fail(`tarball contains forbidden path '${relativePath}'`)
102+
}
103+
}
104+
}
105+
106+
console.log(`package verification passed for ${packageJson.name}@${packageJson.version}`)
107+
console.log(`tarball entries: ${packResult[0].entryCount}`)

0 commit comments

Comments
 (0)