@selfcure/cli 0.1.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/README.md +42 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +1562 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @selfcure/cli
|
|
2
|
+
|
|
3
|
+
> Command-line entry point for **selfcure** — the preventive testability layer for frontend codebases.
|
|
4
|
+
|
|
5
|
+
selfcure scores every interactive element in your React / Vue / Angular / HTML source, flags ambiguous locators and missing stable identifiers, and opens a Pull Request with `data-testid` fixes — **before** Cypress, Playwright, Selenium, TestCafe, or WebdriverIO ever run.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @selfcure/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
selfcure init # scaffold selfcure.config.mjs in your project
|
|
17
|
+
selfcure crawl # crawl source files and print component metadata
|
|
18
|
+
selfcure lint # score testability + flag ambiguous locators + suggest data-testid
|
|
19
|
+
selfcure web # browser UI with checkbox-driven PR flow (http://localhost:3333/lint)
|
|
20
|
+
selfcure mcp # start the MCP stdio server for any AI client
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Pro flags:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
selfcure lint --fix # apply patches to source
|
|
27
|
+
selfcure lint --fix --pr # apply + branch + push + open a Pull Request
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Legacy BYOK pipeline (fallback when not using Playwright Test Agents):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
selfcure run # crawl → generate → run → heal → report
|
|
34
|
+
selfcure heal # re-attempt healing on the last failures
|
|
35
|
+
selfcure report # re-generate the HTML report
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
All commands accept `-c <path>` to point at a custom config file.
|
|
39
|
+
|
|
40
|
+
## Docs
|
|
41
|
+
|
|
42
|
+
Full documentation: https://github.com/ricardofrancocustodio/selfcure#readme
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { AIConfig } from '@selfcure/generator';
|
|
2
|
+
export { AIConfig, ProviderId } from '@selfcure/generator';
|
|
3
|
+
|
|
4
|
+
/** Login via an HTML form (selfcure fills the fields and clicks submit). */
|
|
5
|
+
interface AuthFormConfig {
|
|
6
|
+
type: 'form';
|
|
7
|
+
/** Path (relative to baseURL) of the login page, e.g. '/login' */
|
|
8
|
+
loginURL: string;
|
|
9
|
+
/** CSS / ARIA selector for the username input, e.g. '[name="username"]' */
|
|
10
|
+
usernameSelector: string;
|
|
11
|
+
/** CSS / ARIA selector for the password input, e.g. '[name="password"]' */
|
|
12
|
+
passwordSelector: string;
|
|
13
|
+
/** Credential — read from an env var in the config, never hardcode */
|
|
14
|
+
username: string;
|
|
15
|
+
/** Credential — read from an env var in the config, never hardcode */
|
|
16
|
+
password: string;
|
|
17
|
+
/** Selector for the submit button — default: 'button[type=submit]' */
|
|
18
|
+
submitSelector?: string;
|
|
19
|
+
/** URL (or glob) Playwright should wait for after a successful login */
|
|
20
|
+
waitForURL?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Reuse a Playwright browser storage-state file (pre-authenticated). */
|
|
23
|
+
interface AuthStorageStateConfig {
|
|
24
|
+
type: 'storageState';
|
|
25
|
+
/** Path to a storage-state JSON created by `selfcure auth-save` or Playwright */
|
|
26
|
+
storageState: string;
|
|
27
|
+
}
|
|
28
|
+
/** HTTP Basic Auth (e.g. .htaccess-protected staging environments). */
|
|
29
|
+
interface AuthHttpCredentialsConfig {
|
|
30
|
+
type: 'httpCredentials';
|
|
31
|
+
username: string;
|
|
32
|
+
password: string;
|
|
33
|
+
}
|
|
34
|
+
/** Inject custom HTTP request headers (e.g. a Bearer token or API key). */
|
|
35
|
+
interface AuthHeadersConfig {
|
|
36
|
+
type: 'headers';
|
|
37
|
+
/** Record of header name → value; read sensitive values from env vars */
|
|
38
|
+
extraHTTPHeaders: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
type AuthConfig = AuthFormConfig | AuthStorageStateConfig | AuthHttpCredentialsConfig | AuthHeadersConfig;
|
|
41
|
+
interface BrowserConfig {
|
|
42
|
+
/** Browser engine to use — default: 'chromium' */
|
|
43
|
+
type?: 'chromium' | 'firefox' | 'webkit';
|
|
44
|
+
/** Run browser without a visible UI — default: true */
|
|
45
|
+
headless?: boolean;
|
|
46
|
+
/** Viewport dimensions — default: { width: 1280, height: 720 } */
|
|
47
|
+
viewport?: {
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
51
|
+
/** Default navigation and action timeout in ms — default: 30000 */
|
|
52
|
+
timeout?: number;
|
|
53
|
+
/** Slow-motion delay between actions in ms (useful for debugging) — default: 0 */
|
|
54
|
+
slowMo?: number;
|
|
55
|
+
}
|
|
56
|
+
interface DiscoveryConfig {
|
|
57
|
+
/** 'agentic' uses static + optional runtime discovery; 'static' is AST-only. */
|
|
58
|
+
mode?: 'agentic' | 'static';
|
|
59
|
+
/** Enable static (AST) discovery — default true */
|
|
60
|
+
static?: boolean;
|
|
61
|
+
/** Enable runtime Playwright discovery — default false */
|
|
62
|
+
runtime?: boolean;
|
|
63
|
+
/** Maximum routes to visit during runtime discovery — default 50 */
|
|
64
|
+
maxRoutes?: number;
|
|
65
|
+
/** Maximum link-follow depth from baseUrl — default 3 */
|
|
66
|
+
maxDepth?: number;
|
|
67
|
+
/** Also discover hidden states (modals, wizards) — default true */
|
|
68
|
+
includeHiddenStates?: boolean;
|
|
69
|
+
/** Extra route paths to always visit (e.g. auth-protected routes) */
|
|
70
|
+
routeHints?: string[];
|
|
71
|
+
/** Glob patterns to ignore during static discovery */
|
|
72
|
+
ignore?: string[];
|
|
73
|
+
}
|
|
74
|
+
interface TestabilityConfig {
|
|
75
|
+
/** Prefer role/accessible-name locators over CSS selectors — default true */
|
|
76
|
+
preferRoleLocators?: boolean;
|
|
77
|
+
/** Auto-suggest data-testid values for unidentifiable elements — default true */
|
|
78
|
+
suggestTestIds?: boolean;
|
|
79
|
+
/** Minimum testability score (0–100) before an element is flagged — default 80 */
|
|
80
|
+
minimumScore?: number;
|
|
81
|
+
}
|
|
82
|
+
/** Optional linter behaviour — only required for `selfcure lint --pr` */
|
|
83
|
+
interface LintOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Base branch the auto-generated PR will target.
|
|
86
|
+
* When omitted, selfcure asks `gh` / `glab` for the repo's default branch.
|
|
87
|
+
*/
|
|
88
|
+
prBaseBranch?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Force a specific git host provider. When `'auto'` (default), selfcure
|
|
91
|
+
* inspects `git remote get-url origin` and picks GitHub or GitLab based on
|
|
92
|
+
* the hostname. Set explicitly for self-hosted GitLab with custom domain.
|
|
93
|
+
*/
|
|
94
|
+
gitProvider?: 'github' | 'gitlab' | 'auto';
|
|
95
|
+
}
|
|
96
|
+
/** Full selfcure configuration — used in selfcure.config.mjs */
|
|
97
|
+
interface SelfcureConfig {
|
|
98
|
+
/** Project root — alternative to rootDir for the new config format. */
|
|
99
|
+
projectRoot?: string;
|
|
100
|
+
/** App base URL — alternative to baseURL for the new config format. */
|
|
101
|
+
baseUrl?: string;
|
|
102
|
+
/** Discovery configuration block. */
|
|
103
|
+
discovery?: DiscoveryConfig;
|
|
104
|
+
/** Testability scoring configuration. */
|
|
105
|
+
testability?: TestabilityConfig;
|
|
106
|
+
rootDir: string;
|
|
107
|
+
include: string[];
|
|
108
|
+
exclude: string[];
|
|
109
|
+
/** Optional framework hint — skips auto-detection — default: 'auto' */
|
|
110
|
+
framework?: 'react' | 'vue' | 'angular' | 'auto';
|
|
111
|
+
auth?: AuthConfig;
|
|
112
|
+
browser?: BrowserConfig;
|
|
113
|
+
ai: AIConfig;
|
|
114
|
+
testsDir: string;
|
|
115
|
+
maxInputTokens?: number;
|
|
116
|
+
playwrightConfig: string;
|
|
117
|
+
baseURL: string;
|
|
118
|
+
maxHealAttempts?: number;
|
|
119
|
+
reportDir: string;
|
|
120
|
+
reportTitle?: string;
|
|
121
|
+
/** Optional Pro flag — enables `selfcure lint --fix` and `--pr` without the env var. */
|
|
122
|
+
pro?: boolean;
|
|
123
|
+
/** Optional linter settings (currently just PR base branch). */
|
|
124
|
+
lint?: LintOptions;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type { AuthConfig, AuthFormConfig, AuthHeadersConfig, AuthHttpCredentialsConfig, AuthStorageStateConfig, BrowserConfig, DiscoveryConfig, LintOptions, SelfcureConfig, TestabilityConfig };
|