@open-mova/cli 0.1.10 → 0.1.12
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/commands/build.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
4
|
import { readApplicationConfiguration, requireApplicationRoot, } from '../application/configuration.js';
|
|
5
|
+
import { npmCommand, useCommandShell } from '../utils/platform.js';
|
|
5
6
|
export function registerBuildCommand(program) {
|
|
6
7
|
program
|
|
7
8
|
.command('build')
|
|
@@ -24,9 +25,10 @@ export function registerBuildCommand(program) {
|
|
|
24
25
|
}
|
|
25
26
|
function runBuild(directory, label) {
|
|
26
27
|
console.log(`Compilando ${label}...`);
|
|
27
|
-
const result = spawnSync(
|
|
28
|
+
const result = spawnSync(npmCommand(), ['run', 'build'], {
|
|
28
29
|
cwd: directory,
|
|
29
30
|
stdio: 'inherit',
|
|
31
|
+
shell: useCommandShell(),
|
|
30
32
|
});
|
|
31
33
|
if (result.status !== 0) {
|
|
32
34
|
throw new Error(`La compilación de ${label} no ha finalizado correctamente.`);
|
|
@@ -2,6 +2,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { existsSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { readApplicationConfiguration, requireApplicationRoot, } from '../application/configuration.js';
|
|
5
|
+
import { localBinaryName, npmCommand, useCommandShell } from '../utils/platform.js';
|
|
5
6
|
export function registerCapacitorCommands(program) {
|
|
6
7
|
const capacitor = program.command('cap').description('Prepara la shell para Android o iOS');
|
|
7
8
|
capacitor.command('add <platform>')
|
|
@@ -38,7 +39,7 @@ function buildMobileShell(root) {
|
|
|
38
39
|
}
|
|
39
40
|
const configuration = readApplicationConfiguration(root);
|
|
40
41
|
const manifest = createProductionManifest(configuration);
|
|
41
|
-
run(root,
|
|
42
|
+
run(root, npmCommand(), ['run', 'build']);
|
|
42
43
|
const webDirectory = join(root, 'dist', 'browser');
|
|
43
44
|
if (!existsSync(join(webDirectory, 'index.html'))) {
|
|
44
45
|
throw new Error(`No se encuentra la shell compilada en ${webDirectory}.`);
|
|
@@ -67,14 +68,18 @@ function runCapacitor(root, args) {
|
|
|
67
68
|
if (!existsSync(join(root, 'capacitor.config.ts'))) {
|
|
68
69
|
throw new Error('Esta versión de shell no incluye Capacitor. Usa una shell v0.1.2 o posterior.');
|
|
69
70
|
}
|
|
70
|
-
const binary = join(root, 'node_modules', '.bin', 'cap');
|
|
71
|
+
const binary = join(root, 'node_modules', '.bin', localBinaryName('cap'));
|
|
71
72
|
if (!existsSync(binary)) {
|
|
72
73
|
throw new Error('Instala las dependencias de la aplicación con npm install.');
|
|
73
74
|
}
|
|
74
75
|
run(root, binary, args);
|
|
75
76
|
}
|
|
76
77
|
function run(root, command, args) {
|
|
77
|
-
const result = spawnSync(command, args, {
|
|
78
|
+
const result = spawnSync(command, args, {
|
|
79
|
+
cwd: root,
|
|
80
|
+
stdio: 'inherit',
|
|
81
|
+
shell: useCommandShell(),
|
|
82
|
+
});
|
|
78
83
|
if (result.error) {
|
|
79
84
|
throw result.error;
|
|
80
85
|
}
|
package/dist/commands/start.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { readApplicationConfiguration, requireApplicationRoot, } from '../application/configuration.js';
|
|
5
|
+
import { npmCommand, useCommandShell } from '../utils/platform.js';
|
|
5
6
|
export function registerStartCommand(program) {
|
|
6
7
|
program
|
|
7
8
|
.command('start')
|
|
@@ -34,9 +35,10 @@ export function registerStartCommand(program) {
|
|
|
34
35
|
async function startProjects(projects) {
|
|
35
36
|
const children = projects.map(({ directory, label }) => {
|
|
36
37
|
console.log(`- ${label}: ${directory}`);
|
|
37
|
-
return spawn(
|
|
38
|
+
return spawn(npmCommand(), ['run', 'start'], {
|
|
38
39
|
cwd: directory,
|
|
39
40
|
stdio: 'inherit',
|
|
41
|
+
shell: useCommandShell(),
|
|
40
42
|
});
|
|
41
43
|
});
|
|
42
44
|
const stopChildren = () => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function npmCommand() {
|
|
2
|
+
return process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
3
|
+
}
|
|
4
|
+
export function localBinaryName(name) {
|
|
5
|
+
return process.platform === 'win32' ? `${name}.cmd` : name;
|
|
6
|
+
}
|
|
7
|
+
export function useCommandShell() {
|
|
8
|
+
return process.platform === 'win32';
|
|
9
|
+
}
|