@kodus/cli 0.0.5 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodus/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "CLI tool for Kodus installation and management",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,7 +20,12 @@
20
20
  "scripts": {
21
21
  "test": "echo \"Error: no test specified\" && exit 1"
22
22
  },
23
- "keywords": ["kodus", "cli", "installation", "deployment"],
23
+ "keywords": [
24
+ "kodus",
25
+ "cli",
26
+ "installation",
27
+ "deployment"
28
+ ],
24
29
  "author": "Kodus",
25
30
  "license": "ISC",
26
31
  "repository": {
@@ -4,6 +4,11 @@ import path from 'path';
4
4
  import { execSync } from 'child_process';
5
5
  import ora from 'ora';
6
6
  import chalk from 'chalk';
7
+ import { fileURLToPath } from 'url';
8
+ import { dirname } from 'path';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
7
12
 
8
13
  export const generateSecretKey = () => crypto.randomBytes(32).toString("base64");
9
14
 
@@ -15,8 +20,32 @@ export const generateDbPassword = () =>
15
20
  .slice(0, 16);
16
21
 
17
22
  export const copyTemplates = (targetDir) => {
18
- const templatesDir = path.join(process.cwd(), 'templates');
19
- fs.copySync(path.join(templatesDir, 'docker-compose.yml'), path.join(targetDir, 'docker-compose.yml'));
23
+ try {
24
+ const moduleDir = dirname(dirname(dirname(__filename))); // Sobe 3 níveis: utils -> src -> root
25
+ const templatesDir = path.join(moduleDir, 'templates');
26
+
27
+ if (!fs.existsSync(templatesDir)) {
28
+ console.error(chalk.red(`Templates directory not found at: ${templatesDir}`));
29
+ console.error(chalk.yellow('Current directory structure:'));
30
+ console.error(chalk.white(fs.readdirSync(moduleDir)));
31
+ throw new Error('Templates directory not found');
32
+ }
33
+
34
+ const sourceFile = path.join(templatesDir, 'docker-compose.yml');
35
+ const targetFile = path.join(targetDir, 'docker-compose.yml');
36
+
37
+ if (!fs.existsSync(sourceFile)) {
38
+ console.error(chalk.red(`Template file not found at: ${sourceFile}`));
39
+ console.error(chalk.yellow('Files in templates directory:'));
40
+ console.error(chalk.white(fs.readdirSync(templatesDir)));
41
+ throw new Error('Template file not found');
42
+ }
43
+
44
+ fs.copySync(sourceFile, targetFile);
45
+ } catch (error) {
46
+ console.error(chalk.red('Error copying templates:'), error);
47
+ throw error;
48
+ }
20
49
  };
21
50
 
22
51
  export const backupEnv = () => {