@dokploy/cli 0.2.7 → 0.3.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.
Files changed (88) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/client.d.ts +10 -0
  3. package/dist/client.js +72 -0
  4. package/dist/commands/auth.d.ts +2 -0
  5. package/dist/commands/auth.js +28 -0
  6. package/dist/generated/commands.d.ts +2 -0
  7. package/dist/generated/commands.js +9059 -0
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +24 -1
  10. package/package.json +25 -58
  11. package/readme.md +101 -83
  12. package/bin/dev.cmd +0 -3
  13. package/bin/dev.js +0 -6
  14. package/bin/run.cmd +0 -3
  15. package/bin/run.js +0 -5
  16. package/dist/commands/app/create.d.ts +0 -17
  17. package/dist/commands/app/create.js +0 -127
  18. package/dist/commands/app/delete.d.ts +0 -11
  19. package/dist/commands/app/delete.js +0 -106
  20. package/dist/commands/app/deploy.d.ts +0 -11
  21. package/dist/commands/app/deploy.js +0 -107
  22. package/dist/commands/app/stop.d.ts +0 -11
  23. package/dist/commands/app/stop.js +0 -102
  24. package/dist/commands/authenticate.d.ts +0 -10
  25. package/dist/commands/authenticate.js +0 -83
  26. package/dist/commands/database/mariadb/create.d.ts +0 -18
  27. package/dist/commands/database/mariadb/create.js +0 -188
  28. package/dist/commands/database/mariadb/delete.d.ts +0 -11
  29. package/dist/commands/database/mariadb/delete.js +0 -104
  30. package/dist/commands/database/mariadb/deploy.d.ts +0 -11
  31. package/dist/commands/database/mariadb/deploy.js +0 -103
  32. package/dist/commands/database/mariadb/stop.d.ts +0 -11
  33. package/dist/commands/database/mariadb/stop.js +0 -103
  34. package/dist/commands/database/mongo/create.d.ts +0 -17
  35. package/dist/commands/database/mongo/create.js +0 -176
  36. package/dist/commands/database/mongo/delete.d.ts +0 -11
  37. package/dist/commands/database/mongo/delete.js +0 -106
  38. package/dist/commands/database/mongo/deploy.d.ts +0 -11
  39. package/dist/commands/database/mongo/deploy.js +0 -103
  40. package/dist/commands/database/mongo/stop.d.ts +0 -11
  41. package/dist/commands/database/mongo/stop.js +0 -103
  42. package/dist/commands/database/mysql/create.d.ts +0 -18
  43. package/dist/commands/database/mysql/create.js +0 -188
  44. package/dist/commands/database/mysql/delete.d.ts +0 -11
  45. package/dist/commands/database/mysql/delete.js +0 -106
  46. package/dist/commands/database/mysql/deploy.d.ts +0 -6
  47. package/dist/commands/database/mysql/deploy.js +0 -86
  48. package/dist/commands/database/mysql/stop.d.ts +0 -6
  49. package/dist/commands/database/mysql/stop.js +0 -86
  50. package/dist/commands/database/postgres/create.d.ts +0 -17
  51. package/dist/commands/database/postgres/create.js +0 -176
  52. package/dist/commands/database/postgres/delete.d.ts +0 -11
  53. package/dist/commands/database/postgres/delete.js +0 -106
  54. package/dist/commands/database/postgres/deploy.d.ts +0 -11
  55. package/dist/commands/database/postgres/deploy.js +0 -103
  56. package/dist/commands/database/postgres/stop.d.ts +0 -11
  57. package/dist/commands/database/postgres/stop.js +0 -103
  58. package/dist/commands/database/redis/create.d.ts +0 -15
  59. package/dist/commands/database/redis/create.js +0 -151
  60. package/dist/commands/database/redis/delete.d.ts +0 -11
  61. package/dist/commands/database/redis/delete.js +0 -106
  62. package/dist/commands/database/redis/deploy.d.ts +0 -11
  63. package/dist/commands/database/redis/deploy.js +0 -103
  64. package/dist/commands/database/redis/stop.d.ts +0 -11
  65. package/dist/commands/database/redis/stop.js +0 -103
  66. package/dist/commands/env/pull.d.ts +0 -10
  67. package/dist/commands/env/pull.js +0 -68
  68. package/dist/commands/env/push.d.ts +0 -10
  69. package/dist/commands/env/push.js +0 -106
  70. package/dist/commands/project/create.d.ts +0 -11
  71. package/dist/commands/project/create.js +0 -89
  72. package/dist/commands/project/info.d.ts +0 -10
  73. package/dist/commands/project/info.js +0 -122
  74. package/dist/commands/project/list.d.ts +0 -6
  75. package/dist/commands/project/list.js +0 -43
  76. package/dist/commands/verify.d.ts +0 -6
  77. package/dist/commands/verify.js +0 -62
  78. package/dist/utils/http.d.ts +0 -4
  79. package/dist/utils/http.js +0 -4
  80. package/dist/utils/shared.d.ts +0 -10
  81. package/dist/utils/shared.js +0 -55
  82. package/dist/utils/slug.d.ts +0 -1
  83. package/dist/utils/slug.js +0 -12
  84. package/dist/utils/slugify.d.ts +0 -3
  85. package/dist/utils/slugify.js +0 -2
  86. package/dist/utils/utils.d.ts +0 -6
  87. package/dist/utils/utils.js +0 -26
  88. package/oclif.manifest.json +0 -1680
