diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af0d6f8..d186d73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,3 +35,6 @@ jobs: - name: Build run: yarn run build + + - name: Check package contents + run: yarn check:package diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9451d1c..f13cf4a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,5 +56,7 @@ jobs: run: yarn check - name: Build run: yarn build + - name: Check package contents + run: yarn check:package - name: Publish package run: yarn npm publish --access public --provenance diff --git a/package.json b/package.json index 30ed4cf..859186f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,13 @@ { "name": "@huskly/cli", - "version": "1.2.6", + "version": "1.2.7", "description": "Terminal-based trading tools for Schwab and IBKR through the IBKR gateway", "type": "module", + "files": [ + "dist", + "README.md", + "LICENSE" + ], "main": "dist/index.js", "types": "dist/index.d.ts", "repository": "https://github.com/huskly/cli", @@ -25,6 +30,7 @@ }, "scripts": { "build": "tsc -p tsconfig.build.json", + "check:package": "node scripts/checkPackageFiles.mjs", "start": "node dist/index.js", "dev": "tsx src/index.ts", "test": "node --conditions=tsx --import tsx --test \"test/**/*.test.ts\"", diff --git a/scripts/checkPackageFiles.mjs b/scripts/checkPackageFiles.mjs new file mode 100644 index 0000000..b1c1943 --- /dev/null +++ b/scripts/checkPackageFiles.mjs @@ -0,0 +1,20 @@ +import { execFileSync } from "node:child_process"; +import { readdir } from "node:fs/promises"; + +const built = (await readdir("dist", { recursive: true })) + .filter((path) => path.endsWith(".js")) + .map((path) => `dist/${path}`); +const packed = execFileSync("yarn", ["pack", "--dry-run", "--json"], { + encoding: "utf8", +}) + .trimEnd() + .split("\n") + .map((line) => JSON.parse(line).location) + .filter((path) => typeof path === "string"); +const missing = built.filter((path) => !packed.includes(path)); + +if (built.length === 0 || missing.length > 0) { + throw new Error(`Package is missing built JavaScript files: ${missing.join(", ")}`); +} + +console.log(`Package includes all ${built.length} built JavaScript files.`);