@orxataguy/tyr 1.5.0 → 1.6.2

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.
@@ -1,61 +1,61 @@
1
- import { TyrContext } from '../core/Kernel';
2
- import path from 'path';
3
- import { homedir } from 'os';
4
-
5
- export default ({ task, fail, logger, fs }: TyrContext) => {
6
- return async (_args: string[]) => {
7
- const homeDir = homedir();
8
- const userRoot = path.join(homeDir, '.tyr');
9
-
10
- const aliasesTemplatePath = path.join(homeDir, 'avantio', 'framework', 'core', 'include', 'bin', 'aliases.template.sh');
11
- const pluginsTemplatePath = path.join(homeDir, 'avantio', 'framework', 'core', 'include', 'bin', 'plugins.template.sh');
12
-
13
- const aliasesTarget = path.join(userRoot, 'aliases');
14
- const pluginsTarget = path.join(userRoot, 'plugins');
15
-
16
- await task('Verificando configuración de Tyr', async () => {
17
- if (!fs.exists(userRoot)) {
18
- fail(
19
- 'El directorio ~/.tyr no existe.',
20
- "Ejecuta 'tyr --config' antes de continuar."
21
- );
22
- }
23
- logger.success(`Directorio ~/.tyr encontrado: ${userRoot}`);
24
- });
25
-
26
- await task('Verificando templates de Avantio', async () => {
27
- if (!fs.exists(aliasesTemplatePath)) {
28
- fail(
29
- `Template de aliases no encontrado: ${aliasesTemplatePath}`,
30
- 'Verifica que el framework de Avantio esté correctamente instalado.'
31
- );
32
- }
33
- if (!fs.exists(pluginsTemplatePath)) {
34
- fail(
35
- `Template de plugins no encontrado: ${pluginsTemplatePath}`,
36
- 'Verifica que el framework de Avantio esté correctamente instalado.'
37
- );
38
- }
39
- logger.success('Templates de Avantio encontrados.');
40
- });
41
-
42
- await task('Copiando aliases de Avantio', async () => {
43
- const content = await fs.read(aliasesTemplatePath);
44
- if (!content) fail('No se pudo leer aliases.template.sh');
45
- await fs.write(aliasesTarget, content!);
46
- logger.success(`Aliases copiados a: ${aliasesTarget}`);
47
- });
48
-
49
- await task('Copiando plugins de Avantio', async () => {
50
- const content = await fs.read(pluginsTemplatePath);
51
- if (!content) fail('No se pudo leer plugins.template.sh');
52
- await fs.write(pluginsTarget, content!);
53
- logger.success(`Plugins copiados a: ${pluginsTarget}`);
54
- });
55
-
56
- logger.success('\nInstalación de Avantio completada.');
57
- logger.info(` aliases → ${aliasesTarget}`);
58
- logger.info(` plugins → ${pluginsTarget}`);
59
- logger.warn('\nRecuerda recargar tu shell para aplicar los cambios.');
60
- };
61
- };
1
+ import { TyrContext } from '../core/Kernel';
2
+ import path from 'path';
3
+ import { homedir } from 'os';
4
+
5
+ export default ({ task, fail, logger, fs }: TyrContext) => {
6
+ return async (_args: string[]) => {
7
+ const homeDir = homedir();
8
+ const userRoot = path.join(homeDir, '.tyr');
9
+
10
+ const aliasesTemplatePath = path.join(homeDir, 'avantio', 'framework', 'core', 'include', 'bin', 'aliases.template.sh');
11
+ const pluginsTemplatePath = path.join(homeDir, 'avantio', 'framework', 'core', 'include', 'bin', 'plugins.template.sh');
12
+
13
+ const aliasesTarget = path.join(userRoot, 'aliases');
14
+ const pluginsTarget = path.join(userRoot, 'plugins');
15
+
16
+ await task('Verificando configuración de Tyr', async () => {
17
+ if (!fs.exists(userRoot)) {
18
+ fail(
19
+ 'El directorio ~/.tyr no existe.',
20
+ "Ejecuta 'tyr --config' antes de continuar."
21
+ );
22
+ }
23
+ logger.success(`Directorio ~/.tyr encontrado: ${userRoot}`);
24
+ });
25
+
26
+ await task('Verificando templates de Avantio', async () => {
27
+ if (!fs.exists(aliasesTemplatePath)) {
28
+ fail(
29
+ `Template de aliases no encontrado: ${aliasesTemplatePath}`,
30
+ 'Verifica que el framework de Avantio esté correctamente instalado.'
31
+ );
32
+ }
33
+ if (!fs.exists(pluginsTemplatePath)) {
34
+ fail(
35
+ `Template de plugins no encontrado: ${pluginsTemplatePath}`,
36
+ 'Verifica que el framework de Avantio esté correctamente instalado.'
37
+ );
38
+ }
39
+ logger.success('Templates de Avantio encontrados.');
40
+ });
41
+
42
+ await task('Copiando aliases de Avantio', async () => {
43
+ const content = await fs.read(aliasesTemplatePath);
44
+ if (!content) fail('No se pudo leer aliases.template.sh');
45
+ await fs.write(aliasesTarget, content!);
46
+ logger.success(`Aliases copiados a: ${aliasesTarget}`);
47
+ });
48
+
49
+ await task('Copiando plugins de Avantio', async () => {
50
+ const content = await fs.read(pluginsTemplatePath);
51
+ if (!content) fail('No se pudo leer plugins.template.sh');
52
+ await fs.write(pluginsTarget, content!);
53
+ logger.success(`Plugins copiados a: ${pluginsTarget}`);
54
+ });
55
+
56
+ logger.success('\nInstalación de Avantio completada.');
57
+ logger.info(` aliases → ${aliasesTarget}`);
58
+ logger.info(` plugins → ${pluginsTarget}`);
59
+ logger.warn('\nRecuerda recargar tu shell para aplicar los cambios.');
60
+ };
61
+ };
@@ -1,56 +1,56 @@
1
- import { ShellManager } from '../lib/ShellManager.js';
2
- import { FileSystemManager } from '../lib/FileSystemManager.js';
3
- import { PackageManager } from '../lib/PackageManager.js';
4
- import { DockerManager } from '../lib/DockerManager.js';
5
- import { GitManager } from '../lib/GitManager.js';
6
- import { SystemManager } from '../lib/SystemManager.js';
7
- import { SQLManager } from '../lib/SQLManager.js';
8
- import { WebManager } from '../lib/WebManager.js';
9
- import { Logger, createLogger } from './Logger.js';
10
-
11
- export type { Logger };
12
-
13
- export interface ServiceContainer {
14
- logger: Logger;
15
- shell: ShellManager;
16
- fs: FileSystemManager;
17
- pkg: PackageManager;
18
- docker: DockerManager;
19
- git: GitManager;
20
- sys: SystemManager;
21
- db: SQLManager;
22
- web: WebManager;
23
- }
24
-
25
- export class Container {
26
- private services: Partial<ServiceContainer>;
27
-
28
- constructor() {
29
- this.services = {};
30
- }
31
-
32
- public init(isDebug: boolean): void {
33
- const logger = createLogger(isDebug);
34
- const shell = new ShellManager();
35
- const db = new SQLManager();
36
-
37
- this.services = {
38
- logger,
39
- shell,
40
- db,
41
- web: new WebManager(logger),
42
- fs: new FileSystemManager(logger),
43
- pkg: new PackageManager(shell, logger),
44
- docker: new DockerManager(shell, logger),
45
- git: new GitManager(shell, logger),
46
- sys: new SystemManager(shell, logger),
47
- };
48
- }
49
-
50
- public get(): ServiceContainer {
51
- if (!this.services.logger) {
52
- throw new Error('Container not initialised. Call .init() first.');
53
- }
54
- return this.services as ServiceContainer;
55
- }
56
- }
1
+ import { ShellManager } from '../lib/ShellManager.js';
2
+ import { FileSystemManager } from '../lib/FileSystemManager.js';
3
+ import { PackageManager } from '../lib/PackageManager.js';
4
+ import { DockerManager } from '../lib/DockerManager.js';
5
+ import { GitManager } from '../lib/GitManager.js';
6
+ import { SystemManager } from '../lib/SystemManager.js';
7
+ import { SQLManager } from '../lib/SQLManager.js';
8
+ import { WebManager } from '../lib/WebManager.js';
9
+ import { Logger, createLogger } from './Logger.js';
10
+
11
+ export type { Logger };
12
+
13
+ export interface ServiceContainer {
14
+ logger: Logger;
15
+ shell: ShellManager;
16
+ fs: FileSystemManager;
17
+ pkg: PackageManager;
18
+ docker: DockerManager;
19
+ git: GitManager;
20
+ sys: SystemManager;
21
+ db: SQLManager;
22
+ web: WebManager;
23
+ }
24
+
25
+ export class Container {
26
+ private services: Partial<ServiceContainer>;
27
+
28
+ constructor() {
29
+ this.services = {};
30
+ }
31
+
32
+ public init(isDebug: boolean): void {
33
+ const logger = createLogger(isDebug);
34
+ const shell = new ShellManager();
35
+ const db = new SQLManager();
36
+
37
+ this.services = {
38
+ logger,
39
+ shell,
40
+ db,
41
+ web: new WebManager(logger),
42
+ fs: new FileSystemManager(logger),
43
+ pkg: new PackageManager(shell, logger),
44
+ docker: new DockerManager(shell, logger),
45
+ git: new GitManager(shell, logger),
46
+ sys: new SystemManager(shell, logger),
47
+ };
48
+ }
49
+
50
+ public get(): ServiceContainer {
51
+ if (!this.services.logger) {
52
+ throw new Error('Container not initialised. Call .init() first.');
53
+ }
54
+ return this.services as ServiceContainer;
55
+ }
56
+ }
@@ -134,7 +134,7 @@ export class Kernel {
134
134
 
135
135
  // --config (needs context for fs/logger)
136
136
  if (commandName === '--config') {
137
- await config(context)([]);
137
+ await config(context)(args.slice(1));
138
138
  return;
139
139
  }
140
140
 
@@ -1,48 +1,48 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { homedir } from 'os';
5
-
6
- export interface Logger {
7
- log(msg: any): void;
8
- info(msg: any): void;
9
- success(msg: any): void;
10
- error(msg: any): void;
11
- warn(msg: any): void;
12
- }
13
-
14
- export function createLogger(isDebug: boolean): Logger {
15
- const logDir = path.join(homedir(), '.tyr', 'logs');
16
- const logFile = path.join(logDir, `${new Date().toISOString().slice(0, 10)}.log`);
17
-
18
- fs.mkdirSync(logDir, { recursive: true });
19
-
20
- const writeToFile = (level: string, msg: any) => {
21
- const timestamp = new Date().toISOString();
22
- const line = `[${timestamp}] [${level}] ${String(msg)}\n`;
23
- fs.appendFileSync(logFile, line, 'utf-8');
24
- };
25
-
26
- return {
27
- log: (msg) => {
28
- console.log(msg);
29
- writeToFile('LOG', msg);
30
- },
31
- info: (msg) => {
32
- console.log(chalk.blue('ℹ'), msg);
33
- writeToFile('INFO', msg);
34
- },
35
- success: (msg) => {
36
- console.log(chalk.green('✔'), msg);
37
- writeToFile('SUCCESS', msg);
38
- },
39
- error: (msg) => {
40
- if (isDebug) console.error(chalk.red('✖'), msg);
41
- writeToFile('ERROR', msg);
42
- },
43
- warn: (msg) => {
44
- if (isDebug) console.warn(chalk.yellow('⚠'), msg);
45
- writeToFile('WARN', msg);
46
- },
47
- };
48
- }
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { homedir } from 'os';
5
+
6
+ export interface Logger {
7
+ log(msg: any): void;
8
+ info(msg: any): void;
9
+ success(msg: any): void;
10
+ error(msg: any): void;
11
+ warn(msg: any): void;
12
+ }
13
+
14
+ export function createLogger(isDebug: boolean): Logger {
15
+ const logDir = path.join(homedir(), '.tyr', 'logs');
16
+ const logFile = path.join(logDir, `${new Date().toISOString().slice(0, 10)}.log`);
17
+
18
+ fs.mkdirSync(logDir, { recursive: true });
19
+
20
+ const writeToFile = (level: string, msg: any) => {
21
+ const timestamp = new Date().toISOString();
22
+ const line = `[${timestamp}] [${level}] ${String(msg)}\n`;
23
+ fs.appendFileSync(logFile, line, 'utf-8');
24
+ };
25
+
26
+ return {
27
+ log: (msg) => {
28
+ console.log(msg);
29
+ writeToFile('LOG', msg);
30
+ },
31
+ info: (msg) => {
32
+ console.log(chalk.blue('ℹ'), msg);
33
+ writeToFile('INFO', msg);
34
+ },
35
+ success: (msg) => {
36
+ console.log(chalk.green('✔'), msg);
37
+ writeToFile('SUCCESS', msg);
38
+ },
39
+ error: (msg) => {
40
+ if (isDebug) console.error(chalk.red('✖'), msg);
41
+ writeToFile('ERROR', msg);
42
+ },
43
+ warn: (msg) => {
44
+ if (isDebug) console.warn(chalk.yellow('⚠'), msg);
45
+ writeToFile('WARN', msg);
46
+ },
47
+ };
48
+ }
@@ -1,57 +1,57 @@
1
- import { Logger, createLogger } from './Logger.js';
2
-
3
- export class TyrError extends Error {
4
- public readonly originalError: unknown;
5
- public readonly isTyrError = true;
6
- public readonly suggestion?: string;
7
- public readonly commandName?: string;
8
-
9
- constructor(message: string, originalError?: unknown, suggestion?: string, commandName?: string) {
10
- super(message);
11
- this.originalError = originalError;
12
- this.suggestion = suggestion;
13
- this.commandName = commandName;
14
- Error.captureStackTrace(this, this.constructor);
15
- }
16
-
17
- private extractErrorMessage(err: unknown): string {
18
- if (err instanceof Error) return err.message;
19
- if (typeof err === 'string') return err;
20
- try {
21
- return JSON.stringify(err);
22
- } catch {
23
- return 'Unknown error (non-serializable)';
24
- }
25
- }
26
-
27
- public handle(isDebug: boolean = false, _logger?: Logger): void {
28
- const logger = _logger ?? createLogger(isDebug);
29
-
30
- if (this.commandName) {
31
- logger.error(`Error in command: ${this.commandName}`);
32
- }
33
-
34
- logger.error('Oops! An error occurred.');
35
- logger.error(`↳ ${this.message}`);
36
-
37
- if (this.originalError) {
38
- logger.error(` ↳ Caused by: ${this.extractErrorMessage(this.originalError)}`);
39
- }
40
-
41
- if (this.suggestion) {
42
- logger.warn(` Suggestion: ${this.suggestion}`);
43
- }
44
-
45
- if (isDebug) {
46
- if (this.originalError instanceof Error) {
47
- logger.log('\n--- Stack Trace ---');
48
- logger.log(this.originalError.stack);
49
- } else {
50
- logger.log('\n--- Stack Trace ---');
51
- logger.log(this);
52
- }
53
- } else {
54
- logger.log('\n(Use --debug to see the full stack trace)');
55
- }
56
- }
57
- }
1
+ import { Logger, createLogger } from './Logger.js';
2
+
3
+ export class TyrError extends Error {
4
+ public readonly originalError: unknown;
5
+ public readonly isTyrError = true;
6
+ public readonly suggestion?: string;
7
+ public readonly commandName?: string;
8
+
9
+ constructor(message: string, originalError?: unknown, suggestion?: string, commandName?: string) {
10
+ super(message);
11
+ this.originalError = originalError;
12
+ this.suggestion = suggestion;
13
+ this.commandName = commandName;
14
+ Error.captureStackTrace(this, this.constructor);
15
+ }
16
+
17
+ private extractErrorMessage(err: unknown): string {
18
+ if (err instanceof Error) return err.message;
19
+ if (typeof err === 'string') return err;
20
+ try {
21
+ return JSON.stringify(err);
22
+ } catch {
23
+ return 'Unknown error (non-serializable)';
24
+ }
25
+ }
26
+
27
+ public handle(isDebug: boolean = false, _logger?: Logger): void {
28
+ const logger = _logger ?? createLogger(isDebug);
29
+
30
+ if (this.commandName) {
31
+ logger.error(`Error in command: ${this.commandName}`);
32
+ }
33
+
34
+ logger.error('Oops! An error occurred.');
35
+ logger.error(`↳ ${this.message}`);
36
+
37
+ if (this.originalError) {
38
+ logger.error(` ↳ Caused by: ${this.extractErrorMessage(this.originalError)}`);
39
+ }
40
+
41
+ if (this.suggestion) {
42
+ logger.warn(` Suggestion: ${this.suggestion}`);
43
+ }
44
+
45
+ if (isDebug) {
46
+ if (this.originalError instanceof Error) {
47
+ logger.log('\n--- Stack Trace ---');
48
+ logger.log(this.originalError.stack);
49
+ } else {
50
+ logger.log('\n--- Stack Trace ---');
51
+ logger.log(this);
52
+ }
53
+ } else {
54
+ logger.log('\n(Use --debug to see the full stack trace)');
55
+ }
56
+ }
57
+ }