cispacempt-v2 0.0.5 → 0.0.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +45 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "main": "src/index.js",
3
3
  "name": "cispacempt-v2",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "description": "Fast CI engine for CodespaceMPT with script stages and file system hooks",
6
6
  "author": "argentidev",
7
7
  "license": "MIT",
package/src/index.js CHANGED
@@ -2,6 +2,7 @@ const path = require("path"),
2
2
  os = require("os"),
3
3
  fs = require("fs"),
4
4
  { spawn } = require("child_process"),
5
+ yaml = require("js-yaml"),
5
6
  getCPUUsageSnapshot = function () {
6
7
  const cpus = os.cpus();
7
8
  return cpus.map(cpu => ({ ...cpu.times }));
@@ -108,6 +109,49 @@ module.exports = {
108
109
  });
109
110
  };
110
111
 
112
+ const findFileInMap = function (fileSystem, searchFilePath) {
113
+ const pathParts = searchFilePath.split("/");
114
+ let currentMap = fileSystem;
115
+
116
+ for (let i = 0; i < pathParts.length; i++) {
117
+ const part = pathParts[i];
118
+
119
+ if (currentMap[part]) {
120
+ if (typeof currentMap[part] === "object") {
121
+ currentMap = currentMap[part];
122
+ } else {
123
+ return currentMap[part]; // Return the found file if it exists
124
+ }
125
+ } else {
126
+ return null; // Return null if not found at all
127
+ }
128
+ }
129
+
130
+ return null; // Return null if path doesn't exist
131
+ }
132
+
133
+ if (ciScript.include) {
134
+ for (const includePath of ciScript.include) {
135
+ const templateContent = findFileInMap(fileSystem, includePath);
136
+ if (!templateContent) {
137
+ console.warn(`Included file '${includePath}' not found`);
138
+ continue;
139
+ }
140
+
141
+ const includedYaml = yaml.load(templateContent);
142
+
143
+ // Merge included content
144
+ ciScript.stages = {
145
+ ...(includedYaml.stages || {}),
146
+ ...(ciScript.stages || {})
147
+ };
148
+ ciScript.env = {
149
+ ...(includedYaml.env || {}),
150
+ ...(ciScript.env || {}),
151
+ };
152
+ }
153
+ }
154
+
111
155
  for (const stage of stages) {
112
156
  extensionSystem.runPreExecution(stage.name); // <-- pre execution hook
113
157
 
@@ -191,6 +235,7 @@ module.exports = {
191
235
  }
192
236
  }
193
237
 
238
+ console.log(successIn, errorIn);
194
239
  const finalResultEndTime = Date.now();
195
240
  timeTaken = convertMsToSec(finalResultEndTime - startTime);
196
241
  const cpuEnd = getCPUUsageSnapshot();