mdat-plugin-cli-help 1.0.1 → 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 (3) hide show
  1. package/dist/index.js +22 -10
  2. package/package.json +14 -15
  3. package/readme.md +1 -1
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,13 +15321,21 @@ 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
15329
15331
  //#region src/utilities/is-executable.ts
15332
+ /**
15333
+ * This file is vendored with modification from https://github.com/sindresorhus/is-executable
15334
+ * to work around a "[DEP0176] DeprecationWarning: fs.X_OK is deprecated, use fs.constants.X_OK instead"
15335
+ * error from Node.
15336
+ */
15330
15337
  const isWindows = process.platform === "win32";
15331
- const pathExtensions = isWindows ? new Set(process.env.PATHEXT?.split(";").map((extension) => extension.toLowerCase()) ?? []) : /* @__PURE__ */ new Set();
15338
+ const pathExtensions = isWindows ? new Set(process.env.PATHEXT?.split(";").map((extension) => extension.toLowerCase())) : /* @__PURE__ */ new Set();
15332
15339
  /**
15333
15340
  * Check if a file is executable (async).
15334
15341
  */
@@ -15354,9 +15361,10 @@ async function inferCommand(cliCommand) {
15354
15361
  return ensureExecutable(cliCommand);
15355
15362
  }
15356
15363
  async function getFirstBinFromPackage() {
15357
- const packageJson$1 = await getPackageJson();
15364
+ const { packageJson: packageJson$1, packagePath } = await getPackageJson();
15365
+ const packageDirectory = path.dirname(packagePath);
15358
15366
  if (packageJson$1.bin) {
15359
- 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)));
15360
15368
  if (looksLikePath(binPath)) {
15361
15369
  log.info(`Inferred <!-- cli-help --> command to run from package.json: ${binPath}`);
15362
15370
  return binPath;
@@ -15368,14 +15376,18 @@ function looksLikePath(maybePath) {
15368
15376
  const parsed = path.parse(maybePath);
15369
15377
  return parsed.root !== "" || parsed.dir !== "";
15370
15378
  }
15371
- async function ensureExecutable(path$1) {
15372
- let resolvedPath = await which(path$1, { nothrow: true }) ?? void 0;
15373
- 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;
15374
15382
  if (resolvedPath !== void 0 && await isExecutable(resolvedPath)) return resolvedPath;
15375
15383
  throw new Error(`The cli-help rule noticed that "${resolvedPath}" is not executable.`);
15376
15384
  }
15377
15385
  async function getCommandPathFromPackage(commandName) {
15378
- 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
+ }
15379
15391
  }
15380
15392
 
15381
15393
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mdat-plugin-cli-help",
3
- "version": "1.0.1",
4
- "description": "Mdat plugin to generate tabular CLI tool documentation in Markdown files.",
3
+ "version": "1.0.3",
4
+ "description": "Mdat plugin to generate tabular help documentation for CLI tools in Markdown files.",
5
5
  "keywords": [
6
6
  "markdown",
7
7
  "mdat-plugin",
@@ -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.7.4",
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.15.12",
50
+ "remark-mdat": "^1.2.0",
51
+ "tsdown": "^0.17.0",
50
52
  "typescript": "~5.9.3",
51
- "vitest": "^4.0.6",
53
+ "vitest": "^4.0.15",
52
54
  "zod": "^3.25.76"
53
55
  },
54
56
  "peerDependencies": {
@@ -58,11 +60,8 @@
58
60
  "engines": {
59
61
  "node": ">=20.19.0"
60
62
  },
61
- "publishConfig": {
62
- "access": "public"
63
- },
64
63
  "scripts": {
65
- "build": "tsdown --tsconfig tsconfig.build.json",
64
+ "build": "tsdown --no-fixed-extension --tsconfig tsconfig.build.json",
66
65
  "clean": "git rm -f pnpm-lock.yaml ; git clean -fdX",
67
66
  "fix": "ksc fix",
68
67
  "lint": "ksc lint",
package/readme.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  <!-- short-description -->
17
17
 
18
- **Mdat plugin to generate tabular CLI tool documentation in Markdown files.**
18
+ **Mdat plugin to generate tabular help documentation for CLI tools in Markdown files.**
19
19
 
20
20
  <!-- /short-description -->
21
21