tauri-test-cli 0.3.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/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "tauri-test-cli",
3
+ "version": "0.3.0",
4
+ "description": "CLI for testing Tauri applications with screenshot capture, DOM inspection, and user interaction simulation",
5
+ "type": "module",
6
+ "bin": {
7
+ "tauri-test": "./dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "scripts"
12
+ ],
13
+ "keywords": [
14
+ "tauri",
15
+ "testing",
16
+ "webdriver",
17
+ "automation",
18
+ "screenshot",
19
+ "e2e",
20
+ "cli"
21
+ ],
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/lllangWV/tauri-test-cli"
26
+ },
27
+ "scripts": {
28
+ "build": "bun build ./src/cli.ts --outdir ./dist --target node",
29
+ "dev": "bun run ./src/cli.ts",
30
+ "typecheck": "tsc --noEmit",
31
+ "test": "bun test",
32
+ "test:watch": "bun test --watch",
33
+ "prepublishOnly": "bun run build && bun test",
34
+ "postinstall": "node scripts/postinstall.js"
35
+ },
36
+ "dependencies": {
37
+ "webdriverio": "^9.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/bun": "latest",
41
+ "typescript": "^5.3.3"
42
+ }
43
+ }
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Bump version in pixi.toml, package.json, and plugin.json
5
+ # Usage: ./scripts/bump-version.sh [major|minor|patch|<version>]
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
9
+
10
+ PIXI_TOML="$PROJECT_DIR/pixi.toml"
11
+ PACKAGE_JSON="$PROJECT_DIR/package.json"
12
+ PLUGIN_JSON="$PROJECT_DIR/.claude-plugin/plugin.json"
13
+
14
+ # Colors
15
+ RED='\033[0;31m'
16
+ GREEN='\033[0;32m'
17
+ YELLOW='\033[1;33m'
18
+ CYAN='\033[0;36m'
19
+ NC='\033[0m'
20
+
21
+ usage() {
22
+ echo "Usage: $0 [major|minor|patch|<version>]"
23
+ echo ""
24
+ echo "Bump version in pixi.toml, package.json, and plugin.json"
25
+ echo ""
26
+ echo "Arguments:"
27
+ echo " major Bump major version (1.0.0 -> 2.0.0)"
28
+ echo " minor Bump minor version (1.0.0 -> 1.1.0)"
29
+ echo " patch Bump patch version (1.0.0 -> 1.0.1)"
30
+ echo " <version> Set specific version (e.g., 1.2.3)"
31
+ echo ""
32
+ echo "Examples:"
33
+ echo " $0 patch # 0.1.0 -> 0.1.1"
34
+ echo " $0 minor # 0.1.0 -> 0.2.0"
35
+ echo " $0 major # 0.1.0 -> 1.0.0"
36
+ echo " $0 2.0.0 # Set to 2.0.0"
37
+ }
38
+
39
+ get_current_version() {
40
+ grep -E '^version = ' "$PIXI_TOML" | sed 's/version = "\(.*\)"/\1/'
41
+ }
42
+
43
+ bump_version() {
44
+ local current="$1"
45
+ local bump_type="$2"
46
+
47
+ IFS='.' read -r major minor patch <<< "$current"
48
+
49
+ case "$bump_type" in
50
+ major)
51
+ echo "$((major + 1)).0.0"
52
+ ;;
53
+ minor)
54
+ echo "${major}.$((minor + 1)).0"
55
+ ;;
56
+ patch)
57
+ echo "${major}.${minor}.$((patch + 1))"
58
+ ;;
59
+ *)
60
+ # Assume it's a specific version
61
+ if [[ "$bump_type" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
62
+ echo "$bump_type"
63
+ else
64
+ echo ""
65
+ fi
66
+ ;;
67
+ esac
68
+ }
69
+
70
+ update_pixi_toml() {
71
+ local new_version="$1"
72
+ sed -i "s/^version = \".*\"/version = \"$new_version\"/" "$PIXI_TOML"
73
+ }
74
+
75
+ update_package_json() {
76
+ local new_version="$1"
77
+ sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" "$PACKAGE_JSON"
78
+ }
79
+
80
+ update_plugin_json() {
81
+ local new_version="$1"
82
+ if [[ -f "$PLUGIN_JSON" ]]; then
83
+ sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" "$PLUGIN_JSON"
84
+ fi
85
+ }
86
+
87
+ # Main
88
+ if [[ $# -lt 1 ]]; then
89
+ usage
90
+ exit 1
91
+ fi
92
+
93
+ BUMP_TYPE="$1"
94
+
95
+ if [[ "$BUMP_TYPE" == "-h" || "$BUMP_TYPE" == "--help" ]]; then
96
+ usage
97
+ exit 0
98
+ fi
99
+
100
+ # Get current version
101
+ CURRENT_VERSION=$(get_current_version)
102
+ echo -e "${CYAN}Current version:${NC} $CURRENT_VERSION"
103
+
104
+ # Calculate new version
105
+ NEW_VERSION=$(bump_version "$CURRENT_VERSION" "$BUMP_TYPE")
106
+
107
+ if [[ -z "$NEW_VERSION" ]]; then
108
+ echo -e "${RED}Error: Invalid version or bump type: $BUMP_TYPE${NC}"
109
+ usage
110
+ exit 1
111
+ fi
112
+
113
+ echo -e "${YELLOW}New version:${NC} $NEW_VERSION"
114
+ echo ""
115
+
116
+ # Update files
117
+ echo -e "${GREEN}Updating pixi.toml...${NC}"
118
+ update_pixi_toml "$NEW_VERSION"
119
+
120
+ echo -e "${GREEN}Updating package.json...${NC}"
121
+ update_package_json "$NEW_VERSION"
122
+
123
+ echo -e "${GREEN}Updating plugin.json...${NC}"
124
+ update_plugin_json "$NEW_VERSION"
125
+
126
+ # Verify
127
+ echo ""
128
+ echo -e "${CYAN}Verification:${NC}"
129
+ echo -n " pixi.toml: "
130
+ grep -E '^version = ' "$PIXI_TOML"
131
+ echo -n " package.json: "
132
+ grep '"version"' "$PACKAGE_JSON" | sed 's/^[[:space:]]*//'
133
+ if [[ -f "$PLUGIN_JSON" ]]; then
134
+ echo -n " plugin.json: "
135
+ grep '"version"' "$PLUGIN_JSON" | sed 's/^[[:space:]]*//'
136
+ fi
137
+
138
+ echo ""
139
+ echo -e "${GREEN}Done!${NC} Version bumped to $NEW_VERSION"
140
+ echo ""
141
+ echo "Next steps:"
142
+ echo " git add pixi.toml package.json .claude-plugin/plugin.json"
143
+ echo " git commit -m \"Bump version to $NEW_VERSION\""
144
+ echo " git tag v$NEW_VERSION"
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from "child_process";
4
+ import os from "os";
5
+
6
+ // ANSI color codes
7
+ const reset = "\x1b[0m";
8
+ const bold = "\x1b[1m";
9
+ const yellow = "\x1b[33m";
10
+ const green = "\x1b[32m";
11
+ const cyan = "\x1b[36m";
12
+ const dim = "\x1b[2m";
13
+
14
+ const warnings = [];
15
+
16
+ // Check for tauri-driver (the actual Tauri WebDriver binary)
17
+ try {
18
+ const checkCmd = os.platform() === "win32"
19
+ ? "where tauri-driver"
20
+ : "which tauri-driver";
21
+ execSync(checkCmd, { stdio: "ignore" });
22
+ } catch {
23
+ warnings.push({
24
+ name: "tauri-driver",
25
+ install: "cargo install tauri-driver",
26
+ reason: "Required to control Tauri applications via WebDriver",
27
+ });
28
+ }
29
+
30
+ // Linux-specific checks
31
+ if (os.platform() === "linux") {
32
+ // Check for webkit2gtk (use --modversion as it's more reliable)
33
+ try {
34
+ execSync("pkg-config --modversion webkit2gtk-4.1", { stdio: "ignore" });
35
+ } catch {
36
+ warnings.push({
37
+ name: "webkit2gtk-4.1",
38
+ install: "sudo apt install libwebkit2gtk-4.1-dev # Debian/Ubuntu\nsudo dnf install webkit2gtk4.1-devel # Fedora\nsudo pacman -S webkit2gtk-4.1 # Arch\npixi add webkit2gtk4.1 # Or use pixi",
39
+ reason: "Required for WebDriver to communicate with Tauri's WebView",
40
+ });
41
+ }
42
+ }
43
+
44
+ // Print output
45
+ console.log();
46
+ console.log(`${cyan}${bold}tauri-test-cli${reset} installed successfully!`);
47
+ console.log();
48
+
49
+ if (warnings.length > 0) {
50
+ console.log(`${yellow}${bold}Missing dependencies:${reset}`);
51
+ console.log();
52
+
53
+ for (const warning of warnings) {
54
+ console.log(` ${yellow}! ${warning.name}${reset}`);
55
+ console.log(` ${dim}${warning.reason}${reset}`);
56
+ console.log();
57
+ console.log(` Install with:`);
58
+ for (const line of warning.install.split("\n")) {
59
+ console.log(` ${green}${line}${reset}`);
60
+ }
61
+ console.log();
62
+ }
63
+
64
+ console.log(`${dim}Run 'tauri-test --help' for usage information.${reset}`);
65
+ } else {
66
+ console.log(`${green}All dependencies found!${reset}`);
67
+ console.log(`${dim}Run 'tauri-test --help' to get started.${reset}`);
68
+ }
69
+
70
+ console.log();
@@ -0,0 +1,80 @@
1
+ import { describe, test, expect, mock, beforeEach, afterEach } from "bun:test";
2
+ import { execSync } from "child_process";
3
+ import path from "path";
4
+
5
+ describe("postinstall script", () => {
6
+ // We'll test by actually running the script and capturing output
7
+ const scriptPath = path.join(import.meta.dir, "postinstall.js");
8
+
9
+ test("script executes without errors", () => {
10
+ // Run the script and check it doesn't throw
11
+ // We use a subshell to capture output
12
+ const result = Bun.spawnSync(["node", scriptPath], {
13
+ env: { ...process.env, PATH: process.env.PATH },
14
+ stdout: "pipe",
15
+ stderr: "pipe",
16
+ });
17
+
18
+ // Script should complete (exit code 0)
19
+ expect(result.exitCode).toBe(0);
20
+ });
21
+
22
+ test("script outputs package name", () => {
23
+ const result = Bun.spawnSync(["node", scriptPath], {
24
+ env: { ...process.env },
25
+ stdout: "pipe",
26
+ stderr: "pipe",
27
+ });
28
+
29
+ const output = result.stdout.toString();
30
+ expect(output).toContain("tauri-test-cli");
31
+ });
32
+
33
+ test("script outputs 'installed successfully'", () => {
34
+ const result = Bun.spawnSync(["node", scriptPath], {
35
+ env: { ...process.env },
36
+ stdout: "pipe",
37
+ stderr: "pipe",
38
+ });
39
+
40
+ const output = result.stdout.toString();
41
+ expect(output).toContain("installed successfully");
42
+ });
43
+
44
+ test("script mentions help command", () => {
45
+ const result = Bun.spawnSync(["node", scriptPath], {
46
+ env: { ...process.env },
47
+ stdout: "pipe",
48
+ stderr: "pipe",
49
+ });
50
+
51
+ const output = result.stdout.toString();
52
+ expect(output).toContain("tauri-test");
53
+ });
54
+ });
55
+
56
+ describe("postinstall dependency detection", () => {
57
+ test("detects missing tauri-driver when not in PATH", () => {
58
+ // Run with empty PATH to simulate missing tauri-driver
59
+ const result = Bun.spawnSync(["node", path.join(import.meta.dir, "postinstall.js")], {
60
+ env: { ...process.env, PATH: "" },
61
+ stdout: "pipe",
62
+ stderr: "pipe",
63
+ });
64
+
65
+ const output = result.stdout.toString();
66
+ // Should mention tauri-driver as missing
67
+ expect(output).toContain("tauri-driver");
68
+ });
69
+
70
+ test("provides cargo install instruction for tauri-driver", () => {
71
+ const result = Bun.spawnSync(["node", path.join(import.meta.dir, "postinstall.js")], {
72
+ env: { ...process.env, PATH: "" },
73
+ stdout: "pipe",
74
+ stderr: "pipe",
75
+ });
76
+
77
+ const output = result.stdout.toString();
78
+ expect(output).toContain("cargo install tauri-driver");
79
+ });
80
+ });
@@ -0,0 +1,191 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Publish package to npm with version bump
5
+ # Usage: ./scripts/publish.sh
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
9
+
10
+ # Colors
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ BLUE='\033[0;34m'
15
+ CYAN='\033[0;36m'
16
+ NC='\033[0m'
17
+
18
+ cd "$PROJECT_DIR"
19
+
20
+ # Get current version
21
+ CURRENT_VERSION=$(grep -E '^version = ' pixi.toml | sed 's/version = "\(.*\)"/\1/')
22
+
23
+ echo -e "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
24
+ echo -e "${CYAN}║ Publish to npm ║${NC}"
25
+ echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}"
26
+ echo ""
27
+ echo -e "${BLUE}Current version:${NC} $CURRENT_VERSION"
28
+ echo ""
29
+
30
+ # Check for uncommitted changes
31
+ if [[ -n $(git status --porcelain) ]]; then
32
+ echo -e "${YELLOW}Warning: You have uncommitted changes:${NC}"
33
+ git status --short
34
+ echo ""
35
+ read -p "Continue anyway? (y/N) " -n 1 -r
36
+ echo ""
37
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
38
+ echo -e "${RED}Aborted.${NC}"
39
+ exit 1
40
+ fi
41
+ fi
42
+
43
+ # ============================================================================
44
+ # STEP 1: Run tests and build BEFORE bumping version
45
+ # ============================================================================
46
+
47
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
48
+ echo -e "${GREEN}▶ Step 1: Running pre-publish checks...${NC}"
49
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
50
+ echo ""
51
+
52
+ echo -e "${BLUE}Running unit tests...${NC}"
53
+ if ! pixi run test-unit; then
54
+ echo -e "${RED}Tests failed! Aborting publish.${NC}"
55
+ exit 1
56
+ fi
57
+ echo -e "${GREEN}✓ Tests passed${NC}"
58
+ echo ""
59
+
60
+ echo -e "${BLUE}Building package...${NC}"
61
+ if ! pixi run build; then
62
+ echo -e "${RED}Build failed! Aborting publish.${NC}"
63
+ exit 1
64
+ fi
65
+ echo -e "${GREEN}✓ Build successful${NC}"
66
+ echo ""
67
+
68
+ # ============================================================================
69
+ # STEP 2: Ask for version bump type
70
+ # ============================================================================
71
+
72
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
73
+ echo -e "${GREEN}▶ Step 2: Select version bump...${NC}"
74
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
75
+ echo ""
76
+
77
+ # Calculate preview versions
78
+ IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
79
+ PATCH_VERSION="${major}.${minor}.$((patch + 1))"
80
+ MINOR_VERSION="${major}.$((minor + 1)).0"
81
+ MAJOR_VERSION="$((major + 1)).0.0"
82
+
83
+ echo -e "${CYAN}Select version bump type:${NC}"
84
+ echo " 1) patch (${CURRENT_VERSION} -> ${PATCH_VERSION})"
85
+ echo " 2) minor (${CURRENT_VERSION} -> ${MINOR_VERSION})"
86
+ echo " 3) major (${CURRENT_VERSION} -> ${MAJOR_VERSION})"
87
+ echo " 4) cancel"
88
+ echo ""
89
+
90
+ read -p "Enter choice [1-4]: " -n 1 -r CHOICE
91
+ echo ""
92
+
93
+ case $CHOICE in
94
+ 1)
95
+ BUMP_TYPE="patch"
96
+ NEW_VERSION="$PATCH_VERSION"
97
+ ;;
98
+ 2)
99
+ BUMP_TYPE="minor"
100
+ NEW_VERSION="$MINOR_VERSION"
101
+ ;;
102
+ 3)
103
+ BUMP_TYPE="major"
104
+ NEW_VERSION="$MAJOR_VERSION"
105
+ ;;
106
+ 4|*)
107
+ echo -e "${YELLOW}Publish cancelled.${NC}"
108
+ exit 0
109
+ ;;
110
+ esac
111
+
112
+ echo ""
113
+
114
+ # ============================================================================
115
+ # STEP 3: Bump version
116
+ # ============================================================================
117
+
118
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
119
+ echo -e "${GREEN}▶ Step 3: Bumping version to ${NEW_VERSION}...${NC}"
120
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
121
+ echo ""
122
+
123
+ ./scripts/bump-version.sh "$BUMP_TYPE"
124
+
125
+ # ============================================================================
126
+ # STEP 4: Commit, tag, and push to GitHub
127
+ # ============================================================================
128
+
129
+ echo ""
130
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
131
+ echo -e "${GREEN}▶ Step 4: Pushing to GitHub...${NC}"
132
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
133
+ echo ""
134
+
135
+ echo -e "${BLUE}Committing changes...${NC}"
136
+ git add pixi.toml package.json .claude-plugin/plugin.json
137
+ git commit -m "Bump version to $NEW_VERSION"
138
+
139
+ echo -e "${BLUE}Creating git tag v${NEW_VERSION}...${NC}"
140
+ git tag "v${NEW_VERSION}"
141
+
142
+ echo -e "${BLUE}Pushing to remote...${NC}"
143
+ git push
144
+ git push --tags
145
+
146
+ echo -e "${GREEN}✓ Pushed to GitHub${NC}"
147
+
148
+ # ============================================================================
149
+ # STEP 5: Final build for publish
150
+ # ============================================================================
151
+
152
+ echo ""
153
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
154
+ echo -e "${GREEN}▶ Step 5: Final build...${NC}"
155
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
156
+ echo ""
157
+
158
+ echo -e "${BLUE}Building package for publish...${NC}"
159
+ if ! pixi run build; then
160
+ echo -e "${RED}Final build failed! Version is bumped but not published.${NC}"
161
+ echo -e "${YELLOW}You may need to run 'pixi run build && npm publish' manually.${NC}"
162
+ exit 1
163
+ fi
164
+ echo -e "${GREEN}✓ Build successful${NC}"
165
+
166
+ # ============================================================================
167
+ # STEP 6: Publish to npm
168
+ # ============================================================================
169
+
170
+ echo ""
171
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
172
+ echo -e "${GREEN}▶ Step 6: Publishing to npm...${NC}"
173
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
174
+ echo ""
175
+
176
+ # Check if logged in to npm, login if needed
177
+ if ! npm whoami &>/dev/null; then
178
+ echo -e "${YELLOW}Not logged in to npm. Please login:${NC}"
179
+ npm login
180
+ fi
181
+
182
+ npm publish
183
+
184
+ echo ""
185
+ echo -e "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
186
+ echo -e "${CYAN}║ Published successfully! ║${NC}"
187
+ echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}"
188
+ echo ""
189
+ echo -e "${GREEN}Version:${NC} $NEW_VERSION"
190
+ echo -e "${GREEN}Tag:${NC} v$NEW_VERSION"
191
+ echo -e "${GREEN}npm:${NC} https://www.npmjs.com/package/tauri-test-cli"