dockup-cli 1.0.1 → 1.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/bin/dockup +2 -0
- package/dist/commands/agent.js +356 -0
- package/dist/commands/auth.js +123 -126
- package/dist/commands/database.js +315 -563
- package/dist/commands/env.js +125 -93
- package/dist/commands/link.js +148 -189
- package/dist/commands/logs.js +100 -82
- package/dist/commands/open.js +69 -41
- package/dist/commands/projects.js +128 -94
- package/dist/commands/push.js +138 -122
- package/dist/commands/service.js +143 -119
- package/dist/commands/status.js +116 -89
- package/dist/commands/workspace.js +210 -220
- package/dist/index.js +75 -179
- package/dist/lib/api.js +241 -191
- package/dist/lib/config.js +135 -142
- package/dist/lib/flags.js +36 -0
- package/dist/lib/output.js +65 -0
- package/dist/lib/target.js +40 -0
- package/dockupcli.md +185 -0
- package/package.json +13 -25
- package/dist/commands/auth.d.ts +0 -5
- package/dist/commands/database.d.ts +0 -16
- package/dist/commands/env.d.ts +0 -5
- package/dist/commands/link.d.ts +0 -2
- package/dist/commands/logs.d.ts +0 -4
- package/dist/commands/open.d.ts +0 -3
- package/dist/commands/projects.d.ts +0 -2
- package/dist/commands/push.d.ts +0 -3
- package/dist/commands/service.d.ts +0 -8
- package/dist/commands/status.d.ts +0 -1
- package/dist/commands/workspace.d.ts +0 -10
- package/dist/index.d.ts +0 -2
- package/dist/lib/api.d.ts +0 -39
- package/dist/lib/config.d.ts +0 -51
|
@@ -1,584 +1,336 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 };
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
11
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var database_exports = {};
|
|
30
|
+
__export(database_exports, {
|
|
31
|
+
databaseCreate: () => databaseCreate,
|
|
32
|
+
databaseCredentials: () => databaseCredentials,
|
|
33
|
+
databaseDelete: () => databaseDelete,
|
|
34
|
+
databaseInfo: () => databaseInfo,
|
|
35
|
+
databaseList: () => databaseList,
|
|
36
|
+
databaseRename: () => databaseRename
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(database_exports);
|
|
39
|
+
var import_chalk = __toESM(require("chalk"));
|
|
40
|
+
var import_ora = __toESM(require("ora"));
|
|
41
|
+
var readline = __toESM(require("readline"));
|
|
42
|
+
var import_config = require("../lib/config");
|
|
43
|
+
var import_api = require("../lib/api");
|
|
55
44
|
const DB_TYPES = [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
{ name: "PostgreSQL", value: "postgresql" },
|
|
46
|
+
{ name: "MySQL", value: "mysql" },
|
|
47
|
+
{ name: "MongoDB", value: "mongodb" },
|
|
48
|
+
{ name: "Redis", value: "redis" }
|
|
60
49
|
];
|
|
61
50
|
function question(prompt) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
51
|
+
const rl = readline.createInterface({
|
|
52
|
+
input: process.stdin,
|
|
53
|
+
output: process.stdout
|
|
54
|
+
});
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
rl.question(prompt, (answer) => {
|
|
57
|
+
rl.close();
|
|
58
|
+
resolve(answer);
|
|
71
59
|
});
|
|
60
|
+
});
|
|
72
61
|
}
|
|
73
62
|
function requireAuth() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
64
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
79
68
|
}
|
|
80
69
|
function requireWorkspace() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
const ws = (0, import_config.getCurrentWorkspace)();
|
|
71
|
+
if (!ws) {
|
|
72
|
+
console.log(import_chalk.default.yellow("No workspace selected. Run `dockup workspace select` first."));
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
87
76
|
}
|
|
88
77
|
function getStatusColor(status) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
78
|
+
switch (status?.toLowerCase()) {
|
|
79
|
+
case "running":
|
|
80
|
+
case "active":
|
|
81
|
+
return import_chalk.default.green(status);
|
|
82
|
+
case "pending":
|
|
83
|
+
case "creating":
|
|
84
|
+
return import_chalk.default.yellow(status);
|
|
85
|
+
case "stopped":
|
|
86
|
+
case "suspended":
|
|
87
|
+
return import_chalk.default.gray(status);
|
|
88
|
+
case "error":
|
|
89
|
+
case "failed":
|
|
90
|
+
return import_chalk.default.red(status);
|
|
91
|
+
default:
|
|
92
|
+
return import_chalk.default.dim(status || "unknown");
|
|
93
|
+
}
|
|
105
94
|
}
|
|
106
95
|
async function databaseList() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
try {
|
|
114
|
-
const databases = await api_1.api.getDatabases(workspace.slug);
|
|
115
|
-
spinner.stop();
|
|
116
|
-
if (databases.length === 0) {
|
|
117
|
-
console.log(chalk_1.default.yellow(`\nNo databases in workspace "${workspace.name}". Create one with \`dockup db create\``));
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
console.log(chalk_1.default.cyan(`\n Databases in "${workspace.name}":\n`));
|
|
121
|
-
databases.forEach((db) => {
|
|
122
|
-
const status = getStatusColor(db.status);
|
|
123
|
-
const type = chalk_1.default.dim(`[${db.dbType || db.type}]`);
|
|
124
|
-
console.log(` ${chalk_1.default.white(db.name)} ${type} - ${status}`);
|
|
125
|
-
});
|
|
126
|
-
console.log();
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
spinner.fail(`Failed to fetch databases: ${error.message}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async function databaseCreate(options) {
|
|
133
|
-
if (!requireAuth())
|
|
134
|
-
return;
|
|
135
|
-
if (!requireWorkspace())
|
|
136
|
-
return;
|
|
137
|
-
const workspace = (0, config_1.getCurrentWorkspace)();
|
|
138
|
-
let { name, type } = options;
|
|
139
|
-
if (!name) {
|
|
140
|
-
name = await question('Database name: ');
|
|
141
|
-
if (!name || name.trim() === '') {
|
|
142
|
-
console.log(chalk_1.default.red('Name is required'));
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
name = name.trim();
|
|
146
|
-
}
|
|
147
|
-
if (!type) {
|
|
148
|
-
console.log(chalk_1.default.cyan('\n Select database type:\n'));
|
|
149
|
-
DB_TYPES.forEach((t, i) => {
|
|
150
|
-
console.log(` ${i + 1}. ${t.name}`);
|
|
151
|
-
});
|
|
152
|
-
console.log();
|
|
153
|
-
const answer = await question('Enter number: ');
|
|
154
|
-
const index = parseInt(answer) - 1;
|
|
155
|
-
if (isNaN(index) || index < 0 || index >= DB_TYPES.length) {
|
|
156
|
-
console.log(chalk_1.default.red('Invalid selection'));
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
type = DB_TYPES[index].value;
|
|
160
|
-
}
|
|
161
|
-
const spinner = (0, ora_1.default)(`Creating ${type} database "${name}"...`).start();
|
|
162
|
-
try {
|
|
163
|
-
const database = await api_1.api.createDatabase(workspace.slug, name, type);
|
|
164
|
-
spinner.succeed(`Database "${chalk_1.default.green(database.name)}" created successfully`);
|
|
165
|
-
console.log(chalk_1.default.dim(`\nDatabase is being provisioned. Run \`dockup db creds\` to get connection details.`));
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
spinner.fail(`Failed to create database: ${error.message}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
async function databaseRename(slug) {
|
|
172
|
-
if (!requireAuth())
|
|
173
|
-
return;
|
|
174
|
-
if (!requireWorkspace())
|
|
175
|
-
return;
|
|
176
|
-
const workspace = (0, config_1.getCurrentWorkspace)();
|
|
177
|
-
let dbSlug = slug;
|
|
178
|
-
// If no slug provided, let user select from list
|
|
179
|
-
if (!dbSlug) {
|
|
180
|
-
const spinner = (0, ora_1.default)('Fetching databases...').start();
|
|
181
|
-
const databases = await api_1.api.getDatabases(workspace.slug);
|
|
182
|
-
spinner.stop();
|
|
183
|
-
if (databases.length === 0) {
|
|
184
|
-
console.log(chalk_1.default.yellow('No databases found in this workspace.'));
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
console.log(chalk_1.default.cyan('\n Select database to rename:\n'));
|
|
188
|
-
databases.forEach((db, i) => {
|
|
189
|
-
console.log(` ${i + 1}. ${db.name} ${chalk_1.default.dim(`[${db.dbType || db.type}]`)}`);
|
|
190
|
-
});
|
|
191
|
-
console.log();
|
|
192
|
-
const answer = await question('Enter number: ');
|
|
193
|
-
const index = parseInt(answer) - 1;
|
|
194
|
-
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
195
|
-
console.log(chalk_1.default.red('Invalid selection'));
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
dbSlug = databases[index].slug;
|
|
199
|
-
}
|
|
200
|
-
const spinner = (0, ora_1.default)('Getting database info...').start();
|
|
201
|
-
const database = await api_1.api.getDatabase(workspace.slug, dbSlug);
|
|
202
|
-
spinner.stop();
|
|
203
|
-
const newName = await question(`New name for "${database.name}": `);
|
|
204
|
-
if (!newName || newName.trim() === '') {
|
|
205
|
-
console.log(chalk_1.default.dim('Cancelled'));
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const renameSpinner = (0, ora_1.default)('Renaming database...').start();
|
|
209
|
-
try {
|
|
210
|
-
const updated = await api_1.api.renameDatabase(workspace.slug, dbSlug, newName.trim());
|
|
211
|
-
renameSpinner.succeed(`Database renamed to "${chalk_1.default.green(updated.name)}"`);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
renameSpinner.fail(`Failed to rename database: ${error.message}`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
async function databaseDelete(slug) {
|
|
218
|
-
if (!requireAuth())
|
|
219
|
-
return;
|
|
220
|
-
if (!requireWorkspace())
|
|
221
|
-
return;
|
|
222
|
-
const workspace = (0, config_1.getCurrentWorkspace)();
|
|
223
|
-
let dbSlug = slug;
|
|
224
|
-
// If no slug provided, let user select from list
|
|
225
|
-
if (!dbSlug) {
|
|
226
|
-
const spinner = (0, ora_1.default)('Fetching databases...').start();
|
|
227
|
-
const databases = await api_1.api.getDatabases(workspace.slug);
|
|
228
|
-
spinner.stop();
|
|
229
|
-
if (databases.length === 0) {
|
|
230
|
-
console.log(chalk_1.default.yellow('No databases found in this workspace.'));
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
console.log(chalk_1.default.cyan('\n Select database to delete:\n'));
|
|
234
|
-
databases.forEach((db, i) => {
|
|
235
|
-
console.log(` ${i + 1}. ${db.name} ${chalk_1.default.dim(`[${db.dbType || db.type}]`)}`);
|
|
236
|
-
});
|
|
237
|
-
console.log();
|
|
238
|
-
const answer = await question('Enter number: ');
|
|
239
|
-
const index = parseInt(answer) - 1;
|
|
240
|
-
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
241
|
-
console.log(chalk_1.default.red('Invalid selection'));
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
dbSlug = databases[index].slug;
|
|
245
|
-
}
|
|
246
|
-
const spinner = (0, ora_1.default)('Getting database info...').start();
|
|
247
|
-
const database = await api_1.api.getDatabase(workspace.slug, dbSlug);
|
|
96
|
+
if (!requireAuth()) return;
|
|
97
|
+
if (!requireWorkspace()) return;
|
|
98
|
+
const workspace = (0, import_config.getCurrentWorkspace)();
|
|
99
|
+
const spinner = (0, import_ora.default)(`Fetching databases for "${workspace.name}"...`).start();
|
|
100
|
+
try {
|
|
101
|
+
const databases = await import_api.api.getDatabases(workspace.id);
|
|
248
102
|
spinner.stop();
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return;
|
|
267
|
-
if (!requireWorkspace())
|
|
268
|
-
return;
|
|
269
|
-
const workspace = (0, config_1.getCurrentWorkspace)();
|
|
270
|
-
let dbSlug = slug;
|
|
271
|
-
// If no slug provided, let user select from list
|
|
272
|
-
if (!dbSlug) {
|
|
273
|
-
const spinner = (0, ora_1.default)('Fetching databases...').start();
|
|
274
|
-
const databases = await api_1.api.getDatabases(workspace.slug);
|
|
275
|
-
spinner.stop();
|
|
276
|
-
if (databases.length === 0) {
|
|
277
|
-
console.log(chalk_1.default.yellow('No databases found in this workspace.'));
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
console.log(chalk_1.default.cyan('\n Select database:\n'));
|
|
281
|
-
databases.forEach((db, i) => {
|
|
282
|
-
console.log(` ${i + 1}. ${db.name} ${chalk_1.default.dim(`[${db.dbType || db.type}]`)}`);
|
|
283
|
-
});
|
|
284
|
-
console.log();
|
|
285
|
-
const answer = await question('Enter number: ');
|
|
286
|
-
const index = parseInt(answer) - 1;
|
|
287
|
-
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
288
|
-
console.log(chalk_1.default.red('Invalid selection'));
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
dbSlug = databases[index].slug;
|
|
292
|
-
}
|
|
293
|
-
const spinner = (0, ora_1.default)('Fetching credentials...').start();
|
|
294
|
-
try {
|
|
295
|
-
const creds = await api_1.api.getDatabaseCredentials(workspace.slug, dbSlug);
|
|
296
|
-
spinner.stop();
|
|
297
|
-
console.log(chalk_1.default.cyan('\n Database Credentials:\n'));
|
|
298
|
-
console.log(` ${chalk_1.default.dim('Host:')} ${creds.host}`);
|
|
299
|
-
console.log(` ${chalk_1.default.dim('Port:')} ${creds.port}`);
|
|
300
|
-
console.log(` ${chalk_1.default.dim('Database:')} ${creds.database}`);
|
|
301
|
-
console.log(` ${chalk_1.default.dim('Username:')} ${creds.user || creds.username}`);
|
|
302
|
-
console.log(` ${chalk_1.default.dim('Password:')} ${creds.password}`);
|
|
303
|
-
if (creds.connectionString) {
|
|
304
|
-
console.log(chalk_1.default.cyan('\n Connection String:\n'));
|
|
305
|
-
console.log(` ${creds.connectionString}`);
|
|
306
|
-
}
|
|
307
|
-
console.log();
|
|
308
|
-
}
|
|
309
|
-
catch (error) {
|
|
310
|
-
spinner.fail(`Failed to fetch credentials: ${error.message}`);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async function databaseInfo(slug) {
|
|
314
|
-
if (!requireAuth())
|
|
315
|
-
return;
|
|
316
|
-
if (!requireWorkspace())
|
|
317
|
-
return;
|
|
318
|
-
const workspace = (0, config_1.getCurrentWorkspace)();
|
|
319
|
-
let dbSlug = slug;
|
|
320
|
-
// If no slug provided, let user select from list
|
|
321
|
-
if (!dbSlug) {
|
|
322
|
-
const spinner = (0, ora_1.default)('Fetching databases...').start();
|
|
323
|
-
const databases = await api_1.api.getDatabases(workspace.slug);
|
|
324
|
-
spinner.stop();
|
|
325
|
-
if (databases.length === 0) {
|
|
326
|
-
console.log(chalk_1.default.yellow('No databases found in this workspace.'));
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
console.log(chalk_1.default.cyan('\n Select database:\n'));
|
|
330
|
-
databases.forEach((db, i) => {
|
|
331
|
-
console.log(` ${i + 1}. ${db.name} ${chalk_1.default.dim(`[${db.dbType || db.type}]`)}`);
|
|
332
|
-
});
|
|
333
|
-
console.log();
|
|
334
|
-
const answer = await question('Enter number: ');
|
|
335
|
-
const index = parseInt(answer) - 1;
|
|
336
|
-
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
337
|
-
console.log(chalk_1.default.red('Invalid selection'));
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
dbSlug = databases[index].slug;
|
|
341
|
-
}
|
|
342
|
-
const spinner = (0, ora_1.default)('Fetching database info...').start();
|
|
343
|
-
try {
|
|
344
|
-
const db = await api_1.api.getDatabase(workspace.slug, dbSlug);
|
|
345
|
-
spinner.stop();
|
|
346
|
-
console.log(chalk_1.default.cyan('\n Database Info:\n'));
|
|
347
|
-
console.log(` ${chalk_1.default.dim('Name:')} ${db.name}`);
|
|
348
|
-
console.log(` ${chalk_1.default.dim('Type:')} ${db.dbType || db.type}`);
|
|
349
|
-
console.log(` ${chalk_1.default.dim('Version:')} ${db.dbVersion || db.version || 'latest'}`);
|
|
350
|
-
console.log(` ${chalk_1.default.dim('Status:')} ${getStatusColor(db.status)}`);
|
|
351
|
-
console.log(` ${chalk_1.default.dim('Slug:')} ${db.slug}`);
|
|
352
|
-
console.log(` ${chalk_1.default.dim('Created:')} ${new Date(db.createdAt).toLocaleString()}`);
|
|
353
|
-
console.log();
|
|
354
|
-
}
|
|
355
|
-
catch (error) {
|
|
356
|
-
spinner.fail(`Failed to fetch database info: ${error.message}`);
|
|
357
|
-
}
|
|
103
|
+
if (databases.length === 0) {
|
|
104
|
+
console.log(import_chalk.default.yellow(`
|
|
105
|
+
No databases in workspace "${workspace.name}". Create one with \`dockup db create\``));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
console.log(import_chalk.default.cyan(`
|
|
109
|
+
Databases in "${workspace.name}":
|
|
110
|
+
`));
|
|
111
|
+
databases.forEach((db) => {
|
|
112
|
+
const status = getStatusColor(db.status);
|
|
113
|
+
const type = import_chalk.default.dim(`[${db.type}]`);
|
|
114
|
+
console.log(` ${import_chalk.default.white(db.name)} ${type} - ${status}`);
|
|
115
|
+
});
|
|
116
|
+
console.log();
|
|
117
|
+
} catch (error) {
|
|
118
|
+
spinner.fail(`Failed to fetch databases: ${error.message}`);
|
|
119
|
+
}
|
|
358
120
|
}
|
|
359
|
-
async function
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
console.log();
|
|
396
|
-
}
|
|
397
|
-
catch (error) {
|
|
398
|
-
spinner.fail(`Failed to fetch logs: ${error.message}`);
|
|
399
|
-
}
|
|
121
|
+
async function databaseCreate(options) {
|
|
122
|
+
if (!requireAuth()) return;
|
|
123
|
+
if (!requireWorkspace()) return;
|
|
124
|
+
const workspace = (0, import_config.getCurrentWorkspace)();
|
|
125
|
+
let { name, type } = options;
|
|
126
|
+
if (!name) {
|
|
127
|
+
name = await question("Database name: ");
|
|
128
|
+
if (!name || name.trim() === "") {
|
|
129
|
+
console.log(import_chalk.default.red("Name is required"));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
name = name.trim();
|
|
133
|
+
}
|
|
134
|
+
if (!type) {
|
|
135
|
+
console.log(import_chalk.default.cyan("\n Select database type:\n"));
|
|
136
|
+
DB_TYPES.forEach((t, i) => {
|
|
137
|
+
console.log(` ${i + 1}. ${t.name}`);
|
|
138
|
+
});
|
|
139
|
+
console.log();
|
|
140
|
+
const answer = await question("Enter number: ");
|
|
141
|
+
const index = parseInt(answer) - 1;
|
|
142
|
+
if (isNaN(index) || index < 0 || index >= DB_TYPES.length) {
|
|
143
|
+
console.log(import_chalk.default.red("Invalid selection"));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
type = DB_TYPES[index].value;
|
|
147
|
+
}
|
|
148
|
+
const spinner = (0, import_ora.default)(`Creating ${type} database "${name}"...`).start();
|
|
149
|
+
try {
|
|
150
|
+
const database = await import_api.api.createDatabase(workspace.id, name, type);
|
|
151
|
+
spinner.succeed(`Database "${import_chalk.default.green(database.name)}" created successfully`);
|
|
152
|
+
console.log(import_chalk.default.dim(`
|
|
153
|
+
Database is being provisioned. Run \`dockup db credentials\` to get connection details.`));
|
|
154
|
+
} catch (error) {
|
|
155
|
+
spinner.fail(`Failed to create database: ${error.message}`);
|
|
156
|
+
}
|
|
400
157
|
}
|
|
401
|
-
async function
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
catch (error) {
|
|
442
|
-
spinner.fail(`Failed to restart database: ${error.message}`);
|
|
443
|
-
}
|
|
158
|
+
async function databaseRename(id) {
|
|
159
|
+
if (!requireAuth()) return;
|
|
160
|
+
if (!requireWorkspace()) return;
|
|
161
|
+
const workspace = (0, import_config.getCurrentWorkspace)();
|
|
162
|
+
if (!id) {
|
|
163
|
+
const spinner2 = (0, import_ora.default)("Fetching databases...").start();
|
|
164
|
+
const databases = await import_api.api.getDatabases(workspace.id);
|
|
165
|
+
spinner2.stop();
|
|
166
|
+
if (databases.length === 0) {
|
|
167
|
+
console.log(import_chalk.default.yellow("No databases found in this workspace."));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
console.log(import_chalk.default.cyan("\n Select database to rename:\n"));
|
|
171
|
+
databases.forEach((db, i) => {
|
|
172
|
+
console.log(` ${i + 1}. ${db.name} ${import_chalk.default.dim(`[${db.type}]`)}`);
|
|
173
|
+
});
|
|
174
|
+
console.log();
|
|
175
|
+
const answer = await question("Enter number: ");
|
|
176
|
+
const index = parseInt(answer) - 1;
|
|
177
|
+
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
178
|
+
console.log(import_chalk.default.red("Invalid selection"));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
id = databases[index].id;
|
|
182
|
+
}
|
|
183
|
+
const spinner = (0, import_ora.default)("Getting database info...").start();
|
|
184
|
+
const database = await import_api.api.getDatabase(id);
|
|
185
|
+
spinner.stop();
|
|
186
|
+
const newName = await question(`New name for "${database.name}": `);
|
|
187
|
+
if (!newName || newName.trim() === "") {
|
|
188
|
+
console.log(import_chalk.default.dim("Cancelled"));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const renameSpinner = (0, import_ora.default)("Renaming database...").start();
|
|
192
|
+
try {
|
|
193
|
+
const updated = await import_api.api.renameDatabase(id, newName.trim());
|
|
194
|
+
renameSpinner.succeed(`Database renamed to "${import_chalk.default.green(updated.name)}"`);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
renameSpinner.fail(`Failed to rename database: ${error.message}`);
|
|
197
|
+
}
|
|
444
198
|
}
|
|
445
|
-
async function
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
199
|
+
async function databaseDelete(id) {
|
|
200
|
+
if (!requireAuth()) return;
|
|
201
|
+
if (!requireWorkspace()) return;
|
|
202
|
+
const workspace = (0, import_config.getCurrentWorkspace)();
|
|
203
|
+
if (!id) {
|
|
204
|
+
const spinner2 = (0, import_ora.default)("Fetching databases...").start();
|
|
205
|
+
const databases = await import_api.api.getDatabases(workspace.id);
|
|
206
|
+
spinner2.stop();
|
|
207
|
+
if (databases.length === 0) {
|
|
208
|
+
console.log(import_chalk.default.yellow("No databases found in this workspace."));
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
console.log(import_chalk.default.cyan("\n Select database to delete:\n"));
|
|
212
|
+
databases.forEach((db, i) => {
|
|
213
|
+
console.log(` ${i + 1}. ${db.name} ${import_chalk.default.dim(`[${db.type}]`)}`);
|
|
214
|
+
});
|
|
215
|
+
console.log();
|
|
216
|
+
const answer2 = await question("Enter number: ");
|
|
217
|
+
const index = parseInt(answer2) - 1;
|
|
218
|
+
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
219
|
+
console.log(import_chalk.default.red("Invalid selection"));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
id = databases[index].id;
|
|
223
|
+
}
|
|
224
|
+
const spinner = (0, import_ora.default)("Getting database info...").start();
|
|
225
|
+
const database = await import_api.api.getDatabase(id);
|
|
226
|
+
spinner.stop();
|
|
227
|
+
console.log(import_chalk.default.red(`
|
|
228
|
+
WARNING: This will permanently delete "${database.name}"!
|
|
229
|
+
`));
|
|
230
|
+
const answer = await question('Type "yes" to confirm: ');
|
|
231
|
+
if (answer.toLowerCase() !== "yes") {
|
|
232
|
+
console.log(import_chalk.default.dim("Cancelled"));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const deleteSpinner = (0, import_ora.default)("Deleting database...").start();
|
|
236
|
+
try {
|
|
237
|
+
await import_api.api.deleteDatabase(id);
|
|
238
|
+
deleteSpinner.succeed(`Database "${database.name}" deleted`);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
deleteSpinner.fail(`Failed to delete database: ${error.message}`);
|
|
241
|
+
}
|
|
489
242
|
}
|
|
490
|
-
async function
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
const date = new Date(backup.createdAt).toLocaleString();
|
|
534
|
-
console.log(` ${i + 1}. ${chalk_1.default.white(backup.filename)} - ${status} - ${size} - ${chalk_1.default.dim(date)}`);
|
|
535
|
-
});
|
|
536
|
-
console.log();
|
|
537
|
-
}
|
|
538
|
-
catch (error) {
|
|
539
|
-
spinner.fail(`Failed to fetch backups: ${error.message}`);
|
|
540
|
-
}
|
|
243
|
+
async function databaseCredentials(id) {
|
|
244
|
+
if (!requireAuth()) return;
|
|
245
|
+
if (!requireWorkspace()) return;
|
|
246
|
+
const workspace = (0, import_config.getCurrentWorkspace)();
|
|
247
|
+
if (!id) {
|
|
248
|
+
const spinner2 = (0, import_ora.default)("Fetching databases...").start();
|
|
249
|
+
const databases = await import_api.api.getDatabases(workspace.id);
|
|
250
|
+
spinner2.stop();
|
|
251
|
+
if (databases.length === 0) {
|
|
252
|
+
console.log(import_chalk.default.yellow("No databases found in this workspace."));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
console.log(import_chalk.default.cyan("\n Select database:\n"));
|
|
256
|
+
databases.forEach((db, i) => {
|
|
257
|
+
console.log(` ${i + 1}. ${db.name} ${import_chalk.default.dim(`[${db.type}]`)}`);
|
|
258
|
+
});
|
|
259
|
+
console.log();
|
|
260
|
+
const answer = await question("Enter number: ");
|
|
261
|
+
const index = parseInt(answer) - 1;
|
|
262
|
+
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
263
|
+
console.log(import_chalk.default.red("Invalid selection"));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
id = databases[index].id;
|
|
267
|
+
}
|
|
268
|
+
const spinner = (0, import_ora.default)("Fetching credentials...").start();
|
|
269
|
+
try {
|
|
270
|
+
const creds = await import_api.api.getDatabaseCredentials(id);
|
|
271
|
+
spinner.stop();
|
|
272
|
+
console.log(import_chalk.default.cyan("\n Database Credentials:\n"));
|
|
273
|
+
console.log(` ${import_chalk.default.dim("Host:")} ${creds.host}`);
|
|
274
|
+
console.log(` ${import_chalk.default.dim("Port:")} ${creds.port}`);
|
|
275
|
+
console.log(` ${import_chalk.default.dim("Database:")} ${creds.database}`);
|
|
276
|
+
console.log(` ${import_chalk.default.dim("Username:")} ${creds.username}`);
|
|
277
|
+
console.log(` ${import_chalk.default.dim("Password:")} ${creds.password}`);
|
|
278
|
+
if (creds.connectionString) {
|
|
279
|
+
console.log(import_chalk.default.cyan("\n Connection String:\n"));
|
|
280
|
+
console.log(` ${creds.connectionString}`);
|
|
281
|
+
}
|
|
282
|
+
console.log();
|
|
283
|
+
} catch (error) {
|
|
284
|
+
spinner.fail(`Failed to fetch credentials: ${error.message}`);
|
|
285
|
+
}
|
|
541
286
|
}
|
|
542
|
-
async function
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
if (
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
}
|
|
287
|
+
async function databaseInfo(id) {
|
|
288
|
+
if (!requireAuth()) return;
|
|
289
|
+
if (!requireWorkspace()) return;
|
|
290
|
+
const workspace = (0, import_config.getCurrentWorkspace)();
|
|
291
|
+
if (!id) {
|
|
292
|
+
const spinner2 = (0, import_ora.default)("Fetching databases...").start();
|
|
293
|
+
const databases = await import_api.api.getDatabases(workspace.id);
|
|
294
|
+
spinner2.stop();
|
|
295
|
+
if (databases.length === 0) {
|
|
296
|
+
console.log(import_chalk.default.yellow("No databases found in this workspace."));
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
console.log(import_chalk.default.cyan("\n Select database:\n"));
|
|
300
|
+
databases.forEach((db, i) => {
|
|
301
|
+
console.log(` ${i + 1}. ${db.name} ${import_chalk.default.dim(`[${db.type}]`)}`);
|
|
302
|
+
});
|
|
303
|
+
console.log();
|
|
304
|
+
const answer = await question("Enter number: ");
|
|
305
|
+
const index = parseInt(answer) - 1;
|
|
306
|
+
if (isNaN(index) || index < 0 || index >= databases.length) {
|
|
307
|
+
console.log(import_chalk.default.red("Invalid selection"));
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
id = databases[index].id;
|
|
311
|
+
}
|
|
312
|
+
const spinner = (0, import_ora.default)("Fetching database info...").start();
|
|
313
|
+
try {
|
|
314
|
+
const db = await import_api.api.getDatabase(id);
|
|
315
|
+
spinner.stop();
|
|
316
|
+
console.log(import_chalk.default.cyan("\n Database Info:\n"));
|
|
317
|
+
console.log(` ${import_chalk.default.dim("Name:")} ${db.name}`);
|
|
318
|
+
console.log(` ${import_chalk.default.dim("Type:")} ${db.type}`);
|
|
319
|
+
console.log(` ${import_chalk.default.dim("Version:")} ${db.version || "latest"}`);
|
|
320
|
+
console.log(` ${import_chalk.default.dim("Status:")} ${getStatusColor(db.status)}`);
|
|
321
|
+
console.log(` ${import_chalk.default.dim("ID:")} ${db.id}`);
|
|
322
|
+
console.log(` ${import_chalk.default.dim("Created:")} ${new Date(db.createdAt).toLocaleString()}`);
|
|
323
|
+
console.log();
|
|
324
|
+
} catch (error) {
|
|
325
|
+
spinner.fail(`Failed to fetch database info: ${error.message}`);
|
|
326
|
+
}
|
|
584
327
|
}
|
|
328
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
329
|
+
0 && (module.exports = {
|
|
330
|
+
databaseCreate,
|
|
331
|
+
databaseCredentials,
|
|
332
|
+
databaseDelete,
|
|
333
|
+
databaseInfo,
|
|
334
|
+
databaseList,
|
|
335
|
+
databaseRename
|
|
336
|
+
});
|