mdat-plugin-cli-help 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +16 -9
  2. package/package.json +12 -13
package/dist/index.js CHANGED
@@ -3395,7 +3395,6 @@ ZodNaN.create = (params) => {
3395
3395
  ...processCreateParams(params)
3396
3396
  });
3397
3397
  };
3398
- const BRAND = Symbol("zod_brand");
3399
3398
  var ZodBranded = class extends ZodType {
3400
3399
  _parse(input) {
3401
3400
  const { ctx } = this._processInputParams(input);
@@ -15175,7 +15174,7 @@ var CliHelpToObjectVisitor = class extends parser.getBaseCstVisitorConstructor()
15175
15174
  return context.map((entry) => clean ? this.clean(entry.image) : entry.image).join(" ");
15176
15175
  }
15177
15176
  positionalParentCommandToArguments(object) {
15178
- const { arguments: theArguments, parentCommandName,...rest } = object;
15177
+ const { arguments: theArguments, parentCommandName, ...rest } = object;
15179
15178
  if (parentCommandName === void 0) return object;
15180
15179
  return {
15181
15180
  arguments: [parentCommandName, ...theArguments ?? []],
@@ -15322,7 +15321,10 @@ async function getPackageJson() {
15322
15321
  const { packageFile } = await loadConfig();
15323
15322
  if (packageFile === void 0) throw new Error("No packageFile found or set in config");
15324
15323
  packageJson ??= await readPackage({ cwd: path.dirname(packageFile) });
15325
- return packageJson;
15324
+ return {
15325
+ packageJson,
15326
+ packagePath: packageFile
15327
+ };
15326
15328
  }
15327
15329
 
15328
15330
  //#endregion
@@ -15359,9 +15361,10 @@ async function inferCommand(cliCommand) {
15359
15361
  return ensureExecutable(cliCommand);
15360
15362
  }
15361
15363
  async function getFirstBinFromPackage() {
15362
- const packageJson$1 = await getPackageJson();
15364
+ const { packageJson: packageJson$1, packagePath } = await getPackageJson();
15365
+ const packageDirectory = path.dirname(packagePath);
15363
15366
  if (packageJson$1.bin) {
15364
- const binPath = typeof packageJson$1.bin === "string" ? packageJson$1.bin : String(Object.values(packageJson$1.bin).at(0));
15367
+ const binPath = typeof packageJson$1.bin === "string" ? path.resolve(packageDirectory, packageJson$1.bin) : path.resolve(packageDirectory, String(Object.values(packageJson$1.bin).at(0)));
15365
15368
  if (looksLikePath(binPath)) {
15366
15369
  log.info(`Inferred <!-- cli-help --> command to run from package.json: ${binPath}`);
15367
15370
  return binPath;
@@ -15373,14 +15376,18 @@ function looksLikePath(maybePath) {
15373
15376
  const parsed = path.parse(maybePath);
15374
15377
  return parsed.root !== "" || parsed.dir !== "";
15375
15378
  }
15376
- async function ensureExecutable(path$1) {
15377
- let resolvedPath = await which(path$1, { nothrow: true }) ?? void 0;
15378
- resolvedPath ??= await getCommandPathFromPackage(path$1) ?? void 0;
15379
+ async function ensureExecutable(filePath) {
15380
+ let resolvedPath = path.isAbsolute(filePath) ? filePath : await which(filePath, { nothrow: true }) ?? void 0;
15381
+ resolvedPath ??= await getCommandPathFromPackage(filePath) ?? void 0;
15379
15382
  if (resolvedPath !== void 0 && await isExecutable(resolvedPath)) return resolvedPath;
15380
15383
  throw new Error(`The cli-help rule noticed that "${resolvedPath}" is not executable.`);
15381
15384
  }
15382
15385
  async function getCommandPathFromPackage(commandName) {
15383
- return (await getPackageJson()).bin?.[commandName] ?? void 0;
15386
+ const { packageJson: packageJson$1 } = await getPackageJson();
15387
+ for (const [key, value] of Object.entries(packageJson$1.bin ?? {})) {
15388
+ if (key === commandName) return value;
15389
+ if (path.normalize(value) === path.normalize(commandName)) return value;
15390
+ }
15384
15391
  }
15385
15392
 
15386
15393
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdat-plugin-cli-help",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Mdat plugin to generate tabular help documentation for CLI tools in Markdown files.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -35,20 +35,22 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@types/which": "^3.0.4",
38
- "execa": "^9.6.0",
39
- "read-pkg": "^9.0.1",
40
- "type-fest": "^5.2.0",
41
- "which": "^5.0.0"
38
+ "execa": "^9.6.1",
39
+ "read-pkg": "^10.0.0",
40
+ "type-fest": "^5.3.0",
41
+ "which": "^6.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@kitschpatrol/shared-config": "^5.8.1",
45
- "@types/node": "^20.19.24",
46
- "bumpp": "^10.3.1",
44
+ "@kitschpatrol/shared-config": "^5.10.0",
45
+ "@types/node": "^20.19.25",
46
+ "bumpp": "^10.3.2",
47
47
  "chevrotain": "^11.0.3",
48
+ "mdat": "^1.3.2",
48
49
  "meow": "^14.0.0",
49
- "tsdown": "^0.16.0",
50
+ "remark-mdat": "^1.2.0",
51
+ "tsdown": "^0.17.0",
50
52
  "typescript": "~5.9.3",
51
- "vitest": "^4.0.7",
53
+ "vitest": "^4.0.15",
52
54
  "zod": "^3.25.76"
53
55
  },
54
56
  "peerDependencies": {
@@ -58,9 +60,6 @@
58
60
  "engines": {
59
61
  "node": ">=20.19.0"
60
62
  },
61
- "publishConfig": {
62
- "access": "public"
63
- },
64
63
  "scripts": {
65
64
  "build": "tsdown --no-fixed-extension --tsconfig tsconfig.build.json",
66
65
  "clean": "git rm -f pnpm-lock.yaml ; git clean -fdX",