codecrypto-cli 1.0.4 → 1.0.5

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/dist/index.js CHANGED
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const commander_1 = require("commander");
5
5
  const deploy_1 = require("./commands/deploy");
6
6
  const deploy_sc_1 = require("./commands/deploy-sc");
7
- const user_1 = require("./commands/user");
8
- const config_1 = require("./commands/config");
9
- const database_1 = require("./commands/database");
10
7
  const program = new commander_1.Command();
11
8
  program
12
9
  .name('codecrypto')
@@ -15,8 +12,5 @@ program
15
12
  // Registrar comandos
16
13
  program.addCommand(deploy_1.deployCommand);
17
14
  program.addCommand(deploy_sc_1.deployScCommand);
18
- program.addCommand(user_1.userCommand);
19
- program.addCommand(config_1.configCommand);
20
- program.addCommand(database_1.dbCommand);
21
15
  program.parse(process.argv);
22
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,8CAAkD;AAClD,oDAAuD;AACvD,0CAA8C;AAC9C,8CAAkD;AAClD,kDAAgD;AAEhD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,oCAAoC,CAAC;KACjD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,qBAAqB;AACrB,OAAO,CAAC,UAAU,CAAC,sBAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,2BAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,sBAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,oBAAS,CAAC,CAAC;AAE9B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,8CAAkD;AAClD,oDAAuD;AAEvD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,oCAAoC,CAAC;KACjD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,qBAAqB;AACrB,OAAO,CAAC,UAAU,CAAC,sBAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,2BAAe,CAAC,CAAC;AAEpC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codecrypto-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI tool for CodeCrypto operations",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -3,9 +3,6 @@
3
3
  import { Command } from 'commander';
4
4
  import { deployCommand } from './commands/deploy';
5
5
  import { deployScCommand } from './commands/deploy-sc';
6
- import { userCommand } from './commands/user';
7
- import { configCommand } from './commands/config';
8
- import { dbCommand } from './commands/database';
9
6
 
10
7
  const program = new Command();
11
8
 
@@ -17,8 +14,5 @@ program
17
14
  // Registrar comandos
18
15
  program.addCommand(deployCommand);
19
16
  program.addCommand(deployScCommand);
20
- program.addCommand(userCommand);
21
- program.addCommand(configCommand);
22
- program.addCommand(dbCommand);
23
17
 
24
18
  program.parse(process.argv);
