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: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ The release gate covers:

- `npm run check` - tsc --noEmit
- `npm run lint` - eslint src --ext .ts
- `npm run build` - tsc
- `npm run build` - tsc && chmod +x dist/cli.js
- `npm test` - vitest run --coverage
- `npm run smoke` - npm run build && node dist/cli.js --help && node dist/cli.js fixtures --format text
- `npm run validate` - bash scripts/validate.sh
- `npm run package:smoke` - npm pack --dry-run
- `npm run release:check` - npm run check && npm test && npm run smoke && npm run package:smoke
- `npm run package:smoke` - npm run build && node scripts/package-smoke.mjs
- `npm run release:check` - npm run check && npm run lint && npm test && npm run smoke && npm run package:smoke

## Release readiness

Expand Down
200 changes: 178 additions & 22 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"CONTRIBUTING.md"
],
"scripts": {
"build": "tsc",
"build": "tsc && chmod +x dist/cli.js",
"dev": "tsx src/cli.ts",
"check": "tsc --noEmit",
"lint": "eslint src --ext .ts",
Expand All @@ -32,8 +32,8 @@
"test": "vitest run --coverage",
"test:watch": "vitest",
"prepublishOnly": "npm run build",
"release:check": "npm run check && npm test && npm run smoke && npm run package:smoke",
"package:smoke": "npm pack --dry-run",
"release:check": "npm run check && npm run lint && npm test && npm run smoke && npm run package:smoke",
"package:smoke": "npm run build && node scripts/package-smoke.mjs",
"smoke": "npm run build && node dist/cli.js --help && node dist/cli.js fixtures --format text"
},
"keywords": [
Expand Down Expand Up @@ -71,6 +71,7 @@
"prettier": "^3.0.0",
"tsx": "^4.0.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.63.0",
"vitest": "^3.0.0"
}
}
67 changes: 67 additions & 0 deletions scripts/package-smoke.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { spawnSync } from "node:child_process";
import { readFileSync } from "node:fs";

const result = spawnSync("npm", ["pack", "--dry-run", "--json"], {
encoding: "utf8",
});

if (result.status !== 0) {
process.stderr.write(result.stderr);
process.exit(result.status ?? 1);
}

const [packument] = JSON.parse(result.stdout);
const packedFiles = new Set(packument.files.map((file) => file.path));

const requiredFiles = [
"dist/cli.js",
"dist/index.js",
"dist/analyzer.js",
"dist/parser.js",
"dist/reporter.js",
"README.md",
"LICENSE",
"SECURITY.md",
"CHANGELOG.md",
"CONTRIBUTING.md",
];

const forbiddenFiles = [
"src/cli.ts",
"fixtures/fully-typed/math.ts",
"coverage/index.html",
];

const missing = requiredFiles.filter((file) => !packedFiles.has(file));
const leaked = forbiddenFiles.filter((file) => packedFiles.has(file));

if (missing.length > 0 || leaked.length > 0) {
for (const file of missing) {
console.error(`package smoke missing required file: ${file}`);
}
for (const file of leaked) {
console.error(`package smoke leaked development file: ${file}`);
}
process.exit(1);
}

const packageJson = JSON.parse(readFileSync("package.json", "utf8"));
const binPath = packageJson.bin?.typegap?.replace(/^\.\//, "");
const binEntry = packument.files.find((file) => file.path === binPath);

if (!binPath || !binEntry) {
console.error("package smoke missing typegap bin entry.");
process.exit(1);
}

if ((binEntry.mode & 0o111) === 0) {
console.error("package smoke found a non-executable typegap bin.");
process.exit(1);
}

if (!readFileSync(binPath, "utf8").startsWith("#!/usr/bin/env node")) {
console.error("package smoke found typegap bin without a Node shebang.");
process.exit(1);
}

console.log(`typegap package smoke passed with ${packument.files.length} packed file(s).`);
1 change: 0 additions & 1 deletion src/analyzer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, it, expect } from 'vitest';
import { buildFileResult, buildProjectResult, analyzeDirectory } from './analyzer.js';
import { parseFile } from './parser.js';
import type { NodeInfo } from './types.js';
import { AnnotationStatus } from './types.js';

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* applies ignore patterns, calculates coverage.
*/

import { relative } from 'node:path';
import type { NodeInfo, FileResult, ProjectResult } from './types.js';
import { parseFile } from './parser.js';
import { glob } from 'glob';
Expand Down Expand Up @@ -34,6 +33,7 @@ export async function analyzeFiles(
filePaths: string[],
options: AnalyzeOptions = {},
): Promise<ProjectResult> {
void options;
const fileResults: FileResult[] = [];

for (const file of filePaths) {
Expand Down
Loading
Loading