cispacempt-v2 0.0.8 → 0.1.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/package.json +1 -1
- package/src/index.js +28 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -85,6 +85,32 @@ const path = require("path"),
|
|
|
85
85
|
fs.writeFileSync(filePath, fileSystem[file]);
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
+
},
|
|
89
|
+
detectAvailableProotOSID = () => {
|
|
90
|
+
const baseDir = path.resolve(__dirname); // o __dirname donde esté el código
|
|
91
|
+
const entries = fs.readdirSync(baseDir, { withFileTypes: true });
|
|
92
|
+
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (entry.isDirectory() && entry.name.startsWith("rootfs-")) {
|
|
95
|
+
const osReleasePath = path.join(baseDir, entry.name, "etc", "os-release");
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
const content = fs.readFileSync(osReleasePath, "utf8");
|
|
99
|
+
const match = content.match(/^ID="?([\w\-]+)"?/m);
|
|
100
|
+
|
|
101
|
+
if (match) {
|
|
102
|
+
return {
|
|
103
|
+
id: match[1], // ej. "debian", "alpine"
|
|
104
|
+
rootfsPath: path.join(baseDir, entry.name), // ruta completa
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
} catch (_) {
|
|
108
|
+
// No es un rootfs válido, seguimos con el siguiente
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return null; // No se encontró ninguno válido
|
|
88
114
|
}, { extensionSystem } = require("./extension");
|
|
89
115
|
|
|
90
116
|
// Export as a Node JS module
|
|
@@ -188,7 +214,7 @@ module.exports = {
|
|
|
188
214
|
await new Promise(async (res) => {
|
|
189
215
|
const commandToRun = resolvedCommand;
|
|
190
216
|
let finalCommand;
|
|
191
|
-
if (ciScript.os && Object.keys(require("
|
|
217
|
+
if (ciScript.os && Object.keys(require("./lib/prootEnv").prepareProotEnv.rootfsMap || {}).includes(ciScript.os)) {
|
|
192
218
|
const { prootBin, rootfsDir } = await prepareProotEnv(ciScript.os, path.join(__dirname, "ci_proot_cache"));
|
|
193
219
|
|
|
194
220
|
finalCommand = `${prootBin} -R ${rootfsDir} -b ${tempDir}:/sandbox -w /sandbox /bin/sh -c "${commandToRun.replace(/"/g, '\\"')}"`;
|
|
@@ -260,6 +286,7 @@ module.exports = {
|
|
|
260
286
|
name: os.platform(),
|
|
261
287
|
version: os.release(),
|
|
262
288
|
arch: os.arch(),
|
|
289
|
+
id: detectAvailableProotOSID()?.id || 'ubuntu',
|
|
263
290
|
},
|
|
264
291
|
errorIn: errorIn.length > 0 ? errorIn : null,
|
|
265
292
|
successIn: successIn.length > 0 ? successIn : null,
|