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
package/dist/commands/push.js
CHANGED
|
@@ -1,135 +1,151 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 push_exports = {};
|
|
30
|
+
__export(push_exports, {
|
|
31
|
+
push: () => push
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(push_exports);
|
|
34
|
+
var import_chalk = __toESM(require("chalk"));
|
|
35
|
+
var import_ora = __toESM(require("ora"));
|
|
36
|
+
var import_child_process = require("child_process");
|
|
37
|
+
var import_config = require("../lib/config");
|
|
38
|
+
var import_api = require("../lib/api");
|
|
12
39
|
async function push(branch, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
41
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const config = (0, import_config.getProjectConfig)();
|
|
45
|
+
if (!config) {
|
|
46
|
+
console.log(import_chalk.default.red("Not linked to any service. Run `dockup link` first."));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
console.log(import_chalk.default.cyan(`
|
|
50
|
+
Deploying to ${import_chalk.default.bold(config.projectName)}/${import_chalk.default.bold(config.serviceName)}
|
|
51
|
+
`));
|
|
52
|
+
if (!branch) {
|
|
53
|
+
try {
|
|
54
|
+
branch = (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", { encoding: "utf-8" }).trim();
|
|
55
|
+
} catch {
|
|
56
|
+
branch = "main";
|
|
16
57
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const status = (0, import_child_process.execSync)("git status --porcelain", { encoding: "utf-8" }).trim();
|
|
61
|
+
if (status) {
|
|
62
|
+
console.log(import_chalk.default.yellow("\u26A0 You have uncommitted changes:"));
|
|
63
|
+
console.log(import_chalk.default.dim(status.split("\n").slice(0, 5).join("\n")));
|
|
64
|
+
if (status.split("\n").length > 5) {
|
|
65
|
+
console.log(import_chalk.default.dim(` ... and ${status.split("\n").length - 5} more files`));
|
|
66
|
+
}
|
|
67
|
+
console.log();
|
|
21
68
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
branch = (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' }).trim();
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
branch = 'main';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// Check for uncommitted changes
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
if (!options?.force) {
|
|
72
|
+
const gitSpinner = (0, import_ora.default)(`Pushing to origin/${branch}...`).start();
|
|
33
73
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
74
|
+
(0, import_child_process.execSync)(`git push origin ${branch}`, {
|
|
75
|
+
encoding: "utf-8",
|
|
76
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
77
|
+
});
|
|
78
|
+
gitSpinner.succeed(`Pushed to origin/${branch}`);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error.stderr?.includes("Everything up-to-date") || error.stdout?.includes("Everything up-to-date")) {
|
|
81
|
+
gitSpinner.succeed("Already up to date");
|
|
82
|
+
} else {
|
|
83
|
+
gitSpinner.warn("Git push failed (continuing with deploy)");
|
|
84
|
+
console.log(import_chalk.default.dim(error.message));
|
|
85
|
+
}
|
|
43
86
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(chalk_1.default.dim(error.message));
|
|
65
|
-
}
|
|
87
|
+
}
|
|
88
|
+
const deploySpinner = (0, import_ora.default)("Triggering deployment...").start();
|
|
89
|
+
try {
|
|
90
|
+
const result = await import_api.api.deploy(config.projectSlug, config.serviceSlug, { branch });
|
|
91
|
+
deploySpinner.succeed("Deployment started!");
|
|
92
|
+
console.log(import_chalk.default.dim(`
|
|
93
|
+
Deployment ID: ${result.deployment?.id || "N/A"}`));
|
|
94
|
+
console.log(import_chalk.default.cyan("\n Building...\n"));
|
|
95
|
+
let lastStatus = "";
|
|
96
|
+
let dots = 0;
|
|
97
|
+
const maxPolls = 120;
|
|
98
|
+
let polls = 0;
|
|
99
|
+
while (polls < maxPolls) {
|
|
100
|
+
polls++;
|
|
101
|
+
try {
|
|
102
|
+
const status = await import_api.api.getServiceStatus(config.projectSlug, config.serviceSlug);
|
|
103
|
+
const deployment = status.deployments?.[0];
|
|
104
|
+
if (!deployment) {
|
|
105
|
+
await sleep(1e3);
|
|
106
|
+
continue;
|
|
66
107
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (currentStatus !== lastStatus) {
|
|
91
|
-
lastStatus = currentStatus;
|
|
92
|
-
if (currentStatus === 'building') {
|
|
93
|
-
process.stdout.write(chalk_1.default.yellow(' ⏳ Building'));
|
|
94
|
-
}
|
|
95
|
-
else if (currentStatus === 'deploying') {
|
|
96
|
-
process.stdout.write(chalk_1.default.blue('\n 🚀 Deploying'));
|
|
97
|
-
}
|
|
98
|
-
else if (currentStatus === 'success') {
|
|
99
|
-
console.log(chalk_1.default.green('\n\n ✓ Deployed successfully!\n'));
|
|
100
|
-
console.log(chalk_1.default.dim(' URL: ') + chalk_1.default.cyan(`https://${status.domain}`));
|
|
101
|
-
console.log();
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
else if (currentStatus === 'failed') {
|
|
105
|
-
console.log(chalk_1.default.red('\n\n ✗ Deployment failed\n'));
|
|
106
|
-
console.log(chalk_1.default.dim(' Run `dockup logs` to see error details'));
|
|
107
|
-
console.log();
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Show progress dots
|
|
113
|
-
dots++;
|
|
114
|
-
if (dots % 3 === 0) {
|
|
115
|
-
process.stdout.write('.');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
await sleep(1000);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
await sleep(1000);
|
|
122
|
-
}
|
|
108
|
+
const currentStatus = deployment.status;
|
|
109
|
+
if (currentStatus !== lastStatus) {
|
|
110
|
+
lastStatus = currentStatus;
|
|
111
|
+
if (currentStatus === "building") {
|
|
112
|
+
process.stdout.write(import_chalk.default.yellow(" \u23F3 Building"));
|
|
113
|
+
} else if (currentStatus === "deploying") {
|
|
114
|
+
process.stdout.write(import_chalk.default.blue("\n \u{1F680} Deploying"));
|
|
115
|
+
} else if (currentStatus === "success") {
|
|
116
|
+
console.log(import_chalk.default.green("\n\n \u2713 Deployed successfully!\n"));
|
|
117
|
+
console.log(import_chalk.default.dim(" URL: ") + import_chalk.default.cyan(`https://${status.domain}`));
|
|
118
|
+
console.log();
|
|
119
|
+
return;
|
|
120
|
+
} else if (currentStatus === "failed") {
|
|
121
|
+
console.log(import_chalk.default.red("\n\n \u2717 Deployment failed\n"));
|
|
122
|
+
console.log(import_chalk.default.dim(" Run `dockup logs` to see error details"));
|
|
123
|
+
console.log();
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
dots++;
|
|
128
|
+
if (dots % 3 === 0) {
|
|
129
|
+
process.stdout.write(".");
|
|
130
|
+
}
|
|
123
131
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
catch (error) {
|
|
129
|
-
deploySpinner.fail(`Deployment failed: ${error.message}`);
|
|
130
|
-
process.exit(1);
|
|
132
|
+
await sleep(1e3);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
await sleep(1e3);
|
|
135
|
+
}
|
|
131
136
|
}
|
|
137
|
+
console.log(import_chalk.default.yellow("\n\n \u26A0 Deployment is taking longer than expected"));
|
|
138
|
+
console.log(import_chalk.default.dim(" Run `dockup status` to check progress"));
|
|
139
|
+
console.log();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
deploySpinner.fail(`Deployment failed: ${error.message}`);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
132
144
|
}
|
|
133
145
|
function sleep(ms) {
|
|
134
|
-
|
|
146
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
135
147
|
}
|
|
148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
+
0 && (module.exports = {
|
|
150
|
+
push
|
|
151
|
+
});
|
package/dist/commands/service.js
CHANGED
|
@@ -1,133 +1,157 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 service_exports = {};
|
|
30
|
+
__export(service_exports, {
|
|
31
|
+
deployService: () => deployService,
|
|
32
|
+
restartService: () => restartService,
|
|
33
|
+
serviceLogs: () => serviceLogs,
|
|
34
|
+
startService: () => startService,
|
|
35
|
+
stopService: () => stopService
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(service_exports);
|
|
38
|
+
var import_chalk = __toESM(require("chalk"));
|
|
39
|
+
var import_ora = __toESM(require("ora"));
|
|
40
|
+
var import_config = require("../lib/config");
|
|
41
|
+
var import_api = require("../lib/api");
|
|
15
42
|
async function getServiceContext() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
const config = (0, import_config.getProjectConfig)();
|
|
44
|
+
if (!config) {
|
|
45
|
+
console.log(import_chalk.default.red("Not linked to any service. Run `dockup link` first."));
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return { projectSlug: config.projectSlug, serviceSlug: config.serviceSlug };
|
|
22
49
|
}
|
|
23
50
|
async function startService() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
51
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
52
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
const ctx = await getServiceContext();
|
|
56
|
+
if (!ctx) process.exit(1);
|
|
57
|
+
const spinner = (0, import_ora.default)("Starting service...").start();
|
|
58
|
+
try {
|
|
59
|
+
await import_api.api.post(`/projects/${ctx.projectSlug}/services/${ctx.serviceSlug}/start`);
|
|
60
|
+
spinner.succeed("Service started!");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
spinner.fail(`Failed to start: ${error.message}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
40
65
|
}
|
|
41
66
|
async function stopService() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
67
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
68
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
const ctx = await getServiceContext();
|
|
72
|
+
if (!ctx) process.exit(1);
|
|
73
|
+
const spinner = (0, import_ora.default)("Stopping service...").start();
|
|
74
|
+
try {
|
|
75
|
+
await import_api.api.post(`/projects/${ctx.projectSlug}/services/${ctx.serviceSlug}/stop`);
|
|
76
|
+
spinner.succeed("Service stopped!");
|
|
77
|
+
} catch (error) {
|
|
78
|
+
spinner.fail(`Failed to stop: ${error.message}`);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
58
81
|
}
|
|
59
82
|
async function restartService() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
83
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
84
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
const ctx = await getServiceContext();
|
|
88
|
+
if (!ctx) process.exit(1);
|
|
89
|
+
const spinner = (0, import_ora.default)("Restarting service...").start();
|
|
90
|
+
try {
|
|
91
|
+
await import_api.api.post(`/projects/${ctx.projectSlug}/services/${ctx.serviceSlug}/restart`);
|
|
92
|
+
spinner.succeed("Service restarted!");
|
|
93
|
+
} catch (error) {
|
|
94
|
+
spinner.fail(`Failed to restart: ${error.message}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
76
97
|
}
|
|
77
98
|
async function deployService() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
99
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
100
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
const ctx = await getServiceContext();
|
|
104
|
+
if (!ctx) process.exit(1);
|
|
105
|
+
const spinner = (0, import_ora.default)("Triggering deployment...").start();
|
|
106
|
+
try {
|
|
107
|
+
const result = await import_api.api.deploy(ctx.projectSlug, ctx.serviceSlug);
|
|
108
|
+
spinner.succeed("Deployment started!");
|
|
109
|
+
console.log(import_chalk.default.dim(`
|
|
110
|
+
Deployment ID: ${result.deploymentId || "N/A"}`));
|
|
111
|
+
console.log(import_chalk.default.dim(" Run `dockup logs` to watch progress\n"));
|
|
112
|
+
} catch (error) {
|
|
113
|
+
spinner.fail(`Failed to deploy: ${error.message}`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
96
116
|
}
|
|
97
117
|
async function serviceLogs(options) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
catch (error) {
|
|
130
|
-
spinner.fail(`Failed to fetch logs: ${error.message}`);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
118
|
+
if (!(0, import_config.isLoggedIn)()) {
|
|
119
|
+
console.log(import_chalk.default.red("Not logged in. Run `dockup login` first."));
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
const ctx = await getServiceContext();
|
|
123
|
+
if (!ctx) process.exit(1);
|
|
124
|
+
const spinner = (0, import_ora.default)("Fetching logs...").start();
|
|
125
|
+
try {
|
|
126
|
+
const lines = parseInt(options.tail || "100", 10);
|
|
127
|
+
const logs = await import_api.api.get(`/projects/${ctx.projectSlug}/services/${ctx.serviceSlug}/logs?lines=${lines}`);
|
|
128
|
+
spinner.stop();
|
|
129
|
+
if (!logs.logs || logs.logs.length === 0) {
|
|
130
|
+
console.log(import_chalk.default.yellow("\n No logs available\n"));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
console.log(import_chalk.default.cyan("\n Service Logs:\n"));
|
|
134
|
+
const logLines = logs.logs.split("\n");
|
|
135
|
+
for (const line of logLines) {
|
|
136
|
+
if (line.toLowerCase().includes("error")) {
|
|
137
|
+
console.log(import_chalk.default.red(` ${line}`));
|
|
138
|
+
} else if (line.toLowerCase().includes("warn")) {
|
|
139
|
+
console.log(import_chalk.default.yellow(` ${line}`));
|
|
140
|
+
} else {
|
|
141
|
+
console.log(import_chalk.default.dim(` ${line}`));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
console.log();
|
|
145
|
+
} catch (error) {
|
|
146
|
+
spinner.fail(`Failed to fetch logs: ${error.message}`);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
133
149
|
}
|
|
150
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
+
0 && (module.exports = {
|
|
152
|
+
deployService,
|
|
153
|
+
restartService,
|
|
154
|
+
serviceLogs,
|
|
155
|
+
startService,
|
|
156
|
+
stopService
|
|
157
|
+
});
|