diff --git a/.github/workflows/nodejs-test.yml b/.github/workflows/nodejs-test.yml index 325d915..e7d1e23 100644 --- a/.github/workflows/nodejs-test.yml +++ b/.github/workflows/nodejs-test.yml @@ -3,7 +3,7 @@ name: Node CI on: [push, pull_request] jobs: - build: + test: runs-on: ${{ matrix.os }} @@ -25,3 +25,5 @@ jobs: npm test env: CI: true + - name: JSR Publish Test + run: npm run test:jsr diff --git a/package.json b/package.json index f5272be..9c900bf 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,13 @@ }, "scripts": { "build:cts-types": "node -e \"fs.copyFileSync('dist/retrier.d.ts', 'dist/retrier.d.cts')\"", - "build:prepend-type-ref": "node tools/prepend-type-ref.js dist/retrier.js", - "build": "rollup -c && tsc && npm run build:prepend-type-ref && npm run build:cts-types", + "build": "rollup -c && tsc && npm run build:cts-types", "prepare": "npm run build", "lint": "eslint src/ tests/", "pretest": "npm run build", "test:unit": "mocha tests/retrier.test.js", "test:build": "node tests/pkg.test.cjs && node tests/pkg.test.mjs", + "test:jsr": "npx jsr@latest publish --dry-run", "test": "npm run test:unit && npm run test:build" }, "repository": { diff --git a/rollup.config.js b/rollup.config.js index 95f7d6d..0f5b478 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,7 +14,8 @@ export default [ }, { file: "dist/retrier.js", - format: "esm" + format: "esm", + banner: "// @ts-self-types=\"./retrier.d.ts\"" } ] }, diff --git a/tools/prepend-type-ref.js b/tools/prepend-type-ref.js deleted file mode 100644 index a8d11cc..0000000 --- a/tools/prepend-type-ref.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @fileoverview Prepends a TypeScript reference comment to the beginning of a file. - * This is necessary because JSR requires that all JavaScript files have a reference - * to the TypeScript types file. We can't do this in Rollup because that happens - * before tsc is run. This script is run after tsc is run. - * - * Usage: - * node tools/prepend-type-ref.js filename.js - * - * @author Nicholas C. Zakas - */ - -//----------------------------------------------------------------------------- -// Imports -//----------------------------------------------------------------------------- - -import fs from "node:fs"; -import path from "node:path"; - -//----------------------------------------------------------------------------- -// Main -//----------------------------------------------------------------------------- - -// read file from the command line -const filePath = process.argv[2]; -const filename = path.basename(filePath, ".js"); - -// read the file -const contents = fs.readFileSync(filePath, "utf8"); - -// prepend the reference comment -const newContents = `/// \n${contents}`; - -// write the file back out -fs.writeFileSync(filePath, newContents, "utf8");