@open-mova/cli 0.1.17 → 0.1.19

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/README.md CHANGED
@@ -165,6 +165,10 @@ mova cap sync android
165
165
  mova cap sync
166
166
  ```
167
167
 
168
+ En Android, el CLI aplica también los requisitos técnicos de los plugins
169
+ incluidos por la shell: configura el repositorio AAR de Background Runner y
170
+ eleva `minSdkVersion` a 28 cuando está instalado Local LLM.
171
+
168
172
  ### `mova cap open`
169
173
 
170
174
  Abre el proyecto nativo en Android Studio o Xcode.
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { existsSync, writeFileSync } from 'node:fs';
2
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { readApplicationConfiguration, requireApplicationRoot, } from '../application/configuration.js';
5
5
  import { localBinaryName, npmCommand, useCommandShell } from '../utils/platform.js';
@@ -12,13 +12,21 @@ export function registerCapacitorCommands(program) {
12
12
  const root = requireApplicationRoot(process.cwd());
13
13
  buildMobileShell(root);
14
14
  runCapacitor(root, ['add', selectedPlatform]);
15
+ configureNativePlatform(root, selectedPlatform);
15
16
  });
16
17
  capacitor.command('sync [platform]')
17
18
  .description('Compila la shell y sincroniza sus assets y plugins nativos')
18
19
  .action((platform) => {
19
20
  const root = requireApplicationRoot(process.cwd());
20
21
  buildMobileShell(root);
21
- runCapacitor(root, ['sync', ...(platform ? [parsePlatform(platform)] : [])]);
22
+ const selectedPlatform = platform ? parsePlatform(platform) : undefined;
23
+ runCapacitor(root, ['sync', ...(selectedPlatform ? [selectedPlatform] : [])]);
24
+ if (selectedPlatform) {
25
+ configureNativePlatform(root, selectedPlatform);
26
+ }
27
+ else {
28
+ configureExistingPlatforms(root);
29
+ }
22
30
  });
23
31
  capacitor.command('open <platform>')
24
32
  .description('Abre el proyecto nativo en Android Studio o Xcode')
@@ -64,6 +72,54 @@ function isHttpsUrl(value) {
64
72
  return false;
65
73
  }
66
74
  }
75
+ function configureExistingPlatforms(root) {
76
+ if (existsSync(join(root, 'android'))) {
77
+ configureNativePlatform(root, 'android');
78
+ }
79
+ }
80
+ function configureNativePlatform(root, platform) {
81
+ if (platform === 'android') {
82
+ configureMinimumAndroidSdk(root);
83
+ configureBackgroundRunnerForAndroid(root);
84
+ }
85
+ }
86
+ function configureMinimumAndroidSdk(root) {
87
+ const packageJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
88
+ if (!packageJson.dependencies?.['@capacitor/local-llm'])
89
+ return;
90
+ const variablesPath = join(root, 'android', 'variables.gradle');
91
+ if (!existsSync(variablesPath)) {
92
+ throw new Error('No se encuentra android/variables.gradle para configurar Local LLM.');
93
+ }
94
+ const variables = readFileSync(variablesPath, 'utf8');
95
+ const minimumSdkPattern = /minSdkVersion\s*=\s*(\d+)/;
96
+ const currentMinimumSdk = Number(minimumSdkPattern.exec(variables)?.[1]);
97
+ if (!Number.isFinite(currentMinimumSdk)) {
98
+ throw new Error('No se ha encontrado minSdkVersion en android/variables.gradle.');
99
+ }
100
+ if (currentMinimumSdk >= 28)
101
+ return;
102
+ writeFileSync(variablesPath, variables.replace(minimumSdkPattern, 'minSdkVersion = 28'), 'utf8');
103
+ }
104
+ function configureBackgroundRunnerForAndroid(root) {
105
+ const packageJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
106
+ if (!packageJson.dependencies?.['@capacitor/background-runner'])
107
+ return;
108
+ const gradlePath = join(root, 'android', 'app', 'build.gradle');
109
+ if (!existsSync(gradlePath)) {
110
+ throw new Error('No se encuentra android/app/build.gradle para configurar Background Runner.');
111
+ }
112
+ const repositoryEntry = "dirs '../../node_modules/@capacitor/background-runner/android/src/main/libs', 'libs'";
113
+ const gradle = readFileSync(gradlePath, 'utf8');
114
+ if (gradle.includes(repositoryEntry))
115
+ return;
116
+ const flatDirectory = /flatDir\s*\{/;
117
+ if (!flatDirectory.test(gradle)) {
118
+ throw new Error('No se ha encontrado el bloque flatDir en android/app/build.gradle.');
119
+ }
120
+ const configuredGradle = gradle.replace(flatDirectory, (match) => `${match}\n ${repositoryEntry}`);
121
+ writeFileSync(gradlePath, configuredGradle, 'utf8');
122
+ }
67
123
  function runCapacitor(root, args) {
68
124
  if (!existsSync(join(root, 'capacitor.config.ts'))) {
69
125
  throw new Error('Esta versión de shell no incluye Capacitor. Usa una shell v0.1.2 o posterior.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mova/cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "CLI para crear y mantener aplicaciones Open Mova",
5
5
  "license": "MIT",
6
6
  "author": "Open Mova contributors",