@@ -1,55 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
-
4
- export const configCommand = new Command('config')
5
- .description('Manage CLI configuration');
6
-
7
- // Subcomando: set
8
- configCommand
9
- .command('set <key> <value>')
10
- .description('Set a configuration value')
11
- .option('-g, --global', 'Set global configuration', false)
12
- .action((key, value, options) => {
13
- const scope = options.global ? 'global' : 'local';
14
- console.log(chalk.blue('\n⚙️ Configuration\n'));
15
- console.log(chalk.green(`✅ Set ${chalk.cyan(key)} = ${chalk.yellow(value)} (${scope})\n`));
16
- });
17
-
18
- // Subcomando: get
19
- configCommand
20
- .command('get <key>')
21
- .description('Get a configuration value')
22
- .action((key) => {
23
- console.log(chalk.blue('\n⚙️ Configuration\n'));
24
- // Simular obtener valor
25
- const mockValues: Record<string, string> = {
26
- 'api.url': 'https://api.codecrypto.com',
27
- 'api.token': '*********************',
28
- 'default.region': 'us-east-1'
29
- };
30
-
31
- const value = mockValues[key] || 'not set';
32
- console.log(chalk.white(`${chalk.cyan(key)}: ${chalk.yellow(value)}\n`));
33
- });
34
-
35
- // Subcomando: list
36
- configCommand
37
- .command('list')
38
- .description('List all configuration values')
39
- .option('-g, --global', 'Show global configuration', false)
40
- .action((options) => {
41
- const scope = options.global ? 'global' : 'local';
42
- console.log(chalk.blue(`\n⚙️ Configuration (${scope})\n`));
43
-
44
- const configs = {
45
- 'api.url': 'https://api.codecrypto.com',
46
- 'api.token': '*********************',
47
- 'default.region': 'us-east-1',
48
- 'default.env': 'dev'
49
- };
50
-
51
- Object.entries(configs).forEach(([key, value]) => {
52
- console.log(chalk.white(` ${chalk.cyan(key)}: ${chalk.yellow(value)}`));
53
- });
54
- console.log();
55
- });
@@ -1,105 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
-
5
- export const dbCommand = new Command('db')
6
- .description('Database operations');
7
-
8
- // Subcomando: migrate
9
- dbCommand
10
- .command('migrate')
11
- .description('Run database migrations')
12
- .option('-e, --env <environment>', 'Target environment', 'dev')
13
- .option('--rollback', 'Rollback last migration', false)
14
- .option('--steps <number>', 'Number of migrations to run/rollback', 'all')
15
- .action(async (options) => {
16
- console.log(chalk.blue('\n💾 Database Migration\n'));
17
-
18
- const action = options.rollback ? 'Rolling back' : 'Running';
19
- const spinner = ora(`${action} migrations...`).start();
20
-
21
- await sleep(1500);
22
-
23
- if (options.rollback) {
24
- spinner.succeed(chalk.green('✅ Migrations rolled back successfully!'));
25
- } else {
26
- spinner.succeed(chalk.green('✅ Migrations completed successfully!'));
27
- }
28
-
29
- console.log(chalk.gray(`Environment: ${chalk.cyan(options.env)}`));
30
- console.log(chalk.gray(`Steps: ${chalk.cyan(options.steps)}\n`));
31
- });
32
-
33
- // Subcomando: seed
34
- dbCommand
35
- .command('seed')
36
- .description('Seed the database with sample data')
37
- .option('-e, --env <environment>', 'Target environment', 'dev')
38
- .option('-f, --file <file>', 'Seed file to run')
39
- .option('--clear', 'Clear existing data before seeding', false)
40
- .action(async (options) => {
41
- console.log(chalk.blue('\n🌱 Database Seeding\n'));
42
-
43
- if (options.clear) {
44
- console.log(chalk.yellow('⚠️ Clearing existing data...'));
45
- await sleep(1000);
46
- }
47
-
48
- const spinner = ora('Seeding database...').start();
49
- await sleep(2000);
50
-
51
- spinner.succeed(chalk.green('✅ Database seeded successfully!'));
52
- console.log(chalk.gray(`Environment: ${chalk.cyan(options.env)}`));
53
- if (options.file) {
54
- console.log(chalk.gray(`Seed file: ${chalk.cyan(options.file)}`));
55
- }
56
- console.log();
57
- });
58
-
59
- // Subcomando: backup
60
- dbCommand
61
- .command('backup')
62
- .description('Create a database backup')
63
- .argument('<name>', 'Backup name')
64
- .option('-e, --env <environment>', 'Source environment', 'prod')
65
- .option('-o, --output <path>', 'Output directory', './backups')
66
- .option('--compress', 'Compress backup file', true)
67
- .action(async (name, options) => {
68
- console.log(chalk.blue('\n💼 Database Backup\n'));
69
-
70
- const spinner = ora('Creating backup...').start();
71
- await sleep(2500);
72
-
73
- spinner.succeed(chalk.green('✅ Backup created successfully!'));
74
-
75
- const fileName = `${name}_${new Date().toISOString().split('T')[0]}.sql${options.compress ? '.gz' : ''}`;
76
- console.log(chalk.gray(`Environment: ${chalk.cyan(options.env)}`));
77
- console.log(chalk.gray(`Output: ${chalk.cyan(options.output)}/${chalk.cyan(fileName)}`));
78
- console.log(chalk.gray(`Compressed: ${options.compress ? chalk.green('Yes') : chalk.yellow('No')}\n`));
79
- });
80
-
81
- // Subcomando: restore
82
- dbCommand
83
- .command('restore <backupFile>')
84
- .description('Restore database from backup')
85
- .option('-e, --env <environment>', 'Target environment', 'dev')
86
- .option('--force', 'Skip confirmation', false)
87
- .action(async (backupFile, options) => {
88
- console.log(chalk.blue('\n♻️ Database Restore\n'));
89
-
90
- if (options.env === 'prod' && !options.force) {
91
- console.log(chalk.red('❌ Cannot restore to production without --force flag\n'));
92
- return;
93
- }
94
-
95
- const spinner = ora('Restoring database...').start();
96
- await sleep(3000);
97
-
98
- spinner.succeed(chalk.green('✅ Database restored successfully!'));
99
- console.log(chalk.gray(`Environment: ${chalk.cyan(options.env)}`));
100
- console.log(chalk.gray(`Backup file: ${chalk.cyan(backupFile)}\n`));
101
- });
102
-
103
- function sleep(ms: number): Promise<void> {
104
- return new Promise(resolve => setTimeout(resolve, ms));
105
- }
@@ -1,122 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import inquirer from 'inquirer';
4
-
5
- export const userCommand = new Command('user')
6
- .description('Manage users in the system');
7
-
8
- // Subcomando: crear usuario
9
- userCommand
10
- .command('create')
11
- .description('Create a new user')
12
- .option('-u, --username <username>', 'Username')
13
- .option('-e, --email <email>', 'Email address')
14
- .option('-r, --role <role>', 'User role (admin, user, guest)', 'user')
15
- .option('--interactive', 'Interactive mode', false)
16
- .action(async (options) => {
17
- console.log(chalk.blue('\n👤 Create New User\n'));
18
-
19
- let userData = {
20
- username: options.username,
21
- email: options.email,
22
- role: options.role
23
- };
24
-
25
- // Modo interactivo
26
- if (options.interactive || !options.username || !options.email) {
27
- const answers = await inquirer.prompt([
28
- {
29
- type: 'input',
30
- name: 'username',
31
- message: 'Enter username:',
32
- default: options.username,
33
- validate: (input) => input.length > 0 || 'Username is required'
34
- },
35
- {
36
- type: 'input',
37
- name: 'email',
38
- message: 'Enter email:',
39
- default: options.email,
40
- validate: (input) => {
41
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
42
- return emailRegex.test(input) || 'Invalid email format';
43
- }
44
- },
45
- {
46
- type: 'list',
47
- name: 'role',
48
- message: 'Select role:',
49
- choices: ['admin', 'user', 'guest'],
50
- default: options.role
51
- }
52
- ]);
53
-
54
- userData = { ...userData, ...answers };
55
- }
56
-
57
- console.log(chalk.green('\n✅ User created successfully!'));
58
- console.log(chalk.gray('User details:'));
59
- console.log(chalk.white(` Username: ${chalk.cyan(userData.username)}`));
60
- console.log(chalk.white(` Email: ${chalk.cyan(userData.email)}`));
61
- console.log(chalk.white(` Role: ${chalk.cyan(userData.role)}`));
62
- });
63
-
64
- // Subcomando: listar usuarios
65
- userCommand
66
- .command('list')
67
- .description('List all users')
68
- .option('-r, --role <role>', 'Filter by role')
69
- .option('-l, --limit <number>', 'Limit number of results', '10')
70
- .action((options) => {
71
- console.log(chalk.blue('\n📋 User List\n'));
72
-
73
- if (options.role) {
74
- console.log(chalk.gray(`Filtering by role: ${chalk.cyan(options.role)}`));
75
- }
76
-
77
- // Datos de ejemplo
78
- const users = [
79
- { id: 1, username: 'john_doe', email: 'john@example.com', role: 'admin' },
80
- { id: 2, username: 'jane_smith', email: 'jane@example.com', role: 'user' },
81
- { id: 3, username: 'bob_wilson', email: 'bob@example.com', role: 'user' }
82
- ];
83
-
84
- const filteredUsers = options.role
85
- ? users.filter(u => u.role === options.role)
86
- : users;
87
-
88
- const limitedUsers = filteredUsers.slice(0, parseInt(options.limit));
89
-
90
- limitedUsers.forEach(user => {
91
- console.log(chalk.white(` ${user.id}. ${chalk.cyan(user.username)} (${user.email}) - ${chalk.yellow(user.role)}`));
92
- });
93
-
94
- console.log(chalk.gray(`\nTotal: ${limitedUsers.length} users\n`));
95
- });
96
-
97
- // Subcomando: eliminar usuario
98
- userCommand
99
- .command('delete <userId>')
100
- .description('Delete a user by ID')
101
- .option('-f, --force', 'Skip confirmation', false)
102
- .action(async (userId, options) => {
103
- console.log(chalk.blue('\n🗑️ Delete User\n'));
104
-
105
- if (!options.force) {
106
- const { confirm } = await inquirer.prompt([
107
- {
108
- type: 'confirm',
109
- name: 'confirm',
110
- message: `Are you sure you want to delete user ${userId}?`,
111
- default: false
112
- }
113
- ]);
114
-
115
- if (!confirm) {
116
- console.log(chalk.yellow('❌ Operation cancelled\n'));
117
- return;
118
- }
119
- }
120
-
121
- console.log(chalk.green(`✅ User ${userId} deleted successfully!\n`));
122
- });