textrun-repo 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,33 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executable = void 0;
4
- const color = require("colorette");
5
- const fs = require("fs");
6
- const fs_1 = require("fs");
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 fs_1.promises.access(fullPath, fs.constants.X_OK);
13
+ await fsp.access(fullPath, fs.constants.X_OK);
17
14
  }
18
15
  catch (err) {
19
- if (!tr.isFsError(err)) {
16
+ if (!textRunner.isFsError(err)) {
20
17
  throw err;
21
18
  }
22
19
  switch (err.code) {
23
20
  case "EACCES":
24
- throw new tr.UserError(`file is not executable: ${color.cyan(filePath)}`, "", action.location);
21
+ throw new textRunner.UserError(`file is not executable: ${color.cyan(filePath)}`, "", action.location);
25
22
  case "ENOENT":
26
- throw new tr.UserError(`file not found: ${color.cyan(filePath)}`, "", action.location);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.existingFileContent = void 0;
4
- const assertNoDiff = require("assert-no-diff");
5
- const color = require("colorette");
6
- const eol = require("eol");
7
- const fs_1 = require("fs");
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
- const expectedContent = action.region.textInNodeOfTypes("fence", "code");
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 fs_1.promises.readFile(fullPath, "utf8");
21
+ actualContent = await fs.readFile(fullPath, "utf8");
25
22
  }
26
23
  catch (err) {
27
- if (!tr.isFsError(err)) {
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(eol.lf(actualContent.trim()), eol.lf(expectedContent.trim()));
37
+ assertNoDiff.trimmedLines(actualContent, expectedContent);
39
38
  }
40
39
  catch (err) {
41
- throw new tr.UserError(`mismatching content in ${color.cyan(color.bold(filePath))}`, tr.errorMessage(err));
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
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.existingFile = void 0;
4
- const color = require("colorette");
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 fs_1.promises.stat(fullPath);
10
+ var stats = await fs.stat(fullPath);
14
11
  }
15
12
  catch (err) {
16
- if (!tr.isFsError(err)) {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textrunActions = void 0;
4
- const executable_1 = require("./executable");
5
- const existing_file_1 = require("./existing-file");
6
- const existing_file_content_1 = require("./existing-file-content");
7
- exports.textrunActions = {
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.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "Text-Runner actions for verifying the content of the current repository",
5
5
  "license": "ISC",
6
- "main": "dist/index.js",
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 --ignore-pattern=dist/ . && prettier --write .",
17
+ "lint": "prettier -l . && eslint --ignore-pattern=dist/ . && depcheck --config=../.depcheckrc"
18
+ },
10
19
  "dependencies": {
11
20
  "assert-no-diff": "3.0.6",
12
- "colorette": "2.0.19",
13
- "eol": "0.9.1",
14
- "text-runner-core": "^5.0.2"
21
+ "colorette": "2.0.20",
22
+ "eol": "0.10.0",
23
+ "text-runner-core": "6.0.1"
15
24
  },
16
25
  "devDependencies": {
17
- "shared-cucumber-steps": "0.0.0",
18
- "text-runner": "^5.0.2",
19
- "textrun-action": "^0.1.2",
20
- "textrun-extension": "^0.1.2",
21
- "textrun-npm": "^0.1.2"
26
+ "shared-cucumber-steps": "*",
27
+ "text-runner": "6.0.1",
28
+ "textrun-action": "0.2.1",
29
+ "textrun-extension": "0.2.1",
30
+ "textrun-npm": "0.2.1",
31
+ "tsx": "4.19.3"
22
32
  },
23
- "gitHead": "1dca29620ef3189c64a62d706ded97c9b99deda3"
33
+ "gitHead": "e479ff08fba71c7b2f6d1e3e14001b7818a38e12"
24
34
  }