textrun-npm 0.1.0 → 0.2.0

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.
@@ -1,19 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportedExecutable = void 0;
4
- const color = require("colorette");
5
- const trim_dollar_1 = require("../helpers/trim-dollar");
6
- function exportedExecutable(action) {
7
- const commandName = trim_dollar_1.trimDollar(action.region.text().trim());
1
+ import * as color from "colorette";
2
+ import { promises as fs } from "fs";
3
+ import { trimDollar } from "../helpers/trim-dollar.js";
4
+ export async function exportedExecutable(action) {
5
+ const commandName = trimDollar(action.region.text().trim());
8
6
  if (commandName === "") {
9
7
  throw new Error("No executable name specified");
10
8
  }
11
9
  action.name(`npm package exports executable ${color.cyan(commandName)}`);
12
- // eslint-disable-next-line @typescript-eslint/no-var-requires
13
- const pkgData = require(action.configuration.sourceDir.joinStr("package.json"));
10
+ const packageJsonPath = action.configuration.sourceDir.joinStr("package.json");
11
+ const pkgText = await fs.readFile(packageJsonPath, "utf-8");
12
+ const pkgData = JSON.parse(pkgText);
14
13
  if (!Object.keys(pkgData.bin).includes(commandName)) {
15
14
  throw new Error(`package.json does not export a "${commandName}" command`);
16
15
  }
17
16
  }
18
- exports.exportedExecutable = exportedExecutable;
19
17
  //# sourceMappingURL=exported-executable.js.map
@@ -1,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.install = void 0;
4
- const color = require("colorette");
5
- const fs = require("fs-extra");
6
- const trim_dollar_1 = require("../helpers/trim-dollar");
7
- async function install(action) {
1
+ import * as color from "colorette";
2
+ import { promises as fs } from "fs";
3
+ import { trimDollar } from "../helpers/trim-dollar.js";
4
+ export async function install(action) {
8
5
  var _a, _b;
9
- const installText = trim_dollar_1.trimDollar(action.region.text());
6
+ const installText = trimDollar(action.region.text());
10
7
  if (installText === "") {
11
8
  throw new Error("no installation instructions found");
12
9
  }
13
10
  action.name(`check npm package name in ${color.cyan(installText)}`);
14
11
  const dir = ((_b = (_a = action.region[0]) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b.dir) || "";
15
- const pkg = await fs.readJSON(action.configuration.sourceDir.joinStr(dir, "package.json"));
12
+ const pkgJsonPath = action.configuration.sourceDir.joinStr(dir, "package.json");
13
+ const pkgText = await fs.readFile(pkgJsonPath, "utf-8");
14
+ const pkg = JSON.parse(pkgText);
16
15
  if (missesPackageName(installText, pkg.name)) {
17
16
  throw new Error(`installation instructions ${color.cyan(installText)} don't contain expected npm package name ${color.cyan(pkg.name)}`);
18
17
  }
19
18
  }
20
- exports.install = install;
21
19
  function missesPackageName(installText, packageName) {
22
20
  // Note: cannot use minimist here
23
21
  // because it is too stupid to understand
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.installedExecutable = void 0;
4
- const color = require("colorette");
5
- const fs_1 = require("fs");
6
- const path = require("path");
7
- const tr = require("text-runner-core");
8
- const trim_dollar_1 = require("../helpers/trim-dollar");
9
- async function installedExecutable(action) {
10
- const commandName = trim_dollar_1.trimDollar(action.region.text().trim());
1
+ import * as color from "colorette";
2
+ import { promises as fsp } from "fs";
3
+ import * as path from "path";
4
+ import * as textRunner from "text-runner-core";
5
+ import { trimDollar } from "../helpers/trim-dollar.js";
6
+ export async function installedExecutable(action) {
7
+ const commandName = trimDollar(action.region.text().trim());
11
8
  if (commandName === "") {
12
- throw new tr.UserError("Executable name not specified", "This action checks for executables provided by npm modules that you have installed. They are typically inside node_modules/.bin. Please provide the name of the executable.", action.location);
9
+ throw new textRunner.UserError("Executable name not specified", "This action checks for executables provided by npm modules that you have installed. They are typically inside node_modules/.bin. Please provide the name of the executable.", action.location);
13
10
  }
14
11
  action.name(`installed npm executable ${color.cyan(commandName)}`);
15
12
  const fullPath = path.join("node_modules", ".bin", commandName);
16
13
  try {
17
- await fs_1.promises.stat(action.configuration.sourceDir.joinStr(fullPath));
14
+ await fsp.stat(action.configuration.sourceDir.joinStr(fullPath));
18
15
  }
19
16
  catch (e) {
20
- if (e.code === "ENOENT") {
17
+ if (textRunner.isFsError(e) && e.code === "ENOENT") {
21
18
  throw new Error(`no installed executable ${color.cyan(fullPath)} found`);
22
19
  }
23
20
  else {
@@ -25,5 +22,4 @@ async function installedExecutable(action) {
25
22
  }
26
23
  }
27
24
  }
28
- exports.installedExecutable = installedExecutable;
29
25
  //# sourceMappingURL=installed-executable.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=package-json.js.map
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trimDollar = void 0;
4
1
  /** trims the leading dollar from the given command */
5
- function trimDollar(text) {
2
+ export function trimDollar(text) {
6
3
  return text.replace(/^\$?\s*/, "");
7
4
  }
8
- exports.trimDollar = trimDollar;
9
5
  //# sourceMappingURL=trim-dollar.js.map
package/dist/index.js CHANGED
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textrunActions = void 0;
4
- const exported_executable_1 = require("./actions/exported-executable");
5
- const install_1 = require("./actions/install");
6
- const installed_executable_1 = require("./actions/installed-executable");
7
- exports.textrunActions = {
8
- exportedExecutable: exported_executable_1.exportedExecutable,
9
- install: install_1.install,
10
- installedExecutable: installed_executable_1.installedExecutable,
1
+ import { exportedExecutable } from "./actions/exported-executable.js";
2
+ import { install } from "./actions/install.js";
3
+ import { installedExecutable } from "./actions/installed-executable.js";
4
+ export const textrunActions = {
5
+ exportedExecutable,
6
+ install,
7
+ installedExecutable,
11
8
  };
12
9
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,24 +1,32 @@
1
1
  {
2
2
  "name": "textrun-npm",
3
- "version": "0.1.0",
4
- "main": "dist/index.js",
3
+ "version": "0.2.0",
5
4
  "license": "ISC",
5
+ "type": "module",
6
+ "exports": "./dist/index.js",
6
7
  "files": [
7
8
  "dist/**/*.js"
8
9
  ],
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig-build.json",
12
+ "clean": "rm -rf dist",
13
+ "cuke": "cucumber-js --format=progress",
14
+ "doc": "text-run static --format=summary && text-run dynamic --format=progress",
15
+ "fix": "eslint . --fix --ext=.ts --ignore-path=../.eslintignore && prettier --write .",
16
+ "lint": "prettier -l . && eslint . --ext=.ts --ignore-path=../.eslintignore && depcheck --config=../.depcheckrc",
17
+ "unit": "env NODE_NO_WARNINGS=1 mocha --reporter=dot 'src/**/*.test.ts'"
18
+ },
9
19
  "dependencies": {
10
- "fs-extra": "9.1.0",
11
- "text-runner-core": "5.0.0"
20
+ "colorette": "2.0.19",
21
+ "text-runner-core": "6.0.0"
12
22
  },
13
23
  "devDependencies": {
14
- "colorette": "1.2.2",
15
- "cucumber": "6.0.5",
16
- "mocha": "8.3.0",
17
- "shared-cucumber-steps": "0.0.0",
18
- "text-runner": "5.0.0",
19
- "textrun-action": "0.1.0",
20
- "textrun-extension": "0.1.0",
21
- "textrun-workspace": "0.1.0"
24
+ "shared-cucumber-steps": "*",
25
+ "text-runner": "6.0.0",
26
+ "textrun-action": "0.2.0",
27
+ "textrun-extension": "0.2.0",
28
+ "textrun-workspace": "0.2.0",
29
+ "ts-node": "10.9.1"
22
30
  },
23
- "gitHead": "1196acaca38c929200160d352267f6e25b1df087"
31
+ "gitHead": "5434976346f2e02bc08c0a6ea9f7cbfa67d68c4e"
24
32
  }