g360-cli 1.1.1 → 1.2.1

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": "g360-cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "CLI tool for bootstrapping G360 ecosystem projects",
5
5
  "type": "module",
6
6
  "main": "src/cli.js",
@@ -9,7 +9,15 @@
9
9
  },
10
10
  "scripts": {
11
11
  "prepublishOnly": "node -e \"console.log('Use: npm install -g g360-cli')\"",
12
- "test": "echo \"No tests configured\""
12
+ "test": "echo \"No tests configured\"",
13
+ "build": "npm run build:portable",
14
+ "build:portable": "pkg . --targets node18-win-x64 --output dist/g360.exe"
15
+ },
16
+ "pkg": {
17
+ "assets": [
18
+ "src/assets/**/*"
19
+ ],
20
+ "outputPath": "dist"
13
21
  },
14
22
  "keywords": [
15
23
  "g360",
@@ -26,6 +34,9 @@
26
34
  "inquirer": "^9.2.15",
27
35
  "ora": "^7.0.1"
28
36
  },
37
+ "devDependencies": {
38
+ "pkg": "^5.8.1"
39
+ },
29
40
  "engines": {
30
41
  "node": ">=18.0.0"
31
42
  }
@@ -0,0 +1,10 @@
1
+ @echo off
2
+ :: Script para ejecucion portable e independiente
3
+ title G360 Python Portable - %CD%
4
+
5
+ echo [G360] Iniciando aplicacion portable...
6
+
7
+ :: Aseguramos que se use el entorno sincronizado
8
+ uv run python src/main.py
9
+
10
+ if %errorlevel% neq 0 pause
@@ -0,0 +1,19 @@
1
+ @echo off
2
+ setlocal enabledelayedexpansion
3
+
4
+ echo [G360] Verificando entorno de desarrollo Python (uv)...
5
+
6
+ where uv >nul 2>nul
7
+ if %errorlevel% neq 0 (
8
+ echo [G360] uv no detectado. Iniciando instalacion automatica...
9
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
10
+ set "PATH=%USERPROFILE%\.cargo\bin;%PATH%"
11
+ echo [G360] uv instalado correctamente.
12
+ ) else (
13
+ echo [G360] uv ya esta instalado.
14
+ )
15
+
16
+ echo [G360] Sincronizando dependencias y entorno virtual...
17
+ uv sync
18
+ echo [G360] Entorno listo. Puedes usar 'uv run python src/main.py' para probar.
19
+ pause
@@ -17,6 +17,7 @@
17
17
  <!-- Firma G360 -->
18
18
  <g360-signature mode="powered" style="position: fixed; bottom: 16px; right: 16px; z-index: 100;"></g360-signature>
19
19
 
20
+ <script type="module" src="https://unpkg.com/g360-signature@1.0.0/index.js"></script>
20
21
  <script type="module" src="/app.js"></script>
21
22
  </body>
22
23
  </html>
package/src/cli.js CHANGED
@@ -12,6 +12,7 @@ import { clean } from './commands/clean.js';
12
12
  import { health } from './commands/health.js';
13
13
  import { update } from './commands/update.js';
14
14
  import { convert } from './commands/convert.js';
15
+ import { signature } from './commands/signature.js';
15
16
 
16
17
  const program = new Command();
17
18
 
@@ -96,4 +97,11 @@ program
96
97
  .option('--backup', 'Create backup before converting')
97
98
  .action(convert);
98
99
 
100
+ program
101
+ .command('signature')
102
+ .argument('<command>', 'Command to execute (install)')
103
+ .option('-p, --path <path>', 'Target project path', '.')
104
+ .option('--force', 'Force reinstall if already exists')
105
+ .action(signature);
106
+
99
107
  program.parse();
@@ -4,6 +4,7 @@ import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { manifest } from '../lib/manifest.js';
6
6
  import { progress } from '../lib/progress.js';
7
+ import { setSkill } from './set-skill.js';
7
8
 
8
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
10
 
