@xcrawl/cli 0.2.0 → 0.2.4
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/CHANGELOG.md +7 -0
- package/README.md +43 -49
- package/dist/api/status.d.ts +2 -0
- package/dist/api/status.js +35 -0
- package/dist/api/status.js.map +1 -0
- package/dist/commands/doctor.js +4 -4
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.js +26 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +40 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/core/config.d.ts +5 -0
- package/dist/core/config.js +24 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +2 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/formatters/text.d.ts +3 -3
- package/dist/formatters/text.js +20 -15
- package/dist/formatters/text.js.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/types/api.d.ts +29 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.3] - 2026-03-17
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Updated `status` command to always call `https://api.xcrawl.com/web_v1/user/credit-user-info`.
|
|
9
|
+
- Removed `--api-base-url` override from `status` to avoid ambiguous routing behavior.
|
|
10
|
+
- Refined `README.md` structure to a more user-facing layout and removed the local development section.
|
|
11
|
+
|
|
5
12
|
## [0.2.0] - 2026-03-12
|
|
6
13
|
|
|
7
14
|
### Added
|
package/README.md
CHANGED
|
@@ -1,62 +1,71 @@
|
|
|
1
1
|
# XCrawl CLI
|
|
2
2
|
|
|
3
|
-
XCrawl CLI is
|
|
3
|
+
XCrawl CLI is the official command-line interface for XCrawl.
|
|
4
|
+
Use it to scrape pages, run search queries, map sites, and manage crawl jobs from your terminal.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Installation
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Run directly with `npx`:
|
|
8
9
|
|
|
9
10
|
```bash
|
|
10
11
|
npx -y @xcrawl/cli@latest doctor
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Install globally with npm:
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
17
|
npm install -g @xcrawl/cli
|
|
17
18
|
xcrawl --help
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
##
|
|
21
|
+
## Quick Start
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Authenticate:
|
|
23
24
|
|
|
24
25
|
```bash
|
|
25
|
-
# Save API key locally
|
|
26
26
|
xcrawl login --api-key <your_api_key>
|
|
27
|
-
|
|
28
|
-
# Or use env var
|
|
29
|
-
export XCRAWL_API_KEY=<your_api_key>
|
|
30
27
|
```
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
Run core commands:
|
|
33
30
|
|
|
34
31
|
```bash
|
|
35
|
-
# Scrape a page
|
|
36
32
|
xcrawl scrape https://example.com --format markdown
|
|
37
|
-
|
|
38
|
-
# Search
|
|
39
33
|
xcrawl search "xcrawl cli" --limit 10
|
|
40
|
-
|
|
41
|
-
# Map links in a site
|
|
34
|
+
xcrawl status
|
|
42
35
|
xcrawl map https://example.com --limit 10
|
|
43
|
-
|
|
44
|
-
# Start a crawl
|
|
45
36
|
xcrawl crawl https://example.com
|
|
46
|
-
|
|
47
|
-
# Check crawl status
|
|
48
37
|
xcrawl crawl status <job-id>
|
|
49
38
|
```
|
|
50
39
|
|
|
51
|
-
Default shortcut:
|
|
40
|
+
Default shortcut for scrape:
|
|
52
41
|
|
|
53
42
|
```bash
|
|
54
43
|
xcrawl https://example.com
|
|
55
|
-
# same as:
|
|
56
|
-
xcrawl scrape https://example.com
|
|
57
44
|
```
|
|
58
45
|
|
|
59
|
-
##
|
|
46
|
+
## Authentication
|
|
47
|
+
|
|
48
|
+
Use either local login or environment variable:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
xcrawl login --api-key <your_api_key>
|
|
52
|
+
xcrawl logout
|
|
53
|
+
export XCRAWL_API_KEY=<your_api_key>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Common Commands
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
xcrawl scrape <url...> [--format markdown|json|html|screenshot|text] [--output <path>] [--json]
|
|
60
|
+
xcrawl search <query> [--limit <n>] [--json]
|
|
61
|
+
xcrawl map <url> [--limit <n>] [--json]
|
|
62
|
+
xcrawl crawl <url> [--wait]
|
|
63
|
+
xcrawl crawl status <job-id>
|
|
64
|
+
xcrawl status [--json]
|
|
65
|
+
xcrawl doctor [--json]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Batch scrape example:
|
|
60
69
|
|
|
61
70
|
```bash
|
|
62
71
|
xcrawl scrape --input ./urls.txt --concurrency 3 --json
|
|
@@ -64,7 +73,9 @@ xcrawl scrape --input ./urls.txt --concurrency 3 --json
|
|
|
64
73
|
|
|
65
74
|
`urls.txt` should contain one URL per line. Lines starting with `#` are ignored.
|
|
66
75
|
|
|
67
|
-
##
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
Manage config values:
|
|
68
79
|
|
|
69
80
|
```bash
|
|
70
81
|
xcrawl config keys
|
|
@@ -72,7 +83,7 @@ xcrawl config get api-base-url
|
|
|
72
83
|
xcrawl config set api-base-url https://run.xcrawl.com
|
|
73
84
|
```
|
|
74
85
|
|
|
75
|
-
|
|
86
|
+
Configuration priority:
|
|
76
87
|
1. CLI flags
|
|
77
88
|
2. Environment variables
|
|
78
89
|
3. Local config file `~/.xcrawl/config.json`
|
|
@@ -87,29 +98,12 @@ Environment variables:
|
|
|
87
98
|
|
|
88
99
|
## Output
|
|
89
100
|
|
|
90
|
-
- Default
|
|
91
|
-
- `--json
|
|
92
|
-
- `--output
|
|
93
|
-
- Multi-URL scrape defaults to `.xcrawl/` when no output path is provided
|
|
101
|
+
- Default output is human-readable text.
|
|
102
|
+
- Use `--json` for machine-readable output.
|
|
103
|
+
- Use `--output <path>` to save output to a file.
|
|
104
|
+
- Multi-URL scrape defaults to `.xcrawl/` when no output path is provided.
|
|
94
105
|
|
|
95
|
-
##
|
|
106
|
+
## API Routing Notes
|
|
96
107
|
|
|
97
108
|
- Default API base URL is `https://run.xcrawl.com`.
|
|
98
|
-
-
|
|
99
|
-
- CLI handles this with explicit fallback output instead of hard failure.
|
|
100
|
-
|
|
101
|
-
## Local Development
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
npm install
|
|
105
|
-
npm run build
|
|
106
|
-
npm run test
|
|
107
|
-
npm run lint
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Real API smoke test:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
export XCRAWL_API_KEY=<your_api_key>
|
|
114
|
-
npm run smoke
|
|
115
|
-
```
|
|
109
|
+
- `status` always calls `https://api.xcrawl.com/web_v1/user/credit-user-info`.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchStatus = fetchStatus;
|
|
4
|
+
function toNumber(value) {
|
|
5
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
function mapStatusData(raw) {
|
|
11
|
+
return {
|
|
12
|
+
username: raw.username ?? '',
|
|
13
|
+
email: raw.email ?? '',
|
|
14
|
+
createdAt: raw.created_at,
|
|
15
|
+
creditLevel: toNumber(raw.credit_level),
|
|
16
|
+
totalCredits: toNumber(raw.total_credits),
|
|
17
|
+
remainCredits: toNumber(raw.remain_credits),
|
|
18
|
+
consumedCredits: toNumber(raw.consumed_credits),
|
|
19
|
+
todayCredits: toNumber(raw.today_credits),
|
|
20
|
+
nextResetAt: raw.next_reset_at ?? null,
|
|
21
|
+
expiredAt: raw.expired_at ?? null,
|
|
22
|
+
packageTitle: raw.package_title ?? null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function isStatusEnvelope(value) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(value, 'data');
|
|
27
|
+
}
|
|
28
|
+
async function fetchStatus(client) {
|
|
29
|
+
const raw = await client.get('/web_v1/user/credit-user-info');
|
|
30
|
+
if (isStatusEnvelope(raw)) {
|
|
31
|
+
return mapStatusData(raw.data ?? {});
|
|
32
|
+
}
|
|
33
|
+
return mapStatusData(raw);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/api/status.ts"],"names":[],"mappings":";;AA8BA,kCAQC;AApCD,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,aAAa,CAAC,GAAkB;IACvC,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE;QAC5B,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE;QACtB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;QACvC,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC;QACzC,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC;QAC3C,eAAe,EAAE,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC/C,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC;QACzC,WAAW,EAAE,GAAG,CAAC,aAAa,IAAI,IAAI;QACtC,SAAS,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI;QACjC,YAAY,EAAE,GAAG,CAAC,aAAa,IAAI,IAAI;KACxC,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAwC;IAChE,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC;AAEM,KAAK,UAAU,WAAW,CAAC,MAAoB;IACpD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAoC,+BAA+B,CAAC,CAAC;IAEjG,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerDoctorCommand = registerDoctorCommand;
|
|
4
|
-
const
|
|
4
|
+
const status_1 = require("../api/status");
|
|
5
5
|
const config_1 = require("../core/config");
|
|
6
6
|
const output_1 = require("../core/output");
|
|
7
7
|
const text_1 = require("../formatters/text");
|
|
@@ -63,11 +63,11 @@ function registerDoctorCommand(program, context) {
|
|
|
63
63
|
if (runtime.apiKey) {
|
|
64
64
|
try {
|
|
65
65
|
const client = context.createApiClient(runtime);
|
|
66
|
-
await (0,
|
|
66
|
+
await (0, status_1.fetchStatus)(client);
|
|
67
67
|
report.checks.push({
|
|
68
68
|
name: 'api_connectivity',
|
|
69
69
|
ok: true,
|
|
70
|
-
detail: '
|
|
70
|
+
detail: 'status check passed'
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
catch (error) {
|
|
@@ -87,7 +87,7 @@ function registerDoctorCommand(program, context) {
|
|
|
87
87
|
});
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
const message = error instanceof Error ? error.message : '
|
|
90
|
+
const message = error instanceof Error ? error.message : 'status check failed';
|
|
91
91
|
report.checks.push({
|
|
92
92
|
name: 'api_connectivity',
|
|
93
93
|
ok: false,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerLogoutCommand = registerLogoutCommand;
|
|
4
|
+
const config_1 = require("../core/config");
|
|
5
|
+
const output_1 = require("../core/output");
|
|
6
|
+
const text_1 = require("../formatters/text");
|
|
7
|
+
function registerLogoutCommand(program, context) {
|
|
8
|
+
program
|
|
9
|
+
.command('logout')
|
|
10
|
+
.description('Clear the locally saved XCrawl API key')
|
|
11
|
+
.option('--json', 'Output result as JSON')
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const result = await (0, config_1.clearLocalApiKey)(context.homeDir);
|
|
14
|
+
await (0, output_1.renderOutput)({
|
|
15
|
+
ctx: { stdout: context.stdout },
|
|
16
|
+
data: {
|
|
17
|
+
ok: true,
|
|
18
|
+
cleared: result.cleared,
|
|
19
|
+
configPath: result.configPath
|
|
20
|
+
},
|
|
21
|
+
json: options.json,
|
|
22
|
+
renderText: () => (0, text_1.formatLogoutResult)(result.cleared, result.configPath)
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;AAWA,sDAmBC;AA5BD,2CAAkD;AAClD,2CAA8C;AAC9C,6CAAwD;AAOxD,SAAgB,qBAAqB,CAAC,OAAgB,EAAE,OAAmB;IACzE,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,wCAAwC,CAAC;SACrD,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;SACzC,MAAM,CAAC,KAAK,EAAE,OAAsB,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAgB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEvD,MAAM,IAAA,qBAAY,EAAC;YACjB,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;YAC/B,IAAI,EAAE;gBACJ,EAAE,EAAE,IAAI;gBACR,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B;YACD,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,yBAAkB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC;SACxE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerStatusCommand = registerStatusCommand;
|
|
4
|
+
const status_1 = require("../api/status");
|
|
5
|
+
const auth_1 = require("../core/auth");
|
|
6
|
+
const constants_1 = require("../core/constants");
|
|
7
|
+
const output_1 = require("../core/output");
|
|
8
|
+
const text_1 = require("../formatters/text");
|
|
9
|
+
const validate_1 = require("../utils/validate");
|
|
10
|
+
const shared_1 = require("./shared");
|
|
11
|
+
function registerStatusCommand(program, context) {
|
|
12
|
+
program
|
|
13
|
+
.command('status')
|
|
14
|
+
.description('Show account profile and credit package status')
|
|
15
|
+
.option('--api-key <key>', 'Override API key')
|
|
16
|
+
.option('--timeout <ms>', 'Request timeout in milliseconds')
|
|
17
|
+
.option('--debug', 'Enable debug output')
|
|
18
|
+
.option('--json', 'Output result as JSON')
|
|
19
|
+
.option('--output <path>', 'Save output to a file')
|
|
20
|
+
.action(async (options) => {
|
|
21
|
+
const runtime = await (0, shared_1.resolveCommandRuntimeConfig)(context, {
|
|
22
|
+
apiKey: options.apiKey,
|
|
23
|
+
timeoutMs: (0, validate_1.parsePositiveInt)(options.timeout, 'timeout'),
|
|
24
|
+
debug: options.debug
|
|
25
|
+
});
|
|
26
|
+
runtime.apiKey = (0, auth_1.requireApiKey)(runtime.apiKey);
|
|
27
|
+
runtime.apiBaseUrl = constants_1.ACCOUNT_API_BASE_URL;
|
|
28
|
+
const client = context.createApiClient(runtime);
|
|
29
|
+
const outputPath = (0, shared_1.resolveOutputPath)(context, options.output);
|
|
30
|
+
const result = await (0, status_1.fetchStatus)(client);
|
|
31
|
+
await (0, output_1.renderOutput)({
|
|
32
|
+
ctx: { stdout: context.stdout },
|
|
33
|
+
data: result,
|
|
34
|
+
json: options.json,
|
|
35
|
+
outputPath,
|
|
36
|
+
renderText: text_1.formatStatus
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";;AAmBA,sDA+BC;AAhDD,0CAA4C;AAC5C,uCAA6C;AAC7C,iDAAyD;AACzD,2CAA8C;AAC9C,6CAAkD;AAElD,gDAAqD;AACrD,qCAA0E;AAU1E,SAAgB,qBAAqB,CAAC,OAAgB,EAAE,OAAmB;IACzE,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,gDAAgD,CAAC;SAC7D,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;SAC7C,MAAM,CAAC,gBAAgB,EAAE,iCAAiC,CAAC;SAC3D,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC;SACxC,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;SACzC,MAAM,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;SAClD,MAAM,CAAC,KAAK,EAAE,OAAsB,EAAE,EAAE;QACvC,MAAM,OAAO,GAAG,MAAM,IAAA,oCAA2B,EAAC,OAAO,EAAE;YACzD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,IAAA,2BAAgB,EAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;YACvD,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,GAAG,IAAA,oBAAa,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,CAAC,UAAU,GAAG,gCAAoB,CAAC;QAE1C,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,IAAA,qBAAY,EAAC;YACjB,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;YAC/B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU;YACV,UAAU,EAAE,mBAAY;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/core/config.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import type { ConfigField, ConfigKey, RuntimeConfig, XCrawlConfig } from '../typ
|
|
|
2
2
|
export declare function getConfigPath(homeDir?: string): string;
|
|
3
3
|
export declare function readLocalConfig(homeDir?: string): Promise<XCrawlConfig>;
|
|
4
4
|
export declare function saveLocalConfig(nextConfig: XCrawlConfig, homeDir?: string): Promise<string>;
|
|
5
|
+
export interface ClearLocalApiKeyResult {
|
|
6
|
+
configPath: string;
|
|
7
|
+
cleared: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function clearLocalApiKey(homeDir?: string): Promise<ClearLocalApiKeyResult>;
|
|
5
10
|
export interface ResolveRuntimeConfigInput {
|
|
6
11
|
flags?: XCrawlConfig;
|
|
7
12
|
env?: XCrawlConfig;
|
package/dist/core/config.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getConfigPath = getConfigPath;
|
|
7
7
|
exports.readLocalConfig = readLocalConfig;
|
|
8
8
|
exports.saveLocalConfig = saveLocalConfig;
|
|
9
|
+
exports.clearLocalApiKey = clearLocalApiKey;
|
|
9
10
|
exports.resolveRuntimeConfig = resolveRuntimeConfig;
|
|
10
11
|
exports.isConfigKey = isConfigKey;
|
|
11
12
|
exports.resolveConfigField = resolveConfigField;
|
|
@@ -60,6 +61,29 @@ async function saveLocalConfig(nextConfig, homeDir) {
|
|
|
60
61
|
throw new errors_1.ConfigError(`Failed to write config file: ${configPath}`, 'Please check directory permissions.', error);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
async function clearLocalApiKey(homeDir) {
|
|
65
|
+
const configPath = getConfigPath(homeDir);
|
|
66
|
+
const existing = await readLocalConfig(homeDir);
|
|
67
|
+
if (!Object.prototype.hasOwnProperty.call(existing, 'apiKey')) {
|
|
68
|
+
return {
|
|
69
|
+
configPath,
|
|
70
|
+
cleared: false
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const configDir = node_path_1.default.dirname(configPath);
|
|
74
|
+
const { apiKey: _apiKey, ...withoutApiKey } = existing;
|
|
75
|
+
try {
|
|
76
|
+
await (0, promises_1.mkdir)(configDir, { recursive: true });
|
|
77
|
+
await (0, promises_1.writeFile)(configPath, `${JSON.stringify(withoutApiKey, null, 2)}\n`, 'utf8');
|
|
78
|
+
return {
|
|
79
|
+
configPath,
|
|
80
|
+
cleared: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw new errors_1.ConfigError(`Failed to write config file: ${configPath}`, 'Please check directory permissions.', error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
63
87
|
function resolveRuntimeConfig(input) {
|
|
64
88
|
const defaults = input.defaults ?? constants_1.DEFAULT_RUNTIME_CONFIG;
|
|
65
89
|
const flags = input.flags ?? {};
|
package/dist/core/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":";;;;;AAmBA,sCAEC;AAED,0CAgBC;AAED,0CAaC;AASD,oDAcC;AAED,kCAEC;AAED,gDASC;AA0BD,4CAgBC;AAED,wCAIC;AAED,wCAcC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":";;;;;AAmBA,sCAEC;AAED,0CAgBC;AAED,0CAaC;AAOD,4CAwBC;AASD,oDAcC;AAED,kCAEC;AAED,gDASC;AA0BD,4CAgBC;AAED,wCAIC;AAED,wCAcC;AA3LD,+CAAsE;AACtE,sDAAyB;AACzB,0DAA6B;AAE7B,2CAAqD;AACrD,qCAAwD;AAGxD,MAAM,mBAAmB,GAAmC;IAC1D,SAAS,EAAE,QAAQ;IACnB,cAAc,EAAE,YAAY;IAC5B,gBAAgB,EAAE,eAAe;IACjC,YAAY,EAAE,WAAW;IACzB,YAAY,EAAE,WAAW;IACzB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,uBAAuB,GAA8B,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvH,SAAgB,aAAa,CAAC,UAAkB,iBAAE,CAAC,OAAO,EAAE;IAC1D,OAAO,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,OAAgB;IACpD,MAAM,UAAU,GAAG,aAAa,CAAC,OAA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ChB,OAAgB;IAEhB,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAkC,EAAE,OAAO,CAAC,CAAC;IAEtG,OAAO;QACL,UAAU;QACV,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/dist/core/constants.d.ts
CHANGED
package/dist/core/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_RUNTIME_CONFIG = exports.DEFAULT_API_BASE_URL = void 0;
|
|
3
|
+
exports.DEFAULT_RUNTIME_CONFIG = exports.ACCOUNT_API_BASE_URL = exports.DEFAULT_API_BASE_URL = void 0;
|
|
4
4
|
exports.DEFAULT_API_BASE_URL = 'https://run.xcrawl.com';
|
|
5
|
+
exports.ACCOUNT_API_BASE_URL = 'https://api.xcrawl.com';
|
|
5
6
|
exports.DEFAULT_RUNTIME_CONFIG = {
|
|
6
7
|
apiBaseUrl: exports.DEFAULT_API_BASE_URL,
|
|
7
8
|
defaultFormat: 'markdown',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAEhD,QAAA,sBAAsB,GAAkB;IACnD,UAAU,EAAE,4BAAoB;IAChC,aAAa,EAAE,UAAU;IACzB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,KAAK;CACb,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAChD,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAEhD,QAAA,sBAAsB,GAAkB;IACnD,UAAU,EAAE,4BAAoB;IAChC,aAAa,EAAE,UAAU;IACzB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,KAAK;CACb,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { CrawlStartResponse, CrawlStatusResponse,
|
|
1
|
+
import type { CrawlStartResponse, CrawlStatusResponse, MapResponse, ScrapeResponse, SearchResponse, StatusResponse } from '../types/api';
|
|
2
2
|
export declare function formatLoginSuccess(configPath: string): string;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function formatLogoutResult(cleared: boolean, configPath: string): string;
|
|
4
|
+
export declare function formatStatus(data: StatusResponse): string;
|
|
4
5
|
export declare function formatScrape(data: ScrapeResponse): string;
|
|
5
6
|
export declare function formatSearch(data: SearchResponse): string;
|
|
6
|
-
export declare function formatCredits(data: CreditsResponse): string;
|
|
7
7
|
export declare function formatMap(data: MapResponse): string;
|
|
8
8
|
export declare function formatCrawlStart(data: CrawlStartResponse): string;
|
|
9
9
|
export declare function formatCrawlStatus(data: CrawlStatusResponse): string;
|
package/dist/formatters/text.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatLoginSuccess = formatLoginSuccess;
|
|
4
|
-
exports.
|
|
4
|
+
exports.formatLogoutResult = formatLogoutResult;
|
|
5
|
+
exports.formatStatus = formatStatus;
|
|
5
6
|
exports.formatScrape = formatScrape;
|
|
6
7
|
exports.formatSearch = formatSearch;
|
|
7
|
-
exports.formatCredits = formatCredits;
|
|
8
8
|
exports.formatMap = formatMap;
|
|
9
9
|
exports.formatCrawlStart = formatCrawlStart;
|
|
10
10
|
exports.formatCrawlStatus = formatCrawlStatus;
|
|
@@ -14,12 +14,25 @@ exports.formatDoctorReport = formatDoctorReport;
|
|
|
14
14
|
function formatLoginSuccess(configPath) {
|
|
15
15
|
return `API key saved to: ${configPath}`;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function formatLogoutResult(cleared, configPath) {
|
|
18
|
+
if (!cleared) {
|
|
19
|
+
return 'No local API key found. Already logged out.';
|
|
20
|
+
}
|
|
21
|
+
return `API key removed from: ${configPath}`;
|
|
22
|
+
}
|
|
23
|
+
function formatStatus(data) {
|
|
18
24
|
return [
|
|
19
|
-
`
|
|
25
|
+
`Username: ${data.username || 'N/A'}`,
|
|
20
26
|
`Email: ${data.email}`,
|
|
21
|
-
`
|
|
22
|
-
`
|
|
27
|
+
`Created At: ${data.createdAt ?? 'N/A'}`,
|
|
28
|
+
`Credit Level: ${data.creditLevel}`,
|
|
29
|
+
`Total Credits: ${data.totalCredits}`,
|
|
30
|
+
`Remaining Credits: ${data.remainCredits}`,
|
|
31
|
+
`Consumed Credits: ${data.consumedCredits}`,
|
|
32
|
+
`Today Credits: ${data.todayCredits}`,
|
|
33
|
+
`Next Reset At: ${data.nextResetAt ?? 'N/A'}`,
|
|
34
|
+
`Expired At: ${data.expiredAt ?? 'N/A'}`,
|
|
35
|
+
`Package: ${data.packageTitle ?? 'N/A'}`
|
|
23
36
|
].join('\n');
|
|
24
37
|
}
|
|
25
38
|
function formatScrape(data) {
|
|
@@ -36,19 +49,11 @@ function formatSearch(data) {
|
|
|
36
49
|
});
|
|
37
50
|
return `Query: ${data.query}\n\n${lines.join('\n\n')}`;
|
|
38
51
|
}
|
|
39
|
-
function formatCredits(data) {
|
|
40
|
-
return [
|
|
41
|
-
`Remaining: ${data.remaining}`,
|
|
42
|
-
`Used: ${data.used}`,
|
|
43
|
-
`Total: ${data.total}`,
|
|
44
|
-
`Reset At: ${data.resetAt ?? 'N/A'}`
|
|
45
|
-
].join('\n');
|
|
46
|
-
}
|
|
47
52
|
function formatMap(data) {
|
|
48
53
|
if (data.links.length === 0) {
|
|
49
54
|
return `Source URL: ${data.url}\nTotal links: 0`;
|
|
50
55
|
}
|
|
51
|
-
const lines = data.links.map((link, index) => `${index + 1}. ${link.
|
|
56
|
+
const lines = data.links.map((link, index) => `${index + 1}. ${link.url}`);
|
|
52
57
|
return `Source URL: ${data.url}\nTotal links: ${data.total}\n\n${lines.join('\n\n')}`;
|
|
53
58
|
}
|
|
54
59
|
function formatCrawlStart(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/formatters/text.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/formatters/text.ts"],"names":[],"mappings":";;AASA,gDAEC;AAED,gDAMC;AAED,oCAcC;AAED,oCAGC;AAED,oCAWC;AAED,8BAOC;AAED,4CAEC;AAED,8CAUC;AAED,0CAEC;AAED,0CAEC;AAaD,gDAGC;AA7FD,SAAgB,kBAAkB,CAAC,UAAkB;IACnD,OAAO,qBAAqB,UAAU,EAAE,CAAC;AAC3C,CAAC;AAED,SAAgB,kBAAkB,CAAC,OAAgB,EAAE,UAAkB;IACrE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,6CAA6C,CAAC;IACvD,CAAC;IAED,OAAO,yBAAyB,UAAU,EAAE,CAAC;AAC/C,CAAC;AAED,SAAgB,YAAY,CAAC,IAAoB;IAC/C,OAAO;QACL,aAAa,IAAI,CAAC,QAAQ,IAAI,KAAK,EAAE;QACrC,UAAU,IAAI,CAAC,KAAK,EAAE;QACtB,eAAe,IAAI,CAAC,SAAS,IAAI,KAAK,EAAE;QACxC,iBAAiB,IAAI,CAAC,WAAW,EAAE;QACnC,kBAAkB,IAAI,CAAC,YAAY,EAAE;QACrC,sBAAsB,IAAI,CAAC,aAAa,EAAE;QAC1C,qBAAqB,IAAI,CAAC,eAAe,EAAE;QAC3C,kBAAkB,IAAI,CAAC,YAAY,EAAE;QACrC,kBAAkB,IAAI,CAA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,KAAK,CAAC,EAAE,EAAE,gBAAgB,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvF,CAAC;AAaD,SAAgB,kBAAkB,CAAC,MAAoB;IACrD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzG,OAAO,CAAC,cAAc,MAAM,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,21 +14,21 @@ const commander_1 = require("commander");
|
|
|
14
14
|
const client_1 = require("./api/client");
|
|
15
15
|
const config_1 = require("./commands/config");
|
|
16
16
|
const crawl_1 = require("./commands/crawl");
|
|
17
|
-
const credits_1 = require("./commands/credits");
|
|
18
17
|
const doctor_1 = require("./commands/doctor");
|
|
19
18
|
const init_1 = require("./commands/init");
|
|
20
19
|
const login_1 = require("./commands/login");
|
|
20
|
+
const logout_1 = require("./commands/logout");
|
|
21
21
|
const map_1 = require("./commands/map");
|
|
22
22
|
const scrape_1 = require("./commands/scrape");
|
|
23
23
|
const search_1 = require("./commands/search");
|
|
24
|
-
const
|
|
24
|
+
const status_1 = require("./commands/status");
|
|
25
25
|
const errors_1 = require("./core/errors");
|
|
26
26
|
const KNOWN_COMMANDS = new Set([
|
|
27
27
|
'login',
|
|
28
|
-
'
|
|
28
|
+
'logout',
|
|
29
|
+
'status',
|
|
29
30
|
'scrape',
|
|
30
31
|
'search',
|
|
31
|
-
'credits',
|
|
32
32
|
'doctor',
|
|
33
33
|
'map',
|
|
34
34
|
'crawl',
|
|
@@ -36,6 +36,9 @@ const KNOWN_COMMANDS = new Set([
|
|
|
36
36
|
'init',
|
|
37
37
|
'help'
|
|
38
38
|
]);
|
|
39
|
+
function isLikelyHttpUrl(value) {
|
|
40
|
+
return value.startsWith('http://') || value.startsWith('https://');
|
|
41
|
+
}
|
|
39
42
|
function normalizeArgv(argv) {
|
|
40
43
|
if (argv.length === 0) {
|
|
41
44
|
return argv;
|
|
@@ -50,6 +53,9 @@ function normalizeArgv(argv) {
|
|
|
50
53
|
if (first.startsWith('-') || KNOWN_COMMANDS.has(first)) {
|
|
51
54
|
return argv;
|
|
52
55
|
}
|
|
56
|
+
if (!isLikelyHttpUrl(first)) {
|
|
57
|
+
return argv;
|
|
58
|
+
}
|
|
53
59
|
return ['scrape', ...argv];
|
|
54
60
|
}
|
|
55
61
|
function createDefaultContext(overrides = {}) {
|
|
@@ -74,10 +80,10 @@ function createProgram(context) {
|
|
|
74
80
|
const program = new commander_1.Command();
|
|
75
81
|
program.name('xcrawl').description('XCrawl CLI').version(context.version);
|
|
76
82
|
(0, login_1.registerLoginCommand)(program, context);
|
|
77
|
-
(0,
|
|
83
|
+
(0, logout_1.registerLogoutCommand)(program, context);
|
|
84
|
+
(0, status_1.registerStatusCommand)(program, context);
|
|
78
85
|
(0, scrape_1.registerScrapeCommand)(program, context);
|
|
79
86
|
(0, search_1.registerSearchCommand)(program, context);
|
|
80
|
-
(0, credits_1.registerCreditsCommand)(program, context);
|
|
81
87
|
(0, doctor_1.registerDoctorCommand)(program, context);
|
|
82
88
|
(0, map_1.registerMapCommand)(program, context);
|
|
83
89
|
(0, crawl_1.registerCrawlCommand)(program, context);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AA+DA,oDAkBC;AAED,sCAqBC;AAED,wBAmBC;AA3HD,sDAAyB;AACzB,0DA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,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC9B,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,KAAK,IAAI,EAAE,CAAC;AACd,CAAC;AAEY,QAAA,WAAW,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC"}
|
package/dist/types/api.d.ts
CHANGED
|
@@ -9,11 +9,36 @@ export interface ApiTransport {
|
|
|
9
9
|
get<T>(path: string, options?: ApiRequestOptions): Promise<T>;
|
|
10
10
|
post<T>(path: string, options?: ApiRequestOptions): Promise<T>;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
13
|
-
|
|
12
|
+
export interface StatusResponse {
|
|
13
|
+
username: string;
|
|
14
14
|
email: string;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
createdAt?: string;
|
|
16
|
+
creditLevel: number;
|
|
17
|
+
totalCredits: number;
|
|
18
|
+
remainCredits: number;
|
|
19
|
+
consumedCredits: number;
|
|
20
|
+
todayCredits: number;
|
|
21
|
+
nextResetAt?: string | null;
|
|
22
|
+
expiredAt?: string | null;
|
|
23
|
+
packageTitle?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface RawStatusData {
|
|
26
|
+
username?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
created_at?: string;
|
|
29
|
+
credit_level?: number;
|
|
30
|
+
total_credits?: number;
|
|
31
|
+
remain_credits?: number;
|
|
32
|
+
consumed_credits?: number;
|
|
33
|
+
today_credits?: number;
|
|
34
|
+
next_reset_at?: string | null;
|
|
35
|
+
expired_at?: string | null;
|
|
36
|
+
package_title?: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface RawStatusEnvelope {
|
|
39
|
+
code?: number;
|
|
40
|
+
msg?: string;
|
|
41
|
+
data?: RawStatusData;
|
|
17
42
|
}
|
|
18
43
|
export interface ScrapeRequest {
|
|
19
44
|
url: string;
|
|
@@ -82,12 +107,6 @@ export interface RawSearchResponse {
|
|
|
82
107
|
ended_at?: string;
|
|
83
108
|
total_credits_used?: number;
|
|
84
109
|
}
|
|
85
|
-
export interface CreditsResponse {
|
|
86
|
-
remaining: number;
|
|
87
|
-
used: number;
|
|
88
|
-
total: number;
|
|
89
|
-
resetAt?: string;
|
|
90
|
-
}
|
|
91
110
|
export interface MapRequest {
|
|
92
111
|
url: string;
|
|
93
112
|
maxDepth?: number;
|