textrun-npm 0.1.2 → 0.2.1
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,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const trim_dollar_1 = require("../helpers/trim-dollar");
|
|
7
|
-
async function exportedExecutable(action) {
|
|
8
|
-
const commandName = (0, 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());
|
|
9
6
|
if (commandName === "") {
|
|
10
7
|
throw new Error("No executable name specified");
|
|
11
8
|
}
|
|
12
9
|
action.name(`npm package exports executable ${color.cyan(commandName)}`);
|
|
13
10
|
const packageJsonPath = action.configuration.sourceDir.joinStr("package.json");
|
|
14
|
-
const
|
|
11
|
+
const pkgText = await fs.readFile(packageJsonPath, "utf-8");
|
|
12
|
+
const pkgData = JSON.parse(pkgText);
|
|
15
13
|
if (!Object.keys(pkgData.bin).includes(commandName)) {
|
|
16
14
|
throw new Error(`package.json does not export a "${commandName}" command`);
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
|
-
exports.exportedExecutable = exportedExecutable;
|
|
20
17
|
//# sourceMappingURL=exported-executable.js.map
|
package/dist/actions/install.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 =
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const trim_dollar_1 = require("../helpers/trim-dollar");
|
|
9
|
-
async function installedExecutable(action) {
|
|
10
|
-
const commandName = (0, 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
|
|
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
|
|
14
|
+
await fsp.stat(action.configuration.sourceDir.joinStr(fullPath));
|
|
18
15
|
}
|
|
19
16
|
catch (e) {
|
|
20
|
-
if (
|
|
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
|
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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,22 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textrun-npm",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "ISC",
|
|
5
|
-
"
|
|
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 --ignore-pattern=dist/ . && prettier --write .",
|
|
16
|
+
"lint": "prettier -l . && eslint --ignore-pattern=dist/ . && depcheck --config=../.depcheckrc",
|
|
17
|
+
"unit": "env NODE_NO_WARNINGS=1 mocha --reporter=dot 'src/**/*.test.ts'"
|
|
18
|
+
},
|
|
9
19
|
"dependencies": {
|
|
10
|
-
"colorette": "2.0.
|
|
11
|
-
"
|
|
12
|
-
"text-runner-core": "^5.0.2"
|
|
20
|
+
"colorette": "2.0.20",
|
|
21
|
+
"text-runner-core": "6.0.1"
|
|
13
22
|
},
|
|
14
23
|
"devDependencies": {
|
|
15
|
-
"shared-cucumber-steps": "
|
|
16
|
-
"text-runner": "
|
|
17
|
-
"textrun-action": "
|
|
18
|
-
"textrun-extension": "
|
|
19
|
-
"textrun-workspace": "
|
|
24
|
+
"shared-cucumber-steps": "*",
|
|
25
|
+
"text-runner": "6.0.1",
|
|
26
|
+
"textrun-action": "0.2.1",
|
|
27
|
+
"textrun-extension": "0.2.1",
|
|
28
|
+
"textrun-workspace": "0.2.1",
|
|
29
|
+
"tsx": "4.19.3"
|
|
20
30
|
},
|
|
21
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "e479ff08fba71c7b2f6d1e3e14001b7818a38e12"
|
|
22
32
|
}
|