textrun-repo 0.1.2 → 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.
- package/dist/executable.js +10 -14
- package/dist/existing-file-content.js +14 -16
- package/dist/existing-file.js +6 -10
- package/dist/index.js +7 -10
- package/package.json +19 -9
package/dist/executable.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const tr = require("text-runner-core");
|
|
9
|
-
async function executable(action) {
|
|
1
|
+
import * as color from "colorette";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import { promises as fsp } from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import * as textRunner from "text-runner-core";
|
|
6
|
+
export async function executable(action) {
|
|
10
7
|
const fileName = action.region.text();
|
|
11
8
|
const filePath = path.join(action.location.file.directory().platformified(), fileName);
|
|
12
9
|
action.name(`repository contains executable ${color.cyan(filePath)}`);
|
|
13
10
|
const fullPath = action.configuration.sourceDir.joinStr(filePath);
|
|
14
11
|
action.log(`ls ${fullPath}`);
|
|
15
12
|
try {
|
|
16
|
-
await
|
|
13
|
+
await fsp.access(fullPath, fs.constants.X_OK);
|
|
17
14
|
}
|
|
18
15
|
catch (err) {
|
|
19
|
-
if (!
|
|
16
|
+
if (!textRunner.isFsError(err)) {
|
|
20
17
|
throw err;
|
|
21
18
|
}
|
|
22
19
|
switch (err.code) {
|
|
23
20
|
case "EACCES":
|
|
24
|
-
throw new
|
|
21
|
+
throw new textRunner.UserError(`file is not executable: ${color.cyan(filePath)}`, "", action.location);
|
|
25
22
|
case "ENOENT":
|
|
26
|
-
throw new
|
|
23
|
+
throw new textRunner.UserError(`file not found: ${color.cyan(filePath)}`, "", action.location);
|
|
27
24
|
default:
|
|
28
25
|
throw err;
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
|
-
exports.executable = executable;
|
|
33
29
|
//# sourceMappingURL=executable.js.map
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const path = require("path");
|
|
9
|
-
const tr = require("text-runner-core");
|
|
10
|
-
async function existingFileContent(action) {
|
|
1
|
+
import * as assertNoDiff from "assert-no-diff";
|
|
2
|
+
import * as color from "colorette";
|
|
3
|
+
import eol from "eol";
|
|
4
|
+
import { promises as fs } from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import * as textRunner from "text-runner-core";
|
|
7
|
+
export async function existingFileContent(action) {
|
|
11
8
|
const fileName = action.region.textInNodeOfType("em_open", "strong_open");
|
|
12
9
|
let relativeBaseDir = ".";
|
|
13
10
|
if (action.region.hasNodeOfType("link_open")) {
|
|
14
11
|
const linkNode = action.region.nodeOfTypes("link_open");
|
|
15
12
|
relativeBaseDir = linkNode.attributes.href;
|
|
16
13
|
}
|
|
17
|
-
|
|
14
|
+
let expectedContent = action.region.textInNodeOfTypes("fence", "code");
|
|
18
15
|
const filePath = path.join(action.location.file.directory().platformified(), relativeBaseDir, fileName);
|
|
19
16
|
action.name(`document content matches source code file ${color.cyan(filePath)}`);
|
|
20
17
|
const fullPath = action.configuration.sourceDir.joinStr(filePath);
|
|
21
18
|
action.log(`cat ${fullPath}`);
|
|
22
19
|
let actualContent;
|
|
23
20
|
try {
|
|
24
|
-
actualContent = await
|
|
21
|
+
actualContent = await fs.readFile(fullPath, "utf8");
|
|
25
22
|
}
|
|
26
23
|
catch (err) {
|
|
27
|
-
if (!
|
|
24
|
+
if (!textRunner.isFsError(err)) {
|
|
28
25
|
throw err;
|
|
29
26
|
}
|
|
30
27
|
if (err.code === "ENOENT") {
|
|
@@ -34,12 +31,13 @@ async function existingFileContent(action) {
|
|
|
34
31
|
throw err;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
34
|
+
actualContent = eol.lf(actualContent.trim());
|
|
35
|
+
expectedContent = eol.lf(expectedContent.trim());
|
|
37
36
|
try {
|
|
38
|
-
assertNoDiff.trimmedLines(
|
|
37
|
+
assertNoDiff.trimmedLines(actualContent, expectedContent);
|
|
39
38
|
}
|
|
40
39
|
catch (err) {
|
|
41
|
-
throw new
|
|
40
|
+
throw new textRunner.UserError(`mismatching content in ${color.cyan(color.bold(filePath))}`, textRunner.errorMessage(err));
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
exports.existingFileContent = existingFileContent;
|
|
45
43
|
//# sourceMappingURL=existing-file-content.js.map
|
package/dist/existing-file.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const tr = require("text-runner-core");
|
|
7
|
-
async function existingFile(action) {
|
|
1
|
+
import * as color from "colorette";
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import * as textRunner from "text-runner-core";
|
|
4
|
+
export async function existingFile(action) {
|
|
8
5
|
const fileName = action.region.text();
|
|
9
6
|
action.name(`document mentions source code file ${color.cyan(fileName)}`);
|
|
10
7
|
const fullPath = action.configuration.sourceDir.joinStr(fileName);
|
|
11
8
|
action.log(`ls ${fullPath}`);
|
|
12
9
|
try {
|
|
13
|
-
var stats = await
|
|
10
|
+
var stats = await fs.stat(fullPath);
|
|
14
11
|
}
|
|
15
12
|
catch (err) {
|
|
16
|
-
if (!
|
|
13
|
+
if (!textRunner.isFsError(err)) {
|
|
17
14
|
throw err;
|
|
18
15
|
}
|
|
19
16
|
if (err.code === "ENOENT") {
|
|
@@ -27,5 +24,4 @@ async function existingFile(action) {
|
|
|
27
24
|
throw new Error(`expected ${color.cyan(fileName)} to be a file but is a directory`);
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.existingFile = existingFile;
|
|
31
27
|
//# sourceMappingURL=existing-file.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
executable: executable_1.executable,
|
|
9
|
-
existingFile: existing_file_1.existingFile,
|
|
10
|
-
existingFileContent: existing_file_content_1.existingFileContent,
|
|
1
|
+
import { executable } from "./executable.js";
|
|
2
|
+
import { existingFile } from "./existing-file.js";
|
|
3
|
+
import { existingFileContent } from "./existing-file-content.js";
|
|
4
|
+
export const textrunActions = {
|
|
5
|
+
executable,
|
|
6
|
+
existingFile,
|
|
7
|
+
existingFileContent,
|
|
11
8
|
};
|
|
12
9
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textrun-repo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Text-Runner actions for verifying the content of the current repository",
|
|
5
5
|
"license": "ISC",
|
|
6
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": "./dist/index.js",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist/**/*.js"
|
|
9
10
|
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc -p tsconfig-build.json",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"cuke": "cucumber-js --format=progress",
|
|
15
|
+
"doc": "text-run static --format=summary && text-run dynamic --format=progress",
|
|
16
|
+
"fix": "eslint . --fix --ext=.ts --ignore-path=../.eslintignore && prettier --write .",
|
|
17
|
+
"lint": "prettier -l . && eslint . --ext=.ts --ignore-path=../.eslintignore && depcheck --config=../.depcheckrc"
|
|
18
|
+
},
|
|
10
19
|
"dependencies": {
|
|
11
20
|
"assert-no-diff": "3.0.6",
|
|
12
21
|
"colorette": "2.0.19",
|
|
13
22
|
"eol": "0.9.1",
|
|
14
|
-
"text-runner-core": "
|
|
23
|
+
"text-runner-core": "6.0.0"
|
|
15
24
|
},
|
|
16
25
|
"devDependencies": {
|
|
17
|
-
"shared-cucumber-steps": "
|
|
18
|
-
"text-runner": "
|
|
19
|
-
"textrun-action": "
|
|
20
|
-
"textrun-extension": "
|
|
21
|
-
"textrun-npm": "
|
|
26
|
+
"shared-cucumber-steps": "*",
|
|
27
|
+
"text-runner": "6.0.0",
|
|
28
|
+
"textrun-action": "0.2.0",
|
|
29
|
+
"textrun-extension": "0.2.0",
|
|
30
|
+
"textrun-npm": "0.2.0",
|
|
31
|
+
"ts-node": "10.9.1"
|
|
22
32
|
},
|
|
23
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "5434976346f2e02bc08c0a6ea9f7cbfa67d68c4e"
|
|
24
34
|
}
|