test-axz-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/index.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import { commandsConfiguration } from './src/config/commands.js';
5
+
6
+ const program = new Command();
7
+
8
+ program
9
+ .name('axz')
10
+ .description('Herramientas CLI para desarrollo.')
11
+ .version('1.0.0');
12
+
13
+ commandsConfiguration.forEach(config => {
14
+ program
15
+ .command(config.name)
16
+ .description(config.description)
17
+ .action(config.action);
18
+ });
19
+
20
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "test-axz-cli",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "Aitor Sanchez Rodriguez",
11
+ "license": "ISC",
12
+ "type": "module",
13
+ "bin": {
14
+ "axz": "./index.js"
15
+ },
16
+ "dependencies": {
17
+ "commander": "^14.0.3",
18
+ "execa": "^9.6.1",
19
+ "inquirer": "^9.3.8",
20
+ "picocolors": "^1.1.1"
21
+ },
22
+ "files": [
23
+ "index.js",
24
+ "src/**/*"
25
+ ]
26
+ }
@@ -0,0 +1,13 @@
1
+ import pc from 'picocolors';
2
+ import { commandsConfiguration } from '../config/commands.js';
3
+
4
+ export async function help() {
5
+ console.log(pc.bold(pc.blue('Lista de comandos de Axazure:')));
6
+
7
+ commandsConfiguration.forEach(cmd => {
8
+ const name = pc.green(cmd.name.padEnd(12));
9
+ const desc = pc.white(cmd.description);
10
+
11
+ console.log(` ${name} ${desc}`);
12
+ });
13
+ }
@@ -0,0 +1,75 @@
1
+ import inquirer from 'inquirer';
2
+ import { execa } from 'execa';
3
+ import pc from 'picocolors';
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+
7
+ export async function pcfAction() {
8
+ console.log('Instalación de PCFs');
9
+ console.log('Configurando tu entorno de desarrollo...');
10
+
11
+ const answers = await inquirer.prompt([
12
+ {
13
+ type: 'input',
14
+ name: 'namespace',
15
+ message: 'Introduce el namespace del proyecto (ej. Axazure):',
16
+ validate: (input) => input ? true : 'El namespace es obligatorio.'
17
+ },
18
+ {
19
+ type: 'input',
20
+ name: 'name',
21
+ message: 'Introduce el nombre del PCF (ej. ListPCF):',
22
+ validate: (input) => input ? true : 'El nombre es obligatorio.'
23
+ },
24
+ {
25
+ type: 'list',
26
+ name: 'template',
27
+ message: 'Selecciona el tipo de PCF:',
28
+ choices: [
29
+ { name: 'Field (Campo)', value: 'field' },
30
+ { name: 'Dataset (Vista)', value: 'dataset' }
31
+ ]
32
+ },
33
+ {
34
+ type: 'confirm',
35
+ name: 'installFluent',
36
+ message: '¿Quieres instalar Fluent UI (y/n)?',
37
+ default: true
38
+ }
39
+ ]);
40
+
41
+ try {
42
+ console.log(`Iniciando proyecto PAC: ${answers.namespace}.${answers.name}...`);
43
+ await execa('pac', [
44
+ 'pcf', 'init',
45
+ '--namespace', answers.namespace,
46
+ '--name', answers.name,
47
+ '--template', answers.template,
48
+ '--framework', 'react',
49
+ '--run-npm-install'
50
+ ], { stdio: 'inherit' });
51
+
52
+ console.log('Instalando @axazure/pcf-proxy-dynamics...');
53
+ await execa('npm', ['install', '@axazure/pcf-proxy-dynamics'], { stdio: 'inherit' });
54
+
55
+ if (answers.installFluent) {
56
+ console.log('Instalando @fluentui/react-components...');
57
+ await execa('npm', ['install', '@fluentui/react-components'], { stdio: 'inherit' });
58
+ }
59
+
60
+ console.log('Generando archivo .env...');
61
+ const envContent = [
62
+ 'ENVIRONMENT_URL=<ENVIRONMENT_URL>',
63
+ 'TENANT_ID=<TENANT_ID>',
64
+ 'CLIENT_ID=<CLIENT_ID>',
65
+ 'CLIENT_SECRET=<CLIENT_SECRET>'
66
+ ].join('\n');
67
+
68
+ fs.writeFileSync(path.join(process.cwd(), '.env'), envContent, 'utf8');
69
+
70
+ console.log(pc.green('Instalación completada con éxito. Puedes configurar tus credenciales en el archivo .env'));
71
+ } catch (error) {
72
+ console.error(pc.red('\nError durante el proceso:'), error.message);
73
+ console.log(pc.red('Asegúrate de tener instalado "Power Platform CLI" (pac).'));
74
+ }
75
+ }
@@ -0,0 +1,15 @@
1
+ import { pcfAction } from '../commands/pcf.js';
2
+ import { help } from '../commands/help.js';
3
+
4
+ export const commandsConfiguration = [
5
+ {
6
+ name: 'pcf',
7
+ description: 'Inicializa un proyecto PCF con configuración Axazure.',
8
+ action: pcfAction
9
+ },
10
+ {
11
+ name: 'help',
12
+ description: 'Muestra la lista de comandos disponibles y su función.',
13
+ action: help
14
+ }
15
+ ];