@@ -48,8 +49,15 @@ export async function init(name, options) {
48
49
  const progressBar = progress('Creating project...');
49
50
 
50
51
  try {
52
+ // Asegurar que el directorio base existe
53
+ await fs.ensureDir(path.dirname(targetDir));
54
+
51
55
  await fs.copy(templateDir, targetDir);
52
56
  await manifest.init(targetDir, { name, template, version: '1.0.0' });
57
+
58
+ // Aplicar el skill pasando el directorio destino explícitamente
59
+ await setSkill(skill, { force: true, verbose: options.verbose, cwd: targetDir });
60
+
53
61
  progressBar.stop();
54
62
 
55
63
  console.log(chalk.green('\n✅ Project created successfully!\n'));
@@ -7,19 +7,21 @@
7
7
  import chalk from 'chalk';
8
8
  import fs from 'fs-extra';
9
9
  import path from 'path';
10
+ import { fileURLToPath } from 'url';
10
11
 
11
- const SKILLS_PATH = path.join(process.cwd(), 'g360-cli/src/assets/config/g360-skills.json');
12
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
+ const SKILLS_PATH = path.resolve(__dirname, '../assets/config/g360-skills.json');
12
14
 
13
15
  export async function setSkill(skillName, options) {
14
- const { verbose = false } = options;
16
+ const { verbose = false, cwd = process.cwd() } = options;
17
+ const isInternalCall = options.cwd !== undefined;
15
18
 
16
19
  console.log(chalk.bold.cyan('\n🎨 G360 Skill Selector\n'));
17
20
 
18
21
  // Cargar skills disponibles
19
22
  let skillsConfig;
20
23
  try {
21
- const cliPath = path.join(process.cwd(), 'g360-cli/src/assets/config/g360-skills.json');
22
- skillsConfig = await fs.readJson(cliPath);
24
+ skillsConfig = await fs.readJson(SKILLS_PATH);
23
25
  } catch (error) {
24
26
  console.error(chalk.red('❌ No se pudo cargar la configuración de skills'));
25
27
  return;
@@ -38,7 +40,7 @@ export async function setSkill(skillName, options) {
38
40
  }
39
41
 
40
42
  // Verificar si existe skill.json en el proyecto
41
- const skillJsonPath = path.join(process.cwd(), 'skill.json');
43
+ const skillJsonPath = path.join(cwd, 'skill.json');
42
44
 
43
45
  if (fs.existsSync(skillJsonPath)) {
44
46
  console.log(chalk.yellow('⚠️ El proyecto ya tiene un skill configurado.'));
@@ -0,0 +1,51 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+
8
+ export async function signature(command, options) {
9
+ const { path: targetPath = '.', force = false } = options;
10
+
11
+ if (command === 'install') {
12
+ console.log(chalk.bold.cyan('\n🔖 Instalando g360-signature\n'));
13
+
14
+ const targetDir = path.resolve(process.cwd(), targetPath);
15
+ const indexHtmlPath = path.join(targetDir, 'index.html');
16
+
17
+ if (!fs.existsSync(indexHtmlPath)) {
18
+ console.error(chalk.red('❌ No se encontro archivo index.html en el directorio actual'));
19
+ return;
20
+ }
21
+
22
+ let htmlContent = fs.readFileSync(indexHtmlPath, 'utf8');
23
+
24
+ // Verificar si ya esta instalado
25
+ if (htmlContent.includes('g360-signature') && !force) {
26
+ console.log(chalk.yellow('⚠️ g360-signature ya se encuentra instalado'));
27
+ console.log(chalk.gray('Usa --force para reinstalar'));
28
+ return;
29
+ }
30
+
31
+ // Agregar script CDN antes del cierre del body
32
+ const scriptTag = ' <script type="module" src="https://unpkg.com/g360-signature@latest/index.js"></script>';
33
+ const signatureComponent = `
34
+ <!-- Firma Oficial G360 -->
35
+ <g360-signature mode="powered" style="position: fixed; bottom: 16px; right: 16px; z-index: 99999;"></g360-signature>
36
+ `;
37
+
38
+ if (!htmlContent.includes(scriptTag)) {
39
+ htmlContent = htmlContent.replace('</body>', `${scriptTag}\n </body>`);
40
+ }
41
+
42
+ if (!htmlContent.includes('<g360-signature')) {
43
+ htmlContent = htmlContent.replace('</body>', `${signatureComponent}\n </body>`);
44
+ }
45
+
46
+ fs.writeFileSync(indexHtmlPath, htmlContent, 'utf8');
47
+
48
+ console.log(chalk.green('✅ g360-signature instalado exitosamente!'));
49
+ console.log(chalk.gray('\nEl componente ha sido agregado en el pie de pagina de tu proyecto\n'));
50
+ }
51
+ }
@@ -1,14 +1,23 @@
1
1
  import chalk from 'chalk';
2
2
  import { execSync } from 'child_process';
3
+ import fs from 'fs-extra';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const pkgPath = path.resolve(__dirname, '../../package.json');
3
9
 
4
10
  export async function update(options) {
5
11
  const { check = false } = options;
6
12
 
7
- console.log(chalk.bold.cyan('\n⬆️ G360 Update\n'));
13
+ // Detectar si estamos corriendo en modo portable (pkg)
14
+ const isPortable = process.pkg !== undefined;
8
15
 
16
+ console.log(chalk.bold.cyan('\n⬆️ G360 Update\n'));
17
+ const { version: currentVersion } = fs.readJsonSync(pkgPath);
18
+
9
19
  if (check) {
10
20
  try {
11
- const currentVersion = '1.0.0';
12
21
  console.log(chalk.gray(`Current version: ${currentVersion}`));
13
22
  console.log(chalk.gray('Check npm for latest version...'));
14
23
  console.log(chalk.yellow('\nUse: npm install -g g360-cli@latest to update'));
@@ -18,6 +27,12 @@ export async function update(options) {
18
27
  return;
19
28
  }
20
29
 
30
+ if (isPortable) {
31
+ console.log(chalk.cyan('🚀 Estás usando la versión portable de G360-CLI.'));
32
+ console.log(chalk.yellow('Para actualizar, descarga el nuevo binario desde el repositorio oficial.'));
33
+ return;
34
+ }
35
+
21
36
  try {
22
37
  console.log(chalk.yellow('Installing latest g360-cli...\n'));
23
38
  execSync('npm install -g g360-cli', { stdio: 'inherit' });
@@ -1,6 +0,0 @@
1
- ' G360 VBA Excel Template
2
- ' Powered by G360 Ecosystem
3
-
4
- Sub G360_Main()
5
- MsgBox "G360 VBA initialized", vbInformation, "G360"
6
- End Sub
@@ -1,46 +0,0 @@
1
- ' ============================================================================
2
- ' G360 DataMap VBA
3
- ' ============================================================================
4
- ' Funciones de mapeo de campos para VBA Excel
5
- ' ============================================================================
6
-
7
- Option Explicit
8
-
9
- ' ============================================================================
10
- ' TIPOS
11
- ' ============================================================================
12
-
13
- Public Type G360FieldMap
14
- LocalName As String
15
- StandardName As String
16
- DataType As String
17
- End Type
18
-
19
- ' ============================================================================
20
- ' FUNCIONES DE MAPEO
21
- ' ============================================================================
22
-
23
- Public Function G360_NormalizeFieldName(fieldName As String, dominio As String) As String
24
- Dim normalized As String
25
- normalized = LCase(Replace(Replace(fieldName, "_", ""), " ", ""))
26
-
27
- Select Case normalized
28
- Case "codigo", "sku", "cod", "producto", "item"
29
- G360_NormalizeFieldName = "codigo"
30
- Case "nombre", "descripcion", "producto", "nombreproducto"
31
- G360_NormalizeFieldName = "nombre"
32
- Case "cantidad", "cant", "qty", "stock"
33
- G360_NormalizeFieldName = "cantidad"
34
- Case "precio", "tarifa", "monto", "valor", "importe"
35
- G360_NormalizeFieldName = "precio"
36
- Case "fecha", "fec", "date"
37
- G360_NormalizeFieldName = "fecha"
38
- Case Else
39
- G360_NormalizeFieldName = fieldName
40
- End Select
41
- End Function
42
-
43
- Public Function G360_MapRow(rowData As Object, dominio As String) As Object
44
- ' Placeholder para mapeo de fila completa
45
- Set G360_MapRow = rowData
46
- End Function
@@ -1,9 +0,0 @@
1
- {
2
- "proyecto": "vba-excel-template",
3
- "tipo": "vba-excel",
4
- "skill": "libre",
5
- "dominio": "operaciones",
6
- "version": "1.0.0",
7
- "autor": "Carlos Cusi",
8
- "descripcion": "Template base para macros VBA Excel con G360"
9
- }