codecrypto-cli 1.0.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.
- package/.claude/settings.local.json +11 -0
- package/PUBLISHING.md +156 -0
- package/README.md +551 -0
- package/codecrypto-cli-1.0.0.tgz +0 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +55 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/database.d.ts +3 -0
- package/dist/commands/database.d.ts.map +1 -0
- package/dist/commands/database.js +94 -0
- package/dist/commands/database.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +46 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +112 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
- package/src/commands/config.ts +55 -0
- package/src/commands/database.ts +105 -0
- package/src/commands/deploy.ts +49 -0
- package/src/commands/user.ts +122 -0
- package/src/index.ts +22 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.configCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
exports.configCommand = new commander_1.Command('config')
|
|
10
|
+
.description('Manage CLI configuration');
|
|
11
|
+
// Subcomando: set
|
|
12
|
+
exports.configCommand
|
|
13
|
+
.command('set <key> <value>')
|
|
14
|
+
.description('Set a configuration value')
|
|
15
|
+
.option('-g, --global', 'Set global configuration', false)
|
|
16
|
+
.action((key, value, options) => {
|
|
17
|
+
const scope = options.global ? 'global' : 'local';
|
|
18
|
+
console.log(chalk_1.default.blue('\n⚙️ Configuration\n'));
|
|
19
|
+
console.log(chalk_1.default.green(`✅ Set ${chalk_1.default.cyan(key)} = ${chalk_1.default.yellow(value)} (${scope})\n`));
|
|
20
|
+
});
|
|
21
|
+
// Subcomando: get
|
|
22
|
+
exports.configCommand
|
|
23
|
+
.command('get <key>')
|
|
24
|
+
.description('Get a configuration value')
|
|
25
|
+
.action((key) => {
|
|
26
|
+
console.log(chalk_1.default.blue('\n⚙️ Configuration\n'));
|
|
27
|
+
// Simular obtener valor
|
|
28
|
+
const mockValues = {
|
|
29
|
+
'api.url': 'https://api.codecrypto.com',
|
|
30
|
+
'api.token': '*********************',
|
|
31
|
+
'default.region': 'us-east-1'
|
|
32
|
+
};
|
|
33
|
+
const value = mockValues[key] || 'not set';
|
|
34
|
+
console.log(chalk_1.default.white(`${chalk_1.default.cyan(key)}: ${chalk_1.default.yellow(value)}\n`));
|
|
35
|
+
});
|
|
36
|
+
// Subcomando: list
|
|
37
|
+
exports.configCommand
|
|
38
|
+
.command('list')
|
|
39
|
+
.description('List all configuration values')
|
|
40
|
+
.option('-g, --global', 'Show global configuration', false)
|
|
41
|
+
.action((options) => {
|
|
42
|
+
const scope = options.global ? 'global' : 'local';
|
|
43
|
+
console.log(chalk_1.default.blue(`\n⚙️ Configuration (${scope})\n`));
|
|
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
|
+
Object.entries(configs).forEach(([key, value]) => {
|
|
51
|
+
console.log(chalk_1.default.white(` ${chalk_1.default.cyan(key)}: ${chalk_1.default.yellow(value)}`));
|
|
52
|
+
});
|
|
53
|
+
console.log();
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAEb,QAAA,aAAa,GAAG,IAAI,mBAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,0BAA0B,CAAC,CAAC;AAE3C,kBAAkB;AAClB,qBAAa;KACV,OAAO,CAAC,mBAAmB,CAAC;KAC5B,WAAW,CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,cAAc,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACzD,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,SAAS,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,eAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC;AAC7F,CAAC,CAAC,CAAC;AAEL,kBAAkB;AAClB,qBAAa;KACV,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACjD,wBAAwB;IACxB,MAAM,UAAU,GAA2B;QACzC,SAAS,EAAE,4BAA4B;QACvC,WAAW,EAAE,uBAAuB;QACpC,gBAAgB,EAAE,WAAW;KAC9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":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,SAAS,SACe,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.dbCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const ora_1 = __importDefault(require("ora"));
|
|
10
|
+
exports.dbCommand = new commander_1.Command('db')
|
|
11
|
+
.description('Database operations');
|
|
12
|
+
// Subcomando: migrate
|
|
13
|
+
exports.dbCommand
|
|
14
|
+
.command('migrate')
|
|
15
|
+
.description('Run database migrations')
|
|
16
|
+
.option('-e, --env <environment>', 'Target environment', 'dev')
|
|
17
|
+
.option('--rollback', 'Rollback last migration', false)
|
|
18
|
+
.option('--steps <number>', 'Number of migrations to run/rollback', 'all')
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
console.log(chalk_1.default.blue('\n💾 Database Migration\n'));
|
|
21
|
+
const action = options.rollback ? 'Rolling back' : 'Running';
|
|
22
|
+
const spinner = (0, ora_1.default)(`${action} migrations...`).start();
|
|
23
|
+
await sleep(1500);
|
|
24
|
+
if (options.rollback) {
|
|
25
|
+
spinner.succeed(chalk_1.default.green('✅ Migrations rolled back successfully!'));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
spinner.succeed(chalk_1.default.green('✅ Migrations completed successfully!'));
|
|
29
|
+
}
|
|
30
|
+
console.log(chalk_1.default.gray(`Environment: ${chalk_1.default.cyan(options.env)}`));
|
|
31
|
+
console.log(chalk_1.default.gray(`Steps: ${chalk_1.default.cyan(options.steps)}\n`));
|
|
32
|
+
});
|
|
33
|
+
// Subcomando: seed
|
|
34
|
+
exports.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_1.default.blue('\n🌱 Database Seeding\n'));
|
|
42
|
+
if (options.clear) {
|
|
43
|
+
console.log(chalk_1.default.yellow('⚠️ Clearing existing data...'));
|
|
44
|
+
await sleep(1000);
|
|
45
|
+
}
|
|
46
|
+
const spinner = (0, ora_1.default)('Seeding database...').start();
|
|
47
|
+
await sleep(2000);
|
|
48
|
+
spinner.succeed(chalk_1.default.green('✅ Database seeded successfully!'));
|
|
49
|
+
console.log(chalk_1.default.gray(`Environment: ${chalk_1.default.cyan(options.env)}`));
|
|
50
|
+
if (options.file) {
|
|
51
|
+
console.log(chalk_1.default.gray(`Seed file: ${chalk_1.default.cyan(options.file)}`));
|
|
52
|
+
}
|
|
53
|
+
console.log();
|
|
54
|
+
});
|
|
55
|
+
// Subcomando: backup
|
|
56
|
+
exports.dbCommand
|
|
57
|
+
.command('backup')
|
|
58
|
+
.description('Create a database backup')
|
|
59
|
+
.argument('<name>', 'Backup name')
|
|
60
|
+
.option('-e, --env <environment>', 'Source environment', 'prod')
|
|
61
|
+
.option('-o, --output <path>', 'Output directory', './backups')
|
|
62
|
+
.option('--compress', 'Compress backup file', true)
|
|
63
|
+
.action(async (name, options) => {
|
|
64
|
+
console.log(chalk_1.default.blue('\n💼 Database Backup\n'));
|
|
65
|
+
const spinner = (0, ora_1.default)('Creating backup...').start();
|
|
66
|
+
await sleep(2500);
|
|
67
|
+
spinner.succeed(chalk_1.default.green('✅ Backup created successfully!'));
|
|
68
|
+
const fileName = `${name}_${new Date().toISOString().split('T')[0]}.sql${options.compress ? '.gz' : ''}`;
|
|
69
|
+
console.log(chalk_1.default.gray(`Environment: ${chalk_1.default.cyan(options.env)}`));
|
|
70
|
+
console.log(chalk_1.default.gray(`Output: ${chalk_1.default.cyan(options.output)}/${chalk_1.default.cyan(fileName)}`));
|
|
71
|
+
console.log(chalk_1.default.gray(`Compressed: ${options.compress ? chalk_1.default.green('Yes') : chalk_1.default.yellow('No')}\n`));
|
|
72
|
+
});
|
|
73
|
+
// Subcomando: restore
|
|
74
|
+
exports.dbCommand
|
|
75
|
+
.command('restore <backupFile>')
|
|
76
|
+
.description('Restore database from backup')
|
|
77
|
+
.option('-e, --env <environment>', 'Target environment', 'dev')
|
|
78
|
+
.option('--force', 'Skip confirmation', false)
|
|
79
|
+
.action(async (backupFile, options) => {
|
|
80
|
+
console.log(chalk_1.default.blue('\n♻️ Database Restore\n'));
|
|
81
|
+
if (options.env === 'prod' && !options.force) {
|
|
82
|
+
console.log(chalk_1.default.red('❌ Cannot restore to production without --force flag\n'));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const spinner = (0, ora_1.default)('Restoring database...').start();
|
|
86
|
+
await sleep(3000);
|
|
87
|
+
spinner.succeed(chalk_1.default.green('✅ Database restored successfully!'));
|
|
88
|
+
console.log(chalk_1.default.gray(`Environment: ${chalk_1.default.cyan(options.env)}`));
|
|
89
|
+
console.log(chalk_1.default.gray(`Backup file: ${chalk_1.default.cyan(backupFile)}\n`));
|
|
90
|
+
});
|
|
91
|
+
function sleep(ms) {
|
|
92
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/commands/database.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AAET,QAAA,SAAS,GAAG,IAAI,mBAAO,CAAC,IAAI,CAAC;KACvC,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAEtC,sBAAsB;AACtB,iBAAS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Root":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SAwCtB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deployCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const ora_1 = __importDefault(require("ora"));
|
|
10
|
+
exports.deployCommand = new commander_1.Command('deploy')
|
|
11
|
+
.description('Deploy your application to different environments')
|
|
12
|
+
.option('-e, --env <environment>', 'Environment to deploy (dev, staging, prod)', 'dev')
|
|
13
|
+
.option('-b, --branch <branch>', 'Git branch to deploy', 'main')
|
|
14
|
+
.option('-r, --region <region>', 'AWS region', 'us-east-1')
|
|
15
|
+
.option('--skip-tests', 'Skip running tests before deployment', false)
|
|
16
|
+
.option('--dry-run', 'Simulate deployment without actually deploying', false)
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
console.log(chalk_1.default.blue('\n🚀 CodeCrypto Deployment\n'));
|
|
19
|
+
console.log(chalk_1.default.gray('Deployment Configuration:'));
|
|
20
|
+
console.log(chalk_1.default.white(` Environment: ${chalk_1.default.green(options.env)}`));
|
|
21
|
+
console.log(chalk_1.default.white(` Branch: ${chalk_1.default.green(options.branch)}`));
|
|
22
|
+
console.log(chalk_1.default.white(` Region: ${chalk_1.default.green(options.region)}`));
|
|
23
|
+
console.log(chalk_1.default.white(` Skip Tests: ${options.skipTests ? chalk_1.default.yellow('Yes') : chalk_1.default.green('No')}`));
|
|
24
|
+
console.log(chalk_1.default.white(` Dry Run: ${options.dryRun ? chalk_1.default.yellow('Yes') : chalk_1.default.green('No')}`));
|
|
25
|
+
if (options.dryRun) {
|
|
26
|
+
console.log(chalk_1.default.yellow('\n⚠️ Running in dry-run mode. No actual deployment will occur.\n'));
|
|
27
|
+
}
|
|
28
|
+
// Simular proceso de deployment
|
|
29
|
+
const spinner = (0, ora_1.default)('Preparing deployment...').start();
|
|
30
|
+
await sleep(1000);
|
|
31
|
+
spinner.text = 'Building application...';
|
|
32
|
+
await sleep(1500);
|
|
33
|
+
if (!options.skipTests) {
|
|
34
|
+
spinner.text = 'Running tests...';
|
|
35
|
+
await sleep(1000);
|
|
36
|
+
}
|
|
37
|
+
await sleep(1000);
|
|
38
|
+
spinner.text = `Deploying to ${options.env}...`;
|
|
39
|
+
await sleep(2000);
|
|
40
|
+
spinner.succeed(chalk_1.default.green(`✅ Successfully deployed to ${options.env}!`));
|
|
41
|
+
console.log(chalk_1.default.gray('\n📦 Deployment URL:'), chalk_1.default.cyan(`https://${options.env}.codecrypto.com`));
|
|
42
|
+
});
|
|
43
|
+
function sleep(ms) {
|
|
44
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AAET,QAAA,aAAa,GAAG,IAAI,mBAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,yBAAyB,EAAE,4CAA4C,EAAE,KAAK,CAAC;KACtF,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,CAAC;KAC/D,MAAM,CAAC,uBAAuB,EAAE,YAAY,EAAE,WAAW,CAAC;KAC1D,MAAM,CAAC,cAAc,EAAE,sCAAsC,EAAE,KAAK,CAAC;KACrE,MAAM,CAAC,WAAW,EAAE,gDAAg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,aAAG,EAAC,yBAAyB,CAAC,CAAC,KAAK,EAAE,CAAC;IAEvD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,IAAI,GAAG,yBAAyB,CAAC;IAEzC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IAClB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAClC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,IAAI,GAAG,gBAAgB,OAAO,CAAC,GAAG,KAAK,CAAC;IAEhD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,OAAO,CAAC,eAAK,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAE3E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,EAAE,eAAK,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC;AACvG,CAAC,CAAC,CAAC;AAEL,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/commands/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,WAAW,SACoB,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.userCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
+
exports.userCommand = new commander_1.Command('user')
|
|
11
|
+
.description('Manage users in the system');
|
|
12
|
+
// Subcomando: crear usuario
|
|
13
|
+
exports.userCommand
|
|
14
|
+
.command('create')
|
|
15
|
+
.description('Create a new user')
|
|
16
|
+
.option('-u, --username <username>', 'Username')
|
|
17
|
+
.option('-e, --email <email>', 'Email address')
|
|
18
|
+
.option('-r, --role <role>', 'User role (admin, user, guest)', 'user')
|
|
19
|
+
.option('--interactive', 'Interactive mode', false)
|
|
20
|
+
.action(async (options) => {
|
|
21
|
+
console.log(chalk_1.default.blue('\n👤 Create New User\n'));
|
|
22
|
+
let userData = {
|
|
23
|
+
username: options.username,
|
|
24
|
+
email: options.email,
|
|
25
|
+
role: options.role
|
|
26
|
+
};
|
|
27
|
+
// Modo interactivo
|
|
28
|
+
if (options.interactive || !options.username || !options.email) {
|
|
29
|
+
const answers = await inquirer_1.default.prompt([
|
|
30
|
+
{
|
|
31
|
+
type: 'input',
|
|
32
|
+
name: 'username',
|
|
33
|
+
message: 'Enter username:',
|
|
34
|
+
default: options.username,
|
|
35
|
+
validate: (input) => input.length > 0 || 'Username is required'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'input',
|
|
39
|
+
name: 'email',
|
|
40
|
+
message: 'Enter email:',
|
|
41
|
+
default: options.email,
|
|
42
|
+
validate: (input) => {
|
|
43
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
44
|
+
return emailRegex.test(input) || 'Invalid email format';
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'list',
|
|
49
|
+
name: 'role',
|
|
50
|
+
message: 'Select role:',
|
|
51
|
+
choices: ['admin', 'user', 'guest'],
|
|
52
|
+
default: options.role
|
|
53
|
+
}
|
|
54
|
+
]);
|
|
55
|
+
userData = { ...userData, ...answers };
|
|
56
|
+
}
|
|
57
|
+
console.log(chalk_1.default.green('\n✅ User created successfully!'));
|
|
58
|
+
console.log(chalk_1.default.gray('User details:'));
|
|
59
|
+
console.log(chalk_1.default.white(` Username: ${chalk_1.default.cyan(userData.username)}`));
|
|
60
|
+
console.log(chalk_1.default.white(` Email: ${chalk_1.default.cyan(userData.email)}`));
|
|
61
|
+
console.log(chalk_1.default.white(` Role: ${chalk_1.default.cyan(userData.role)}`));
|
|
62
|
+
});
|
|
63
|
+
// Subcomando: listar usuarios
|
|
64
|
+
exports.userCommand
|
|
65
|
+
.command('list')
|
|
66
|
+
.description('List all users')
|
|
67
|
+
.option('-r, --role <role>', 'Filter by role')
|
|
68
|
+
.option('-l, --limit <number>', 'Limit number of results', '10')
|
|
69
|
+
.action((options) => {
|
|
70
|
+
console.log(chalk_1.default.blue('\n📋 User List\n'));
|
|
71
|
+
if (options.role) {
|
|
72
|
+
console.log(chalk_1.default.gray(`Filtering by role: ${chalk_1.default.cyan(options.role)}`));
|
|
73
|
+
}
|
|
74
|
+
// Datos de ejemplo
|
|
75
|
+
const users = [
|
|
76
|
+
{ id: 1, username: 'john_doe', email: 'john@example.com', role: 'admin' },
|
|
77
|
+
{ id: 2, username: 'jane_smith', email: 'jane@example.com', role: 'user' },
|
|
78
|
+
{ id: 3, username: 'bob_wilson', email: 'bob@example.com', role: 'user' }
|
|
79
|
+
];
|
|
80
|
+
const filteredUsers = options.role
|
|
81
|
+
? users.filter(u => u.role === options.role)
|
|
82
|
+
: users;
|
|
83
|
+
const limitedUsers = filteredUsers.slice(0, parseInt(options.limit));
|
|
84
|
+
limitedUsers.forEach(user => {
|
|
85
|
+
console.log(chalk_1.default.white(` ${user.id}. ${chalk_1.default.cyan(user.username)} (${user.email}) - ${chalk_1.default.yellow(user.role)}`));
|
|
86
|
+
});
|
|
87
|
+
console.log(chalk_1.default.gray(`\nTotal: ${limitedUsers.length} users\n`));
|
|
88
|
+
});
|
|
89
|
+
// Subcomando: eliminar usuario
|
|
90
|
+
exports.userCommand
|
|
91
|
+
.command('delete <userId>')
|
|
92
|
+
.description('Delete a user by ID')
|
|
93
|
+
.option('-f, --force', 'Skip confirmation', false)
|
|
94
|
+
.action(async (userId, options) => {
|
|
95
|
+
console.log(chalk_1.default.blue('\n🗑️ Delete User\n'));
|
|
96
|
+
if (!options.force) {
|
|
97
|
+
const { confirm } = await inquirer_1.default.prompt([
|
|
98
|
+
{
|
|
99
|
+
type: 'confirm',
|
|
100
|
+
name: 'confirm',
|
|
101
|
+
message: `Are you sure you want to delete user ${userId}?`,
|
|
102
|
+
default: false
|
|
103
|
+
}
|
|
104
|
+
]);
|
|
105
|
+
if (!confirm) {
|
|
106
|
+
console.log(chalk_1.default.yellow('❌ Operation cancelled\n'));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
console.log(chalk_1.default.green(`✅ User ${userId} deleted successfully!\n`));
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/commands/user.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,wDAAgC;AAEnB,QAAA,WAAW,GAAG,IAAI,mBAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,4BAA4B,CAAC,CAAC;AAE7C,4BAA4B;AAC5B,mBAAW;KACR,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,mBAAmB,CAAC;KAChC,MAAM,CAAC,2BAA2B,EAAE,UAAU,CAAC;KAC/C,MAAM,CAAC,qBAAqB,EAAE,eAAe,CAAC;KAC9C,MAAM,CAAC,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,CAAC;KACrE,MA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EAAE,OAAO,EAAE,EAAE;IAChC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAEhD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC;YACxC;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,wCAAwC,MAAM,GAAG;gBAC1D,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,UAAU,MAAM,0BAA0B,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const deploy_1 = require("./commands/deploy");
|
|
6
|
+
const user_1 = require("./commands/user");
|
|
7
|
+
const config_1 = require("./commands/config");
|
|
8
|
+
const database_1 = require("./commands/database");
|
|
9
|
+
const program = new commander_1.Command();
|
|
10
|
+
program
|
|
11
|
+
.name('codecrypto')
|
|
12
|
+
.description('CLI tool for CodeCrypto operations')
|
|
13
|
+
.version('1.0.0');
|
|
14
|
+
// Registrar comandos
|
|
15
|
+
program.addCommand(deploy_1.deployCommand);
|
|
16
|
+
program.addCommand(user_1.userCommand);
|
|
17
|
+
program.addCommand(config_1.configCommand);
|
|
18
|
+
program.addCommand(database_1.dbCommand);
|
|
19
|
+
program.parse(process.argv);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,8CAAkD;AAClD,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,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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codecrypto-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool for CodeCrypto operations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"codecrypto": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsx src/index.ts",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"test": "node dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cli",
|
|
17
|
+
"codecrypto",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"commander": "^12.0.0",
|
|
24
|
+
"chalk": "^4.1.2",
|
|
25
|
+
"ora": "^5.4.1",
|
|
26
|
+
"inquirer": "^8.2.5"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.10.0",
|
|
30
|
+
"@types/inquirer": "^9.0.7",
|
|
31
|
+
"typescript": "^5.3.0",
|
|
32
|
+
"tsx": "^4.7.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=16.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
}
|