polish: package manifest, README, exclude test files from npm pack

This commit is contained in:
pi
2026-04-11 01:54:46 +01:00
parent cdc8976088
commit 11380ed49b
4 changed files with 53 additions and 3 deletions

View File

@@ -1,16 +1,20 @@
# pi-dev-tools # pi-dev-tools
`pi-dev-tools` is a Pi extension package that adds formatting-aware `edit` and `write` tools plus a setup-suggestion tool for project-local developer tooling. `pi-dev-tools` is a Pi extension package that adds formatting-aware `edit` and `write` tools plus setup-suggestion tooling for project-local developer workflows.
## Install ## Install
Use it as a local package root today: Local path:
```bash ```bash
pi install /absolute/path/to/dev-tools pi install /absolute/path/to/dev-tools
``` ```
After this folder is moved into its own repository, the same package can be installed from git. Git:
```bash
pi install https://gitea.rwiesner.com/pi/pi-dev-tools
```
## Resources ## Resources

View File

@@ -1,8 +1,13 @@
{ {
"name": "pi-dev-tools", "name": "pi-dev-tools",
"version": "0.1.0", "version": "0.1.0",
"description": "Pi extension package that adds formatting-aware edit/write tools plus setup-suggestion tooling for project-local developer workflows.",
"type": "module", "type": "module",
"keywords": ["pi-package"], "keywords": ["pi-package"],
"repository": {
"type": "git",
"url": "https://gitea.rwiesner.com/pi/pi-dev-tools"
},
"scripts": { "scripts": {
"test": "tsx --test src/*.test.ts src/**/*.test.ts" "test": "tsx --test src/*.test.ts src/**/*.test.ts"
}, },

2
src/.npmignore Normal file
View File

@@ -0,0 +1,2 @@
*.test.ts
**/*.test.ts

View File

@@ -1,17 +1,36 @@
import test from "node:test"; import test from "node:test";
import assert from "node:assert/strict"; import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { existsSync, readFileSync } from "node:fs"; import { existsSync, readFileSync } from "node:fs";
import { dirname, resolve } from "node:path"; import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const pkg = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8")); const pkg = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
const readme = readFileSync(resolve(packageRoot, "README.md"), "utf8");
function getPackedPaths() {
const output = execFileSync("npm", ["pack", "--dry-run", "--json"], {
cwd: packageRoot,
encoding: "utf8",
});
const [packResult] = JSON.parse(output) as Array<{ files: Array<{ path: string }> }>;
return packResult.files.map((file) => file.path);
}
test("package.json exposes pi-dev-tools as a standalone pi package", () => { test("package.json exposes pi-dev-tools as a standalone pi package", () => {
assert.equal(pkg.name, "pi-dev-tools"); assert.equal(pkg.name, "pi-dev-tools");
assert.equal(pkg.type, "module"); assert.equal(pkg.type, "module");
assert.equal(
pkg.description,
"Pi extension package that adds formatting-aware edit/write tools plus setup-suggestion tooling for project-local developer workflows.",
);
assert.ok(Array.isArray(pkg.keywords)); assert.ok(Array.isArray(pkg.keywords));
assert.ok(pkg.keywords.includes("pi-package")); assert.ok(pkg.keywords.includes("pi-package"));
assert.deepEqual(pkg.repository, {
type: "git",
url: "https://gitea.rwiesner.com/pi/pi-dev-tools",
});
assert.deepEqual(pkg.pi, { assert.deepEqual(pkg.pi, {
extensions: ["./index.ts"], extensions: ["./index.ts"],
}); });
@@ -27,4 +46,24 @@ test("package.json exposes pi-dev-tools as a standalone pi package", () => {
assert.ok(existsSync(resolve(packageRoot, "index.ts"))); assert.ok(existsSync(resolve(packageRoot, "index.ts")));
assert.ok(existsSync(resolve(packageRoot, "src/runtime.ts"))); assert.ok(existsSync(resolve(packageRoot, "src/runtime.ts")));
assert.ok(existsSync(resolve(packageRoot, "src/tools/edit.ts"))); assert.ok(existsSync(resolve(packageRoot, "src/tools/edit.ts")));
assert.ok(existsSync(resolve(packageRoot, "src/tools/write.ts")));
});
test("README documents local and git installation", () => {
assert.match(readme, /pi install \/absolute\/path\/to\/dev-tools/);
assert.match(readme, /pi install https:\/\/gitea\.rwiesner\.com\/pi\/pi-dev-tools/);
});
test("npm pack includes runtime package assets", () => {
const packedPaths = getPackedPaths();
assert.ok(packedPaths.includes("README.md"));
assert.ok(packedPaths.includes("package.json"));
assert.ok(packedPaths.includes("index.ts"));
assert.ok(packedPaths.includes("src/runtime.ts"));
assert.ok(packedPaths.includes("src/tools/edit.ts"));
assert.ok(packedPaths.includes("src/tools/write.ts"));
// Ensure test sources are not shipped
assert.ok(!packedPaths.some((p) => p.endsWith(".test.ts")));
}); });