chore: polish pi-question package manifest and README for packaging/tests
This commit is contained in:
10
README.md
10
README.md
@@ -1,16 +1,20 @@
|
|||||||
# pi-question
|
# pi-question
|
||||||
|
|
||||||
`pi-question` is a Pi extension package that provides a multi-question interactive choice flow with built-in support for a final free-text “Something else…” answer.
|
`pi-question` is a Pi extension package that provides a multi-question interactive choice flow with a built-in final free-text "Something else..." answer.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Use it as a local package root today:
|
Local path:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pi install /absolute/path/to/question
|
pi install /absolute/path/to/question
|
||||||
```
|
```
|
||||||
|
|
||||||
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-question
|
||||||
|
```
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,38 @@
|
|||||||
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 = dirname(fileURLToPath(import.meta.url));
|
const packageRoot = 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",
|
||||||
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
|
timeout: 30_000,
|
||||||
|
});
|
||||||
|
const [packResult] = JSON.parse(output);
|
||||||
|
return packResult.files.map((file) => file.path);
|
||||||
|
}
|
||||||
|
|
||||||
test("package.json exposes pi-question as a standalone pi package", () => {
|
test("package.json exposes pi-question as a standalone pi package", () => {
|
||||||
assert.equal(pkg.name, "pi-question");
|
assert.equal(pkg.name, "pi-question");
|
||||||
assert.equal(pkg.type, "module");
|
assert.equal(pkg.type, "module");
|
||||||
|
assert.equal(
|
||||||
|
pkg.description,
|
||||||
|
'Pi extension package that provides a multi-question interactive choice flow with a built-in final free-text "Something else..." answer.',
|
||||||
|
);
|
||||||
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-question",
|
||||||
|
});
|
||||||
assert.deepEqual(pkg.pi, {
|
assert.deepEqual(pkg.pi, {
|
||||||
extensions: ["./index.ts"],
|
extensions: ["./index.ts"],
|
||||||
});
|
});
|
||||||
@@ -26,3 +47,17 @@ test("package.json exposes pi-question as a standalone pi package", () => {
|
|||||||
assert.ok(existsSync(resolve(packageRoot, "index.ts")));
|
assert.ok(existsSync(resolve(packageRoot, "index.ts")));
|
||||||
assert.ok(existsSync(resolve(packageRoot, "question-core.mjs")));
|
assert.ok(existsSync(resolve(packageRoot, "question-core.mjs")));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("README documents local and git installation", () => {
|
||||||
|
assert.match(readme, /pi install \/absolute\/path\/to\/question/);
|
||||||
|
assert.match(readme, /pi install https:\/\/gitea\.rwiesner\.com\/pi\/pi-question/);
|
||||||
|
});
|
||||||
|
|
||||||
|
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("question-core.mjs"));
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "pi-question",
|
"name": "pi-question",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"description": "Pi extension package that provides a multi-question interactive choice flow with a built-in final free-text \"Something else...\" answer.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"keywords": ["pi-package"],
|
"keywords": ["pi-package"],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.rwiesner.com/pi/pi-question"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tsx --test *.test.mjs"
|
"test": "tsx --test *.test.mjs"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user