dockup-cli 1.0.2 → 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,240 +1,230 @@
|
|
|
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
|
-
|
|
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 workspace_exports = {};
|
|
30
|
+
__export(workspace_exports, {
|
|
31
|
+
workspaceCreate: () => workspaceCreate,
|
|
32
|
+
workspaceCurrent: () => workspaceCurrent,
|
|
33
|
+
workspaceDelete: () => workspaceDelete,
|
|
34
|
+
workspaceList: () => workspaceList,
|
|
35
|
+
workspaceRename: () => workspaceRename,
|
|
36
|
+
workspaceSelect: () => workspaceSelect
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(workspace_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");
|
|
50
44
|
function question(prompt) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
45
|
+
const rl = readline.createInterface({
|
|
46
|
+
input: process.stdin,
|
|
47
|
+
output: process.stdout
|
|
48
|
+
});
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
rl.question(prompt, (answer) => {
|
|
51
|
+
rl.close();
|
|
52
|
+
resolve(answer);
|
|
60
53
|
});
|
|
54
|
+
});
|
|
61
55
|
}
|
|
62
56
|
function requireAuth() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
58
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
68
62
|
}
|
|
69
63
|
async function workspaceList() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
else {
|
|
95
|
-
console.log(chalk_1.default.dim('No workspace selected. Run `dockup workspace select` to choose one.'));
|
|
96
|
-
}
|
|
97
|
-
console.log();
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
spinner.fail(`Failed to fetch workspaces: ${error.message}`);
|
|
64
|
+
if (!requireAuth()) return;
|
|
65
|
+
const spinner = (0, import_ora.default)("Fetching workspaces...").start();
|
|
66
|
+
try {
|
|
67
|
+
const workspaces = await import_api.api.getWorkspaces();
|
|
68
|
+
spinner.stop();
|
|
69
|
+
if (workspaces.length === 0) {
|
|
70
|
+
console.log(import_chalk.default.yellow("\nNo workspaces found. Create one with `dockup workspace create`"));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const currentWs = (0, import_config.getCurrentWorkspace)();
|
|
74
|
+
console.log(import_chalk.default.cyan("\n Your Workspaces:\n"));
|
|
75
|
+
workspaces.forEach((ws) => {
|
|
76
|
+
const isCurrent = currentWs?.id === ws.id;
|
|
77
|
+
const marker = isCurrent ? import_chalk.default.green("\u25CF ") : " ";
|
|
78
|
+
const name = isCurrent ? import_chalk.default.green(ws.name) : ws.name;
|
|
79
|
+
const slug = import_chalk.default.dim(`(${ws.slug})`);
|
|
80
|
+
const dbCount = import_chalk.default.dim(`${ws._count?.databases || 0} databases`);
|
|
81
|
+
console.log(`${marker}${name} ${slug} - ${dbCount}`);
|
|
82
|
+
});
|
|
83
|
+
console.log();
|
|
84
|
+
if (currentWs) {
|
|
85
|
+
console.log(import_chalk.default.dim(`Current workspace: ${currentWs.name}`));
|
|
86
|
+
} else {
|
|
87
|
+
console.log(import_chalk.default.dim("No workspace selected. Run `dockup workspace select` to choose one."));
|
|
101
88
|
}
|
|
89
|
+
console.log();
|
|
90
|
+
} catch (error) {
|
|
91
|
+
spinner.fail(`Failed to fetch workspaces: ${error.message}`);
|
|
92
|
+
}
|
|
102
93
|
}
|
|
103
94
|
async function workspaceCreate(options) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
catch (error) {
|
|
128
|
-
spinner.fail(`Failed to create workspace: ${error.message}`);
|
|
129
|
-
}
|
|
95
|
+
if (!requireAuth()) return;
|
|
96
|
+
let name = options.name;
|
|
97
|
+
if (!name) {
|
|
98
|
+
name = await question("Workspace name: ");
|
|
99
|
+
if (!name || name.trim() === "") {
|
|
100
|
+
console.log(import_chalk.default.red("Name is required"));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
name = name.trim();
|
|
104
|
+
}
|
|
105
|
+
const spinner = (0, import_ora.default)("Creating workspace...").start();
|
|
106
|
+
try {
|
|
107
|
+
const workspace = await import_api.api.createWorkspace(name);
|
|
108
|
+
spinner.succeed(`Workspace "${import_chalk.default.green(workspace.name)}" created successfully`);
|
|
109
|
+
(0, import_config.setCurrentWorkspace)({
|
|
110
|
+
id: workspace.id,
|
|
111
|
+
name: workspace.name,
|
|
112
|
+
slug: workspace.slug
|
|
113
|
+
});
|
|
114
|
+
console.log(import_chalk.default.dim(`Workspace selected: ${workspace.name}`));
|
|
115
|
+
} catch (error) {
|
|
116
|
+
spinner.fail(`Failed to create workspace: ${error.message}`);
|
|
117
|
+
}
|
|
130
118
|
}
|
|
131
119
|
async function workspaceSelect() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
spinner.fail(`Failed to select workspace: ${error.message}`);
|
|
166
|
-
}
|
|
120
|
+
if (!requireAuth()) return;
|
|
121
|
+
const spinner = (0, import_ora.default)("Fetching workspaces...").start();
|
|
122
|
+
try {
|
|
123
|
+
const workspaces = await import_api.api.getWorkspaces();
|
|
124
|
+
spinner.stop();
|
|
125
|
+
if (workspaces.length === 0) {
|
|
126
|
+
console.log(import_chalk.default.yellow("\nNo workspaces found. Create one with `dockup workspace create`"));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const currentWs = (0, import_config.getCurrentWorkspace)();
|
|
130
|
+
console.log(import_chalk.default.cyan("\n Select a workspace:\n"));
|
|
131
|
+
workspaces.forEach((ws, index2) => {
|
|
132
|
+
const isCurrent = currentWs?.id === ws.id;
|
|
133
|
+
const marker = isCurrent ? import_chalk.default.green("\u25CF") : " ";
|
|
134
|
+
console.log(` ${marker} ${index2 + 1}. ${ws.name} ${import_chalk.default.dim(`(${ws.slug})`)}`);
|
|
135
|
+
});
|
|
136
|
+
console.log();
|
|
137
|
+
const answer = await question("Enter number: ");
|
|
138
|
+
const index = parseInt(answer) - 1;
|
|
139
|
+
if (isNaN(index) || index < 0 || index >= workspaces.length) {
|
|
140
|
+
console.log(import_chalk.default.red("Invalid selection"));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const selected = workspaces[index];
|
|
144
|
+
(0, import_config.setCurrentWorkspace)({
|
|
145
|
+
id: selected.id,
|
|
146
|
+
name: selected.name,
|
|
147
|
+
slug: selected.slug
|
|
148
|
+
});
|
|
149
|
+
console.log(import_chalk.default.green(`\u2713 Workspace "${selected.name}" selected`));
|
|
150
|
+
} catch (error) {
|
|
151
|
+
spinner.fail(`Failed to select workspace: ${error.message}`);
|
|
152
|
+
}
|
|
167
153
|
}
|
|
168
154
|
async function workspaceRename(options) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
spinner.fail(`Failed to rename workspace: ${error.message}`);
|
|
199
|
-
}
|
|
155
|
+
if (!requireAuth()) return;
|
|
156
|
+
const currentWs = (0, import_config.getCurrentWorkspace)();
|
|
157
|
+
if (!currentWs) {
|
|
158
|
+
console.log(import_chalk.default.yellow("No workspace selected. Run `dockup workspace select` first."));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
let newName = options.name;
|
|
162
|
+
if (!newName) {
|
|
163
|
+
newName = await question(`New name for "${currentWs.name}" (enter to keep): `);
|
|
164
|
+
if (!newName || newName.trim() === "") {
|
|
165
|
+
newName = currentWs.name;
|
|
166
|
+
} else {
|
|
167
|
+
newName = newName.trim();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const spinner = (0, import_ora.default)("Renaming workspace...").start();
|
|
171
|
+
try {
|
|
172
|
+
const workspace = await import_api.api.renameWorkspace(currentWs.id, newName);
|
|
173
|
+
spinner.succeed(`Workspace renamed to "${import_chalk.default.green(workspace.name)}"`);
|
|
174
|
+
(0, import_config.setCurrentWorkspace)({
|
|
175
|
+
id: workspace.id,
|
|
176
|
+
name: workspace.name,
|
|
177
|
+
slug: workspace.slug
|
|
178
|
+
});
|
|
179
|
+
} catch (error) {
|
|
180
|
+
spinner.fail(`Failed to rename workspace: ${error.message}`);
|
|
181
|
+
}
|
|
200
182
|
}
|
|
201
183
|
async function workspaceDelete() {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
184
|
+
if (!requireAuth()) return;
|
|
185
|
+
const currentWs = (0, import_config.getCurrentWorkspace)();
|
|
186
|
+
if (!currentWs) {
|
|
187
|
+
console.log(import_chalk.default.yellow("No workspace selected. Run `dockup workspace select` first."));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
console.log(import_chalk.default.red(`
|
|
191
|
+
WARNING: This will delete "${currentWs.name}" and all its databases!
|
|
192
|
+
`));
|
|
193
|
+
const answer = await question("Type workspace name to confirm: ");
|
|
194
|
+
if (answer !== currentWs.name) {
|
|
195
|
+
console.log(import_chalk.default.dim("Cancelled"));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const spinner = (0, import_ora.default)("Deleting workspace...").start();
|
|
199
|
+
try {
|
|
200
|
+
await import_api.api.deleteWorkspace(currentWs.id);
|
|
201
|
+
spinner.succeed(`Workspace "${currentWs.name}" deleted`);
|
|
202
|
+
(0, import_config.clearCurrentWorkspace)();
|
|
203
|
+
console.log(import_chalk.default.dim("Run `dockup workspace select` to select another workspace."));
|
|
204
|
+
} catch (error) {
|
|
205
|
+
spinner.fail(`Failed to delete workspace: ${error.message}`);
|
|
206
|
+
}
|
|
225
207
|
}
|
|
226
208
|
async function workspaceCurrent() {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
console.log();
|
|
209
|
+
if (!requireAuth()) return;
|
|
210
|
+
const currentWs = (0, import_config.getCurrentWorkspace)();
|
|
211
|
+
if (!currentWs) {
|
|
212
|
+
console.log(import_chalk.default.yellow("No workspace selected."));
|
|
213
|
+
console.log(import_chalk.default.dim("Run `dockup workspace select` to choose one."));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
console.log(import_chalk.default.cyan("\n Current Workspace:\n"));
|
|
217
|
+
console.log(` ${import_chalk.default.dim("Name:")} ${currentWs.name}`);
|
|
218
|
+
console.log(` ${import_chalk.default.dim("Slug:")} ${currentWs.slug}`);
|
|
219
|
+
console.log(` ${import_chalk.default.dim("ID:")} ${currentWs.id}`);
|
|
220
|
+
console.log();
|
|
240
221
|
}
|
|
222
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
223
|
+
0 && (module.exports = {
|
|
224
|
+
workspaceCreate,
|
|
225
|
+
workspaceCurrent,
|
|
226
|
+
workspaceDelete,
|
|
227
|
+
workspaceList,
|
|
228
|
+
workspaceRename,
|
|
229
|
+
workspaceSelect
|
|
230
|
+
});
|