optikit 1.2.2 → 1.2.3
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/USAGE.md +1 -1
- package/dist/commands/config/init.js +1 -1
- package/dist/utils/services/exec.js +24 -0
- package/dist/utils/validators/validation.js +3 -3
- package/package.json +1 -1
- package/src/commands/config/init.ts +1 -1
- package/src/utils/services/exec.ts +29 -0
- package/src/utils/validators/validation.ts +3 -3
package/USAGE.md
CHANGED
|
@@ -57,6 +57,30 @@ export async function execCommand(command) {
|
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
+
export async function execCommandSilent(command) {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
const fullCommand = `${command}`;
|
|
63
|
+
const process = spawn(fullCommand, { shell: true });
|
|
64
|
+
let output = "";
|
|
65
|
+
process.stdout.on("data", (data) => {
|
|
66
|
+
output += data.toString();
|
|
67
|
+
});
|
|
68
|
+
process.stderr.on("data", (data) => {
|
|
69
|
+
output += data.toString();
|
|
70
|
+
});
|
|
71
|
+
process.on("close", (code) => {
|
|
72
|
+
if (code !== 0) {
|
|
73
|
+
reject(new Error(`Command failed with exit code ${code}`));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolve(output);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
process.on("error", (err) => {
|
|
80
|
+
reject(new Error(`Failed to start subprocess: ${err.message}`));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
60
84
|
export async function execInIos(command) {
|
|
61
85
|
return new Promise((resolve, reject) => {
|
|
62
86
|
const fullCommand = `cd "${iosDirectory}" && ${command}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { execCommandSilent } from "../services/exec.js";
|
|
4
4
|
import { LoggerHelpers } from "../services/logger.js";
|
|
5
5
|
export { validateFlutterProject, validateFlutterSdk, validateIosProject, validateAndroidProject, checkFileExists, };
|
|
6
6
|
/**
|
|
@@ -36,12 +36,12 @@ async function validateFlutterSdk(useFvm = false) {
|
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
// Check if fvm command is available
|
|
39
|
-
await
|
|
39
|
+
await execCommandSilent("fvm --version");
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
// Check if global Flutter is available
|
|
44
|
-
await
|
|
44
|
+
await execCommandSilent("flutter --version");
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -73,6 +73,35 @@ export async function execCommand(command: string): Promise<string> {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
export async function execCommandSilent(command: string): Promise<string> {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const fullCommand = `${command}`;
|
|
79
|
+
const process = spawn(fullCommand, { shell: true });
|
|
80
|
+
|
|
81
|
+
let output = "";
|
|
82
|
+
|
|
83
|
+
process.stdout.on("data", (data) => {
|
|
84
|
+
output += data.toString();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
process.stderr.on("data", (data) => {
|
|
88
|
+
output += data.toString();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
process.on("close", (code) => {
|
|
92
|
+
if (code !== 0) {
|
|
93
|
+
reject(new Error(`Command failed with exit code ${code}`));
|
|
94
|
+
} else {
|
|
95
|
+
resolve(output);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
process.on("error", (err) => {
|
|
100
|
+
reject(new Error(`Failed to start subprocess: ${err.message}`));
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
76
105
|
export async function execInIos(command: string): Promise<string> {
|
|
77
106
|
return new Promise((resolve, reject) => {
|
|
78
107
|
const fullCommand = `cd "${iosDirectory}" && ${command}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { execCommandSilent } from "../services/exec.js";
|
|
4
4
|
import { LoggerHelpers } from "../services/logger.js";
|
|
5
5
|
|
|
6
6
|
export {
|
|
@@ -49,11 +49,11 @@ async function validateFlutterSdk(useFvm: boolean = false): Promise<boolean> {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// Check if fvm command is available
|
|
52
|
-
await
|
|
52
|
+
await execCommandSilent("fvm --version");
|
|
53
53
|
return true;
|
|
54
54
|
} else {
|
|
55
55
|
// Check if global Flutter is available
|
|
56
|
-
await
|
|
56
|
+
await execCommandSilent("flutter --version");
|
|
57
57
|
return true;
|
|
58
58
|
}
|
|
59
59
|
} catch (error) {
|