Skip to content
Open
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: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ scoop bucket add Coding-Dev-Tools https://github.com/Coding-Dev-Tools/scoop-buck
scoop install json2sql-cli
```

**npm (Node.js wrapper):**
```bash
npm install -g json2sql
```
Then run: `json2sql --help`

## Quick Start

```bash
Expand Down
64 changes: 64 additions & 0 deletions tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,67 @@ test("smoke: required repo files present", () => {
assert.ok(fs.existsSync(path.join(root, f)), `${f} must exist`);
}
});

test("smoke: README documents supported install paths only", () => {
const readmePath = path.join(__dirname, "..", "README.md");
assert.ok(fs.existsSync(readmePath), "README.md must exist");

const readme = fs.readFileSync(readmePath, "utf8");
const lines = readme.split(/\r?\n/);

const installStart = lines.findIndex((line) => /^##\s+Install(?:ation)?\s*$/i.test(line));
assert.notStrictEqual(installStart, -1, "README must have an Install section");
const nextHeading = lines.findIndex(
(line, index) => index > installStart && /^##\s+/.test(line)
);
const installSection = lines
.slice(installStart + 1, nextHeading === -1 ? undefined : nextHeading)
.join("\n");

assert.match(
installSection,
/pip install (?:json2sql-cli|git\+https:\/\/github\.com\/Coding-Dev-Tools\/json2sql(?:\.git)?)/,
"README Install section must document `pip install json2sql-cli` (or the documented git fallback)"
);
assert.match(
installSection,
/\bjson2sql-cli\b/,
"README Install section must name the json2sql-cli package"
);

for (const [needle, label] of [
["brew tap ", "Homebrew tap"],
["scoop bucket add ", "Scoop bucket"],
]) {
assert.ok(installSection.includes(needle), `README must document ${label}`);
}

const fencedBlocks = [
...readme.matchAll(/^```[^\n]*\n([\s\S]*?)^```[ \t]*$/gm),
].map((match) => match[1]);

const forbiddenNpmUsage = [
[
/\bnpm\s+(?:-{1,2}[A-Za-z][\w-]*\s+)*(?:install|i|add|exec|x|dlx)\b[^\n]*\bjson2sql(?:-cli)?(?![\w.-])/i,
"npm",
],
[/\bnpx\b[^\n]*\bjson2sql(?:-cli)?(?![\w.-])/i, "npx"],
[
/\b(?:pnpm|yarn)\s+(?:-{1,2}[A-Za-z][\w-]*\s+)*(?:add|global\s+add|dlx)\b[^\n]*\bjson2sql(?:-cli)?(?![\w.-])/i,
"pnpm/yarn",
],
];

const sources = fencedBlocks.map((block, index) => [
`README.md fenced code block ${index + 1}`,
block,
]);
for (const [sourceName, source] of sources) {
for (const [pattern, runner] of forbiddenNpmUsage) {
assert.ok(
!pattern.test(source),
`${sourceName} must not use \`${runner}\` to install or run json2sql: npm \`json2sql\` is an unrelated third-party package and this project publishes no npm package`
);
}
}
});
Loading