@crawlee-cloud/cli 0.1.5 ā 0.1.6
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 +3 -4
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +41 -18
- package/dist/commands/login.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -58,12 +58,11 @@ You'll be prompted for your API token. Credentials are stored in `~/.crawlee-clo
|
|
|
58
58
|
|
|
59
59
|
### Environment Variables
|
|
60
60
|
|
|
61
|
-
| Variable
|
|
62
|
-
|
|
61
|
+
| Variable | Description |
|
|
62
|
+
| ----------------------- | --------------------- |
|
|
63
63
|
| `CRAWLEE_CLOUD_API_URL` | Override API base URL |
|
|
64
|
-
| `CRAWLEE_CLOUD_TOKEN`
|
|
64
|
+
| `CRAWLEE_CLOUD_TOKEN` | Override API token |
|
|
65
65
|
|
|
66
66
|
## Documentation
|
|
67
67
|
|
|
68
68
|
For full documentation, visit the [Crawlee Cloud Documentation](https://github.com/crawlee-cloud/crawlee-cloud).
|
|
69
|
-
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,eAAO,MAAM,YAAY,SA6ErB,CAAC"}
|
package/dist/commands/login.js
CHANGED
|
@@ -15,25 +15,42 @@ export const loginCommand = new Command('login')
|
|
|
15
15
|
console.log(chalk.bold('\nš Login to Crawlee Cloud\n'));
|
|
16
16
|
const existingConfig = await getConfig();
|
|
17
17
|
// Get API URL
|
|
18
|
-
const apiBaseUrl = options.url
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const apiBaseUrl = options.url ??
|
|
19
|
+
(await input({
|
|
20
|
+
message: 'API URL:',
|
|
21
|
+
default: existingConfig.apiBaseUrl || 'http://localhost:3000',
|
|
22
|
+
}));
|
|
22
23
|
// Get token
|
|
23
|
-
const token = options.token
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const token = options.token ??
|
|
25
|
+
(await password({
|
|
26
|
+
message: 'API Token:',
|
|
27
|
+
mask: '*',
|
|
28
|
+
}));
|
|
29
|
+
// Test connection and validate token
|
|
30
|
+
console.log(chalk.dim('\nValidating credentials...'));
|
|
29
31
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
// First check if server is reachable
|
|
33
|
+
const healthResponse = await fetch(`${apiBaseUrl}/health`);
|
|
34
|
+
if (!healthResponse.ok) {
|
|
35
|
+
throw new Error(`Server returned ${String(healthResponse.status)}`);
|
|
33
36
|
}
|
|
34
|
-
const health = await
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
const health = (await healthResponse.json());
|
|
38
|
+
// Now validate the token by calling an authenticated endpoint
|
|
39
|
+
const authResponse = await fetch(`${apiBaseUrl}/v2/auth/me`, {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${token}`,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
if (authResponse.status === 401 || authResponse.status === 403) {
|
|
45
|
+
throw new Error('Invalid token. Please check your API key and try again.');
|
|
46
|
+
}
|
|
47
|
+
if (!authResponse.ok) {
|
|
48
|
+
throw new Error(`Authentication failed: ${String(authResponse.status)}`);
|
|
49
|
+
}
|
|
50
|
+
const userData = (await authResponse.json());
|
|
51
|
+
console.log(chalk.green(`ā
Connected to Crawlee Cloud v${health.version ?? '1.0.0'}`));
|
|
52
|
+
console.log(chalk.dim(` Authenticated as: ${userData.data.email}`));
|
|
53
|
+
// Save config only after successful validation
|
|
37
54
|
await saveConfig({
|
|
38
55
|
apiBaseUrl,
|
|
39
56
|
token,
|
|
@@ -42,8 +59,14 @@ export const loginCommand = new Command('login')
|
|
|
42
59
|
console.log(chalk.green('\nā
Login successful!\n'));
|
|
43
60
|
}
|
|
44
61
|
catch (err) {
|
|
45
|
-
|
|
46
|
-
console.log(chalk.
|
|
62
|
+
const message = err.message;
|
|
63
|
+
console.log(chalk.red(`\nā ${message}`));
|
|
64
|
+
if (message.includes('Invalid token')) {
|
|
65
|
+
console.log(chalk.dim(`\nGet a valid token from your dashboard: Settings ā API Keys`));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.log(chalk.dim(`\nMake sure the platform is running at ${apiBaseUrl}`));
|
|
69
|
+
}
|
|
47
70
|
process.exit(1);
|
|
48
71
|
}
|
|
49
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAkB3D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CA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AC,0CAA0C,UAAU,EAAE,CAAC,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee-cloud/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "CLI for Crawlee Cloud - run and deploy Actors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
"url": "https://github.com/crawlee-cloud/crawlee-cloud/issues"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://crawlee.cloud"
|
|
54
|
-
}
|
|
54
|
+
}
|