textrun-workspace 0.7.0 → 0.7.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.
- package/LICENSE +23 -0
- package/dist/actions/append-file.js +4 -4
- package/dist/actions/compare-files.js +4 -4
- package/dist/actions/copy-file.js +3 -3
- package/dist/actions/empty-file.js +4 -4
- package/dist/actions/existing-directory.js +6 -5
- package/dist/actions/existing-file-with-content.js +7 -6
- package/dist/actions/existing-file.js +3 -3
- package/dist/actions/new-directory.js +3 -3
- package/dist/actions/new-file.js +6 -5
- package/dist/index.js +1 -1
- package/package.json +8 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
SPDX-License-Identifier: ISC
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Kevin Goslar
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software
|
|
6
|
+
for any purpose with or without fee is hereby granted,
|
|
7
|
+
provided that the above copyright notice
|
|
8
|
+
and this permission notice appear in all copies.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED “AS IS”
|
|
11
|
+
AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
12
|
+
WITH REGARD TO THIS SOFTWARE
|
|
13
|
+
INCLUDING ALL IMPLIED WARRANTIES
|
|
14
|
+
OF MERCHANTABILITY AND FITNESS.
|
|
15
|
+
|
|
16
|
+
IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
|
17
|
+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
|
18
|
+
OR ANY DAMAGES WHATSOEVER
|
|
19
|
+
RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
22
|
+
ARISING OUT OF OR IN CONNECTION WITH
|
|
23
|
+
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
|
-
import * as path from "path";
|
|
4
4
|
import * as textRunner from "text-runner-engine";
|
|
5
5
|
export async function appendFile(action) {
|
|
6
6
|
action.name("append to existing file");
|
|
7
|
-
const fileNameAttribute = action.region[0].attributes
|
|
7
|
+
const fileNameAttribute = action.region[0].attributes.filename;
|
|
8
8
|
if (fileNameAttribute === "") {
|
|
9
9
|
throw new textRunner.UserError(`attribute "filename" is empty`, "");
|
|
10
10
|
}
|
|
11
11
|
const fileName = fileNameAttribute || action.region.textInNodeOfType("em", "strong");
|
|
12
|
-
const dirAttribute = action.region[0].attributes
|
|
12
|
+
const dirAttribute = action.region[0].attributes.dir;
|
|
13
13
|
if (dirAttribute === "") {
|
|
14
14
|
throw new textRunner.UserError(`attribute "dir" is empty`, "");
|
|
15
15
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
3
2
|
import { styleText } from "node:util";
|
|
3
|
+
import * as assertNoDiff from "assert-no-diff";
|
|
4
4
|
import * as textRunner from "text-runner-engine";
|
|
5
5
|
export async function compareFiles(action) {
|
|
6
|
-
const have = action.region[0].attributes
|
|
6
|
+
const have = action.region[0].attributes.have;
|
|
7
7
|
if (!have) {
|
|
8
8
|
throw new textRunner.UserError("Missing attribute: have", 'Please provide the file to verify via the "have" attribute');
|
|
9
9
|
}
|
|
10
|
-
const want = action.region[0].attributes
|
|
10
|
+
const want = action.region[0].attributes.want;
|
|
11
11
|
if (!want) {
|
|
12
12
|
throw new textRunner.UserError("Missing attribute: want", 'Please provide the golden file via the "want" attribute');
|
|
13
13
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
2
|
import { styleText } from "node:util";
|
|
3
3
|
import * as textRunner from "text-runner-engine";
|
|
4
4
|
export async function copyFile(action) {
|
|
5
|
-
const src = action.region[0].attributes
|
|
5
|
+
const src = action.region[0].attributes.src;
|
|
6
6
|
if (!src) {
|
|
7
7
|
throw new textRunner.UserError("No src given", 'Please provide the file to copy via the "src" attribute');
|
|
8
8
|
}
|
|
9
|
-
const dst = action.region[0].attributes
|
|
9
|
+
const dst = action.region[0].attributes.dst;
|
|
10
10
|
if (!dst) {
|
|
11
11
|
throw new textRunner.UserError("No dst given", 'Please provide the destination filename via the "dst" attribute');
|
|
12
12
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
|
-
import * as path from "path";
|
|
4
4
|
import * as textRunner from "text-runner-engine";
|
|
5
5
|
export async function emptyFile(action) {
|
|
6
6
|
var _a;
|
|
7
|
-
const fileNameAttribute = action.region[0].attributes
|
|
7
|
+
const fileNameAttribute = action.region[0].attributes.filename;
|
|
8
8
|
const fileName = fileNameAttribute || action.region.text().trim();
|
|
9
9
|
if (fileName === "") {
|
|
10
10
|
throw new textRunner.UserError("No filename given", "");
|
|
11
11
|
}
|
|
12
|
-
const filePath = path.join((_a = action.region[0].attributes
|
|
12
|
+
const filePath = path.join((_a = action.region[0].attributes.dir) !== null && _a !== void 0 ? _a : ".", fileName);
|
|
13
13
|
action.name(`create file ${styleText("cyan", filePath)}`);
|
|
14
14
|
const fullPath = action.configuration.workspace.joinStr(filePath);
|
|
15
15
|
action.log(`create file ${filePath}`);
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as fsp from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
|
-
import * as path from "path";
|
|
4
4
|
/**
|
|
5
5
|
* The "directory" action verifies that the test workspace
|
|
6
6
|
* contains the given directory.
|
|
7
7
|
*/
|
|
8
8
|
export async function existingDirectory(action) {
|
|
9
9
|
const dirName = action.region.text();
|
|
10
|
-
const dirRelName = path.join(action.region[0].attributes
|
|
10
|
+
const dirRelName = path.join(action.region[0].attributes.dir || ".", dirName);
|
|
11
11
|
action.name(`directory ${styleText("cyan", dirRelName)} exists in the workspace`);
|
|
12
12
|
const fullPath = action.configuration.workspace.joinStr(dirRelName);
|
|
13
|
+
let stats;
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
stats = await fsp.lstat(fullPath);
|
|
15
16
|
}
|
|
16
|
-
catch (
|
|
17
|
+
catch (_err) {
|
|
17
18
|
throw new Error(`directory ${styleText(["cyan", "bold"], dirRelName)} does not exist in the workspace`);
|
|
18
19
|
}
|
|
19
20
|
if (!stats.isDirectory()) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
|
-
import * as
|
|
4
|
+
import * as assertNoDiff from "assert-no-diff";
|
|
5
5
|
import * as textRunner from "text-runner-engine";
|
|
6
6
|
export async function existingFileWithContent(action) {
|
|
7
|
-
const fileNameAttribute = action.region[0].attributes
|
|
7
|
+
const fileNameAttribute = action.region[0].attributes.filename;
|
|
8
8
|
const fileName = fileNameAttribute || action.region.textInNodeOfType("em", "strong");
|
|
9
|
-
const dirAttribute = action.region[0].attributes
|
|
9
|
+
const dirAttribute = action.region[0].attributes.dir;
|
|
10
10
|
const fileRelPath = dirAttribute ? path.join(dirAttribute, fileName) : fileName;
|
|
11
11
|
const fullPath = action.configuration.workspace.joinStr(fileRelPath);
|
|
12
12
|
const partialMatch = action.region[0].attributes["partial-match"] !== undefined;
|
|
@@ -17,8 +17,9 @@ export async function existingFileWithContent(action) {
|
|
|
17
17
|
else {
|
|
18
18
|
action.name(`verify content of file ${styleText("cyan", fileRelPath)}`);
|
|
19
19
|
}
|
|
20
|
+
let actualContent;
|
|
20
21
|
try {
|
|
21
|
-
|
|
22
|
+
actualContent = await fs.readFile(fullPath, "utf-8");
|
|
22
23
|
}
|
|
23
24
|
catch (e) {
|
|
24
25
|
if (!textRunner.isFsError(e)) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
|
-
import * as path from "path";
|
|
4
4
|
import * as textRunner from "text-runner-engine";
|
|
5
5
|
export async function existingFile(action) {
|
|
6
6
|
const fileName = action.region.text();
|
|
7
|
-
const fileRelPath = path.join(action.region[0].attributes
|
|
7
|
+
const fileRelPath = path.join(action.region[0].attributes.dir || ".", fileName);
|
|
8
8
|
action.name(`verify existence of file ${styleText("cyan", fileRelPath)}`);
|
|
9
9
|
const fullPath = action.configuration.workspace.joinStr(fileRelPath);
|
|
10
10
|
try {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
|
-
import * as path from "path";
|
|
4
4
|
export async function newDirectory(action) {
|
|
5
5
|
const dirName = action.region.text().trim();
|
|
6
6
|
if (!dirName) {
|
|
7
7
|
throw new Error("empty directory name given");
|
|
8
8
|
}
|
|
9
|
-
const dirRelName = path.join(action.region[0].attributes
|
|
9
|
+
const dirRelName = path.join(action.region[0].attributes.dir || ".", dirName);
|
|
10
10
|
action.name(`create directory ${styleText("cyan", dirRelName)}`);
|
|
11
11
|
const fullPath = action.configuration.workspace.joinStr(dirRelName);
|
|
12
12
|
await fs.mkdir(fullPath, { recursive: true });
|
package/dist/actions/new-file.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
|
-
import * as path from "path";
|
|
4
4
|
import * as textRunner from "text-runner-engine";
|
|
5
5
|
export async function newFile(action) {
|
|
6
6
|
var _a;
|
|
7
|
-
let fileName = action.region[0].attributes
|
|
7
|
+
let fileName = action.region[0].attributes.filename || "";
|
|
8
8
|
try {
|
|
9
9
|
fileName || (fileName = action.region.textInNodeOfType("em", "strong"));
|
|
10
10
|
}
|
|
@@ -15,8 +15,9 @@ export async function newFile(action) {
|
|
|
15
15
|
const guidance = `Cannot determine the name of the file to create.\n${e.guidance}`;
|
|
16
16
|
throw new textRunner.UserError(e.message, guidance);
|
|
17
17
|
}
|
|
18
|
+
let content;
|
|
18
19
|
try {
|
|
19
|
-
|
|
20
|
+
content = action.region.textInNodeOfType("fence", "code");
|
|
20
21
|
}
|
|
21
22
|
catch (e) {
|
|
22
23
|
if (!textRunner.isUserError(e)) {
|
|
@@ -25,7 +26,7 @@ export async function newFile(action) {
|
|
|
25
26
|
const guidance = `Cannot determine the content of the file to create.\n${e.guidance}`;
|
|
26
27
|
throw new textRunner.UserError(e.message, guidance);
|
|
27
28
|
}
|
|
28
|
-
const filePath = path.join((_a = action.region[0].attributes
|
|
29
|
+
const filePath = path.join((_a = action.region[0].attributes.dir) !== null && _a !== void 0 ? _a : ".", fileName);
|
|
29
30
|
action.name(`create file ${styleText("cyan", filePath)}`);
|
|
30
31
|
const fullPath = action.configuration.workspace.joinStr(filePath);
|
|
31
32
|
action.log(`create file ${filePath}`);
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { compareFiles } from "./actions/compare-files.js";
|
|
|
3
3
|
import { copyFile } from "./actions/copy-file.js";
|
|
4
4
|
import { emptyFile } from "./actions/empty-file.js";
|
|
5
5
|
import { existingDirectory } from "./actions/existing-directory.js";
|
|
6
|
-
import { existingFileWithContent } from "./actions/existing-file-with-content.js";
|
|
7
6
|
import { existingFile } from "./actions/existing-file.js";
|
|
7
|
+
import { existingFileWithContent } from "./actions/existing-file-with-content.js";
|
|
8
8
|
import { newDirectory } from "./actions/new-directory.js";
|
|
9
9
|
import { newFile } from "./actions/new-file.js";
|
|
10
10
|
import { workingDir } from "./actions/working-dir.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textrun-workspace",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Text-Runner actions for the Text-Runner workspace",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
"build": "tsc -p tsconfig-build.json",
|
|
13
13
|
"cuke": "cucumber-js --format=progress",
|
|
14
14
|
"doc": "text-runner",
|
|
15
|
-
"fix": "
|
|
16
|
-
"lint": "dprint check && sort-package-json --check --quiet &&
|
|
15
|
+
"fix": "biome check --write --unsafe && dprint fmt && sort-package-json --quiet && ../tools/rta ghokin fmt replace features",
|
|
16
|
+
"lint": "biome check --error-on-warnings && dprint check && sort-package-json --check --quiet && depcheck",
|
|
17
17
|
"reset": "rm -rf dist && yarn run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"assert-no-diff": "4.1.0",
|
|
21
|
-
"text-runner-engine": "7.5.
|
|
21
|
+
"text-runner-engine": "7.5.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"shared-cucumber-steps": "*",
|
|
25
|
-
"text-runner": "7.5.
|
|
26
|
-
"textrun-action": "0.7.
|
|
27
|
-
"textrun-extension": "0.7.
|
|
25
|
+
"text-runner": "7.5.1",
|
|
26
|
+
"textrun-action": "0.7.1",
|
|
27
|
+
"textrun-extension": "0.7.1",
|
|
28
28
|
"tsx": "4.21.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "ffa7b993386ef88d6f199373e97d9c39e3ea3ac4"
|
|
31
31
|
}
|