@@ -1,106 +0,0 @@
1
- import { Args, Command } from '@oclif/core';
2
- import fs from "fs";
3
- import chalk from "chalk";
4
- import inquirer from "inquirer";
5
- import { readAuthConfig } from "../../utils/utils.js";
6
- import { getProject, getProjects } from "../../utils/shared.js";
7
- import axios from "axios";
8
- export default class EnvPush extends Command {
9
- static args = {
10
- file: Args.string({ description: '.env file to push', required: true }),
11
- };
12
- static description = 'Push dotenv file to remote service';
13
- static examples = [
14
- '<%= config.bin %> <%= command.id %> .env.stage.local',
15
- ];
16
- static flags = {};
17
- async run() {
18
- const { args, flags } = await this.parse(EnvPush);
19
- if (!fs.existsSync(args.file)) {
20
- console.log(chalk.red.bold(`\n File ${args.file} doesn't exists \n`));
21
- return;
22
- }
23
- const { override } = await inquirer.prompt([
24
- {
25
- message: `This command will override entire remote environment variables. Do you want to continue?`,
26
- name: "override",
27
- default: false,
28
- type: "confirm",
29
- },
30
- ]);
31
- if (!override) {
32
- return;
33
- }
34
- const fileContent = fs.readFileSync(args.file, 'utf-8');
35
- const auth = await readAuthConfig(this);
36
- console.log(chalk.blue.bold("\n Listing all Projects \n"));
37
- const projects = await getProjects(auth, this);
38
- const { project } = await inquirer.prompt([
39
- {
40
- choices: projects.map((project) => ({
41
- name: project.name,
42
- value: project,
43
- })),
44
- message: "Select the project:",
45
- name: "project",
46
- type: "list",
47
- },
48
- ]);
49
- const projectId = project.projectId;
50
- const projectSelected = await getProject(projectId, auth, this);
51
- const choices = [
52
- ...projectSelected.applications.map((app) => ({
53
- name: `${app.name} (Application)`,
54
- value: { serviceType: 'app', service: app },
55
- })),
56
- ...projectSelected.compose.map((compose) => ({
57
- name: `${compose.name} (Compose)`,
58
- value: { serviceType: 'compose', service: compose }
59
- })),
60
- ];
61
- const { result: { serviceType, service } } = await inquirer.prompt([
62
- {
63
- choices,
64
- message: "Select a service to pull the environment variables:",
65
- name: "result",
66
- type: "list",
67
- },
68
- ]);
69
- if (serviceType === 'app') {
70
- const { applicationId } = service;
71
- const response = await axios.post(`${auth.url}/api/trpc/application.update`, {
72
- json: {
73
- applicationId,
74
- env: fileContent
75
- }
76
- }, {
77
- headers: {
78
- "x-api-key": auth.token,
79
- "Content-Type": "application/json",
80
- },
81
- });
82
- if (response.status !== 200) {
83
- this.error(chalk.red("Error stopping application"));
84
- }
85
- this.log(chalk.green("Environment variable push successful."));
86
- }
87
- if (serviceType === 'compose') {
88
- const { composeId } = service;
89
- const response = await axios.post(`${auth.url}/api/trpc/compose.update`, {
90
- json: {
91
- composeId,
92
- env: fileContent
93
- }
94
- }, {
95
- headers: {
96
- "x-api-key": auth.token,
97
- "Content-Type": "application/json",
98
- },
99
- });
100
- if (response.status !== 200) {
101
- this.error(chalk.red("Error stopping application"));
102
- }
103
- this.log(chalk.green("Environment variable push successful."));
104
- }
105
- }
106
- }
@@ -1,11 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class ProjectCreate extends Command {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
- description: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
- };
10
- run(): Promise<void>;
11
- }
@@ -1,89 +0,0 @@
1
- import { Command, Flags } from "@oclif/core";
2
- import axios from "axios";
3
- import chalk from "chalk";
4
- import inquirer from "inquirer";
5
- import { readAuthConfig } from "../../utils/utils.js";
6
- export default class ProjectCreate extends Command {
7
- static description = "Create a new project.";
8
- static examples = [
9
- "$ <%= config.bin %> project create",
10
- "$ <%= config.bin %> project create -n MyProject -d 'Project description'",
11
- "$ <%= config.bin %> project create --name MyProject --skipConfirm",
12
- ];
13
- static flags = {
14
- name: Flags.string({
15
- char: "n",
16
- description: "Name of the project",
17
- required: false,
18
- }),
19
- description: Flags.string({
20
- char: "d",
21
- description: "Description of the project",
22
- required: false,
23
- }),
24
- skipConfirm: Flags.boolean({
25
- char: "y",
26
- description: "Skip confirmation prompt",
27
- default: false,
28
- }),
29
- };
30
- async run() {
31
- const auth = await readAuthConfig(this);
32
- const { flags } = await this.parse(ProjectCreate);
33
- let { name, description } = flags;
34
- // Modo interactivo si no se proporcionan los flags necesarios
35
- if (!name) {
36
- const answers = await inquirer.prompt([
37
- {
38
- message: "Enter the project name:",
39
- name: "name",
40
- type: "input",
41
- validate: (input) => (input ? true : "Project name is required"),
42
- },
43
- {
44
- message: "Enter the project description (optional):",
45
- name: "description",
46
- type: "input",
47
- default: description || "",
48
- },
49
- ]);
50
- name = answers.name;
51
- description = answers.description;
52
- }
53
- // Confirmar si no se especifica --skipConfirm
54
- if (!flags.skipConfirm) {
55
- const confirm = await inquirer.prompt([
56
- {
57
- type: 'confirm',
58
- name: 'proceed',
59
- message: 'Do you want to create this project?',
60
- default: false,
61
- },
62
- ]);
63
- if (!confirm.proceed) {
64
- this.error(chalk.yellow("Project creation cancelled."));
65
- return;
66
- }
67
- }
68
- try {
69
- const response = await axios.post(`${auth.url}/api/trpc/project.create`, {
70
- json: {
71
- name,
72
- description,
73
- },
74
- }, {
75
- headers: {
76
- "x-api-key": auth.token,
77
- "Content-Type": "application/json",
78
- },
79
- });
80
- if (!response.data.result.data.json) {
81
- this.error(chalk.red("Error creating project", response.data.result.data.json));
82
- }
83
- this.log(chalk.green(`Project '${name}' created successfully.`));
84
- }
85
- catch (error) {
86
- this.error(chalk.red(`Error creating project: ${error.message}`));
87
- }
88
- }
89
- }
@@ -1,10 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class ProjectInfo extends Command {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
- };
8
- run(): Promise<void>;
9
- private showProjectInfo;
10
- }
@@ -1,122 +0,0 @@
1
- import { Command, Flags } from "@oclif/core";
2
- import chalk from "chalk";
3
- import inquirer from "inquirer";
4
- import { readAuthConfig } from "../../utils/utils.js";
5
- import { getProject, getProjects } from "../../utils/shared.js";
6
- export default class ProjectInfo extends Command {
7
- static description = "Get detailed information about a project, including the number of applications and databases.";
8
- static examples = [
9
- "$ <%= config.bin %> project info",
10
- "$ <%= config.bin %> project info -p <projectId>",
11
- ];
12
- static flags = {
13
- projectId: Flags.string({
14
- char: "p",
15
- description: "ID of the project",
16
- required: false,
17
- }),
18
- };
19
- async run() {
20
- const auth = await readAuthConfig(this);
21
- const { flags } = await this.parse(ProjectInfo);
22
- if (flags.projectId) {
23
- await this.showProjectInfo(auth, flags.projectId);
24
- }
25
- else {
26
- console.log(chalk.blue.bold("\n Listing all Projects \n"));
27
- try {
28
- const projects = await getProjects(auth, this);
29
- if (projects.length === 0) {
30
- this.log(chalk.yellow("No projects found."));
31
- return;
32
- }
33
- const answers = await inquirer.prompt([
34
- {
35
- choices: projects.map((project) => ({
36
- name: project.name,
37
- value: project.projectId,
38
- })),
39
- message: "Select a project to view details:",
40
- name: "selectedProject",
41
- type: "list",
42
- },
43
- ]);
44
- const selectedProjectId = answers.selectedProject;
45
- await this.showProjectInfo(auth, selectedProjectId);
46
- }
47
- catch (error) {
48
- // @ts-expect-error hola
49
- this.error(chalk.red(`Failed to fetch project list: ${error.message}`));
50
- }
51
- }
52
- }
53
- async showProjectInfo(auth, projectId) {
54
- console.log(chalk.blue.bold(`\n Information for Project ID: ${projectId} \n`));
55
- try {
56
- const projectInfo = await getProject(projectId, auth, this);
57
- this.log(chalk.green(`Project Name: ${projectInfo.name}`));
58
- this.log(chalk.green(`Description: ${projectInfo?.description || "No description"}`));
59
- this.log(chalk.green(`Number of Applications: ${projectInfo.applications.length}`));
60
- this.log(chalk.green(`Number of Compose Services: ${projectInfo.compose.length}`));
61
- this.log(chalk.green(`Number of MariaDB Databases: ${projectInfo.mariadb.length}`));
62
- this.log(chalk.green(`Number of MongoDB Databases: ${projectInfo.mongo.length}`));
63
- this.log(chalk.green(`Number of MySQL Databases: ${projectInfo.mysql.length}`));
64
- this.log(chalk.green(`Number of PostgreSQL Databases: ${projectInfo.postgres.length}`));
65
- this.log(chalk.green(`Number of Redis Databases: ${projectInfo.redis.length}`));
66
- if (projectInfo.applications.length > 0) {
67
- this.log(chalk.blue("\nApplications:"));
68
- // @ts-ignore
69
- projectInfo.applications.forEach((app, index) => {
70
- this.log(` ${index + 1}. ${app.name}`);
71
- });
72
- }
73
- if (projectInfo.compose.length > 0) {
74
- this.log(chalk.blue("\nCompose Services:"));
75
- // @ts-ignore
76
- projectInfo.compose.forEach((service, index) => {
77
- this.log(` ${index + 1}. ${service.name}`);
78
- });
79
- }
80
- if (projectInfo.mariadb.length > 0) {
81
- this.log(chalk.blue("\nMariaDB Databases:"));
82
- // @ts-ignore
83
- projectInfo.mariadb.forEach((db, index) => {
84
- this.log(` ${index + 1}. ${db.name}`);
85
- });
86
- }
87
- if (projectInfo.mongo.length > 0) {
88
- this.log(chalk.blue("\nMongoDB Databases:"));
89
- // @ts-ignore
90
- projectInfo.mongo.forEach((db, index) => {
91
- this.log(` ${index + 1}. ${db.name}`);
92
- });
93
- }
94
- if (projectInfo.mysql.length > 0) {
95
- this.log(chalk.blue("\nMySQL Databases:"));
96
- // @ts-ignore
97
- projectInfo.mysql.forEach((db, index) => {
98
- this.log(` ${index + 1}. ${db.name}`);
99
- });
100
- }
101
- if (projectInfo.postgres.length > 0) {
102
- this.log(chalk.blue("\nPostgreSQL Databases:"));
103
- // @ts-ignore
104
- projectInfo.postgres.forEach((db, index) => {
105
- this.log(` ${index + 1}. ${db.name}`);
106
- });
107
- }
108
- if (projectInfo.redis.length > 0) {
109
- this.log(chalk.blue("\nRedis Databases:"));
110
- // @ts-ignore
111
- projectInfo.redis.forEach((db, index) => {
112
- this.log(` ${index + 1}. ${db.name}`);
113
- });
114
- }
115
- }
116
- catch (error) {
117
- this.error(
118
- // @ts-expect-error
119
- chalk.red(`Failed to fetch project information: ${error.message}`));
120
- }
121
- }
122
- }
@@ -1,6 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class ProjectList extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,43 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import chalk from "chalk";
3
- import Table from "cli-table3";
4
- import { readAuthConfig } from "../../utils/utils.js";
5
- import { getProjects } from "../../utils/shared.js";
6
- export default class ProjectList extends Command {
7
- static description = "List all projects.";
8
- static examples = ["$ <%= config.bin %> project list"];
9
- async run() {
10
- const auth = await readAuthConfig(this);
11
- console.log(chalk.blue.bold("\n Listing all Projects \n"));
12
- try {
13
- const projects = await getProjects(auth, this);
14
- if (projects.length === 0) {
15
- this.log(chalk.yellow("No projects found."));
16
- }
17
- else {
18
- this.log(chalk.green("Projects:"));
19
- const table = new Table({
20
- colWidths: [10, 30, 50],
21
- head: [
22
- chalk.cyan("Index"),
23
- chalk.cyan("Name"),
24
- chalk.cyan("Description"),
25
- ],
26
- });
27
- const index = 1;
28
- for (const project of projects) {
29
- table.push([
30
- chalk.white(index + 1),
31
- chalk.white(project.name),
32
- chalk.gray(project.description || "No description"),
33
- ]);
34
- }
35
- this.log(table.toString());
36
- }
37
- }
38
- catch (error) {
39
- // @ts-expect-error error is not defined
40
- this.error(chalk.red(`Failed to list projects: ${error?.message}`));
41
- }
42
- }
43
- }
@@ -1,6 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class Verify extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,62 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import axios from "axios";
3
- import chalk from "chalk";
4
- import * as fs from "node:fs";
5
- import * as path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
- const configPath = path.join(__dirname, "..", "..", "config.json");
10
- export default class Verify extends Command {
11
- static description = "Verify if the saved authentication token is valid";
12
- static examples = ["$ <%= config.bin %> <%= command.id %>"];
13
- async run() {
14
- console.log(chalk.blue.bold("\nVerifying Authentication Token"));
15
- let token;
16
- let url;
17
- // Verificar variables de entorno primero
18
- const envToken = process.env.DOKPLOY_AUTH_TOKEN;
19
- const envUrl = process.env.DOKPLOY_URL;
20
- if (envToken && envUrl) {
21
- token = envToken;
22
- url = envUrl;
23
- this.log(chalk.green("Using environment variables for authentication"));
24
- }
25
- else {
26
- // Si no hay variables de entorno, verificar archivo de configuración
27
- if (!fs.existsSync(configPath)) {
28
- this.error(chalk.red("No configuration found. Please either:\n" +
29
- "1. Authenticate using `authenticate` command\n" +
30
- "2. Set DOKPLOY_URL and DOKPLOY_AUTH_TOKEN environment variables"));
31
- }
32
- try {
33
- const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
34
- token = config.token;
35
- url = config.url;
36
- this.log(chalk.green("Using configuration file for authentication"));
37
- }
38
- catch (error) {
39
- this.error(chalk.red("Invalid configuration file. Please authenticate again using `authenticate` command."));
40
- }
41
- }
42
- // Validar el token contra el servidor
43
- try {
44
- console.log(chalk.blue("Validating token with server..."));
45
- const response = await axios.get(`${url}/api/trpc/user.get`, {
46
- headers: {
47
- "x-api-key": token,
48
- "Content-Type": "application/json",
49
- },
50
- });
51
- if (response.data.result.data.json) {
52
- this.log(chalk.green("\n✓ Token is valid"));
53
- }
54
- else {
55
- this.error(chalk.red("Invalid token. Please authenticate again using `authenticate` command."));
56
- }
57
- }
58
- catch (error) {
59
- this.error(chalk.red(`Failed to verify token: ${error.message}. Please authenticate again using 'authenticate' command.`));
60
- }
61
- }
62
- }
@@ -1,4 +0,0 @@
1
- export declare const headers: {
2
- "Content-Type": string;
3
- "User-Agent": string;
4
- };
@@ -1,4 +0,0 @@
1
- export const headers = {
2
- "Content-Type": "application/json",
3
- "User-Agent": "Dokploy CLI",
4
- };
@@ -1,10 +0,0 @@
1
- import type { Command } from "@oclif/core";
2
- import type { AuthConfig } from "./utils.js";
3
- export type Project = {
4
- adminId: string;
5
- name: string;
6
- projectId?: string | undefined;
7
- description?: string | undefined;
8
- };
9
- export declare const getProjects: (auth: AuthConfig, command: Command) => Promise<Project[]>;
10
- export declare const getProject: (projectId: string | undefined, auth: AuthConfig, command: Command) => Promise<any>;
@@ -1,55 +0,0 @@
1
- import axios from "axios";
2
- import chalk from "chalk";
3
- export const getProjects = async (auth, command) => {
4
- try {
5
- const response = await axios.get(`${auth.url}/api/trpc/project.all`, {
6
- headers: {
7
- "x-api-key": auth.token,
8
- "Content-Type": "application/json",
9
- },
10
- });
11
- if (!response.data.result.data.json) {
12
- command.error(chalk.red("Error fetching projects"));
13
- }
14
- const projects = response.data.result.data.json;
15
- if (projects.length === 0) {
16
- command.log(chalk.yellow("No projects found."));
17
- return [];
18
- }
19
- return projects;
20
- }
21
- catch (error) {
22
- // @ts-expect-error TODO: Fix this
23
- command.error(chalk.red(`Failed to fetch project list: ${error.message}`));
24
- }
25
- };
26
- export const getProject = async (projectId, auth, command) => {
27
- try {
28
- if (!projectId) {
29
- command.error(chalk.red("Project ID is required"));
30
- }
31
- const response = await axios.get(`${auth.url}/api/trpc/project.one`, {
32
- headers: {
33
- "x-api-key": auth.token,
34
- "Content-Type": "application/json",
35
- },
36
- params: {
37
- input: JSON.stringify({
38
- json: { projectId },
39
- }),
40
- },
41
- });
42
- if (!response.data.result.data.json) {
43
- command.error(chalk.red("Error fetching project"));
44
- }
45
- const project = response.data.result.data.json;
46
- if (!project) {
47
- command.error(chalk.red("Error fetching project"));
48
- }
49
- return project;
50
- }
51
- catch (error) {
52
- // @ts-expect-error TODO: Fix this
53
- command.error(chalk.red(`Failed to fetch project: ${error.message}`));
54
- }
55
- };
@@ -1 +0,0 @@
1
- export declare const slugify: (text: string | undefined) => string;
@@ -1,12 +0,0 @@
1
- import slug from "./slugify.js";
2
- export const slugify = (text) => {
3
- if (!text) {
4
- return "";
5
- }
6
- const cleanedText = text.trim().replaceAll(/[^\d\sA-Za-z]/g, "");
7
- return slug(cleanedText, {
8
- lower: true,
9
- strict: true,
10
- trim: true,
11
- });
12
- };
@@ -1,3 +0,0 @@
1
- import slugify from "slugify";
2
- declare const _default: typeof slugify.default;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- import slugify from "slugify";
2
- export default slugify;
@@ -1,6 +0,0 @@
1
- import type { Command } from "@oclif/core";
2
- export type AuthConfig = {
3
- token: string;
4
- url: string;
5
- };
6
- export declare const readAuthConfig: (command: Command) => Promise<AuthConfig>;
@@ -1,26 +0,0 @@
1
- import chalk from "chalk";
2
- import * as fs from "node:fs";
3
- import * as path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- const configPath = path.join(__dirname, "..", "..", "config.json");
8
- export const readAuthConfig = async (command) => {
9
- // Primero intentar leer desde variables de entorno
10
- const envToken = process.env.DOKPLOY_AUTH_TOKEN;
11
- const envUrl = process.env.DOKPLOY_URL;
12
- if (envToken && envUrl) {
13
- return { token: envToken, url: envUrl };
14
- }
15
- // Si no hay variables de entorno, usar el archivo de configuración
16
- if (!fs.existsSync(configPath)) {
17
- command.error(chalk.red("No configuration file found and no environment variables set. Please authenticate first using the 'authenticate' command or set DOKPLOY_URL and DOKPLOY_AUTH_TOKEN environment variables."));
18
- }
19
- const configFileContent = fs.readFileSync(configPath, "utf8");
20
- const config = JSON.parse(configFileContent);
21
- const { token, url } = config;
22
- if (!url || !token) {
23
- command.error(chalk.red("Incomplete authentication details. Please authenticate again using the 'authenticate' command or set environment variables."));
24
- }
25
- return { token, url };
26
- };