Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/usr/bin/env node

import { readFileSync } from "node:fs";
import chalk from "chalk";
import { program } from "commander";
import { registerAuthCommand } from "./commands/auth.js";
import { registerGeneratedCommands } from "./generated/commands.js";

const packageJson = JSON.parse(
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
) as { version: string };

const pkg = {
name: "dokploy",
version: "0.3.0",
version: packageJson.version,
description: "Dokploy CLI - Manage your Dokploy server",
};

Expand Down
6 changes: 5 additions & 1 deletion tests/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { execFileSync } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(__dirname, "..");
const CLI = path.join(ROOT, "dist", "index.js");
const packageJson = JSON.parse(
fs.readFileSync(path.join(ROOT, "package.json"), "utf8"),
) as { version: string };

function run(...args: string[]): string {
return execFileSync("node", [CLI, ...args], {
Expand All @@ -25,7 +29,7 @@ describe("CLI", () => {

it("should show version with --version", () => {
const output = run("--version");
expect(output.trim()).toMatch(/^\d+\.\d+\.\d+$/);
expect(output.trim()).toBe(packageJson.version);
});

it("should show subcommands for application", () => {
Expand Down