dockup-cli 1.0.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.
@@ -0,0 +1,5 @@
1
+ export declare function login(options: {
2
+ token?: string;
3
+ }): Promise<void>;
4
+ export declare function logout(): Promise<void>;
5
+ export declare function whoami(): Promise<void>;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.login = login;
40
+ exports.logout = logout;
41
+ exports.whoami = whoami;
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const ora_1 = __importDefault(require("ora"));
44
+ const open_1 = __importDefault(require("open"));
45
+ const readline = __importStar(require("readline"));
46
+ const config_1 = require("../lib/config");
47
+ const api_1 = require("../lib/api");
48
+ function question(prompt) {
49
+ const rl = readline.createInterface({
50
+ input: process.stdin,
51
+ output: process.stdout
52
+ });
53
+ return new Promise((resolve) => {
54
+ rl.question(prompt, (answer) => {
55
+ rl.close();
56
+ resolve(answer);
57
+ });
58
+ });
59
+ }
60
+ async function login(options) {
61
+ if ((0, config_1.isLoggedIn)()) {
62
+ const user = (0, config_1.getUser)();
63
+ console.log(chalk_1.default.yellow(`Already logged in as ${user?.email}`));
64
+ const answer = await question('Log in with different account? (y/N): ');
65
+ if (answer.toLowerCase() !== 'y') {
66
+ return;
67
+ }
68
+ }
69
+ let token = options.token;
70
+ if (!token) {
71
+ const authUrl = 'https://app.dockup.ai/cli-auth';
72
+ console.log(chalk_1.default.cyan('\n Dockup CLI Login\n'));
73
+ console.log(chalk_1.default.dim(' Opening browser for authentication...'));
74
+ console.log(chalk_1.default.dim(' If browser does not open, visit:'));
75
+ console.log(chalk_1.default.cyan(` ${authUrl}\n`));
76
+ // Open browser for authentication
77
+ await (0, open_1.default)(authUrl);
78
+ // Ask for the token
79
+ token = await question(chalk_1.default.white(' Paste token from browser: '));
80
+ }
81
+ if (!token || token.trim() === '') {
82
+ console.log(chalk_1.default.red('\n No token provided'));
83
+ process.exit(1);
84
+ }
85
+ token = token.trim();
86
+ const spinner = (0, ora_1.default)('Verifying token...').start();
87
+ // Save token temporarily to verify
88
+ (0, config_1.setToken)(token);
89
+ try {
90
+ const user = await api_1.api.verifyToken();
91
+ if (!user) {
92
+ (0, config_1.clearToken)();
93
+ spinner.fail('Invalid token');
94
+ process.exit(1);
95
+ }
96
+ (0, config_1.setUser)(user);
97
+ spinner.succeed(`Logged in as ${chalk_1.default.green(user.email)}`);
98
+ console.log(chalk_1.default.dim(`\nWelcome back, ${user.name}!`));
99
+ }
100
+ catch (error) {
101
+ (0, config_1.clearToken)();
102
+ spinner.fail(`Authentication failed: ${error.message}`);
103
+ process.exit(1);
104
+ }
105
+ }
106
+ async function logout() {
107
+ if (!(0, config_1.isLoggedIn)()) {
108
+ console.log(chalk_1.default.yellow('Not logged in'));
109
+ return;
110
+ }
111
+ const user = (0, config_1.getUser)();
112
+ (0, config_1.clearToken)();
113
+ console.log(chalk_1.default.green(`✓ Logged out from ${user?.email}`));
114
+ }
115
+ async function whoami() {
116
+ if (!(0, config_1.isLoggedIn)()) {
117
+ console.log(chalk_1.default.yellow('Not logged in'));
118
+ console.log(chalk_1.default.dim('Run `dockup login` to authenticate'));
119
+ return;
120
+ }
121
+ const spinner = (0, ora_1.default)('Fetching user info...').start();
122
+ try {
123
+ const user = await api_1.api.verifyToken();
124
+ if (!user) {
125
+ spinner.fail('Session expired. Please login again.');
126
+ (0, config_1.clearToken)();
127
+ return;
128
+ }
129
+ (0, config_1.setUser)(user);
130
+ spinner.stop();
131
+ console.log(chalk_1.default.cyan('\n Current User:\n'));
132
+ console.log(` ${chalk_1.default.dim('Name:')} ${user.name}`);
133
+ console.log(` ${chalk_1.default.dim('Email:')} ${user.email}`);
134
+ console.log(` ${chalk_1.default.dim('ID:')} ${user.id}`);
135
+ console.log();
136
+ }
137
+ catch (error) {
138
+ spinner.fail(`Failed to fetch user info: ${error.message}`);
139
+ }
140
+ }
@@ -0,0 +1,16 @@
1
+ export declare function databaseList(): Promise<void>;
2
+ export declare function databaseCreate(options: {
3
+ name?: string;
4
+ type?: string;
5
+ }): Promise<void>;
6
+ export declare function databaseRename(slug?: string): Promise<void>;
7
+ export declare function databaseDelete(slug?: string): Promise<void>;
8
+ export declare function databaseCredentials(slug?: string): Promise<void>;
9
+ export declare function databaseInfo(slug?: string): Promise<void>;
10
+ export declare function databaseLogs(slug?: string, options?: {
11
+ tail?: string;
12
+ }): Promise<void>;
13
+ export declare function databaseRestart(slug?: string): Promise<void>;
14
+ export declare function databaseSize(slug?: string): Promise<void>;
15
+ export declare function databaseBackupList(slug?: string): Promise<void>;
16
+ export declare function databaseBackupCreate(slug?: string): Promise<void>;